akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
	Scanner In = new Scanner(System.in);

	int a,b;

	do
	    {
		a = In.nextInt();
		b = In.nextInt();
	    }while(1 >= a && a >= Math.pow(10,9) && 1 >= b && b >= Math.pow(10,9));


	gcd(a,b);
	
    }
	private static void gcd(int a, int b)
	{
	    int c;
	    if(a < b)
		swap(a,b);

	    while(b > 0)
		{
		    c = a % b;
		    a = b;
		    b = c;
		}
	System.out.println(a);
	}

    private static void swap(int a, int b)
    {
	int d;
	d = a;
	a = b;
	b = d;
    }
}

Measured memory_bytes: 26044
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1LL << 60
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const long long MOD=1000000007;

// vector<p> cut(M); vector<vector<ll> > v(4);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// for(int i=0; i<N;i++){
// }
// sort(cut.begin(),cut.end()), sort(v.rbegin(), v.rend()); //sort
// char '' str ""
int main(void)
{
    int N;cin>>N; int sum=0; int pmax=0;
    for(int i=0;i<N;i++){
      int p; cin>>p;
      sum += p; pmax = max(pmax, p);
    }
    int ans = sum - pmax / 2;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
typedef long long ll;
using namespace std;
int main(){
  ll n;
  cin>>n;
  int mi = 30;
  for(ll i=1;i<=sqrt(n);i++){
    if(n%i==0){
    int a = to_string(i).length();
    int b = to_string(n/i).length();
    mi = min(mi,max(a,b));
    }
  }
    cout << mi << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;


int main(){

	int N,D,length,table[1001],count;
	char buf[1001];
	queue<int> Zero;
	stack<int> One;

	scanf("%d",&N);
	scanf("%s",buf);
	scanf("%d",&D);

	for(length = 0; buf[length] != '\0'; length++){
		table[length] = buf[length] - '0';
		if(buf[length] == '0'){
			Zero.push(length);
		}else{
			One.push(length);
		}
	}

	count = 0;

	while(!Zero.empty()){
		if(count != D){
			table[Zero.front()] = 1;
			count++;
		}
		Zero.pop();
	}

	if(count < D){
		while(!One.empty()){
			if(count != D){
				table[One.top()] = 0;
				count++;
			}
			One.pop();
		}
	}

	for(int i = 0; i < N; i++)printf("%d",table[i]);
	printf("\n");

	return 0;
}

Measured memory_bytes: 2752
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <map>
#include <string>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <algorithm> 
#include <ctime>

#define MaxN 100005
#define INF 2140000000
#define MOD 1000000007
using namespace std;

int N,Ans=0,P1=1,P2=1,K=1,father[MaxN];
pair<int,int>Xaxis[MaxN],Yaxis[MaxN];
vector<pair<pair<int,int>,int> >T;
bool cond(pair<pair<int,int>,int>a,pair<pair<int,int>,int>b)
{
	return a.second<b.second;
}
int find(int x)
{
	int y=x,aux;
	while(father[x]!=x)
		x=father[x];
	while(x!=y)
	{
		aux=father[y];
		father[y]=x;
		y=aux;
	}
	return x;
}
void unite(int x,int y)
{
	x=find(x),y=find(y);
	father[x]=y;
}
int main()
{
	cin>>N;
	for(int i=1;i<=N;i++)
	{
		cin>>Xaxis[i].first>>Yaxis[i].first;
		Yaxis[i].second=Xaxis[i].second=i;
		father[i]=i;
	}
	sort(Xaxis+1,Xaxis+1+N);
	sort(Yaxis+1,Yaxis+1+N);
	for(int i=1;i<N;i++)
	{
		int D=abs(Xaxis[i].first-Xaxis[i+1].first);
		T.push_back(make_pair(make_pair(Xaxis[i].second,Xaxis[i+1].second),D));
		D=abs(Yaxis[i].first-Yaxis[i+1].first);
		T.push_back(make_pair(make_pair(Yaxis[i].second,Yaxis[i+1].second),D));
	}
	sort(T.begin(),T.end(),cond);
	for(int i=0;i<T.size()&&K<N;i++)
	{
		if(find(T[i].first.first)!=find(T[i].first.second))
		{
			K++;
			unite(T[i].first.first,T[i].first.second);
			Ans+=T[i].second;
		}
	}
	cout<<Ans;
	return 0;
}

Measured memory_bytes: 6900
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
typedef long long ll;
typedef pair<ll, ll> P;

int main() {
    int n, m; cin >> n >> m;
    //vector<int> a(n), b(n);
    vector<P> p(n);
    rep(i, n) {
        int a, b;
        cin >> a >> b;
        p[i] = P(a, b);
    }
    //安いやつから貪欲
    sort(all(p));
    ll ans = 0;
    int cnt = 0;
    int mem = 0;
    rep(i, n) {
        ans += p[i].first * p[i].second;
        cnt += p[i].second;
        if (cnt >= m) {
            mem = i;
            break;
        }
    }
    int over = cnt - m;
    ans -= p[mem].first * over;
    cout << ans << endl;

}

Measured memory_bytes: 1792
#define _GLIBCXX_DEBUG　//配列入力
#include <bits/stdc++.h>
using namespace std;
//chmix関数
template<class T> void chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return;
    }
    return;
}
//chmax関数
template<class T> void chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return;
    }
    return;
}
//無限大
const long long int INF = 1LL << 60;
//DP table
long long  dp[100010];


