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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

using Weight = int;
using Flow = int;
struct Edge {
	int s, d; Weight w; Flow c; int id;
	Edge() {};
	Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {};
};
bool operator<(const Edge &e1, const Edge &e2) { return e1.w < e2.w; }
bool operator>(const Edge &e1, const Edge &e2) { return e2 < e1; }
inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); }

using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

void addArc(Graph &g, int s, int d, Weight w = 1) {
	g[s].emplace_back(s, d, w);
}
void addEdge(Graph &g, int a, int b, Weight w = 1) {
	addArc(g, a, b, w);
	addArc(g, b, a, w);
}


signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N, Q; cin >> N >> Q;

	Graph g(N);

	vector<int>a(N - 1), b(N - 1); rep(i, 0, N - 1) { cin >> a[i] >> b[i]; a[i]--, b[i]--; addEdge(g, a[i], b[i]); }

	vector<int>ans(N);
	vector<int>p(Q), x(Q); rep(i, 0, Q) { cin >> p[i] >> x[i]; p[i]--; ans[p[i]] += x[i]; }

	dump(ans);
	function<void(int, int)>dfs = [&](int v, int p) {

		for (auto e : g[v]) {
			if (e.d == p)continue;
			ans[e.d] += ans[v];
			dfs(e.d, v);
		}

	};
	dfs(0, -1);
	rep(i, 0, N) {
		cout << ans[i] << (i == N - 1 ? '\n' : ' ');

	}




	return 0;
}


Measured memory_bytes: 50176
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

// https://beta.atcoder.jp/contests/abc063/tasks/abc063_b

int main() {
    string S; cin >> S;
    map<char, int> mp;

    REP(i, S.length()) {
        if (mp[S[i]]) {
            cout << "no" << "\n";
            return 0;
        }
        mp[S[i]]++;
    }

    cout << "yes" << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> dia;
  int n,s;
  cin>>n;
  for(int i=0;i<n;i++){
    int k;
    cin>>k;
    dia.push_back(k);
  }
  sort(dia.begin(),dia.end());
  s=n;
  for(int i=0;i<n-1;i++){
    if(dia.at(i)==dia.at(i+1))
      s-=1;
  }
  cout<<s;
}

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

