akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<cstdint>
#include<bits/stdc++.h>
#include<queue>
#include<set>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );



int main(void){

  ll n,m;
  cin>>n>>m;

  ll ans=0;

  vector< pair<ll,ll> > p(n);

  rep(i,n){
    ll a,b;
    cin>>a>>b;
    p[i]=make_pair(a,b);
  }

  using pa=pair<ll,ll>;

  sort( begin(p),end(p) );

  ll cnt=0;

  //auto x=p[cnt];

  multiset< pa , greater<pa> > s;

  ll prev_cnt=0;

  rep1(i,m){

    while( p[cnt].first <= i && cnt<n){
      s.insert( make_pair(p[cnt].second,p[cnt].first) );
      cnt++;
    }
    //if(prev_cnt==cnt) continue;
    //cout << "s.size():" << s.size() << endl;
    if(s.empty()) continue;
    auto x=*(begin(s));
    //cout << i << "," << x.first << "," << x.second << endl;
    ans+=x.first;
    auto itr=s.find(x);
    s.erase(itr);
    prev_cnt=cnt;

  }

  cout << ans << endl;


  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}

Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string &s)
{
    return '"' + s + '"';
}

string to_string(const char *s)
{
    return to_string((string)s);
}

string to_string(bool b)
{
    return (b ? "true" : "false");
}