int main(){
    //入力
    int n;
    cin >> n;
    int h[n];
    for (int i = 0; i < n; ++i)
    {
       cin >> h[i];
    }
    //INF代入
    for (int i = 0; i < 100010; ++i)
    {
        dp[i] = INF;
    }

    //初期条件
    dp[0]=0;
    for (int i = 1; i < n; ++i)
    {
        chmin(dp[i],dp[i-1]+abs(h[i]-h[i-1]));
        if(i>1){
            chmin(dp[i], dp[i - 2] + abs(h[i] - h[i-2]));
        }
    }
    cout << dp[n-1] << endl;

}

  

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};
int main() {
  int h,w,k;
  cin >> h >> w >> k;
  int x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2;
  --x1;--y1;--x2;--y2;
  vector<string> c(h);
  rep(i,h) cin >> c[i];
  
  vector<vector<int>> d(h,vector<int>(w,-1));
  queue<P> q;
  auto push = [&](int x,int y,int nd){
    if(x<0||h<=x||y<0||w<=y) return false;
    if(c[x][y]=='@') return false;
    if(d[x][y]!=-1&&nd>d[x][y]) return false;
    if(d[x][y]!=-1&&nd==d[x][y]) return true;
    d[x][y] = nd;
    q.emplace(x,y);
    return true;
  };
  push(x1,y1,0);
  while(!q.empty()){
    P p = q.front(); q.pop();
    int x = p.first, y = p.second;
    int nd = d[x][y]+1;
    rep(i,4)rep(j,k){
      if(!push(x+dx[i]*(j+1),y+dy[i]*(j+1),nd)) break;
    }
  }
  cout << d[x2][y2] << endl;
}


Measured memory_bytes: 12048
if __name__ == '__main__':
    # a = int(input())
    # a, b = map(int, input().split())

    n, k = map(int, input().split())
    h = list(sorted(map(int, input().split())))
    if k == 0:
        print(sum(h))
    else:
        print(sum(h[:-k]))



Measured memory_bytes: 89044
n=int(input())
t=[list(map(int,input().split()))for i in range(n)]
t.insert(0,[0,0,0])
for i in range(n):
    dxy=abs(t[i][1]-t[i+1][1])+abs(t[i][2]-t[i+1][2])
    dt=abs(t[i][0]-t[i+1][0])
    dd=dt-dxy
    if dxy<=dt and dd%2==0:
        pass
    else:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 27300
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  for(int i = 0;i < N;i++){
    string S;
  	cin >> S;
  	  if(S=="Y"){
        cout << "Four" << endl;
        break;
 	 }
      if(i==N-1&&S!="Y"){
      	  cout << "Three" << endl;
     }
  }
}

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

int main() {
    int d = 100000;
    int n;
    cin >> n;
    while(n--) {
        d *= 1.05;
        if(d % 1000) {
            d = (d / 1000 + 1) * 1000;
        }
    }
        cout << d << endl;
    return 0;
}


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

template <typename T> inline void read (T &x) {bool b = 0; char c; while (!isdigit (c = getchar()) && c != '-');
if (c == '-') c = getchar(), b = 1; x = c - 48; while (isdigit(c = getchar())) x = (x<<3) + (x<<1) + c - 48; if (b)x=-x;}
template <typename T> inline void wrip(T x) {if (x > 9) wrip(x / 10); putchar(x%10 + 48); }

template <typename T> inline void write(T x) {if (x < 0) putchar('-'), x = -x; wrip(x); putchar(' ');}
template <typename T> inline void writeln(T x) {if (x < 0) putchar('-'), x = -x; wrip(x); putchar('\n');}
inline char readch() {char c; do c = getchar(); while (c == '\n' || c == ' '); return c;}
inline void reads(string &s) {char c; while((c=getchar())==' '||c =='\n'); s=c; while((c=getchar())!=' '&&c!='\n') s+=c;}
inline void getlines(string &s) {char c; while((c=getchar())=='\n'); s=c; while((c=getchar())!='\n') s+=c;}
typedef const int csint;

#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair <int, int> ii;
typedef vector <int> vi;

const ld pi = acos(-1);
const int inf = 12e8;
const int mod = 1e9 + 7,
N = 2e6 + 11;

int n, num[N];
ll res[N], sum[N];
vector <int> ds;
struct stc{
    ll v;
    int id;
} a[N];
bool cmp(stc a, stc b) {
    if (a.v == b.v)
        return a.id > b.id;
    return a.v < b.v;
}
void Add(int p, int val) {
    for (; p > 0; p -= (p & -p))
        num[p] += val;
}
int Num(int p) {
    int ans = 0;
    for (; p <= n; p += (p & -p))
        ans += num[p];
    return ans;
}
void Inc(int p, ll val) {
    for (; p > 0; p -= (p & -p))
        sum[p] += val;
}
ll Sum(int p) {
    ll ans = 0;
    for (; p <= n; p += (p & -p))
        ans += sum[p];
    return ans;
}
int main() {
    #ifdef makacha
        freopen("m.inp", "r", stdin);
        freopen("m.out", "w", stdout);
    #endif // makacha
    read(n);
    for (int i = 1; i <= n; i++) {
        read(a[i].v);
        a[i].id = i;
    }
    sort(a + 1, a + n + 1, cmp);
    ll last = 0;
    for (int i = 1; i <= n; i++) {
        a[i].v -= last;
        ds.push_back(i);
        Add(a[i].id, 1);
        Inc(a[i].id, a[i].v);
        if (Num(1) - Num(a[i].id) == a[i].id - 1) {
            last = a[i].v + last;
            res[a[i].id] += a[i].v * (n - a[i].id - Num(a[i].id + 1)) + Sum(a[i].id);
            for (auto j: ds)
                Inc(a[j].id, -a[j].v);
            ds.clear();
        }
    }
    for (int i = 1; i <= n; i++)
        writeln(res[i]);
}



