akhauriyash/Code-Regression huggingface dataset:
const input = require('fs').readFileSync('/dev/stdin', 'utf8').split(/[\s]/);
const nin=()=>{const r = input[0];input.shift();return Number(r)};
const nrin=(n)=>{const a:number[]=[];rep(n,()=>a.push(nin()));return a};
const sin=()=>{const r = input[0];input.shift();return String(r)}
const out=(...a)=>{console.log(...a)}
const floor=(a)=>{return Math.floor(a)}
const min=(...a)=>{return Math.min(...a)}
const rep=(n, callback)=>{for(let i = 0;i < n; i++){callback()}}
const strrep=(s, i, v)=>{return s.slice(0, i)+v+s.slice(i+1);};
const main = ()=>{
  let [n, k] = [...nrin(2)];
  let s = sin();
  s = strrep(s, k-1, s[k-1].toLowerCase());
  out(s);
}
main();

Measured memory_bytes: 7372
// #pragma GCC target("avx2")
#pragma GCC optimize("O3", "unroll-loops")

// #include <bits/extc++.h>
// using namespace __gnu_pbds;

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

#define int long long
#define double long double
// template <typename T>
// using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
using pii = pair<int, int>;
template<typename T>
using prior = priority_queue<T, vector<T>, greater<T>>;
template<typename T>
using Prior = priority_queue<T>;

#define X first
#define Y second
#define ALL(x) (x).begin(), (x).end()
#define eb emplace_back
#define pb push_back

#define fastIO() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define RANDOM() random_device __rd; \
                 mt19937 __gen = mt19937(__rd()); \
                 uniform_int_distribution<int> __dis(0, 1); \
                 auto rnd = bind(__dis, __gen);

const int INF = 1E18;
const int mod = 1E9 + 7;
const int maxn = 1 << 18;

int BIT[maxn];

int RangeMax(int idx, int ans = 0) {
    while (idx) ans = max(ans, BIT[idx]), idx -= idx & -idx;
    return ans;
}

void Modify(int idx, int val) {
    while (idx < maxn) BIT[idx] = max(BIT[idx], val), idx += idx & -idx;
}

int32_t main() {
    fastIO();
    
    int n, ans = 0;
    cin >> n;
    
    vector<int> hei(n), val(n);
    for (auto &x : hei) cin >> x;
    for (auto &x : val) cin >> x;
    
    vector<int> dp(n + 1, 0); /// dp[i] : maximum value end at height i
    for (int i = 0; i < n; ++i) {
        dp[hei[i]] = RangeMax(hei[i]) + val[i];
        Modify(hei[i], dp[hei[i]]);
        ans = max(ans, dp[hei[i]]);
    }
    
    cout << ans << "\n";
    
    return 0;
}

Measured memory_bytes: 6528
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
        int n;
        scanf("%d", &n);
        vector<int> p(n);
        for (int i = 0; i < n - 1; i ++) {
                int a, b, c;
                scanf("%d %d %d", &a, &b, &c);
                p[a] ^= c;
                p[b] ^= c;
        }
        vector<int> cnt(16, 0);
        for (int i = 0; i < n; i ++) {
                cnt[p[i]] ++;
        }
        int ans = 0;
        int mask = 0;
        for (int i = 1; i < 16; i ++) {
                ans += cnt[i] / 2;
                if (cnt[i] & 1) {
                        mask |= 1 << i;
                }
        }
        vector<bool> ok(1 << 16, 0);
        for (int i = 0; i < (1 << 16); i ++) {
                int check = 0;
                for (int j = 0; j < 16; j ++) {
                        if (i & (1 << j)) {
                                check ^= j;
                        }
                }
                ok[i] = check == 0;
        }
        vector<int> dp(1 << 16, 0);
        for (int i = 0; i < (1 << 16); i ++) {
                if (i & 1) continue;
                int sub = i;
                while (sub > 0) {
                        if (ok[sub]) {
                                dp[i] = max(dp[i], dp[i ^ sub] + 1);
                        }
                        sub = (sub - 1) & i;
                }
        }
        printf("%d\n", ans + __builtin_popcount(mask) - dp[mask]);
        return 0;
}


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

