akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define db(x) cout<<x<<" "
#define db1(x) cout<<x<<'\n'
#define db2(x,y) cout<<x<<" "<<y<<'\n'
#define db3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pair(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define ll  long long int
#define vi vector<ll>
#define pi pair<ll,ll>
#define vpi vector<pair<ll,ll>>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define mod 1000000007
#define MAX_N 100000
using namespace std;
// int dx[4] = {1,-1,0,0};
// int dy[4] = {0,0,1,-1};
double dp[301][300][301];

double get(ll x, ll y, ll z, ll n){

    if(x<0||y<0||z<0)
        return 0;

    if(x==0&&y==0&&z==0)
        return 0;

    //db(x),db(y),db1(z);

    if(dp[x][y][z]>0.9)
        return dp[x][y][z];

    double exp = n+x*get(x-1,y,z,n)+y*get(x+1,y-1,z,n)+z*get(x,y+1,z-1,n);
    return dp[x][y][z] = exp/(x+y+z);
}

void solve(){

    ll n,k;
    cin>>n>>k;

    ll arr[n];

    rep(i,n)
    cin>>arr[i];

    ll dp[k+1];
    dp[0]=0;

    repA(i,1,k){
        dp[i]=0;
        rep(j,n){
            if(i>=arr[j]){
                if(dp[i-arr[j]]==0){
                    dp[i]=1;
                    break;
                }
            }
            else{
                break;
            }
        }
    }

    if(dp[k]==1){
        db1("First");
    }
    else{
        db1("Second");
    }

}
int main(){ 

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





Measured memory_bytes: 1024
//William Lin is a beast!!
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
int c[N];
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n,d,a;
   cin>>n>>d>>a;
   vector<pii>v;
   for(int i=0;i<n;i++)
   {
       int x,h;
       cin>>x>>h;
       v.pb({x,h});
   }
   sort(all(v));
   int ans=0;
   int j=0;
   for(int i=0;i<n;i++)
   {
       while(j<n && v[j].F<=v[i].F + 2*d)
        j++;
       int need=max((v[i].S - c[i]*a + a-1)/a,0LL);
       ans+=need;
       c[i]+=need;
       c[j]-=need;
       c[i+1]+=c[i];
   }
   cout<<ans<<endl;

}



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

using namespace std;
typedef long long ll;
using pii = pair<ll, ll>;
const ll mx = 1000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define ull unsigned long long
#define    ss   second
#define    ff   first
#define    pb   push_back
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))

///--------------Graph Moves--------------------------------------
///const ll fx[] = {+1,-1,+0,+0};
///const ll fy[] = {+0,+0,+1,-1};
///const ll fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const ll fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const ll fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const ll fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);