Measured memory_bytes: 10880
A = input()
B = input()
C = input()

xa = 0
xb = 0
xc = 0

h = 'A'
k = A[xa]
xa += 1

while True:

    if k == 'a':
        h = 'A'

        if xa < len(A): 
            k = A[xa]
            xa += 1
        else:
            break

    elif k == 'b':
        h = 'B'
        xb += 1
        if xb < len(B):
            k = B[xb]
            xb += 1
        else:
            break
    else:
        h = 'C'
        xc += 1
        if xc < len(C):
            k = C[xc]
            xc += 1
        else:
            break

print(h)


Measured memory_bytes: 3188
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  int C[3][3];
  rep(i, 3) {
    rep(j, 3) { cin >> C[i][j]; }
  }

  int A[3];
  int B[3];
  A[0] = 0;
  B[0] = C[0][0] - A[0];
  B[1] = C[0][1];
  B[2] = C[0][2];
  A[1] = C[1][0] - B[0];
  A[2] = C[2][0] - B[0];

  bool flag = true;
  rep(i, 3) {
    rep(j, 3) {
      if (C[i][j] != (A[i] + B[j])) {
        flag = false;
      }
    }
  }

  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

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

// Sorting three numbers

int main(){
	int a, b, c;
	cin >> a;
	cin >> b;
	cin >> c;
	if(b > c) swap(b, c);
	if(a > b) swap(a, b);
	if(b > c) swap(b, c);

	cout << a << ' ' << b << ' ' << c << endl;

	return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<algorithm>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
using namespace std;
typedef long long ll;
ll n,m;
char s[100010],t[100010];
ll gcd(ll a,ll b){
  if(b==0) return a;
  else return gcd(b,a%b);
}
ll lcm(ll a,ll b){
  return a*b/gcd(a,b);
}
ll solve(){
  int x=0,y=0;
  ll z=lcm(n,m);
  while(x<n){
    if(s[x]!=t[y]) return -1;
    x+=z/m;
    y+=z/n;
  }
  return z;
}


int main(){
  cin>>n>>m;
  rep(i,n) cin>>s[i];
  rep(i,m) cin>>t[i];
  ll res=solve();
  prin(res);
  
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int N;
LL K;
vector<int> divs;
map<int, LL> dp;

LL mypow(LL base, LL exp) {
  if (exp == 0) return 1;
  LL res = mypow(base*base%MOD, exp/2);
  if (exp%2) res = res*base % MOD;
  return res;
}

LL f(LL t) {
  LL num = (t/2) + t%2;
  return mypow(K, num);
}

int main() {
  scanf("%d%lld", &N, &K);
  for (int d=1; d*d<=N; d++) {
    if (N%d == 0) {
      divs.eb(d);
      divs.eb(N/d);
    }
  }
  sort(all(divs));
  divs.erase(unique(all(divs)), divs.end());
  
  LL ans = 0;
  for (int g : divs) {
    dp[g] = f(g);
    vector<int> dd;
    for (int d=1; d*d<=g; d++) {
      if (g%d == 0) {
        dd.eb(d);
        dd.eb(g/d);
      }
    }
    sort(all(dd));
    dd.erase(unique(all(dd)), dd.end());
    if (dd.back() == g) dd.pop_back();
    for (int d : dd) {
      dp[g] = (dp[g] + MOD - dp[d]) % MOD;
    }
    //printf("dp[%d]: %lld\n", g, dp[g]);
    //ans += dp[g]*g;
    //ans %= MOD;
  }

  if (N%2) {
    for (int g : divs) {
      ans += dp[g]*g;
      ans %= MOD;
    }
  } else {
    for (int g : divs) {
      if (g%2) {
        ans += dp[g]*g;
      } else {
        ans += dp[g]*(g/2);
        ans %= MOD;
      }
    }
  }

  printf("%lld\n", ans);
}


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

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>

#define INF 10e9
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;

int main(){
    long long int n;
    cin >> n;
    vector<long long int> v(n);
    long long int i;
    long long int sum = 0;
    long long int tmp = 0;
    for(i = 0; i < n; i++){
        cin >> v[i];
        sum += 2 * v[i];
        if(i%2 == 0 && i != n-1){
            tmp += 2 * v[i];
        }
    }

    vector<long long int> a(n);
    a[n-1] = sum/2 - tmp;
    for(i = n-2; i >= 0; i--){
        a[i] = 2 * v[i] - a[i+1];
    }

    for(i = 0; i < n; i++){
        cout << a[i] << endl;
    }
}










Measured memory_bytes: 2944
N = int(input())
A = list(map(int,input().split()))

fp = A[0]
tmp = 0
c = 1000
stock = 0
IsSearchTop = False
first = True
for i in range(1,N):
#
        if IsSearchTop:
            if fp <= A[i]:
                fp = A[i]
                if i == N-1:
                    c += stock * fp
            elif fp > A[i]:
                c += stock * fp
                stock = 0
                fp = A[i]
                IsSearchTop = False
        else:
            if fp >= A[i]:
                fp = A[i]
            elif fp < A[i]:
                stock += c // fp
                c -= stock * fp
                IsSearchTop = True
                fp = A[i]
                if i == N - 1:
                    c += stock * fp
print(c)














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


int main() {
	char s[26];
	bool check[26];
	for (int i = 0; i < 26; i++) {
		check[i] = false;
	}
	cin >> s;

	for (int i = 0; s[i] != '\0'; i++) {
		if (check[(int)(s[i] - 'a')]) {
			cout << "no";
			return 0;
		}
		check[(int)(s[i] - 'a')] = true;
	}
	cout << "yes";

	return 0;
}

Measured memory_bytes: 256
N, A, B, C = gets.chomp.split.map(&:to_i)
L_LIST = N.times.map { gets.to_i }
MAX = 10 << 60

def dfs(n, a, b, c)
  if n == N
    if [a, b, c].include?(0)
      return MAX
    else
      return (A - a).abs + (B - b).abs + (C - c).abs - 10 * 3
    end
  end
  l = L_LIST[n]
  ret1 = dfs(n + 1, a, b, c)
  ret2 = dfs(n + 1, a + l, b, c) + 10
  ret3 = dfs(n + 1, a, b + l, c) + 10
  ret4 = dfs(n + 1, a, b, c + l) + 10
  [ret1, ret2, ret3, ret4].min
end

ans = dfs(0, 0, 0, 0)
puts ans


Measured memory_bytes: 1788
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	int a,b;
	for(;a=in(),b=in();){
		b-=a;
		cout<<b%500/100<<" "<<b%1000/500<<" "<<b/1000<<endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define MAXN 2007
using namespace std;
long long dp[3*MAXN][MAXN];
int main()
{
	int n,MOD;
	cin>>n>>MOD;
	for(int i=0;i<=3*n;i++) dp[i][0]=1;
	for(int i=1;i<=3*n;i++) for(int j=1;j<=n;j++) 
	{
		dp[i][j]=dp[i-1][j];
		if(i>1) dp[i][j]=(dp[i][j]+dp[i-2][j-1]*((long long)i-1))%MOD;
		if(i>2) dp[i][j]=(dp[i][j]+dp[i-3][j-1]*((long long)i-1)*((long long)i-2))%MOD;
	}
	long long res=0;
	for(int i=0;i<=n;i++) res=(res+dp[3*n][i])%MOD;
	cout<<res;
}

Measured memory_bytes: 94464
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections

x,y,z = map(int,input().split())
x-= 2*z
ans = x//(y+z)
if x%(y+z)>=y:
    ans += 1
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> l(n);
  for (int i=0;i<n;i++){
    cin >> l[i];
  }
  sort(l.begin(),l.end());
  int sum=0;
  for (int i=0;i<n;i++){
    sum+=l[i];
  }
  if(sum-2*l[n-1]>0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main(void) {
  char S[11];
  scanf("%s", &S);
  int l = strlen(S);
  int cnt = 0;
  if (S[0] == 'A') {
    for (int i = 1; i < l; i++) {
      if ('a' <= S[i] && S[i] <= 'z') {
      } else if (2 <= i && i <= l-2 &&  S[i] == 'C') cnt++;
      else {
        puts("WA");
        return 0;
      }
    }
  }
  if (cnt == 1) puts("AC");
  else puts("WA");

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a>b) { a=b; return 1; } return 0; }

ll N,Q;
vector<vector<ll>> G(200100);
vector<ll> cnt(200100,0);
vector<bool> f(200100);

void dfs(ll n){
    for(ll i=0;i<G[n].size();i++){
        if(!f[G[n][i]]){
            cnt[G[n][i]]+=cnt[n];
            f[G[n][i]]=true;
            dfs(G[n][i]);
        }
    }
}

int main(){
    cin>>N>>Q;
    for(ll i=0;i<N-1;i++){
        ll a,b;
        cin>>a>>b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    for(ll i=0;i<N;i++) f[i]=false;
    for(ll i=0;i<Q;i++){
        ll p,x;
        cin>>p>>x;
        cnt[p-1]+=x;
    }
    f[0]=true;
    dfs(0);
    for(ll i=0;i<N;i++){
        cout<<cnt[i];
        if(i!=N-1) cout<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 24320
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
    
    public static void main(String[] args) {
        
        new Main().q1();
    }
    
    
    public void q1() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<String> list = new ArrayList<String>();
       
        for(int i = 0; i < n; i++) {
          list.add(sc.next());
        }
        String ret = "";
        
        for(char target = 'a' ; target  <= 'z'; target++) {
            List<Integer> count = new ArrayList<Integer>();
             for (String string :list){
                 int x = 0;
                 for(char c:string.toCharArray()){
                     if(c==target){
                       x ++;
                     }
                 }
                 count.add(x);
             }
            int max = Collections.min(count);
            for(int i = 0; i < max; i++) {
              ret += target;
            }
            
        }
    
        System.out.println(ret);
        
        
    }
    
    
}



Measured memory_bytes: 22868
n=int(input())
a=[]
for _ in range(n):
    a.append(int(input()))

a=sorted(a)

from collections import deque

d=deque(a)

ans=deque([d.pop()])

for i in range(n-1):
    if i%2==0:
        p=d.popleft()
    else:
        p=d.pop()
        
    if abs(p-ans[0])>=abs(p-ans[-1]):
        ans.appendleft(p)
    else:
        ans.append(p)


dif = 0

for j in range(n-1):
    dif += abs(ans[j+1] - ans[j])

d=deque(a)
ans=deque([])

for i in range(n):
    if i==n-1:
        z=d.pop()

        if abs(z-ans[0])>abs(z-ans[-1]):
            ans.appendleft(z)
        else:
            ans.append(z)
    else:
        if i%2==0:
            p=d.pop()
            ans.append(p)
        else:
            q=d.popleft()
            ans.append(q)

dif2 = 0
for j in range(n-1):
    dif2 += abs(ans[j+1] - ans[j])

print(max(dif,dif2))

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

typedef pair<int,int> pii;
typedef vector<int> vec;
typedef unordered_map<int,int> hash;
#define long long long
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define sz(x) (int)x.size()
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define fill(a,v) memset(a,v,sizeof(a))
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define INF 0x3f3f3f3f//infinity for integers
#define JJ ios_base::sync_with_stdio(0); cin.tie(0)//input fast
#define MOD 1000000007


int main()
{
	JJ;
	int n,x,t; cin>>n>>x>>t;
	int ans=((n/x)*t);
	if(n%x!=0)
		ans+=t;
	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 3660
//be naame khodaa
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
#define F first
#define S second

inline int in(){int x, y; y = scanf("%d", &x); return x; }

const int N = -1;

struct PT{
	ld x, y;
	PT (ld x = 0, ld y = 0) : x(x), y(y) {}
	PT operator + (PT ro) const{
		return PT(x+ro.x, y+ro.y);
	}
	PT operator - (PT ro) const{
		return PT(x-ro.x, y-ro.y);
	}
	PT operator * (ld co) const{
		return PT(x*co, y*co);
	}
	PT operator / (ld co) const{
		return PT(x/co, y/co);
	}
	ld operator * (PT ro) const{
		return x*ro.x + y*ro.y;
	}
	ld operator ^ (PT ro) const{
		return x*ro.y - y*ro.x;
	}
};

PT operator * (ld co, PT p){
	return p*co;
}

PT proj(PT a, PT b, PT c){
	PT ab = b-a, ac = c-a;
	return a + (ab*ac)/(ab*ab)*ab;
}

int main(){
	PT a, b;;
	cin >> a.x >> a.y >> b.x >> b.y;
	PT p;
	cout << setprecision(10) << fixed;
	for (int i = in(); i; i--){
		cin >> p.x >> p.y;
		PT img = proj(a, b, p);
		cout << img.x << ' ' << img.y << '\n';
	}
	return 0;
}


Measured memory_bytes: 3340
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
 
n = int(raw_input())
  
d = [99999 for i in range(n)]
G = [0 for i in range(n)]
M = [[0 for i in range(n)] for j in range(n)]
  
def BFS(s):
    for e in range(n):
        if M[s][e] == 1:
            if d[e] > d[s] + 1:
                d[e] = d[s]+1
                BFS(e)
  
for i in range(n):
    G = map(int, raw_input().split())
    for j in range(G[1]):
        M[G[0]-1][G[2+j]-1] = 1
  
d[0] = 0
for s in range(n):
        BFS(s)
for s in range(n):
    if d[s] == 99999:
        d[s] = -1
for s in range(n):
    print'{0} {1}'.format(s+1, d[s])
 

Measured memory_bytes: 6492
import Control.Monad

type Point = (Int, Int)
type Square = (Point, Point)
data Direction = West | East | North | South deriving (Show, Eq, Ord, Enum)

fill :: Square -> (Point, Direction) -> Square
fill ((x1, y1), (x2, y2)) ((x, y), West) = ((max x1 x, y1), (x2, y2))
fill ((x1, y1), (x2, y2)) ((x, y), East) = ((x1, y1), (min x2 x, y2))
fill ((x1, y1), (x2, y2)) ((x, y), North) = ((x1, max y1 y), (x2, y2))
fill ((x1, y1), (x2, y2)) ((x, y), South) = ((x1, y1), (x2, min y2 y))

readLine :: String -> (Point, Direction)
readLine str = ((x, y), dir)
  where [x, y, i] = read <$> words str :: [Int]
        dir = toEnum (i - 1) :: Direction

area :: Square -> Int
area ((x1, y1), (x2, y2)) = (max 0 (x2 - x1)) * (max 0 (y2 - y1))

main :: IO ()
main = do
  line <- getLine
  let [w, h, n] = read <$> words line :: [Int]
  lines <- replicateM n getLine
  let res = foldl fill ((0, 0), (w, h)) $ fmap readLine lines
  print $ area res


Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  int h,w;
  cin >> h >> w ;
  string a[h];
  rep(i,h) cin >>a[i];
  int c[26];
  rep(i,26)c[i]=0;
  rep(i,h){
    rep(j,w){
      int ind=a[i][j]-'a';
      c[ind]++;
    }
  }
  int tc=0;
  int oc=0;
  if(h%2==1) tc+=w/2;
  if(w%2==1) tc+=h/2;
  if(h%2==1 && w%2==1) oc=1;

  rep(i,26){
    if(c[i]%4!=0){
      if(c[i]%4==2) tc--;
      if(c[i]%4==1) oc--;
      if(c[i]%4==3){
	tc--;oc--;
      }      
    }
    if(oc<0 || tc<0){
      cout << "No" <<endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
    
  
  return 0;

}


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

typedef long long ll;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

// bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) {
//     return arg1.first > arg2.first;
// }

int main(void) {
    ll k;
    cin >> k;

    queue<ll> q;
    for(int i=0;i<9;i++) {
        q.push(i+1);
    }

    ll ans, before=0, r, ik=0;
    while(ik<k) {
        ans = q.front(); q.pop();
        r = ans % 10;
        if(r!=0) q.push(10*ans+r-1);
        q.push(10*ans+r);
        if(r!=9) q.push(10*ans+r+1);
        ik++;
    }
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        sc.nextLine(); // 改行
        String[] strz = new String[N];
        for (int n = 0; n < N; n++){
            strz[n] = sc.nextLine();
        }

        for (int n = 0; n < N; n++){
            char[] charn = strz[n].toCharArray();
            Arrays.sort(charn);
            strz[n] = new String(charn);
        }

        Map<String, Integer> map = new HashMap<>();
        for (String s : strz) {
            Integer i = map.get(s);
            map.put(s, i == null ? 1 : i + 1);
        }
        long cnt = 0;
        for (String key : map.keySet()){
            long num = map.get(key);
            if (num > 1) {
                // cnt+=conbi(num,2);
                cnt+= (num*(num-1)/2);
            }
        }
        System.out.println(cnt);
    }

    public static long f (long n){
        if (n<=1){return 1;}
        return f(n-1)*n;
    }
    public static long conbi(long n,long r){
        return (f(n)/(f(n-r)*f(r)));
    }
}


Measured memory_bytes: 99996
#include <iostream>
    using namespace std;
    int main(void){
        // Your code here!
        char s[4];
        scanf("%s",s);
        if(s[0] == '7' || s[1] == '7' || s[2] == '7')
            printf("Yes\n");
        else
            printf("No\n");
    }

Measured memory_bytes: 3760
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int P = 1000000007;
const int INF = 2147483647;
const ll LLINF = 1LL<<60;

int H,W;
char s[51][51];

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

string s;
cin >> s;
int a=0,b=0,c=0;
rep(i,s.length()){
    if(s[i]=='a')a++;
    if(s[i]=='b')b++;
    if(s[i]=='c')c++;
}
if(abs(a-b)<=1 && abs(b-c)<=1 && abs(c-a)<=1)fin("YES");else fin("NO");

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;

int n, k;

int main(){
    long long a[100005];

    cin >> n >> k;
    rep(i,n) cin >> a[i];

    long long total = 0, sum = 0;
    long long ans = 0;
    rep(i,k) sum+=a[i];
    range(i,k,n){
        if(a[i] > 0) total += a[i];
    }
    ans = max(ans, max(total, total + sum));

    range(i,k,n){
        sum -= a[i - k];
        sum += a[i];
        if(a[i - k] > 0) total += a[i - k];
        if(a[i] > 0) total -= a[i];
        ans = max(ans, max(total, total + sum));
    }

    cout << ans << endl;

}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <queue>
#include <cstring>
using namespace std;

long long gcd(long long a,long long b) {
	while (a!=0) {
		if (b > a)swap(a, b);
		a %= b;
	}
	return b;
}

int main() {
	int N; cin >> N;
	vector<long long> A(N);
	for (int i = 0; i < N; i++)cin >> A[i];
	long long ans = A[0];
	for (int i = 1; i < N; i++)ans = gcd(ans, A[i]);
	cout << ans << endl;

}





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

int main() {
  int N;
  vector<int> a(100002,0), b(100002,0), c(100002,0);
  vector< vector<int> > dp(100002,vector<int>(3,0));
  
  cin >> N;
  for (int i=0;i<N;++i ) {
    cin >> a[i] >> b[i] >> c[i];
  }
  dp[0][0] = a[0];
  dp[0][1] = b[0];
  dp[0][2] = c[0];
  for (int i=0;i<N-1;++i){
    dp[i+1][0] = max( dp[i+1][0], dp[i][1]+a[i+1] );
    dp[i+1][0] = max( dp[i+1][0], dp[i][2]+a[i+1] );
    dp[i+1][1] = max( dp[i+1][1], dp[i][0]+b[i+1] );
    dp[i+1][1] = max( dp[i+1][1], dp[i][2]+b[i+1] );
    dp[i+1][2] = max( dp[i+1][2], dp[i][0]+c[i+1] );
    dp[i+1][2] = max( dp[i+1][2], dp[i][1]+c[i+1] );
  }
  cout << max(dp[N-1][0],max(dp[N-1][1],dp[N-1][2])) << endl;
}


Measured memory_bytes: 6912
a, b, k = map(int, input().split())
a, b = min(a, b), max(a, b)

lst = []
for i in range(1, a+1):
  if a % i == 0:
    lst.append(i)
lst.sort(reverse=True)
cnt = 0
for num in lst:
  if b % num == 0:
    cnt += 1
    if cnt == k:
      print(num)
      break

Measured memory_bytes: 3064
n = int(input())
l = [list(map(int,input().split(" "))) for i in range(n)]
c = 0
mc = 0
for i in range(n):
  if l[i][0] == l[i][1]:
    c += 1
    if mc < c:
      mc = c
    if mc >= 3:
      print("Yes")
      break
  else:
    c = 0
else:
  print("No")

Measured memory_bytes: 9196
#include<stdio.h>
int main(void)
{
	int a,b,c,d,p,x,y,z,k;
	scanf("%d %d %d %d %d",&a,&b,&c,&d,&p);
	x=a*p;
	if(p>c){
			y=p-c;
			z=y*d;
			k=b+z;
	}
	else {
			k=b;
	}
	if(x<k){
			printf("%d\n",x);
	}
	else {
			printf("%d\n",k);
	}
	return 0;
}


Measured memory_bytes: 2708
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c<=32)c=_buff.get();return c;}
ll qpow(ll x,ll k){return k==0?1:1ll*qpow(1ll*x*x%mod,k>>1)*(k&1?x:1)%mod;}
ll a,b,c,K;
int main()
{
	cin>>a>>b>>c>>K;
	if(K&1)cout<<b-a<<endl;
	else cout<<a-b<<endl;
	return 0;
}


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

int main(){
	set<int> se;
	for(int i=1;i<=30;i++){
		se.insert(i);
	}
	int a;
	for(int i=1;i<=28;i++){
		cin>>a;
		se.erase(a);
	}
	for(set<int>::iterator it=se.begin();it!=se.end();it++){
		cout<<(*it)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1196
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RSORT(x) sort(x.begin(), x.end(), std::greater<int>())
#define swap(a, b) \
  do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0)
#define vi vector<int>
using namespace std;

const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main() {
  
  int n, a;
  cin >> n >> a;

  if(n < 500) {
    if(n <= a) 
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
	
  } else if((n-(n / 500)*500) <= a) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  
}


Measured memory_bytes: 256
H,W = map(int, input().split())

s =[]
s_w =[]

for i in range(H):
    s_t = input()
    s_w =[]
    for j in range(W):           
        s_w.append(s_t[j])
    s.append(s_w)

dx = [ 0, -1,  1, 0]
dy = [ -1, 0,  0, 1]

flag = True

for i in range(H):
    for j in range(W):
        
        if s[i][j] != "#":
            continue
        
        flag2 = False
        for k in range(len(dx)):
            ni = i + dy[k]
            nj = j + dx[k]
            if (ni<0 or H<=ni) or (nj<0 or W<=nj):
                continue
            
            #周りに一つも#がなければおわり
            if s[ni][nj] == "#":
                flag2 = True
                break
        
        if flag2 == False:
            flag = False
if flag == True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cstring>
#include<cmath>
#include <numeric>
#include<queue>
#include<climits>
#include<cstdio>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
//#define INF ((LLONG_MAX) / (2))
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
typedef pair<ll,int> LL_IP;
#define INF 1e9+7




int main(){

    ll n;
    cin >> n;
    vector<ll> arr(n);
    REP(i,n){
        cin >> arr[i];
    }
    ll count = 0;

    for(ll i = 0;i < n;){

        ll j = i+1;
        ll tmp = arr[i];
        if(tmp < arr[j]){
            /*単調増加の部分*/
            while(tmp <= arr[j] && j < n){
                tmp = arr[j];
                j++;
            }
            if(j != n){
                /*途中で単調増加しなくなった場合*/
                count++;
                i = j;
            }else{
                i = n;
                break;
            }
        }else if(tmp > arr[j]){
            /*単調減少の部分*/
            while(tmp >= arr[j] && j < n){
                tmp = arr[j];
                j++;
            }
            if(j != n){
                /*途中で単調減少しなくなった場合*/
                count++;
                i = j;
            }else{
                i = n;
                break;
            }
        }else{
            //一致している場合は次の要素を調べる
            i++;
        }
    }
    cout << count+1 << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
template <typename T>
bool PN(T x){ if (x <= 1) return false; if (x == 2) return true; for (int i = 2; i < sqrt(x) + 1; i++) if (x % i == 0) return false; return true;}
const ll MOD = 1e9+7;
long long Comb(int n, int i){long long ans = 1; if(i>n || i < 0) return 0; if(i == 0 || i == n) return 1; else {for(int j = 1; j <= i; ++j){
      ans *=(n+1-j);
      ans /= j;
      ans %= MOD;} }return ans;}

void solve(){
   int n; cin >> n;
   int ans = 0;
   int kijun = -1;
   for(int i = 1; i <= n; ++i){
       int tmp = i;
       int cnt = 0;
       while(tmp){
           if(tmp%2 == 0){
            tmp/=2;
            cnt++;
           } else {
               break;
           }
       }
        if(cnt > kijun) {
            ans = i;
            kijun = cnt;
        }
   }
   cout << ans << endl;
}

int main(void){
    solve();
    return 0;
}


Measured memory_bytes: 3636
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	iv, _ := strconv.Atoi(scanString())
	return iv
}

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

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 100001), 100001*100)
}

func main() {
	n := scanInt()
	m := make(map[string]int, n)
	for i := 0; i < n; i++ {
		s := scanString()
		r := []rune(s)
		sort.Slice(r, func(i, j int) bool { return r[i] < r[j] })
		m[string(r)]++
	}

	ans := 0
	for _, v := range m {
		ans += v * (v - 1) / 2
	}
	fmt.Println(ans)
}


Measured memory_bytes: 14800
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

const ll MOD = 1e9 + 7;
int N;
string s1, s2;
ll dp[52];

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> s1 >> s2;
  fill_n((ll*)dp, 52, -1);
  if (s1[0] == s2[0]) dp[0] = 3;
  else dp[0] = dp[1] = 6;
  for (int i = 0; i < s1.size(); i++) {
    if (!(dp[i] < 0)) continue;
    if (s1[i - 1] == s2[i - 1]) {
      if (s1[i] == s2[i]) dp[i] = dp[i - 1] * 2 % MOD;
      else dp[i] = dp[i + 1] = dp[i - 1] * 2 % MOD;
    } else {
      if (s1[i] == s2[i]) dp[i] = dp[i - 1];
      else dp[i] = dp[i + 1] = dp[i - 1] * 3 % MOD;
    }
  }
  cout << dp[s1.size() - 1] << endl;

  return 0;
}

