akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,ans=1;
  R n;
  rep(i,n) {
    ll x;
    R x;
    ans=ans/__gcd(ans,x)*x;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
	int N, Q;
	ll T;
	cin >> N >> T >> Q;
	vector<ll> A(N), D(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> D[i];
	}
	vector<ll> pos;
	for (int i = 1; i < N; i++) {
		if (D[i - 1] == 1 && D[i] == 2) {
			pos.push_back((A[i - 1] + A[i]) / 2);
		}
	}
	while (Q--) {
		int X;
		cin >> X; X--;
		if (D[X] == 1) {
			int id = lower_bound(pos.begin(), pos.end(), A[X]) - pos.begin();
			if (id == (int)pos.size()) {
				printf("%lld\n", A[X] + T);
			}
			else {
				printf("%lld\n", min(A[X] + T, pos[id]));
			}
		}
		else {
			int id = upper_bound(pos.begin(), pos.end(), A[X]) - pos.begin() - 1;
			if (id == -1) {
				printf("%lld\n", A[X] - T);
			}
			else {
				printf("%lld\n", max(A[X] - T, pos[id]));
			}
		}
	}
	return 0;
}



Measured memory_bytes: 4660
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    vector<int> p(n, 0);
    for(int i=0; i<m; i++){
        int k;
        cin >> k;
        for(int j=0; j<n; j++){
            if(k >= a[j]){
                p[j]++;
                break;
            }
        }
    }

    int ans = 0;
    for(int i=0; i<n; i++){
        if(p[i] > p[ans]){
            ans = i;
        }
    }
    cout << ans +1 << endl;
    return 0;
}



Measured memory_bytes: 3104
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func match(s, t string) bool {
	for i := 0; i < len(s); i++ {
		if s[i] != t[i] {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)
	N := getInt()
	s := getString()
	t := getString()

	for i := 0; i < N; i++ {
		if match(s[i:], t) {
			out(len(s[:i] + t))
			return
		}
	}
	out(len(s + t))
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<long long int> point(m);
  for(int i=0;i<m;i++) cin >> point[i];
  sort(point.begin(), point.end());

  if(n == 1) {
    cout << point[m-1] - point[0] << endl;
  } else {
    if(n >= m) {
      cout << 0 << endl;
    } else {
      vector<long long int> distance(m-1);
      for(int i=0;i<m-1;i++) {
        distance[i] = point[i+1] - point[i];
      }
    
      sort(distance.begin(), distance.end());

      long long int total = 0;
      for(int i=0;i<n-1;i++) {
        total += distance[m-2-i];
      }

      long long int ans = point[m-1] - point[0] - total;

      cout << ans << endl;
    }
  }
}


Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)

n = int(input())
a = list(map(int, input().split()))

a_origin = a[:]

min_a = min(a)
min_a_index = a.index(min_a)
max_a = max(a)
max_a_index = a.index(max_a)

ans = []
if min_a < 0 and max_a > 0:

    if abs(min_a) > abs(max_a):
        a_new = []
        for i in range(len(a)):
            if a[i] > 0:
                a_new.append(a[i]+min_a)
                ans.append((min_a_index+1, i+1))
            else:
                a_new.append(a[i])
    else:
        a_new = []
        for i in range(len(a)):
            if a[i] < 0:
                a_new.append(a[i]+max_a)
                ans.append((max_a_index+1, i+1))
            else:
                a_new.append(a[i])

    # print(a_new)
    # print(ans)
    a = a_new

min_a = min(a)
max_a = max(a)

if min_a >= 0 and max_a >= 0:
    a_new = [a[0]]
    for i in range(1, len(a)):
        a_new.append(a[i]+a_new[-1])
        ans.append((i-1+1, i+1))
elif min_a <= 0 and max_a <= 0:
    a_new = [a[-1]]
    for i in reversed(range(0, len(a)-1)):
        a_new.append(a[i]+a_new[-1])
        ans.append((i+1+1, i+1))
    a_new = list(reversed(a_new))

# print(a_new)
# print(ans)
print(len(ans))
for i in ans:
    print(*i)


# for i, j in ans:
#     a_origin[j-1] += a_origin[i-1]
# print(a_new)
# print(a_origin)


Measured memory_bytes: 9184
#include <iostream>
#include <algorithm>
using namespace std;
#define MAX 101