// t[ti]とh[hi]交換する関数
void change(vector<int>& t, vector<int>& h, int ti, int hi) {
	int tmp = t[ti];
	t[ti] = h[hi];
	h[hi] = tmp;
}
int sum(vector<int> t) {
	int sum = 0;
	for (int i = 0; i < t.size(); i++) {
		sum += t[i];
	}
	return sum;
}
int main()
{
	int n, m, curSum, ta, ha;
	vector<int> defT, defH, t, h;
	
	while (cin >> n >> m) {
		if (n == 0 && m == 0) {
			break;
		}

		// 入力の読み込み
		curSum = -1;
		ta = ha = 0;
		t.clear();
		t.resize(n);
		h.clear();
		h.resize(m);
		defT.clear();
		defT.resize(n);
		defH.clear();
		defH.resize(m);
		for (int i = 0; i < n; i++) {
			int tmp = 0;
			cin >> tmp;
			t[i] = tmp;		
			defT[i] = tmp;
		}
		for (int j = 0; j < m; j++) {
			int tmp = 0;
			cin >> tmp;
			h[j] = tmp;
			defH[j] = tmp;
		}

		/*for (int i = 0; i < n; i++) cout << t[i] << flush;
		cout << endl;
		for (int i = 0; i < n; i++) cout << h[i] << flush;
		cout << endl;*/

		bool flg = false;
		for (int i = 0; i < n; i++) {

			for (int j = 0; j < m; j++) {
				// 太郎と花子のカードを交換する
				change(t, h, i, j);
			
				/*for (int k = 0; k < n; k++) cout << t[k] << flush;
				cout << endl;
				for (int k = 0; k < n; k++) cout << h[k] << flush;
				cout << endl;
				cout << endl;*/

				int st = sum(t);
				int ht = sum(h);
				//cout << st << " " << ht << endl;
				if (sum(t) == sum(h)) {
					if (curSum == -1 || curSum > t[i] + h[j]) {
						//cout << "d" << endl;
						curSum = t[i] + h[j];
						ta = i;
						ha = j;
					}
					
				}

				// カードの状態をリセット(交換し直せば良いはず)
				change(t, h, i, j);
			}
		}

		// 出力
		if (curSum == -1) {
			//cout << t[ta]+h[ha] << " " << ta << " " << ha << endl;
			cout << -1 << endl;
		} else {
			//cout << t[ta]+h[ha] << " " << t[ta] << " " << h[ha] << endl;
			cout << t[ta] << " " << h[ha] << endl;
		}
		
	}

	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int max_price = 0;
    int res = 0;
    for(int i=0; i<n; i++){
        int price;
        cin >> price;
        max_price = max(price, max_price);
        res += price;
    }
    res -= max_price/2;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
//B - Not Found: 
//Assunto:
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    string s;
    vector<bool> show(26, false);
    cin >> s;
    for(auto x : s) show[x-'a'] = true;
    loop(i, 0, 26) {
        if(!show[i]) {
            cout << (char)(i+'a') << "\n";
            return 0;
        }
    }
    cout << "None\n";
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
char s[100], t[100];
int main() {
  scanf("%s%s", s, t);
  int n = strlen(s), m = strlen(t);
  for (int i = n - m; ~i; --i) {
    int j;
    for (j = 0; j < m; ++j)
      if (s[i + j] != t[j] && s[i + j] != '?') break;
    if (j >= m) {
      for (int j = 0; j < i; ++j) putchar((s[j] == '?') ? 'a' : s[j]);
      for (int j = 0; j < m; ++j) putchar(t[j]);
      for (int j = i + m; j < n; ++j) putchar((s[j] == '?') ? 'a' : s[j]);
      return 0;
    }
  }
  puts("UNRESTORABLE");
  return 0;
}

Measured memory_bytes: 128
#encoding utf-8
from operator import itemgetter


n,t = map(int, input().split())

ct = []
for i in range(n):
    c_0,t_0 = map(int, input().split())
    ct.append([c_0,t_0])

time_flag = 0
for i in range(len(ct)):
    if ct[i][1] <= t:
        time_flag += 1
    else:
        ct[i][0] = 1001

ct0=list(ct)
ct.sort(key=itemgetter(0))
# print(ct)

if time_flag == 0:
    print("TLE")
else:
    print(ct[0][0])

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#define pb push_back
using namespace std;
int w,ta,yo;
int a,b,c,d,i,j,n;
int mat[2005][2005];
void dfs(int x,int y){
  if(x>=0 && y>=0 && x<=ta-1 && y<=yo-1 && mat[x][y]==0){
      mat[x][y]=1;
      dfs(x-1,y);
      dfs(x+1,y);
      dfs(x,y-1);
      dfs(x,y+1);
  }
  return;
}
int main(void){
  scanf("%d%d",&ta,&yo);
  while(ta!=0){
    scanf("%d",&n);
    vector<int> zg,sy;
    vector<int>::iterator ita,itb;
    map<int,int> mapa,mapb;
    int dat[1000][4];
    memset(mat,0,sizeof(mat));
    for(i=0;i<n;i++){
      for(j=0;j<4;j++)scanf("%d",&(dat[i][j]));
      zg.pb(dat[i][0]);zg.pb(dat[i][2]);
      sy.pb(dat[i][1]);sy.pb(dat[i][3]);
    }
    zg.pb(0);zg.pb(ta);
    sy.pb(0);sy.pb(yo);
    sort(zg.begin(),zg.end());
    zg.erase(unique(zg.begin(),zg.end()),zg.end());
    sort(sy.begin(),sy.end());
    sy.erase(unique(sy.begin(),sy.end()),sy.end());
    i=0;
    for(ita=zg.begin();ita!=zg.end();ita++){
      //printf("%d ",*ita);
      mapa[*ita]=i;
      i++;
    }
    ta=mapa[ta];
    //printf("\n");

    i=0;
    for(ita=sy.begin();ita!=sy.end();ita++){
      //printf("%d ",*ita);
      mapb[*ita]=i;
      i++;
    }
    yo=mapb[yo];

    //printf("\n");
    for(i=0;i<n;i++){
      a=mapa[dat[i][0]];b=mapb[dat[i][1]];
      c=mapa[dat[i][2]];d=mapb[dat[i][3]];
      mat[a][b]++;
      mat[a][d]--;
      mat[c][b]--;
      mat[c][d]++;
    }
    /*
    for(i=0;i<=ta;i++){
      for(j=0;j<=yo;j++){
	printf("%d ",mat[i][j]);
      }
      printf("\n");
      }*/
    for(i=1;i<=ta+1;i++){
      for(j=0;j<=yo+1;j++){
	mat[i][j]+=mat[i-1][j];
      }
    }
    for(i=0;i<=ta+1;i++){
      for(j=1;j<=yo+1;j++){
	mat[i][j]+=mat[i][j-1];
      }
    }
    /*printf("\n");
    for(i=0;i<ta;i++){
      for(j=0;j<yo;j++){
	printf("%d ",mat[i][j]);
      }
      printf("\n");
      }*/
    int ans=0;
    for(i=0;i<ta;i++){
      for(j=0;j<yo;j++){
	if(mat[i][j]==0){
	  ans++;
	  dfs(i,j);
	}
      }
    }
    printf("%d\n",ans);
    scanf("%d%d",&ta,&yo);
  }
  return 0;
}

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

template<class T>
class segTree{
    vector<T> tree;             // 木を示す配列
    int N;                      // 木で保持しているノード数
    T def_val;                  // 範囲外値(初期値)
    function<T(T,T)> selector;  // 選択関数(max, min, sum etc...)

    public: 
        // 初期化
        segTree(vector<T> &v, function<T(T,T)> f, T default_val){
            int n = v.size();
            N = pow(2, ceil(log2(n))); 
            tree.resize(2*N-1);
            selector = f;
            def_val = default_val;

            for(int i=0;i<N;i++) tree[N-1+i] = (i>=n?def_val:v[i]);
            for(int i=N-2;i>=0;i--) tree[i] = selector(tree[2*i+1], tree[2*i+2]);
        };

        // 値の更新
        void update(int ind, T val){
            ind += N - 1;
            tree[ind] = val;
            while(ind > 0){
                ind = (ind - 1) / 2;
                tree[ind] = selector(tree[2*ind+1], tree[2*ind+2]);
            }
        };

        // 値の取得(半閉区間[a,b)の範囲)
        T query(int a, int b, int ind = 0, int l = 0, int r = -1){
            if(r < 0) r = N;
            if(r <= a || b <= l) return def_val;
            if(a <= l && r <= b) return tree[ind];
            else return selector(query(a, b, 2*ind+1, l, (l+r)/2), 
                                 query(a, b, 2*ind+2, (l+r)/2, r));
        };
};

vector<int> charm(char x){
    vector<int> def(27);
    def[x-'a']++;
    return def;
}

int spe(vector<int> x){
    int ret = 0;
    for(int c = 0; c < x.size(); c++){
        if(x[c] > 0)ret++;
    }
    return ret;
}

int main(){
    int n;
    string s;
    int q;
    cin >> n >> s >> q;
    int t;
    vector<vector<int>> tables(n, vector<int>(27));
    for(int i=0;i<n;i++){
        for(int c = 0; c < tables[i].size(); c++){
            tables[i][c] = (c == s[i] - 'a'?1:0);
        }
    }
    vector<int> def(27);
    segTree<vector<int>> tr(tables, [](vector<int> x, vector<int> y){
        vector<int> ret(27);
        for(int i=0;i<x.size();i++){
            ret[i] = x[i] + y[i];
        }        
        return ret;
    }, def);

    for(int i=0;i<q;i++){
        cin >> t;
        if(t == 1){
            int pos;
            char c;
            cin >> pos >> c;
            tr.update(--pos, charm(c));
        }else if(t == 2){
            int left, right;
            cin >> left >> right;
            cout << spe(tr.query(--left, right)) << endl;
        }
    }
}

Measured memory_bytes: 230660
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @author Pavel Mavrin
 */
public class Main {

    private void solve() throws IOException {
        long a = nextInt();
        long b = nextInt();
        long c = nextInt();
        for (int i = 0; i < 1000; i++) {
            if (a % 2 == 1 || b % 2 == 1 || c % 2 == 1) {
                out.println(i);
                return;
            }
            long aa = (b + c) / 2;
            long bb = (a + c) / 2;
            long cc = (a + b) / 2;
            a = aa;
            b = bb;
            c = cc;
        }
        out.println(-1);
    }

    // ------------------

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st;
    PrintWriter out = new PrintWriter(System.out);

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

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

    private void run() throws IOException {
        solve();
        out.close();
    }

}


Measured memory_bytes: 23124
// cf.) https://atcoder.jp/contests/abc057/submissions/7555104

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

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

    ll n; cin >> n;
    int ans = 1e6;
    for (ll i = 1; i*i <= n; ++i) {
        if (n % i == 0) {
            int tmp = (int)max(log10(i)+1, log10(n/i)+1);
            ans = min(ans, tmp);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#define ll long long

int main(){
  ll n,k,s,a[100002],i;
  scanf("%lld%lld%lld",&n,&k,&s);
  if(s!=1000000000){
    for(i=0;i<k;i++){
      printf("%lld ",s);
    }
    for(i=k;i<n;i++){
      printf("1000000000 ");
    }
  }else{
    for(i=0;i<k;i++){
      printf("%lld ",s);
    }
    for(i=k;i<n;i++){
      printf("1 ");
    }
  }
  return 0;
}

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

using namespace std;

int main()
{
    int n , m ;
    scanf("%d %d" , &n , &m);
    if(n == 1)
        return printf("%d" , m) , 0 ;
    int ans = 1 ;
    for(int i = 1 ; i <= m ; ++i)
    {
        int x = i*(n-1) ;
        if(x >= m)
         break;
        if((m - x) % i == 0)
            ans = i ;
    }
    return printf("%d" , ans) , 0 ;
}


Measured memory_bytes: 256
import itertools
import math

n = int(input())
sv = [[0 for i in range(n)] for _ in range(n)]
num = [j for j in range(n)]
d = []
dis_sum = 0
count = 0
count2 = 0

for _ in range(n):
    tmpx, tmpy = map(int, input().split())
    d.append([tmpx, tmpy])

for v in itertools.permutations(num, n):
    count += 1
    v = list(v)
    for i in range(n - 1):
        if sv[v[i]][v[i + 1]] != 0:
            dis_sum += sv[v[i]][v[i + 1]]
        else:
            tmp1, tmp2 = d[v[i]][0] - d[v[i + 1]][0], d[v[i]][1] - d[v[i + 1]][1]
            tmp = math.sqrt(abs(tmp1) ** 2 + abs(tmp2) ** 2)
            dis_sum += tmp
            sv[v[i]][v[i + 1]] = tmp

print(dis_sum / count)


Measured memory_bytes: 3064
from sys import stdin

a, b = [int(x) for x in stdin.readline().split()]

while b != 0:
    a, b = b, a % b

c = 1
lim = a ** 0.5 + 10
n = 0
i = 2
while a > 1 and i <= lim:
    n = 0
    while a % i == 0:
        a //= i
        n += 1
    if n > 0:
        c += 1
    i += 1
if a > 1:
    c += 1

print(c)


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


int main() {
  int N;
  cin>>N;
  vector<long> a(N);
  vector<long> b(N);
  for(int i=0;i<N;i++) cin>>a[i]>>b[i];
  vector<vector<long>> c(N,vector<long>(2));
  for(int i=0;i<N;i++) c[i][0]=a[i]+b[i],c[i][1]=i;
  sort(c.begin(),c.end());
  reverse(c.begin(),c.end());
  long A=0,B=0;
  for(int i=0;i<N;i++){
    if(i%2) B+=b[c[i][1]];
    else A+=a[c[i][1]];
  }
  cout<<A-B<<endl;
}


Measured memory_bytes: 10316
#include <bits/stdc++.h>
#define INF 1000000007
#define MAX_N 200
using namespace std;

int d[MAX_N + 1][MAX_N + 1];

void warshall_floyd(int n) {
    for (int k = 1; k <= n; k++) {
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

int dfs(int r[], int n, int start, short bit_set) {
    if (n == 0)
        return 0;
    int i = 0, ret = INF;
    short b = bit_set;
    while (b > 0) {
        if (b & 1)
            ret = min(ret, d[start][r[i]] + dfs(r, n - 1, r[i], bit_set ^ (1 << i)));
        i++;
        b >>= 1;
    }
    return ret;
}

int main() {
    int N, M, R;
    cin >> N >> M >> R;
    int r[R];
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            d[i][j] = (i == j) ? 0 : INF;
        }
    }
    for (int i = 0; i < R; i++) {
        cin >> r[i];
    }
    for (int i = 0; i < M; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        d[a][b] = c;
        d[b][a] = c;
    }
    warshall_floyd(N);
    int ans = INF;
    for (int i = 0; i < R; i++) {
        ans = min(ans, dfs(r, R - 1, r[i], ((1 << R) - 1) ^ (1 << i)));
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
  std::string S ;
  cin >> S ;
  std::vector< std::string > judge = {"maerd" , "remaerd" , "esare" , "resare"} ;
  reverse(S.begin(), S.end()) ;

  int count = 0 ;
  std::string r ;
  for(int i = 0 ; i <= S.size() ; i++)
  {
    if(count >= 5 || i == S.size())
    {
      if(i == S.size())
      {
        cout << "YES" << endl;
        return 0 ;
      }

      for(int j = 0 ; j < 4 ; j++)
      {
        if(judge.at(j) == r)
        {
          count = 0 ;
          r  = "";
        }
      }
    }

    count++ ;
    r += S.at(i) ;
    //cout << count << " " << r << endl ;
    if(count >= 8)
    {
      cout << "NO" << endl ;
      return 0 ;
    }
    

  }


}


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

main(){
	int S;
	cin  >> S;
	int A[1000000];
	A[0] = S;
	int m = -1;
	for (int i=1;i<1000000;i++){
		if (A[i-1] % 2 == 0)
			A[i] = A[i-1]/2;
		else
			A[i] = 3 * A[i-1] + 1;
		for(int j=0;j<i;j++){
			if(A[j] == A[i]){
				m = i + 1;
				break;
			}
		}
		if(m>0)
			break;
	}
	cout << m << endl;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int pre[100005],bk[100005];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=0;i<n;i++)
		scanf("%d",&a[i]);
	int mx=0,t1,t2;
	pre[0]=a[0];
	for(int i=1;i<n;i++)
		pre[i]=__gcd(pre[i-1],a[i]);
	bk[n-1]=a[n-1];
	for(int i=n-2;i>=0;i--)
		bk[i]=__gcd(bk[i+1],a[i]);
	int ans=0;
	for(int i=0;i<n;i++)
		ans=max(ans,__gcd(pre[i-1],bk[i+1]));
	printf("%d\n",ans);
}


Measured memory_bytes: 1408
// abc128_b
#include<iostream>
#include <iterator>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(int argc, char *argv[])
{
  int n,p;
  string s;
  cin>>n;
  vector<pair<pair<string, int>, int> > spv;
  for (int i=0;i<n;++i) {
    cin>>s>>p;
    spv.emplace_back(make_pair(s, -p), i);
  }
  sort(spv.begin(), spv.end());
  for (auto x : spv) {
    cout<<x.second+1<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n;cin>>n;
    vector<pair<int,int>> a;
    for(int i=0;i<n;i++){
        int x;cin>>x;
        a.push_back(make_pair(x,i+1));
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++){
        cout<<a[i].second<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 1780
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = (1<<30);

struct SegT
{
  vector<int> tree;
  int n;
 
  SegT(int n_)
  {
    n = 1;
    while( n < n_ ) n <<= 1;
    tree = vector<int>(2 * n - 1, 0);
  }
  int rmq(int a, int b, int k, int l, int r)
  {
    if( a >= r || b <= l ) return 0;
    if( a <= l && r <= b ) return tree[k];
    return(max(rmq(a, b, 2 * k + 1, l, (l + r) >> 1),
               rmq(a, b, 2 * k + 2, (l + r) >> 1, r)));
  }
  int rmq(int a, int b)
  {
    return (rmq(a, b+1, 0, 0, n));
  }
  int update(int k, int x)
  {
    k += n - 1;
    tree[k] = x;
    while( k > 0 ) {
      k = (k - 1) >> 1;
      tree[k] = max(tree[2 * k + 1], tree[2 * k + 2]);
    }
  }
};

main() {
  int n;
  cin >> n;
  SegT tree( n+1 );

  Rep(i, n) {
    int x;
    cin >> x;
    tree.update(x, tree.rmq(1, x-1) + x);
  }

  cout << n * (n+1) / 2 - tree.rmq(1, n) << endl;
}

Measured memory_bytes: 7096
#include "bits/stdc++.h"
using namespace std;

int main() {

	int N, sumT = 0;
	cin >> N;
	vector<int> T(N);
	for (int i = 0; i < N; i++) {
		cin >> T[i];
		sumT += T[i];
	}

	int M;
	cin >> M;
	vector<int> P(M), X(M);
	for (int i = 0; i < M; i++)
	{
		cin >> P[i] >> X[i];
	}

	for (int i = 0; i < M; i++)
	{
		cout << (sumT - T[P[i] - 1] + X[i]) << endl;
	}
}

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

int main(){
  	int n, k;
  	cin>>n>>k;
    vector <int> m;
  	int h;
    for(int i=0 ; i < n; i++){
      cin>>h;
      m.push_back(h);
    }
  	int tong = 0;
  	for(int i =0 ; i < k; i++){
      int dem = 0;
      int min = m[0];
      for(int i =1; i < m.size(); i++){
        if( m[i] < min){
          min = m[i];
          dem = i;
        }
      }
      tong +=min;
      m.erase(m.begin() + dem);
    }
  	cout<<tong;
    return 0; 
}

Measured memory_bytes: 3168
// Problem : B - Go to Jail
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 200005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
void solve()
{
	int n;
	cin >> n;
	int a[n] = {0},flag=0;
	for(int i=0;i<n;i++)
	{
		int x,y;
		cin >>x  >> y;
		if(x == y)
		{
			a[i]=1;
			if(i > 0)
				a[i] += a[i-1]; 
		}
		else a[i]=0;
		if(a[i] >= 3)
			flag=1;
	}	
	if(flag)
		cout << "Yes" <<"\n";
	else cout << "No" <<"\n";
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3668
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); }
void log()(){ writeln(""); } void log(T, A ...)(T t, lazy A a){ if(DEBUG) write(t, " "), log(a); } bool DEBUG = 0; 
string rstring(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T rtype(T)(){ return rstring.to!T; } alias rint = rtype!int, rlong = rtype!long, rreal = rtype!real;
T[] rtypes(T)(int n){ return n.iota.map!(i => rtype!T()).array; } alias rint = rtypes!int, rlong = rtypes!long, rreal = rtypes!real;
T[][] rtypess(T)(int n, int m){ return n.iota.map!(i => rtypes!T(m)).array; } alias rint = rtypess!int, rlong = rtypess!long, rreal = rtypess!real;

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
	int n = rint;
	string s = rstring;

	string ans;
	foreach(c; s) ans ~= 'A' + (c + n + 26 - 'A') % 26;

	ans.writeln;
}

Measured memory_bytes: 380
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
#define mod 1000000007
#define MAX 910000
using namespace std;
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;}

ll modpow(ll x, ll y) {
  ll ret = 1;
  rep(i, y) {
    ret = ret*x%MOD;
  }
  return ret;
}

int main() {
  ll N; cin >> N;
  ll ans = modpow(10, N) - modpow(9,N) - modpow(9,N) + modpow(8,N);
  ans %= MOD;
  ans = (ans+MOD)%MOD;
  cout << ans << endl;
}

Measured memory_bytes: 3628
Convert = [0,1,2,3,5,7,8,9]

def solve n
  result = Array.new
  while n > 0 do
    l = n % 8
    n = n / 8
    result.push(Convert[l])
  end
  result.reverse.join()
end

while (n = $stdin.gets.to_i) != 0 do
  puts solve(n)
end

Measured memory_bytes: 6116
S = input()
m = ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"]
if S[:2] in m and S[2:] in m:
  print("AMBIGUOUS")
elif S[:2] not in m and S[2:] in m:
  print("YYMM")
elif S[:2] in m and S[2:] not in m:
  print("MMYY")
else:
  print("NA")

Measured memory_bytes: 3064
H,W = map(int,input().split())
G = []

for n in range(H):
  G = G + [input()]
  
L = [[0 for w in range(W)] for h in range(H)]
R = [[0 for w in range(W)] for h in range(H)]
U = [[0 for w in range(W)] for h in range(H)]
D = [[0 for w in range(W)] for h in range(H)]

for i in range(H):
  for j in range(1,W):
    if G[i][j]=='#' or G[i][j-1]=='#':
      L[i][j] = 0
    else:
      L[i][j] = L[i][j-1]+1
        
    if G[i][W-1-j]=='#' or G[i][W-j]=='#':
      R[i][W-1-j] = 0
    else:
      R[i][W-1-j] = R[i][W-j]+1
  
for i in range(1,H):
  for j in range(W):
    if G[i][j]=='#' or G[i-1][j]=='#':
      U[i][j] = 0
    else:
      U[i][j] = U[i-1][j]+1
        
    if G[H-1-i][j]=='#' or G[H-i][j]=='#':
      D[H-1-i][j] = 0
    else:
      D[H-1-i][j] = D[H-i][j]+1

v = [0]*H
for i in range(H):
  v_ = [0]*W
  for j in range(W):
    if G[i][j]=='.':
      v_[j] = L[i][j]+R[i][j]+U[i][j]+D[i][j]+1
  v[i] = max(v_)
print(max(v))

Measured memory_bytes: 187140
def main():
    N, A, B = (int(x) for x in input().split(" "))
    total = 0
    for n in range(1, N+1):
        sum_digit = sum([int(x) for x in str(n)])
        if A <= sum_digit & sum_digit <= B:
            total += n
    print(total)


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 1000000000 + 7;

// modint
const ll mod = 1e9+7;
template< int mod >
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
      return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inv();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
    
  ModInt inv() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  
  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
  
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
  
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }
  
  static int get_mod() { return mod; }
};
 
using mint = ModInt<mod>;
vector<mint> fact;

mint comb(int x, int y){
  mint ret = 1;
  if(x < y) return 0;

  ret *= fact[x];
  ret *= fact[x-y].inv();
  ret *= fact[y].inv();

  return ret;
}

mint calc(int r, int c){
  mint ret = 0;
  if(r < 0 || c < 0){
    return 0;
  }

  ret += comb(r+c+2, c+1) - 1;

  return ret;
}

int main(){
  cout << setprecision(10);
  int r1,c1,r2,c2; cin >> r1 >> c1 >> r2 >> c2;

  fact.assign(r2+c2+3, 1);
  for(int i = 2; i <= r2 + c2 + 2; i+=1){
    fact[i] = fact[i-1] * (mint)(i);
  }

  mint ans = 0;

  ans += calc(r2,c2);
  ans -= calc(r1-1, c2);
  ans -= calc(r2, c1-1);
  ans += calc(r1-1, c1-1);

  cout << ans << endl;
}


Measured memory_bytes: 11124
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=a;i<b;i++)
#define fore(i,a,b) for(int i=a;i<=b;i++)
#define pb push_back
#define F first
#define S second
#define INF ll(1e18)
#define MOD 998244353
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define MAXN 100005

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k; cin>>k;
	cout<<a[k-1]<<'\n';
	
	return 0;
}


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

