akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>

int main(void) {
  char s[1000];
  char t[1000];
  char kari;

  if(scanf("%s %s", s, t) == 1);

  for(int i = 0; i < strlen(s); i++) {
    if(strcmp(s, t) == 0) {
      break;
    } else if(i == strlen(s) - 1) {
      printf("No");
      return 0;
    }
    kari = s[0];
    for(int i = 0; i < strlen(s) - 1; i++) {
      s[i] = s[i+1];
    }
    s[strlen(s) - 1] = kari;
  }

  printf("Yes");

  return 0;
}


Measured memory_bytes: 128
def solve():
    N, Y = map(int, input().split())
    for i in range(0,2000+1):
        for j in range(0, 2000+1-i):
            k = (Y - i * 10000 - j * 5000) // 1000
            if k >= 0 and i + j + k == N:
                print(i,j,k)
                return
    
    print(-1,-1,-1)
    

if __name__ == '__main__':
    solve()

Measured memory_bytes: 38896
#include<iostream>
#include<vector>
#include<algorithm>
#include<complex>
using namespace std;
typedef long long int llint;

int three(llint &n, vector<llint>&cnt);
int change(llint n);


int three(llint &n, vector<llint>&cnt) {
	llint n_;
	llint tmp;
	for (int i = 0;i < 10;i++) {
		n_ = n;
		n_ /= pow(10, i);
		tmp = change(n_ % 10);
		if (tmp == 3) {
			n -= 4 * pow(10, i);
			cnt[2]--;
			cnt[0]++;
		}
		else if (tmp == 1) {
			n += 3 * pow(10, i);
			cnt[0]++;
			break;
		}
		else if (tmp == 5) {
			n += 2 * pow(10, i);
			cnt[0]--;
			cnt[1]++;
			break;
		}
		else if (tmp == 7) {
			n += 2 * pow(10, i);
			cnt[1]--;
			cnt[2]++;
			break;
		}
	}
	return 0;
}

int change(llint n) {
	if (n == 3) {
		return 5;
	}
	if (n == 5) {
		return 7;
	}
	if (n == 7) {
		return 3;
	}
	if (n == 0) {
		return 1;
	}
}

