akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

const i64 mod = 1e9 + 7;

i64 fact_memo[200001];
i64 fact(i64 x) {
  if (x == 0) return 1;
  if (fact_memo[x]) return fact_memo[x];
  return fact_memo[x] = x * fact(x - 1) % mod;
}
i64 ipow(i64 a, i64 b) {
  return (b & 1 ? a : 1) * (b > 1 ? ipow(a * a % mod, b >> 1) : 1) % mod;
}
i64 inv(i64 x) {
  return ipow(x, mod - 2);
}
i64 fact_inv(i64 x) {
  return inv(fact(x));
}
i64 perm(i64 a, i64 b) {
  return fact(a) * fact_inv(a - b) % mod;
}
i64 conb(i64 a, i64 b) {
  return fact(a) * fact_inv(b) % mod * fact_inv(a - b) % mod;
}
int main() {
    i64 n, k;
    cin >> n >> k;
    vector<i64> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    sort(begin(a), end(a));

    i64 y[2] = {};
    for (int j = 0; j < 2; ++j) {
        for (int i = n - 1; i >= k - 1; --i) {
            i64 x = conb(i, k - 1) % mod * (a[i] + mod) % mod;
            (y[j] += x) %= mod;
        }
        reverse(begin(a), end(a));
    }

    cout << (y[0] - y[1] + mod) % mod << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>
#include <cassert>
using namespace std;

//common
// using i32=int;using i64=long long;using ll =i64;
// using uint=unsigned int;using ull=unsigned long long;
// template<typename T> using matrix=vector<vector<T> >;

#define BR "\n"
#define ALL(c) (c).begin(),(c).end()
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define EACH(it,o) for(auto it = (o).begin(); it != (o).end(); ++it)
#define IN(l,v,r) ((l)<=(v) && (v)<(r))

//config
//#undef NDEBUG
//#define INF 1<<30
//#define EPS 1e-8
//const ll MOD =100000007;

//debug
#ifdef NDEBUG
#define DUMP(x)
#define DUMPLN(x)
#define DEBUG(x)
#define DEBUGLN(x)
#define LINE()
#define LINELN()
#define CHECK(exp,act)
#define STOP(e)
#else
#define DUMP(x)  cerr << #x << " = " << (x)
#define DUMPLN(x)  DUMP(x) <<endl
#define DEBUG(x) DUMP(x) << LINE() << " " << __FILE__
#define DEBUGLN(x) DEBUG(x)<<endl
#define LINE()    cerr<< " (L" << __LINE__ << ")"
#define LINELN()    LINE()<<endl
#define CHECK(exp,act)  if(exp!=act){DUMPLN(exp);DEBUGLN(act);}
#define STOP(e)  CHECK(e,true);if(!(e)) exit(1);
#endif

template<class T> inline string toString(const vector<T>& x) {
	stringstream ss;
	REP(i,x.size()){
		if(i!=0)ss<<" ";
		ss<< x[i];
	}
	return ss.str();
}

template<class T> inline string toString(const vector<vector<T> >& map) {
	stringstream ss;
	REP(i,map.size()){
		if(i!=0)ss<<BR;
		ss<< toString(map[i]);
	}
	return ss.str();
}
template<class K,class V>  string toString(map<K,V>& x) {
	string res;stringstream ss;
	for(auto& p:x)ss<< p.first<<":" << p.second<<" ";
	return ss.str();
}

string BITtoString(int bit){
    stringstream ss;
    while(bit!=0){ss<<(bit%2);bit/=2;}
    string res=ss.str();reverse(ALL(res));
    return res;
}

template<typename T,typename V> inline T mod(T v,V MOD){
	return (v%MOD+MOD)%MOD;
}

class Main{
public:
	void run(){
		int N;cin >> N;
		int K;cin >>K;
		REP(k,K){
			int a,b; cin >>a >> b;a--;b--;
			int c;
			if(N%2==1){
				a-=(N-1)/2;b-=(N-1)/2;
				c=(N-1)/2%3;
				c=mod(c-(max(abs(a),abs(b))),3);
			}else{
				a-=(N-1)/2;b-=(N-1)/2;
				c=(N-1)/2%3;
				c=mod(c-(max(abs(a<=0?a:a-1),abs(b<=0?b:b-1))),3);
			}

			cout <<(c+1)<<endl;
		}

	}
};
int main(){
  	Main().run();
  	return 0;
 }

Measured memory_bytes: 1168
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
 
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ll long long
using namespace std;
int main(){
  int N;
  cin >> N;
  ll a[200010];
  FOR(i, 0, N) cin >> a[i];
  FOR(i, 0, N) a[i] -= i+1;
  
  sort(a, a+N);
  
  ll m;
  if(N%2==0) m = (a[N/2] + a[N/2-1])/2;
  else m = a[N/2];
  
  ll ans1 = 0;
  ll ans2 = 0;
  ll ans3 = 0;
  
  FOR(i, 0, N) ans1+=abs(a[i]-m);
  FOR(i, 0, N) ans2+=abs(a[i]-m-1);
  FOR(i, 0, N) ans3+=abs(a[i]-m+1);
  
  cout << min({ans1, ans2, ans3}) << endl;

}

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

#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

typedef pair<int, int> pint;

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front

#define MOD (1000 * 1000 * 1000 + 7)

struct Edge {
    int s, c, i, j;
};

signed main() {
    int n;
    int max_e = 0;
    cin >> n;

    vector<vector<Edge>> edges(n, vector<Edge>());

    REP(i, n-1) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;

        int j1 = SZ(edges[a]);
        int j2 = SZ(edges[b]);
        edges[a].pb(Edge{b, -1, i, j2});
        edges[b].pb(Edge{a, -1, i, j1});
    }

    REP(i, n) {
        max_e = max(max_e, SZ(edges[i]));
    }

    vector<int> ok(n, 0);
    queue<int> que;
    que.push(0);
    ok[0] = 1;

    vector<int> ans(n-1, -1);

    while (!que.empty()) {
        int a = que.front();
        que.pop();

        vector<int> colors(max_e, 0);
        for (Edge &e: edges[a]) {
            if (e.c == -1) continue;
            colors[e.c] = 1;
        }

        int m = 0;
        for (Edge &e: edges[a]) {
            if (ok[e.s] == 1) continue;
            que.push(e.s);
            ok[e.s] = 1;

            while (colors[m] != 0) {
                m++;
            }
            colors[m] = 1;
            edges[e.s][e.j].c = m;
            e.c = m;
            ans[e.i] = m;
        }
    }

    cout << max_e << endl;
    REP(i, n-1) {
        cout << (ans[i] + 1) << endl;
    }

    return 0;
}