int main() {
	array<int,3> value;
	
	for(int i=0;i<3;++i){
		int tmp;
		cin >> tmp;
		value[i]=tmp;
	}
	
	int answer = value[0]*100+value[1]*10+value[2];
	
	if(answer%4==0) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}

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

int main(){
  int x,n;
  cin>>x>>n;
  vector<int> v(110,0);
  for(int i=0;i<n;i++){
    int m;
    cin>>m;
    v[m+1]=1;
  }
  for(int i=0;i<110;i++){
    if(v[x+1-i]==0){
      cout<<x-i;
      return 0;
    }
    if(v[x+1+i]==0){
      cout<<x+i;
      return 0;
    }
  }
}
      

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

#define int         long long
#define mod         1000000007
#define FAST        ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define vi          vector<int>
#define nn          100001

int n;
vector<vi> graph;
int dp[nn][2];

// clr = 1 (white)
// clr = 0 (black)
int solve(int nd,bool clr,int par){
    if(dp[nd][clr] != -1)
        return dp[nd][clr];

    int ans = 0;
    int w1 = 1;
    for(auto nbr: graph[nd]){
        if(nbr != par)
            w1 = (w1 * solve(nbr, 0, nd)) % mod;
    }
    ans = (ans + w1) % mod;
    if(!clr){
        int w2 = 1;
        for(auto nbr: graph[nd]){
            if(nbr != par)
                w2 = (w2 * solve(nbr, 1, nd)) % mod;
        }
        ans = (ans + w2) % mod;
    }

    return dp[nd][clr] = ans;
}

