akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <math.h>

using namespace std;

vector<int> fact;

void factor(int m) {
  int a = sqrt(m + 0.5);
  for (int i = 1; i <= a; ++i) {
    if (m % i == 0) {
      fact.push_back(i);
      if (m / i != i)
        fact.push_back(m / i);
    }
  }
}

int solve(int n, int m) {
  int res = 1;
  factor(m);
  for(auto i : fact) {
    if (m / i >= n && i > res)
      res = i;
  }
  return res;
}

int main() {
  int n, m;
  cin >> n >> m;
  cout << solve(n, m) << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <algorithm>
#include <queue>

using namespace std;

#define INT_MAX 2147483647

int main( void ){

	int n, l;
	cin >> n >> l;
	vector<string> vs;

	for( int i = 0; i < n; i++ ){
		string tmp;
		cin >> tmp;
		vs.push_back( tmp);
	}
	sort(vs.begin(), vs.end());

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

}

Measured memory_bytes: 256
#include <iostream>
    using namespace std;
     
    int main() {
int m,f,r ;
while (1){
cin >> m >> f >> r;
if (m == -1 && f == -1 && r == -1){
	break;
};
if (m == -1 || f == -1){
	cout << "F" << endl;
}
else if ( m + f >=80){
	cout << "A" << endl;
}
else if ( m + f >=65){
	cout << "B" << endl;
}
else if ( m + f >=50){
	cout << "C" << endl;
}
else if ( m + f >=30){
	if ( r >= 50){
		cout << "C" << endl;
	}
	else {
		cout << "D" << endl;
	}
}
else {
	cout << "F"<< endl;
}
}
    return 0;
    }

Measured memory_bytes: 1152
#include <iostream>

using namespace std;

int main()
{
  string X, Y; cin >> X >> Y;
  if (X.size() < Y.size() || (X.size() == Y.size() && X < Y)) {
    cout << "LESS" << endl;
  } else if (X.size() > Y.size() || (X.size() == Y.size() && X > Y)) {
    cout << "GREATER" << endl;
  } else {
    cout << "EQUAL" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<string>
#include<unordered_map>
#include<string.h>
#include<math.h>
using namespace std;
using ll = long long;
int main(){
    int ans = 0;
    int X, Y;
    cin >> X >> Y;
    if(X == 1)ans += 300000;
    if(Y == 1)ans += 300000;
    if(X == 2)ans += 200000;
    if(Y == 2)ans += 200000;
    if(X == 3)ans += 100000;
    if(Y == 3)ans += 100000;

    if(X == 1 && Y == 1)ans += 400000;
    
    cout << ans;
}


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

using namespace std;

int totalCost = -1;

int calCost(vector<int>& l, vector<int>& target, vector<int>& used) {
    int cost = 0;
    
    vector<int> sum(target.size(), 0);
    
    for(int i = 0; i < used.size(); ++i) {
        if(used[i] == 3) {
            continue;
        }
        if(sum[used[i]] == 0) {
            sum[used[i]] = l[i];
        } else {
            sum[used[i]] += l[i];
            cost += 10;
        }
    }
    for(int i = 0; i < target.size(); ++i) {
        if(sum[i] == 0) {
          return 10000;
        }
        cost += abs(target[i] - sum[i]);
    }
    return cost;
}

void step(int s, int n, vector<int>& l, vector<int>& target, vector<int>& used) {
    if(s == n) {
        int cost = calCost(l, target, used);
        if(totalCost == -1) {
            totalCost = cost;
        } else {
            totalCost = min(totalCost, cost);
        }
        return;
    }
    
    for(int i = 0; i <= 3; ++i) {
        used[s] = i;
        step(s + 1, n, l, target, used);
    }
}

int main(int argc, const char * argv[]) {
    int n = 0;
    vector<int> target(3, 0);
    cin >> n >> target[0] >> target[1] >> target[2];
    
    vector<int> l(n, 0);
    for(int i = 0; i < n; ++i) {
        cin >> l[i];
    }
    
    vector<int> used(n, -1);
    step(0, n, l, target, used);
    cout << totalCost << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MAX 100005
#define NIL -1

typedef struct Node{
  int parent;
  int child;
  int sibling;
}Node;

Node gNode[MAX];
int gDepth[MAX];

void print(int);
void rec(int, int);

int main(){
  int i,j,nodeN,nodeI,node,child,root,n;

  scanf("%d",&n);

  for(i = 0; i < n; i++){
    gNode[i].parent = NIL;
    gNode[i].child = NIL;
    gNode[i].sibling = NIL;
  }

  for(i = 0; i < n; i++){
    scanf("%d%d",&nodeI,&nodeN);
    for(j = 0; j < nodeN; j++){
      scanf("%d",&node);
      if(j == 0){
	gNode[nodeI].child = node;
      }
      else{
	gNode[child].sibling = node;
      }
      child = node;
      gNode[node].parent = nodeI;
    }
  }

  for(i = 0; i < n; i++){
    if(gNode[i].parent == NIL){
      root = i;
    }
  }

  rec(root,0);

  for(i = 0; i < n; i++){
    print(i);
  }
  return 0;
}

void print(int node){
  int i,child;
  
  printf("node %d: ",node);
  printf("parent = %d, ",gNode[node].parent);
  printf("depth = %d, ",gDepth[node]);

  if(gNode[node].parent == NIL) printf("root, ");
  else if(gNode[node].child == NIL) printf("leaf, ");
  else printf("internal node, ");

  printf("[");

  for(i = 0,child = gNode[node].child; child != NIL; i++,child = gNode[child].sibling){
    if(i) printf(", ");
    printf("%d",child);
  }
  
  printf("]\n");
}

void rec(int node, int parent){
  gDepth[node] = parent;
  if(gNode[node].sibling != NIL){
    rec(gNode[node].sibling,parent);
  }
  if(gNode[node].child != NIL){
    rec(gNode[node].child,parent+1);
  }
}



Measured memory_bytes: 6388
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
  int n;
  double a,ans,sum;
  while(1){
    n=scanf("%lf",&a);
    if(n==EOF) break;
    ans=sum=a;
    for(int i=2;i<=10;i++){
      if(i%2==0){
	ans*=2;
      }else{
	ans/=3;
      }
      sum+=ans;
    }
    printf("%.8f\n",sum);
  }
  return 0;
}

Measured memory_bytes: 1236
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);


ll ct[100];
ll md[10];

void qt(bool b)
{
  if(b)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  exit(0);
}

int main()
{
    IOS();
    ll r,c;
    cin>>r>>c;
    REP(i,r)
    {
      string s;
      cin>>s;
      REP(j,c)ct[s[j]-'a']++;
    }
    REP(i,26)md[ct[i]&3]++;

    bool tr=(r&1),tc=(c&1);

    if(!tr&&!tc)
    {
      if(md[0]!=26)qt(0);
      else qt(1);
    }
    else if(tr^tc)
    {
      ll t=(tr?c:r);
      t/=2;
      if(md[1]||md[3])qt(0);
      if(md[2]>t)qt(0);
      if((t-md[2])%2!=0)qt(0);
      else qt(1);
    }
    else
    {
      ll t=c+r-2;
      t/=2;
      if(md[1]&&md[3])qt(0);
      else if(md[1])md[0]++;
      else if(md[3])md[2]++;
      else qt(0);
      if(md[2]>t)qt(0);
      if((t-md[2])%2!=0)qt(0);
      else qt(1);

    }
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
input=lambda :sys.stdin.readline().rstrip()
inputs= sys.stdin.buffer.readlines
INF=float("inf")
MOD=10**9+7
#input = sys.stdin.buffer.readline
#sys.setrecursionlimit(2147483647)
#rstrip().decode('utf-8')
#import math
#import numpy as np
#import operator
#import bisect
#from heapq import heapify,heappop,heappush
#from math import gcd
#from fractions import gcd
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from itertools import accumulate
#from itertools import groupby
#from itertools import permutations
#from itertools import combinations
#from scipy.sparse import csr_matrix
#from scipy.sparse.csgraph import floyd_warshall
#from scipy.sparse.csgraph import csgraph_from_dense
#from scipy.sparse.csgraph import dijkstra
#map(int,input().split())


def main():
	n=int(input())
	ans="ABC"
	if n>999:
		ans="ABD"
	print(ans)
	




if __name__ == '__main__':
	main()

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

int main()
{
    int W, H, x, y;
    cin >> W >> H >> x >> y;

    float ans =  (float) W * H / (float) 2;
    cout << ans << ' ';
    bool f1 = W % 2 == 0 and H % 2 == 0;
    bool f2 = x == W/2 and y == H/2;
    if (f1 and f2)
        cout << 1 << endl;
    else
        cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
import sys

L,R = list(map(int,input().split()))
ans = 2019

for i in range(L,R):
    for v in range(i+1,R+1):
        a = (i*v)%2019
        ans = min(ans,a)
        if a == 0:
            break
    else:
        continue
    break
print(ans)

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

int main()
{
    int a, b;
    cin >> a >> b;
    if(a>9 || b>9)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << a*b << endl;
    }
    

    return 0;
}


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

using namespace std;

int main(void)
{
  long long a, b, r, x, tmp;
  cin >> a >> b;
 
  x = a * b;
 
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
  cout << x/b << endl;
  return 0;
}


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

constexpr long long PMOD = 1e9 + 7;
constexpr int MAXK = 1e5 + 5;
int N, K;
long long cnt[MAXK];
bool isPrime[MAXK];
long long ans;

long long powmod(long long p, int q) {
    if (q == 0) return 1;
    if (q == 1) return p % PMOD;
    long long d = powmod(p, q / 2);
    return d * d % PMOD * powmod(p, q % 2) % PMOD;
}

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

    cin >> N >> K;
    for (int i = 1; i <= K; ++i) {
        cnt[i] = powmod(K / i, N);
    }
    for (int i = 2; i <= K; ++i) {
        isPrime[i] = true;
    }
    for (int i = 2; i <= K; ++i) {
        if (!isPrime[i]) continue;
        for (int j = 1; i * j <= K; ++j) {
            cnt[j] = (cnt[j] + PMOD - cnt[i * j]) % PMOD;
            if (j != 1) isPrime[i * j] = false;
        }
    }
    for (int i = 1; i <= K; ++i) {
        ans = (ans + i * cnt[i] % PMOD) % PMOD;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 4372
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

vector<int> G[1000];
vector<int> x;

pii dfs(int cur){
    if(G[cur].size()==0){
        return pii(x[cur],0);
    }
    
    vector<pii> v;
    for(auto e:G[cur])v.pb(dfs(e));
    
    static int dp[1000][6001];
    rep(i,1000)rep(j,6001)dp[i][j] = INF;
    dp[0][0] = 0;

    rep(i,v.size()){
        pii res = v[i];
        for(int j=6000;j>=0;j--){
            if(j+res.first<=6000){
                dp[i+1][j+res.first] = min(dp[i+1][j+res.first],dp[i][j]+res.second);
            }
            if(j+res.second<=6000){
                dp[i+1][j+res.second] = min(dp[i+1][j+res.second],dp[i][j]+res.first);
            }
        }
    }
    int y = INF;
    for(int i=0;i<=x[cur];i++) y = min(y,dp[v.size()][i]);
    return pii(x[cur],y);
}

int main(){
    int n;
    cin>>n;
    
    rep(i,n-1){
        int p;
        cin>>p;
        G[p-1].pb(i+1);
    }
    x.resize(n);
    rep(i,n)cin>>x[i];
    
    pii res = dfs(0);
    
    if(res.second==INF)cout<<"IMPOSSIBLE"<<endl;
    else cout<<"POSSIBLE"<<endl;
}


Measured memory_bytes: 23808
import java.util.*;
public class Main {
	
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int[][] c = new int[3][3];
		for(int i = 0; i < 3; i++) {
			for(int j = 0; j < 3; j++) {
				c[i][j] = stdIn.nextInt();
			}
		}
		int s1 = c[0][0]-c[1][0];
		int s2 = c[0][1]-c[1][1];
		int s3 = c[0][2]-c[1][2];
		
		int s4 = c[1][0]-c[2][0];
		int s5 = c[1][1]-c[2][1];
		int s6 = c[1][2]-c[2][2];
		
		int s7 = c[0][0]-c[0][1];
		int s8 = c[1][0]-c[1][1];
		int s9 = c[2][0]-c[2][1];
		
		int s10 = c[0][1]-c[0][2];
		int s11 = c[1][1]-c[1][2];
		int s12 = c[2][1]-c[2][2];
		
		if(s1 == s2 && s2 == s3 && s4 == s5 && s5 == s6 && s7 == s8 && s8 == s9 && s10 == s11 && s11 == s12) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}
		
	}

}

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

using namespace std;

#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

//const int inf = 1LL << 55;
const int mod = 10000;//1e9 + 7;

string A, B;
int M;

// dp[index][islower][mod][zig-zag][prev]
int dp[501][2][500][3][10];

int solve(const string& s, int idx, int lt, int m, int zg, int prev)
{
  if(idx == s.size()) return m == 0;

  int& ret = dp[idx][lt][m][zg][prev];
  if(~ret) return ret;

  ret = 0;
  int lim = lt ? 9 : s[idx]-'0';
  rep(d, lim + 1) {
    int zgzg = -1;//0;
    if(zg == 0) { // start
      if(prev == 0) zgzg = 0;
      else if(d == prev) continue;
      else if(d < prev) zgzg = 1;
      else if(d > prev) zgzg = 2;
    } else if(zg == 1) { // up
      if(d <= prev) continue;
      else zgzg = 2;
    } else if(zg == 2) { // down
      if(d >= prev) continue;
      else zgzg = 1;
    }
    assert(zgzg != -1);
    (ret += solve(s, idx+1, lt||d<lim, (m*10+d)%M, zgzg, d)) %= mod;
  }

  return ret % mod;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> A >> B >> M;

  for(int i = (int)A.size()-1; i >= 0; i--) {
    if(A[i] == '0') {
      A[i] = '9';
    } else {
      A[i]--;
      break;
    }
  }

  memset(dp, -1, sizeof(dp));
  int a = solve(A, 0, 0, 0, 0, 0);
  memset(dp, -1, sizeof(dp));
  int b = solve(B, 0, 0, 0, 0, 0);

  cout << (b - a + mod) % mod << endl;

  return 0;
}

Measured memory_bytes: 61824
#include<iostream>
using namespace std;
static const int N = 100;
static const int INF = 10000000;
static const int WHITE =0;
static const int GRAY =1;
static const int BLACK =2;

int n,A[N][N]; //隣接行列

void dijkstra(){
    int min ;
    int d[N],color[N];

    for(int i =0;i<n;i++){
        d[i] = INF;
        color[i] =WHITE;
    }
    d[0] =0;
    color[0] = GRAY;
    while(1){
        min = INF;
        int u = -1;
        for(int i =0;i <n;i++){
            if(min > d[i] && color[i] != BLACK){
                u = i;
                min  = d[i];
            }
        }
        if(u ==-1) break;
        color[u] = BLACK;
        for(int v =0;v<n;v++){
            if(color[v] != BLACK && A[u][v] != INF){
                if(d[v] > d[u] + A[u][v]){
                    d[v] = d[u] + A[u][v];
                    color[v] =GRAY; 
                }
            }
        }
    }

    for(int i = 0;i<n;i++){
        cout<< i << " "<< (d[i] == INF ? -1 :d[i]) << endl; 
    }
}

int main(){
    cin >> n;
    for(int i=0;i<n;i++){
        for(int j =0;j<n;j++){
            A[i][j] = INF;
        }
    }
    
    int k,c,u,v;
    for(int i =0;i<n;i++){
        cin >> u >> k;
        for(int j =0;j<k;j++){
            cin >> v >> c;
            A[u][v] = c;
        }
    }

    dijkstra();

    return 0;
}


Measured memory_bytes: 3124
/* Bismillahirrahmanirrahim
   Semoga Dapet AC ya Allah
   Amin.................. :)
   Ps. SelfRemainder #1: Variabel gak otomatis nilainya 0
					 #2: Output harus sama persis formatnya sama di contoh
					 #3: Jangan lama2 mikirin 1 soal. Kalo dah gabisa, stop
					 #4: Kalau for bersarang, variabelnya jangan sama
*/
#include<bits/stdc++.h>
#define forA for(int i=0; i<a; i++)
#define Fora for(int i=1; i<=a; i++)
#define ll long long
#define F first
#define S second
using namespace std;

int main(){
	int a;
	cin >> a;
	if(a%2==1) cout << (a/2)+1 << endl;
	else cout << a/2 << endl;
}

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

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

  vector<int> a, odd;
  for (int i = 0; i < m; ++i) {
    int x;
    cin >> x;

    if (x & 1)
      odd.push_back(x);
    else
      a.push_back(x);
  }

  if ((n & 1) + odd.size() >= 3) {
    puts("Impossible");
    return 0;
  }

  for (int i = 0; i < odd.size(); ++i) {
    a.push_back(odd[i]);
    reverse(a.begin(), a.end());
  }

  if (n == 1) {
    cout << 1 << endl;
    cout << 1 << endl;
    cout << 1 << endl;

    return 0;
  }

  if (m == 1) {
    cout << a[0] << endl;
    cout << 2 << endl;
    cout << a[0] - 1 << endl;
    cout << 1 << endl;

    return 0;
  }

  for (int i = 0; i < m; ++i) {
    cout << a[i] << (i + 1 == m ? "\n" : " ");
  }

  vector<int> b;
  if (a[0] != 1) b.push_back(a[0] - 1);
  a[0] = 1;

  for (int i = 1; i < a.size() - 1; ++i) {
    b.push_back(a[i]);
  }

  b.push_back(2);
  if (a.back() != 1) b.push_back(a.back() - 1);

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


Measured memory_bytes: 256
#include<cstdlib>
#include<cstring>
#include<queue>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>

using namespace std;
int main()
{
	char a[101],b[101];
    int max,len1,len2;
    scanf("%s",a);
    scanf("%s",b);
     len1=strlen(a);
     len2=strlen(b);
     if(len1>len2)
	 	 	printf("GREATER\n");
	 if(len1<len2)
            printf("LESS\n");
	 if(len1==len2)
	 {
			max=strcmp(a,b);
           if(max>0)
				printf("GREATER\n");
           if(max==0)
					printf("EQUAL\n");
	       if(max<0)
                    printf("LESS\n");
	 }
}



Measured memory_bytes: 128
#import sys
#import math
#import numpy as np
'''a,b= map(int,input().split())'''
#a, b, c = [list(map(int, input().split())) for _ in range(3)]
#li0= [int(x) for x in input().split()]
#n,l= map(int, input().split())
#x = [list(map(int, input().split())) for _ in range(n)] 
N=input()
ans=ju=0
li=[]
li=list(N)

for i in range(len(li)):
  ans=0
  if str(li[i])=='T' or str(li[i])=='A' or str(li[i])=='G'or str(li[i])=='C':
    ans+=1
    for j in range(1,len(li)-i):
      if str(li[i+j])!='T' and str(li[i+j])!='A' and str(li[i+j])!='G' and str(li[i+j])!='C':
        break
      ans+=1
    ju=max(ju,ans)
print(ju)


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define INF 2000000000000000000LL
#define EPS 1e-9
#define debug(a) cerr<<#a<<"="<<(a)<<"\n"
#define FastSlowInput ios_base::sync_with_stdio(false); cin.tie(NULL);

typedef long long ll;
typedef unsigned long long ull;
typedef complex<double> cd;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll mod = 1e9+7;
const double PI = acos(-1);

int n,i,j,k,t;
int h,w;
int fact[200002];
int ifact[200002];
pii p[3002];
int dp[3002];
int lis[3002];

int powmod(int a, int b){
    int ans = 1;
    for(;b;b>>=1){
        if(b&1){
            ans = 1LL*ans*a%mod;
        }
        a = 1LL*a*a%mod;
    }
    return ans;
}

int combin(int a, int b){
    int ans = 1LL*fact[a]*ifact[b] % mod;
    ans = 1LL*ans*ifact[a-b] % mod;
    return ans;
}

int main(){
    fact[0] = ifact[0] = 1;
    for(i=1;i<=200000;++i){
        fact[i] = 1LL*i*fact[i-1] % mod;
        ifact[i] = 1LL*powmod(i, mod-2)*ifact[i-1] % mod;
    }
    scanf("%d %d %d", &h, &w, &n);
    for(i=1;i<=n;++i)
        scanf("%d %d", &p[i].fi, &p[i].se);
    p[0] = {1,1};
    p[n+1] = {h, w};
    sort(p, p+n+2);
    memset(dp, 0, sizeof dp);
    dp[0] = 0;
    for(i=1;i<=n+1;++i){
        dp[i] = combin(p[i].fi+p[i].se-2, p[i].fi-1);
        for(j=1;j<i;++j){
            if(p[j].se > p[i].se) continue;
            dp[i] -= 1LL*combin(p[i].fi+p[i].se-p[j].fi-p[j].se, p[i].fi - p[j].fi) * dp[j] % mod;
            dp[i] %= mod;
        }
    }
    if(dp[n+1] < 0)
        dp[n+1] += mod;
    printf("%d\n", dp[n+1]);
    return 0;
}

Measured memory_bytes: 1792
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7

bit = [0] * 61
for i in range(N):
    for x in range(61):
        if 2**x > A[i]:
            break
        else:
            bit[x] += (A[i]>>x)&1

ans = 0
for i in range(61):
    ans += 2**i * (bit[i] * (N-bit[i]))
    ans %= MOD

print(ans)

Measured memory_bytes: 122928
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    S = input()
    L = S.split('S')
    ans = 0
    for l in L:
        ans = max(ans, len(l))
    print(ans)



if __name__ == '__main__':
    solve()


Measured memory_bytes: 9156
/*__ _(_) __ _  ___  ___ _   _  __| | __ _ _   _| |_ ___
 / _` | |/ _` |/ _ \/ __| | | |/ _` |/ _` | | | | __/ _ \
| (_| | | (_| | (_) \__ \ |_| | (_| | (_| | |_| | || (_) |
 \__, |_|\__,_|\___/|___/\__,_|\__,_|\__,_|\__,_|\__\___/
 |___/                                  Accepted Code  */
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
#ifdef gsdt
    freopen("input.txt","r",stdin);
#endif // gsdt

    int m,n,dem=0;
    char a[10][10];
    cin>>n>>m;
    for(int i=1; i<=n; i++)
        for(int j=1; j<=m; j++) cin>>a[i][j], dem+=a[i][j]=='#';

    int x=1;
    for(int i=1; i<=n; i++){
        while(a[i][x]=='#') x++, dem--;
        x--;
    }

    if(dem) cout<<"Impossible";
    else cout<<"Possible";
    return 0;
}



Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;

int main(){
	int w,h;
	while(1){
		cin>>w>>h;if(w==0&&h==0)break;
	int map[55][55]={};
	int W=0;
	for(int i=0;i<h;i++)
		for(int j=0;j<w;j++)
		{int x;cin>>x;if(x==1){W++;map[i+1][j+1]=W;}}

	int MAP[55][55]={};int c=0;
	for(int i=0;i<h+1;i++)
		for(int j=0;j<w+1;j++)
		{if(map[i][j]>0){c=map[i][j];

	int G[10]={map[i-1][j-1],map[i-1][j],map[i-1][j+1],map[i][j-1],map[i][j],map[i][j+1],map[i+1][j-1],map[i+1][j],map[i+1][j+1]};
			if(map[i-1][j-1]>0&&c>map[i-1][j-1])c=map[i-1][j-1];
			if(map[i-1][j]>0&&c>map[i-1][j])c=map[i-1][j];
			if(map[i-1][j+1]>0&&c>map[i-1][j+1])c=map[i-1][j+1];
			if(map[i][j-1]>0&&c>map[i][j-1])c=map[i][j-1];
			if(map[i][j+1]>0&&c>map[i][j+1])c=map[i][j+1];
			if(map[i+1][j-1]>0&&c>map[i+1][j-1])c=map[i+1][j-1];
			if(map[i+1][j]>0&&c>map[i+1][j])c=map[i+1][j];
			if(map[i+1][j+1]>0&&c>map[i+1][j+1])c=map[i+1][j+1];
			for(int I=0;I<53;I++)
				for(int J=0;J<53;J++)
					for(int H=0;H<9;H++)
					{if(map[I][J]==G[H]&&map[I][J]>0)map[I][J]=c;}
	}
		}
	bool C[2502]={};
	for(int i=0;i<h+1;i++){//cout<<endl;
		for(int j=0;j<w+1;j++){//cout<<map[i][j]<<" ";
			if(map[i+1][j+1]>0)C[map[i+1][j+1]]=true;
		}
	}
	int R=0;
	for(int i=0;i<2501;i++)if(C[i]==true)R++;
			cout<<R<<endl;

	}
	return 0;
}

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

using namespace std;

const int NM_MAX = 10;

int n, m;

bool ma[NM_MAX][NM_MAX];

int dp[NM_MAX][NM_MAX];

int main()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
    {
        string s;
        cin >> s;
        for(int j = 1; j <= m; j++)
            ma[i][j] = (s[j - 1] == '#');
    }
    int cnt = 0;
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            if(ma[i][j] == 1)
                cnt++;
    if(cnt > n + m - 1)
    {
        cout << "Impossible\n";
        return 0;
    }
    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= m; j++)
            if(ma[i][j] == 1)
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + 1;
    if(dp[n][m] == n + m - 1)
        cout << "Possible\n";
    else
        cout << "Impossible\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>