Measured memory_bytes: 8704
#include<stdio.h>
#define N 101

main(){
  int G[N][N];
  int i,j,v,r,s,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      G[i][j] = 0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d", &v,&r);
    for(j=0;j<r;j++){
      scanf("%d",&s);
      G[i][s-1] = 1;
    }
  }  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d",G[i][j]);
      if(j < n-1){
	printf(" ");
      }
    }
    printf("\n");
  }
  return 0;
}

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
      string s;
      cin>>s;
      vector<int> a(27);
      r(i,s.size()){
        int x=s.at(i)-'a';
        //cout<<x<<endl;
        a.at(x)++;
      }
      //r(i,26)cout<<a.at(i)<<endl;
      r(i,27){
        if(i==26){cout<<"None"<<endl;break;}
        if(a.at(i)==0){
          char y=i+'a';
          cout<<y<<endl;
          break;
        }


      }









return 0;

}


Measured memory_bytes: 512
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define y0 y12345
#define y1 y54321

#ifdef LOCAL
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
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(a>b){a=b;return 1;}return 0;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;
	ll s,a=0;cin>>s;
	string str = to_string(s);
	int size = str.size();
	debug("%d\n", (ll)pow(2.0,(size-1.0)));
	rep(i, (ll)pow(2.0,(size-1.0)) ){
		ll t = s;
		int last = 0;
		rep(j, size-1){
			if(((1<<j) & i)){
				debug("%ld\n",t % (ll)pow(10.0, j+1-last) );
				a += t % (ll)pow(10.0, j+1-last);
				t /= (ll)pow(10.0, j+1-last);
				last = j+1;
			}
		}
		a+= t;
		debug("%ld\n", a);
	}
	cout << a<< endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;

void chmax(ll& x, ll y) {
    if (x < y) x = y;
}

struct UnionFind {
    vector<int> par;

    UnionFind(int n): par(n, -1) {}
    void init(int n) { par.assign(n, -1); }

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

    int issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);

        if (x == y) return false;

        // merge by size
        // force size of x to be bigger than that of y
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;

        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};

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

    int n, m; cin >> n >> m;

    UnionFind uf(n + 1);

    REP(i, m) {
        int c, x, y; cin >> c >> x >> y;

        if (c == 0) uf.merge(x, y);
        else print(int(uf.issame(x, y)));
    }


}


Measured memory_bytes: 3280
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    int A , B , K ;
    cin >> A >> B >> K ;
    int count = 0 ;
     for(int i=100; 1<=i; i--){
    if( A%i == 0 && B%i == 0 ){
      count ++;
    }
    if( count == K ){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

   

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int t,n,i,s,f,sum;
	while(1){
		sum=0;
		scanf("%d",&t);
		if(t==0)break;
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d %d",&s,&f);
			sum+=f-s;
		}
		if(sum>=t){
			printf("OK\n");
		}
		else{
			printf("%d\n",t-sum);
		}
	}
	return 0;
}

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

int main(void)
{
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if (u == s)
    {
        a--;
    }
    else
    {
        b--;
    }
    cout << a << ' ' << b << endl;
    return 0;
}


Measured memory_bytes: 3588
import java.util.Scanner;

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 c = sc.nextInt();

		if(a == b) {
			if(a == c) {
				System.out.println("No");
			}else {
				System.out.println("Yes");
			}
		}else if(a == c) {
			System.out.println("Yes");
		}else {
			if(b == c) {
				System.out.println("Yes");
			}else {
			System.out.println("No");
			}
		}
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1 ; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1 ; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const bool debug = 0;
/***************************************/

int N;
int wc[40];
int nec[5] = {5,7,5,7,7};