int main() {
	llint n;
	cin >> n;
	vector<llint>cnt(3, 1);
	llint tmp;
	llint n_ = n;
	n = n_;
	n_ = 357;
	if (n < 357) {
		cout << 0 << endl;
		return 0;
	}
	llint ans = 1;
	while (n_ <= n) {
		three(n_, cnt);
		if (n_ > n) {
			break;
		}
		if (cnt[0] != 0 && cnt[1] != 0 && cnt[2] != 0) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


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

#define rep(s,n) for(int i=s;i<n;i++)

int main(){
	int n, r;
	cin >> n >> r;
	if (n < 10)cout << r + (100 * (10 - n)) << "\n";
	else cout << r << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
main(){int N[32769]={0},M=32769,i=1,j,k,l,I,J,K;for(;(I=i*i)<M;i++)for(N[I]++,j=i;(J=I+j*j)<M;j++)for(N[J]++,k=j;(K=J+k*k)<M;k++)for(N[K]++,l=k;K+l*l<M;)N[K+l*l++]++;for(;std::cin>>l,l;)printf("%d\n",N[l]);}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    rep(i, n-2){
        if(s.substr(i, 3) == "ABC") {
            ans++;
        }
    }

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

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

int main()
{
  string s;
  cin >> s;
  int len = s.length();
  int ans = 0;

  for (int i = 0; i < len; i++) {
    if (s[i] != s[len - i - 1]) ans++;
  }
  ans /= 2;
  cout << ans << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  for(int i = K-N+1; i<=N+K-1; i++){
    if(i<-1000000){
      continue;
    }
    if(i>100000){
      break;
    }
    cout << i << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
int X, Y;
int b[510];
int r[510];
vector<int>G[510];
int match[510];
int visited[510];
bool dfs(int v, int cnt) {
	if (visited[v] == cnt) {
		return false;
	}
	visited[v] = cnt;
	for (int x : G[v]) {
		if (match[x] == -1) {
			match[x] = v;
			return true;
		}
		else {
			if (dfs(match[x], cnt)) {
				match[x] = v;
				return true;
			}
		}
	}
	return false;
}
int main() {
	while (cin >> X >> Y,X||Y) {
		REP(i, 510)G[i].clear();
		REP(i, 510)visited[i] = 0;
		REP(i, X)cin >> b[i];
		REP(i, Y)cin >> r[i];
		REP(i, X) {
			REP(j, Y) {
				if (gcd(b[i], r[j]) > 1) {
					G[i].push_back(j);
				}
			}
		}
		REP(i, 510)match[i] = -1;
		int num = 0;
		REP(i, X) {
			if (dfs(i, i + 1))num++;
		}
		cout << num << endl;
	}
	return 0;
}



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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int64 N, M, K;
	vector<int64> a;
	string s;
	cin >> N >> M;
	if (M % N == 0) {
		cout << M + N << endl;
	} else {
		cout << M - N << endl;
	}
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
public class Hello{
    public static void Main()
    {
        //入力を保持する
        var input = Console.ReadLine().Split().Select(v => int.Parse(v)).ToArray();
        var ans =0;
        for (var n = 1;n<6;n++)
        {
            if(input[n-1]==0)
            {
                ans =n;
                break;
            }
        }
        Console.WriteLine(ans);

    }
}


Measured memory_bytes: 28092
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 ln         PIC X(500).
01 maxlen     PIC 9(10) VALUE 100 COMP.
01 cur        PIC 9(10) VALUE 1 COMP.
01 i          PIC 9(10) VALUE 1 COMP.
01 j          PIC 9(10) COMP.
01 len        PIC 9(10) COMP.
01 ans        PIC 9(10)V9(14) VALUE ZERO.
01 zs         PIC Z(9)9.9(14).
01 N          PIC 9(10).
01 A1.
   03 A11 OCCURS 100 DEPENDING ON N.
      05 A    PIC S9(10).

PROCEDURE DIVISION.
  ACCEPT N.
  ACCEPT ln.
  MOVE N TO maxlen.
  PERFORM maxlen TIMES
    PERFORM VARYING j FROM cur BY 1 UNTIL ln(j:1) = SPACE
    END-PERFORM
    COMPUTE len = j - cur
    MOVE ln(cur:len) TO A(i)
    COMPUTE ans = ans + 1 / A(i)
    COMPUTE cur = j + 1
    ADD 1 TO i
  END-PERFORM.
  COMPUTE ans = 1 / ans.
  MOVE ans TO zs.
  DISPLAY FUNCTION TRIM(zs).
  STOP RUN.


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	int N;
	cin>>N;
	vint H(N);rep(i,N)cin>>H[i];

	int ans=0;
	int cnt=0;
	for(int i=N-1;i>=0;i--){
		if(i+1<N&&H[i]>=H[i+1])cnt++;
		else cnt=1;
		chmax(ans,cnt);
	}
	cout<<ans-1<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
template<typename T>void read(T &x){
	x=0;int f(1);char c(getchar());
	for(;!isdigit(c);c=getchar())if(c=='-')f=-f;
	for(; isdigit(c);c=getchar())x=(x<<3)+(x<<1)+(c-'0');
	x*=f;
}
template<typename T>void write(T x){
	if(x<0)putchar('-'),x=-x;
	if(x/10)write(x/10),x%=10;
	putchar(x+'0');
}
const int maxn=200005;
int val[maxn],rv[maxn],sm[maxn],a[maxn];
int main(){
	int n;read(n);
	for(int i=1;i<=n;++i){
		read(a[i]);val[i]=rv[i-1]=a[i]+i;
	}
	sort(rv,rv+n);int cn=unique(rv,rv+n)-rv;
	for(int i=1;i<=n;++i)
		val[i]=lower_bound(rv,rv+cn,val[i])-rv;
	long long ans=0;
	for(int i=1;i<=n;++i){
		int pos=lower_bound(rv,rv+cn,i-a[i])-rv;
		if(rv[pos]==i-a[i])ans+=sm[pos];
		++sm[val[i]];
	}
	write(ans);
	return 0;
}


Measured memory_bytes: 6696
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <vector>
#include <cstring>
using namespace std;
#define ll long long
vector<int> v[100005];
int p[100005];
int arr[100005], n;
int memo[100005]; //stores min length

int dp(int x){
	if (memo[x] != -1) return memo[x];
	vector<int> temp;
	for (vector<int>::iterator it = v[x].begin(); it != v[x].end(); it++){
		if (*it == p[x]) continue;
		temp.push_back(dp(*it));
	}
	sort(temp.begin(), temp.end());
	reverse(temp.begin(), temp.end());
	int answer = 0;
	int counter = 1;
	for (vector<int>::iterator it = temp.begin(); it != temp.end(); it++){
		answer = max(answer, *it + counter);
		counter++;
	}
	temp.clear();
	return memo[x] = answer;
}


int main(){
	memset(memo, -1, sizeof(memo));
	scanf("%d", &n);
	p[0] = -1;
	for (int i = 0; i < n - 1; i++){
		scanf("%d", &arr[i]);
		v[arr[i] - 1].push_back(i + 1);
		v[i + 1].push_back(arr[i] - 1);
		p[i + 1] = arr[i] - 1;
	}

	printf("%d\n", dp(0));

	
}

Measured memory_bytes: 16256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(long long int i=a; i<n; i++)
#define rloop(i,a,n) for(long long int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcount(a)
#define mod 1000000007
#define ll long long int
#define ull unsigned long long int 
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define stkll stack<ll>
#define qll queue<ll>
#define pqll priority_queue<ll>
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power)
{
    ll ans=1;
    while(power>0)
    {
        if(power%2==1)
        {
            ans=(ans*B)%mod;
        }
        B=(B*B)%mod;
        power/=2;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1)
    { 
        return false; 
    }
    if(n<=3)
    { 
        return true;
    } 
    if(n%2==0 || n%3==0) 
    {
        return false; 
    }
    for(ll i=5; i*i<=n; i+=6) 
    {
        if(n%i==0 || n%(i+2)==0) 
        {
            return false; 
        }
    }
    return true; 
}
using namespace std;
int main()
{
    FAST
    FO
    FI
    int n;
    IN n;
    string s;
    IN s;
    n%=26;
    loop(i,0,s.length())
    {
        int temp= s[i];
        temp+=n;
        if(temp>90)
        {
            temp-=26;
        }
        OUT char(temp);
    }
    return 0;
}

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

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

  vector<int> a(N);
  rep(i, N) { cin >> a.at(i); }
  sort(a.begin(), a.end(), greater<int>());

  int alice = 0, bob = 0;
  rep(i, N) {
    if (i % 2 == 0) {
      alice += a.at(i);
    } else {
      bob += a.at(i);
    }
  }

  cout << alice - bob << endl;
}


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

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	string s, t;
	cin >> s >> t;
	if (s == t.substr(0, s.size()))
		cout << "Yes\n";
	else
		cout << "No\n";

}


Measured memory_bytes: 3604
#include <string.h>
i,m,h,t,a;
main(){
    char s[201];
    for(;scanf("%s%d",s,&m),s[0]!='-';puts("")){
        a=strlen(s);
        for(i=t=0;i<m;scanf("%d",&h),t+=h,i++);
        for(i=0;i<a;printf("%c",s[(t+i++)%a]));
    }
}

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

int a[1010];
int INF = 0x3f3f3f3f;

int main()
{
	int cnt,ans, n;
	cin >> n;
	int min = INF, max = -INF;
	for (int i = 1; i <= n; i++)
	{
		cin >> a[i];
		cnt += a[i];
		if (a[i]<min) min = a[i];
		if (a[i]>max) max = a[i];
	}
	int t = cnt / n;
	for (int k = min; k <= max; k++)
	{
		ans = 0;
		for (int i = 1; i <= n; i++)
		{
			ans +=(a[i] - k)*(a[i] - k);
		}
		if (ans < INF){ INF = ans; }
	}
	cout << INF;
	return 0;
}



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

int main(){
    int n; cin>>n;
    vector<int> nums(101,0);
    for (int i=1; i<=n; i++){
        cin >> nums[i];
    }
    int del = 0;
    stack<int> process;
    for(int i=0; i<n; i++){
        int idx = -1;
        for(int j=1; j<=n-i; j++){
            if(nums[j]==j) idx=j;
        }
        if(idx==-1){
            cout << -1 << endl;
            return 0;
        }
        process.push(idx);
        for(int j=idx; j<=n-i; j++) nums[j]=nums[j+1];
    }
    for (int i=0; i<n; i++){
        cout << process.top() << endl;
        process.pop();
    }
}

Measured memory_bytes: 3636
/* 
 * シカのAtCoDeerくんは二次元平面上で旅行をしようとしています。 AtCoDeerくんの旅行プランでは、時刻 0 に 点 (0,0) を出発し、 1 以上 N 以下の各 i に対し、時刻 ti に 点 (xi,yi) を訪れる予定です。
 * 
 * AtCoDeerくんが時刻 t に 点 (x,y) にいる時、 時刻 t+1 には 点 (x+1,y), (x−1,y), (x,y+1), (x,y−1) のうちいずれかに存在することができます。 その場にとどまることは出来ないことに注意してください。
 * AtCoDeerくんの旅行プランが実行可能かどうか判定してください。
 */

import java.util.*;
	public class Main{
        public static void main(String[] args){
            Scanner sc = new Scanner(System.in);
            //入力
            int n = Integer.parseInt(sc.next());
            
            int t = 0;
            int ti = 0;
            int x = 0;
            int xi = 0;
            int y = 0;
            int yi = 0;
            // 連続する二点間の距離d
            int d = 0;
            
            // 各連続する二点間について考える
            for(int i=0; i<n; i++){
            	ti = Integer.parseInt(sc.next());
            	xi = Integer.parseInt(sc.next());
            	yi = Integer.parseInt(sc.next());
            	
            	d = (int)(Math.abs(xi-x) + Math.abs(yi-y));
            	
            	// dが時間より長い、またdと時間の差が奇数(ちょうど目的地に着けない)ならばNoを出力してreturn
            	if(ti-t < d || Math.abs(d-ti+t)%2 == 1){
            		System.out.println("No");
                    sc.close();
                    return;
            	}
            	t = ti;
            	x = xi;
            	y = yi;
            }
            
            // どの二点間も旅行可能ならばYesを出力
            System.out.println("Yes");
            sc.close();
        }
    }
	

Measured memory_bytes: 61116
#-----------入力-------------------------
n,m = gets.split.map(&:to_i)

sc = Array.new(m).map{Array.new(2,0)}
m.times { |i| 
    a,b = gets.split.map(&:to_i)
    sc[i][0] = a
    sc[i][1] = b
}
=begin
    条件 
        0～999まで
        N桁     0~9,10~99,100~999
        si桁目がciである最小の数
    否定条件
        1桁目が0
        N桁目(si)が同じでciが異なる
=end

#1 まずN桁の0を用意
num = Array.new
n.times{ |i| num.push(0) }
#2 各要素を入れていく(1桁目が0ならアウト、既に0ではない異なる数値が入っていればアウト)
flag =true
sc.each{ |i,v|
    if i == 1 && v == 0 && n > 1 then flag = false; break end   #1桁目が0ならアウト
    if num[i-1] != 0 && num[i-1] != v then flag = false; break end #0ではない異なる数値が入っていればアウト)
    num[i-1] = v
}


if flag == true then
    if num[0] == 0 && n > 1 then num[0] = 1 end
    num.each{|v| print(v) }
    puts("")
else
    puts("-1")
end


Measured memory_bytes: 1788
// F.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <numeric>


using lolo=long long;
using namespace std;
using vec=vector<lolo>;
using pari=pair<lolo, lolo>;
using vvec=vector<vec>;
using vecb=vector<bool>;
#define FOR(i,n) for (lolo i=0; i<n; ++i)
#define FORIT(it,v) for (auto it=v.begin(); it!=v.end(); ++it)
#define FORANGE(it, v) for (auto it : v)
#define FORN(i,a,b) for (lolo i=a; i<b; ++i)
#define REV(i,a,b) for (lolo i=a; i>b; --i)
#define ALL(x) x.begin(), x.end()


template <class T>
void chmax(T& ans, const T& b)
{
	if (ans < b) {
		ans = b;
	}
}

int main()
{
	lolo N;
	cin >> N;
	vec S(N);
	FOR(i, N) cin >> S[i];
	// N-1の約数の個数?

	lolo ans = 0;

	FORN(C,1, N) {
		set<lolo> usedIndexSet;
		lolo nowScore = 0;
		lolo score = 0;
		lolo nowA = N - 1;
		const auto k_MAX = N ;
		FORN(k, 1, k_MAX+1) { 
			auto A2 = nowA - C;
			auto B = A2 - C;
			
			if (/*N - 1 >= A2 and*/ /*A2 > B and*/ B > 0); else break;
			if (B > 0); else break;
			if (A2 != k * C); else continue;			

			if (!((usedIndexSet.count(k * C) == 0) and (usedIndexSet.count(A2 ) == 0))) {
				break;
			}

			usedIndexSet.insert(k * C);//kCとA2が追加される。
			usedIndexSet.insert(A2);
			score += S[k * C];
			score += S[A2];
			chmax(ans, score);

			nowA =A2;

		}
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 7808
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <list>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

using ll = long long;
constexpr int maxn = 3000;
constexpr ll inf = (ll) 1000000000000000;
ll dp[maxn + 1][maxn + 1][2];

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

  vector<int> v(n);
  for (int& e : v) cin >> e;

  for (int i = 0; i <= n; i++) dp[i][i][0] = dp[i][i][1] = 0;

  for (int i = 1; i <= n; i++) {
    for (int j = 0; j + i <= n; j++) {
      int b = j, e = j + i;
      for (int k = 0; k < 2; k++) {
        ll& ans = dp[b][e][k];
        ans = (k == 0) ? -inf : inf;

        if (k == 0) {
          ans = max(ans, v[b] + dp[b + 1][e][!k]);
          ans = max(ans, v[e - 1] + dp[b][e - 1][!k]);
        } else {
          ans = min(ans, dp[b + 1][e][!k] - v[b]);
          ans = min(ans, dp[b][e - 1][!k] - v[e - 1]);
        }
      }
    }
  }
  cout << dp[0][n][0] << endl;
  return 0;
}


Measured memory_bytes: 139648
// https://atcoder.jp/contests/abc140/tasks/abc140_f

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(i, n) printf("%d%c", a[i], i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%d%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 18;
const int S_I_MAX = 1e9;
const int K_MAX = 1 << N_MAX;

int N, K;
int S[K_MAX];
multiset<int> T;
vector<int> V;

void pick(multiset<int>::iterator it) {
  V.push_back(*it);
  T.erase(it);
}

void solve() {
  REP(i, K) T.insert(S[i]);
  pick(--T.end());
  // DUMP(V, V.size());
  REP(i, N) {
    int m = V.size();
    REP(j, m) {
      auto it = T.lower_bound(V[j]);
      // printf("i = %d, j = %d, *it = %d\n", i, j, *it);
      if (it == T.begin()) {
        puts("No");
        return;
      }
      pick(--it);
    }
    // DUMP(V, V.size());
    sort(V.begin(), V.end(), greater<int>());
  }
  puts("Yes");
}

void input() {
  scanf("%d", &N);
  K = 1 << N;
  REP(i, K) scanf("%d", S + i);
}

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


Measured memory_bytes: 14716
def solve(n, m, arr)
  arr.reduce(&:+) - arr.sort.reverse.each_slice(m).to_a.map {|x|
    x.size == m ? x.last : 0
  }.reduce(&:+)
end
def reader
  $stdin.gets.split(" ").map(&:to_i)
end
loop do
  n, m = reader
  break if n == 0 and m == 0
  puts solve(n, m, reader)
end

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


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

struct edge {int to; ll cost; };

int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int k, x;
  cin >> k >> x;
  for(int i=x-k+1; i<x+k; i++){
    if(i==x+k-1) cout << i << endl;
    else cout << i << " ";
  }
  return 0;
}


Measured memory_bytes: 3580
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val m = sc.nextInt()
    val s = (0 until m).map { 
        (0 until sc.nextInt()).map { sc.nextInt() - 1 }
    }
    val p = (0 until m).map { 
        sc.nextInt()
    }

    abc128c(n, m, s, p)
}

fun abc128c(n: Int, m: Int, s: List<List<Int>>, p: List<Int>) {
    var ans = 0
    for (bit in 0 until (1.shl(n))) {
        var ok = true
        for (i in 0 until m) {
            var con = 0
            for (si in s.get(i)) {
                if (bit and 1.shl(si) != 0) con++
            }
            if (con % 2 != p.get(i)) ok = false
        }
        if (ok) ans++
    }

    println(ans)
}


Measured memory_bytes: 31652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  int a,b,c,d;
  cin >> A;

  a = A / 1000 % 10;
  b = A / 100 % 10;
  c = A / 10 % 10;
  d = A / 1 % 10;

  if ( b == c ){
    if ( a == b ){
      cout << "Yes" << endl;
    } else if ( c == d ){
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  } else {
      cout << "No" << endl;
  }
}

Measured memory_bytes: 3644
n,k = map(int,input().split())

min_ = k * (k-1) // 2
max_ = k * (2*n-k+1) // 2
ans = max_ - min_ + 1
ans = ans % (10**9+7)

if k == n+1:
    print(ans)

else:
    for i in range(k+1,n+2):
        min_ = min_ + (i-1)
        max_ = max_ + (n-(i-1))
        ans += max_ - min_ + 1
        ans = ans % (10**9+7)
    print(ans)

Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x)      begin(x),end(x)

using namespace std;
using vecint = vector<int>;
using ll = int64_t;

int main()
{
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  if ((k % 2) == 0) {
    cout << (a - b) << endl;
  } else {
    cout << ((b + c) - (a + c)) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys
from itertools import accumulate

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    S = [int(i) for i in input()]
    N = len(S)
    sac = [0] + list(accumulate(S))
    ans = 0

    for i in range(N):
        ans += (int(sac[i] * 2**(i - 1)) + 2**i * S[i]) * 10**(N - 1 - i)

    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
    int S,h,m,s;
    cin >> S;
    if (S>=0 && S<=86400) {
        s = S%60;
        m = S/60%60;
        h = S/60/60;
        cout << h << ":" << m << ":" << s << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
import java.util.Arrays;
import java.util.Scanner;

public class Main {

     static Scanner scanner;

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

         int N=gi();
         long[] a=new long[N];
         
         for(int i=0; i<N;i++) {
        	 a[i]=gl()-i-1;
         }
         
         Arrays.parallelSort(a);
         
         long b1=a[Math.floorDiv(N, 2)];
         long ans=0;
         for(int i=0; i<N; i++) {
             ans+=Math.abs(a[i]-b1);
         }

         System.out.println(ans);
     }


     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

Measured memory_bytes: 61904
n = int(input())
p,q = 0,0
ans = 'Yes'
for i in range(n):
    t,x,y = map(int,input().split())
    if not(x-p+y-q <= t and (x-p+y-q-t)%2 == 0):
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep1n(i,n) for(int i=1; i<=(n); ++i)
#define repxn(i,x,n) for(int i=x; i<=(n); ++i)
#define sort_u(x) sort((x).begin(),(x).end())
#define sort_d(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
#define INF 1001001001  // 浮動小数点型
#define INF_L 1001001001001001001  // 浮動小数点型
#define bit(n,m)(((n)>>(m))&1)  // nのmビット目が1
#define MOD 1000000007
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main() {
    int d, t, s; cin >> d >> t >> s;
    if(t*s >= d) cout << "Yes" << endl;
    else cout << "No" << endl;
}

/*
g++ a.cpp
./a.out

oj d
oj t

debug:ctrl+shift+B problemin

*/


Measured memory_bytes: 3608
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, core.stdc.string;

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

    A ~= A.reduce!((a,b) => a^b);
    B ~= B.reduce!((a,b) => a^b);

    if (A.dup.sort() != B.dup.sort()) {
        writeln(-1);
        return;
    }

    auto C = A.dup.sort().uniq.array;
    int M = C.length.to!int;

    int[int] D;
    foreach (i; 0..M) {
        D[C[i]] = i;
    }

    A.each!((ref a) => a = D[a]);
    B.each!((ref a) => a = D[a]);

    auto uf = new UnionFind(M);
    foreach (i; 0..N+1) {
        if (A[i] != B[i]) {
            uf.unite(A[i], B[i]);
            uf.edge[uf.find(A[i])] += 1;
        }
    }


    int ans = 0;

    foreach (i; 0..M) {
        if (uf.find(i) != i) continue;
        if (uf.edge[i] == 0) continue;
        if (uf.find(A.back) == i) {
            ans += uf.edge[i];
            if (A.back != B.back) ans -= 1;
        } else {
            ans += uf.edge[i] + 1;
        }
    }

    ans.writeln;
}



class UnionFind {
    int N;
    int[] table;
    int[] edge;

    this(int n) {
        N = n;
        table = new int[](N);
        fill(table, -1);
        edge = new int[](N);
    }

    int find(int x) {
        return table[x] < 0 ? x : (table[x] = find(table[x]));
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (table[x] > table[y]) swap(x, y);
        edge[x] += edge[y];
        table[x] += table[y];
        table[y] = x;
    }
}


Measured memory_bytes: 15292
import java.util.*;

public class Main{
    public static void main(String[] agrs){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int bit = 0;
        for(int i = 0; i < N; i ++){
            bit |= sc.nextInt();
        }
        System.out.println(Integer.numberOfTrailingZeros(bit));
    }
}

Measured memory_bytes: 36044
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int[][] map = new int[10][10];
        for(int i = 0; i < 10; i++){
            for(int j = 0; j < 10; j++){
                map[i][j] = sc.nextInt();
            }
        }
        for(int k = 0; k < 10; k++){
            for(int i = 0; i < 10; i++){
                for(int j = 0; j < 10; j++){
                    map[i][j] = Math.min(map[i][j],map[i][k]+map[k][j]);
                }
            }
        }
        int ans = 0;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                int now = sc.nextInt();
                if(now == -1){
                    continue;
                }else{
                    ans += map[now][1];
                }
            }
        }
        System.out.println(ans);
    }
    
    public static Boolean[] dfs(int now, boolean[][] map, Boolean[] visited, int n){
        for(int i = 0; i < n; i++){
            if(visited[i] || !map[now][i]){
                continue;
            }else{
               visited[i] = true;
               dfs(i,map,visited,n);
            }
        }
        return visited;
    }
}