Measured memory_bytes: 256
/*
* welcome to my code!
* ------------------------------------------
* author : lynmisakura(twitter : @andoreiji11)
*/

#include<bits/stdc++.h>
using namespace std;

using ll = long long;

#define REP(i,n) for(int i = 0;i < n;i++)
#define all(x) x.begin(),x.end()
#define dup(x,y) (x + y - 1)/y
#define sz(v) (int)v.size()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

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

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

    int n;cin >> n;
    vector<int> a(n);
    REP(i,n)cin >> a[i];

    int ans = 0;

    REP(i,n){
      if((i+1)%2==1 and (a[i] % 2 == 1)) ans ++ ;
    }

    cout << ans << '\n';

}


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

int main() {
    int n;

    cin >> n;
    int i = 1;

    for(int i = 1; i <= n; i++) {
        int x = i;
        if(x % 3 ==0) {
            cout << " " << i;
        } else {
        while(x) {
            if (x % 10 ==3) {
            cout << " " << i;
            break;
            }
            x /= 10;
        }
        }
    }
    cout << endl;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,D,X;
  cin>>N>>D>>X;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  vector<int> a(101,0);
  for(int i=0;i<N;i++){
    for(int j=1;j<=D;j+=A[i]){
      a[j]++;
    }
  }
  int ans=0;
  for(int i=1;i<=D;i++){
    ans+=a[i];
  }
  cout<<ans+X<<endl;
}