int main() {
  while (cin >> N, N) {
    REP(i, N) {
      string str;
      cin >> str;
      wc[i] = str.size();
    }
    
    int nec[5] = {5, 7, 5, 7, 7};
    bool en = false;
    REP(i, N) {
      if (en) break;
      int cur = 0, cnt = 0;
      FOR(j, i, N) {
        cnt += wc[j];
        if (cnt == nec[cur]) {
          cur++;
          cnt = 0;
          if (cur == 5) {
            cout << i + 1 << endl;
            en = true;
            break;
          }
        }
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3128
#include<iostream>
using namespace std;
 
int main(){
    int N,K;
  	int d;
    int list[101]={};	
    cin>> N>>K;
   	int ans=N;
	for(int i=0; i< K; i++){
    //cout << K<<endl;
      cin >> d;
      for(int j = 0; j< d; j++){
        int input;
        cin >>input;
        if (list[input]==0) ans =ans-1;
      	list[input] =list[input]+1;
      }
    }
    cout <<ans<<endl;
    return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <climits>

using namespace std;


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

	string s;
	cin >> s;

	for (int i = 0; i < (int) s.size(); ++i) {
		if (i % 2 == 0)
			cout << s[i];
	} cout << endl;

	return 0;
}

Measured memory_bytes: 592
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())
A=[int(input()) for i in range(n)]
print("first" if not all(ai % 2 == 0 for ai in A) else "second")   
    


Measured memory_bytes: 43868
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 200020
using namespace std;
namespace IO{
	const int BS=(1<<20); int Top=0;
	char Buffer[BS],OT[BS],*OS=OT,*HD,*TL,SS[20]; const char *fin=OT+BS-1;
	char Getchar(){if(HD==TL){TL=(HD=Buffer)+fread(Buffer,1,BS,stdin);} return (HD==TL)?EOF:*HD++;}
	void flush(){fwrite(OT,1,OS-OT,stdout);}
	void Putchar(char c){*OS++ =c;if(OS==fin)flush(),OS=OT;}
	void write(int x){
		if(!x){Putchar('0');return;} if(x<0) x=-x,Putchar('-');
		while(x) SS[++Top]=x%10,x/=10;
		while(Top) Putchar(SS[Top]+'0'),--Top;
	}
	int read(){
		int nm=0,fh=1; char cw=Getchar();
		for(;!isdigit(cw);cw=Getchar()) if(cw=='-') fh=-fh;
		for(;isdigit(cw);cw=Getchar()) nm=nm*10+(cw-'0');
		return nm*fh;
	}
}
using namespace IO;
int n,fs[M],nt[M],to[M],tmp;
void link(int x,int y){nt[tmp]=fs[x],fs[x]=tmp,to[tmp++]=y;}
int DP(int x,int last){
	int sg=0;
	for(int i=fs[x];i!=-1;i=nt[i]) if(to[i]!=last) sg^=(DP(to[i],x)+1);
	return sg;
}
int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	n=read(),memset(fs,-1,sizeof(fs));
	for(int i=1;i<n;i++){int x=read(),y=read();link(x,y),link(y,x);}
	puts(DP(1,0)?"Alice":"Bob");
	return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        // スペース区切りの整数の入力
        string[] input = Console.ReadLine().Split(' ');
        long a = long.Parse(input[0]);
        long b = long.Parse(input[1]);

        int sum = 0;
        if (b >= a)
        {
            sum++;
        }

        for (; ; )
        {
            a += a;
            if (b >= a)
            {
                sum++;
            }
            else
            {
                break;
            }
        }
        Console.WriteLine(sum);
        //Console.ReadLine();
    }
}

Measured memory_bytes: 11092
#include<iostream>
using namespace std;
int main(){
  int d,m;
  int d1,d2;
  cin>>d>>m;
  int ans=0;
  for(int i=1;i<=d;i++){
    for(int j=1;j<=m;j++){
      d1=j/10;
      d2=j%10;
      if(d1>1&&d2>1){
        if(i==d1*d2)
          ans++;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const ll MOD=1000000007;
const ll LINF=1ll<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};




int main(){
    string s;cin >> s;
    if(s.back () == 's'){
        cout << s << "es" << endl;
    }
    else{
        cout << s << "s" << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long int
#define pi pair<int,int>
#define eps 0.000000001
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second 
#define endl '\n'
#define dbg(x) cout<<#x<<" "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const int mod = 1e9+7;
const double PI = acos(-1.0);
const int MAXN = 1e6+5;

void cp()
{
	string s,t;
	cin>>s>>t;
	bool ok = true;
	for(int i=0;i<ln(s);i++)
		if(s[i] != t[i])
			ok = false;
	cout<<(ok?"Yes":"No");
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    while(t--)
    {
        cp();
    }
    return 0;
}

Measured memory_bytes: 3580
import collections
table = collections.defaultdict(int)
A = list(input())
N = len(A)

for x in A:
    table[x] += 1
ans = (N*(N-1) // 2) + 1
for x in table:
    ans -= (table[x] * (table[x] - 1)) // 2

print(ans)


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

int main(){
  int a, b, c[3][3];
  bool ans=true;;
    for(int i=0; i<3; i++)
      for(int j=0; j<3; j++) cin >> c[i][j];
    for(int i=0; i<2; i++){
      a = c[0][i] - c[0][i+1];
      b = c[i][0] - c[i+1][0];
      for(int j=1; j<3; j++){
        int tmp1 = c[j][i] - c[j][i+1];
        int tmp2 = c[i][j] - c[i+1][j];
        if(a != tmp1 || b != tmp2){
          ans = false;
          break;
        }
      }
      if(!ans) break;
    }
    ans ? cout<<"Yes"<< endl : cout << "No" << endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, 1000000007)
	sc.Split(bufio.ScanWords)
	n, _ := strconv.Atoi(Scanner())
	k, _ := strconv.Atoi(Scanner())
	d := int(1e9) + 7
	ans := make([]int, k+1)
	for i := k; i > 0; i-- {
		ans[i] = repeatPow(k/i, n, d)
		for j := 2; j <= k/i; j++ {
			ans[i] -= ans[i*j]
			ans[i] %= d
		}
		if ans[i]%d < 0 {
			ans[i] += d
		}
	}
	fmt.Println(sum(ans) % d)
}
func repeatPow(x, y, d int) int {
	if y == 1 {
		return x
	} else {
		z := repeatPow(x, y/2, d)
		if y%2 == 0 {
			return z * z % d
		} else {
			return z * z % d * x % d
		}
	}
}
func sum(x []int) int {
	ret := 0
	for i, v := range x {
		ret += i * v
	}
	return ret
}


Measured memory_bytes: 2580
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;

struct UnionFind {
  // 要素に対応する値は自分の根。根は要素数の-1倍したものを代入する。
  // 根ならそのグループの要素数(負)が、子であれば親の番号が入る。初期値-1。
  vector<int> uni;
  UnionFind(){
    uni = vector<int>(300100, -1);
  }

  // 頂点aの所属するグループを調べる。
  int root(int a)
  {
    // uni[a]が負の値なら親はa自身
    if (uni[a] < 0) return a;
    // 正の値であれば、親ルートを調べ戻り値で根に直接つなぐ。
    else {
      uni[a] = root(uni[a]);
      return uni[a];
      // return uni[a] = root(uni[a]);
    }
  }

  // 頂点aとbをつなぐ、もともと同じグループの場合falseを返す。
  bool connect(int a, int b)
  {
    a = root(a);
    b = root(b);
    if (a == b) return false;

    // aを大きなグループにしたいので、逆であれば入れ替える。
    if (uni[a] > uni[b])
    {
      int hoge = a;
      a = b;
      b = hoge;
    }

    //aとbを結合し、bをaの親とする。
    uni[a] += uni[b];
    uni[b] = a;
    return true;
  }

  //  頂点a, bが同じグループか
  bool isConnect(int a, int b)
  {
    return root(a) == root(b);
  }

  // 頂点aを含むグループの頂点数を調べる
  int size(int a)
  {
    return -uni[root(a)];
  }

};

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n, k;
  cin >> n >> k;
  vector<int> v(n);
  rep(i, n){
    cin >> v[i];
    v[i]--;
  }
  UnionFind uni;

  int s = 0;
  int now = 0;
  int next = 0;
  vector<int> path(n, INT_MAX);
  path[0] = 0;
  rep(i, n+100){
    if(i == k){
      cout << next+1 << endl;
      return 0;
    }
    if(uni.isConnect(0, v[next]) && i != 0) {
      s = uni.size(0);
      k -= path[v[next]];
      s = s - path[v[next]];
      break;
    }
    now = next;
    next = v[next];
    path[next] = i+1;
    uni.connect(0, next);
  }

  if(s == 0){
    s = 1;
  }

  ll num = k % s;

  int res = v[next];
  rep(i, num){
    res = v[res];
  }
  cout << res + 1 << endl;
}


Measured memory_bytes: 6104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int a[] = new int[5];
		for(int i = 0; i < 5; i++){
			a[i] = sc.nextInt();
		}
		int k = sc.nextInt();

		for(int i = 0; i < 5; i++){
			for(int j = i + 1; j < 5; j++){
				if(a[j] - a[i] > k){
					System.out.println(":(");
					return;
				}
			}
		}

		System.out.println("Yay!");
	}

}


Measured memory_bytes: 23764
#include <iostream>
#include <string>
using namespace std;
int main() {
	string str;
	getline(cin ,str);
	int n = str.length();
	int a[n][2]; 
	/*
	0 -> 1
	1 -> 2
	*/

	for (int i=0 ;i< n;i++) {
		a[i][0] = 0;
		a[i][1] = 0;
	}
	for (int i =0 ;i < n;i++) {
		if (i == 0) {
			a[i][0] = 1;
			a[i][1] = 0;
		} else if (i==1){
			a[i][0] = 2 - 2 * (str.at(i) == str.at(i-1));
			a[i][1] = 1;
		} else if ( i == 2){
			if (str.substr(i, 1) == str.substr( i-1, 1)) {
				a[i][0] = a[i-1][1] +1;
			} else {
				a[i][0] = max(a[i-1][0], a[i-1][1]) + 1;
			}
			a[i][1] = 2;
		} else {
			if (str.substr(i-1, 2) == str.substr( i-3, 2)) {
				a[i][1] = a[i-2][0] +1;
			} else {
				a[i][1] = max(a[i-2][0], a[i-2][1]) + 1;
			}

			if (str.substr(i, 1) == str.substr( i-1, 1)) {
				a[i][0] = a[i-1][1] +1;
			} else {
				a[i][0] = max(a[i-1][0], a[i-1][1]) + 1;
			}

		}
	}
	cout << max(a[n-1][0] , a[n-1][1]) << endl;



}

Measured memory_bytes: 2180
N=gets.to_i
array=gets.chomp.split(" ").map(&:to_i).sort_by{|a| a.abs }

minus_count = 0
ret = 0
array.each do |a|
    minus_count+=1 if a < 0
    ret+=a.abs
end
ret-=(array[0].abs*2) if minus_count.odd?
puts ret


Measured memory_bytes: 24812
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>
#include <set>

using namespace std;

class cExhaustiveSearch
{
	int mn, mq;
	string mA, mm;
	vector<int> vA, vm;

	void decode();
	bool search(int, int);

public:
	cExhaustiveSearch(int n, int q, const string &a, const string &m)
		: mn(n), mq(q)
	{
		mA = a;
		mm = m;
		decode();
	}
	void output();
};

bool cExhaustiveSearch::search(int i, int m)
{
	if (m == 0) return true;
	if (i >= vA.size()) return false;
	if (search(i + 1, m)) return true;
	if (search(i + 1, m - vA[i])) return true;
	return false;
}

void cExhaustiveSearch::output()
{
	string ans;
	for (int i = 0; i < vm.size(); ++i)
	{
		search(0, vm[i]) ? ans = "yes" : ans = "no";
		cout << ans << endl;
	}
}

void cExhaustiveSearch::decode()
{
	istringstream iss;
	iss.str(mA);
	int ts;
	for (int i = 0; i < mn; ++i)
	{
		iss >> ts;
		vA.push_back(ts);
	}
	iss.str(mm);
	iss.seekg(0, iss.beg);
	for (int i = 0; i < mq; ++i)
	{
		iss >> ts;
		vm.push_back(ts);
	}
}

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

	int n, q;
	string A, m;

	cin >> n;
	cin.ignore();
	getline(cin, A);

	cin >> q;
	cin.ignore();
	getline(cin, m);

	cExhaustiveSearch ces(n, q, A, m);
	ces.output();

	return 0;
}

Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  long long a[n+1];
  a[0]=2;
  a[1]=1;
  for(int i=2;i<=n;i++){
    a[i]=a[i-1]+a[i-2];
  }
  cout<<a[n]<<endl;
  return(0);
}

Measured memory_bytes: 256
import sys
import numpy as np

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip() # ignore trailing spaces

N = ri()
S = np.array([list(rs()) for _ in range(N)])

S = np.concatenate([S, S], axis=0)
answer = 0
for b in range(N):
    S2 = S[b:b+N]
    if (S2 == S2.T).all():
        answer += N

print(answer)



Measured memory_bytes: 15856
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int h, w;
    using A = array<array<char, 12>, 12>;
    while(cin >> w >> h, w){
        A v;
        for (auto &&k : v) fill(k.begin(),k.end(), -1);
        for (int i = 1; i <= h; ++i) {
            for (int j = 1; j <= w; ++j) {
                char c;
                cin >> c;
                if(c == 'R') v[i][j] = 0;
                else if(c == 'G') v[i][j] = 1;
                else v[i][j] = 2;
            }
        }
        int ans = 18;
        array<int, 4> dx{-1, 1, 0, 0}, dy{0, 0, -1, 1};
        vector<pair<int, int>> hist;
        queue<pair<int, int>> Q;
        auto dfs = [&](int dep, A a, int prv, auto &&f) -> void {
            if(dep >= ans) return;
            for (int to = 0; to < 3; ++to) {
                if(a[1][1] == to) continue;
                A b = a;
                int cnt = 0;
                Q.emplace(1, 1);
                b[1][1] = to;
                while(!Q.empty()){
                    int y, x; tie(y, x) = Q.front(); Q.pop();
                    cnt++;
                    for (int k = 0; k < 4; ++k) {
                        if(b[y+dy[k]][x+dx[k]] == a[1][1]){
                            b[y+dy[k]][x+dx[k]] = to;
                            Q.emplace(y+dy[k], x+dx[k]);
                        }
                    }
                }
                if(cnt == h*w) ans = min(ans, dep);
                else if(prv < cnt) f(dep+1, b, cnt, f);
            }
        };
        dfs(0, v, 0, dfs);
        cout << ans << "\n";
    }


    return 0;
}




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