class Bridge{
    int s,g;
    public Bridge(int s, int g){
        this.s = s;
        this.g = g;
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


Measured memory_bytes: 26708
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// use std::io::{stdout, Write, BufWriter};
use std::cmp::max;

fn main() {
    input!{ s: String }
    let mut ans = 0;
    let mut length = 0;
    let s = s.as_bytes();
    for (i, &c) in s.into_iter().enumerate() {
        match c {
            b'A' | b'T' | b'G' | b'C' => {
                length += 1;
                if i == s.len() - 1{
                    ans = max(ans, length)
                }
            }
            _ => {
                ans = max(ans, length);
                length = 0;
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){

  int A,B,st=0;
  string S;
  cin>>A>>B>>S;
  int n=S.length();
  for(int i=0;i<n;i++){
    if(i==A&&S[i]!='-')st=1;
    if(i!=A&&(S[i]<'0'||'9'<S[i]))st=1;
  }
  if(st)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;


  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;

int dist(vi a,vi b){
    int ans=0;
    for(int i=0;i<a.size();i++){
        ans+=((a[i]-b[i])*(a[i]-b[i]));
    }
    return ans;
}

int main(){
    ll N;
    cin>>N;
    vl A(N);
    ll sum=0;
    F0R(i,N){
        cin>>A[i];
        sum+=pow(-1,i)*2*A[i];
    }
    vl vt(N);
    vt[0]=sum/2;
    FOR(i,1,N){
        vt[i]=2*A[i-1]-vt[i-1];
    }
    FOR(i,0,N){
        cout<<vt[i]<<" ";
    }
    return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int n;
int a[20];
int x[20][20];
int y[20][20];

int counter(int x) {
  if (x == 0) return 0;
  return counter(x >> 1) + (x&1);
}

int main () {
  cin >> n;
  rep(i,n) {
    cin >> a[i];
    rep(j,a[i]) {
      cin >> x[i][j] >> y[i][j];
      x[i][j]--;
    }
  }

  int ans = 0;
  rep(b,1<<n) {
    bool ok = true;
    rep(i,n) {
      if (!(b&(1<<i))) continue;
      // 正直者の証言が矛盾しないか確認
      rep(j,a[i]) {
        //if ((b&(1<<x[i][j])) ^ y[i][j]) ok = false;
        //b&(1<<x[i][j])は1より大きな値になりうり、xorの計算が狂うのでダメ
        //1^1 -> 0, 2^1 -> 3

        if (((b>>x[i][j])&1) ^ y[i][j]) ok = false;

        //printf("b = %d, b&(1<<x[i][j]) = %d, y[i][j] = %d\n", b, b&(1<<x[i][j]), y[i][j]);
        //printf("b = %d, (b>>x[i][j])&1 = %d, y[i][j] = %d\n", b, (b>>x[i][j])&1, y[i][j]);
      }
    }
    if (ok) ans = max(ans, counter(b));
    //if (ok) debug(b);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

ll gcd(ll a, ll b) {
	if(b == 0) return a;
	else return gcd(b, a % b);
}

int N;
ll A[MAX_N];

bool sub_solve() {
	if(N == 1) return (A[0] - 1) % 2;
	bool second = false;
	while(true) {
		// debug(vi(A, A + N));
		int odd = 0;
		bool one = false;
		rep(i, 0, N) {
			if(A[i] % 2) odd++;
			if(A[i] == 1) one = true;
		}
		if((N - odd) % 2) return (second ^ 1);
		else if(odd != 1 || one) return second;
		else {
			if(A[0] % 2) A[0]--;
			ll g = A[0];
			rep(i, 0, N) {
				if(A[i] % 2) A[i]--;
				g = gcd(g, A[i]);
			}
			rep(i, 0, N) A[i] /= g;
		}
		second ^= 1;
	}
}

void solve() {
	cin >> N;
	rep(i, 0, N) cin >> A[i];
	if(sub_solve()) {
		cout << "First\n";
	}
	else cout << "Second\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(), a.end()
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; }
using namespace std;
typedef long long ll;

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

    vector<ll> a(N);
    rep(i, N)cin >> a[i];
    sort(all(a));

    vector<int> sign(N);
    rep(i, N){
        if(a[i] >= 0)sign[i] = 1;
        else sign[i] = -1;
    }
    if(a[0] > 0)sign[0] = -1;
    if(a[N - 1] < 0)sign[N - 1] = 1;

    ll ans = 0;
    int pcnt = 0, ncnt = 0;
    rep(i, N)ans += a[i] * sign[i];
    cout << ans << endl;

    ll now = a[N - 1] - a[0];
    vector<pair<int, int>> vec(N - 1);
    vec[0].first = a[N - 1];
    vec[0].second = a[0];

    vector<bool> swaps(N - 1, false);
    for(int i = 1; i < N - 1; i++){
        if(sign[i] == 1){
            swaps[i - 1] = true;
            vec[i].first = a[i];
            vec[i].second = -now;
            now += a[i];
        } else {
            vec[i].first = now;
            vec[i].second = a[i];
            now -= a[i];
        }
    }

    rep(i, N - 1){
        if(swaps[i])swap(vec[i].first, vec[i].second);
        cout << vec[i].first << ' ' << vec[i].second << endl;
    }

}

Measured memory_bytes: 3840
import java.util.*;

class Main{
    Main(){
        Scanner SC = new Scanner(System.in);

        String S = SC.next();

        if(S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5)){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

    public static void main(String[] args){
        Main main = new Main();
    }
}


Measured memory_bytes: 21204
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	ld n = 100;
	ll x; cin >> x;
	int cnt=0;
	while(n<x){
		n *= 1.01;
		n = floor(n);
		cnt++;
	}
	cout << cnt << endl;
	
}	


Measured memory_bytes: 3656
using System;
class Program
{

    static void Main(string[] args)
    {

        // input with space delimiter
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
        int c = int.Parse(input[2]);
        int total = a+b+c;

        if (total >=22)
        {
            Console.WriteLine("bust");
        }
        else
        {
            Console.WriteLine("win");
        }


    }
}

Measured memory_bytes: 11092
/**
 * author: said_v15
**/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
//#include <__msvc_all_public_headers.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
 
typedef long long  ll;

#define press_F_to_pay_respect ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define fore(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define pob pop_back()
#define mp make_pair 
#define sc second 
#define f first 
#define th third
#define ld long double
#define kek cout<<"\n"; 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) ((v).begin()), ((v).end()) 
#define halt {cout<<"NO"; return 0;}


const ll MOD = 1e9 + 7;
const ll MOD1 = 998244353;
const int MAXN = 1000100;
const int INF = 1e8;
const ll LL_INF=1e18;
const double pi=3.1415926535;
using namespace std;
int divide(int a, int b)
{
          return (a+b-1)/b;
}

int main()
{
    #if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
    #endif
 press_F_to_pay_respect;
 // cout << fixed << setprecision(12) << ans;
 // string al = "abcdefghijklmnopqrstuvwxyz";
 int questions=1;
// cin>>questions;
 while(questions--)
 {
           ll a,b,c,d;
           cin>>a>>b>>c>>d;
           ll ans=-1e18;
           ans=max(ans, a*c);
           ans=max(ans, a*d);
           ans=max(ans, c*b);
           ans=max(ans, b*d);
           cout<<ans;
       
 }
 
 
 // !!! LOOK AT NUMBER OF QUESTIONS IN A PROBLEM !!! (cin>>questions)
 

  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
}

Measured memory_bytes: 3640
def sieve():
    n = 100003
    prime_list = []
    is_prime = [True for _ in range(n+1)]
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        f = is_prime[i]
        if f:
            prime_list.append(i)
            j = 2 * i
            while j <= n:
                is_prime[j] = False
                j += i

    return prime_list

X = int(input())
primes = sieve()
for i in primes:
    if i >= X:
        print(i)
        exit()


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

#define pb push_back
#define fi first
#define se second

typedef long long ll;


void sove() {
	
}


int main() {
	int n;
	cin >> n;
	int l = n % 10;
	
	
	if(l == 2 || l == 4 || l == 5 || l == 7 ||l == 9) {
		cout << "hon";
	} else if(l == 3) {
		cout << "bon";
	} else {
		cout << "pon";
	}
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;

int main()
{ 

    fast;

    ll n,mm;
    cin>>n>>mm;

    ll p[mm];
    string s[mm];
    map<ll,vector<ll> > m;
    for(ll i=0;i<mm;i++)
    	{cin>>p[i]>>s[i];
    		if(s[i]=="AC")
    			m[p[i]].pb(1);
    		else m[p[i]].pb(0);
    	}

ll ac=0,wa=0;

	for(auto i:m)
	{
		ll tmp=0;
		bool f=0;
		for(auto j:m[i.ff])
		{
			if(j!=1)
				tmp++;
			else
			{
				f=1;
				break;
			}

		}
		if(f)
		{
			ac++;
			wa+=tmp;
		}
	}
    
    cout<<ac<<" "<<wa<<endl;
  }

Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

int main() {
    ll h, w, n; cin >> h >> w >> n;
    vector <vector <ll>> v(h, vector <ll> (w));
    ll loc_h = 0, loc_w = 0;
    rep(i, n) {
        ll a; cin >> a;
        rep(j, a) {
            v.at(loc_h).at(loc_w) = i+1;
            if (loc_h%2 && loc_w==0) loc_h++;
            else if (loc_h%2==0 && loc_w==w-1) loc_h++;
            else if (loc_h%2) loc_w--;
            else loc_w++;
        }
    }
    rep(i, h) {
        rep(j, w) {
            if (j) cout << ' ' << v.at(i).at(j);
            else cout << v.at(i).at(j);
        }
        cout << endl;
    }
}

Measured memory_bytes: 3652
package main

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

var scanner *bufio.Scanner

func nextInt() int {
	scanner.Scan()

	var i, _ = strconv.Atoi(scanner.Text())

	return i
}

func nextString() string {
	scanner.Scan()

	return scanner.Text()
}

func initScanner() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
}

// math functuon
func maxInt(a, b int) int {
	return int(math.Max(float64(a), float64(b)))
}
func minInt(a, b int) int {
	return int(math.Min(float64(a), float64(b)))
}

// 階乗
func factorial(n int64) int64 {
	if n < 1 {
		return 1
	}

	return n * factorial(n-1)
}

// 順列
func permutation(n, k int64) int64 {
	return factorial(n) / factorial(n-k)
}

// 組み合わせ
func combination(n, k int64) int64 {
	if k == 0 || k == n {
		return 1
	}

	return permutation(n, k) / factorial(k)
}

var isDebug = true

func log(format string, args ...interface{}) {
	if !isDebug {
		return
	}

	fmt.Printf(format+"\n", args...)
}

func main() {
	var debugFlag = flag.Bool("debug-mode", false, "debug flag")
	flag.Parse()
	isDebug = *debugFlag

	initScanner()

	var n = nextInt()
	var m = nextInt()

	log("n=%d, m=%d", n, m)

	if n == 1 {
		fmt.Println(1)
		return
	}

	var stops = make([]int, n+1)
	for i := 0; i < m; i++ {
		stops[nextInt()] = 1
	}

	var result = make([]int, n+1)

	if stops[1] == 0 {
		result[1] = 1
	}

	if stops[2] == 0 {
		if stops[1] == 0 {
			result[2] = 2
		} else {
			result[2] = 1
		}
	}

	for i := 3; i < n+1; i++ {
		if stops[i] == 1 {
			continue
		}
		if stops[i-1] == 1 && stops[i-2] == 1 {
			result[n] = 0

			break
		}

		if stops[i-1] == 0 {
			result[i] += result[i-1]
			result[i] %= 1000000007
		}
		if stops[i-2] == 0 {
			result[i] += result[i-2]
			result[i] %= 1000000007
		}

	}

	fmt.Println(result[n])

}


Measured memory_bytes: 2560
while n = gets.to_i
  break if n == 0
  min = 1.0/0.0
  0.upto(n/200){|i|
    0.upto(n/300){|j|
      break if 200*i+300*j > n
      if (n - 200*i-300*j) % 500 == 0
        k = (n - 200*i-300*j) / 500
        cost = i % 5 * 380 + (380 * 0.80) * (i - i % 5) \
        + j % 4 * 550 + (550 * 0.85) * (j - j % 4) \
        + k % 3 * 850 + (850 * 0.88) * (k - k % 3)
        min = cost if cost < min
      end
    }
  }
  puts min.to_i
end

Measured memory_bytes: 8736