string to_string(vector<bool> v)
{
    bool first = true;
    string res = "{";
    for (int i = 0; i < static_cast<int>(v.size()); i++)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v)
{
    string res = "";
    for (size_t i = 0; i < N; i++)
    {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v)
{
    bool first = true;
    string res = "{";
    for (const auto &x : v)
    {
        if (!first)
        {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p)
{
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p)
{
    return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << to_string(H);
    debug_out(T...);
}

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair
#define fst first
#define snd second
#define fr(i, a, b) for(int i=a; i<b; i++)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    int res1 = 0, res2 = 0;
    map<int, int> mm;
    for(int i=0; i<m; i++) {
        int p; string s;
        cin >> p >> s;
        if(mm[p] == -1) continue;
        if(s == "WA") {
            mm[p]++; 
        } else {
            res2+=mm[p];
            res1++; mm[p] = -1;
        }
    }
    cout << res1 << " " << res2 << endl;
}


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

int half(int v){
    if ( v%2 == 1 ){
	return 0;
    } else {
        return half(v/2)+1;
    }
}

int main()
{
    ////////////////////////////
    //変数を用意&入力
    int n;
    cin >> n;

    int a[n];
    for (int i=0; i<n; i++){
	cin >> a[i];
    }

    //計算
    int min = 100000000;
    for (int i=0; i<n; i++){
        if ( half(a[i]) < min ){
	    min = half(a[i]);
	}
    }

    //出力
    cout << min << endl;
    ////////////////////////////
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  int64_t w,h,x,y;
  cin>>w>>h>>x>>y;
  cout<<0.5*w*h<<' ';
  if(w%2==0 && h%2==0 && x==w/2 && y==h/2) cout<<1<<endl;
  else cout<<0<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;

/*
  データを互いに素な集合に分類して管理するデータ構造
  （一つの要素が複数の集合に属することがない集合）
  makeSet(x): 要素ｘがただ一つである新しい集合を作る
  findSet(x): 要素ｘが属する集合の代表の要素を求める
  unite(x,y): 指定された２つの要素を合併する

  Union Find： x,yの２つの要素が同じ集合に属するかを調べる操作のことを示す
*/

class DisjointSet{
  public:
    vector<int> rank, p;  //rank:根の高さ， ｐ:代表
    DisjointSet(int size){
      rank.resize(size, 0);
      p.resize(size, 0);
      for(int i = 0; i < size; i++) makeSet(i);
    }

    void makeSet(int x){
      p[x] = x;
      rank[x] = 0;
    }

    bool same(int x, int y){
      return findSet(x) == findSet(y);
    }

    void unite(int x, int y){
      link(findSet(x), findSet(y));
    }

    void link(int x, int y){
      if( rank[x] > rank [y]){
        p[y] = x;
      }
      else{
        p[x] = y;
        if(rank[x] == rank[y]){
          rank[y]++;
        }
      }
    }

    int findSet(int x){
      if( x != p[x]){
        p[x] = findSet(p[x]);
      }
      return p[x];
    }

};

int main(){
  int n, a, b, q;
  int t;
  cin >> n >> q;

  DisjointSet ds = DisjointSet(n);

  for(int i = 0; i < q; ++i){
    cin >> t >> a >> b;

    //t = 0: unite 集合を合併
    if(t == 0) ds.unite(a, b);
    //t = 1: same 同じ集合に属しているか判定
    else if(t == 1){
      if(ds.same(a,b)) cout << 1 << endl;
      else cout << 0 << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3172
l = [11,31,41,61,71,101,131,151,181,191,211,241,251,271,281,311,331,401,421,431,461,491,521,541,571,601,631,641,661,691,701,751,761,811,821,881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,1201,1231,1291,1301,1321,1361,1381]
n = int(input())
print(' '.join(map(str, l[:n])))

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>

typedef struct{
    int top,front,right,left,back,bottom;
}Dice;

void roll(char c,Dice* d){
    int tmp;
    switch(c){
        case 'N':
        tmp=d->top;
        d->top=d->front;
        d->front=d->bottom;
        d->bottom=d->back;
        d->back=tmp;
        break;
        case 'S':
        tmp=d->top;
        d->top=d->back;
        d->back=d->bottom;
        d->bottom=d->front;
        d->front=tmp;
        break;
        case 'E':
        tmp=d->top;
        d->top=d->left;
        d->left=d->bottom;
        d->bottom=d->right;
        d->right=tmp;
        break;
        case 'W':
        tmp=d->top;
        d->top=d->right;
        d->right=d->bottom;
        d->bottom=d->left;
        d->left=tmp;
        break;
    }
    return;
}

int main(void){
    int i,l;

    Dice dice;
    scanf("%d%d%d%d%d%d",&dice.top,&dice.front,&dice.right,&dice.left,&dice.back,&dice.bottom);
    
    scanf("%d",&l);
    for(i=0;i<l;i++){
        int t,f;
        scanf("%d%d",&t,&f);

        if(t==dice.front){
            roll('N',&dice);
        }
        else if(t==dice.back){
            roll('S',&dice);
        }
        else if(t==dice.right){
            roll('W',&dice);
        }
        else if(t==dice.left){
            roll('E',&dice);
        }
        else if(t==dice.bottom){
            roll('W',&dice);
            roll('W',&dice);
        }

        if(f==dice.back){
            roll('W',&dice);
            roll('S',&dice);
            roll('S',&dice);
            roll('E',&dice);
        }
        else if (f==dice.right){
            roll('W',&dice);
            roll('S',&dice);
            roll('E',&dice);
        }
        else if (f==dice.left){
            roll('E',&dice);
            roll('S',&dice);
            roll('W',&dice);
        }

        printf("%d\n",dice.right);
    }
    return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
bool checkSosuu(int);
int main(){/*
  for(int i = 0;i < 10000;i++){
    if(checkSosuu(i))cout << i <<endl;
  }
  return 0;
	   */
  while(true){
    int a,d,n;
    cin >> a;
    cin >> d;
    cin >> n;
    if(a == 0 && d == 0 && n == 0)return 0;
    int i = 0;
    int cnt = 0;
    
    while(true){
      int tmp;
      tmp = a+i*d;
      if(checkSosuu(tmp)){
	cnt++;
	//	cout << tmp  << " " << cnt << endl;
      }
      i++;
      if(cnt == n){
	cout << tmp << endl;
	break;
      }
    }
    
  }
 
  return 0;
}
bool checkSosuu(int n){
  if(n < 2)return false;
  if(n == 2)return true;
  if(n%2 == 0)return false;
  
  for(int i = 3;i <= sqrt(n);i=i+2){
    if(n%i == 0){
      return false;
    }
  }
  return true;
} 

Measured memory_bytes: 1160
#include <stdio.h>

int main(void) 
{
	int	n;
	int	i;
	long int	a[100000];
	long int	min;
	long int	max;
	long long int	sum;
	int *p_a;
	
	p_a = a;
	
	n = 0;
	i = 0;
	*p_a = 0;
	min = 1000000;
	max = -1000000;
	sum = 0;

	scanf("%d", &n);
	
	for(i = 0; i < n; i++)
	{
		scanf("%d ", p_a);

		if(min > *p_a)
		{
			min = *p_a;
		}
		else
		{
			
		}
		
		if(max < *p_a)
		{
			max = *p_a;
		}
		else
		{

		}
		
		sum = sum + (long long int)*p_a;
	}
	
	printf("%ld %ld %lld\n", min, max, sum);
	return 0;
}

Measured memory_bytes: 612
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <utility>
#include <vector>
using namespace std;
int main() {
  string t;
  cin >> t;
  for (int i = 0; i < t.length(); i++) {
    if (t[i] == '?') {
      t[i] = 'D';
    }
  }
  cout << t << endl;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
#define ll long long int

using namespace std;

int main()
{
    ll t,n,item,temp=1,h,flag1=0,flag2=0,cost=100000000000,sum=0,k,avg=0;
    vector<ll>v1;
    vector<ll>v2;
    map<ll,ll>mp;
    ll L,R,d;
    cin>>n;
    for(ll i=1;i<=n;i++)
    {
        cin>>item;
        if(i%2==1 && item%2==1)
            sum++;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {
	static int gcd(int a, int b){
		int c;
		while (b>0){
			c=a%b;
			a=b;
			b=c;
		}
		return a;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		if (x>=y){
			int n =gcd(x,y);
			 System.out.println(n);
	} else if (y>x){
		int n =gcd(y,x);
			 System.out.println(n);
	}
	}
}


Measured memory_bytes: 26344
#include<bits/stdc++.h>
using namespace std;
long long mod = 1000000007;

int main()
{

    long long h,w;
    cin>>h>>w;
    vector<vector<char> > A(h, vector<char> (w));
    for(int i=0; i<h; i++)
        for(int j=0; j<w; j++)
          cin>>A[i][j];
    bool flagi=true;
    bool flagj=true;
    vector<vector<long long> > dp(h, vector<long long> (w));
    for(int i = 0; i<h; i++)
        for(int j=0; j<w; j++)
    {

         if(i==0)
            {
                if(A[i][j]=='#')
                    {dp[i][j] = 0;
                      flagi=false;}
                else
                {
                    if(flagi==true)
                        dp[i][j] = 1;
                    else
                        dp[i][j] = 0;
                }
            }
            else if(j==0)
            {
                if(A[i][j]=='#')
                    {dp[i][j] = 0;
                      flagj=false;}
                else
                {
                    if(flagj==true)
                        dp[i][j] = 1;
                    else
                        dp[i][j] = 0;
                }
            }

            else if(A[i][j]=='#')
                dp[i][j]=0;
        else
            dp[i][j] = (dp[i-1][j]%mod + dp[i][j-1]%mod)%mod;
    }

    cout<<dp[h-1][w-1]%mod;
    return 0;
}


Measured memory_bytes: 9088
#include <stdio.h>
#include <string.h>

int main(void){
    int times, m, n, i, j, c[1001][1001];
    char x[1001], y[1001];

    scanf("%d", &times);

    while(times--){
        scanf("%s", x);
        scanf("%s", y);
        m = strlen(x);
        n = strlen(y);
        for(i=1; i<=m; i++){
            c[i][0] = 0;
        }
        for(j=0; j<=n; j++){
            c[0][j] = 0;
        }
        for(i=1; i<=m; i++){
            for(j=1; j<=n; j++){
                if(x[i-1] == y[j-1]){
                    c[i][j] = c[i-1][j-1] + 1;
                }else{
                    if(c[i-1][j] >= c[i][j-1]) c[i][j] = c[i-1][j];
                    else c[i][j] = c[i][j-1];
                }
            }
        }
        printf("%d\n",c[m][n]);
    }
    
    return 0;
}




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

int main()
{
    string S;
    cin >> S;
    for (;;)
    {
        S.pop_back();
        int len = S.length();
        if (len % 2 == 0)
        {

            string str1 = S.substr(0, len / 2);
            string str2 = S.substr((len / 2), (len / 2));
            // cout << S << " " << str1 << " " << str2 << endl;
            if (str1 == str2)
            {
                cout << len;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO 自动生成的方法存根
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		int h=sc.nextInt();
		int S=(a+b)*h/2;
		System.out.println(S);

	}

}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define PI 2*asin(1)
#define int long long
#define mod 1000000007
#define all(a) begin(a),end(a)
#define fore(i, j, n) for(long long i = j; i < n;i++)
using namespace std;

int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n; cin >> n;
    fore(a,1,10) fore(b,1,10) if(a*b == n){
        cout << "Yes"; return 0;
    }
    cout << "No";
}

Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 17.11.2019 00:53:39       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> s(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  vector<int> dp(10, -1);
  dp[0] = 0;
  for (int x : s) {
    vector<int> new_dp(10, -1);
    for (int i = 0; i < 10; i++) {
      if (dp[i] != -1) {
        new_dp[i] = max(new_dp[i], dp[i]);
        new_dp[(i + x) % 10] = max(new_dp[(i + x) % 10], dp[i] + x);
      }
    }
    dp = new_dp;
  }
  cout << max(0, *max_element(dp.begin() + 1, dp.end())) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
  int a, b, c, box, i;
  scanf("%d %d %d", &a, &b, &c);
  for (i = 0; i < 3; i++){
    if (a > b) {
      box = a;
      a = b;
      b = box;
    } else if (b > c) {
      box = b;
      b = c;
      c = box;
    } else if (a > c) {
      box = c;
      c = a;
      a = box;
    } else if (a < b && b < c) {
      break;
    }
  }
  printf("%d %d %d\n", a, b, c);
}

Measured memory_bytes: 1780
last = 1
while last != 0:
	num = list(map(int, input().split(" ")))
	if num[0] == 0 and num[1] == 0:
		last = 0
	else:
		if num[0] >= num[1]:
			print(str(num[1]) + " " + str(num[0]))
		else:
			print(str(num[0]) + " " + str(num[1]))


Measured memory_bytes: 5620
S = input()
enki = {"A", "T", "C", "G"}
T = list(S)
l = [0] * 10
for i in range(len(T)):
    j = i
    while(j<len(T) and T[j] in enki):
        l[i] += 1
        j += 1

print(max(l))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define debug(a) cout<<a<<endl
#define clr(a) memset(a,0,sizeof(a))
#define clrne(a) memset(a,-1,sizeof(a))
#define clrinf(a) memset(a,0x3f,sizeof(a))
#define clrneinf(a) memset(a,0xc0,sizeof(a))
#define pb(a) push_back(a)
#define maxn 100010
#define mod 1000000007
#define eps 1e-9
#define inf 0x7fffffff
int a[maxn];
int b[maxn];
ll ans = 0;
int K;
int n,k;
void solve()
{
//    cout<<K<<endl;
    ll res = 0;
    for (int i = 1;i<=n;i++)
        if ((a[i]|K)<=K) res += b[i];
//    cout<<res<<' '<<K<<endl;
    ans = max(ans,res);
}
int main()
{
//  freopen("in.txt","r",stdin);
//  freopen("out.txt","w",stdout);
    scanf("%d%d",&n,&k);
    for (int i = 1;i<=n;i++)
        scanf("%d%d",&a[i],&b[i]);
    K = k;
    solve();
    for (int i = 0;i<=30;i++)
    {
        if ((k&(1<<i)))
        {
            K = k;
            K^=(1<<i);
            for (int j = i-1;j>=0;j--)
                K |= (1<<j);
        }
        solve();
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
  string N;
  cin >> N;
  int s = 0;
  for(int i = 0; i < N.length(); i++){
    int r = static_cast<int>(N[i])%3;
    if(r == 2) r = -1;
    s += r;
  }
  if(s%3 == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3708
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define ll long long

int s[11][1001];
int bunkatu[11]={};
int h,w,k;

int next(){
  int tmp=h-2;
  while(tmp>=0 && bunkatu[tmp]==1){
    tmp--;}
  if(tmp<0) return 0;
  bunkatu[tmp]=1;
  tmp++;
  while(tmp<h-1){
    bunkatu[tmp]=0;
    tmp++;}
  return 1;
}

int onerole(){
  int count[11]={};
  int tmpans=0;
    for(int m=0;m<h-1;m++){
      tmpans += bunkatu[m];}
    
    for(int j=0;j<w;j++){
      int i=0;
      int max=0;
      int group=0;
      int tmpcount[11]={};
      while(i<h){
	tmpcount[group] += s[i][j];
	if(bunkatu[i]==1){
	  if(tmpcount[group]>k){
	    return -1;}
	  if(max<tmpcount[group]+count[group]){
	    max=tmpcount[group]+count[group];}
	  //printf("tmpcount = %d\n",tmpcount[group]);
	  group++;}
	i++;}//end of while
      if(tmpcount[group]>k){
	    return -1;}
	  if(max<tmpcount[group]+count[group]){
	    max=tmpcount[group]+count[group];}
      if(max<=k){
	for(int m=0;m<=group;m++){
	  count[m] += tmpcount[m];}}
      else{
	for(int m=0;m<=group;m++){
	  count[m] = tmpcount[m];}
	tmpans++;}
    }//end of for
    return tmpans;
}

int main(){
  scanf("%d%d%d",&h,&w,&k);
  char st[1001];
  for(int i=0;i<h;i++){
    scanf("%s",st);
    for(int j=0;j<w;j++){
      s[i][j] = st[j]-'0';}}

  int ans = 100000;
  int tmpans;

  do{
    //printf("hi\n");
    tmpans = onerole();
    if(tmpans==-1) continue;
    if(ans>tmpans) ans=tmpans;
    //printf("%d\n",tmpans);
  }while(next());

  printf("%d\n",ans);
      
  return 0;
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}




void _main() {
        int n, m; cin >> n >> m;
        vector<vector<int>> adj(n+1);
        while (m--) {
                int a, b; cin >> a >> b;
                adj[a].emplace_back(b);
                adj[b].emplace_back(a);
        }

        queue<int> q;
        q.emplace(1);
        vector<bool> vis(n+1);
        vector<int> ans(n+1);
        vis[1] = 1;
        while (!q.empty()) {
                int a = q.front(); q.pop();
                for (const auto b: adj[a]) {
                        if (vis[b]) continue;
                        q.emplace(b);
                        ans[b] = a;
                        vis[b] = 1;
                }
        }

        cout << "Yes\n";
        for (int i = 2; i <= n; i++) cout << ans[i] << '\n';
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 10136
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char s[100100];
int main(){
	scanf("%s",s+1);
	int n=strlen(s+1);
	for(int i=1;i<=n;i++){
		if(s[i-1]==s[i]){
			cout<<i-1<<" "<<i;
			return 0;
		}
		else if(s[i]==s[i-2]){
			cout<<i-2<<" "<<i;
			return 0;
		}
		else if(i==n){
			cout<<"-1 -1";
			return 0;
		}
	}
}

Measured memory_bytes: 384
#include<stdio.h>

int main(void){
    int i,j,r,c;
    scanf("%d %d", &r, &c);
    int graph[r+1][c+1];
    for ( i = 0 ; i < r+1 ; i++ ){
        for ( j = 0 ; j < c+1 ; j++ ){
            graph[i][j] = 0;
        }
    }
    for ( i = 0 ; i < r ; i++ ){
        for ( j = 0 ; j < c ; j++ ){
            scanf("%d", &graph[i][j]);
            graph[i][c]+=graph[i][j];
            graph[r][j]+=graph[i][j];
        }
        graph[r][c]+=graph[i][c];
    }
    for ( i = 0 ; i < r+1 ; i++ ){
        for ( j = 0 ; j < c+1 ; j++ ){
            printf("%d", graph[i][j]);
            if ( j != c ) {
                printf(" ");
            } else {
                printf("\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

void solve(long long n){
	vector<pll> v;
	for (ll x=1;x<=n;x++) {
		ll e=n+1-x-(n%2);
		for (ll y=x+1;y<=n;y++) {
			if (y!=x&&y!=e) v.PB(MP(x,y));
		}
	}
	printf("%d\n",(int)v.size());
	for (auto &w:v) printf("%lld %lld\n",w.fst,w.snd);

}

int main(){	
	ios_base::sync_with_stdio(false); cin.tie(0);
	long long N;
	scanf("%lld",&N);
	solve(N);
	return 0;
}



Measured memory_bytes: 512
import Control.Applicative ((<$>))
import Data.List (group)

main :: IO ()
main = do
  _ <- getLine
  as <- map read . words <$> getLine
  print $ solve as

solve :: [Int] -> Int
solve = go 1 1
  where
    go m n [] = m `max` n
    go m n (x:xs)
      | x == 0
        = go (m `max` n) 1 xs
      | x == 1
        = go m (n+1) xs


Measured memory_bytes: 4160
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    int n,m,ans=0;
    cin >> n >> m;
    vector<vector<int>> g(n);
    int h[n];
    rep(i,n) cin >> h[i];
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--,b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    rep(i,n){
        bool flag = 1;
        rep(j,(int)g[i].size()){
            if(h[i]<=h[g[i][j]]) flag = 0;
        }
        if(flag) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8736
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define FORN(i, x, y) for (int i = x; i <= y; i++)
#define DEC(i, x, y) for (int i = x; i >= y; i--)
#define scan1(X) scanf("%d", &X)
#define scan2(X, Y) scanf("%d%d", &X, &Y)
#define scan3(X, Y, Z) scanf("%d%d%d", &X, &Y, &Z)
#define scan4(X, Y, Z, W) scanf("%d%d%d%d", &X, &Y, &Z, &W)
#define scanl1(X) scanf("%lld", &X);
#define scanl2(X, Y) scanf("%lld%lld", &X, &Y)
#define scanl3(X, Y, Z) scanf("%lld%lld%lld", &X, &Y, &Z)
#define scanl4(X, Y, Z, W) scanf("%lld%lld%lld%lld", &X, &Y, &Z, &W)
#define print1(X) printf("%d\n", X);
#define print2(X, Y) printf("%d %d\n", X, Y);
#define print3(X, Y, Z) printf("%d %d %d\n", X, Y, Z);
#define print4(X, Y, Z, W) printf("%d %d %d %d\n", X, Y, Z, W);
#define printl1(X) printf("%lld\n", X);
#define printl2(X, Y) printf("%lld %lld\n", X, Y);
#define printl3(X, Y, Z) printf("%lld %lld %lld\n", X, Y, Z);
#define printl4(X, Y, Z, W) printf("%lld %lld %lld %lld\n", X, Y, Z, W);
#define max3(X, Y, Z) max(X, max(Y, Z))
#define max4(X, Y, Z, W) max(max(X, Y), max(Z, W))
#define min3(X, Y, Z) min(X, min(Y, Z))
#define min4(X, Y, Z, W) min(min(X, Y), min(Z, W))
#define popcount(X) __builtin_popcount(X)
#define all(x) x.begin(), x.end()
#define size(X) (int)X.size()
#define mp make_pair
#define pb push_back
#define fr first
#define sc second
#define lc(x) 2 * x
#define rc(x) 2 * x + 1
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<ld, ld> pldld;
const long long l_inf = numeric_limits<long long>::max();
const long long l_ninf = numeric_limits<long long>::min();
const int inf = numeric_limits<int>::max();
const int ninf = numeric_limits<int>::min();
const double pi = 1.00 * acos(-1.00);
const double eps = 1e-8;
void cio(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
ll gcd(ll a, ll b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return (a * (b / gcd(a, b))); }
int sq( int x ) {return x * x;}
////////////////////////////////////////////////////////////////////Header
const int maxn = 1e5 + 5;
int n, k;
int h[maxn];
int dp[maxn];

int main () {
    scan2(n, k);
    FORN(i, 1, n) scan1(h[i]);
    dp[1] = 0;
    FORN(i, 2, n) {
        dp[i] = inf;
        FORN(j, 1, k) {
            if ( i - j > 0 ) dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i - j]));
        }
    }
    print1(dp[n]);
}

Measured memory_bytes: 4560
# -*- coding: utf-8 -*-
import collections
n = int(input())
s = list(input())

c = collections.Counter(s)
total = c['R'] * c['G'] * c['B']
tmp = 0
#print(total)
for i in range(1, n - 1):
    for j in range(i + 1, n):
        k = 2 * j - i
        if i <= k <= n:
            #print(i, j, k)
            if s[i-1] != s[j-1] and s[i-1] != s[k-1] and s[j-1] != s[k-1]:
                tmp += 1
print(total - tmp)


Measured memory_bytes: 68856
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back

using namespace std;

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

const int MAXN = 10 + 10;

int n, m;
vector<int> k[MAXN];
int on[MAXN], p[MAXN];
int ans;

void go(int ind){
	if(ind == n+1){
		for(int i=1; i<=m; i++){
			int cc = 0;
			for(int u : k[i])
				cc += on[u];
			if(cc%2 != p[i]%2) return;
		}
		ans++;
		return;
	}

	on[ind] = 0;
	go(ind+1);
	on[ind] = 1;
	go(ind+1);
}

int main(){
	ios_base::sync_with_stdio(false), cin.tie(0);
	cin >> n >> m;
	for(int i=1; i<=m; i++){
		int ck; cin >> ck;
		while(ck--){
			int cv; cin >> cv;
			k[i].pb(cv);
		}
	}

	for(int i=1; i<=m; i++) cin >> p[i];

	go(1);

	cout << ans << endl;
}


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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define MOD ll(1000000007)
#define debug(x) cout << '[' << #x << " is: " << x << "] " <<endl;
#define decimalpoint cout << std::fixed << setprecision(5)


void solve(){
	long long n , x , t;
	cin >> n >> x >> t;

	cout << (long long)(ceil(n*1.0/x) * t) << endl;

}



int main()
{
    FAST;
    int t;
   	t = 1;

    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <string.h>

void rank(int *r, float sight)
{
    if (sight >= 1.1){
        r[0]++;
    }
    else if (sight >= 0.6){
        r[1]++;
    }
    else if (sight >= 0.2){
        r[2]++;
    }
    else{
        r[3]++;
    }
}

int main(void)
{
    int eye[2][4];
    float left, right;
    int i;
    
    memset(eye, 0, sizeof(eye));
    
    while (scanf("%f%f", &right, &left) != EOF){
        rank(eye[0], right);
        rank(eye[1], left);
    }
    
    for (i = 0; i < 4; i++){
        printf("%d %d\n", eye[0][i], eye[1][i]);
    }
    
    return (0);
}

Measured memory_bytes: 0
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define VIZ {printf("digraph G{\n"); for(int i=1;i<=n;i++) for es(i,e) printf("%d->%d;\n",i,vb[e]); puts("}");}
#define VIZ2 {printf("graph G{\n"); for(int i=1;i<=n;i++) for es(i,e) if(vb[e]>=i)printf("%d--%d;\n",i,vb[e]); puts("}");}
#define SZ 666666
ll n,m;
bool ok(ll x)
{
	ll N=n,M=m;
	if(N<x)
	{
		ll ls=x-N;
		M-=ls*2; N+=ls;
		if(M<0) return 0;
	}
	return N>=x&&M>=x*2;
}
int main()
{
	cin>>n>>m;
	ll l=0,r=1e13;
	while(l<r)
	{
		ll m=(l+r+1)>>1;
		if(ok(m)) l=m; else r=m-1;
	}
	cout<<l<<"\n"; 
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	private static final boolean TEST = false;

	public static void main(String[] args) {

		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int h, w, a, b;
		h = in.nextInt();
		w = in.nextInt();
		a = in.nextInt();
		b = in.nextInt();
		solve(h, w, a, b);
		in.close();
	}

	private static void solve(int h, int w, int a, int b) {
		String x = "";
		String y = "";
		for (int i = 0; i < w; i++)
			if (i < a) {
				x = x.concat("0");
				y = y.concat("1");
			} else {
				x = x.concat("1");
				y = y.concat("0");
			}
		for (int i = 0; i < h; i++) {
			if (i < b)
				System.out.println(x);
			else
				System.out.println(y);
		}
	}
}

Measured memory_bytes: 27220
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int N;
vector<int> v;

void func(int bit, int S1, int S2, int lock){
	//cout << bit << " " << S1 << " " << S2 << " " << lock << endl;
	if(bit <= 1){
		v.push_back(S1);
		v.push_back(S2);
		//cout << S1 << " " << S2 << " " << endl;
		return;
	}
	for(int i = 0; i < N; i++){
		if((S1 & (1 << i)) != (S2 & (1 << i))){
			lock += (1 << i);
			bool flag = true;
			for(int j = i + 1; j < N; j++){
				if((S1 & (1 << j)) != (S2 & (1 << j))){
					flag = false;
					int num;
					if(S1 & (1 << j)){
						num = S1 - (1 << j);
						func(bit - 1, S1, num, lock);
						func(bit - 1, num ^ (1 << i), S2, lock);
					}else{
						num = S2 - (1 << j);
						func(bit - 1, S1, num ^ (1 << i), lock);
						func(bit - 1, num, S2, lock);
					}
					break;
				}
			}
			if(flag){
				for(int j = 0; j < N; j++){
					if((lock & (1 << j)) == 0){
						func(bit - 1, S1, S1 ^ (1 << j), lock);
						func(bit - 1, S1 ^ (1 << j) ^ (1 << i), S2, lock);
						break;
					}
				}
			}
			break;
		}
	}
}

int main(){
	int A, B;
	cin >> N >> A >> B;
	int num = (A ^ B), cnt = 0;
	while(num > 0){
		if(num % 2){
			cnt += 1;
		}
		num /= 2;
	}
	if(cnt % 2 == 0){
		cout << "NO" << endl;
		return 0;
	}
	func(N, A, B, 0);
	cout << "YES" << endl;
	for(int i = 0; i < v.size() - 1; i++){
		cout << v[i] << " ";
	}
	cout << v[v.size() - 1] << endl;
	return 0;
}

Measured memory_bytes: 1656
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
using namespace std;
#define vel vector<long long>
#define vvel vector<vel>
#define int long long
#define rep(i,n) for(long long i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define V vector
long long p = 998244353;
vel kai(4001, 1);
vel ink(4001, 1);
vel uni(vel &list) {
	if (list.size() == 0) { return list; }
	sort(list.begin(), list.end());
	vel ql(1, list[0]);
	rep(i, list.size() - 1) {
		if (list[i] != list[i + 1]) { ql.push_back(list[i + 1]); }
	}
	return ql;
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a, p - 2);
}
void make_kai() {
	rep(i, 4000) { kai[i + 1] = (kai[i] * (i + 1)) % p; }
	rep(i, 4001) { ink[i] = inv(kai[i]); }
}
int com(int n, int r) {
	int ans = kai[n] * ink[r];
	ans %= p; ans *= ink[n - r]; ans %= p;
	return ans;
}
signed main() {
	int n, k; cin >> n >> k;
	double ans = 0; double rui = 1;
	int mu = 1;
	for (int i = n; i > 0; i--) {
		while (k > i*mu) {
			mu *= 2;
			rui = rui / 2;
		}
		ans += rui;
	}
	double qn = n;
	ans = ans / qn;
	printf("%6.11lf", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>	
using namespace std;
int main(){
	int A, B, C, D;
	cin>>A;
	cin>>B;
	cin>>C;
	if(A+B>=C|| B>C){
		D=B+C;
	}else if(A+B<C){
		D=2*B+A+1;
	}
	cout<<D<<endl;
} 

Measured memory_bytes: 3508
solve [a, b] = sum [ mod (f i) 2 * 2^i | i <- [0..40] ] where
  f i = cnt (b+1) - cnt a where
    cnt x = q * 2^i + max 0 (r - 2^i)
      where (q, r) = divMod x (2^(i+1))

main = getLine >>= print . solve . map read . words

Measured memory_bytes: 508
#include <iostream>

using namespace std;

int main(void)
{
	int in1,in2;

	cin >> in1 >> in2;
	while(in1 | in2){
		int c = 0;
		for(int i = in1; i <= in2; i++){
			if(i % 4 == 0 && ( (i % 100 > 0 || i % 400 == 0) ) ){
				cout << i << endl;
				c++;
			}
		}
		if(c == 0)
			cout << "NA" << endl;

		cin >> in1 >> in2;
		if(in1 | in2)
			cout << endl;

	}

	return 0;
}

Measured memory_bytes: 1160
s=input()
n=int(input())
l=["z" for i in range(5)]
for i in s:
  if l[4]>i and not i in l:
    l[4]=i
    l=sorted(l)
l2=[]
s+=" "
for i in range(len(s)-1):
  if s[i] in l:
    w=""
    for j in range(5):
      if s[i+j]==" ":
        break
      else:
        w+=s[i+j]
        l2.append(w)
l2=sorted(list(set(l2)))
print(l2[n-1])
    
    
    
    

Measured memory_bytes: 4212
using System;

namespace AtCoder.Problems
{
    public class ProblemB
    {
        public static void Main(string[] args)
        {
            var s = new SolveB();
            s.Solve();
        }

        public class Scanner
        {
            private string[] _s;
            private int _i;
            private readonly char[] _separators = new char[] { ' ' };

            public Scanner()
            {
                _s = new string[0];
                _i = 0;
            }

            public string Next()
            {
                if (_i < _s.Length) return _s[_i++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();
                _s = st.Split(_separators, StringSplitOptions.RemoveEmptyEntries);
                if (_s.Length == 0) return Next();
                _i = 0;
                return _s[_i++];
            }

            public int NextInt() => int.Parse(Next());
            public long NextLong() => long.Parse(Next());
            public ulong NextULong() => ulong.Parse(Next());
            public double NextDouble() => double.Parse(Next());

            public int[] GetIntArray(int n, int add = 0)
            {
                int[] array = new int[n];
                for (int i = 0; i < n; i++)
                {
                    array[i] = NextInt() + add;
                }
                return array;
            }

            public long[] GetLongArray(int n, long add = 0)
            {
                long[] array = new long[n];
                for (int i = 0; i < n; i++)
                {
                    array[i] = NextLong() + add;
                }
                return array;
            }

            public double[] GetDoubleArray(int n, double add = 0)
            {
                double[] array = new double[n];
                for (int i = 0; i < n; i++)
                {
                    array[i] = NextDouble() + add;
                }
                return array;
            }
        }
    }

    public class SolveB
    {
        public void Solve()
        {
            var cin = new ProblemB.Scanner();
            var k = cin.NextInt();
            var s = cin.NextInt();

            var result = GetAnswer(k, s);
            Console.WriteLine(result);
        }

        public long GetAnswer(int k, int s)
        {
            long answer = 0;
            for (int x = 0; x <= k; x++)
            {
                for (int y = 0; y <= k; y++)
                {
                    var z = s - x - y;
                    if (z >= 0 && z <= k) { answer++; }
                }
            }
            return answer;
        }
    }
}


Measured memory_bytes: 13140
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int k = int.Parse(Console.ReadLine());
            int x = int.Parse(Console.ReadLine());
            int y = int.Parse(Console.ReadLine());

            int p = 0;

            if (k >= n) p = n * x;
            else
            {
                p = k * x + (n - k) * y;
            }
            Console.WriteLine(p);
        }
    }
}

Measured memory_bytes: 2648
import java.util.Scanner;

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

        int N = scanner.nextInt();
        int X = scanner.nextInt();
        int[] L = new int[N + 1];

        for (int i = 1 ; i <= N ; i++) {
            L[i] = scanner.nextInt();
        }

        int count = 1;
        int d = 0;

        for (int i = 1 ; i <= N ; i++) {
            d += L[i];
            if (d > X) {
                break;
            }
            count++;
        }

        System.out.println(count);
    }
}


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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

int main() {
  int N;
  string S;
  cin>>N>>S;
  int ans = 0;
  for(int t = 0; t < N; t++){
    vector<int> Z(N-t);
    Z[0] = N-t;
    int i = 1, j = 0;
    while(i < N-t){
      while(i + j < N-t && S[j+t] == S[i + j+t]) j++;
      Z[i] = j;

      if(j == 0){
        i++;
        continue;
      }
      int k = 1;
      while(k < j && k + Z[k] < j){
        Z[i + k] = Z[k];
        k++;
      }
      i += k;
      j -= k;
    }
    for(int l = 0; l < (int)Z.size();l++) chmax(ans,min(Z[l],l));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int hankei = scan.nextInt();
		int menseki = 0;

		menseki = (int)(hankei*hankei*Math.PI);
		System.out.println(Math.round(menseki/Math.PI));

		scan.close();

	}

}


Measured memory_bytes: 22612
#!/usr/bin/env python3

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def main():
    q, h, s, d = map(int, input().split())
    n = int(input())
    l = min(4 * q, 2 * h, s)
    if 2 * l > d:
        print((n // 2) * d + (n % 2) * l)
    else:
        print(n * l)

main()


Measured memory_bytes: 3444
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
{-# LANGUAGE BangPatterns      #-}
{-# LANGUAGE CPP               #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections     #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    !n <- readLn :: IO Int
    xs <- U.map (subtract 1).U.unfoldrN n (B.readInt.B.dropWhile isSpace) <$> B.getLine
    print $ solve n xs

solve :: Int -> U.Vector Int -> Int
solve n xs = (flip div 2) . U.length $ U.ifilter (\i x -> xs U.! x == i) xs

Measured memory_bytes: 3836
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    std::string S;
    std::cin >> S;

    const auto L = S.size();

    int64_t open = 0;

    int64_t depth = 0;
    for (size_t i = 0; i < L; ++i) {
        if (S[i] == '(') {
            depth++;
        }
        else {
            if (depth == 0) {
                open++;
            }
            else {
                depth--;
            }
        }
    }
    if (open > 0) {
        std::cout << std::string(open, '(');
    }
    std::cout << S;

    if (depth > 0) {
        std::cout << std::string(depth, ')');
    }

    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
    int N;
    cin >> N;
    int V[21];
    int C[21];
    for (int i = 0; i < N; i++)
    {
        cin >> V[i];
    }
        for (int i = 0; i < N; i++)
    {
        cin >> C[i];
    }
    int res=0;
for (int i = 0; i < N; i++)
    {
       if(V[i]>C[i]){
           res+=V[i]-C[i];
       }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
ab=[]
n,m=gets.split.map(&:to_i)
for i in 0...n do
  a,b=gets.split.map(&:to_i)
  ab[i]=[a,b]
end
ab.sort!{|c,d| c[0]<=>d[0]}
sum=0
cnt=0
for i in 0...n do
  if cnt+ab[i][1]<m
    sum += ab[i][0]*ab[i][1]
    cnt += ab[i][1]
  else
    sum += (m-cnt)*ab[i][0]
    p sum
    exit
  end
end  

Measured memory_bytes: 10488
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/











int N, W[1010], S[1010], V[1010];
ll dp[1010][30101];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> W[i] >> S[i] >> V[i];

    vector<int> ord;
    rep(i, 0, N) ord.push_back(i);
    sort(all(ord), [&](int a, int b) { return min(S[a], S[b] - W[a]) > min(S[b], S[a] - W[b]); });


    rep(i, 0, N) rep(tot, 0, 20101) {
        int a = ord[i];
        chmax(dp[i + 1][tot], dp[i][tot]);
        if(tot <= S[a]) chmax(dp[i + 1][tot + W[a]], dp[i][tot] + V[a]);
    }

    ll ans = 0;
    rep(tot, 0, 20101) chmax(ans, dp[N][tot]);
    cout << ans << endl;
}


Measured memory_bytes: 234368