#include<utility>

#define P 1000000007

using namespace std;

int n;
vector<long long> a;
long long z, w;
long long xdp[2001], ydp[2001];

int main() {
  cin >> n >> z >> w;
  a.resize(n + 1);
  a[0] = w;
  for(int i = 0; i < n; i++) cin >> a[i + 1];
  ydp[n] = xdp[n] = abs(a[n] - a[0]);
  for(int i = n - 1; i >= 0; i--) {
    xdp[i] = abs(a[n] - a[i]);
    for(int j = i + 1; j < n; j++) xdp[i] = max(xdp[i], ydp[j]);
    ydp[i] = abs(a[n] - a[i]);
    for(int j = i + 1; j < n; j++) ydp[i] = min(ydp[i], xdp[j]);
  }
  long long ans = xdp[n];
  for(int i = 0; i < 2000; i++) ans = max(ans, ydp[i]);
  cout << ans << endl;
  return 0;
}


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

public class Main {
	private static void solve(){
		//Implement solution here.
		int n = ni();
		int d = ni();
		int result = 0;
		int[][] x = new int[n][d];
		for(int i = 0; i < n; i++) {
			x[i] = na(d);
		}

		for(int i = 0; i < n; i++) {
			for(int j = i + 1; j < n; j++) {
				double tmp = 0;
				for(int k = 0; k < d; k++) {
					tmp += Math.pow(x[i][k] - x[j][k], 2);
				}
				tmp = Math.pow(tmp, 0.5);
				if((double)(int)tmp == tmp) {
					result++;
				}				
			}			
		}

		System.out.println(result);
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 21204
import sys
sys.setrecursionlimit(int(1e6))

S = input()

ans = 0
for n in range(len(S)-1, 1, -1):
  if n % 2:
    continue
  s = S[0:n]
  m = n // 2
  #print(s, n, m, s[0:m])
  if s[0:m] == s[m:n]:
    ans = n
    break
  
print(ans)


Measured memory_bytes: 2940
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		List<Integer> list = new ArrayList<Integer>();

		list.add(scanner.nextInt());
		list.add(scanner.nextInt());
		list.add(scanner.nextInt());

		if(list.contains(5)) {
			list.remove(list.indexOf(5));
		}
		if(list.contains(7)) {
			list.remove(list.indexOf(7));
		}
		if(list.contains(5)) {
			list.remove(list.indexOf(5));
		}
		if(list.size()==0) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
	    scanner.close();
		}
}