Measured memory_bytes: 3632
N, M, X = map(int, input().split())
C = []
A = []
for _ in range(N):
    l = list(map(int, input().split()))
    C.append(l[0])
    A.append(l[1:])

ans = -1
for i in range((1<<N)):
    u = [0] * M
    p = 0
    for j in range(N):
        if i & (1 << j):
            p += C[j]
            for k in range(M):
                u[k] += A[j][k]
    if min(u) >= X:
        if ans == -1 or ans > p:
            ans = p
print(ans)



Measured memory_bytes: 9112
#include<bits/stdc++.h>
#define ll int
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define ins insert
#define sb substr
#define con continue
#define ub upper_bound
#define lb lower_bound
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define pll pair<ll,ll>
#define pld pair<ld,ld>
using namespace std;

ll power(ll x, ll y);
ll mpower(ll x, ll y, ll p);
ll modInv(ll a, ll m);
ll gcdExtended(ll a, ll b, ll *x, ll *y);
bool isPrime(ll n);

int myf(int arr[], int n)
{
    int count = 0;
    for (int i = 0; i < n - 2; ++i)
    {
        int k = i + 2;
        for (int j = i + 1; j < n; ++j)
        {
            while (k < n && arr[i] + arr[j] > arr[k])
                ++k;
            if(k > j)
                count += k - j - 1;
        }
    }
    return count;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,i,j,k,l,h,p,q,r,x,y,z,a,b,c,d,f,n,m,M=1000000007;
    char ch,ch2,ch3;
    string s,s1,s2,s3;
    vector<ll> v,w;
    unordered_map<ll,ll> N;
    set<ll> S;
    set<ll> :: iterator itr;
    cin>>n;
    ll A[n];
    for(i=0;i<n;i++){
        cin>>A[i];
    }
    sort(A,A+n);
    cout<<myf(A,n);
    return 0;
}

