akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(){
  long long n,m,i,a,b,s=0,c;
  scanf("%lld %lld",&n,&m);
  scanf("%lld",&a);
  if(a>m){
    s+=a-m;
    a=m;
  }
  while(--n){//printf("%d\n",s);
    scanf("%lld",&b);
    c=0;
    if(a+b>m)c=a+b-m;
    s+=c;
    a=b-c;
  }
  printf("%lld\n",s);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e9;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n, K; cin >> n >> K;
    deque<ll> deq;
    rep(i, n){
        ll v; cin >> v;
        deq.push_back(v);
    }

    ll ans = 0;

    for(ll i = 0; i <= K; i++){
        for(ll j = 0; j <= K - i; j++){
            deque<ll> que = deq;
            priority_queue<int, vector<int>, greater<int>> pq;

            for(ll k = 0; k < i; k++){
                if(!que.empty()){
                    pq.push(que.front());
                    que.pop_front();
                }else{
                    break;
                }
            }
            for(ll k = 0; k < j; k++){
                if(!que.empty()){
                    pq.push(que.back());
                    que.pop_back();
                }else{
                    break;
                }
            }

            //discard
            for(ll k = 0; k < K - i - j; k++){
                if(!pq.empty()){
                    ll now = pq.top();
                    if(now < 0){
                        pq.pop();
                    }else{
                        break;
                    }
                }
            }

            //calc
            ll tmp = 0;
            while(!pq.empty()){
                tmp += pq.top();
                pq.pop();
            }
            ans = max(ans, tmp);
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define dbug printf("I am here\n");
#define Fast ios_base::sync_with_stdio(false); cin.tie(0);
static const long double pi = 3.141592653589793;

const unsigned ll int k = 1e18;
using namespace std;
ll ar[8005];
bool mark[8005];


int main() {
    Fast;

   ll unsigned int n,m,tst;
    string s;
    cin>>n;
    vector<ull>v(n);

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

    __int128 ans = 1;
   for(int i =0; i<n; i++){
     ans *= v[i];
     if(ans  > k){
        cout<<"-1"<<endl;
        return 0;
     }
   }
   cout<<(ll)ans<<endl;

    return 0;
}


Measured memory_bytes: 3988
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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; }

int main() {
  ll n, m;
  cin >> n >> m;
  ll ans = (n-2)*(m-2);
  ans = abs(ans);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
INF = float("inf")
import sys
sys.setrecursionlimit(10000)


def solve(N, S):
    if "Y" in S:
        return "Four"
    else:
        return "Three"


def main():
    N = int(input())
    S = list(input().split())
    print(solve(N, S))


if __name__ == '__main__':
    main()


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

int main() {
    int N;
    int check=1;
    ll count=0;
    cin>>N;
    vector<int> h(N);
    rep(i,N){cin>>h[i];}
    while(1){
      bool s_flg=false;
      bool all_end_flg=true;
      rep(i,N){
        if(!s_flg){
        	if(h[i]>=check){
              s_flg=true;
              all_end_flg=false;
            }
        }else{
            if(h[i]<check){
              s_flg=false;
              count++;
            }
        }
      }
      if(s_flg)count++;//
      if(all_end_flg)break;
      else{
        check++;
        s_flg=false;
      }
    }//while
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<cstring>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
#define rep(x,a,b) for(int x=a;x<=b;x++)
#define drep(x,a,b) for(int x=a;x>=b;x--)
#define rush() int T;scanf("%d",&T);while(T--)
#define wash(x,y) memset(x,y,sizeof(x));

const int maxn=1e5+5;
int fa[maxn],dd[maxn],n,m;

//并查集初始化
//！！！注意i的起点
void init(){
	for(int i=1;i<=n;i++){
		fa[i]=i;
		dd[i]=0;
	}
}
//并查集路径压缩寻找根节点
int find(int x){
	if(x==fa[x]) return x;
	else{
		int tmp=fa[x];
		fa[x]=find(tmp);
		dd[x]=dd[x]+dd[tmp];
		return fa[x];
	}
}
//并查集合并
bool merge(int x,int y,int d){
	int fx=find(x),fy=find(y);
	if(fx==fy) return (dd[y]-dd[x]==d);
	else{
		fa[fx]=fy;
		dd[fx]=dd[y]-dd[x]-d;
		return true;
	}
}

int main(){
	int l,r,d;
	bool flag=true;
	scanf("%d%d",&n,&m);
	init();
	rep(i,1,m){
		scanf("%d%d%d",&l,&r,&d);
		if(flag&&!merge(l,r,d)) flag=false;
	}
	printf(flag?"Yes":"No");
}

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

int main() {
  int a[] = {0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};
  int x, y;
  cin >> x >> y;
  if(a[x-1] == a[y-1]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int ans=0;
  string S;
  cin>>S;
  
  for(int i=0; i<6; ++i) if(S.at(i)=='1') ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
import math

a, b, x = (int(_) for _ in input().split())

L3 = b * (a**2)
x2  = L3 - x

if x >= x2:
    h = 2 * (x2 / (a**2))
    print(math.degrees(math.atan(h/a)))
else:
    h = 2 * (x  / (a*b))
    print(90-math.degrees(math.atan(h/b)))


Measured memory_bytes: 3060
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

int main() {
    int D;
    cin >> D;
    vector<int> c(26);
    for (int i = 0; i < 26; i++) cin >> c[i];
    vector<vector<int>> s(D, vector<int>(26));
    for (int i = 0; i < D; i++) {
        for (int j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    int ans = 0;
    vector<int> last(26, -1);
    for (int i = 0; i < D; i++) {
        int mx = -(1 << 30), idx = 0;
        for (int j = 0; j < 26; j++) {
            int tmp = s[i][j];
            for (int k = 0; k < 26; k++) {
                if (j == k) continue;
                tmp -= c[k] * (i - last[k]);
            }
            if (tmp > mx) {
                mx = tmp;
                idx = j;
            }
        }
        ans += mx;
        last[idx] = i;
        cout << idx + 1 << endl;
    }
    return 0;
}

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

int N;
const int MAX_N = 1.0e5 + 100;
int h[MAX_N];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) cin >> h[i];
    
    int dp[N];
    dp[0] = 0;
    dp[1] = abs(h[1] - h[0]);
    for (int i = 2; i < N; i++) {
        dp[i] = min(abs(h[i] - h[i-1]) + dp[i-1], abs(h[i] - h[i-2]) + dp[i-2]);
    }

    cout << dp[N-1] << endl;    

    return 0;
}


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

map<int,int> m;
vector<int> v;

int main(){
    int n,ans;
    cin>>n;
    for(register int i=1;i<=n;++i){
        int x;
        cin>>x;
        if(m[x]==0) v.push_back(x);
        ++m[x];
    }
    for(register int i=0;i<v.size();++i) if(m[v[i]]>=v[i]) ans+=m[v[i]]-v[i]; else ans+=m[v[i]];
    cout<<ans;
    return 0;
}


Measured memory_bytes: 5112
#include<iostream>
#include<bitset>
#include<string>
using namespace std;
bool iseven(int x){ return x % 2 == 0; }
bool isodd(int x){ return !iseven(x); }

int dist(int x, int y) { return abs(x - y); }
int main(){
    int A, B;
    cin >> A >> B;
    int ncakes = 16;
    // 方針：単純に奇数番目にAを偶数番目にBを割り当ててやればよいはず
    if ((A > ncakes / 2) || (B > ncakes / 2)){ cout << ":("; }
    else { cout << "Yay!"; }
    return 0;
}


Measured memory_bytes: 764
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;

public class Main {

	private BufferedReader br;
	private BufferedWriter bw;
	private StringTokenizer st;
	private int a;
	private int b;
	private int c;
	private int sum;
	private boolean check;
	public static void main(String[] args) throws IOException {
		new Main().start();
	}

	void start() throws IOException {

		br = new BufferedReader(new InputStreamReader(System.in));
		bw = new BufferedWriter(new OutputStreamWriter(System.out));
		st = new StringTokenizer(br.readLine());
		
			a=Integer.parseInt(st.nextToken());
			b=Integer.parseInt(st.nextToken());
			c=Integer.parseInt(st.nextToken());
			sum=a;
			for(int i=0;i<=b;i++){
				if(sum%b==c){
					bw.write("YES");
					check=true;
					break;
				}
				sum+=a;
			}
			if(!check){
				bw.write("NO");
			}
			
		bw.flush();
		br.close();
		bw.close();
	}

}


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

typedef long long ll; 
typedef pair<int, int> pii; 
typedef pair<ll, ll> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef vector<pii> vii; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 

double EPS=1e-9; 
int INF=1000000005; 
long long INFF=1000000000000000005ll; 
double PI=acos(-1); 
int dirx[8]={ -1, 0, 0, 1, -1, -1, 1, 1 }; 
int diry[8]={ 0, 1, -1, 0, -1, 1, -1, 1 }; 
const ll MOD = 1000000007;

#define DEBUG fprintf(stderr, "====TESTING====\n") 
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl 
#define OUT(x) cout << x << endl 
#define OUTH(x) cout << x << " " 
#define debug(...) fprintf(stderr, __VA_ARGS__) 
#define READ(x) for(auto &(z):x) cin >> z;
#define FOR(a, b, c) for (int(a)=(b); (a) < (c); ++(a)) 
#define FORN(a, b, c) for (int(a)=(b); (a) <= (c); ++(a)) 
#define FORD(a, b, c) for (int(a)=(b); (a) >= (c); --(a)) 
#define FORSQ(a, b, c) for (int(a)=(b); (a) * (a) <= (c); ++(a)) 
#define FORC(a, b, c) for (char(a)=(b); (a) <= (c); ++(a)) 
#define EACH(a, b) for (auto&(a) : (b)) 
#define REP(i, n) FOR(i, 0, n) 
#define REPN(i, n) FORN(i, 1, n) 
#define MAX(a, b) a=max(a, b) 
#define MIN(a, b) a=min(a, b) 
#define SQR(x) ((ll)(x) * (x)) 
#define RESET(a, b) memset(a, b, sizeof(a)) 
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back 
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define SIZE(v) (int)v.size() 
#define SORT(v) sort(ALL(v)) 
#define REVERSE(v) reverse(ALL(v)) 
#define SORTA(arr, sz) sort(ALLA(arr, sz)) 
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz)) 
#define PERMUTE next_permutation 
#define TC(t) while (t--) 
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)


void solve() {
    
}

int main()  
{ 
    FAST_INP;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r", stdin);
    freopen("output.txt","w", stdout);
    #endif
    
    int n,x,t;
    cin >> n >> x >> t;
    int k = (n/x)+(n%x?1:0);
    OUT(k*t);

    return 0; 
} 


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

int main(){
    ll n,p=1;
    cin>>n;
    for(int i=1;i<=n;i++){
        p*=i;
        p%=1000000007;
    }
    cout<<p<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a, b;
  bool flag = true;
  cin >> a >> b;
  rep(i, 1, 10000) {
    if ((int)(i * 0.08) == a & (int)(i * 0.1) == b) {
      cout << i << endl;
      flag = false;
      break;
    }
  }
  if (flag) cout << -1 << endl;
}

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

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1e9+7
using namespace std;
typedef long long ll;

int main(){
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int half = C * 2;
    int ab = A + B;

    if(half>=ab){
        cout << A * X + B * Y;
    }else{
        int sum = 0;
        if(X>Y){
            sum += Y * half;
            int num = X - Y;
            sum += num * min(A, half);
        }else{
            sum += X * half;
            int num = Y - X;
            sum += num * min(B, half);
        }
        cout << sum;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>

int main(){
	long N, T, i;
	scanf("%ld %ld", &N, &T);
	long A[N] , min = pow(10, 9), max = 0, change = 1;
	long min1 = min;
	
	
	for(i = 0; i < N; i ++){
		scanf("%ld" , &A[i]);
		if(A[i] < min){
			min = A[i];
			continue;
		}
		if(A[i] - min == max) change ++;
		
		if(A[i] - min > max){
			max = A[i] - min;
			change = 1;
		}
		
		
}
	
	printf("%ld\n" ,change);
	return 0;
}


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

int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int gdb(int i, int j, int l){
    int x,y;
    x = gcd(i,j);
    y = gcd(x,l);
    return y;
}

int main(){
    int k;
    cin >> k;
    long long sum = 0;
    for (int i = 1; i < k+1; i++){
        for (int j = 1; j < k+1; j++){
            for (int l = 1; l < k+1; l++){
                sum = sum + gdb(i,j,l);
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3636
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,w,z;
    char ca,cb,cc;
    cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b))<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

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;
}

const int a=0,b=1,c=2;

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n; cin>>n;
    vi s[3];
    vl dp[3];
    REP(i,3){
        s[i].resize(n);
        dp[i].resize(n+5);
        fill(ALL(dp[i]), -1);
    }
    
    REP(i,n){
        cin>>s[a][i]>>s[b][i]>>s[c][i];
    }
    dp[a][0] = s[a][0];
    dp[b][0] = s[b][0];
    dp[c][0] = s[c][0];

    REP(i,n-1){
        dp[a][i+1] =  s[a][i+1] + max(dp[b][i], dp[c][i]);
        dp[b][i+1] =  s[b][i+1] + max(dp[c][i], dp[a][i]);
        dp[c][i+1] =  s[c][i+1] + max(dp[a][i], dp[b][i]);
    }
    // DEBUG_ARR(dp[a],n+1);
    // DEBUG_ARR(dp[b],n+1);
    // DEBUG_ARR(dp[c],n+1);

    ll ans = 0;
    ans = max(dp[a][n-1], dp[b][n-1]);
    ans = max(ans, dp[c][n-1]);

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

Measured memory_bytes: 3840
package main

import "fmt"

func main() {
	var _n, _a, _b int
	fmt.Scan(&_n, &_a, &_b)
	ans := exec(_n, _a, _b)
	fmt.Println(ans)
}

func exec(n, a, b int) int {
	result := 0
	for i := 0; i <= n; i++ {
		sum := 0
		div := i
		for div > 0 {
			sum += div % 10
			div /= 10
		}
		if sum >= a && sum <= b {
			result += i
		}
	}
	return result
}


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

int main(){
  int year[] = {1868,1912,1926,1989};
  int month[] = {9,7,12,1};
  int day[] = {8,30,25,8};
  string gen[] = {"pre-meiji","meiji","taisho","showa","heisei"};
  int y,m,d;
  while(cin >> y >> m >> d){
    bool flg = true;
    for(int i=3;i>=0;i--){
      if(y > year[i]){
	cout << gen[i+1] << " ";
	cout << y - year[i] + 1 << " " << m << " " << d << endl;
	flg = false;
	break;
      }
      else if(y == year[i] && m >= month[i]){
	if(m > month[i]){
	  cout << gen[i+1] << " ";
	  cout << y - year[i] + 1 << " " << m << " " << d << endl;
	  flg = false;
	  break;
	}
	else if(m == month[i] && d >= day[i]){
	  cout << gen[i+1] << " ";
	  cout << y - year[i] + 1 << " " << m << " " << d << endl;
	  flg = false;
	  break;
	}
      }
    }
    if(flg) cout << gen[0] << endl;
  }
}
  
	

Measured memory_bytes: 1204
#include"bits/stdc++.h"
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define ld           long double
#define vi           vector<int>
#define pii          pair<int,int>
#define pb           push_back
#define mp           make_pair
#define ff           first
#define ss           second
#define endl         '\n'
#define rep(i,s,e)   for(int i=(s);i<=(e);i++)
#define brep(i,s,e)  for(int i=(s);i>=(e);i--)
#define all(x)       (x).begin(),(x).end()
#define ball(x)      (x).rbegin(),(x).rend()
#define sz(x)        (int)x.size()
#define mem(x,y)     memset(x,y,sizeof(x))
#define milf(x)      x.reserve(1LL<<14LL); x.max_load_factor(0.25); // less_equal
#define pbds         tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
mt19937              rng(chrono::steady_clock::now().time_since_epoch().count());
#define int          long long
const int INF = 0x3F3F3F3F3F3F3F3F;
const int MOD = 1e9+7;
ld EPS = 1e-12;


short rain()
{
    // ifstream fin("ip.txt"); ofstream fout("op.txt");
    // int t;cin>>t;rep(test,1,t)
    {
        int a, b, c, k;
        cin >> a >> b >> c >> k;
        int sm = 0;
        int x = min( a, k );
        sm += x;
        a -= x, k -= x;
        if( k==0 )
            return cout << sm << endl, 0;
        x = min( b, k );
        b -= x, k -= x;
        if( k==0 )
            return cout << sm << endl, 0;
        x = min( c, k );
        sm += (-x);
        c -= x, k -= x;
        if( k==0 )
            return cout << sm << endl, 0;
    }

    return 0;
}

signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int start = 1000*clock()/CLOCKS_PER_SEC;
    cout << fixed << setprecision(15);           rain();
    cerr << 1000*clock()/CLOCKS_PER_SEC-start << "ms\n";
}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = ReadArrayInt();
            var N = input[0];
            var M = input[1];
            var ks = new List<int>[M].Select(l => new List<int>()).ToList();
            for (int i = 0; i < M; i++)
            {
                input = ReadArrayInt();
                var k = input[0];
                for (int j = 0; j < k; j++)
                {
                    ks[i].Add(input[j + 1]);
                }
            }
            var p = ReadArrayInt();            

            var ans = 0;
            for (int i = 0; i < 1 << N; i++)
            {
                var suc = true;
                for (int j = 0; j < M; j++)
                {
                    var cnt = 0;
                    for (int k = 0; k < ks[j].Count(); k++)
                    {
                        var chk = (1 << (ks[j][k] - 1)) & i;
                        if (chk != 0) cnt++;
                    }
                    if (cnt % 2 != p[j])
                    {
                        suc = false;
                        break;
                    }
                }
                if (suc) ans++;
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

Measured memory_bytes: 13524
s = input()
#l = s.__len__()
ans = 0
gt = 0
pt = 0

for i in s:
    if i == "g" and gt > pt:
        ans += 1
        pt += 1
    elif i == "g":
        gt += 1
    elif i == "p" and gt > pt:
        pt += 1
    else:
        ans -= 1
        gt += 1
print(ans)


Measured memory_bytes: 3316
s = gets.strip.split('').reverse.map {|c| c=='?' ? nil : c.to_i}
N=13
MOD = 10**9+7

dp = Array.new(13,0)
dp[0] = 1
mul=1
a09 = (0..9).to_a

#p s

s.each do |current_c|
  next_dp = Array.new(13,0)

  (current_c.nil? ? a09 : [current_c]).each do |candidate|

    bigger = candidate*mul
    N.times do |previous|
        next_dp[(bigger + previous)%N] += dp[previous]
    end
  end
  mul = mul * 10 % N
  dp=next_dp.map {|v| v%MOD }

#p dp
end

p dp[5]


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

P f(int x){
    int a = x%10;
    int b = 0;
    while (x){
        b = x;
        x /=10;
    }
    return P(a, b);
}


int main(){
    int n;
    cin >> n;
    map <P,int> freq;
    for (int i = 1; i <= n; ++i){
        P p = f(i);
        freq[p]++;
    }
    ll ans = 0;
    for ( int i = 1; i <=n; ++i){
        P p = f(i);
        P q(p.second, p.first);
        ans += freq[q];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main(){
	var k,n,temp int
	fmt.Scan(&k,&n)
	a := make([]int,n)
	for i:= 0 ; i<n ; i++ {
		fmt.Scan(&a[i])
	}
	if a[n-1]-a[0] <= k/2 {
		fmt.Println(a[n-1]-a[0])
	} else {
		ans := k
		for i:=0 ; i<n-1 ; i++ {
			if i == 0 {
				temp_a := k - (a[1] - a[0])
				temp_b := a[n-1] - a[0]
				if temp_a < temp_b {
					ans = temp_a
				} else {
					ans = temp_b
				}
			} else {
				temp_a := k - (a[i+1] - a[i])
				temp_b := k - (a[i] - a[i-1])
				if temp_a < temp_b {
					temp = temp_a
				} else {
					temp = temp_b
				}
				if temp < ans {
					ans = temp
				}
			}
		}
		fmt.Println(ans)
	}
}


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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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;
}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    ll k; cin >> k;
    vector<ll> anslis(50, 49);
    ll c = k / 50;
    ll mid = k % 50;
    REP(i, 0, 50){
        anslis[i] += c;
    }
    REP(i, 0, mid){
        REP(l, 0, 50){
            if(i == l){
                anslis[l] += 50;
            }else{
                anslis[l]--;
            }
        }
    }
    cout << 50 << endl;
    REP(i, 0, 50){
        cout << anslis[i] << " ";
    }
}

Measured memory_bytes: 3628
s = input()
t = input()
nt = len(t)
def check(a,b):
    cnt = 0
    for sa,sb in zip(a,b):
        if sa != sb:
            cnt += 1
    return cnt
ans = 1 << 50
for i in range(nt,len(s)+1):
    s_p = s[i-nt:i]
    # print(s_p,t)
    ans = min(check(s_p,t),ans)
print(ans)

Measured memory_bytes: 9124
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
using namespace std;

typedef long long ll;
typedef double db;
typedef long double ldb;

template<class T> inline void checkmin(T &a,const T &b){if(b<a) a=b;}
template<class T> inline void checkmax(T &a,const T &b){if(b>a) a=b;}

const int inf=1e9+10;

map <string,int> Map;
int n;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		Map[s]=1;
	}
	cout<<Map.size()<<endl;
	return 0;
}


Measured memory_bytes: 19148
#include<stdio.h>

int main(){
	
	int n,c[101][2][7],z,Z,x;
	
	scanf("%d",&n);
	
	for(int i=0;i<n;i++){
		for(int t=0;t<6;t++){
			scanf("%d",&c[i][1][t]);
			c[i][0][t]=t;
		}
	}
	
	for(int p=0;p<n-1;p++){
		for(int s=p+1;s<n;s++){
			
			///????????????????????????///
			
			for(int i=0;i<6;i++){
				
				///??????c[s][1][i]?????????///
				
				for(int t=0;i!=c[s][0][0];t++){
					if(t==4) break;
					z=c[s][0][0];
					Z=c[s][1][0];
					c[s][0][0]=c[s][0][4];
					c[s][1][0]=c[s][1][4];
					c[s][0][4]=c[s][0][5];
					c[s][1][4]=c[s][1][5];
					c[s][0][5]=c[s][0][1];
					c[s][1][5]=c[s][1][1];
					c[s][0][1]=z;
					c[s][1][1]=Z;
				}
				if(i!=c[s][0][0]){
					for(int t=0;i!=c[s][0][0];t++){
						if(t==4) break;
						z=c[s][0][0];
						Z=c[s][1][0];
						c[s][0][0]=c[s][0][2];
						c[s][1][0]=c[s][1][2];
						c[s][0][2]=c[s][0][5];
						c[s][1][2]=c[s][1][5];
						c[s][0][5]=c[s][0][3];
						c[s][1][5]=c[s][1][3];
						c[s][0][3]=z;
						c[s][1][3]=Z;
					}
				}
				///a[]??¨????????????????????´??¢?????????///
				
				for(int t=0;t<4;t++){
					x=0;
					for(int t=0;t<6;t++){
						if(c[p][1][t]!=c[s][1][t]){
							x++;
						}
					}
					//printf("%d\n",x);
					if(x==0) break;
					
					Z=c[s][1][1];
					c[s][1][1]=c[s][1][3];
					c[s][1][3]=c[s][1][4];
					c[s][1][4]=c[s][1][2];
					c[s][1][2]=Z;
				}
				if(x==0) break;
			}
			if(x==0) break;
		}
		if(x==0) break;
	}
	if(x==0){
		printf("No\n");
	}
	else printf("Yes\n");
	return 0;
}

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

int main(){
    int ans[100000]={0};
    for(int i=1;i<=100;i++){
        for(int j=1;j<=100;j++){
            for(int k=1;k<=100;k++){
                ans[((i+j)*(i+j)+(i+k)*(i+k)+(j+k)*(j+k))/2]++;
            }
        }
    }
    int n;cin>>n;
    for(int i=1;i<=n;i++) cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 3984
#include <bits/stdc++.h>
using namespace std;
 
int main() {
string n;
  cin >> n;
  if (n[1]==n[2]){
    if (n[1]==n[0]||n[2]==n[3]){
    cout<< "Yes" <<endl;
    }
    else{
          cout<< "No"<<endl;
  }
  }
  else{
    cout<< "No"<<endl;
}
}

Measured memory_bytes: 256
inf = float("inf")


class Node():

    def __init__(self, _id):
        self.id = _id
        self.d = inf
        self.pi = None
        self.color = 0
        self.adj = {}

    def input_data(self, data):
        k = data[0]
        for i in range(k):
            self.adj[G[data[2 * i + 1]]] = data[2 * i + 2]

    def __hash__(self):
        return hash(self.id)

def dijkstra():
    while True:
        mincost = inf
        for i in G:
            if i.color != 1 and i.d < mincost:
                mincost = i.d
                u = i
        if mincost == inf:
            break
        u.color = 1
        for v in u.adj.keys():
            if v.color != 1 and u.d + u.adj[v] < v.d:
                v.pi = u
                v.d = u.d + u.adj[v]

if __name__ == "__main__":
    n = int(input())
    G = [Node(i) for i in range(n)]
    for _ in range(n):
        data = [int(i) for i in input().split()]
        G[data[0]].input_data(data[1:])
        if data[0] == 0:
            G[data[0]].d = 0
    dijkstra()
    [print(i.id, i.d) for i in G]


Measured memory_bytes: 6012
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

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


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <math.h>
#include <stdlib.h>
#define LL long long
#define num 100000
using namespace std;

int main(){
  LL N,i,cnt;
  scanf("%lld",&N);
  cnt=0;
  for(i=1;i<=N;i++){
   
    if(1<=i&&i<10){
     cnt++;
    }else if(100<=i&&i<1000){
     cnt++;
    }else if(10000<=i&&i<100000){
     cnt++;
    }
  }
 
  
  printf("%lld",cnt);
     return 0;
  
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  int count = 0;
  for (int i = 0; i <= A; i++) {
    for (int j = 0; j <= B; j++) {
      for (int k = 0; k <= C; k++) {
        if (500 * i + 100 * j + 50 * k == X) {
          count = count + 1;
        }
      }
    }
  }
  cout << count << endl;
}
          

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

struct edge{ int u,v,cost;};
vector<edge> E;
int n;

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};


bool comp(const edge& e, edge& f){
    return e.cost < f.cost;
}


int main(){
    cin >> n;
    rep(i,n){
        rep(j,n){
            int c ; cin >> c;
            if(c!=-1){
                edge e = {i,j,c};
                E.push_back(e);
            }
        }
    }
    UnionFind T(n);
    sort(E.begin(),E.end(),comp);
    ll res = 0;
    rep(i,E.size()){
        edge e = E[i];
        if(T.find(e.u)!=T.find(e.v)) {
            T.unite(e.u,e.v);
            res+=e.cost;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 3208
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int dy[8] = {1,0,-1,0,1,-1,1,-1};
//////////////////////////////////


int main() {
    long long n, k; cin >> n >> k;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    long long ans = 0;
    long long cnt = 0;
    for(int i=0; i<n; i++) {
        for(int j=i+1; j<n; j++) {
            if(a[i] > a[j]) cnt++;
        }
    }
    ans += (cnt * k)%mod;

    cnt = 0;
    for(int i=0; i<n; i++) {
        for(int j=0; j<n; j++) {
            if(a[i] > a[j]) cnt++;
        }
    }
    long long num = ((k*(k-1))/2)%mod;
    ans += (cnt * num)%mod;
    ans %= mod;
    cout << ans << endl;
    
    return 0;
}




// EOF


Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n: usize =  read_as_vec()[0];
    let x = read_as_vec::<i64>();

    let p = x.iter().map(|v| *v as f64).sum::<f64>() / n as f64;
    let p = p.round() as i64;

    let hp_lost = x.into_iter().map(|x| (x-p)*(x-p)).sum::<i64>();

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


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;
const double PI = acos(-1);

int main(){
	char c[256];
	c['('] = ')';
	c[')'] = '(';
	c['['] = ']';
	c[']'] = '[';
	c['{'] = '}';
	c['}'] = '{';
	string s;
	cin>>s;
	string l, r;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'i'){
			l = s.substr(0, i);
			r = s.substr(i+3);
			break;
		}
	}
	//cout<<l<<" "<<r<<endl;
	int ans = 3;
	if(l.size() > r.size()) swap(l, r);
	reverse(all(r));
	for(int mask = 1; mask < (1<<l.size()); mask++){
		int idx = 0, t = 0;
		bool f = false;
		for(int i = 0; i < l.size(); i++){
			if((mask&(1<<i)) == 0) continue;
			t++;
			while(idx < r.size() && r[idx] != c[l[i]]) idx++;
			if(idx >= r.size()){
				f = true;
				break;
			}
			idx++;
		}
		if(f) continue;
		ans = max(ans, t*2+3);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1192
import sys, math, itertools, bisect, copy, re, heapq
from collections import Counter, deque, defaultdict
from itertools import accumulate, permutations, combinations, takewhile, compress, cycle

# from functools import reduce
# from math import ceil, floor, log10, log2, factorial
# from pprint import pprint


INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)

# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))

N = int(input())
A = [int(x) for x in input().split()]

# -1:減少、0:維持、+1：増加
mode = 0
cnt = 0

last = A[0]
for a in A:
    # print("{} -> {} : mode:{}".format(last, a, mode))
    if mode == 0:
        if last < a:
            mode = +1
        elif last > a:
            mode = -1
        else:
            pass
    elif mode == +1:
        if last <= a:
            pass
        else:
            cnt += 1
            mode = 0
    else:
        if last >= a:
            pass
        else:
            cnt += 1
            mode = 0
    last = a

print(cnt+1)


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

typedef long long ll;



int main() {
	int N; cin >> N;
	vector<int>A(N); 
	vector<int>B(N);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		B[i] = A[i] - (i + 1);
	}
	sort(B.begin(), B.end());

	int b = 0; B.size() % 2 == 0 ? b = (B[B.size() / 2] + B[B.size() / 2 - 1]) / 2 : b = B[B.size() / 2];
	ll sum = 0;
	for (int i = 0; i < N; i++) {
		sum += abs(B[i] - b);
	}
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 1792
from math import gcd
from functools import reduce
 
 
def facs(n):
    yield 2
    for x in range(3, n, 2):
        yield x
 
 
def main():
    input()  # N
    array = [int(x) for x in input().split()]
    MAX_A = 10 ** 6 + 1
    histogram = [0] * MAX_A
    for x in array:
        histogram[int(x)] += 1
 
    for divider in facs(MAX_A):
        count = sum(histogram[divider::divider])
        if count > 1:
            break
    else:
        return 'pairwise coprime'
 
    gcd_total = reduce(gcd, array)
    if gcd_total == 1:
        return 'setwise coprime'
    else:
        return 'not coprime'
 
 
if __name__ == '__main__':
    print(main())

Measured memory_bytes: 133172
S = input()
count = dict()
for c in S:
    if c in count:
        count[c] += 1
    else:
        count[c] = 1

yes = True
for e in count.values():
    if e % 2 != 0:
        yes = False
        break
        
if yes:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 8976
#include<iostream>

using namespace std;

int main() {
	char x[3][3];
	int i, j;
	
	for (i = 0; i < 3; i++) {
		for (j = 0; j < 3; j++) {
			cin >> x[j][i];
		}
	}
	for (i = 0; i < 3; i++) {
		for (j = 0; j < 3; j++) {
			if (i == j) {
				cout << x[i][j];
			}
		}
	}
  return 0;

}

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

if N % 2:
    index = list(range(N - 1, -1, -2)) + list(range(1, N, 2))
else:
    index = list(range(N - 1, 0, -2)) + list(range(0, N, 2))

print(*list(map(lambda i: A[i], index)))


Measured memory_bytes: 26020
from itertools import accumulate

N, K, *A = map(int, open(0).read().split())

S = []
for i in range(N):
    S += [0] + list(accumulate(A[i:]))

ans = 0
for i in reversed(range(41)):
    b = 2 ** i
    T = [s for s in S if b & s != 0]
    if len(T) >= K:
        S = T
        ans += b

print(ans)

Measured memory_bytes: 27724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    ll x; cin>>x;
    int sum=0;
    for(int i=1;i<100000;i++){
        sum+=i;
        if(sum>=x){
            cout<<i<<endl;
            return 0;
        }
    }

}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
#define mp make_pair
#define pb push_back
bool sortbysec(const pair<string,int>&a,pair<string,int>&b)
{
    return (a.second>b.second);
}
pair<pair<string,int>,int>pa[120];
int main()
{
    int n;
    cin>>n;
    int i=0,a=n;
    while(n--)
    {
        string s;
        int p;
        cin>>s>>p;
        pa[i]=make_pair(make_pair(s,-p),i+1);
        i++;
    }
    sort(pa,pa+a);
    for(int i=0;i<a;i++)
        cout<<pa[i].second<<endl;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
long long bb[1005];
bool prime[1001];

const long long mod=1e9+7;
int main()
{
    int n;
    cin>>n;
    int i;
    int j;
    vector<long long>v;
    for(i=2;i<=1000;i++)
    {
        if(!prime[i])
        {
            v.push_back(i);
            for(j=2*i;j<=1000;j+=i)
            {
                prime[j]=1;
            }
        }
    }
    for(i=2;i<=n;i++)
    {
        for(j=0;j<v.size();j++)
        {
            if(i%v[j]==0)
            {
                long long d=i;
                while(d%v[j]==0)
                {
                    bb[v[j]]++;
                    d/=v[j];
                }
            }
        }
    }
    long long ans=1;
    for(i=1;i<=1000;i++)
    {
        ans=(ans%mod*(bb[i]+1)%mod)%mod;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
h,w=map(int,input().split())
n=int(input())
a=list(map(int,input().split()))
tmp=[]
for i in range(len(a)):
  for _ in range(a[i]):
    tmp.append(i+1)
ans=[]
for i in range(h):
  if i%2==0:
    print(*tmp[i*w:i*w+w])
  else:
    print(*list(reversed(tmp[i*w:i*w+w])))

Measured memory_bytes: 9468
# -*- coding:utf-8 -*-

def solve():
    import numpy as np
    import copy

    H, W, K = list(map(int, input().split()))
    Cs = []
    for _ in range(H):
        s = input()
        lst = []
        for moji in s:
            a = 0 if moji == "." else 1
            lst.append(a)
        Cs.append(lst)
    Cs = np.array(Cs)

    Hs = []
    for bits in range(1<<H):
        lst = []
        for i in range(H):
            lst.append(bits>>i&1)
        Hs.append(np.array(lst).reshape(H,1))

    Ws = []
    for bits in range(1<<W):
        lst = []
        for i in range(W):
            lst.append(bits>>i&1)
        Ws.append(np.array(lst))

    ans = 0
    oCs = Cs
    for hs in Hs:
        for ws in Ws:
            Cs = copy.deepcopy(oCs)
            # print(Cs)
            Cs *= ws
            Cs *= hs
            # print(ws)
            # print(hs)
            # print(Cs)
            # input()
            if Cs.sum() == K:
                ans += 1
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 27248
import java.util.Scanner;

class Main{
	public static void main(String arg[]) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		
		if( a*b % 2 == 0) {
			System.out.println("Even");
		}else {
			System.out.println("Odd");
		}
	}
}

Measured memory_bytes: 22612
# -*- coding: utf-8 -*-
# 整数の入力
N = int(input())
infos = []
for i in range(N):
  infos.append([int(s) for s in input().split()])

def check():
    c_t = 0
    c_x = 0
    c_y = 0
    for info in infos:
      n_t = info[0]
      n_x = info[1]
      n_y = info[2]

      d_t = n_t - c_t
      d_x = abs(n_x - c_x)
      d_y = abs(n_y - c_y)
      if d_t < (d_x + d_y):
        return "No"

      if (d_t - (d_x+d_y)) % 2 != 0:
        return "No"
      c_t = n_t
      c_x = n_x
      c_y = n_y
    return "Yes"

print(check())


Measured memory_bytes: 25692
import java.util.*;

class Main {
	Scanner sc;
	int N;
	int[] C;
	static final int MOD = 1000_000_007;
	
	private void calc() {
		sc = new Scanner(System.in);
		N = sc.nextInt();
		C = new int[N];
		for (int i = 0; i < N; i++) C[i] = sc.nextInt();
		Arrays.sort(C);
		long p = 1;
		for (int i = 0; i < N-2; i++) p = p * 2 % MOD;
		long pp = (N>1)?(p * 2 % MOD * 2 % MOD):2;
		
		long a = (N>1)?p*2%MOD:1;
		long sum = 0;
		long d = (N==1)?0:p;
		for (int i = 0; i < N; i++) {
			sum = (a*C[N-1-i]%MOD + sum)%MOD;
			a = (a + d)%MOD;
		}
		sum = sum * pp % MOD;
		
		System.out.println(sum);
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}


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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

// ダイクストラ法
// T: コスト (非負)
template<typename T>
class Dijkstra {
    struct edge {
        int to;
        T cost;
    };
    const int n;
    const T ZERO, INF;
    std::vector<std::vector<edge> > G;
public:
    // 頂点数と零元と十分大きな値を指定して初期化
    Dijkstra(int n, T ZERO, T INF) : n(n), ZERO(ZERO), INF(INF), G(n) {}

    // 始点、終点、コストを指定して辺を追加
    void addEdge(int from, int to, T cost) { G[from].push_back({to, cost}); }

    // 頂点sからの最短距離列を取得
    std::vector<T> getDist(int s) {
        typedef std::pair<T, int> P;
        std::priority_queue<P, std::vector<P>, std::greater<P> > pq;
        std::vector<T> d(n);
        std::fill(d.begin(), d.end(), INF);
        d[s] = ZERO;
        pq.push(P(ZERO, s));
        while (!pq.empty()) {
            P p = pq.top();
            pq.pop();
            int v = p.second;
            if (d[v] < p.first)continue;
            for (int i = 0; i < G[v].size(); i++) {
                edge e = G[v][i];
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    pq.push(P(d[e.to], e.to));
                }
            }
        }
        return d;
    }
};

int V, E, r;
int s[550000], t[550000], d[550000];

signed main() {
    cin >> V >> E >> r;
    Dijkstra<int> dij(V, 0, 1e12);
    for (int i = 0; i < E; i++) {
        cin >> s[i] >> t[i] >> d[i];
        dij.addEdge(s[i], t[i], d[i]);
    }
    vint d = dij.getDist(r);
    for (int i = 0; i < V; i++) {
        if (d[i] == 1e12)cout << "INF" << endl;
        else cout << d[i] << endl;
    }
}


Measured memory_bytes: 30904