Measured memory_bytes: 35740
/* Your prologue will be the story. */
/* Copyright by HenryLi */
#include<iostream>
#include<algorithm>
#include<queue>
#include<string>
#include<map>
#include<vector>
#include<set>
#include<sstream>
#include<stack>
#include<ctime>
#include<cmath>
#include<cctype>
#include<climits>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<iomanip>
#include<bitset>
#include<complex>
using namespace std;
template <class _T> inline void read(_T &_x) {
	int _t; bool _flag=false;
	while((_t=getchar())!='-'&&(_t<'0'||_t>'9')) ;
	if(_t=='-') _flag=true,_t=getchar(); _x=_t-'0';
	while((_t=getchar())>='0'&&_t<='9') _x=_x*10+_t-'0';
	if(_flag) _x=-_x;
}
typedef long long LL;
const int maxn = 300010;
const int mod = 998244353;
void exgcd(LL a, LL b, LL &x, LL &y, LL &g) {
	if (!b) {x = 1, y = 0, g = a; return ; }
	exgcd(b, a % b, y, x, g), y -= x * (a / b);
}
LL qpow(LL a, LL b) {
	LL res = 1;
	while (b) {
		if (b & 1) (res *= a) %= mod;
		(a *= a) %= mod, b >>= 1;
	}
	return res;
}
LL inv(LL a) {return qpow(a, mod - 2); }
LL n, A, B, k, x, y, g, C[maxn];
int main() {
	//freopen("B.in","r",stdin);
	//freopen("B.out","w",stdout);
	read(n), read(A), read(B), read(k);
	C[0] = 1;
	for (int i = 1; i <= n; ++i) C[i] = C[i - 1] * inv(i) % mod * (n - i + 1) % mod;
	LL ans = 0;
	for (LL i = 0, j; i <= n && i * A <= k; ++i) if ((k - i * A) % B == 0) {
		j = (k - i * A) / B;
		if (j > n) continue;
		(ans += C[i] * C[j]) %= mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x)  \
    int x;    \
    cin >> x; \
    while (x--)

int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<int> v(n);
    for(int &i:v)
      cin>>i;
    sort(v.rbegin(),v.rend());
    int comfort = 0;
    for(int i=1;i<n/2+n%2;i++)
      comfort += v[i-1];
    for(int i=n/2+n%2;i<n-1;i++)
      comfort += v[i-n/2-n%2+1];
      comfort += v[n/2+n%2-1];
    cout<<comfort;
    return 0;
}