int main() {
    FIO;
    ll n; cin >> n;
    ll a[n + 1], b[n + 1];
    for(ll i = 0; i < n; i++) cin >> a[i] >> b[i];
    ll c = 0;
    for(ll i = 0; i < n; i++) {
        if(a[i] == b[i]) {
            c++;
        }
        else {
            c = 0;
        }
        if(c == 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}



Measured memory_bytes: 3644
import sys
 
stdin = sys.stdin

mod = 1000000007
inf = 1 << 60
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n = ni()
a = na()
c = [0] * (n + 1)
for i in range(1, n + 1):
    c[i] = c[i - 1] + a[i - 1]

ans = inf
for i in range(n - 1):
    m = i + 1
    ans = min(ans, abs(c[m] - (c[n] - c[m])))

print(ans)

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

#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<int, int> pi;
typedef vector<int> vi;
void print_pair(pi a){
  cerr<<"("<<a.first<<", "<<a.second<<") ";
}
template<int T1, int T2>
void print_2d(int a[T1][T2], int x, int y){
  For(i, x){
    For(j, y){
      cerr<<a[i][j]<<" ";
    }
    cerr<<endl;
  }
}
template<class T>
void print_array(T a[],size_t n){
  cerr<<"array:";
  REP(n-1)cerr<<a[i]<<",";
  cerr<<a[n-1]<<endl;
}

int N;
ll cache[100000];

int main(){
  cin>>N;
  REP(100000)cache[i]=(i+1)*(i+2);
  N*=2;
  for (int i = 0; cache[i] <= N; i++) {
    if(N==cache[i]){
      cout<<"Yes"<<endl;
      cout<<i+2<<endl;
      vector<int> ans[i+2];
      int cur=1;
      For(j,i+2){
        For(k,i+1-j){
          ans[j].push_back(cur);
          ans[j+1+k].push_back(cur);
          cur++;
        }
      }
      For(j,i+2){
        cout<<ans[j].size();
        for(auto tmp:ans[j]){
          cout<<" "<<tmp;
        }
        cout<<endl;
      }
      return 0;
    }
  }
  cout<<"No"<<endl;
  return 0;
}



Measured memory_bytes: 3072
#include <iostream>
#include <map>

using namespace std;

typedef map<int, int> mii;

const int Z = 1e9+7;

int bexp(int a, int x) {
    if (x == 0) {
        return 1;
    }
    if (x % 2 == 1) {
        return 1ll * a * bexp(a, x - 1) % Z;
    }
    int t = bexp(a, x / 2);
    return 1ll * t * t % Z;
}

int inv(int a) {
    return bexp(a, Z - 2);
}

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

    int n;
    cin >> n;

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

    mii lcmp;
    for (int i = 0; i < n; i++) {
        int x = a[i];
        for (int j = 2; j * j <= x; j++) {
            if (x % j == 0) {
                int t = 0;
                while (x % j == 0) {
                    x /= j;
                    t++;
                }

                lcmp[j] = max(lcmp[j], t);
            }
        }
        if (x > 1) {
            lcmp[x] = max(lcmp[x], 1);
        }
    }

    int lcm = 1;
    for (auto p : lcmp) {
        lcm = 1ll * lcm * bexp(p.first, p.second) % Z;
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        ans = (ans + 1ll * lcm * inv(a[i])) % Z;
    }

    cout << ans << endl;

    return 0;
}


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

int64_t GCD(int64_t m,int64_t n){
    int64_t big,small;
    int64_t p=-1;
    big=max(m,n);
    small=min(m,n);

    while(1){
        p=big%small;
        if(p==0)break;
        big=small;
        small=p;
    }
    
    return small;
}

int main(){
    int64_t a,b,c,d;
    int64_t l;
    cin >> a>>b>>c>>d;
    int flag=0;
    int64_t numc,numd,numl;
    int64_t ans=0;

    l= (c*d)/GCD(c,d);

    if(a%c==0){
        numc = (b/c)-(a/c)+1;
    }else{
        numc=(b/c)-(a/c);
    }

    if(a%d==0){
        numd = (b/d)-(a/d)+1;
    }else{
        numd=(b/d)-(a/d);
    }

    if(a%l==0){
        numl = (b/l)-(a/l)+1;
    }else{
        numl=(b/l)-(a/l);
    }

    ans = (b-a+1) -numc -numd +numl;

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<pii, int> para;
const int inf = 1e9 + 7;
const int maxN = 1e6 + 5;

int n, m, balls[maxN], a, b;
bool poss[maxN];
int main() {
	scanf("%d%d",&n,&m);
	RI(i, n) {
		poss[i] = false;
		balls[i] = 1;
	}
	poss[1] = true;
	REP(i, m) {
		scanf("%d%d",&a,&b);
		balls[a]--;
		balls[b]++;
		if (poss[a]) poss[b] = true;
		if (balls[a] == 0 && poss[a]) poss[a] = false;
		//printf("%d %d %d %d\n",balls[a], balls[b], poss[a], poss[b]);
	}
	int ans = 0;
	RI(i, n)
		ans += poss[i];
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {

    static class P{
        String name;
        int time;
    }

    static int len = 100001;
    static P[] Q = new P[len];

    static int head = 0;
    static int tail = 0;

    static boolean isEmpty(){
        return head == tail;
    }

    static boolean isFull(){
        return head == (tail + 1) % len;
    }

    static void enqueue(P p){
        if(isFull()){
            throw new IndexOutOfBoundsException();
        }
        Q[tail] = p;

        tail = (tail + 1) % len;
    }

    static P dequeue(){
        if(isEmpty()){
            throw new IndexOutOfBoundsException();
        }
        P temp = Q[head];

        head = (head + 1) % len;
        return temp;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        P p = null;
        int n = 0;
        int q = 0;
        int index = 0;
        String[] temp = null;
        while (sc.hasNextLine()){
            if(n == 0){
                temp = sc.nextLine().split(" ");
                n = Integer.valueOf(temp[0]);
                q = Integer.valueOf(temp[1]);
            }else{
                temp = sc.nextLine().split(" ");
                p = new P();
                p.name = temp[0];
                p.time = Integer.valueOf(temp[1]);
                enqueue(p);
                index ++;
                if(index == n){
                    break;
                }
            }
        }

        int sumTime = 0;//当前总运行时间

        P curr = null;
        while (head != tail){
            curr = dequeue();
            int c = min(q,curr.time);
            curr.time -= c;
            sumTime += c;
            if(curr.time > 0){
                //如果当前任务有剩余时间 则加入队列
                enqueue(curr);
            }else{
                System.out.println(curr.name + " " + sumTime);
            }
        }
    }


    static int min(int a,int b){
        return a > b ? b : a;
    }
}




Measured memory_bytes: 105884
/*
 * a.cc:
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */
int main(){
  int W,H,x,y,r;
  cin>>W>>H>>x>>y>>r;
  if ((0<=x-r)&&(x+r<=W)&&(0<=y-r)&&(y+r<=H)) cout<<"Yes"<<endl;
  else cout<<"No"<<endl; 

}



Measured memory_bytes: 3128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Volume0020
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] sentence = Console.ReadLine().ToCharArray();
            char[] changedSentence = Sentence.ToUpperFromLower(sentence);
            Console.WriteLine(changedSentence);
        }
    }
    class Sentence
    {
        internal static char[] ToUpperFromLower(char[] sentence)
        {
            for (int i = 0; i < sentence.Length; ++i)
            {
                if (char.IsLower(sentence[i]))
                {
                    sentence[i] = char.ToUpper(sentence[i]);
                }
            }
            return sentence;
        }
    }
}