int main(){
    int n,q;
    
    while(cin >> n >> q ,n+q){
        int flg = 0 , cnt[MAX] , max_n = 0 , m , d;
        fill(cnt,cnt+MAX,0);
        for(int i = 0 ; i < n ; i++){
            cin >> m;
            for(int j = 0 ; j < m ; j++){
                cin >> d;
                ++cnt[d];
                max_n = max(max_n,cnt[d]);
            }
        }
        
        if(max_n >= q) flg = 1;
        
        if(flg){
            int res;
            for(int k = 1 ;; k++){
                if(cnt[k] >= q && cnt[k] == max_n){
                    res = k;
                    break;
                }
            }
            cout << res << endl;
        }
        else cout << flg << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long int ll;
typedef pair<int, int> P;
#define INF 1e9 + 7

//first, secondで昇順ソート
bool compare(P a, P b){
    if(a.first == b.first){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    
    map<char, int> m;
    rep(i,s.size()){
        m[s[i]]++;
    }
    
    bool flag = true;
    for(auto itr=m.begin(); itr!=m.end(); itr++){
        if(flag && itr->second == 2){
            continue;
        }else{
            flag = false;
        }
    }
    
    string ans = "No";
    
    if(flag){
        ans = "Yes";
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if (a+b==c || a+c==b || b+c==a){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
n,a,b,c=map(int,input().split())
l=[0]*n
for i in range(n):
  l[i]=int(input())
fouradic=[0]*n
ret=3000
while fouradic!=([3]*n):
  a_=0
  b_=0
  c_=0
  for i in range(n):
    if fouradic[i]<3:
      fouradic[i]+=1
      break
    fouradic[i]=0
  if not (fouradic.count(1) and fouradic.count(2) and fouradic.count(3)):
    continue
  ret_in=0
  ret_in+=10*(n-fouradic.count(0)-3)
  for i in range(n):
    if fouradic[i]==1:
      a_+=l[i]
    if fouradic[i]==2:
      b_+=l[i]
    if fouradic[i]==3:
      c_+=l[i]
  ret_in+=abs(a-a_)+abs(b-b_)+abs(c-c_)
  ret=min(ret,ret_in)
print(ret)

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 998244353;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

template<class T> class SegmentTree {
    public:
    typedef function<T(T, T)> F;
    size_t n;
    vector<T> data;
    T def;  // 単位元
    T initial_value;    // 初期値
    F update_func;  // 更新用関数
    F find_func;  //クエリ用関数

    SegmentTree(size_t _n, T def, T initial_value, F update_func, F find_func)
        : def(def), initial_value(initial_value), update_func(update_func), find_func(find_func) {
        n = 1;
        while(n < _n) n <<= 1;
        data = vector<T>(2*n-1, initial_value);
    }

    void update(size_t i, T x) {
        i += n-1;
        data[i] = update_func(data[i], x);
        while(i) {
            i = (i-1) / 2;
            data[i] = find_func(data[2*i+1], data[2*i+2]);
        }
    }

    T find(size_t s, size_t t, size_t k, size_t kl, size_t kr) {
        if(kr <= s || t <= kl) return initial_value;
        if(s <= kl && kr <= t) return data[k];
        size_t kc = (kl+kr) / 2;
        T vl = find(s, t, 2*k+1, kl, kc);
        T vr = find(s, t, 2*k+2, kc, kr);
        return find_func(vl, vr);
    }

    T find(size_t s, size_t t) {
        return find(s, t, 0, 0, n);
    }
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    vector<Pll> robots(n);
    for(int i=0;i<n;++i) cin >> robots[i].first >> robots[i].second;
    sort(robots.begin(), robots.end());
    for(int i=0;i<n;++i) {
        cerr << robots[i].first << " " << robots[i].second << endl;
    }


    // 初めて影響が及ばなくなる idx
    SegmentTree<int> ti(
        n+1, 0, 0, 
        [](ll a, ll b) { return b; },
        [](ll a, ll b) { return max(a, b); }
    );
    ll max_sum = -LINF;
    int max_sum_ti = n;
    ti.find(n, n);
    for(int si=n-1;si>=0;--si) {
        max_sum_ti = int(lower_bound(robots.begin()+si, robots.end(), Pll(robots[si].first + robots[si].second, -1LL)) - robots.begin());
        if(max_sum_ti - 1 > si) max_sum_ti = ti.find(si+1, max_sum_ti);
        ti.update(si, max_sum_ti);
    }

    // i 以降を見たとして，最後に起動させたのが i の場合の通り数
    vector<ll> dp(n+1, 0), dpsum(n+1, 0);
    dp[n] = 1;
    dpsum[n] = 1;
    for(int si=n-1;si>=0;--si) {
        dp[si] = dpsum[ti.find(si, si+1)];
        dpsum[si] = (dpsum[si+1] + dp[si]) % MOD;
    }

    cout << dpsum[0] << endl;
}


Measured memory_bytes: 10624
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  int i,memo,t,ans;
  vector<int>array(5);
  for(i=0;i<5;i++){
    cin >> array[i];
  }
  int tmp=10-array[0]%10;
  for(i=0;i<5;i++){
    if(10-array[i]%10>tmp && array[i]%10!=0){
      tmp=10-array[i]%10;
      memo=i;
    }
  }
  t=0;
  ans=0;
  for(i=0;i<5;i++){
    if(i==memo){
      continue;
    }else{
      while(1){
        if(array[i]<=t) break;
        t+=10;
      }
      ans+=t;
      t=0;
    }
  }
  cout << ans+array[memo] << endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func div(a, x int) int {
	if a == 0 {
		return -1
	}
	return (a - 1) / x
}

func main() {
	var a, b, x int
	fmt.Scan(&a, &b, &x)

	fmt.Println(b/x - div(a, x))
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int h=sc.nextInt();
		int w=sc.nextInt();
		char g[][] = new char[h+2][w+2];
		for(int i=0; i<h+2; i++) {
			g[i][0]='.';
			g[i][w+1]='.';
		}
		for(int i=0; i<w+2; i++) {
			g[0][i]='.';
			g[h+1][i]='.';
		}
		for(int i=1; i<=h; i++) {
			String s = sc.next();
			for(int j=1; j<=w; j++) {
				g[i][j]=s.charAt(j-1);
			}
		}

		boolean ok=true;
		for(int i=1; i<=h; i++) {
			for(int j=1; j<=w; j++) {
				if(g[i][j]=='#' && g[i][j+1]=='.' && g[i+1][j]=='.' && g[i][j-1]=='.' && g[i-1][j]=='.') {
					ok=false;
					break;
				}
			}
		}
		if(ok)System.out.println("Yes");
		else System.out.println("No");
		sc.close();
	}
}


Measured memory_bytes: 21972
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

#define fo(i,j,l) for(int i=j;i<=l;++i)
#define fd(i,j,l) for(int i=j;i>=l;--i)

using namespace std;
typedef long long ll;
const ll N=1000,M=N*50,maxn=1e18;

bool bz[N];
int x[N],y[N];
ll v[N];
int la[N],lb[M],ne[M],le[M];
ll cost[M];
int fr[N],f1[N];

int n,m,oo,S,T;
char c[N];
int a[N],b[N],d[M];
int p[N][2],q[N][2];
ll dis[N];
ll rec;

inline ll max(ll a,ll b)
{return a>b?a:b;}

inline int min(int a,int b)
{return a<b?a:b;}

inline void llb(int a,int b,int c,ll co)
{
	ne[++oo]=la[a]; la[a]=oo; lb[oo]=b;
	le[oo]=c; cost[oo]=co; 
}

inline void gg(int a,int b,int c,ll d)
{
	llb(a,b,c,d); llb(b,a,0,-d);
}

inline bool flow()
{
	fo(i,1,T)dis[i]=maxn;
	dis[S]=0;
	int l=0,r=1; d[1]=S; bz[S]=true;
	while(l<r){
		int o=d[++l];
		for(int y=la[o];y;y=ne[y])
		if(dis[o]-cost[y]<dis[lb[y]]&&le[y]==1){
			dis[lb[y]]=dis[o]-cost[y];
			fr[lb[y]]=o; f1[lb[y]]=y;
			if(!bz[lb[y]])d[++r]=lb[y],bz[lb[y]]=true;
		}
		bz[o]=false;
	}
	if(dis[T]==maxn)return false;
	rec=0;
	for(int u=T;u!=S;u=fr[u]){
		int k=f1[u];
		le[k]=0;
		le[k^1]=1;
		rec=rec+cost[k];
	}
	return true;
}

int main()
{
	scanf("%d",&n);
	fo(i,1,n)scanf("%d%d%lld",&x[i],&y[i],&v[i]);
	scanf("%d",&m);
	fo(i,1,m){
		char ch=' ';
		for(;ch!='L'&&ch!='R'&&ch!='D'&&ch!='U';ch=getchar());
		c[i]=ch;
		scanf("%d%d",&a[i],&b[i]);
	}
	ll ans=0;
	fo(i,1,n){
		fo(l,1,i)p[l][0]=1,p[l][1]=100;
		fo(l,1,i)q[l][0]=1,q[l][1]=100;
		fo(l,1,m)
		if(c[l]=='L'&&b[l]<i){
			fo(j,b[l]+1,i)p[j][0]=max(p[j][0],a[l]+1);
		} else if(c[l]=='R'&&b[l]<i){
			fo(j,1,i-b[l])p[j][1]=min(p[j][1],a[l]-1);
		} else if(c[l]=='U'&&b[l]<i){
			fo(j,1,i-b[l])q[j][1]=min(q[j][1],a[l]-1);
		} else if(c[l]=='D'&&b[l]<i){
			fo(j,b[l]+1,i)q[j][0]=max(q[j][0],a[l]+1);
		}
		int ok=0;
		fo(l,1,i)if(p[l][0]>p[l][1]||q[l][0]>q[l][1]){ok=1; break;}
		if(ok)continue;
		oo=1;
		S=2*i+200+1,T=S+1;
		fo(j,1,T)la[j]=0;
		fo(l,1,i)gg(S,l,1,0);
		fo(l,1,i)gg(i+200+l,T,1,0);
		fo(j,1,i)fo(l,p[j][0],p[j][1])gg(j,i+l,1,0);
		fo(j,1,i)fo(l,q[j][0],q[j][1])gg(100+i+l,200+i+j,1,0);
		fo(l,1,n)gg(i+x[l],i+100+y[l],1,v[l]);
		ll da=0; int cs=0;
		while(flow()){
			da=da+rec;
			++cs;
		}
		if(cs==i)ans=max(ans,da);
	}
	cout<<ans;
}

Measured memory_bytes: 768
#include<iostream>
using namespace std;

int main() {
	int i, N;
	int A[100];

	cin >> N;
	for (i = 0; i < N; i++)
		cin >> A[i];

	int max = A[0], min = A[0];
	for (i = 0; i < N; i++) {
		if (A[i] > max)
			max = A[i];
		if (A[i] < min)
			min = A[i];
	}

	cout << max - min << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
		int N;
		cin >> N;
		vector<int> A(N);
		for (int i = 0; i < N; i++) {
				cin >> A[i];
				A[i] -= i+1;
		}

		sort(A.begin(), A.end());
		int c = A[N/2];
		ll ans = 0;
		for (int i = 0; i  < N; i++) {
				ans += abs(A[i] - c);
		}

		cout << ans << endl;
		return 0;
}


Measured memory_bytes: 1024
N=int(input())
S=[]
for i in range(N):
    S.append(int(input()))


maximum_point=-10**10
minv=S[0]

for i in range(N-1):
    maximum_point=max(maximum_point,S[i+1]-minv)
    minv=min(minv,S[i+1])

print(maximum_point)


Measured memory_bytes: 13592
#include <bits/stdc++.h>
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
using namespace std;

int main() {
  double a, b, x;
  double c;
  cin >> a >> b >> x;
  x = x / a;
  if(x >= (a * b) / 2) {
    c = b - ((x * 2) / a - b);
    cout << setprecision(10) << 90 - atan(a / c) / M_PI * 180 << endl;
  } else {
    c = (x * 2) / b;
    cout << setprecision(10) << 90 - atan(c / b) / M_PI * 180 << endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

const int MOD = 998244353;

long long solve(const vector<int>& a){
	long long res = 0;
	int value = 0;
	for(int i=a.size()-1;i>=0;i--){
		value = max(0, value - 1);
		if(a[i] < value) return -1;
		if(a[i] > value){
			res += a[i];
			value = a[i];
		}
	}
	if(value > 0) return -1;
	return res;
}

int main(){
	vector<long long> inv(300002);
	vector<long long> fact(300002);
	vector<long long> factInv(300002);
	for(int i=0;i<2;i++) inv[i] = fact[i] = factInv[i] = 1;
	for(int i=2;i<=300001;i++){
		inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
		fact[i] = fact[i-1] * i % MOD;
		factInv[i] = factInv[i-1] * inv[i] % MOD;
	}
	auto comb = [&](int n, int r){
		if(n < r) return 0LL;
		return fact[n] * factInv[n-r] % MOD * factInv[r] % MOD;
	};

	int N;
	long long A, B, K;
	while(cin >> N >> A >> B >> K){
		long long numA = 0, numB = N;
		long long sum = B * N;
		long long res = 0;
		while(true){
			if(sum == K){
				res += comb(N, numA) * comb(N, numB);
				res %= MOD;
				--numB; sum -= B;
				++numA; sum += A;
			} else if(sum > K){
				--numB; sum -= B;
			} else {
				++numA; sum +=A;
			}
			if(numB < 0 || numA > N) break;
		}
		cout << res << endl;
	}
}


Measured memory_bytes: 7296
#include <iostream>

using namespace std;

int main()
{
    int N, M, K;
    bool flag = false;
    cin >> N >> M >> K;
    for (int i = 0; i <= N; i++)
    {
        for (int j = 0; j <= M; j++)
        {
            if (K == (N - i) * j + (M - j) * i)
            {
                flag = true;
                break;
            }
        }
        if (flag) break;
    }
    string S;
    cin >> S;
    cout << (flag ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())

s = []
check = 0

for _ in range(h):
    s.append(input())

for i in range(h):
    for j in range(w):
        up = 0
        left = 0
        right = 0
        down = 0

        if s[i][j] == ".":
            pass
        else:
            if i == 0:
                up = 0
                if s[i+1][j] == "#":
                    down = 1
            elif i == h-1:
                down == 0
                if s[i-1][j] == "#":
                    up = 1
            else:
                if s[i-1][j] == "#":
                    up = 1
                if s[i+1][j] == "#":
                    down = 1
            if j == 0:
                left = 0
                if s[i][j+1] == "#":
                    right = 1
            elif j == w-1:
                right = 0
                if s[i][j-1] == "#":
                    left = 1
            else:
                if s[i][j-1] == "#":
                    left = 1
                if s[i][j+1] == "#":
                    right = 1

            if up+left+right+down == 0:
                check = 1

if check:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define N 5000005
using namespace std;
int n,ans;char s1[N],s2[N],s3[N];
int main(){
	scanf("%d",&n);
	scanf("%s%s%s",s1+1,s2+1,s3+1);
	for (int i=1;i<=n;i++){
		if (s1[i]==s2[i]||s1[i]==s3[i]||s2[i]==s3[i]){
			if (s1[i]==s2[i]&&s2[i]==s3[i]) continue;
			else ans++;
		}
		else ans+=2;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4352
<?php /*atcoder.php*/

$at = new Atcoder();
$at->main();
unset($at);

class Atcoder{
	private function breakIn(){
		$buf = str_split($this->killNewLine(fgets(STDIN)));
		return $buf;
	}
	private function killNewLine($buf = null){
		$buf = str_replace("\r\n", "", $buf);
		$buf = str_replace("\n", "", $buf);
		$buf = str_replace("\r", "", $buf);
		return $buf;
	}

	public function main(){
		$s = $this->breakIn();
		
		$ans = 0;
		foreach ($s as $v){
			switch ($v){
				case ("+"):
					$ans++;
				break;
				case ("-"):
					$ans--;
				break;
				default:
				break;
			}
		}
		unset($v);

		echo $ans;
	}
}
?>


Measured memory_bytes: 4856
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <array>
#include <utility>
#include <queue>
#include <tuple>
#include <map>
#include <cctype>
using namespace std;
using ll = long long;
using VI = vector<int>;

int main()
{
    int n; cin >> n;
    int a = n % 10;
    if (a == 2 || a == 4 || a == 5 || a == 7 || a == 9) {
        cout << "hon\n";
    }
    else if (a == 0 || a == 1 || a == 6 || a == 8) {
        cout << "pon\n";
    }
    else if (a == 3) {
        cout << "bon\n";
    }

    return 0;
}


Measured memory_bytes: 3584
#include <cstdio>
#include <algorithm>

int fie[5][5];

int check(int a,int b,int c,int d){
	for(int i=a;i<=b;i++){
		for(int j=c;j<=d;j++){
			if(fie[i][j]==0)return -1;
		}
	}
	return (b-a+1)*(d-c+1);
}

int main(void){
	int data;
	scanf("%d",&data);
	for(int ddd=0;ddd<data;ddd++){
		for(int i=0;i<5;i++){
			for(int j=0;j<5;j++){
				scanf("%d",&fie[j][i]);
			}
		}
		int cnt=0;
		for(int i=0;i<5;i++){
			for(int j=i;j<5;j++){
				for(int k=0;k<5;k++){
					for(int l=k;l<5;l++){
						cnt=std::max(cnt,check(i,j,k,l));
					}
				}
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    ll k;
    cin >> s >> k;
    for (int i = 0; i < k; ++i) {
      if (s[i] >= '2') {
        cout << s[i] << '\n';
        return 0;
      }
    }
    cout << '1' << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define pb push_back
typedef pair<int,int> pr;
template <typename T>
T FindMax(T a,T b){
	return a>b?a:b;
}
int main() {
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll abmin=min(a,b);
	ll abmax=max(a,b);
	ll cdmin=min(c,d);
	ll cdmax=max(c,d);
	ll res1=abmin*cdmin;
	ll res2=abmax*cdmax;
	ll res3=abmax*cdmin;
	ll res4=abmin*cdmax;
	cout<<max(max(res1,res2),max(res3,res4));
	return 0;
}

Measured memory_bytes: 3592
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map(String::toLong)
    val nd = n.toDouble()
    val two = (1..20).map { Math.pow(2.0, it.toDouble()) }
    var ans = 0.0
    for (i in 1..n) {
        if (i >= k) {
            ans += 1.0 / nd
        }else{
            for(j in 0..19){
                if(i*two[j]>=k){
                    ans+= 1 / (nd * two[j])
                    break
                }
            }
        }
    }
    println(ans)
}

Measured memory_bytes: 36292
#include <iostream>
#include <math.h>
#include <string>

using namespace std;

int main(){
	int N;
	cin >> N;
	
	int box[56] = {};

	int idx = 0;
	for(int i = 31; i <= 55555 && idx <= 55; i += 30){
		bool l = true;
		for(int j = 3; j <= sqrt(i); j += 2){
			if(i % j == 0){
				l = false;
				break;
			}
		}
		if(l) box[idx++] = i;
	}

	for(int i = 0; i < N - 1; ++i){
		cout << box[i] << " ";
	}
	cout << box[N - 1] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>

#define lb push_back
typedef long long ll;
using namespace std;
const int maxn = 1e6+5;

int k[3][3];
int w[3][3];
int main()
{
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++)
            cin >> k[i][j];
    }
    int n, a; cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a;
        for(int j = 0; j < 3; j++){
        for(int q = 0; q < 3; q++)
            if(k[j][q]==a) w[j][q] = 1;
    }
    }
    int flag = 0;
    for(int i = 0; i < 3; i++) {
        if(w[i][0]&&w[i][1]&&w[i][2]) {
            flag = 1;
            break;
        }
    }
    if(!flag) {
        for(int i = 0; i < 3; i++) {
            if(w[0][i]&&w[1][i]&&w[2][i]) {
            flag = 1;
            break;
        }
        }
    }
    if(!flag) {
        if(w[0][0]&&w[1][1]&&w[2][2]) flag = 1;
        if(w[0][2]&&w[1][1]&&w[2][0]) flag = 1;
    }
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(int i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(int i=x;i<=y;i++)
#define INF 1000000000005
using namespace std;

ll n,m,ar[N],sum;



int main()
{
	fast;
	cin>>n;
	if(n==1)
	{
		return cout<<"1.0000000000",0;
	}
	if(n%2==1)
	{
		double a=(n/2+1)/(double)n;
		return cout<<a,0;
	}
	cout<<"0.5000000000";

}



/*     cd onedrive\desktop\kod
cls

Sinav:21-22 aralik
Aciklama: Muhtemelen 25 aralik
*/

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int solve(int n, int s, int k);
int main(){
  int n,s;
  while(cin >>n>>s,n||s){
    int ans = 0;
    for(int i=0; i<10; i++){
      if(s>=i) ans+=solve(n-1,s-i,i);
    }
    cout <<ans<<endl;
  }
  return 0;
}
int solve(int n, int s, int k){
  int ans = 0;
  if(n == 0 && s == 0) return 1;
  else if(n>0){
    for(int i=k+1; i<10; i++){
      if(s>=i) ans+=solve(n-1,s-i,i);
      else break;
    }
  }
  return ans;
}

Measured memory_bytes: 1160
def loop_pow(x,n,mod):
    if n==0:
        return 1
    if n%2==0:
        t=loop_pow(x,n//2,mod)
        return (t*t)%mod
    return x*loop_pow(x,n-1,mod)%mod

def com(N,K,mod):
    n=N
    k=K
    up=1
    down=1
    for _ in range(K):
        up*=n
        up%=mod
        n-=1
    for _ in range(K):
        down*=k
        down%=mod
        k-=1
    down=loop_pow(down,10**9+5,mod)
    return up*down%mod

def main():
    N,a,b=map(int,input().split())
    mod=10**9+7
    t=(loop_pow(2,N,mod)-1-com(N,a,mod)-com(N,b,mod))%mod
    print(t)

if __name__=="__main__":
    main()

Measured memory_bytes: 3064
#include <iostream>
#include<algorithm>
#include <string>
using namespace std;
typedef long long ll;

//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

int main(int argc, char *argv[]) {

  char s;
  cin >> s;

   if (isupper(s))
   {
       cout << "A" << endl;
   }
   else
   {
       cout << "a" << endl;
   }

  return 0;
}

Measured memory_bytes: 3632
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
uniqu=array(101,0,3)
nums=array(N)
N.times do|i|
    nums[i]=get_i
    nums[i].each_with_index do|n,i|
        uniqu[i][n]+=1
    end
end
N.times do|i|
  ans=0
  nums[i].each_with_index do|n,i|
    ans+=n if uniqu[i][n]==1
  end
  puts ans
end


Measured memory_bytes: 6876
#include <iostream>

using namespace std;

int main(){
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    while(cin >> K){
        cout << a[K-1] << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	string N;cin>>N;
 	int ans=0;
 	ans += (N[0]-'0')-1;
 	ans += 9 * (N.size() - 1);
 	int tmp = 0;
    for(int i=0;i<N.size();++i){
		tmp += N[i] - '0';
    }
 	cout << max(tmp,ans) << endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>

using namespace std;

int main() {
  int m, d;
  cin >> m >> d;
  if (m < 4 || d < 22) {
    cout << 0 << endl;
    return 0;
  }
  int p = 0, d1, d10;
  for (int i = 4; i<=m; i++){
    for (int j = 22; j<=d; j++) {
      d1 = j%10;
      if (d1 > 1) {
        d10 = j/10;
        if (d1*d10 == i) {
          p++;
        }
      }
    }
  }
  cout << p << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define pli pair<ll, int>

const long long INF = 1LL<<60;
const int inf = 1 << 30;
const int mod = 1e9+7;


template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


vector<pair<ll, int>> factrized(ll num){
  vector<pair<ll, int>>  res;
 
  for(ll i = 2; i * i <= num; i++){
    if(num % i)continue;
    res.emplace_back(i, 0);
    while(num % i == 0){
      num /= i;
      res.back().second++;
    }
  }
  if(num != 1) res.emplace_back(num, 1);
  return res;
}

int main(){
  long long s;
  cin >> s;
  // 0 0 1 1e9
  int x2 = 1e9;
  int y2 = 1;

  int x3 = (x2 - (s % x2)) % x2;
  int y3 = s / x2 + 1;
  if (s % x2 == 0){
    x3 = 0;
    y3 = s / x2;
  }
  printf("%d %d %d %d %d %d\n",0, 0, x2, y2, x3, y3);
}


Measured memory_bytes: 256
from math import ceil
from functools import reduce
print(reduce(lambda x, y: int(ceil(int(ceil(100000 * 1.05 / 1000) * 1000) * 1.05 / 1000) * 1000) if x == 0 else int(ceil(x * 1.05 / 1000) * 1000) , range(int(input()))))

Measured memory_bytes: 8244
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(u) (u).begin(),(u).end()

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

typedef pair<int, int> PII;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

int main()
{
	int N;
	scanf("%d", &N);

	map<int, int> M;
	REP(i, N)
	{
		int P;
		scanf("%d", &P);
		M[P] = M[P - 1] + 1;
	}

	int mx = 1;
	for (const auto &p : M)
		mx = max(mx, p.second);

	printf("%d\n", N - mx);

	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

//read_editorial
int main() {
    string s;cin>>s;
    int n = s.size();
    
    ll ans = 0;
    ll tmp = 0;
    rep(i,n){
        if(s[i]=='B')++tmp;
        else ans+=tmp;
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3748
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <unordered_set>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <map>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 100001
#define PLUS 0
#define MINUS 1

using namespace std;

int main(void)
{
	cin.tie(NULL); ios_base::sync_with_stdio(false);
	ll X, Y; cin >> X >> Y;

	ll ret = 0;
	while (X <= Y)
	{
		ret += 1;
		X += X;
	}
	cout << ret;
	return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <vector>
using namespace std;

int main() {
	cin.tie(false);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;

	vector<int> a(n);
	for(int i = 0; i < n; ++i)
		cin >> a[i];

	vector<vector<long long> > dp(n, vector<long long>(21, 0));
	dp[0][a[0]] = 1;

	for(int i = 0; i < n - 2; ++i) {
		for(int j = 0; j <= 20; ++j) {
			if(j + a[i + 1] <= 20)
				dp[i + 1][j + a[i + 1]] += dp[i][j];

			if(0 <= j - a[i + 1])
				dp[i + 1][j - a[i + 1]] += dp[i][j];
		}
	}

	cout << dp[n - 2][a[n - 1]] << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;

const int MAX = 2001;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1; finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  int n, k;
  cin>>n>>k;
  COMinit();

  for (int i=1; i<=k; i++) {
    long long blue = COM(k-1, i-1);
    long long red = COM(n-k+1, i);
    // cout<<blue<<" "<<red<<endl;
    cout<<(blue * red)%MOD<<endl;
  }
}

Measured memory_bytes: 256
function Main(input) {
    input = input.split('\n');
    var n = parseInt(input[0], 10);
    var testNum = input.slice(1, n+1);
    var mochi = new Set(testNum);
    console.log('%d',mochi.size);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<iostream>
using namespace std;

int main(){
    int N,T;
    cin>>N>>T;
    int minimum_cost,cost_temp,time_temp;
    time_temp=T+1;
    minimum_cost=1001;
    for(int i=0;i<N;i++){
        cin>>cost_temp>>time_temp;
        if(time_temp<=T && cost_temp<=minimum_cost){
            minimum_cost=cost_temp;
        }
    }
    if(minimum_cost>1000){cout<<"TLE"<<endl;}
    else{cout<<minimum_cost<<endl;}
    return 0;
}

Measured memory_bytes: 256
n = int(input())

f = [[] for _ in range(n)]
a = [[] for _ in range(n)]

for i in range(n):
    f[i] = list(map(int, input().split()))

for i in range(n):
    a[i] = list(map(int, input().split()))

ans = -float("inf")
for times in range(1, 1 << 10):
    profit = 0
    for i in range(n):
        cnt = 0
        for j in range(10):
            if times >> j & 1 and f[i][j]:
                cnt += 1
        profit += a[i][cnt]

    ans = max(ans, profit)

print(ans)


Measured memory_bytes: 74288
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
using namespace std;
typedef long long int llint;
typedef vector<int> vint;
typedef vector<llint> vllint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<llint, llint>> vpllint;
#define rep(i,n) for(int i=0;i<n;i++)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define POSSIBLE(ans) if(ans)cout<<"POSSIBLE"<<endl;else cout<<"IMPOSSIBLE"<<endl;

class UnionFind {
public:
	//親の番号を格納する。親だった場合は-(その集合のサイズ)
	vector<int> Parent;

	//作るときはParentの値を全て-1にする
	//こうすると全てバラバラになる
	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	//Aがどのグループに属しているか調べる
	int root(int A) {
		if (Parent[A] < 0) return A;
		return Parent[A] = root(Parent[A]);
	}

	//自分のいるグループの頂点数を調べる
	int size(int A) {
		return -Parent[root(A)];//親をとってきたい
	}

	//AとBをくっ付ける
	bool connect(int A, int B) {
		//AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
		A = root(A);
		B = root(B);
		if (A == B) {
			//すでにくっついてるからくっ付けない
			return false;
		}

		//大きい方(A)に小さいほう(B)をくっ付けたい
		//大小が逆だったらひっくり返しちゃう。
		if (size(A) < size(B)) swap(A, B);

		//Aのサイズを更新する
		Parent[A] += Parent[B];
		//Bの親をAに変更する
		Parent[B] = A;

		return true;
	}
};

bool check(int a, int b) {
	return a > b;

}

int main() {
	int n;
	cin >> n;
	llint x;
	llint cnt = 0;
	rep(i, n) {
		cin >> x;
		while (x % 2 == 0) {
			cnt++;
			x /= 2;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T>
void print(T& x){printf("%d\n", x);}
void printvec(vector<int> a){
    rep(i, a.size()-1){
        printf("%d ", a[i]);
    }
    printf("%d\n", a[a.size()-1]);
}
 
int main()
{
    int n, q;
    cin >> n >> q;
    priority_queue<int> que[n];

    int com, t, x;
    rep(i, q){
        scanf("%d %d", &com, &t);
            if(com==0){
                scanf("%d", &x);
                que[t].push(x);
            }else if(com==1){
                if(que[t].empty()) continue;
                printf("%d\n", que[t].top());
            }else if(com==2){
                if(que[t].empty()) continue;
                que[t].pop();
            }
    }
    return 0;
}


Measured memory_bytes: 4092
import collections


class MaxFlow:
    """Dinic Algorithm: find max-flow
       complexity: O(EV^2)
       used in GRL6A(AOJ)
    """
    class Edge:
        def __init__(self, to, cap, rev):
            self.to, self.cap, self.rev = to, cap, rev

    def __init__(self, V):
        """ V: the number of vertexes
            E: adjacency list
            source: start point
            sink: goal point
        """
        self.V = V
        self.E = [[] for _ in range(V)]

    def add_edge(self, fr, to, cap):
        self.E[fr].append(self.Edge(to, cap, len(self.E[to])))
        self.E[to].append(self.Edge(fr, 0, len(self.E[fr])-1))

    def dinic(self, source, sink, INF=10**9):
        """find max-flow"""
        maxflow = 0
        while True:
            self.bfs(source)
            if self.level[sink] < 0:
                return maxflow
            self.itr = [0] * self.V
            while True:
                flow = self.dfs(source, sink, INF)
                if flow > 0:
                    maxflow += flow
                else:
                    break

    def dfs(self, vertex, sink, flow):
        """find augmenting path"""
        if vertex == sink:
            return flow
        for i in range(self.itr[vertex], len(self.E[vertex])):
            self.itr[vertex] = i
            e = self.E[vertex][i]
            if e.cap > 0 and self.level[vertex] < self.level[e.to]:
                d = self.dfs(e.to, sink, min(flow, e.cap))
                if d > 0:
                    e.cap -= d
                    self.E[e.to][e.rev].cap += d
                    return d
        return 0

    def bfs(self, start):
        """find shortest path from start"""
        que = collections.deque()
        self.level = [-1] * self.V
        que.append(start)
        self.level[start] = 0

        while que:
            fr = que.popleft()
            for e in self.E[fr]:
                if e.cap > 0 and self.level[e.to] < 0:
                    self.level[e.to] = self.level[fr] + 1
                    que.append(e.to)


def main():
    INF = 10 ** 9
    N = int(input())
    A = [int(x) for x in input().split()]
    flow = MaxFlow(N + 2)
    source, sink = N, N + 1
    for i, a in enumerate(A):
        if a >= 0:
            flow.add_edge(source, i, a)
        else:
            flow.add_edge(i, sink, abs(a))
    for i in range(1, N + 1):
        for j in range(i, N + 1):
            if j % i == 0:
                flow.add_edge(j - 1, i - 1, INF)
    cost = flow.dinic(source, sink, INF)
    print(sum(a for a in A if a > 0) - cost)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <iostream>
using namespace std;

int main() {
  int n;
  cin >> n;
  int S[100010];
  for (int i = 0; i < n; i++) cin >> S[i];

  int q;
  cin >> q;

  int C = 0;
  for (int i = 0; i < q; i++) {
    int T;
    cin >> T;
    
    int head = 0, tail = n - 1;
    while (head <= tail) {
      int center = (head + tail) / 2;
      if (S[center] == T) {
        C++;
        break;
      } else if (S[center] < T) {
        head = center + 1;
      } else {
        tail = center - 1;
      }
    }
  }

  cout << C << endl;

  return 0;
}


Measured memory_bytes: 3476
#include<bits/stdc++.h>
using namespace std;

int main(){
    int n=0;
    cin >> n;
    bool p=0,w=0,g=0,y=0;
    for(int i=0;i<n;i++){
        string s;
        cin >> s;
        if(s=="P")p=true;
        if(s=="W")w=true;
        if(s=="G")g=true;
        if(s=="Y")y=true;
    }
    if(p==1&&w==1&&g==1&&y==1)cout << "Four" << endl;
    else cout << "Three" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void)
{
	int n,d,x;
	cin >> n >> d >> x;

	int a[n];

	for(int i=1;i<=n;i++)
		cin >> a[i-1];
		

	int ans = 0;

	for(int i=1;i<=n;i++)
	{
		ans+=(d/a[i-1]+(d%a[i-1]==0 ? 0:1));
	}

	cout << ans+x << endl;
}

Measured memory_bytes: 256
a = input()

x = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

a = int(a) - 1

print(x[a])

Measured memory_bytes: 38384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int K=sc.nextInt();
        String s=sc.next();
        
        if(s.length()>K){
            for(int i=0;i<K;i++){
                System.out.print(s.charAt(i));
            }
            System.out.println("...");
        }else{
            System.out.println(s);
        }
    }
}


Measured memory_bytes: 35820
a, b, n = map(int, input().split())
t = n // b

if t == 0:
    ans = int(a * n / b) - a * int(n / b)
else:
    ans = 0
    for i in range(t):
        x = b * i + (b - 1)
        if x > n:
            x = n
        else:
            pass
        
        tmp = int(a * x / b) - a * int(x / b)
        
        if tmp > ans:
            ans = tmp
        else:
            break

print(ans)

Measured memory_bytes: 9196
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cctype>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using ull = unsigned long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;

int main() {
	string c;
	cin >> c;
	if (islower(c[0])) {
		cout << "a" << endl;
	}
	else {
		cout << "A" << endl;
	}
	return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define mal 200005
using namespace std;
int n;
int a[mal];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int l;
        scanf("%d",&l);
        a[l]=i;
    }
    int maxx=1;
    int f=1;
    for(int i=1;i<n;i++)
    {
        if(a[i]<a[i+1])
        {
            f++;
            maxx=max(maxx,f);
        }
        else
        {
            //maxx=max(maxx,f);
            f=1;
        }

    }
   //printf("%d   ",maxx);

    printf("%d",n-maxx);

    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let mut orders = vec![vec![0; n - 1]; n];
    for i in 0..n {
        for j in 0..n - 1 {
            let t = read::<usize>() - 1;
            orders[i][j] = t;
        }
    }
    let ans = solve(n, orders);
    println!("{}", ans);
}

fn solve(n: usize, orders: Vec<Vec<usize>>) -> i64 {
    let mut ans = 0;
    let mut indexs = vec![0; n];
    let mut candidates = (0..n).collect::<Vec<usize>>();
    loop {
        let mut lock = vec![false; n];
        let mut ncandidates = vec![];
        for &i in candidates.iter() {
            if indexs[i] == n - 1 {
                continue;
            }
            let t = orders[i][indexs[i]];
            let f = orders[t][indexs[t]];
            if f != i || lock[f] || lock[t] {
                continue;
            }
            indexs[f] += 1;
            indexs[t] += 1;
            lock[f] = true;
            lock[t] = true;
            ncandidates.push(f);
            ncandidates.push(t);
        }
        if ncandidates.len() == 0 {
            break;
        }
        candidates = ncandidates;
        ans += 1;
    }
    for i in 0..n {
        if indexs[i] != n - 1 {
            return -1;
        }
    }
    return ans;
}

Measured memory_bytes: 12540
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
 
using namespace std;
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define ll long long

const int MOD = 1e9 + 7;

int main() {
    string s;
    int w;
    cin >> s >> w;
    ll i = 0;
    while(i * w < s.length()) {
        
        cout << s[i* w]; i++;
    }
    cout << endl;

}

Measured memory_bytes: 256