int32_t main(){
    FAST;
    cin>>n;
    graph.resize(n+1);
    memset(dp,-1,sizeof(dp));

    for(int i=1;i<=n-1;i++){
        int x,y;
        cin>>x>>y;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    cout<<solve(1,0,-1);
}

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

typedef long long ll;

int main(void)
{
    //freopen("input.txt", "r", stdin);

    int i, n;
    cin >> n;
    string a;
    map <string, int> m;
    vector <string> v;

    int cntt = 1;
    for(i = 0; i < n; i++)
    {
        cin >> a;

        auto it = m.find(a);
        if(it != m.end())
        {
            m[a]++;
            if(m[a] > cntt)
                cntt = m[a];
        }
        else
        {
            m.insert(make_pair(a, 1));
        }
    }

    for(auto it = m.begin(); it != m.end(); it++)
    {
        if(it->second == cntt)
            cout << it->first << "\n";
    }

    return 0;
}

Measured memory_bytes: 19232
#include<iostream>

using namespace std;

int main(){
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  
  int count = 0;
  for (int i=0; i<=a; i++){
    for (int j=0; j<=b; j++){
      for (int k=0; k<=c; k++){
        if(500*i+100*j+50*k == x)	count++;
      }
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
import math


def shori(H, W):
    tmp = 10000000000000
    for h in range(1, H):
        Sa = h * W
        # tatewari
        Sb = (H - h) * math.ceil(W / 2)
        Sc = (H - h) * (math.floor(W / 2))
        Sdiff_t = max(Sa, Sb, Sc) - min(Sa, Sb, Sc)
        # yokowari
        Sb = math.ceil((H - h) / 2) * W
        Sc = math.floor((H - h) / 2) * W
        Sdiff_y = max(Sa, Sb, Sc) - min(Sa, Sb, Sc)

        min_diff = min(Sdiff_t, Sdiff_y)
        tmp = min_diff if min_diff < tmp else tmp

    return tmp


H, W = map(int, input().split())
print(min(shori(H, W), shori(W, H)))


Measured memory_bytes: 3064
def main():
    S, T = [input() for _ in range(2)]
    ans = "Yes" if S == T else "No"
    new_S = S
    for i in range(len(S)):
        new_S = new_S[-1] + new_S[:-1]
        if new_S == T:
            ans = "Yes"
            break
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>

int main(void) {

	int n,k,ans=0,i;
	int h[100001];

	scanf("%d %d",&n, &k);

	for(i =0; i<n;i++){
		scanf("%d",&h[i]);
	}

	for(i =0; i<n;i++){
		if(h[i]>=k)
			ans++;
	}

	printf("%d",ans);

	return EXIT_SUCCESS;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define maxn 55
#define maxm 125005
#define int long long
#define INF 1e9 + 10
int n, X, D, ans, cnt, dp[maxm];
int w[maxn], val[maxn], pos[maxn];
int tot, V[maxn * maxn], W[maxn * maxn];

int read()
{
    int x = 0, k = 1;
    char c; c = getchar();
    while(c < '0' || c > '9') { if(c == '-') k = -1; c = getchar(); }
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * k;
}

struct edge
{
    int cnp, to[maxn], last[maxn], head[maxn];
    edge() { cnp = 1; }
    void add(int u, int v)
    { to[cnp] = v, last[cnp] = head[u], head[u] = cnp ++; }
}E1;

void dfs(int u)
{
    val[u] = 1;
    for(int i = E1.head[u]; i; i = E1.last[i])
    {
        int v = E1.to[i];
        dfs(v);
        w[u] += w[v]; val[u] += val[v];
    }
    cnt += val[u] * n; pos[u] = u;
}

bool cmp(int x, int y) { return val[x] * w[y] > val[y] * w[x]; }
void Get_min(int &x, int y) { x = x < y ? x : y; }

signed main()
{
    n = read(), X = read(), D = read();
    w[1] = read();
    for(int i = 2; i <= n; i ++)
    {
        w[i] = read(); int x = read();
        E1.add(x, i);
    }
    dfs(1);
    sort(pos + 1, pos + n + 1, cmp);
    int tmp = min(n, D);
    for(int i = 1; i <= cnt; i ++) dp[i] = INF;
    for(int i = 1; i <= n; i ++)
    {
        int len = 1, lim = tmp;
        while(lim >= len)
        {
            V[++ tot] = len * val[pos[i]];
            W[tot] = len * w[pos[i]];
            lim -= len, len <<= 1;
        }
        if(lim) V[++ tot] = lim * val[pos[i]], W[tot] = lim * w[pos[i]];
    }
    for(int i = 1; i <= tot; i ++)
        for(int j = cnt; ~j; j --)
                if(j >= V[i]) Get_min(dp[j], dp[j - V[i]] + W[i]); // k件物品
    int ans = 0;
    for(int i = 0; i <= cnt; i ++)
       {
        if(dp[i] > X) continue;
        int ret = i, left = X - dp[i];
        for(int j = 1; j <= n; j ++)
        {
            int tem = pos[j], used = min(max(D - n, 0LL), left / w[tem]);
            if(tem == 1) used = left / w[tem];
            left -= w[tem] * used;
            ret += val[tem] * used;
        }
        ans = max(ans, ret);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 768
s = input()

inatcg = False
longest = 0
cur = 0
for c in s:
    if c in {'A', 'T', 'C', 'G'}:
        inatcg = True
        cur += 1
    else:
        if inatcg:
            longest = max(longest, cur)
            cur = 0
            inatcg = False

print(max(cur,longest))


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

int main(void) {
  int N;
  cin >> N;
  int A = 1;
  while(A <= N) {
    A *= 2;
  }
  cout << A / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
N,M,X=map(int,input().split())
C=[]
A=[]
for _ in range(N):
    Y=list(map(int,input().split()))
    C.append(Y[0])
    A.append(Y[1:])
res=10**9
for bit in range(2**N):
    sums=0
    array=[0]*M
    for i in range(N):
        if bit>>i&1:
            for j in range(M):
                array[j]+=A[i][j]
            sums+=C[i]
    if all((a>=X for a in array)):
        res=min(res,sums)

print(res if res!=10**9 else -1)

Measured memory_bytes: 9140
import Data.Functor

(*%) :: Integral a => a -> a -> a
x *% y = x * y `mod` lM where
    lM = 1000000007

pow :: Integral a => a -> a -> a
pow _ 0 = 1
pow 0 _ = 0
pow m 2 = m * m
pow m n
    | even n = pow (pow m 2) (n `div` 2)
    | odd n = m * pow m (n - 1)

powmod :: Integral a => a -> a -> a
powmod _ 0 = 1
powmod 0 _ = 0
powmod m 2 = m *% m
powmod m n
    | even n = powmod (powmod m 2) (n `div` 2)
    | odd n = m *% powmod m (n - 1)

main :: IO ()
main = do
    [m,n] <- map read . words <$> getLine
    putStrLn . show $ powmod m n

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


int main() {
  
  
  
  int a,b;
  cin>>a>>b;
  string sw=to_string(a);
  string sw1=to_string(b);
  
  for(int i=0;i<b-1;i++){
    sw=sw+to_string(a);
  }
  
  for(int i=0;i<a-1;i++){
    sw1=sw1+to_string(b);
  }
  
  if(sw<=sw1){
     cout<<sw<<endl;
  }else{
    cout<<sw1<<endl;
  }
  
  
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long int pow107 = (int)pow(10, 9) + 7;
long int limit = LONG_MAX;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

//最大limit
//10^9+7    pow107
//素数pn
//n乗jou
//コンビネーションfactorial
//

int main(){
    vector <string> v;
    string s;
    cin >> s;
    v.push_back(s);
    cin >> s;
    v.push_back(s);
    if(v[0].size() > v[1].size()){
        cout << "GREATER" << endl;
    }else if(v[0].size() == v[1].size()){
        bool f = true;
        for(int i = 0; i < v[0].size(); ++i){
            if(v[0][i] > v[1][i]){
                cout << "GREATER" << endl;
                f = false;
                break;
            }
            if(v[0][i] < v[1][i]){
                cout << "LESS" << endl;
                f = false;
                break;
            }
        }
        if(f)
            cout << "EQUAL" << endl;
    }else{
        cout << "LESS" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()

template<class T>
static inline std::vector<T> ndvec(size_t&& n, T val) noexcept {
  return std::vector<T>(n, std::forward<T>(val));
}

template<class... Tail>
static inline auto ndvec(size_t&& n, Tail&&... tail) noexcept {
  return std::vector<decltype(ndvec(std::forward<Tail>(tail)...))>(n, ndvec(std::forward<Tail>(tail)...));
}

int main() {
  string s;
  cin >> s;
  if(std::count(all(s), 'A') % 3 == 0) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    ll N;
    cin >> N;

    string S, T;
    
    cin >> S >> T;

    vector<char > ans(S.length() + T.length());

    ll cn = 0;
    for(ll i = 0; i < S.length(); i++){
        ans[cn] = S[i];
        cn += 2;
    }

    cn = 1;
    for(ll i = 0; i < T.length(); i++){
        ans[cn] = T[i];
        cn += 2;
    }

    for(ll i = 0; i <ans.size(); i++){
        cout << ans[i];
    }
    cout << endl;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    string S;
    cin >> S;
    if(S=="SAT")cout << 1 << endl;
    else if(S=="FRI")cout << 2 << endl;
    else if(S=="THU")cout << 3 << endl;
    else if(S=="WED")cout << 4 << endl;
    else if(S=="TUE")cout << 5 << endl;
    else if(S=="MON")cout << 6 << endl;
    else if(S=="SUN")cout << 7 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int x1, x2, x3, x4, x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;
  if (x1 == 0)
    cout << 1 << endl;
  if (x2 == 0)
    cout << 2 << endl;
  if (x3 == 0)
    cout << 3 << endl;
  if (x4 == 0)
    cout << 4 << endl;
  if (x5 == 0)
    cout << 5 << endl;

  return 0;
}

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

typedef long long ll;

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

    int N, K;
    string S;

    cin >> N >> K >> S;

    vector<int> A(N);
    vector<int> B(N);

    int a = 0;
    int b = 0;

    char c = S[0];

    for(int i = 0; i < N; i++) {
        if(S[i] == c) {
            if(S[i] == '0') {
                A[a]++;
            } else {
                B[b]++;
            }
        } else {
            if(S[i] == '0') {
                b++;
                A[a] = 1;
            } else {
                a++;
                B[b] = 1;
            }
            c = S[i];
        }
    }

    if(c == '0') {
        a++;
    } else {
        b++;
    }


    if(a <= K) {
        cout << N << endl;
    } else {
        int count = 0;
        for(int i = 0; i < K; i++) {
            count += A[i] + B[i];
        }
        if(S[0] == '1') {
            count += B[K];
        }
        int max = count;
        cerr << max << endl;

        if(S[0] == '0') {
            for(int i = K; i < b; i++) {
                count += A[i] + B[i];
                count -= A[i - K];
                if(i - K - 1 >= 0) {
                    count -= B[i - K - 1];
                }
                //cerr << count << endl;
                if(count > max) {
                    max = count;
                }
            } if(a > b) {
                count += A[a - 1];
                count -= A[a - 1 - K];
                if(b - 1 - K >= 0) {
                    count -= B[b - 1 - K];
                }
                if(count > max) {
                    max = count;
                }
                //cerr << count << endl;
            }
        } else {
            for(int i = K; i < a; i++) {
                count += A[i];
                if(i + 1 <= b) {
                    count += B[i + 1];
                }
                count -= A[i - K] + B[i - K];
                if(count > max) {
                    max = count;
                }
                //cerr << count << endl;
            }
        }

        cout << max << endl;
    }
}

Measured memory_bytes: 1232
while True:
    H, W = map(int, input().split())
    if H == W == 0:
        break

    for i in range(H):
        for j in range(W):
            if i == 0 or i == H-1 or j == 0 or j == W-1:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()



Measured memory_bytes: 7008
a,b,c = map(int, input().split())
A = [a,b,c]
A.sort()

if (((A[2]-A[1])%2==0) and ((A[2]-A[0])%2==0)) or (((A[2]-A[1])%2==1) and ((A[2]-A[0])%2==1)):
    print(int(A[2]-(A[0]+A[1])/2))
else:
    print(int(A[2]-(A[0]+A[1])/2+3/2))

Measured memory_bytes: 3064
N = int(input())
a = map(int, input().split())
a_sort = sorted(a, reverse=True)
Alice = 0
Bob = 0
for i in range(N):
    if i%2==0:
        Alice += a_sort[i]
    else:
        Bob += a_sort[i]
print("{}".format(Alice-Bob))

Measured memory_bytes: 3060