Measured memory_bytes: 13644
#include<cstdio>
#include<algorithm>
#include<stack>
using namespace std;
int main(void)
{
	int suji;
	stack<int> S;
	while(scanf("%d",&suji)!=EOF)
	{
		if(suji == 0)
		{
			printf("%d\n",S.top());
			S.pop();
		}
		else
		{
			S.push(suji);
		}

	}
	return 0;
}

Measured memory_bytes: 1036
import java.util.Scanner;

public class Main {

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

		String mae = moji.substring(0,4);
		String ato = moji.substring(4,12);

		System.out.println(mae + ' ' + ato);
		sc.close();
	}

}


Measured memory_bytes: 9556
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, K = MAP()
x = LIST()

ans = INF
for i in range(N-K+1):
	if x[i] <= 0 and x[i+K-1] <= 0:
		ans = min(ans, abs(x[i]))
	elif x[i] >= 0 and x[i+K-1] >= 0:
		ans = min(ans, abs(x[i+K-1]))
	else:
		ans = min(ans, 2*abs(x[i])+abs(x[i+K-1]), abs(x[i])+2*abs(x[i+K-1]))
print(ans)


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (auto&& e : a) {
    cin >> e;
  }

  int do_count = 0;
  while (true) {
    if (all_of(begin(a), end(a), [](const int x) { return x % 2 == 0; })) {
      do_count++;
      transform(begin(a), end(a), begin(a), [](const int x) { return x >> 1; });
    } else {
      break;
    }
  }
  cout << do_count << endl;
}


Measured memory_bytes: 256
from itertools import permutations

N, C = map(int, input().split())
D = list()
for _ in range(C):
    D.append(list(map(int, input().split())))

c = list()
for _ in range(N):
    c.append(list(map(int, input().split())))

# sum of wrongnesses to repaint i-th strip to color j. (i=0,1,2,  j=0,1,...,C-1)
sw = [[0] * C for _ in range(3)]

for i in range(N):
    for j in range(N):
        idc = c[i][j] - 1
        for _idc in range(C):
            sw[(i + j) % 3][_idc] += D[idc][_idc]

ans = 10**9
for p in permutations(range(C), 3):
    tmp = 0
    for idx, q in enumerate(p):
        tmp += sw[idx][q]

    if ans > tmp:
        ans = tmp

print(ans)