Measured memory_bytes: 4768
import sys

class UnionFind():
    def __init__(self, num, V):
        self.par = [-1]*num
        #self.size = [1]*num
        self.unused = [0]*num
        self.cost = V
    def find(self, x):
        if self.par[x] < 0:
            return x
        else:
            x = self.par[x]
            return self.find(x)
    
    def union(self, x, y):
        rx = self.find(x)
        ry = self.find(y)
        if rx == ry:
            return 0
        if ry > rx:
            rx, ry = ry, rx
        self.par[ry] = rx
        #self.size[rx] += self.size[ry]
        self.cost[rx] += self.cost[ry]
        self.unused[rx] += self.unused[ry]
        self.unused[ry] = 0
        return 1

def solve():
    
    N, M = map(int, input().split())
    X = list(map(int, sys.stdin.readline().split()))
    Edge = [None]*M
    for i in range(M):
        a, b, y = list(map(int, sys.stdin.readline().split()))
        Edge[i] = (y, a-1, b-1)
    
    Edge.sort()
    Tr = UnionFind(N, X)
    for y, a, b in Edge:
        Tr.union(a, b)
        pa = Tr.find(a)
        if Tr.cost[pa] >= y:
            Tr.unused[pa] = 0
        else:
            Tr.unused[pa] += 1
    
    print(sum(Tr.unused))
    return