int main() {
  int N,K;cin>>N>>K;
  vector<int> h(N);
  for(int i=0;i<N;i++)cin>>h[i];
  vector<long> dp(N,99999999999999);
  dp[0]=0;
  for(int i=1;i<N;i++){
    for(int j=1;j<=K;j++){
      if(i-j<0)break;
      dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
    }
  }
  cout<<dp[N-1]<<endl;
}

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

using namespace std;

const int N = 1e6;

struct dartou{
	int to, nxt, w;
}e[N];

int k, cnt = 0;
int head[N], dis[N];
bool vis[N];

void add(int x, int y, int w){
	e[++cnt].to = y;
	e[cnt].w = w;
	e[cnt].nxt = head[x];
	head[x] = cnt;
}

void spfa(){
	memset(vis, 0, sizeof(vis));
	memset(dis, 0x3f, sizeof(dis));
	queue<int> q;
	q.push(1);
	vis[1] = 1;
	dis[1] = 0;
	while(!q.empty()){
		int u = q.front();
		q.pop();
		vis[u] = 0;
		for(int i = head[u]; i; i = e[i].nxt){
			int v = e[i].to, w = e[i].w;
			if(dis[u] + w < dis[v]){
				dis[v] = dis[u] + w;
				if(!vis[v]){
					vis[v] = 1;
					q.push(v);
				}
			}
		}
	}
}