Measured memory_bytes: 46428
/*input
2 2
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define eb emplace_back
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (int)(lower_bound(c.begin(),c.end(),x)-c.begin())
#define EL cout<<'\n'
#define BS(a,x) binary_search(ALL(a),x)
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
	REP(i,SZ(V)) out<<V[i]<<((i!=SZ(V)-1)?" ":"");
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=20;
const ll INF64=1e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}


int main(){
	IOS;
	int k,s;
	cin>>k>>s;
	int cnt=0;
	REP(i,k+1) REP(j,k+1){
		int num = s-i-j;
		if(num<=k&&num>=0) cnt++;
	}
	cout<<cnt<<'\n';
	return 0;
}


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

using namespace std;

const int N = 1e5 + 10;
const int inf = 1e9 + 10;

int n, k, h[N];
int f[N];

int main() {
    cin >> n >> k;
    for(int i = 1; i <= n; i++) cin >> h[i];

    for(int i = n - 1; i >= 1; i--) {
        f[i] = inf;
        for(int j = 1; j <= min(n - i, k); j++)
            f[i] = min(f[i], f[i + j] + abs(h[i] - h[i + j]));
    }
    cout << f[1];
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<climits> //INT_MIN/MAX
using namespace std;

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

#define FOR(i,s,e) for(ll (i)=(s);(i)<(e);(i)++)
#define FORR(i,s,e) for(ll (i)=(s);(i)>(e);(i)--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define mp make_pair
#define pb push_back
const ll MOD = 1000000007;
const int INF = 1e9;
const ll LINF = 1e16;
const double PI = acos(-1.0);
int dx[8] = { 0,0,1,-1,1,1,-1,-1 };
int dy[8] = { 1,-1,0,0,1,-1,1,-1 };

/* -----  xtimex  Problem: ABC 0 ABCD / Link:  ----- */
/* ------蝠城｡---



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

ll N, A, B;
ll v[60];
ll ans = 0;
ll comb[100][100];

double ave = 0;

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

    cin >> N >> A >> B;
    FOR(i, 0, N) {
        cin >> v[i];
    }


    for (int i = 0; i <= 60; i++) {
        for (int j = 0; j <= i; j++) {
            if (j == 0 || j == i)
                comb[i][j] = 1;
            else
                comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
        }
    }


    sort(v, v + N);
    reverse(v, v + N);

    if (v[0] != v[A - 1]) {
        int cnt = 0, ne = 0;
        FOR(i, 0, N) {
            if (v[A - 1] == v[i]) {
                cnt++;
                if (i < A) {
                    ne++;
                }
            }
            if (i < A)ave += v[i];
        }
        //debug(cnt);
        ave /= A;
        ans = comb[cnt][ne];
    }
    else if (v[0] == v[A - 1]) {
        int cnt = 0;
        FOR(i, 0, N) {
            if (v[0] == v[i])cnt++;
        }
        ave = v[0];
        FOR(i, A, B + 1) {
            if (cnt>=i) {
                ans += comb[cnt][i];
            }
        }

    }

    printf("%.10f\n", ave);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
from collections import Counter, defaultdict
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline


def read_int():
    return int(buff_readline())


def read_int_n():
    return list(map(int, buff_readline().split()))


class RollingHash():
    """
    Original code is https://tjkendev.github.io/procon-library/python/string/rolling_hash.html
    """
    class RH():
        def __init__(self, s, base, mod):
            self.base = base
            self.mod = mod
            self.rev = pow(base, mod-2, mod)

            l = len(s)
            self.h = h = [0]*(l+1)
            tmp = 0
            for i in range(l):
                num = s[i]
                tmp = (tmp*base + num) % mod
                h[i+1] = tmp

            self.pw = pw = [1]*(len(s)+1)
            v = 1
            for i in range(l):
                pw[i+1] = v = v * base % mod

        def calc(self, l, r):
            return (self.h[r] - self.h[l] * self.pw[r-l]) % self.mod

    @staticmethod
    def gen(a, b, num):
        result = set()
        while 1:
            import random
            import math
            random.seed()
            while 1:
                v = random.randint(a, b)//2*2+1
                if v not in result:
                    break
            for x in range(3, int(math.sqrt(v))+1, 2):
                if v % x == 0:
                    break
            else:
                result.add(v)
                if len(result) == num:
                    break
        return result

    def __init__(self, s, rand=False, num=5):
        if rand:
            bases = RollingHash.gen(2, 10**3, num)
        else:
            assert num <= 10
            bases = [641, 103, 661, 293, 547, 311, 29, 457, 613, 599][:num]

        MOD = 10**9+7
        self.rhs = [self.RH(s, b, MOD) for b in bases]

    def calc(self, l, r):
        return tuple(rh.calc(l, r) for rh in self.rhs)


def slv(N, A, B):
    a = []
    for i in range(N):
        a.append(A[i]^A[i-1])
    a = a[:] + a[:]
    b = []
    for i in range(N):
        b.append(B[i]^B[i-1])

    ah = RollingHash(a)
    bh = RollingHash(b)

    ans = []
    h = bh.calc(0, N)
    for k in range(N):
        if ah.calc(k, N+k) == h:
            ans.append('%d %d' % (k, A[k]^B[0]))

    return ans


def main():
    N = read_int()
    A = read_int_n()
    B = read_int_n()
    print(*slv(N, A, B), sep='\n')


if __name__ == '__main__':
    main()


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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

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

signed main() {
  ll N;
  cin >> N;
  vector<ll> A(N);
  rep(i, N) {
    cin >> A[i];
    A[i] -= i;
  }

  sort(all(A));
  int b = A[N/2];

  int ans = 0;
  rep(i, N) {
    ans += abs(b-A[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,m,b) for(int i=(m);i<(b);i++)
#define rrep(i,m,b) for(int i=(b)-1;i>=(m);i--)
#define all(m) (m).begin(),(m).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	string S; cin >> S;
	unordered_map<char, int> m;
	m['J'] = m['O'] = m['I'] = 0;
	m[S[0]]++;
	int ans = 0;
	rep(i, 1, S.size()) {
		if (S[i - 1] == 'J'&&S[i] == 'I')m['J'] = m['O'] = m['I'] = 0;
		if (S[i - 1] == 'O'&&S[i] == 'J')m['J'] = m['O'] = m['I'] = 0;
		if (S[i - 1] == 'I'&&S[i] == 'O')m['J'] = m['O'] = m['I'] = 0;
		if (S[i - 1] == 'I'&&S[i] == 'J')m['J'] = m['O'] = m['I'] = 0;
		m[S[i]]++;
		if (m['J'] >= m['O'] && m['I'] >= m['O'])
			ans = max(ans, min({ m['J'] , m['O'] , m['I'] }));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4012
#include <bits/stdc++.h>
using namespace std;
int main(){
    int aiueo;
    string ans="No";
    vector<vector<int>>board(3,vector<int>(3));
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin>>board.at(i).at(j);
        }
    }
    int n;
    cin>>n;
    vector<int>bingo(n);
    for(int i=0; i<n; i++){
        cin>>bingo.at(i);
    }

for(int i=0; i<n; i++){
    for(int j=0; j<3; j++){
        for(int k=0; k<3; k++){
            if(bingo.at(i)==board.at(j).at(k)){
                board.at(j).at(k)=0;
            }
        }
    }
}
    int yoko1 = 0;
    int yoko2 = 0;
    int yoko3 = 0;
    int tate1 =0;
    int tate2 =0;
    int tate3 =0;
    int naname1 = 0;
    int naname2 = 0;
for(int i=0; i<3; i++){
    yoko1 += board.at(0).at(i);
    yoko2 += board.at(1).at(i);
    yoko3 += board.at(2).at(i);
    tate1 += board.at(i).at(0);
    tate2 += board.at(i).at(1);
    tate3 += board.at(i).at(2);
    naname1 += board.at(i).at(i);
    naname2 += board.at(i).at(2-i);
}
    if(yoko1==0 or yoko2==0 or yoko3==0 or
       tate1==0 or tate2==0 or tate3==0 or
       naname1==0 or naname2==0) ans="Yes";


cout<<ans<<endl;

}



Measured memory_bytes: 256
n = str(input())

#program = 'python'
a=int(n[0:2])
b=int(n[2:4])

if(0<a<13 and 0<b<13):
    print("AMBIGUOUS")
elif((a==0 or 12<a) and 0<b<13):
    print("YYMM")
elif(0<a<13 and (b==0 or 12<b)):
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rrep(i, n) for(int i=((int)(n)-1); i>=0; i--)
#define REP(i, k, n) for(int i=(int)(k); i<(int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const int INF = INT_MAX;
const ll inf = 1e18;
const ll mod = 998244353;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x, ll y){ if(x>y) swap(x, y);while(x!=0){ y%=x; swap(x, y); }return y; }
ll mpow(ll x, ll r){if(r==0) return 1;if(r%2==1){ return x*mpow(x, r-1)%mod; }else{ ll aa = mpow(x, r/2); return aa*aa%mod; }}

int main(){
	string s; cin >> s;
	if(s == "ABC") cout << "ARC" << endl;
	else cout << "ABC" << endl;
	return 0;
}

Measured memory_bytes: 3592
//#include <bits/stdc++.h>
//#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <bitset>
#include <algorithm>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <utility>
#include <functional>
#include <map>
#include <set>
#include <cctype>
#include <fstream>

#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000			 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define DINF 1000000000000000.0
#define PI 3.14159265358979
#define MAXI 7500000

//.size()はunsigned int　0-1をするとオーバーフローする

using namespace std;
typedef long long int ll;
typedef pair<double, pair<int, int> > P; //コスト、現在地、どこからきたか

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

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

struct edge
{
	int to;
	double cost;
};

int main(void)
{
	long long int n;
	long long int maxi = -1;
	long long int now;
	string tmp;
	char te;
	bool flag = true;

	cin >> n;
	vector<long long int> a(n);
	FOR(i,0,n-1){
		cin >> a[i];
	}
	sort(a.begin(), a.end());

	FOR(i,0,n-2){
		FOR(j,i+1,n-1){
			now = a[i] * a[j];
			tmp = to_string(now);
			flag = true;
			FOR(k, 1, tmp.size() - 1)
			{
				if(tmp[k-1]+1==tmp[k]){
					continue;
				}else{
					flag = false;
					break;
				}
			}
			if(flag){
				if (now > maxi)
				{
					maxi = now;
				}
			}
			
		}
	}

	cout << maxi << endl;

	return 0;
}



Measured memory_bytes: 3284
#include <iostream>

using namespace std;

using ll = long long;

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

int main() {
  string S;
  cin >> S;

  ll white = 0, ans = 0;
  for (auto it = S.rbegin(); it != S.rend(); ++it) {
    if (*it == 'W')
      ++white;
    else
      ans += white;
  }
  OUT(ans);

  return 0;
}


Measured memory_bytes: 640
using System;

class Program
{
    static void Main(string[] args)
    {
        int n, k, x, y,res = 0,c;
        n = int.Parse(Console.ReadLine());
        k = int.Parse(Console.ReadLine());
        x = int.Parse(Console.ReadLine());
        y = int.Parse(Console.ReadLine());
        c = n > k ? k : n;
        for (int i = 0; i < c; i++)
        {
            res += x;
        }
        if (n - k > 0)
        {
            for (int i = 0; i < n - k; i++)
            {
                res += y;
            }
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 2648
while True:
    n,k=[int(i) for i in input().split()]
    if n==0 and k==0:
        break
    a=[int(input()) for i in range(n)]
    s=sum(a[0:k])
    max=s
    for i in range(k,n):
        s=s+a[i]-a[i-k]
        if s>max:
            max=s
    print(max)




Measured memory_bytes: 9880
#include <cstdio>
#include <vector>

int main()
{
  int T;
  scanf("%d",&T);
  while(T--){
    int n;
    scanf("%d",&n);
    std::vector<long long> a(n);
    for(int i=0;i<n;i++){
      scanf("%lld",&a[i]);
    }
    char s[300];
    scanf("%s",s);
    std::vector<long long> bs(64);
    std::vector<int> tp(64);
    int dim=0;
    bool ans=true;
    for(int i=n-1;i>=0;i--){
      long long v=a[i];
      int t=0;
      while(t<dim){
	if((v&((1ll<<tp[t])-1))!=0){
	  break;
	}
	//printf(" %lld %d %d %lld\n",v,t,tp[t],bs[t]);
	if(v&(1ll<<tp[t])){
	  v^=bs[t];
	}
	t++;
      }
      //printf("%d %lld %d %d\n",i,v,dim,t);
      if(v!=0){
	if(s[i]=='0'){
	  for(int x=dim;x>t;x--){
	    bs[x]=bs[x-1];
	    tp[x]=tp[x-1];
	  }
	  bs[t]=v;
	  tp[t]=0;
	  while((v&(1ll<<tp[t]))==0){
	    tp[t]++;
	  }
	  dim++;
	}
	else{
	  ans=false;
	  break;
	}
      }
    }
    puts(ans?"0":"1");
  }
  return 0;
}


Measured memory_bytes: 3136
import heapq
def set_heapq(que, edge, used, v, add_dist=0):
    '''
    確定地点vからつながる辺を全てqueに設定し、返却する

    Parameters
    que : heapque(touple or list)
        辺を管理するキュー (距離、次の行き先)のtopuleまたはlistにて管理
    edge : list
        全ての辺を格納する二次元のリスト edge[0]にてノード0から伸びる辺であることを表し、
        edge[0] → [距離、次の行き先] を表すlistが格納されている
    v : int
        グラフ上のノード ダイクストラでは確定したノードがvにあたる
    add_dist : int
        確定した地点に足し合わせる距離 スタート地点以外では何かしらの値が追加されることになる

    Returns
    que : heapque(touple or list)
        引数queにvからつながる辺を追加したキュー
    '''
    for a,b in edge[v]:
        if used[b]:
            heapq.heappush(que,(a+add_dist,b))
    return que

def prim_heap(edge, n):
    '''
    プリム法で最小全域木を求める

    Parameters
    edge : list
        全ての辺を格納する二次元のリスト edge[0]にてノード0から伸びる辺であることを表し、
        edge[0] → [距離、次の行き先] を表すlistが格納されている
    
    Returns
    res : int
        最小全域木の全ての辺のコストの総和
    '''
    used = [True] * n #True:不使用
    edgelist = []
    edgelist = set_heapq(edgelist, edge, used, 0)
    used[0] = False
    res = 0
    while len(edgelist) != 0:
        minedge = heapq.heappop(edgelist)
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        used[v] = False
        edgelist = set_heapq(edgelist, edge, used, v)
        res += minedge[0]
    return res

N = int(input())
P = []
edge = [[] for _ in range(N)]
for i in range(N):
    x, y = map(int, input().split())
    P.append((i,x,y))

P.sort(key=lambda x:x[1])
for i in range(N-1):
    dist = min(abs(P[i][1]-P[i+1][1]), abs(P[i][2]-P[i+1][2]))
    edge[P[i][0]].append((dist, P[i+1][0]))
    edge[P[i+1][0]].append((dist, P[i][0]))

P.sort(key=lambda x:x[2])
for i in range(N-1):
    dist = min(abs(P[i][1]-P[i+1][1]), abs(P[i][2]-P[i+1][2]))
    edge[P[i][0]].append((dist, P[i+1][0]))
    edge[P[i+1][0]].append((dist, P[i][0]))

print(prim_heap(edge, N))


Measured memory_bytes: 120224
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4")
 
 
#include <iostream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
//#include <unordered_map>
#include <numeric>
 
using namespace std;
 
const int mod = 1e9 + 7;

int n, k, a[123456], b[123456];
set <pair <int, int> > q;
long long cres = 1e18;

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> k;
	for(int i = 1; i <= n; i++) {
		cin >> a[i];
		if(q.size() == k) {
			q.erase((make_pair(a[i - k], i - k)));
		}
		q.insert(make_pair(a[i], i));
		if(q.size() != k) continue;
		b[1] = (*q.begin()).first;
		int len = 2;
		b[len] = (*q.rbegin()).first;
		long long res = -1e18;
		if(b[1] <= 0 && b[len] >= 0){
		res = min(-b[1] * 2 + b[len], b[len] * 2 - b[1]);
		}
		if(b[1] <= 0 && b[len] <= 0) {
			res = -b[1];
		}
		if(b[1] >= 0 && b[len] >= 0) {
			res = b[len];
		}
		if(res < 0) {
			assert(0);
		}
		cres = min(cres, res);
	}
	cout << cres;
	return 0;
}



Measured memory_bytes: 5376
package main

import "fmt"

func score(s1, s2 string) int {
	m1 := make(map[rune]int)
	m2 := make(map[rune]int)
	for _, r := range s1 {
		m1[r]++
	}
	for _, r := range s2 {
		m2[r]++
	}

	cnt := 0
	for k := range m1 {
		if m2[k] > 0 {
			cnt++
		}
	}

	return cnt
}

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)

	max_score := score(s[:0], s[0:len(s)])
	for i := range s {
		if sc := score(s[:i], s[i:len(s)]); sc > max_score {
			max_score = sc
		}
	}
	fmt.Println(max_score)
}


Measured memory_bytes: 640
def distance(x, y):
    return (x**2 + y**2)**0.5


n, d = [int(i) for i in input().split()]
count = 0
for _ in range(n):
    x, y = [int(i) for i in input().split()]
    if distance(x, y) <= d:
        count += 1
print(count)


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

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)


int main()
{
  ll h, w;
  cin >> h >> w;
  vector <string> s(h + 2);
  string tmp;
  vecll dx = {-1, 1, 0, 0};
  vecll dy = {0, 0, -1, 1};
  bool pass;
  s[0] = string(w + 2, '.');
  s[h + 1] = string(w + 2, '.');
  forll(i, 0, h){
	cin >> tmp;
	s[i + 1] = "." + tmp + ".";
  }
  forll(i, 1, h+1){
	forll(j, 1, w+1){
	  if (s[i][j] == '#'){
		pass = false;
		forll(d, 0, dx.size()){
		  if (s[i+dy[d]][j+dx[d]] == '#'){
			pass = true;
			break;
		  }
		}
		if (pass == false){
		  cout << "No" << endl;
		  return 0;
		}
	  }
	}
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
int gcd(int a, int b) {
    if (a < b) {
        int c = a;
        a = b;
        b = c;
    }
 
    while (b != 0) {
        int c = a % b;
        a = b;
        b = c;
    }
 
    return a;
}
 
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}

signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int l=lcm(c,d);
  int ca=(a-1)/c,cb=b/c,da=(a-1)/d,db=b/d,la=(a-1)/l,lb=b/l;
  cout<<(b-a)+1-( (cb-ca) + (db-da) - (lb-la) )<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

//数式の最大の長さ
#define MAXLENGTH 400
//オペランドの最大個数
#define MAXOP 100

void push(int stack[MAXOP], int *sp, int op);
int pop(int stack[MAXOP], int *sp);

int main(void)
{
	//spはスタックのポインタ、opは数式に含まれるオペランドを格納
	int i, sp, op;
	//calc_value1とcalc_value2は計算用のオペランドを格納
	int calc_value1, calc_value2;
	int stack[MAXOP];
	char formual[MAXLENGTH];

	//数式を入力
	scanf("%[^\n]", formual);

	//初期値は0
	sp = 0;
	i = 0;

	//数式の最後まで繰り返す
	while(formual[i] != '\0'){
		//数字ならば数値に変換し、プッシュする
		if(formual[i] >= '0' && formual[i] <= '9'){
			//数値に変換
			op = formual[i] - 48;
			i++;
			//数字が2桁以上の場合の動作
			while(formual[i] != ' '){
				op *= 10;
				op += formual[i] - 48; 
				i++;
			}

			push(stack, &sp, op);
		}
		//演算子ならばポップし、計算する
		else if(formual[i] == '+'){
			calc_value1 = pop(stack, &sp);
			calc_value2 = pop(stack, &sp);

			op = calc_value1 + calc_value2;
			//計算結果をプッシュ
			push(stack, &sp, op);
		}
		else if(formual[i] == '-'){
			calc_value1 = pop(stack, &sp);
			calc_value2 = pop(stack, &sp);

			op = calc_value2 - calc_value1;
			//計算結果をプッシュ
			push(stack, &sp, op);
		}
		else if(formual[i] == '*'){
			calc_value1 = pop(stack, &sp);
			calc_value2 = pop(stack, &sp);

			op = calc_value1 * calc_value2;
			//計算結果をプッシュ
			push(stack, &sp, op);
		}

		//インデックスを増加
		i++;
	}

	//結果をポップし出力
	op = pop(stack, &sp);
	printf("%d\n", op);

	return 0;
}

void push(int stack[100], int *sp, int op)
{
	stack[*sp] = op;
	*sp += 1;
}

int pop(int stack[100], int *sp)
{
	int op;

	*sp -= 1;
	op = stack[*sp];

	return op;
}


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

#define N 1001
#define INT(X) \
  ( *( (const int *)(X) ) )
#define ABS(X) \
  ( (X) < 0 ? -(X) : (X) )

static
int comparator (
  const void  * a,
  const void  * b
  )
{
  return ( INT( a ) - INT( b ) );
}

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int V, d;
  int i;

  while ( scanf ( "%d%d", &V, &d ) == 2 )
  {
    int fib[ N + 1 ] = { 1, 2 };
    int res = 1;

    for ( i = 2; i <= V; ++i )
    {
      fib[ i ] = ( fib[ i - 2 ] + fib[ i - 1 ] ) % N;
    }
    qsort ( fib + 1, V, sizeof ( int ), comparator );

    for ( i = 2; i <= V; ++i )
    {
      if ( ABS ( fib[ i ] - fib[ i - 1 ] ) >= d )
      {
        ++res;
      }
    }

    printf ( "%d\n", res );
  }

  return ( 0 );
}

Measured memory_bytes: 0
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    n = int(ipt())
#    n = 20000
    if n == 3:
        print("2 3 25")
        exit()
    elif n == 4:
        print("2 5 20 63")
        exit()
    tn = (n//8)*8
    sm = 0
    nm = 0
    ans = []
    la = 0
    for i in range(1,30001):
        if i%2 == 0 or i%3 == 0:
            ans.append(i)
            sm += i
            nm += 1
        if nm == tn:
            if ans:
                la = ans[-1]
            break

    if n%8 == 0:
        pass
    elif n%8 == 1:
        ans.append(la+6)
    elif n%8 == 2:
        ans.append(la+2)
        ans.append(la+4)
    elif n%8 == 3:
        ans.append(la+2)
        ans.append(la+4)
        ans.append(la+6)
    elif n%8 == 4:
        ans.append(la+2)
        ans.append(la+4)
        ans.append(la+6)
        ans.append(la+12)
    elif n%8 == 5:
        ans.append(la+2)
        ans.append(la+3)
        ans.append(la+4)
        ans.append(la+6)
        ans.append(la+9)
    elif n%8 == 6:
        ans.append(la+2)
        ans.append(la+3)
        ans.append(la+4)
        ans.append(la+9)
        ans.append(la+8)
        ans.append(la+10)
    elif n%8 == 7:
        ans.append(la+2)
        ans.append(la+3)
        ans.append(la+4)
        ans.append(la+9)
        ans.append(la+8)
        ans.append(la+10)
        ans.append(la+12)


    print(" ".join(map(str,ans)))


    return None

if __name__ == '__main__':
    main()


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

using namespace std;

using ll = long long;

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

ll lcm(ll m, ll n ) {
    if (0 == m || 0 == n)
        return 0;
    return (m / gcd(m, n)) * n; // lcm = m * n / gcd(m,n)
}

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

    ll n, m;
    string s, t;
    cin >> n >> m >> s >> t;

    ll _lcm = lcm(n, m);
    ll n_fac = _lcm / n;
    ll m_fac = _lcm / m;
    // ll _gcd = gcd(n_fac, m_fac);
    ll _gcd = gcd(n, m);

    // int end = _lcm
    for (int i = 0; i < _gcd; ++i) {
        if (s[i * m_fac] != t[i * n_fac]) {
            printf("-1\n");
            return 0;
        }
    }

    cout << _lcm << '\n';

    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main(){
	char sa;
	char sb;
	char sc;
	scanf("%c", &sa);
	scanf("%c", &sb);
	scanf("%c", &sc);
	if(sa == sb && sb == sc){
		printf("No\n");
	}
	else{
		printf("Yes");
	}
  	return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  vector<int> b(m);
  for (int i = 0; i < m; i++) {
    cin >> a.at(i) >> b.at(i);
  }
  
  vector<int> c(n, 0);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a.at(j) == i + 1 || b.at(j) == i + 1) {
        c.at(i)++;
      }
    }
    cout << c.at(i) << endl;
  }
}


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

class Main {

    // Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        String S;
        S = sc.next();
        solve(S);
    }

    static void solve(String S){
        String ans = "";
        switch (S) {
            case "Sunny": ans = "Cloudy"; break;
            case "Cloudy": ans = "Rainy"; break;
            case "Rainy": ans = "Sunny"; break;
        }
        System.out.println(ans);
    }
}


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

#define MAX 100000
int a[MAX], inDeg[MAX];

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

	int ans=n;
	queue<int> Q;
	for(int i=0;i<n;i++){
		if(inDeg[i]==0){
			Q.push(i);
		}
	}
	while(Q.empty()==false){
		int now=Q.front();	Q.pop();
		// inDeg == 0 なら間違いなくループしてないので、nowスタートによるループ不能
		// -> ans -= 1
		ans--;

		int nextPos=(now+a[now])%n;
		inDeg[nextPos]--;
		if(inDeg[nextPos]==0){
			// now の次の地点のinDeg==1なら、ループしてない点からしか繋がってない
			// すなわち、nextPosもループ不能
			Q.push(nextPos);
		}
	}

	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 3860
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <deque>
#include <algorithm>
#include <random>
#include <ctime>
using namespace std;

#define pb push_back
#define pbb pop_back
#define pf pop_front
#define pff push_front
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

const int INF = 5e5, MOD = 1e9 + 7;
const ld EPS = 1e-9, PI = acos(-1);

string names[3];

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    names[0] = "Male";
    names[1] = "Female";
    names[2] = "Vacant";

    int n, good[2];
    string now;
    cin >> n;

    cout << 0 << endl;
    cin >> now;
    if (now == names[2])
        return 0;
    else if (now == names[0]) {
        good[0] = 0;
        good[1] = 1;
    }
    else {
        good[0] = 1;
        good[1] = 0;
    }

    int left = 1, right = n;
    while (right - left > 1) {
        int middle = (left + right) / 2;
        cout << middle << endl;
        cin >> now;

        if (now == names[2])
            return 0;
        if (names[good[middle & 1]] == now)
            left = middle;
        else
            right = middle;
    }

    cout << left << endl;
    cin >> now;
    if (now == names[2])
        return 0;
    cout << right << endl;
    cin >> now;

    return 0;
}


Measured memory_bytes: 852
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
int main(){
    int h,w;
    while(cin >> h >> w){
        if(!h && !w) break;

        vector<string> map(h);
        rep(i,h) cin >> map[i];

        int i = 0, j = 0;
        while(1){
            if(map[i][j] == 'x'){
                cout << "LOOP" << endl;
                break;
            }
            if(map[i][j] == '.'){
                cout << j << " " << i << endl;
                break;
            }
            if(map[i][j] == '>'){
                map[i][j] = 'x';
                j++;
                continue;
            }
            if(map[i][j] == '<'){
                map[i][j] = 'x';
                j--;
                continue;
            }
            if(map[i][j] == '^'){
                map[i][j] = 'x';
                i--;
                continue;
            }
            if(map[i][j] == 'v'){
                map[i][j] = 'x';
                i++;
                continue;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3104