if __name__ == '__main__':
    solve()

Measured memory_bytes: 27548
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    ll N, K; cin >> N >> K;
    int cnt[2001] = {};
    vector<int> A(N);
    REP(i, 0, N) {
        cin >> A[i];
        cnt[A[i]]++;
    }

    int prev = 0; int less[2001] = {};
    REP(i, 0, 2001) {
        less[i] = prev;
        prev += cnt[i];
    }

    ll ans = 0;
    REP(i, 0, N) {
        int tmp = 0;
        REP(j, i + 1, N) {
            if (A[i] > A[j]) tmp++;
        }
        ans = (ans + (tmp * K) % MOD) % MOD;
        
        ans = (ans + (((K - 1) * K / 2) % MOD * less[A[i]]) % MOD) % MOD;
    }

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
using namespace std;
const int N=605,mod=1e9+7;
int n,m,a,b,f[N][N],cnt[N][N],p[N],g[N],ans;
void upd(int &x,int y){x+=y; x-=x>=mod?mod:0;}
int main(){
	scanf("%d%d",&n,&m); n*=2;
	rep (i,1,m) scanf("%d%d",&a,&b),p[a]=b,p[b]=a;
	rep (i,1,n) rep (j,i,n) cnt[i][j]=cnt[i][j-1]+(!p[j]);//i~j中未连过的点数
	g[0]=1; rep (i,1,n) if (!(i&1)) g[i]=(ll)g[i-2]*(i-1)%mod;//两个点可以自成一个匹配或拆散i-2个点中的一个匹配，i-2+1
	rep (i,1,n)
		rep (j,i,n){
			bool flag=1;
			rep (k,i,j) if (p[k]&&(p[k]>j||p[k]<i)) flag=0;//不能连到外面
			if (!flag) continue;
			f[i][j]=g[cnt[i][j]];//容斥
			rep (k,i+1,j-1) upd(f[i][j],mod-(ll)f[i][k]*g[cnt[k+1][j]]%mod);
		}
	rep (i,1,n) rep (j,1,n) upd(ans,(ll)f[i][j]*g[n-2*m-cnt[i][j]]%mod);
	printf("%d\n",ans);
	return 0;
}
//果然很神啊……我好菜