int main(){
	cin >> k;
	for(int i = 0; i < k; i++)
		add(i, (i + 1) % k, 1);
	for(int i = 0; i < k; i++)
		add(i, (i * 10) % k, 0);
	spfa();
	cout << dis[0] + 1 << endl;
}

Measured memory_bytes: 10624
import sys
input = sys.stdin.readline

k = int(input())

if k%2 == 0:
    print(-1)
    exit()

if k == 7:
    print(1)
    exit()

if k == 1:
    print(1)
    exit()

if k % 5 == 0:
    print(-1)
    exit()

seven = 7
d = 1
while seven != 0:
    seven += pow(7*pow(10,d,k),1,k)
    seven = pow(seven,1,k)
    d += 1

print(d)




Measured memory_bytes: 63508
#include <iostream>
using namespace std;
int main(){
	int n,a[100];
	cin>>n;
	for(int i=0 ; i<n ; i++ )
		cin >> a[i];
	int counter=0;
	for( int i=0 ; i<n ; i++ ){
		int minj=i;
		for( int j=i ; j<n ; j++ ){
			if( a[j] < a[minj] ){
				minj=j;
			}
		}
		if( i!=minj ){
			counter++;
			swap(a[i],a[minj]);
		}
	}
	for( int i=0 ; i<n ; i++ ){
		cout << a[i] ;
		if( i!=n-1 )
			cout <<" ";
	}
	cout << endl;
	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 3112
N = int(input())
L = list(map(int, input().split()))

Sum = 0

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            if (L[i] != L[j] and L[j] != L[k] and L[k] != L[i]) and (
                    max(L[i], L[j], L[k]) * 2 - (L[i] + L[j] + L[k])) < 0:
                Sum += 1

print(Sum)


Measured memory_bytes: 68548
from itertools import combinations

while True:
    count = 0
    n,x = map(int,input().split())
    if n == 0 and x == 0:
        break
    
    li = []
    for i in range(n):
        li.append(i+1)
    
    c = combinations(li, 3)
    list_c = list(c)
    for k in list_c:
        if sum(k) == x:
            count += 1
    
    print(count)


Measured memory_bytes: 31424
let id x = x
let m = int_of_float 1e9 + 7
let ( +^ ) x y = (x + y) mod m
let ( *^ ) x y = ((x mod m) * (y mod m)) mod m

let n = read_int ()
let a = Array.init n (fun _ -> Scanf.scanf " %d" id)

let rec loop sum i t arr =
  if i = 60 then
    print_int sum
  else
    let one = Array.fold_left (fun s n -> s + (n mod 2)) 0 arr in
    loop 
      (sum +^ (one *^ (n - one) *^ t))
      (i + 1)
      (t * 2 mod m)
      (Array.map (fun n -> n / 2) arr)

let () = loop 0 0 1 a

Measured memory_bytes: 36080
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define PI (acos(-1))
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/



constexpr ll Q_MAX = 2;
constexpr ll T_I_MAX = 1000000000;
constexpr ll X_I_MAX = 1000000000;
constexpr ll D_Q_MAX = 1000000000;

class Event{
public:
	ll d;//イベント発生までの時間
	ll x;//停止する座標
	ll type;//0insert,1delete,,2query
	Event(ll d,ll x,ll type):d(d),x(x),type(type){}
	bool operator < (const Event &another) const {
		if(d==another.d){
			return type<another.type;
		}
		return d<another.d;
	}
};

ll N, Q;

vector<Event> a;
void input() {
	scanf("%lld%lld", &N, &Q);
	rep(i, N) {
		ll s,t,x;
		scanf("%lld%lld%lld", &s, &t, &x);
		a.push_back(Event(s-x,x,0));
		a.push_back(Event(t-x,x,1));
	}
	rep(i, Q) {
		ll d;
		scanf("%lld", &d);
		a.push_back(Event(d,d,2));
	}
}

void solve() {
	sort(all(a));
	multiset<ll> s;
	vector<ll> ans;
	rep(i,a.size()){
		if(a[i].type==0){
			s.insert(a[i].x);
		}else if(a[i].type==1){
			s.erase(s.lower_bound(a[i].x));
			//s.erase(a[i].x);
		}else if(a[i].type==2){
			if(s.size()) ans.push_back(*(s.begin()));
			else ans.push_back(-1);
		}
	}

	rep(i,Q)p(ans[i]);
}

signed main() {
	input();
	solve();
	return 0;
}


Measured memory_bytes: 29540
#include"bits/stdc++.h"
using namespace std;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20)
#define ll long long
#define endl '\n'
//       Author
//        ::
//    (  NOBODY  )
//   No Copyright .....You can copy and paste it without my permission...................................
// !!!!!!!!!!!!!!!
#define pb push_back
#define N 300009
int a[N],b[N];
int dp[100009];
int main()
{
    FAST_IO;
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=2;i<=n;i++)
    {
      dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
     for(int j=1;j<=min(k,i-1);j++)
     {
        dp[i]=min(dp[i],dp[i-j]+abs(a[i-j]-a[i]));
     }
    }
    cout<<dp[n];
    return 0;
}


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