ll modInv(ll a, ll m){
    ll x, y;
    ll g = gcdExtended(a, m, &x, &y);
    ll res = (x%m + m) % m;
    return res;
}

ll gcdExtended(ll a, ll b, ll *x, ll *y){
    if (a == 0){
        *x = 0, *y = 1;
        return b;
    }
    ll x1, y1;
    ll gcd = gcdExtended(b%a, a, &x1, &y1);
    *x = y1 - (b/a) * x1;
    *y = x1;
    return gcd;
}

ll mpower(ll x, ll y, ll p){
    ll res = 1;
    x = x % p;
    while(y > 0){
        if(y & 1) res = (res*x) % p;
        y = y>>1;
        x = (x*x) % p;
    }
    return res;
}

ll power(ll x, ll y){
    ll res = 1;
    while (y > 0){
        if (y & 1) res = res*x;
        y = y>>1;
        x = x*x;
    }
    return res;
}

bool isPrime(ll n){
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
    ll p=sqrt(n);
    for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
            return false;
    return true;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    string S;
    cin>>S;
    rep(i,0,S.size()){
        if(S[i] == '1')cout<<'9';
        else if(S[i] == '9')cout<<'1';
        else cout << S[i];
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

int main() {
  string s,t;
  ll q;
  cin >> s >> t >> q;
  vec ss(s.size()+1);
  vec st(t.size()+1);
  for(ll i=0;i<s.size();i++) {
    ss[i+1]=ss[i]+(s[i]=='A');
  }
  for(ll i=0;i<t.size();i++) {
    st[i+1]=st[i]+(t[i]=='A');
  }
  while(q--) {
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll ns=ss[b]-ss[a-1];
    ns=(ns%3-(b-a+1-ns)%3+3)%3;
    ll nt=st[d]-st[c-1];
    nt=(nt%3-(d-c+1-nt)%3+3)%3;
    if(ns==nt) {
      cout << "YES" << endl;
    }
    else {
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 2432
#include<iostream> //AA06(17/ 05/ 20)

using namespace std;

int main()
{
    int n, x;

    cin >> n;

    x = n % 10;

    if(x == 3)
        cout << "bon" << endl;

    else if(x == 0 || x == 1 || x == 6 || x == 8)
        cout << "pon" << endl;

    else
        cout << "hon" << endl;

    return 0;
}



Measured memory_bytes: 3636
<?php
// Repetitive Processing - How Many Divisors
$split_data = explode(" ",trim(fgets(STDIN)));
$a = $split_data[0];
$b = $split_data[1];
$c = $split_data[2];
$count = 0;

for($i = $a; $i <= $b; $i++){
    if($c % $i === 0){
        $count++;
    }
}
echo $count."\n";

Measured memory_bytes: 15328
def main():
    n, k = map(int, input().split())
    sum_min = 0
    sum_max = 0
    ans = 0
    m = 10**9 + 7
    for i in range(k-1):
        sum_min += i
        sum_max += n-i
    for i in range(k-1, n+1):
        sum_min += i
        sum_max += n-i
        ans += sum_max - sum_min + 1
        ans %= m
    print(ans)
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 9196