Measured memory_bytes: 3072
#include<iostream>
using namespace std;
int gcd(int a,int b)
{
    return (b==0?a:gcd(b,a%b));
}
int main()
{
    int n,i,k,x;
    int mx=0;
    cin>>n>>k;
    int g=0;
    for (i=1;i<=n;i++)
    {
        cin>>x;
        mx=max(mx,x);
        g=gcd(g,x);
    }
    if (mx<k)
        cout<<"IMPOSSIBLE"<<endl;
    else
    {
        if (k%g==0)
            cout<<"POSSIBLE"<<endl;
        else
            cout<<"IMPOSSIBLE"<<endl;
    }

}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		Student[] students;
		while (stdin.hasNext()) {
			int N = stdin.nextInt();
			int M = stdin.nextInt();
			if (N == 0 && M == 0) break;
			students = new Student[M];
			for (int i = 0; i < M; i++) {
				students[i] = new Student();
			}
			int r = stdin.nextInt();
			for (int i = 0; i < r; i++) {
				int t = stdin.nextInt();
				int n = stdin.nextInt();
				int m = stdin.nextInt();
				boolean s = stdin.nextInt() == 1;
				students[m-1].switchPC(t, s);
			}
			int q = stdin.nextInt();
			for (int i = 0; i < q; i++) {
				int ts = stdin.nextInt();
				int te = stdin.nextInt();
				int m = stdin.nextInt();
				System.out.println(students[m-1].totalTime(ts, te));
			}
		}
		System.exit(0);
	}
}