int main() {
    int n,k;
    cin >> n >> k;
    vector<ll> ls;
    ls.push_back(0);
    for(int i=0; i<n; i++){
        ll a;
        cin >> a;
        ll last;
        last = ls.at(ls.size()-1);
        ls.push_back(last + a);
    }
    ll max = 0;
    for(int i=k; i<=n; i++){
        if(ls.at(i) - ls.at(i-k) > max){
            max = ls.at(i) - ls.at(i-k);
        }
    }
    cout << fixed << setprecision(10);
    cout << (max+k)/2.0 << endl;
}

Measured memory_bytes: 2420
n, p = map(int, input().split())
A = list(map(int, input().split()))

odd = False
for a in A:
    if a % 2 == 1:
        odd = True
        break

if odd:
    print(2**(n-1))
elif p == 0:
    print(2**n)
else:
    print(0)


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main(){
	char s[100001];
	cin>>s;
	int n[100001];
	int k=0,x=0,sum=0;
	for(int i=0;s[i+1]!='\0';i++){
		if(s[i]==s[i+1]){
			k++;
		}
		else{
			n[x]=k+1;
			k=0;
			x++;
		}
		
	}
	n[x]=k+1;
	for(int i=0;i<=x;i+=2){
		for(int j=1;j<n[i];j++){
			cout<<"0 ";
		}
		if((n[i+1]-n[i])%2==0){
			cout<<(n[i+1]+n[i])/2<<" "<<(n[i+1]+n[i])/2<<" ";
		}
		else if((n[i+1]>n[i]&&(n[i+1]-1)%2==1)||(n[i+1]<n[i]&&(n[i]-1)%2==0)){
			cout<<(n[i+1]+n[i])/2+1<<" "<<(n[i+1]+n[i])/2<<" ";
		}
		else{
			cout<<(n[i+1]+n[i])/2<<" "<<(n[i+1]+n[i])/2+1<<" ";	
		}
		for(int j=1;j<n[i+1];j++){
			cout<<"0 ";
		}
	}
	
	
} 

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

using ll = long long;

const int INF = 1e9 + 5;

