akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define Set(a, b) memset(a, b, sizeof (a))
#define For(i, j, k) for (int i = j; i <= k; ++ i)

using namespace std;

typedef long long ll;

inline void File() {
	freopen("D.in", "r", stdin);
	freopen("D.out", "w", stdout);
}

const int N = 1e5 + 10, bas = 1e5, inf = 0x3f3f3f3f;
int a[N], n, s[N], ans, mx;

struct BIT {
	int c[N << 1], lim = N << 1; inline void init() { Set(c, 0); }	
	inline void update(int x, int v) { for (; x <= lim; x += x & -x) c[x] += v; }
	inline int query(int x) { int res = 0; for (; x; x -= x & -x) res += c[x]; return res; }
} T;

inline bool check(int x) {
	T.init(), Set(s, 0);
	For(i, 1, n) s[i] = s[i - 1] + (a[i] >= x ? 1 : -1);

	ll res = 0; T.update(bas, 1);
	For(i, 1, n) 
		res += T.query(s[i] + bas),
		T.update(s[i] + bas, 1);

	return res >= 1ll * n * (n + 1) / 4;
}

int main() {

	cin >> n;
	For(i, 1, n) scanf("%d", a + i), mx = max(mx, *(a + i));

	for (int l = 1, r = mx; l <= r; ) {
		int mid = l + r >> 1;
		if (check(mid)) ans = mid, l = mid + 1;
		else r = mid - 1;
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
#define N 100005
#define inf (1ll << 60)
int n, A[N], B[N];
ll ans, s[N], t[N], now, tot;
int main()
{
	scanf("%d", &n);
	scanf("%lld", &ans);
	t[0] = ans;
	char opt[5];
	for (int i = 1; i < n; i++)
	{
		scanf("%s%d", opt, &A[i]);
		B[i] = opt[0] == '+' ? 1 : -1;
		ans += A[i] * B[i];
	}
	for (int i = n; i >= 1; i--)
		s[i] = A[i] + s[i + 1];
	for (int i = 1; i <= n; i++)
		t[i] = B[i] * A[i] + t[i - 1];
	now = -inf;
	tot = 0;
	for (int i = n; i >= 1; i--)
	{
		tot += A[i];
		if (B[i] == -1)
		{
			ans = max(ans, t[i - 1] - tot + now);
			now = s[i];
			tot = 0;
		}
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 2560
#include<iostream>
using namespace std;
bool flag[10000001];
int main(){
    for(int i=0;i <= 1000000;i++){
		if(i<=1)flag[i]=false;
		else flag[i]=true;
	}
	for(int i=2;i <= 1001 ;i++){
		if(flag[i]==true){
			for(int j=i*2 ; j<=1000000 ; j=j+i){
				flag[j] = false;
			}
		}
	}
	int n;
	while(cin>>n,n){
        for(int i=n;i!=1;i--){
            if(flag[i]&flag[i-2]){
                cout<<i-2<<" "<<i<<endl;
                break;
            }
        }
	}

    return 0;
}

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

int main() {
  int p = 0;
  cin >> p;

  if (p % 2 == 0) {
    cout << (int)(p / 2) << "\n";
  } else {
    cout << (int)(p / 2 + 1) << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


int main() {
  ll n; cin >> n;
  Vll a(n);
  Vll cnt(n+1);
  rep(i, n) cin >> a[i];
  rep(i, n) cnt[a[i]]++;

  ll X = 0;
  rep(i, n+1) {
    X += cnt[i]*(cnt[i]-1)/2;
  }

  rep(i, n) {
    ll ans = X - (cnt[a[i]]-1);
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[201010];
vector<int> V;
int ret[201010];
vector<int> E[201010];

void dfs(int cur,int pre) {
	int pos=lower_bound(ALL(V),A[cur])-V.begin();
	int rev;
	if(pos==V.size()) {
		rev=-1;
		V.push_back(A[cur]);
	}
	else {
		rev=V[pos];
		V[pos]=A[cur];
	}
	ret[cur]=V.size();
	
	
	FORR(e,E[cur]) if(e!=pre) dfs(e,cur);
	
	if(rev==-1) {
		V.pop_back();
	}
	else {
		V[pos]=rev;
	}
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[i];
	FOR(i,N-1) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
		E[y-1].push_back(x-1);
	}
	dfs(0,0);
	
	FOR(i,N) cout<<ret[i]<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 27532
def main():
    n = int(input())
    s = [0] * n
    t = [0] * n
    all_time_count = 0

    for i in range(n):
        s[i],t[i] = input().split()
        t[i] = int(t[i])
        all_time_count += t[i]
    x = input()
    time_count = 0
    for i in range(n):
        time_count += t[i]
        if s[i] == x:
            break
    print(all_time_count - time_count)




if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import heapq
import numpy as np
N = int(input())
A = list(map(int, input().split()))
heapq.heapify(A)

while len(A) > 1:
    not_zero = False
    my_min = heapq.heappop(A)
    A = np.array(A)
    A %= my_min
    A = list(A[A > 0])
    heapq.heapify(A)
    heapq.heappush(A, my_min)
print(A[0])

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

long long md(pair<long long,long long> x,pair<long long,long long> y){
    return max(x.first,y.first)-min(x.first,y.first)+max(x.second,y.second)-min(x.second,y.second);
}

int main(){
    int N,M;
    cin >> N >> M;
    char A[N][N],B[M][M];
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cin >> A[i][j];
        }
    }
    for(int i=0;i<M;i++){
        for(int j=0;j<M;j++){
            cin >> B[i][j];
        }
    }
    bool flag=1;
    string ans="No";
    for(int i=0;i<N-M+1;i++){
        for(int j=0;j<N-M+1;j++){
            flag=1;
            for(int k=0;k<M;k++){
                for(int l=0;l<M;l++){
                    if(A[k+i][l+j]!=B[k][l]){
                        flag=0;
                    }
                }
            }
            if(flag)
            ans="Yes";
        }
    }
    cout << ans << endl;
}

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

long long memo[87];


long long ryuka(int n){
  long long ret;
  if(n == 0){
    return 2;
  } else if (n == 1){
    return 1;
  } else if(memo[n] != -1){
    ret = memo[n];
  } else {
    ret = ryuka(n-1) + ryuka(n-2);
    memo[n] = ret;
  }
  return ret;
}


int main(){
  int h, w;
  int c[10][10];
  cin >> h >> w;
  int i, j;
  int a[h][w];
  for(i = 0; i < 10; i++){
    for(j = 0; j < 10; j++){
      cin >> c[i][j];
    }
  }
  for(i = 0; i < h; i++){
    for(j = 0; j < w; j++){
      cin >> a[i][j];
    }
  }
  int memo[10], tmp[10];
  for(i = 0; i < 10; i++){
    tmp[i] = c[i][1];
  }
  memo[1] = 0;
  int min = 1000,min_i,now_i = 1;
  vector<int> kakutei;
  kakutei.push_back(1);

  for(j = 0; j < 9; j++){
    for(i = 0; i < 10; i++){
      if(tmp[i] > memo[now_i] + c[i][now_i]){
        tmp[i] = memo[now_i] + c[i][now_i];
      }
    }
    min = 1000;
    for(i = 0; i < 10; i++){
      if(tmp[i] < min && find(kakutei.begin(),kakutei.end(),i) == kakutei.end()){
        min = tmp[i];
        min_i = i;
      }
      memo[i] = tmp[i];
    }
    now_i = min_i;
    kakutei.push_back(min_i);
  }

  long long ans = 0;

  for(i = 0; i < h; i++){
    for(j = 0; j < w; j++){
      if(a[i][j] != -1){
        ans += memo[a[i][j]];
      }
    }
  }


  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string x_elim = new string(input.Where(x => x != 'x').ToArray());
            int ans = -1;
            if (x_elim.Substring(0, x_elim.Length / 2) == new string(x_elim.Substring(x_elim.Length / 2 + x_elim.Length % 2, x_elim.Length / 2).Reverse().ToArray()))
            {
                ans++;
                //is Palindrome
                int i = 0;
                int j = input.Length - 1;
                while (true)
                {
                    while (input[i] == 'x')
                    {
                        if (i == j)
                            goto end;
                        if (input[j] == 'x')
                        {
                            i++;
                            j--;
                            if (i >= j)
                                goto end;
                        }
                        else
                        {
                            i++;
                            ans++;
                            if (i >= j)
                                goto end;
                        }
                    }

                    while (input[j] == 'x')
                    {
                        if (i == j)
                            goto end;
                        if (input[i] == 'x')
                        {
                            i++;
                            j--;
                            if (i >= j)
                                goto end;
                        }
                        else
                        {
                            j--;
                            ans++;
                            if (i >= j)
                                goto end;
                        }
                    }

                    i++;
                    j--;
                    if (i >= j)
                        goto end;
                }
            }

            end:
            Console.WriteLine(ans);

#if DEBUG
            Console.ReadKey();
#endif
        }
    }
}


Measured memory_bytes: 13536
while True:
	numbers = map(int, raw_input().split())
	max_ = numbers[0]
	goal = numbers[1]
	cnt = 0
	if max_ == 0 and goal == 0:
		break
	else:
		i = max_
		while 3 * i - 3 >= goal:
			j = i-1
			while goal - i - j < j:
				if goal - i - j > 0:
					cnt += 1
				j -= 1
			i -= 1
	print cnt

Measured memory_bytes: 6448
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <set>
#include <queue>
#include <math.h>
#include <algorithm>

using namespace std;

class Edge
{
public:
  int dst, d;
  Edge(int _dst, int _d)
  : dst(_dst), d(_d)
  {}
};
class Node
{
public:
  vector<Edge> E;
};

int main()
{
  int N, M;
  cin >> N >> M;
  vector<Node> Nodes(N);
  vector<int> flag(N, 0);
  for (int i =0;i<M;i++) {
    int a, b, z;
    cin >> a >> b >> z;
    Nodes[a-1].E.push_back(Edge(b-1, z));
    Nodes[b-1].E.push_back(Edge(a-1, z));
  }
  queue<int> q;
  int count = 0;
  for (int i=0; i<N;i++) {
    if (!flag[i]) {
      q.push(i);
      count++;
    }
    while (!q.empty()) {
      int index = q.front();
      Node& cur = Nodes[index];
      q.pop();
      for (int i = 0; i < cur.E.size(); i++) {
        if (flag[cur.E[i].dst] == 0) {
          flag[cur.E[i].dst] = 1;
          q.push(cur.E[i].dst);
        }
      }
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 7284
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let (n,m,x,y) = {
        let t = read_vec::<i64>();
        (t[0],t[1],t[2],t[3])
    };
    let mut xn = read_vec::<i64>();
    xn.sort();
    let mut yn = read_vec::<i64>();
    yn.sort();
    let x_end = xn[n as usize -1];
    let y_start = yn[0];
    if x_end < y_start {
        let diff = y_start - x_end;
        let ans = (1..diff+1).map(|s| x_end + s )
            .filter(|&s| x < s  && s <= y)
            .count();
        if ans != 0{
            println!("No War");
            return;
        }
    }
    println!("War");
}

Measured memory_bytes: 4352
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<cmath>
#include<cstring>
using namespace std;
int main(){
  int i,j,k,l;
  int n,m;
  while(cin>>n>>m,n||m){
    string s[1024][3];
    for(i=0;i<n;++i)
      cin>>s[i][2]>>s[i][0]>>s[i][1];
    vector<string> t;
    for(i=0;i<m;++i){
      string u[3];
      cin>>u[0]>>u[1]>>u[2];
      for(j=n-1;j>=0;--j){
	for(k=0;k<2;++k){
	  for(l=0;l<8;++l){
	    if(s[j][k][l]!='?'&&s[j][k][l]!=u[k][l])
	      break;
	  }
	  if(l<8)
	    break;
	}
	if(k==2){
	  if(s[j][2][0]=='d')
	    j=-1;
	  break;
	}
      }
      if(j>=0)
	t.push_back(u[0]+' '+u[1]+' '+u[2]);
    }
    cout<<t.size()<<endl;
    for(i=0;i<(int)t.size();++i)
      cout<<t[i]<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime>
using namespace std;

typedef pair<string,int> P;
int n,q,m;

vector<P> v[11];
vector<string> name;
map<string,int> sale;
int root[11][11];
const int INF=10000000;
int dpc[11][1<<15];
int dpd[11][1<<15];
int ac;
int ad;

void rec(int x,int bit,int c,int d){
	if(dpc[x][bit]<c)return;
	if(dpc[x][bit]==c && dpd[x][bit]<d)return;
	dpc[x][bit]=c;
	dpd[x][bit]=d;
	int nbit=bit;
	int nc=c;
	for(int i=0;i<v[x].size();i++){
		for(int j=0;j<name.size();j++){
			if(name[j]==v[x][i].first && !(bit >> j & 1) && sale[name[j]]==v[x][i].second){
				nbit |= 1<<j;
				nc+=v[x][i].second;
			}
		}
	}
	if(nbit==(1<<q)-1){
		if(nc<ac || (nc==ac && d+root[0][x]<ad)){
			ac=nc;
			ad=d+root[0][x];
		}
	}else{
		for(int i=1;i<=n;i++){
			int nd=d+root[i][x];
			if(dpc[i][nbit]>nc || (dpc[i][nbit]==nc && dpd[i][nbit]>nd)){
				dpc[i][nbit]=nc;
				dpd[i][nbit]=nd;
				rec(i,nbit,nc,nd);
			}
		}
	}
}


int main(void){
	while(1){
		ac=INF;
		ad=INF;
		bool ch=true;
		for(int i=0;i<=10;i++){
			for(int j=0;j<=10;j++){
				root[i][j]=INF;
			}
			root[i][i]=0;
			v[i].clear();
		}
		for(int i=0;i<=10;i++){
			for(int j=0;j<=(1<<15)-1;j++){
				dpc[i][j]=INF;
				dpd[i][j]=INF;
			}
		}
		name.clear();
		sale.clear();
		cin >> n;
		if(n==0)break;
		for(int i=1;i<=n;i++){
			int k;
			cin >> k;
			for(int j=0;j<k;j++){
				string str;
				int cost;
				cin >> str >> cost;
				v[i].push_back(P(str,cost));
				if(sale[str]==0)sale[str]=cost;
				else sale[str]=min(cost,sale[str]);
			}
		}
		cin >> q;
		for(int i=0;i<q;i++){
			string str;
			cin >> str;
			name.push_back(str);
			if(sale[str]==0)ch=false;
		}
		cin >> m;
		for(int i=0;i<m;i++){
			int s,t,d;
			cin >> s >> t >> d;
			root[s][t]=min(d,root[s][t]);
			root[t][s]=min(d,root[t][s]);
		}
		for(int k=0;k<=n;k++){
			for(int i=0;i<=n;i++){
				for(int j=0;j<=n;j++){
					root[i][j]=min(root[i][j],root[i][k]+root[k][j]);
				}
			}
		}
		if(ch)rec(0,0,0,0);
		if(ac>=INF || ch==false)cout << "impossible" << endl;
		else cout << ac << " " << ad << endl;
	}
    return 0;
}

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

int main(void) {
	string S;
	cin >> S;
	bool ans = false;
	if (S[0] != S[1]) ans = true;
	if (S[1] != S[2]) ans = true;
	if (S[2] != S[0]) ans = true;
	printf(ans ? "Yes" : "No");

	return 0;
}


Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
#define pb push_back

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

signed main(){
	int N;scanf("%lld",&N);
	int ans=0;
	REP(i,N+1){
		int j=N/i;
		ans+=(i+j*i)*j>>1;
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 3820
#include<bits/stdc++.h>
#define N 1000005 
#define LL long long 
using namespace std;
long long A[N];
int m=0;
char str[N]; 
bool cmp(int a,int b){
	return a>b;
}
void dfs(long long x,int k){
	if(x>1e10)return;
	A[m++]=x;
	//printf("x=%d %d\n",x,k);
	dfs(x*10+k,k); 
	if(k>0)dfs(x*10+k-1,k-1);
	if(k<9)dfs(x*10+k+1,k+1);
}
int main(){ 
	for(int i=1;i<10;i++)dfs(i,i); 
	sort(A,A+m); 
	int K;
	cin>>K;K--;
	cout<<A[K]<<endl; 
	
	return 0; 
} 

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    int x;cin>>x;
    int ans=0;
    for(int i=1;i<=x;i++){
        int c=i;
        for(int j=0;j<=x;j++){
            c*=i;
            if(c>x)break;
            ans=max(ans,c);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N,M;cin>>N>>M;
	vector<bool> ans(N+1, false);
	vector<int> cnt(N+1, 1);
	ans[1] = true;
	rep(i,M){
		int f,t;cin>>f>>t;
		--cnt[f]; ++cnt[t];
		if(!ans[t])ans [t] = ans[f];
		if(cnt[f] == 0){ans[f] = false;}
	}
	int ans_num = 0;
	REP(i,N){
		if(ans[i] && cnt[i]>0) ++ans_num;
	}
	cout<<ans_num<<endl;
	return 0;
}

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

int main() {
  
  int H,W;
  cin >> H >> W;
  
  vector<string> A(H+2);
  for(int i=0; i<W+2; i++){
  A.at(0)+='.';
  A.at(H+1)+='.';
  }
  for(int i=1; i<H+1; i++){
    cin >> A.at(i);
    A.at(i)='.'+A.at(i)+'.';
  }
  
  for(int i=1; i<H+1; i++){
    for(int j=1; j<W+1; j++){
      
      if(A.at(i).at(j)=='#'){
        cout << '#';
      }
      else{
        int k=0;
        for(int ii=i-1; ii<i+2; ii++){
          for(int jj=j-1; jj<j+2; jj++){
            if(A.at(ii).at(jj)=='#'){
              k++;
            }
          }
        }
        cout << k;
      }
      
      if(j==W){
        cout << endl;
      }
    }
  }
}

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

using namespace std;
 
int main() {
	int t, p;
	cin >> t >> p;
	if (p % 2 == 1) {
		cout << "No" << '\n';
	} else {
		if (p >= t * 2 && t * 4 >= p) {
			cout << "Yes" << '\n';
		} else {
			cout << "No" << '\n';
		}
	}
	
	
}

Measured memory_bytes: 3636
# -*- coding: utf-8 -*-
S = input().split()
 
s = str(S)
s = s[2:-2]

if s[0] == s[1]:
  if (s[2] == s[3]) and (s[2] != s[0]):
    print("Yes")
  else:
    print("No")
else:
  if s[2] == s[0]:
    if (s[3] == s[1]) and (s[3] != s[0]):
      print("Yes")
    else:
      print("No")
  elif s[2] == s[1]:
    if (s[3] == s[0]) and (s[3] != s[1]):
      print("Yes")
    else:
      print("No")
  else:
    print("No")

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

int main(){
    ll n,m;
    cin>>n>>m;
    vector<bool>s(200010,false);
    vector<bool>t(200010,false);
    rep(i,m){
        ll a,b;
        cin>>a>>b;
        if(a==1)s[b]=true;
        if(b==n)t[a]=true;
    }
    rep(i,200010){
        if(s[i] && t[i]){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
}



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

int N,M;
char fie[111][111];
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};

bool co[111][111];
bool used[111][111][4];

bool check( int x,int y){
  if( fie[x][y] != '#' ) return true;
  return false;
}

int dfs(int x,int y,int d){
  if( used[x][y][d] ) return -(1<<29);
  used[x][y][d] = true;
  int ret = 0;
  if( !co[x][y] ) ret=1;
  //  cout << x << " "<< y << endl;
  co[x][y] = true;
  if( fie[x][y] == 'G' ) return ret;
  int nd1 = (d+1)%4,nd2 = d, nd3 = (d+3)%4, nd4 = (d+2)%4;
  int nx1 = x + dx[nd1], ny1 = y + dy[nd1];
  int nx2 = x + dx[nd2], ny2 = y + dy[nd2];
  int nx3 = x + dx[nd3], ny3 = y + dy[nd3];
  int nx4 = x + dx[nd4], ny4 = y + dy[nd4];
  if( check( nx1, ny1 ) ) 
    ret += dfs( nx1, ny1, nd1 );
  else if( check( nx2, ny2 ) )
    ret += dfs( nx2, ny2, nd2 );
  else if( check( nx3, ny3 ) )
    ret += dfs( nx3, ny3, nd3 );
  else
    ret += dfs( nx4, ny4, nd4 );
  return ret;
}

int main(){
  cin >> N >> M;
  int sx,sy,sd;
  for(int i=0;i<=N+1;i++)
    for(int j=0;j<=M+1;j++)
      fie[j][i] = '#';
  for(int i=1;i<=N;i++){
    for(int j=1;j<=M;j++){
      cin >> fie[j][i];
      if( fie[j][i] != '.' && fie[j][i] != '#' && fie[j][i] != 'G' ){
	sx = j; sy = i;
	if( fie[j][i] == '^' ) sd = 0;
	if( fie[j][i] == '>' ) sd = 1;
	if( fie[j][i] == 'v' ) sd = 2;
	if( fie[j][i] == '<' ) sd = 3;
      }
    }
  }
  // cout << sx << " "<< sy << " "<< sd << endl;
  int res = dfs(sx,sy,sd);
  if( res < 0 ) cout << -1 << endl;
  else cout << res << endl;
  
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define fastIO                        \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL);                    \
	cout.tie(NULL);
// g++ -std=c++11 -O2 -Wall *.cpp -o *
#define eps 1e-9
#define MAX 10000001
#define MOD 1000000007
#define PI 3.14159265358979323846
#define Fi first
#define Se second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(), a.end()
typedef long long ll;
typedef pair<int, int> pr_int;



int main()
{
	//freopen("input.txt", "r", stdin);
	string s;
	int n;
	cin >> n >> s;
	for (int i = 0; i < s.size(); i++)
	{
		if (s[i] + n <= 'Z')
			s[i] += n;
		else
			s[i] = 'A' + n - ('Z' - s[i]) - 1;
	}
	cout << s;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long
#define pii pair<int,int>
#define pll pair<LL,LL>

using namespace std;

int uf[100001];

int root(int x){
    if(uf[x]<0)return x;
    return uf[x]=root(uf[x]);
}

void unite(int x,int y){
    x = root(x);
    y = root(y);

    if(x==y)return;
    if(uf[x]>uf[y])swap(x,y);
    uf[x] += uf[y];
    uf[y] = x;
}

int main(){

    int N,M;cin>>N>>M;
    vector<int> edge[M];
    fill_n(uf,N,-1);
    REP(i,N){
        int K;cin>>K;
        REP(j,K){
            int l;cin>>l;l--;
            edge[l].push_back(i);
        }
    }

    REP(i,M){
        for(int j=0;j<edge[i].size();j++){
            if(j>0)unite(edge[i][j],edge[i][j-1]);
        }

    }


    if(-uf[root(0)]==N)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}

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

#define F first
#define S second
#define nl '\n'
#define gcd __gcd
#define nset __builtin_popcount
#define pb push_back
#define pf push_front
#define mp make_pair
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define rep(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define nrep(i, a, b) for (int i = int(a); i >= int(b); i--)
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL)

using ll  = long long;
using ull = unsigned long long;
using vi  = vector<int>;
using vl  = vector<ll>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvl = vector<vl>;
using ii  = pair<int, int>;
using vii = vector<ii>;
using vs  = vector<string>;
using msi = map<string, int>;
using iss = istringstream;

ll mod(ll x, ll M)
{
    ll res = x % M;
    return (res >= 0 ? res : res + M);
}

int main()
{
    FASTIO;
    const ll M = 1e9 + 7;

    int n, k;
    cin >> n >> k;
    vl a(n);
    int pcnt = 0;

    rep(i, 0, n-1) {
        cin >> a[i];
        if(a[i] >= 0) pcnt++;
    }

    ll ans = 1;
    if(k == n) {
        rep(i, 0, n-1)
            ans = mod(ans*a[i], M);
        return cout << ans << nl, 0;
    }

    sort(all(a));

    if(pcnt == 0) {
        if(k&1) nrep(i, n-1, n-k) ans = mod(ans*a[i], M);
        else rep(i, 0, k-1) ans = mod(ans*a[i], M);
        return cout << ans << nl, 0;
    }

    int leave = -1;
    if(k&1) {
        nrep(i, n-1, 0) {
            if(a[i] >= 0) {
                leave = i;
                ans = a[i];
                k--;
                break;
            }
        }
    }

    stack<ll> ps, ns;
    rep(i, 0, n-1) if(a[i] >= 0 && i != leave) ps.push(a[i]);
    nrep(i, n-1, 0) if(a[i] < 0) ns.push(a[i]);

    while(k > 0) {
        if(ps.size() > 1 && ns.size() > 1) {
            ll px = ps.top(); ps.pop();
            ll py = ps.top(); ps.pop();

            ll nx = ns.top(); ns.pop();
            ll ny = ns.top(); ns.pop();

            if(px * py > nx * ny) {
                ans = mod(ans*mod(px*py, M), M);
                ns.push(ny);
                ns.push(nx);
            }
            else {
                ans = mod(ans*mod(nx*ny, M), M);
                ps.push(py);
                ps.push(px);
            }
        }
        else if(ps.size() > 1) {
            ll px = ps.top(); ps.pop();
            ll py = ps.top(); ps.pop();
            ans = mod(ans*mod(px*py, M), M);
        }
        else if(ns.size() > 1) {
            ll nx = ns.top(); ns.pop();
            ll ny = ns.top(); ns.pop();
            ans = mod(ans*mod(nx*ny, M), M);
        }
        else break;
        k -= 2;
    }

    cout << ans << nl;
    return 0;
}


Measured memory_bytes: 6352
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define pos first.first
#define dir first.second
#define ind second

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int main(void){
    for(int n, l; cin >> n >> l, n;){
        vector< pair< pair<int, char>, int > > ants(n);

        rep(i, n){
            cin >> ants[i].dir >> ants[i].pos;
            ants[i].ind = i + 1;
        }

        int res;
        int cnt = 0;
        while(1){
            sort(all(ants));

            bool run = false;
            rep(i, n){
                if(0 < ants[i].pos && ants[i].pos < l){
                    run = true;
                }
            }
            if(!run){
                rep(i, n){
                    if(ants[i].pos == 0 || ants[i].pos == l){
                        res = ants[i].ind;
                        break;
                    }
                }
                break;
            }

            rep(i, n){
                range(j, i + 1, n){
                    if(ants[j].pos - ants[i].pos == 2 && ants[i].dir == 'R' && ants[j].dir == 'L'){
                        swap(ants[i].ind, ants[j].ind);
                    }
                }
            }

            rep(i, n){
                int diff = ants[i].dir == 'R' ? 1:-1;
                ants[i].pos += diff;
            }

            cnt++;
        }

        cout << cnt << " " << res << endl;
    }

	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define rep2(i, l, r) for(Int i = (Int)(l); i < (Int)(r); ++i)
#define guard(x) if( not (x) ) continue;
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif

struct T {
   T(Int n_) : n(n_), xs(2*n,((Int)1<<31)-1), ls(2*n,0), rs(2*n,0) {
      rep2(i,n,2*n) {
         ls[i] = i-n;
         rs[i] = i-n+1;
      }
      for(Int i = n-1; i >= 1; --i) {
         ls[i] = ls[2*i];
         rs[i] = rs[2*i+1];
      }
   }
   Int n;
   std::vector<Int> xs;
   std::vector<Int> ls, rs;
   void update(Int i, Int x) {
      xs[n+i] = x;
      update2((n+i)/2);
   }
   void update2(Int i) {
      if( i == 0 ) return;
      xs[i] = std::min(xs[2*i], xs[2*i+1]);
      update2(i/2);
   }
   Int find(Int l, Int r, Int i = 1) {
      if( l <= ls[i] and rs[i] <= r ) return xs[i];
      if( rs[i] <= l or r <= ls[i] ) return ((Int)1<<31) - 1;
      return std::min(find(l,r,2*i),find(l,r,2*i+1));
   }
};

int main() {
   Int n, q;
   std::cin >> n >> q;
   T t(131072);
   rep(i,q) {
      Int c, x, y;
      std::cin >> c >> x >> y;
      if( c == 0 ) {
         t.update(x,y);
      }
      else {
         printf("%ld\n", t.find(x,y+1));
      }
   }
}



Measured memory_bytes: 8912
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt(), m = scan.nextInt();
        int[] num = new int[n];
        boolean[] found = new boolean[n];
        //int min = Integer.MAX_VALUE;
        for (int i = 0; i < m; i ++){
            int a = scan.nextInt(), b = scan.nextInt();
            if (found[a - 1]){
                if (num[a - 1] != b){
                    System.out.println("-1");
                    return;
                }
            }
            else{
                found[a - 1] = true;
                num[a - 1] = b;
            }
        }
        if (num[0] == 0 && n != 1 && found[0]){
            System.out.println("-1");
            return;
        }
        if (num[0] == 0 && n != 1){
            num[0] = 1;
        }
        for (int i : num)
            System.out.print(i);
        

    }
}


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

#define fast                     \
    ios::sync_with_stdio(false); \
    cin.tie(NULL);               \
    cout.tie(NULL)
#define int long long
#define endl '\n'

using namespace std;

const int N = 2e5 + 77, mod = 1e9 + 7;
int A[N];

int32_t main()
{
    fast;
    int n;
    cin >> n;
    int a = 1, b = 1, c = 1;
    for (int i = 0; i < n; ++i)
    {
        a = a*10 % mod;
        b = b*9 % mod;
        c = c*8 % mod;
    }
    cout << (3*mod+a-2*b+c)%mod << endl;
    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001;
struct segtree{
    vector<pint>dat;
    static const int N=1<<18;
    segtree():dat(N*2,pint(INF,-1)){}
    void init(vector<int> &v){
        for(int i=0;i<v.size();i++)dat[i+N-1]={v[i],i};
        for(int i=N-2;i>=0;i--)dat[i]=min(dat[i*2+1],dat[i*2+2]);
    }
    pint get_min(int a,int b,int k,int l,int r){
        if(r<=a||b<=l)return pint(INF,-1);
        if(a<=l&&r<=b)return dat[k];
        return min(get_min(a,b,k*2+1,l,(l+r)/2),get_min(a,b,k*2+2,(l+r)/2,r));
    }
    pint get_min(int a,int b){return get_min(a,b,0,0,N);}
};

int N;
int P[222222];

segtree odd,even;

int cur;
vint G[222222];
pint val[222222];

void solve(int l,int r){
    int x,y;
    if(l%2==0){
        x=even.get_min(l,r).se;
        y=odd.get_min(x+1,r).se;
    }
    else{
        x=odd.get_min(l,r).se;
        y=even.get_min(x+1,r).se;
    }

    val[cur]={P[x],P[y]};

    int v=cur;
    cur++;
    if(x!=l){
        G[v].pb(cur);
        solve(l,x);
    }
    if(x+1!=y){
        G[v].pb(cur);
        solve(x+1,y);
    }
    if(y+1!=r){
        G[v].pb(cur);
        solve(y+1,r);
    }
}

struct data{
    pint p;
    int k;
    data(pint p,int k):p(p),k(k){}
};

bool operator<(const data &a,const data &b){
    return a.p>b.p;
}

signed main(){
    cin>>N;
    rep(i,N)cin>>P[i];

    vint latte(N);
    rep(i,N){
        if(i%2==0)latte[i]=P[i];
        else latte[i]=INF;
    }
    even.init(latte);

    rep(i,N){
        if(i%2==1)latte[i]=P[i];
        else latte[i]=INF;
    }
    odd.init(latte);

    solve(0,N);
    priority_queue<data>que;
    que.push(data(val[0],0));
    vint ans;
    while(que.size()){
        pint p=que.top().p;
        int k=que.top().k;
        que.pop();
        ans.pb(p.fi);
        ans.pb(p.se);
        for(auto u:G[k]){
            que.push(data(val[u],u));
        }
    }
    rep(i,N){
        if(i)cout<<" ";
        cout<<ans[i];
    }cout<<endl;
    return 0;
}


Measured memory_bytes: 52848
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;cin>>n;
  ll a[n];for(ll i=0;i<n;i++)cin>>a[i];
  ll ans=0;
  for(ll i=0;i<n-1;i++){
    if(a[i+1]%2==a[i]%2){
      ll m=min(a[i+1],a[i]);
      a[i+1]-=m;
      a[i]-=m;
      ans+=m;
      ans+=a[i]/2;
    }
    else if(a[i]%2==0){
      ans+=a[i]/2;
    }
    else if(a[i]%2==1){
      if(a[i+1]==0){
        ans+=a[i]/=2;
      }
      else{
        ans++;
        a[i]--;
        a[i+1]--;
        ans+=a[i]/2;
      }
    }
  }
  ans+=a[n-1]/2;
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n; cin >> n;
	vi a(n), ans(n * n, -1);
	REP(i, n)
	{
		cin >> a[i];
		ans[a[i] - 1] = i + 1;
	}
	vector<pii> v;
	REP(i, n) v.emplace_back(a[i], i);
	sort(ALL(v));
	int p = 0;
	REP(i, n)
	{
		int tmp = v[i].second;
		while (tmp > 0)
		{
			while (ans[p] >= 0) p++;
			ans[p] = v[i].second + 1;
			tmp--;
		}
	}
	p = n * n - 1;
	for (int i = n - 1; i >= 0; i--)
	{
		int tmp = n - v[i].second - 1;
		while (tmp > 0)
		{
			while (ans[p] >= 0) p--;
			ans[p] = v[i].second + 1;
			tmp--;
		}
	}
	bool f = true;
	REP(i, n)
	{
		int cnt = 0;
		REP(j, n * n)
		{
			if (ans[j] == i + 1) cnt++;
			if (cnt == i + 1)
			{
				if (a[i] - 1 != j) f = false;
				break;
			}
		}
	}
	if (f)
	{
		cout << "Yes" << endl;
		REP(i, n * n) cout << ans[i] << (i == n * n - 1 ? "\n" : " ");
	}
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 2176
n = 1
j = 0
arry = []
a = []
b = []
a_sum = []
b_sum = []
while n != 0
	n = gets.to_i
	a_sum[j] = 0
	b_sum[j] = 0
	n.times do |i|
		arry = gets.split{" "}
		a[i] = arry[0].to_i
		b[i] = arry[1].to_i
		if a[i] > b[i]
			a_sum[j] += (a[i] + b[i])
		elsif b[i] > a[i]
			b_sum[j] += (a[i] + b[i])
		else
			a_sum[j] += a[i]
			b_sum[j] += b[i]
		end
	end
	j += 1
end
(j - 1).times do |k|
	printf "#{a_sum[k]} #{b_sum[k]}\n"
end

Measured memory_bytes: 6384
#include <iostream>
using namespace std;
int main(){
  int a;
  cin >> a;
  int b;
  int count;
  int maxC;
  for(int k = 0; k < a; k++){
    cin >> b;
    for(int i = 1; b % 2 == 0; i++){
    	b /= 2;
        count = i;
    }
    if(k == 0)maxC = count;
    else if(maxC > count)maxC = count;
  }
  cout << maxC << endl;;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  int n; std::cin >> n;
  for(size_t i = 1; i <= 9; ++i)
    for(size_t j = 1; j <= 9; ++j)
      if(i*j == n) {
        std::cout << "Yes";
        return 0;
      }
  std::cout << "No";
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
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;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int main() {
	string s;
	cin >> s;
	string sreverse = s;
	reverse(sreverse.begin(), sreverse.end());
	for (int i = 0; i < s.size(); i++) {
		if (sreverse[i] != s[i]) {
			cout << "No";
			return 0;
		}
	}
	string s1, s2;
	for (int i = 0; i < (s.size() - 1) / 2; i++) {
		s1 = s1 + s[i];
	}
	s2 = s1;
	reverse(s2.begin(), s2.end());
	for (int i = 0; i < s1.size(); i++) {
		if (s1[i] != s2[i]) {
			cout << "No";
			return 0;
		}
	}
	string s3 = s.substr((s.size() + 3) / 2-1);
	string s4 = s3;
	reverse(s4.begin(), s4.end());
	for (int i = 0; i < s4.size(); i++) {
		if (s3[i] != s4[i]) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";
}


Measured memory_bytes: 256
def f(n):
  ret=0
  while n%2==0:
    ret+=1
    n/=2
  return ret
n=int(input())
ans=0
max_=0
for a in range(1,n+1):
  if f(a)>=max_:
    max_=f(a)
    ans=a
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define per(i,s,n) for(int i=n-1;i>=s;i--)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  int n;
  int h;
  int now=0;
  int ans=0;
  cin>>n;
  rep(i,n){
    cin>>h;
    if(h>=now){
      ans++;
      now=h;
    }
  }
  
  cout<<ans<<endl;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int N; cin >> N;
  vector<vector<pair<int, int>>> G(N);
  rep(i, N) {
    int K; cin >> K;
    rep(k, K) {
      int x, y; cin >> x >> y; x--;
      G[i].emplace_back(x, y);
    }
  }
  int max_honest = 0;
  rep(S, 1 << N) {
    bool ok = 1;
    rep(i, N) if (S >> i & 1) {
      rep(k, G[i].size()) {
        ok = ok && ((S >> G[i][k].first & 1) == (G[i][k].second));
      }
    }
    if (ok) {
      max_honest = max(max_honest, __builtin_popcount(S));
    }
  }
  cout << max_honest << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>

#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 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

int main(){

    string s;
    int b,c,d;
    vector<int> a(3);
    int count = 0;
    for(int i = 0;i < 3;i++){
        cin >> a[i];
    }

    sort(a.begin(),a.end());

    count = (a[2]-a[1])+(a[1]-a[0]);

    cout << count << endl;


    return 0;
}

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

#define lson l, m, o<<1
#define rson m + 1, r, o<<1|1

typedef long long LL;

const int N = 1e5 + 1;

int n;
int cnt;
std::vector<int> G[N];
int id[N << 1];
LL sum[N << 3];

void dfs(int u, int p) {
  id[u] = cnt;
  cnt ++;
  for (int &to : G[u]) {
    if (to != p) {
      dfs(to, u);
    }
  }
  id[u + n] = cnt;
  cnt ++;
}

void up(int o) {
  sum[o] = sum[o << 1] + sum[o << 1 | 1];
}

void modify(int x, int v, int l, int r, int o) {
  if (l == r) {
    sum[o] += v;
    return ;
  }
  int m = (l + r) >> 1;
  if (x <= m) modify(x, v, lson);
  else if (x > m) modify(x, v, rson);
  up(o);
}

LL get(int L, int R, int l, int r, int o) {
  if (L <= l && R >= r) return sum[o];
  int m = (l + r) >> 1;
  LL res = 0;
  if (L <= m) res += get(L, R, lson);
  if (R > m) res += get(L, R, rson);
  return res;
}

int main() {
  std::cin >> n;
  for (int i = 0; i < n; ++i) {
    int k;
    std::cin >> k;
    for (int j = 0; j < k; ++j) {
      int x;
      std::cin >> x;
      G[i].emplace_back(x);
    }
  }
  cnt = 1;
  dfs(0, 0);
  memset(sum, 0, sizeof(sum));
  int q;
  std::cin >> q;
  while (q --) {
    int op;
    std::cin >> op;
    if (op == 0) {
      int v, c;
      std::cin >> v >> c;
      modify(id[v], c, 1, 2 * n,  1);
      modify(id[v + n], -c, 1, 2 * n, 1);
    } else {
      int v;
      std::cin >> v;
      std::cout << get(1, id[v], 1, 2 * n, 1) << std::endl;
    }
  }
  return 0;
}



Measured memory_bytes: 20276
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = Integer.parseInt(scanner.nextLine());
        String[] ta = scanner.nextLine().split(" ", 2);
        int t = Integer.parseInt(ta[0]);
        int a = Integer.parseInt(ta[1]);

        String[] hLine = scanner.nextLine().split(" ", n);
        double minDiff = 100000.0;
        int minInd = 0;
        for (int i = 0; i < n; i++) {
            int h = Integer.parseInt(hLine[i]);
            double temp = (double)t - (double)h * 0.006;
            double diff = Math.abs((double)a - temp);
            if (diff < minDiff) {
                minDiff = diff;
                minInd = i;
            }
        }
        System.out.println(minInd + 1);
    }
}

Measured memory_bytes: 24916
s = input()
k = int(input())

if len(s) == 1:
    print(s)
    exit()

if s[0] == "1":
    if k == 1:
        print(1)
        exit()
    else:
        for i in range(len(s)):
            if s[i] == "1":
                continue
            elif (s[i] != "1") and (i+1 <= k):
                print(s[i])
                exit()
            elif (s[i] != "1") and (i+1 > k):
                print(1)
                exit()
        print(1)
        exit()

elif s[0] != "1":
    print(s[0])
    exit()


Measured memory_bytes: 61960
using System;
using System.Linq;
using System.Collections.Generic;

class MyClass
{
    public static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var X = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var M = int.Parse(Console.ReadLine());
        var A = Console.ReadLine().Split().Select(int.Parse).ToArray();
        for (int i = 0; i < M; i++)
        {
            var j = A[i] - 1;
            if (X[j] != 2019 && !X.Contains(X[j]+1))
            {
                X[j] += 1;
            }
        }
        for (int i = 0; i < N; i++)
        {
            Console.WriteLine(X[i]);
        }
    }
}


Measured memory_bytes: 20348