class Student {
	private List<Integer> logtime = new ArrayList<Integer>();
	private int login = 0;
	public void switchPC(int t, boolean s) {
		if (s) {
			if (login++ == 0) {
				logtime.add(t);
			}
		}
		else {
			if (--login == 0) {
				logtime.add(t);
			}
		}
	}
	public int totalTime(int ts, int te) {
		int sum = 0;
		Iterator it = logtime.iterator();
		while (it.hasNext()) {
			int tin = Integer.parseInt(it.next().toString());
			int tout = Integer.parseInt(it.next().toString());
			if (tout < ts) continue;
			if (tin > te) break;
			if (tin < ts) tin = ts;
			if (tout > te) tout = te;
			sum += tout - tin;
		}
		return sum;
	}
	private boolean isLogedInAt(int time) {
		for (int i = 0; i < logtime.size(); i++) {
			if (logtime.get(i) > time) return i % 2 != 0;
		}
		return false;
	}
}

Measured memory_bytes: 60748
#include <bits/stdc++.h>
    using namespace std;
    #define rep(i, n) for (int i = 0; i < (int)(n); i++)
     
    int main() {
	string s,t;
      cin >> s >> t;
      sort(s.begin(),s.end());
      sort(t.begin(),t.end());
      reverse(t.begin(),t.end());
      
      if ( s < t ) {
      cout << "Yes" << endl;
      }
      else {
        cout << "No" << endl;
      }
	}

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

int main() {
  string s;
  cin >> s;
  if(s.at(0)==s.at(1)||s.at(1)==s.at(2)||s.at(2)==s.at(3)) cout<<"Bad"<<endl;
  else cout<< "Good"<<endl;
}


Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())

using namespace std;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

using ll = long long;
constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u * v / gcd(u, v);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    int N;
    cin >> N;
    vector<int>h(N + 2);
    h[0] = 0;
    REP(i, N)cin >> h[i + 1];
    h[N + 1] = 0;

    int ans = 0;
    int idx = 0;
    REP(i, N + 1) {
        if (h[i] <= h[i + 1]) continue;
        ans += h[i] - h[idx];
        idx = i + 1;
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pl;

#define sl(x) scanf("%lld",&x)
#define pl(x) printf("%lld\n",x)
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define F first
#define S second
#define f(i,n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)

const ll mod = 1000000007;
const ll inf = (ll)5e16;
const ld eps = 1e-12;
const ll N = 1000005;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}
ll n;
int main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    ll ans = 1;
    for(ll i = 0; ; i++)
    {
        ll x = (1 << i);
        if(x <= n)
        {
            ans = x;
        }
        else
        {
            break;
        }
    }
    cout << ans << "\n";
    return 0;
}


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