int main() {
    int n;
    scanf("%d", &n);
    vector<int> h(n);
    for(int& x : h) {
        scanf("%d", &x);
    }
    vector<int> dp(n, INF);
    dp[0] = 0;
    for(int i = 0; i < n; ++i) {
        for(int j : {i + 1, i + 2}) {
            if(j < n) {
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }
    printf("%d\n", dp[n-1]);
}

Measured memory_bytes: 1024
#include <stdio.h>
int main()
{
    int D;
    scanf("%d",&D);
    if(D==25)
        printf("Christmas\n");
    else if(D==24)
        printf("Christmas Eve\n");
    else if(D==23)
        printf("Christmas Eve Eve\n");
    else if(D==22)
        printf("Christmas Eve Eve Eve\n");
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(void) {
  int a, b;
  cin >> a >> b;
  if (b - a == 0 || (a <= 0 && 0 <= b)) cout << "Zero" << endl;
  else if (a > 0) cout << "Positive" << endl;
  else if ((b - a) % 2 == 0) cout << "Negative" << endl;
  else cout << "Positive" << endl;
}


Measured memory_bytes: 256
var
	i,n,ans:longint;
	a:array[0..110] of longint;
procedure work(l,r:longint);
var
	i,min,t:longint;
begin
	if l>r then exit;
	min:=1000;
	for i:=l to r do 
		if a[i]<min then
		begin
			min:=a[i];
			t:=i;
		end;
	for i:=l to r do a[i]:=a[i]-min;
	ans:=ans+min;
	work(l,t-1);
	work(t+1,r);
end;
begin
	read(n);
	for i:=1 to n do read(a[i]);
	ans:=0;
	work(1,n);
	writeln(ans);
end.

Measured memory_bytes: 128
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

long long gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

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

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

    std::vector<int> l(n, 0), r(n + 1, 0);

    for (int i = 1; i < n; i++) {
        l[i] = gcd(l[i - 1], a[i - 1]);
    }

    for (int i = n - 1; i >= 0; i--) {
        r[i] = gcd(r[i + 1], a[i]);
    }

    long long ans = 0;
    for (int i = 0; i < n; i++) {
        ans = std::max(ans, gcd(l[i], r[i + 1]));
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 1408
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

// input に使うやつ
var rdr = bufio.NewReaderSize(os.Stdin, 10000)

func readLine() string {
	buf := make([]byte, 0, 10000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

// string から int へ
func atoi(s string) int {
	i, _ := strconv.Atoi(s)
	return i
}

// 一つの文字を int として読み込み
func readInt() int {
	return atoi(readLine())
}

// 複数の文字を int のスライスとして読み込み
func readInts() []int {
	in := readLine()
	ins := strings.Split(in, " ")
	out := make([]int, len(ins))
	for i, v := range ins {
		out[i] = atoi(v)
	}
	return out
}

// sortしたスライスを返す
func sorted(a []int) []int {
	b := make([]int, len(a))
	copy(b, a)
	sort.Ints(b)
	return b
}

// 逆順のsort
func reverse(a []int) []int {
	b := make([]int, len(a))
	copy(b, a)
	sort.Sort(sort.Reverse(sort.IntSlice(b)))
	return b
}

func main() {
	s := strings.Split(readLine(), "")
	n := len(s)
	ans := make([]int, len(s))
	// for i := 0; i < len(ans); i++ {
	// 	ans[i] = 1
	// }
	for i := 0; i < 2; i++ {
		var c int
		for j := 0; j < n; j++ {
			if s[j] == "R" {
				c++
			} else {
				ans[j] += c / 2
				ans[j-1] += (c + 1) / 2
				c = 0
			}
		}

		ansc := make([]int, n)
		sc := make([]string, n)
		copy(ansc, ans)
		copy(sc, s)
		for j := 0; j < n; j++ {
			ans[j] = ansc[n-1-j]
		}
		for j := 0; j < n; j++ {
			s[j] = sc[n-1-j]
		}
		for j := 0; j < n; j++ {
			if s[j] == "L" {
				s[j] = "R"
			} else {
				s[j] = "L"
			}
		}
	}

	for i := 0; i < len(ans)-1; i++ {
		fmt.Print(fmt.Sprint(ans[i]) + " ")
	}
	fmt.Println(ans[len(ans)-1])
}


Measured memory_bytes: 11656
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
#include <functional>
#include <cctype>

using namespace std;

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

int main()
{
	int c, r;

	int sum1, sum2;
	int sum3 = 0;
	cin >> r >> c;

	int A[r][c];

	REP(i, r)
		REP(j, c)
			cin >> A[i][j];

	REP(i, r) {
		sum1 = 0;
		REP(j, c) {
			cout << A[i][j];
			sum1 += A[i][j];
			(j != c - 1)?
				cout << ' ' : cout << ' ' << sum1;
		}
		sum3 += sum1;
		cout << endl;
	}
	REP(i, c) {
		sum2 = 0;
		REP(j, r) {
			sum2 += A[j][i];
		}
		cout << sum2;
		(i != c - 1)?
			cout << ' ' : cout << ' ' << sum3 << endl;
	}

	return 0;
}

Measured memory_bytes: 1196
n = gets.to_i
h = {}
n.times do
  s = gets
  h[s.chomp]=1
end

for m in ["S", "H", "C", "D"] do
  for i in 1..13 do
    puts "#{m} #{i}" if !h.has_key?(m+" "+i.to_s)
  end
end


Measured memory_bytes: 6872
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int tLife = sc.nextInt();
        int tAttackk = sc.nextInt();
        int aLife = sc.nextInt();
        int aAttack = sc.nextInt();
        boolean flg = false;

        while (true) {
        	flg = false;
        	aLife -= tAttackk;
			if(aLife <= 0) {
				flg = true;
				break;
			}

			tLife -= aAttack;
			if(tLife <= 0) {
				break;
			}

		}
        if(!flg) {
        	System.out.println("No");
        }else {
			System.out.println("Yes");
		}
		}
}



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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 1000003;

struct FiniteField {
 private:
  int64 x;
  static inline int64 Normalize(int64 x) {
    if (0 <= x && x < P) return x; x %= P; if (x < 0) x += P; return x;
  }
 public:
  FiniteField(int64 x) : x(Normalize(x)) {}
  FiniteField() : x(0) {}
  int64 Value() const { return x; }
  inline FiniteField operator+(FiniteField o) const {
    FiniteField r(*this); r += o; return r;
  }
  inline FiniteField operator-(FiniteField o) const {
    FiniteField r(*this); r -= o; return r;
  }
  inline FiniteField operator* (FiniteField o) const {
    FiniteField r(*this); r *= o; return r;
  }
  inline FiniteField operator/ (FiniteField o) const {
    FiniteField r(*this); r /= o; return r;
  }
  inline void operator+= (FiniteField o) { x = (x + o.x) % P; }
  inline void operator-= (FiniteField o) { x = (x + P - o.x) % P; }
  inline void operator*= (FiniteField o) { x = (x * o.x) % P; }
  void operator/=(FiniteField o) {
    int64 p = P - 2; while (p) { if (p % 2) { *this *= o; } o *= o; p /= 2; }
  }
};

ostream& operator<<(ostream& s, const FiniteField& v) { s << v.Value(); return s; }

vector<FiniteField> MakeFactorialTable(int n) {
  vector<FiniteField> factorials(n + 1);
  factorials[0] = 1;
  for (int i = 1; i <= n; i++) {
    factorials[i] = factorials[i - 1] * i;
  }
  return factorials;
}

FiniteField Power(FiniteField x, int p) {
  if (p < 0) return FiniteField(1) / Power(x, -p);
  FiniteField value = 1;
  while (p) {
    if (p % 2) value *= x;
    x *= x;
    p /= 2;
  }
  return value;
}

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

  auto factorials = MakeFactorialTable(P - 1);

  int q_count;
  cin >> q_count;
  for (int q_id = 0; q_id < q_count; q_id++) {
    int x, d, n;
    cin >> x >> d >> n;
    if (d == 0) {
      cout << Power(FiniteField(x), n) << endl;
      continue;
    }
    if (x == 0) {
      cout << 0 << endl;
      continue;
    }

    FiniteField k = FiniteField(x) / d;
    // cout << "k: " << k << endl;
    if (k.Value() + n - 1 >= P) {
      cout << 0 << endl;
      continue;
    }

    cout << (factorials[k.Value() + n - 1] / factorials[k.Value() - 1] * Power(d, n)) << endl;
  }
}

Measured memory_bytes: 8704
{-# LANGUAGE BangPatterns #-}

import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.Bits
import qualified Data.Vector.Unboxed as VU
import Data.List
import Debug.Trace

bsReadInts :: B.ByteString -> [Int]
bsReadInts = map (fst . fromJust . B.readInt) . B.words

cum_max :: [Int] -> [Int]
cum_max = tail . scanl' max 0

nextZeta :: Int -> VU.Vector (Int,Int) -> Int -> VU.Vector (Int,Int)
nextZeta en v i = VU.fromList $ map op [0..en-1]
  where
    op x | testBit x i = f (v VU.! (clearBit x i)) (v VU.! x)
         | otherwise   = v VU.! x
      where
        f (q1,q2) (p1,p2) =
                    if p1 >= q1 then
                      if p2 >= q1 then (p1,p2)
                      else (p1,q1)
                    else
                      if q2 >= p1 then (q1,q2)
                      else (q1,p1)

zeta :: Int -> [Int] -> VU.Vector (Int, Int)
zeta n as = foldl' (nextZeta en) initvec [0..n-1] 
  where
    en = 2^n
    initvec = VU.fromList [(a,0) | a <- as]

solve :: Int -> [Int] -> [Int]
solve n as = cum_max $ tail $ map (\(p,q)->p+q) $ VU.toList $ zeta n as

main :: IO ()
main = do
  conts <- B.getContents
  let n : as = bsReadInts conts
      answer = solve n as
  putStr (unlines (map show answer))


Measured memory_bytes: 63612
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <complex>
#include <iomanip>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
  string a, b, c;
  cin >> a >> b >> c;
  cout << a[0] << b[1] << c[2] << endl;
}

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

int main(void) {
    using namespace std;

    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    for (int &ai : A) cin >> ai;
    vector<pair<int, int>> CB(M);
    for (int i = 0; i < M; ++i) {
        int B, C;
        cin >> B >> C;
        CB.at(i) = make_pair(C, B);
    }

    sort(A.begin(), A.end());
    sort(CB.rbegin(), CB.rend());  // コストの降順
    auto b        = A.begin();
    long long ans = 0LL;
    for (int i = 0; i < M; ++i) {
        //以上の最初
        auto itl = lower_bound(b, A.end(), CB.at(i).first);
        if (itl == A.begin()) break;

        int it = itl - b;
        int df = min(CB.at(i).second, it);
        ans += (long long)df * (long long)CB.at(i).first;
        b = b + df;
    }
    ans += accumulate(b, A.end(), 0LL);

    cout << ans << endl;

    return 0;
}

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

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

#define pb push_back

const int INF = 100100100;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;

int main(){

  int n;
  int tmp;
  cin >> n;
  tmp = n/10;
  if( n%10 == 9 || tmp == 9){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;

}


Measured memory_bytes: 256