int main() {
	string S;
	cin >> S;
	if ((int)S.size()%2 == 1) {
		cout << "No" << endl;
		return 0;
	} else {
		for (int i = 0; i < (int)S.size(); i += 2) {
			if (S.at(i) != 'h' || S.at(i + 1) != 'i') {
				cout << "No" << endl;
				return 0;
			}
		}
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    a, b = list(map(int, input().rstrip('\n').split()))
    for i in range(1, 4):
        if (a * b * i) % 2 != 0:
            print("Yes")
            exit()
    print("No")


if __name__ == '__main__':
    slove()


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

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

bool f[60][10];
bool f2[60][10];
int w,h;
int G[60][10];
string str;

bool check(int y, int x){
    if(y < 0 || y >= h) return false;
    if(x < 0 || x >= w) return false;
    return true;
}

void dfs(int y, int x, int c, int &n, double &sum, int L[], int R[], int Y[], int X[], int C[], int &cnt){
    if(f[y][x]) return;
    n++;
    sum += (int)x + 0.5;
    f[y][x] = true;
    for(int i=0;i<4;i++){
        int ny = y + dy[i];
        int nx = x + dx[i];
        if(check(ny,nx)){
            if(G[ny][nx] == c) dfs(ny,nx,c,n,sum,L,R,Y,X,C,cnt);
            else if(i == 0 && G[ny][nx] != -1){
                C[cnt] = G[ny][nx];
                L[cnt] = min(L[cnt],x);
                R[cnt] = max(R[cnt],x+1);
                Y[cnt] = ny;
                X[cnt] = nx;
                cnt++;
            }
        }
    }
}

void dfs2(int y,int x,int c, int prev, int &l,int &r){
    if(f2[y][x]) return;
    f2[y][x] = true;
    for(int i=0;i<4;i++){
        int ny = y + dy[i];
        int nx = x + dx[i];
        if(check(ny,nx)){
            if(G[ny][nx] == c) dfs2(ny,nx,c,prev,l,r);
            else if(i == 2 && G[ny][nx] == prev){
                l = min(l,x);
                r = max(r,x+1);
            }
        }
    }
}


void solve(int c, int y, int x, int &n, double &sum){
    if(str == "UNSTABLE") return;
    int L[20], R[20], Y[20], X[20], C[20],cnt=0;
    fill(L, L+20,100);
    fill(R, R+20,-1);
    dfs(y,x,c,n,sum,L,R,Y,X,C,cnt);
    for(int i=0;i<cnt;i++){
        if(!f[Y[i]][X[i]]){
            dfs2(Y[i],X[i],C[i],c,L[i],R[i]);
            int n2 = 0;
            double sum2 = 0.0;
            solve(C[i],Y[i],X[i],n2,sum2);
            n += n2;
            sum += sum2;
            if(sum2/(double)n2 > (double)L[i] && sum2/(double)n2 < (double)R[i]);
            else{
                str = "UNSTABLE";
                return;
            }
        }
    }
}

int main(){
    while(cin >> w >> h &&(w||h)){
        str = "STABLE";
        fill(f[0],f[60],false);
        fill(f2[0],f2[60],false);
        int l=100,r=-1;
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                char c;
                cin >> c;
                if(c == '.') G[i][j] = -1;
                else G[i][j] = c - '0';
                if(i == h - 1 && G[i][j] != -1){
                    l = min(l,j);
                    r = max(r,j+1);
                }
            }
        }
            
        for(int i=0;i<w;i++){
            if(G[h-1][i] != -1){
                int n=0;
                double sum=0.0;
                solve(G[h-1][i],h-1,i,n,sum);
                if(sum/(double)n > (double)l && sum/(double)n < (double)r);
                else str = "UNSTABLE";
                break;
            }
        }
        cout << str << endl;
    }
}

Measured memory_bytes: 0
n = int(input())
p= [int(i) for i in input().split()]

label=list(range(1,n+1))

if p==label:
    print("YES")
else:
    import numpy as np
    a=np.array(p)
    b=np.array(label)
    if np.sum(a==b)==n-2:
        index=np.where(a!=b)
        ia=p[index[0][0]]
        ib=p[index[0][1]]
        p[index[0][1]]=ia
        p[index[0][0]]=ib
        if label==p:
            print("YES")
        else:
            print("NO")
    else:
        print("NO")