#define next(a) ( ((a)+1)%SIZE )
#define ABS(x) ( (x)>0 ? x : -(x) )
#define MIN(x,y) ( (x) < (y) ? (x) : (y) )
#define MAX(x,y) ( (x) > (y) ? (x) : (y) )
#define INF 1000000000
#define SIZE 100000



typedef struct queue
{
	int front=0;
	int rear=0;
	int data[200];
}queue;

void enqueue(queue *p,int x)
{
	if (next(p->rear) == p->front)
		printf("OVERFLOW!\n");
	p->data[p->rear] = x;
	p->rear = next(p->rear);
}

int dequeue(queue *p)
{
	int x;

	if (p->front == p->rear)
		printf("NO DADA\n");

	x = p->data[p->front];
	p->front = next(p->front);

	return x;
}

int empty(queue *p)
{
	return p->front == p->rear;
}

int main()
{
	queue Q[20];
	char str[201];
	int i, j;
	int num;
	int h;
	int count = 0;

	while (1)
	{
		scanf("%s", str);
		if (strcmp(str, "-") == 0)
			break;

		for (i = 0; i < strlen(str); i++)
		{
			enqueue(&Q[count], str[i]-'a');
		}


		scanf("%d", &num);

		for (i = 0; i < num; i++)
		{
			scanf("%d", &h);
			for (j = 0; j < h; j++)
				enqueue(&Q[count], dequeue(&Q[count]));
		}
		count++;
	}

	for (i = 0; i < count; i++)
	{
		while (!empty(&Q[i]))
			printf("%c", 'a' + dequeue(&Q[i]));

		printf("\n");
	}


	return 0;
}



Measured memory_bytes: 2608
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define pb(x) push_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<vvll> dp(n + 1, vvll(n + 1, vll(n * n + 1, 0)));
    dp[0][0][0] = 1;
    rep(i,n){
        rep(j,n+1){
            rep(k,n*n+1){
                if (k+2*j>n*n)
                    continue;
                if (j>0){
                    dp[i + 1][j - 1][k + 2 * j] =
                     (dp[i + 1][j - 1][k + 2 * j] + (j * j * dp[i][j][k]) % mod) % mod;
                }
                if (j<n){
                    dp[i + 1][j + 1][k + 2 * j] = (dp[i + 1][j + 1][k + 2 * j] + dp[i][j][k]) % mod;
                }
                dp[i + 1][j][k + 2 * j] =
                 (dp[i + 1][j][k + 2 * j] + (2 * j + 1) * dp[i][j][k] % mod) % mod;
            }
        }
    }
    cout << dp[n][0][k] << endl;
}


Measured memory_bytes: 52224
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef pair<ll , ll> lli;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
typedef vector<lli> vlli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define in insert
#define f0(b) for(int i=0;i<(b);i++)
#define f00(b) for(int j=0;j<(b);j++)
#define f1(b) for(int i=1;i<=(b);i++)
#define f11(b) for(int j=1;j<=(b);j++)
#define f2(a,b) for(int i=(a);i<=(b);i++)
#define f22(a,b) for(int j=(a);j<=(b);j++)
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld", &a , &b)
#define pf(a) printf("%lld\n",a)
#define pff(a,b) printf("%lld %lld\n", a , b)
#define PI 3.14159265359
#define bug printf("**!\n")
#define mem(a , b) memset(a, b ,sizeof(a))
#define front_zero(n) __builtin_clzll(n)
#define back_zero(n) __builtin_ctzll(n)
#define total_one(n) __builtin_popcountll(n)

const ll mod = (ll)998244353;
const ll maxn = (ll)2e5+5;
const int nnn = 1048590;
const int inf = numeric_limits<int>::max()-1;
//const ll INF = numeric_limits<ll>::max()-1;
const ll INF = 1e18;

ll dx[]={0,1,0,-1};
ll dy[]={1,0,-1,0};
ll dxx[]={0,1,0,-1,1,1,-1,-1};
ll dyy[]={1,0,-1,0,1,-1,1,-1};


void solve(){
	
	set < ll > s;
	ll n, a , x;
	cin >> x >> n;
	f1(n) cin >> a, s.in(a);
	for(ll i = 0; i <= 201; i++){
		if(!s.count( x-i )){
			cout << x-i;
			return;
		}
		if(!s.count( x+i )){
			cout << x+i;
			return;
		}
	}
	
	return;
}


int main() {
   
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    ll T;
    T=1;
    //cin >> T;
    //scanf("%lld",&T);
    ll CT = 0;
    //work();
    while(T--){
    	//cout << "Case " << ++CT <<": " ;
    	//printf("Case %lld: ",++CT);
		solve();
	}
    
    return 0;
}


Measured memory_bytes: 3620
{-# LANGUAGE
    BangPatterns, MultiWayIf, TupleSections, TypeApplications #-}
{-# OPTIONS_GHC -O2 #-}


import Control.Arrow
import Control.Concurrent
import Control.Monad
import qualified Data.ByteString.Builder as B
import qualified Data.ByteString.Char8 as C
import Data.Complex
import Data.Char
import Data.Function
import Data.Function.HT
import qualified Data.IntMap.Strict as IM
import qualified Data.IntSet as IS
import Data.List
import Data.Monoid
import Data.Ord
import qualified Data.Sequence as Sq
import Data.Vector.Algorithms.Search
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import Debug.Trace
import System.IO


------------------
-- #   Read   # --
------------------

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


main :: IO ()
main = do
    n <- getLine
    putStrLn $ if qsum n `rem` 9 == 0 then "Yes" else "No"

qsum :: String -> Int
qsum = sum.map(read.pure)



Measured memory_bytes: 11976