Measured memory_bytes: 21456
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#include<string>
#include<cstdio>
#include<queue>
#include<functional>
#include<tuple>
#include<iomanip>
#include<stack>
#include<cmath>
#define int long long
#define INF 1<<40
#define N 100
using namespace std;
signed main() {
	int data[] = { 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 }, n; cin >> n;
	cout << data[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
SA=input()
SB=input()
SC=input()

a=b=c=0
count='a'
while 1:
    if count=='a':
        if a==len(SA):
            print('A')
            break
        count=SA[a]
        a+=1
    elif count=='b':
        if b==len(SB):
            print('B')
            break
        count=SB[b]
        b+=1
    elif count=='c':
        if c==len(SC):
            print('C')
            break
        count=SC[c]
        c+=1

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 1000034000;
typedef vector<ll> vecl;
typedef vector<int> veci;
typedef tuple<string, int, int> TUP;

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


int main()
{
     int H,W;
     cin >> H >> W;
     vector<vector<char>> C(H,vector<char> (W));
     for (int i = 0; i < H;i++)
     {
         for (int j = 0; j < W;j++)
         {
             cin >> C[i][j];
         }
     }
     bool ok = true;
     bool Co = false;
     for (int i = 0; i < H; i++)
     {
         for (int j = 0; j < W;j++)
        {
            Co = false;
            for (int x = 0; x < 4; x++)
            {
                if(C[i][j] == '#'){
                    if (i + dx[x] >= 0 && j + dy[x] >= 0 && i + dx[x] < H && j + dy[x] < W)
                    {
                        if(C[i+dx[x]][j+dy[x]] == '#')
                        {
                            Co = true;
                        }
                    }
                }
                else{
                    Co = ok;
                    break;
                }
            }
            if(Co == false){
                ok = false;
                //cout << i <<":"<< j << endl;
            }
         }
     }
     if(ok){
         cout << "Yes" << endl;
     }
     else{
         cout << "No" << endl;
     }
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector <int> A(N);
  vector <int> B(N);
  vector <int> C(N-1);
  for(int i=0; i<N;i++){
    cin >> A[i];
    A[i]--;
  }
  for(int i=0; i<N;i++){
    cin >> B[i];
  }
  for(int i=0; i<N-1;i++){
    cin >> C[i];
  }
  int sum=0;
  for(int i=0; i<N;i++){
    sum += B[A[i]];
    if(i>0 && A[i]==A[i-1]+1){
      sum += C[A[i-1]];
    }
  }
  cout << sum << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
using namespace std;
const ll MAX_N=2e5,MAX_A=2e5;
typedef vector<ll> vec;
ll N,K,A[MAX_N];
vec p,invp;
bool flg[MAX_A+1];
vec pmul(vec a,vec b){
    vec ret(a.size());
    REP(i,a.size()){
        ret[i]=a[b[i]];
    }
    return ret;
}
vec ppow(vec a,ll n){
    vec ret(a.size());
    REP(i,a.size())ret[i]=i;
    while(n){
        if(n&1){
            ret=pmul(ret,a);
        }
        a=pmul(a,a);
        n>>=1;
    }
    return ret;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>K;
    REP(i,N)cin>>A[i];
    REP(i,MAX_A+1){
        p.push_back(i);
        invp.push_back(i);
    }
    REP(i,N){
        swap(invp[0],invp[A[i]]);
    }
    REP(i,MAX_A+1){
        p[invp[i]]=i;
    }
    p=ppow(p,K-1);
    vec st;
    if(p[0]!=0){
        st.push_back(p[0]);
        flg[p[0]]=true;
    }
    REP(i,N){
        if(flg[A[i]]){
            while(flg[A[i]]){
                flg[st.back()]=false;
                st.pop_back();
            }
        }else{
            st.push_back(A[i]);
            flg[A[i]]=true;
        }
    }
    bool sflg=false;
    for(auto ite:st){
        if(sflg){
            cout<<' ';
        }
        sflg=true;
        cout<<ite;
    }
    cout<<endl;
}                


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


int main() {
  
  int N;
  cin >> N;
  vector<pair<int,int>> P(N);
  
  rep(i,N) {
    int a; cin >> a;
    P[i] = make_pair(a,i);
  }
  sort(P.begin(),P.end());
  rep(i,N) cout << P[i].second + 1 << endl;
}


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

struct node{
    struct node *right;
    struct node *left;
    struct node *parent;
    int key;
};
typedef struct node * Node;

#define NIL NULL

Node root;


void insert(int k){
    Node y = NIL;
    Node x = root;
    Node z;

    z = malloc(sizeof(struct node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x!=NIL){
        y=x;
        if(z->key < x->key){
            x=x->left;
        }else{
            x=x->right;
    }
    }
    z->parent=y;
    if(y==NIL){
        root=z;
    }else{
        if(z->key < y->key){
            y->left=z;
        }else{
            y->right=z;
        }
    }
}

void inorder(Node u){
if ( u == NIL ) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}
void preorder(Node u){
    if ( u == NIL ) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}


int main(){
    int n, i, x;
    char com[20];
    scanf("%d", &n);

    for ( i = 0; i < n; i++ ){
        scanf("%s", com);
        if ( com[0] == 'i' ){
            scanf("%d", &x);

            insert(x);
        } else if ( com[0] == 'p'){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
        }


    return 0;
}



Measured memory_bytes: 25180
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
	int n,tmp = 0,cnt = 0,ans = 0,sum = 0;
	cin >> n;
	int f[n][10],p[n][11],memo[10] = {0};
	
	rep(i,0,n){
		rep(j,0,10){
			cin >> f[i][j];
		}
	}
	
	rep(i,0,n){
		rep(j,0,11){
			cin >> p[i][j];
		}
	}
	
	
	rep(i,1,1024){
		tmp = i;
		sum = 0;
		rep(j,0,10){
			memo[j] = tmp % 2;
			tmp /= 2;
		}
		
		rep(j,0,n){
			cnt = 0;
			rep(k,0,10){
				if(memo[k] == f[j][k] && memo[k]*f[j][k] == 1){
					cnt++;
				}
			}
			sum += p[j][cnt];
		}
		
		if(i == 1){
			ans = sum;
		}
		else{
			ans = max(ans,sum);
		}
		
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include  <set>
#include <cmath>
#include <cstdlib>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,k) for(i=0;i<k;i++)
#define dd(t,h) if(t!=0) h+=10;



int main() {
	ll  a=10, b, c, d, e, f, g, n, i, j, k, m, l[10], sum = 3000,h;
	cin >> n >> a >> b >> c;
	
	rep(i, n)cin >> l[i];
	rep(m, (1 << 2 * n)) {

		e = 0; f = 0; g = 0,h=0,i=m;
		rep(j, n) {
			
			if ((i & (1 << 0)) && (i & (1 << 1))) { dd(g, h)g += l[j]; }
			if (!(i & (1 << 0)) && (i & (1 << 1))) {
				dd(f, h) f += l[j];
			}
			if ((i & (1 << 0)) && !(i & (1 << 1))){ dd(e,h) e += l[j]; }
			i = (i >> 2);
		}
			
		
		//cout << h << "  ";

		h = h+ abs(e - a) + abs(f - b) + abs(c - g);
		//cout << h <<"\n";
		if (((e != 0) && (f != 0))&& (g != 0))
		sum = min(sum,h);
	}
			

	cout << sum;
	return 0;
}

Measured memory_bytes: 256
N, X = map(int, input().split())

a, p = [1], [1]
for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)

def f(N, X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + a[N-1]:
        return f(N-1, X-1)
    else:
        return p[N-1] + 1 + f(N-1, X-2-a[N-1])

print(f(N, X))

Measured memory_bytes: 3188
#include<cstdio>
#include<cmath>

using namespace std;

int main()
{
	long int n;
	scanf("%ld", &n);

	double ceilodd = sqrt(n*1.0);

	bool divisable = false;

	printf("%ld:", n);

	while (n % 2 == 0)
	{
		printf(" 2");
		n /= 2;
	}

	while (n % 3 == 0)
	{
		printf(" 3");
		n /= 3;
	}

	for (long int i = 5; i <= ceilodd; i += 2)
	{
		divisable = false;

		for (long int j = 3; j < sqrt(i*1.0); j += 2)
		{
			if (i%j == 0)
			{
				divisable = true;
				break;
			}
		}

		if (divisable == false)
		{
			while (n%i == 0)
			{
				printf(" %ld", i);
				n /= i;
				if (n == 1)break;
			}
			if (n == 1)break;
		}

	}
	
	if (n != 1)
		printf(" %ld", n);


		printf("\n");
	
	return 0;
}

Measured memory_bytes: 1028
#include <stdio.h>

int main(void) {

  long n,k,cur,move,first,loop,score,max,score_first,max_first,score_loop,set,ans;
  scanf("%ld %ld", &n, &k);
  long p[n+1],c[n+1],list[n+1];
  for (long i = 1; i <= n; i++) {
    scanf("%ld", &p[i]);
  }
  for (long i = 1; i <= n; i++) {
    scanf("%ld", &c[i]);
  }
  for (long start = 1; start <= n; start++) {
    for (long i = 1; i <= n; i++) {
      list[i] = -1;
    }
    list[start] = 0;
    cur = start;
    move = 0;
    while (1) {
      cur = p[cur];
      move++;
      if (list[cur] == -1 ) {
        list[cur] = move;
      } else {
        first = list[cur];
        break;
      }
    }
    loop = move-first;
    move = k;
    if (move <= first) {
      cur = start;
      score = 0;
      for (long i = 1; i <= move; i++) {
        cur = p[cur];
        score += c[cur];
        if (i == 1 || score > max) {
          max = score;
        }
      }
    } else {
      if (first == 0) {
        first = 1;
      }
      cur = start;
      score_first = 0;
      for (long i = 1; i <= first; i++) {
        cur = p[cur];
        score_first += c[cur];
        if (i == 1 || score_first > max_first) {
          max_first = score_first;
        }
      }
      score_loop = 0;
      for (long i = 1; i <= loop; i++) {
        cur = p[cur];
        score_loop += c[cur];
      }
      move -= first;
      if (score_loop > 0) {
        set = move/loop-1;
        if (set < 0) {
          set = 0;
        }
        move -= loop*set;
        score = score_first+score_loop*set;
        max = score;
        for (long i = 1; i <= move; i++) {
          cur = p[cur];
          score += c[cur];
          if (score > max) {
            max = score;
          }
        }
      } else {
        score = score_first;
        max = score;
        if (move > loop) {
          move = loop;
        }
        for (long i = 1; i <= move; i++) {
          cur = p[cur];
          score += c[cur];
          if (score > max) {
            max = score;
          }
        }
      }
      if (max_first > max) {
        max = max_first;
      }
    }
    if (start == 1 || max > ans) {
      ans = max;
    }
  }
  printf("%ld\n", ans);

  return 0;
}

Measured memory_bytes: 1848
a,b,c,x,y = list(map(int, input().split()))

c = 2*c

ans = a * x + b *y
for i in range(1, max(x, y)+1):
    _ans = c * i + a * max(x-i, 0) + b * max(y-i, 0)
    ans = min(ans, _ans)
print(ans)

Measured memory_bytes: 3064
def main():
    K = int(input())

    if K < 10:
        print(K)
        return

    R = [1,2,3,4,5,6,7,8,9]

    x = 9
    while True:
        T = []
        for r in R:
            if r % 10 > 0:
                T.append(r * 10 + (r % 10) - 1)
                x += 1
                if x >= K:
                    print(r * 10 + (r % 10) - 1)
                    return
            T.append(r * 10 + (r % 10))
            x += 1
            if x >= K:
                print(r * 10 + (r % 10))
                return
            if r % 10 < 9:
                T.append(r * 10 + (r % 10) + 1)
                x += 1
                if x >= K:
                    print(r * 10 + (r % 10) + 1)
                    return

        R = T[::]

if __name__ == '__main__':
    main()

Measured memory_bytes: 6124
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};
int main(){
    int k;
    cin >> k;
    cout << a[k-1] << endl;
}


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

int main() {
    ll n,k,s,temp;
    cin>>n>>k>>s;
    if (s==1000000000)temp=1;
    else temp=s+1;
    vector<ll> a(n,temp);
    rep(i,k) {
        a[i]=s;
    }
    rep(i,n) {
        cout<<a[i]<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 2048
/* ex7_3
    sachiyan*/

#include <stdio.h>
#include <stdlib.h>

int main(void){
    int height, width; //変数の定義
    int i, j;
    char **matrix; //入力の表を記憶する二次元配列
    int *row ,*col; //それぞれの行に#があるか記憶する配列

    scanf("%d%d", &height, &width); //行数列数の読み取り

    //二次元配列matrixのメモリの動的確保
    matrix = (char**)calloc(height, sizeof(char*));
    if(matrix == NULL){ //メモリが足りない場合のエラー処理
        exit(1);
    }
    for(i = 0; i < height; i++){
        matrix[i] = (char*)calloc(width+1, sizeof(char));
        if(matrix[i] == NULL){
            exit(1);
        }
    }

    for(i=0; i<height; i++){ //入力の表を二次元配列に記憶
        for(j=0; j<width+1; j++){
            scanf("%c", &matrix[i][j]);
        }
    }

    //一次元配列rowのメモリの動的確保
    row = (int*)calloc(height, sizeof(int));
    if(row ==NULL){
        exit(1);
    }
    //一次元配列rowのメモリの動的確保
    col = (int*)calloc(width, sizeof(int));
    if(col ==NULL){
        exit(1);
    }

    for(i=0; i<height; i++){ //二次元配列を全探索して、#がある行、列をrow,colに記憶
        for(j=0; j<width+1; j++){
            if (matrix[i][j] == '#'){
                row[i] = 1;
                col[j] = 1;
            }
        }
    }
    for(i=0; i<height; i++){
        if(row[i] == 1){ //i番目の行に#が含まれている場合
            for(j=0; j<width+1; j++){
                if(col[j] == 1){ //j番目の列にも#が含まれている場合
                    printf("%c", matrix[i][j]);//出力
                }
            }
            printf("\n"); //一行出力したら改行
        }
    }

    //matrix,row,colのメモリの開放
    for(i = 0; i < height; i++){
        free(matrix[i]);
    }
    free(matrix);

    free(row);
    free(col);
    

    return 0;
}

Measured memory_bytes: 1660
"""
challenge case

in:
3
1 3
2 3

out:
1
1
1
"""

from collections import deque

def main():
	N, *AB = map(int, open(0).read().split())
	B = AB[1::2]

	E = [[] for _ in range(N + 1)]
	for a, b in zip(*[iter(AB)] * 2):
		E[a].append(b)

	Q = deque([1])
	C = [0] * (N + 1)
	while Q:
		v = Q.popleft()
		c = 0
		for u in E[v]:
			c += 1 + (c + 1 == C[v])
			C[u] = c
			Q.append(u)

	print(max(C))
	print("\n".join(str(C[b]) for b in B))

main()

Measured memory_bytes: 28936
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define Pint pair<int, int>
#define Pll  pair<ll, ll>
#define Tint tuple<int, int, int>
#define Tll  tuple<ll, ll, ll>
#define PI   3.141592653589793

int V;
vector<int> G[300];
vector<int> match;
vector<bool> used;

void add_edge(int u, int v) {
    G[u].push_back(v);
    G[v].push_back(u);
}

bool dfs(int v) {
    used[v] = 1;
    for (auto i : G[v]) {
        int w = match[i];
        if (w < 0 || !used[w] && dfs(w)) {
            match[v] = i;
            match[i] = v;
            return 1;
        }
    }
    return 0;
}

int bipartite_matching() { 
    int res = 0;
    match.assign(V, -1);
    for (int i = 0; i < V; i++) {
        if (match[i] < 0) {
            used.assign(V, 0);
            if (dfs(i)) res++;
        }
    }
    return res;
}

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

    int a[n], b[n], c[n], d[n];
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
    for (int i = 0; i < n; i++) cin >> c[i] >> d[i];
 
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (a[i] < c[j] && b[i] < d[j]) {
                add_edge(i, n + j);
            }
        }
    }
 
    //for (int i = 0; i < n; i++) {
    //    add_edge(2*n, i);
    //    add_edge(n + i, 2*n + 1);
    //}

    V = 2*n;
    cout << bipartite_matching() << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

const ll mod = 1000000007LL;

// aのb乗を求める.
ll modpow(ll a, ll b) {
	if (a > mod) a %= mod;
	if (b == 0LL) return 1LL;
	ll tmp = modpow(a, b / 2);
	if (b & 1LL)
		return tmp * tmp % mod * a % mod;
	return tmp * tmp % mod;
}

// aの逆元を求める.
ll inverse(ll a) {
	return modpow(a, mod - 2);
}


int n;
vector<vector<int>> g;
static vector<vector<int>> tree;

void convert_tree(int s) {
	static vector<bool> visited(n, false);
	visited[s] = true;
	for (auto nx : g[s]) {
		if (!visited[nx]) {
			tree[s].push_back(nx);
			convert_tree(nx);
		}
	}
}

vector<vector<int>> st;
vector<int> cnt;
int dfs(int s) {
	if (tree[s].size() == 0) {
		cnt[s] = 0;
		return 0;
	}
	int total = 0;
	for (auto nx : tree[s]) {
		total += dfs(nx) + 1;
	}
	cnt[s] = total;
	return total;
}
void constr(int s) {
	int total = 0;
	for (auto nx : tree[s]) {
		total += cnt[nx] + 1;
		st[s].push_back(cnt[nx] + 1);
	}
	if (n - total - 1 > 0)
		st[s].push_back(n - total - 1);
}

signed main() {
	cin >> n;
	g.resize(n); tree.resize(n);
	st.resize(n); cnt.resize(n);
	for (int i = 0; i < n - 1; ++i) {
		int a, b; cin >> a >> b;
		--a; --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	convert_tree(0);
	/*
	for (int i = 0; i < n; ++i) {
		for (auto c : tree[i])
			cout << c << " ";
		cout << endl;
	}
	cout << "-----" << endl;
	*/
	dfs(0);
	/*
	for (auto ci : cnt)
		cout << ci << " ";
	cout << endl << "----" << endl;
	*/
	for (int i = 0; i < n; ++i)
		constr(i);

	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		//for (auto ni : st[i])
		//	cout << ni << " ";
		//cout << endl;

		ll twon = inverse(modpow(2, n));
		ll tmp = (inverse(2) - twon + mod) % mod;
		for (auto ni : st[i]) {
			ll tmp2 = (inverse(modpow(2, n - ni)) - twon + mod) % mod;
			tmp = (tmp - tmp2 + mod) % mod;
		}
		ans = (ans + tmp) % mod;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 42240
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    n = int(input().strip())
    x = [[0, 0] for  _ in range(n)]
    for i in range(n):
        p, q = list(map(int, input().strip().split()))
        x[i][0] = p-q
        x[i][1] = p+q
    x = sorted(x, key=itemgetter(1))
    m = x[0][1]
    ans = 1
    for mi, ma in x[1:]:
        if m <= mi:
            m = ma
            ans += 1

    # x = sorted(x, key=itemgetter(0))
    # M = x[0][0]
    # ans2 = 1
    # print('x: ', x)
    # for mi, ma in x[1:]:

    #     if M >= ma:
    #         print(M, mi, ma)
    #         M = mi
    #         ans2 += 1
    # print(ans, ans2)
    # print(max(ans, ans2))

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 58288
<?php
$number= (int)substr(trim(fgets(STDIN)),-1);
switch ($number) {
    case 0:
        echo "pon";
        break;
    case 1:
        echo "pon";
        break;
    case 2:
        echo "hon";
        break;
    case 3:
        echo "bon";
        break;
    case 4:
        echo "hon";
        break;
    case 5:
        echo "hon";
        break;
    case 6:
        echo "pon";
        break;
    case 7:
        echo "hon";
        break;
    case 8:
        echo "pon";
        break;
    case 9:
        echo "hon";
        break;
}

?>

Measured memory_bytes: 16056
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>
#include <bitset>
#include <cmath>

#define MOD 1000000007

using namespace std;

typedef long long ll;

typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<vl> vvl;
typedef vector<vi> vvi;

typedef pair<ll, ll> pll;
typedef pair<int, int> pi;

typedef vector<pll> vpl;
typedef vector<pi> vpi;

typedef queue<ll> ql;
typedef queue<int> qi;

template <class T>
void printv(vector<T> vc) {
    for (auto e: vc) cout << e << " ";
    cout << endl;
}

template <class T>
void printvv(vector<T> vvc) { 
    for (auto vc: vvc) {
        for (auto e: vc) cout << e << " ";
        cout << endl;
    }
}

template <class T>
void printvp(vector<pair<T, T> > vp) {
    for (auto pT: vp) cout << pT.first << " " << pT.second << endl;
}

int main() {
    int N, M, C;
    cin >> N >> M >> C;
    vi table;
    for (int i = 0; i < M; ++i) {
        int v;
        cin >> v;
        table.push_back(v);
    }

    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int v = 0;
        for (int j = 0; j < M; ++j) {
            int e;
            cin >> e;
            v += table[j] * e;
        }
        ans += (v + C) > 0 ? 1 : 0;
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 888
N, M = map(int, input().split())
X = list(map(int, input().split()))

X = list(sorted(X))
Y = [0]*(M-1)
for i in range(M-1):
    Y[i] = X[i+1] - X[i]

Y = list(reversed(sorted(Y)))
ans = sum(Y) - sum(Y[:N-1])

print(ans)


Measured memory_bytes: 13968
//#include "atcoder/all"
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
//using namespace atcoder;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) fixed << setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  vl A;

  string S;
  cin >> S;
  if (S[S.size() - 1] == 's') {
    cout << S << "es" << endl;
  } else {
    cout << S << "s" << endl;
  }

  return 0;
}


Measured memory_bytes: 3656
import std.stdio;
import std.array;
import std.string;
import std.conv;
import std.algorithm;
import std.typecons;
import std.range;
import std.random;
import std.math;
import std.container;
import std.numeric;

void main() {
  int N = readln.chomp.to!int;
  auto A = readln.split.map!(to!int);

  auto dp = new double[][][](N+1, N+1, N+1);
  dp[0][0][0] = 0.0;

  foreach (i; iota(N+1))
    foreach (j; iota(N+1))
      foreach (k; iota(N+1)) {
        if (i+j+k == 0)
          continue;
        dp[i][j][k] = N*1.0/(i+j+k);
        if (k-1 >= 0)
          dp[i][j][k] += dp[i][j][k-1] * (k*1.0/(i+j+k));
        if (j-1 >= 0 && k+1 <= N)
          dp[i][j][k] += dp[i][j-1][k+1] * (j*1.0/(i+j+k));
        if (i-1 >= 0 && j+1 <= N)
          dp[i][j][k] += dp[i-1][j+1][k] * (i*1.0/(i+j+k));
      }

  int[4] count;
  foreach (a; A)
    count[a] += 1;
  writefln("%.15f", dp[count[3]][count[2]][count[1]]);
}


Measured memory_bytes: 367484
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    int x;
    cin >> x;
    if(x)cout<<0<<endl;
    else cout<<1<<endl;
}
    



Measured memory_bytes: 3592
/*
 * Author:  heyuhhh
 * Created Time:  2020/5/10 21:13:22
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A> 
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e6 + 5;

void run() {
    int n; cin >> n;
    vector <pii> z(n), f(n), o(n);
    for (int i = 1; i <= n; i++) {
        string s; cin >> s;
        int k = s.length();
        int x = 0, Min = INF;
        for (int j = 0; j < k; j++) {
            if (s[j] == '(') ++x;
            else --x;
            Min = min(Min, x);
        }
        if (x > 0) z.push_back(MP(Min, x));
        else if (x == 0) o.push_back(MP(Min, x));
        else f.push_back(MP(Min, x));
    }
    sort(all(z), [&] (pii A, pii B) {
        return A.fi > B.fi;
    });
    sort(all(f), [&] (pii A, pii B) {
        return A.se + B.fi > A.fi + B.se;
    });
    int tot = 0;
    for (int i = 0; i < sz(z); i++) {
        pii now = z[i];
        if (tot + now.fi >= 0) {
            tot += now.se;   
        } else {
            cout << "No" << '\n';
            return;
        }
    }
    for (int i = 0; i < sz(o); i++) {
        pii now = o[i];
        if (tot + now.fi < 0) {
            cout << "No" << '\n';
            return;
        }
    }
    for (int i = 0; i < sz(f); i++) {
        pii now = f[i];
        if (tot + now.fi >= 0) {
            tot += now.se;   
        } else {
            cout << "No" << '\n';
            return;
        } 
    }
    if (tot != 0) cout << "No" << '\n';
    else cout << "Yes" << '\n';
}

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

Measured memory_bytes: 34572
#include<bits/stdc++.h>
using namespace std;
 
int main(void){

	int n;
	cin >> n;
	
	vector<int> v(n);
	vector<int> c(n);
	for(int i = 0; i < n; i++) cin >> v[i];
	for(int i = 0; i < n; i++) cin >> c[i];
	
	int ans = 0;
	
	for(int i = 0; i < n; i++){
		if(v[i] > c[i]){
			ans += v[i] - c[i];
		}
	}
	
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rrep(i,n) for(int i=(int)(n)-1; i>=0; i--)
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define pr(a) cout << (a) << endl
#define PR(a,b) cout << (a) << " " << (b) << endl
#define F first
#define S second
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000001;
const ll MAXL=1000000000000000001LL;
const ll mod=1000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main() {
  int n,m;
  while(cin >> n >> m && (n||m)) {
    vector<int> a(n);
    rep(i,n) {
      int x;
      cin >> x;
      a[i]=x;
    }
    sort(all(a),greater<int>());
    int ans=0;
    rep(i,n) {
      if((i+1)%m) ans+=a[i];
    }
    pr(ans);
  }
  return 0;
}


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

int main() {
	string str;
	cin >> str;
	sort(str.begin(), str.end());
	if (str == "abc") {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n,m = map(int, input().split())
a = list(input() for i in range(n))
b = list(input() for i in range(m))

ans = 'No'
for i in range(n-m+1): 
  for j in range(n-m+1):
    if b[0] == a[i][j:j+m]:
      for x in range(1,m):
        if b[x] != a[i+x][j:j+m]:
          break
      else:
        ans = 'Yes'
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;

const int MOD = 1000000007;

int main() {
    cout.setf(ios::fixed, ios::floatfield);
    cout.setf(ios::showpoint);
    cout.precision(12);
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    int N, K;
    cin >> N >> K;
    long long res = 0;
    for (long long i = K; i <= N + 1; ++i) {
        long long extra = 1 + ((N - i + 1) * i) % MOD;
        res = (res + extra) % MOD;
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 3644
def find_factor(N):
    factors=[]
    factors2=[]
    S=int(N**0.5)
    for i in xrange(2,S+1):
        if N%i==0:
            factors+=[i]
            factors2+=[N//i]
    if S**2!=N:
        all_factor= factors+factors2[::-1]   
    else:
        all_factor= factors[:-1]+factors2[::-1] 

    return [1]+all_factor+[N]

def find_ans(N):
    ans=0
    factors=find_factor(N)
    for i in xrange(len(factors)):
        x=factors[i]
    
        m=x-1
        k=N//x
        if m==0:
            continue
        if k==N%m:
            ans+=m
    return ans

N=input()
print(find_ans(N))

Measured memory_bytes: 30700
#include<iostream>
#include<set>
#include<vector>
#include<cmath>
#include<complex>
#include<string>
#include<algorithm>

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define pb push_back

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;


int main(void)
{
  int ans = 0,cou = 0;
	string s;

  cin >> s;
	rep(i,s.size()){
  	if('A'==s[i]||'C'==s[i]||'G'==s[i]||'T'==s[i]){
			cou++;
		}else{
			ans = max(ans,cou);
			cou = 0;
		}
	}
	ans = max(ans,cou);

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


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

using ll=long long;
const ll MOD=1e9+7;
int main(){
    int n,m;
    cin>>n>>m;
    vector<vector<ll>> dp0(m,vector<ll>(n,0));
    dp0[0][0]=1;
    for(int i=0;i<m-1;i++){
        for(int j=0;j<n;j++){
            dp0[i+1][j]=(j-1>=0 ? dp0[i][j-1] : 0LL)+2*dp0[i][j]+(j+1<n ? dp0[i][j+1] : 0LL);
            dp0[i+1][j]%=MOD;
        }
    }
    vector<vector<ll>> dp1(m,vector<ll>(n,0));
    dp1[0][0]=1;
    for(int i=0;i<m-1;i++){
        for(int j=1;j<n;j++){
            dp1[i+1][j]=(j-1>=0 ? dp1[i][j-1] : 0LL)+2*dp1[i][j]+(j+1<n ? dp1[i][j+1] : 0LL);
            dp1[i+1][j]%=MOD;
        }
    }
    ll res=0;
    for(int i=0;i<m;i++){
        ll sc=(accumulate(dp1[i].begin(),dp1[i].end(),0LL)%MOD)*(accumulate(dp0[m-1-i].begin(),dp0[m-1-i].end(),0LL)%MOD)%MOD;
        //cerr<<"#"<<i<<" "<<sc<<endl;
        res+=sc;
        res%=MOD;
    }
    res=(res*4)%MOD;
    cout<<res<<endl;
    
    return 0;
}

Measured memory_bytes: 141184
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define ALL(a)			a.begin(), a.end()
#define REP(i, n)		for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)	for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF				2e9
#define MOD				(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)		(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)		(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)	((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)		(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)		(!IsOdd((x)))						
#define	MAX_QWORD		((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI			3.14159265358979323846
typedef long long		ll;
typedef pair<ll, ll>	P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int N;
	cin >> N;
	cout << N / 3 << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX 100005
int W,H;
int N;

struct data{
  int l,r,id;
  data(int l,int r,int id):l(l),r(r),id(id) {}
  bool operator < (const data &p)const{
    return l<p.l;
  }
};

vector< data > t;

bool check(int x,int y){
  if(x==0||y==0)return true;
  if(x==W)return true;
  if(y==H)return true;
  return false;
}

int calc(int x,int y){
  if(x==0)return y;
  if(y==H)return H+x;
  if(x==W)return H+W+H-y;
  return H+W+H+W-x;
}

int main(){
  cin>>W>>H;
  cin>>N;
  for(int i=0;i<N;i++){
    int ax,ay,bx,by;
    cin>>ax>>ay>>bx>>by;
    if(check(ax,ay) && check(bx,by)){
      //      cout<<i<<endl;
      t.push_back( data( calc(ax,ay) , calc(bx,by) , i ) );
      t.push_back( data( calc(bx,by) , calc(ax,ay) , i ) );
    }
  }
  sort(t.begin(),t.end());

  int ans=1;
  
  map<int,bool> flg;
  stack<int> st;
  int size=t.size();
  for(int i=0;i<size+size;i++){
    data d=t[i%size];
    if( flg[ d.id ]== 0){
      st.push(d.id);
      flg[ d.id ]=1;
    }else{
      flg[ d.id ]=0;
      if(st.empty()){
        ans=0;
        break;
      }
      
      int p=st.top();
      st.pop();
      if(p!=d.id){
        ans=0;
        break;
      }
    }
  }

  if(ans==1){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 7536
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int w,h;
  cin>>w>>h;
  vector<Int> a(w),b(h);
  for(Int i=0;i<w;i++) cin>>a[i];
  for(Int i=0;i<h;i++) cin>>b[i];
  sort(a.rbegin(),a.rend());
  for(Int x:a){
    sort(b.rbegin(),b.rend());
    for(Int i=0;i<x;i++) b[i]--;
    if(*min_element(b.begin(),b.end())<0){
      cout<<0<<endl;
      return 0;
    }
  }
  cout<<(*max_element(b.begin(),b.end())==0)<<endl;
  return 0;
}



Measured memory_bytes: 3124
use proconio::input;
use std::cmp::min;

#[allow(unused_variables)]
fn main() {
    input! {
      n: isize, k: isize,
      xa: [isize; n]
    };

    let mut ans = 0;

    for x in xa {
        let a = x * 2;
        let b = (x - k).abs() * 2;

        ans += min(a, b);
    }

    println!("{}", ans);
}


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

int a[55][26];

int main()
{
  int n;
  cin >> n;
  for(int i=0;i<n;i++)
  {
    string s;
    cin >> s;
    for(int j=0;j<s.size();j++)
    {
      a[i][s[j]-'a']++;
    }
  }
  
  for(int j=0;j<26;j++)
  {
    int ret = 100;
    for(int i=0;i<n;i++)
    {
      ret = min(ret,a[i][j]);
    }
    for(int i=0;i<ret;i++)
    {
      printf("%c",'a'+j);
    }
  }
  cout << endl;
}


Measured memory_bytes: 384
N = input()
R = [int(raw_input()) for _ in xrange(N)]
S = [0 for i in xrange(N)]
S[N-1] = R[N-1]
for i in xrange(N-2, -1, -1):
    S[i] = max(R[i], S[i+1])
ans = float('-inf')
for i in xrange(N-1):
    ans = max(ans, S[i+1]-R[i])
print ans

Measured memory_bytes: 14356