akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    map<string, int> b, r;
    int N, M;
    cin >> N;
    rep(i, N) {
        string s;
        cin >> s;
        b[s]++;
    }
    cin >> M;
    rep(i, M) {
        string t;
        cin >> t;
        r[t]++;
    }

    int res = 0;
    for(auto &p: b) {
        int t = p.se - r[p.fi];
        res = max(res, t);
    }

    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
 
int main(){
  int A, B, C;
  
  scanf("%d %d %d", &A, &B, &C);
  
  A = (A + 12)%14;
  B = (B + 12)%14;
  C = (C + 12)%14;
  if(A > B){
    printf("Alice\n");
  } else if(A == B){
    printf("Draw\n");
  } else {
    printf("Bob\n");
  }
  
  return 0;
}

Measured memory_bytes: 128
H, W = map(int, input().split())

ans = min(H, W)

for h in range(H // 3, H // 3 + 3):
    w = W // 2
    s1 = h*W
    s2 = (H-h)*w
    s3 = (H-h)*(W-w)
    ans = min(ans, max(s1,s2,s3) - min(s1,s2,s3))

for w in range(W // 3, W // 3 + 3):
    h = H // 2
    s1 = w*H
    s2 = (W-w)*h
    s3 = (W-w)*(H-h)
    ans = min(ans, max(s1,s2,s3) - min(s1,s2,s3))
    
if H % 3 == 0 or W % 3 == 0:
    ans = 0
    
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[100001];
    FOR(i, 1, n){
        int buf;
        cin >> buf;
        a[i] = buf;
    }

    int i = 1;
    int ans = 0;
    while(true){
        if(a[i] == -1){
            cout << -1 << "\n";
            return 0;
        }
        if(i == 2) break;
        int temp = a[i];
        a[i] = -1;
        i = temp;
        ans++;
    }

    cout << ans << "\n";
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

struct position
{
    int x, y;
};

double dis(int x, int y){
    double res = sqrt(x * x + y * y);

    return res;
}

int main()
{
    int n;
    cin >> n;
    position a[10];
    rep(i, n){
        cin >> a[i].x >> a[i].y;
    }

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

    double ans = 0;
    do
    {
        rep(i, n-1){
            ans += dis(a[v[i]].x - a[v[i+1]].x, a[v[i]].y - a[v[i+1]].y);
        }
    } while (next_permutation(all(v)));
    
    rep(i, n){
        ans /= (i + 1);
    }

    cout << fixed << setprecision(10);
    cout << ans << "\n";


    return 0;
}


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

int main() {

	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int ans = 0;

	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			int value = x - 500 * i - 100 * j;
			if (value / 50 <= c && value >= 0)ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main(){
    cin>>a>>b;
    if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0])
	{
		cout<<"YES"<<endl;
	}
    else 
	{
		cout<<"NO"<<endl;
	}
    return 0;
}


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

int main(){
  int N; cin >> N;
  vector<int> a(N,0);
  for(int i = 0; i < N; i++){
    cin >> a.at(i);
  }
  long ans = 99999999999999;
  for(int i = -100; i <= 100; i++){
    long cost = 0;
    for(int j = 0; j < N; j++){
      cost += pow((i-a.at(j)),2);
    }
    ans = min(ans,cost);
  }
  cout << ans << endl;
}



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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;


int main() {
	int n;
	cin >> n;
	VLL a(n);
	REP(i, n)cin >> a[i];

	sort(ALL(a));

	ll tmp = 0;
	int res = 0;
	REP(i, n - 1) {
		if ((a[i] + tmp) * 2 < a[i + 1]) {
			res = i+1;
		}
		tmp += a[i];
	}
	cout << n - res << endl;

	return 0;

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
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; }
int main()
{
    int64_t N;
    cin >> N;
    vector<int64_t>vec(N);
    for (int64_t i=0; i<N; i++) {
        cin >> vec.at(i);
    }

    int64_t sum = 0;
    int64_t two_devided = 0;
    for (int64_t i=0; i<N; i++) {
        if (vec[i] % 4 == 0) {
            sum += 1;
        } else if (vec[i] % 2 == 0)  {
            two_devided += 1;
        }
    }

    int64_t hikaku = N / 2;
    if (two_devided > 0) {
        hikaku = (N - two_devided + 1) / 2;
    }

    if (sum >= hikaku) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3968
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

#define PI 3.141592

typedef struct{
  double x, y;
}XY;

void fractal(int,XY,XY);
void prt(XY);

int main(){
  int n;
  XY p1 = {0,0};
  XY p2 = {100,0};

  scanf("%d",&n);

  prt(p1);
  fractal(n, p1, p2);
  prt(p2);

  return 0;
}

void fractal(int n, XY p1, XY p2){
  XY s, t, u;

  if(n==0)
    return;

  s.x = (2*p1.x + 1*p2.x)/3;
  s.y = (2*p1.y + 1*p2.y)/3;
  t.x = (1*p1.x + 2*p2.x)/3;
  t.y = (1*p1.y + 2*p2.y)/3;
  u.x = (t.x-s.x)*cos(PI/3) - (t.y-s.y)*sin(PI/3) + s.x;
  u.y = (t.x-s.x)*sin(PI/3) + (t.y-s.y)*cos(PI/3) + s.y;

  fractal(n-1, p1,  s);
  prt(s);
  fractal(n-1,  s,  u);
  prt(u);
  fractal(n-1,  u,  t);
  prt(t);
  fractal(n-1,  t, p2);
}

void prt(XY p){
  printf("%f %f\n",p.x ,p.y);
}



Measured memory_bytes: 2040
import java.util.*;
public class Main {
    static Scanner sc = new Scanner(System.in);
    static boolean[] prime = new boolean[1000001];
    static int n;
    public static void main(String[] args) {
        makePrime();
        while(read()){
            solve();
        }

    }

    static void makePrime(){
        Arrays.fill(prime, true);
        prime[0] = false;
        prime[1] = false;
        for(int i = 2; i < prime.length; i++){
            if(prime[i]){
                for(int j = i*2; j < prime.length; j += i)prime[j] = false;
            }
        }
    }

    static boolean read(){
        n = sc.nextInt();
        if( n == 0 )return false;
        return true;
    }

    static void solve(){
        int res = 0;
        for(int i = 2; i <= n/2; i++){
            if(prime[n - i] && prime[i])res++;
        }
        System.out.println(res);
    }

}

Measured memory_bytes: 13000
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cstring>
#include <cmath>
#include <complex>
#include <map>
#include <climits>
using namespace std;

#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef long long ll;
typedef complex<double> CP;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
static const int INF=1<<24;


int main(){
	int y,m,d;
	ll sum;
	/*
	sum=20*5+19*5;
	sum*=2;
	sum+=20*10;
	sum*=333;
	cout<<sum<<endl;
	*/
	int n;
	cin>>n;
	rep(i,n){
		sum=196470;
		cin>>y>>m>>d;
		ll tmp=0;
		if(y%3==0){
			tmp+=(m-1)*20;
			tmp+=d-1;
		}
		else{
			reep(i,1,m){
				if(i%2==1) tmp+=20;
				else tmp+=19;
			}
			tmp+=d-1;
		}
		//cout<<"     "<<tmp<<endl;
		tmp+=590*(int)((y-1)/3);
		y--;
		y%=3;
		//cout<<tmp<<endl;
		tmp+=195*y;
		//cout<<tmp<<endl;
		cout<<sum-tmp<<endl;
	}
	
		
	return 0;
}

Measured memory_bytes: 1156
var
    s:ansistring;
    i,ans:longint;
begin
    readln(s);
    if(pos('1',s)=0)then
    begin
        writeln(0); 
        exit;
    end
    else
    begin
        for i:=1 to length(s) do
        begin
            if(s[i]='1')then inc(ans);
        end;
    end;
    writeln(ans);
end.


Measured memory_bytes: 128
#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 n;
  cin >> n;
  set<string> st;
  rep(i,n){
    string s;
    cin >> s;
    st.insert(s);
  }
  cout << st.size()<< endl;
  return 0;
}

Measured memory_bytes: 19176
#include <bits/stdc++.h>
#define N 4
using namespace std;
int main() {
  string S, T[N] = {"dream", "dreamer", "erase", "eraser"};
  cin >> S;
  bool valid;
  do {
    valid = false;
    for (int i = 0; i < N && !valid; i++) {
      if (S.length() >= T[i].length() && S.substr(S.length()-T[i].length()) == T[i]) {
        S.erase(S.length()-T[i].length());
        valid = true;
      }
    }
  } while (!S.empty() && valid);
  if (S.empty()) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}

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

import copy

n,m = list(map(int,input().split()))
rinset = [[0]*(n+1) for _ in range(n+1)]
for _ in range(m):
    a,b = list(map(int,input().split()))
    rinset[a][b]=b
    rinset[b][a]=a
cnt = 0
def solve(start,visitted):
    global cnt
    visitted = copy.deepcopy(visitted)
    visitted.append(start)
    if len(visitted) == n:
        cnt+=1
        return
    next_start=[i for i in rinset[start] if (i>1 and i not in visitted)]
    for i in next_start:
        solve(i,visitted)

solve(1,[])
print(cnt)


Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
 
int main(){
  int n;
  cin>>n;
  vector<int> a;
  for(int i=0;i<n;i++){
      int temp;
      cin>>temp;
      a.push_back(temp);
  }

  int i=1,br=0,f=0;
  for(auto itr=a.begin();itr!=a.end();itr++){
      if(i==*itr) i++;
      else br++;
      if(*itr==1) f=1;
  }
  if(f) cout<<br;
  else cout<<-1;
}

Measured memory_bytes: 1400
//#include "bits/stdc++.h"
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <complex>
#include <bitset>
#include <functional>
#include <stack>
#include <regex>
#include <tuple>
#include <iomanip>

#define int long long
#define REP(i,l,r) REPEAT(i,l,r,true) // [l, r)
#define rep(i,n) REP(i,0,n)           // [0, n)
#define REPEAT(i,l,r,condition) for(int i=(condition)?l:r-1;(condition)?i<r:i>=l;(condition)?++i:--i) // false<-[l, r)->true
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define fs first
#define sc second
#define show(...) cerr<<#__VA_ARGS__<<" = ";_DEBUG(__VA_ARGS__)
#define showlr(n,l,r) cerr<<#n<<" = ";for(int i=l;i<r;i++){cerr<<n[i]<<", ";}cerr<<endl // [l, r)

#define YN(condition) puts((condition)?"YES":"NO")
#define Yn(condition) puts((condition)?"Yes":"No")
#define yn(condition) puts((condition)?"yes":"no")
#define YES puts("YES")
#define Yes puts("Yes")
#define yes puts("yes")
#define NO  puts("NO")
#define No  puts("No")
#define no  puts("no")

#define case(i) printf("Case #%lld: ",i)

using namespace std;

using vi=vector<int>;
using pint=pair<int,int>;

struct io{io(){cin.tie(0);ios::sync_with_stdio(false);cout.tie(0);cout<<fixed<<setprecision(20);}}io;

template<class T> istream& operator >>(istream &is, vector<T> &v){for(T &e:v)is>>e;return is;}
template<class T> ostream& operator <<(ostream &os, vector<T> v){os<<"{";for(T &e:v)os<<e<<(v.size()-(int)(&e-&v[0])>1?", ":"");os<<"}";return os;}

void _DEBUG(){}
template<typename H,typename... T> void _DEBUG(H a,T...b){cerr<<a<<(sizeof...(b)?",":"\n");_DEBUG(b...);}

inline void in(){}
template<typename H,typename... T>void in(H &a, T&... b){cin>>a;in(b...);}
inline void out(){}
template<typename H,typename... T> void out(H a, T... b){cout<<a<<(sizeof...(b)?" ":"\n");out(b...);}

template<class T> void resz(int n,T& v){v.resize(n);}
template<class H,class... T> void resz(int n,H& a,T&... b){a.resize(n);resz(n,b...);}

template<typename V,typename H> void resize(vector<V>& v,const H a){v.resize(a);}
template<typename V,typename H,typename... T> void resize(vector<V>& v,const H& a,const T... b){v.resize(a);for(auto &v:v) resize(v,b...);}

const int INF=1LL<<55;
const int MOD=1000000007;
const double EPS=1e-8;

int ans;
int A,B;

signed main(){

    in(A,B);
    auto bit = [](int n){return 1LL<<n;};

    auto f = [](int t,int n){
        return t>=0?n==1?(t+1)/2%2:t/n%2&1&&t%2==0:0;
    };

    for(int i=0;i<=40;i++){
        int ares=f(A-1,bit(i));
        int bres=f(B,bit(i));
        ans+=(ares^bres)*bit(i);
    }

    out(ans);

    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i, n) for(int i = (int)(n); i >= 0; i--)
#define repm(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define repmr(i, m, n) for(int i = (int)(n); i >= (int)(m); i--)
#define all(x) (x).begin(),(x).end()
#define inf 2e9

using namespace std;
typedef long long int lli;
typedef long long ll;

int h,w;
vector<vector<char>> a(1000, vector<char>(1000));
vector<vector<bool>> isFilled(1000, vector<bool>(1000,false));
queue<vector<int>> q;
int ans;

vector<int> num_y = {1,-1,0,0};
vector<int> num_x = {0,0,1,-1};

int main() {
    cin >> h >> w;
    rep(i,h) rep(j,w){
        char c;
        cin >> c;
        a[i][j] = c;
        if(c == '#'){
            q.push({i,j,0});
            isFilled[i][j] = true;
        }
    }

    while(true){
        vector<int> now = q.front();
        q.pop();

        rep(i,4){
            int next_y = now[0] + num_y[i];
            int next_x = now[1] + num_x[i];
            
            if(next_y >= 0 && next_y < h && next_x >= 0 && next_x < w){
                if(a[next_y][next_x] == '.' && !isFilled[next_y][next_x]){
                    q.push({next_y, next_x, now[2]+1});
                    isFilled[next_y][next_x] = true;
                }
            }
        }

        if(q.size() == 0){
            ans = now[2];
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 56884
#include "bits/stdc++.h"

using namespace std;

//int N,M,K,L,R,H,W;
long long int N,M,K,L,R,H,W;

constexpr long long int MOD=1000000007;
//constexpr  int MOD=1000000007;
//constexpr int MOD=998244353;
//constexpr long long int MOD=998244353;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>N>>K;
	string s;
	cin>>s;
	int turn=0;
	int cnt=N;
	vector<int>ans;
	while(cnt){
		int nx=max(0LL,cnt-K);
		while(s[nx]=='1')nx++;
		if(cnt==nx){
			cout<<-1<<endl;
			return 0;
		}
		ans.push_back(cnt-nx);
		cnt=nx;
	}
	reverse(ans.begin(),ans.end());
	for(auto i:ans)cout<<i<<" ";
	cout<<endl;
} 

Measured memory_bytes: 1096
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
typedef long long int ll;
typedef long double ld;
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; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ld a,b;
    cin >> a >> b;
    ld c=a/8*10;
    if (b-c>1 or c-b>1){
        cout << -1 << endl;
        return 0;
    }
    for (ll i=0;i<a*15;i++){
        if (i*8/100>=a and a>i*8/100-1 and i/10>=b and b>i/10-1){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}



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

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()
#define clr(a,v) memset(a, v, sizeof(a))

#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, l, r) for (int i = (l); i >= (r); i--)
#define reflex ios_base::sync_with_stdio(false)

#define nl '\n'
#define ioi exit(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int N= (int)2e5 + 7;
const int inf = (int)1e9 + 7;
const int mod = (int)1e9 + 7;
const ll linf = (ll)1e18 + 7;

const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int kx[] = {-1,1,2,2,1,-1,-2,-2};
const int ky[] = {2,2,1,-1,-2,-2,-1,1};

string conv(int a){
	stringstream ss;
	ss << a;
	string str = ss.str();
	return str;
}


string conv(char a){
	stringstream ss;
	ss << a;
	string str = ss.str();
	return str;
}

int conv(string a){
    stringstream geek(a); 
    int x = 0; 
    geek >> x;   
	return x;
}


int v [7];
int main(void) 
{	
	rep(i,1,5)
		cin>>v[i];
	int k; cin>> k;
	int cont = 0;
	rep(i,1,5){
		rep(j,i+1,5){
			if(v[j] - v[i] > k)
				cont++;
		}
	}
	
	if (cont > 0)
		cout<<":(";
	else
		cout<<"Yay!";
	return 0;
} 



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

#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 reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  deque<int> q;
  int n; cin >> n;
  rep(i, n) {
    int a; cin >> a;
    if (i & 1) q.push_back(a); else q.push_front(a);
  }
  vi32 ans;
  if (n & 1) {
    while (!q.empty()) ans.push_back(q.front()), q.pop_front();
  } else {
    while (!q.empty()) ans.push_back(q.back()), q.pop_back();
  }
  cout << ans << '\n';
}


Measured memory_bytes: 3960
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

int main(){
	FAST_IO;
    int n, k; 
    cin >> n >> k; 
    int h[n]; 
    int dp[n]; 
    for(int i=0; i < n; i++){
        cin >> h[i];
        dp[i] = 1e9; 
    }
    dp[0] = 0; 
    if(n >=2){
        dp[1] = abs(h[1] - h[0]);
    }
    for(int i=2; i < n; i++){
        for(int j = i-1; j >= max(i-k, 0); j--){
            dp[i] = min( dp[i], (dp[j] + abs(h[i] - h[j])));
        }
    }
    /*for(int i=0; i < n; i++){
        trace1(dp[i]);
    }*/
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()
#define INF 1<<28

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int N, K; cin >> N >> K;

	int res = INF;
	for (int i = 0; i < 1<<N; ++i){
		int curr = 1;		
		for (int j = 0; j < N; ++j){
			if (i & (1<<j)){
				curr += K;
			}else{
				curr *= 2;
			} // end if
		} // end for
		res = min(res, curr);
	} // end rfor

	cout << res << endl;
 
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/node
(function() {
  var T=[];
  var S=[];
  var stdin = process.openStdin();
  stdin.setEncoding('utf8');

  var rec=function(x,y){
    if(0<=x&&x<T[0].length&&0<=y&&y<T.length&&T[y][x])
      T[y][x]=0,rec(x-1,y),rec(x+1,y),rec(x,y-1),rec(x,y+1),
      rec(x-1,y-1),rec(x+1,y-1),rec(x-1,y+1),rec(x+1,y+1);
  }

  var input_fragment="";
  stdin.on('data', function(input) {
	var ref=(input_fragment+input).split("\n");
	input_fragment=ref.pop();
	for(var i=0;i<ref.length;i++){
		if(ref[i]=='')continue;
		var y=ref[i].split(" ");
    	for(var j=0;j<y.length;j++)y[j]=parseInt(y[j])
		S.push(y);
	}
  });

  stdin.on('end', function(z) {
    var i,j,r;
    for(;;){
      r=0;
      var h=(S.shift())[1];
      if(!h)break;
      T=S.slice(0,h);
      for(i=0;i<T[0].length;i++)for(j=0;j<T.length;j++)if(T[j][i])r++,rec(i,j);
      console.log(r);
      S=S.slice(h);
    }
  });
}).call(this);

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

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

	
			var inputArray = retreiveLongArray();
			var inputCount = 2;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var N = (int)inputArray[0];
			var M = (int)inputArray[1];

			var hens = new List<Tuple<int, int>>();

			for (int i = 0; i < M; i++) {
				var inpArray = retreiveLongArray();
				var hen = new Tuple<int, int>((int)inpArray[0], (int)inpArray[1]);
				hens.Add(hen);
			}

			_map = new Dictionary<int, List<int>>();
			for (int i = 1; i <= N; i++) {
				_map.Add(i, new List<int>());
			}

			for (int i = 0; i < M; i++) {

				var hen = hens[i];

				_map[hen.Item1].Add(hen.Item2);
				_map[hen.Item2].Add(hen.Item1);

			}

			_isToota = new Dictionary<int, bool>();
			for (int i = 1; i <= N; i++) {
				_isToota.Add(i, false);
			}

			_hitohude = 0;
			//最初は1からスタートする
			dFS(1,N);

			//答えの出力
			var ans = _hitohude;
			Console.WriteLine(ans);

		}

		//フィールドの定義
		private static Dictionary<int, List<int>> _map;
		private static Dictionary<int, bool> _isToota;
		private static int _hitohude;


		private static void dFS(int current,int choutenNum) {
			_isToota[current] = true;

			var tootta = _isToota.Where(x => x.Value).Count();
			if (tootta == choutenNum) {
				_hitohude++;
			}

			var nexts = _map[current];

			foreach (var next in nexts) {
				if (!_isToota[next]) {
					dFS(next,choutenNum);
				}
			}
			_isToota[current] = false;
			return;
		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 29264
#include<iostream>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  if((n-k)%(k-1)!=0){
    cout<<(n-k)/(k-1)+2<<endl;
  }
  else cout<<(n-k)/(k-1)+1<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
	int A, B, C, K;
	cin >> A >> B >> C >> K;
	if (B < C) swap(B, C);
	if (A < B) swap(A, B);
	cout << (A << K) + B + C << endl;
	return 0;
}

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

MOD = 10**9+7
ans = 0

mul = [0]*(N+1)

for i in range(N):
  mul[i+1] = mul[i]+A[i]
  mul[i+1] = mul[i+1]%MOD
  
for i in range(N-1):
  ans += A[i] * (mul[-1]-mul[i+1])
  ans %= MOD
  
print(ans)

Measured memory_bytes: 94044
#include <iostream>

using namespace std;

int main(void)
{
    while (true) {
        u_int h, w;
        cin >> h >> w;
        if (!h && !w)
            break;

        char buf1[w+2], buf2[w+2];
        for (u_int i = 0; i < w; i+=2) {
            buf1[i] = buf2[i+1] = '#';
            buf1[i+1] = buf2[i] = '.';
        }
        buf1[w] = buf2[w] = '\n';
        buf1[w+1] = buf2[w+1] = '\0';

        for (u_int i = 0; i < h; i++)
            if (i % 2 == 0)
                printf("%s", buf1);
            else
                printf("%s", buf2);
        puts("");
    }
    return 0;
}

Measured memory_bytes: 1140
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}
 
using i64=int64_t;

void shift(vector<int> &a){
    rotate(a.begin(),a.begin()+1,a.end());
};

void normalize(vector<int>& a){
    auto amin=a;
    rep(i,0,4){
        amin=min(amin,a);
        shift(a);
    }
    a=amin;
}

i64 encode(vector<int>& a){
    i64 res=0;
    rep(i,0,4){
        res*=1000;
        res+=a[i];
    }
    return res;
}

vector<int> reverse(vector<int> &a){
    auto b=a;
    swap(b[0],b[1]);
    swap(b[3],b[2]);
    return b;
}

int f(vector<int>& a){
    if(a[0]==a[1] and a[1]==a[2] and a[2]==a[3]) return 4;
    if(a[0]==a[2] and a[1]==a[3]) return 2;
    return 1;
}

void input(int& N,vector<vector<int>> &C){
    cin >> N;
    C.resize(N);
    rep(i,0,N){
        C[i].resize(4);
        cin >> C[i][0] >> C[i][1] >> C[i][2] >> C[i][3];
        normalize(C[i]);
    }
}

void solve(){
    int N;
    vector<vector<int>> C;
    input(N,C);

    map<i64,i64> count[5]; //1,2,4
    rep(i,0,N) ++count[f(C[i])][encode(C[i])];
 
    auto make_sides=[&](int i,int j){
        vector<vector<int>> sides(4,vector<int>(4));
        rep(k,0,4){
            sides[k][0]=C[i][(k+1)%4];
            sides[k][1]=C[i][k];
            sides[k][2]=C[j][k];
            sides[k][3]=C[j][(k+1)%4];
        }
        return sides;
    };
 
    i64 ans=0;
    rep(i,0,N){
        --count[f(C[i])][encode(C[i])];
        rep(j,i+1,N){
            --count[f(C[j])][encode(C[j])];
            C[j]=reverse(C[j]);
            rep(k,0,4){
                auto sides=make_sides(i,j);
                for(auto &side:sides) normalize(side);
                i64 tmp=count[f(sides[0])][encode(sides[0])]*f(sides[0]);
                tmp*=(count[f(sides[1])][encode(sides[1])]-(encode(sides[0])==encode(sides[1])))*f(sides[1]);
                tmp*=(count[f(sides[2])][encode(sides[2])]-((encode(sides[0])==encode(sides[2]))+(encode(sides[1])==encode(sides[2]))))*f(sides[2]);
                tmp*=(count[f(sides[3])][encode(sides[3])]-((encode(sides[0])==encode(sides[3]))+(encode(sides[1])==encode(sides[3]))+(encode(sides[2])==encode(sides[3]))))*f(sides[3]);
                ans+=tmp;
                shift(C[j]);
            }
            C[j]=reverse(C[j]);
            ++count[f(C[j])][encode(C[j])];
        }
    }
    
    cout << ans << endl;
}
 
int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

Measured memory_bytes: 80128
a = int(input())
b = int(input())

if a > b:
    tmp = a
    a = b
    b = tmp

if (a == 1) & (b == 2):
    print("3")
if (a == 2) & (b == 3):
    print("1")
if (a == 1) & (b == 3):
    print("2")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ls (w*2)
#define rs (w*2+1)
#define mid ((l+r)/2)
using namespace std;
const int N=6e5+5;
const int C=3e5;
const int m=6e5;

int read()
{
	int s=0;
	char c=getchar(),lc='+';
	while (c<'0'||'9'<c) lc=c,c=getchar();
	while ('0'<=c&&c<='9') s=s*10+c-'0',c=getchar();
	return lc=='-'?-s:s;
}
void write(int x)
{
	if (x<0)
	{
		putchar('-');
		x=-x;
	}
	if (x<10) putchar(x+'0');
	else
	{
		write(x/10);
		putchar(x%10+'0');
	}
}
void print(int x,char c='\n')
{
	write(x);
	putchar(c);
}
int t[N*4],a[N];
void pushup(int w)
{
	t[w]=max(t[ls],t[rs]);
}
void add(int w,int l,int r,int x,int y)
{
	if (r<x||x<l) return;
	if (l==r) return void(t[w]=max(t[w],y));
	add(ls,l,mid,x,y);
	add(rs,mid+1,r,x,y);
	pushup(w);
}
int query(int w,int l,int r,int L,int R)
{
	if (r<L||R<l) return 0;
	if (L<=l&&r<=R) return t[w];
	return max(query(ls,l,mid,L,R),query(rs,mid+1,r,L,R));
}

signed main()
{
	memset(t,0,sizeof(t));
	int n=read(),k=read();
	for (int i=1;i<=n;i++) a[i]=read();
	for (int i=1;i<=n;i++)
	{
		int now=query(1,0,m,a[i]-k+C,a[i]+k+C)+1;
		add(1,0,m,a[i]+C,now);
	}
	print(t[1]);

	return 0;
}

Measured memory_bytes: 14144
#include <cstdio>
#include <cstring>
#include <iostream>
#include <stdio.h>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
ll sum[105],a[105];
int main()
{
    ll x,flag,i,t,ans=0,j,k=1,l,n;
    scanf("%lld",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%lld",&a[i]);
    }
      for(i=1;i<=100;i++)
    {
          for(j=1;j<=n;j++)
          {
              sum[k]+=(i-a[j])*(i-a[j]);
          }
          k++;
    }
    sort(sum+1,sum+k);

    printf("%lld\n",sum[1]);
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
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;
}
class UnionFind {
private:
    int sz;
    vector<int> par, size_;
public:
    UnionFind(){}
    UnionFind(int node_size) : sz(node_size), par(sz), size_(sz, 1){
        iota(par.begin(), par.end(), 0);
    }
    int find(int x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }
    void unite(int x,int y){
        x = find(x), y = find(y);
        if(x == y) return;
        if(size_[x] < size_[y]) swap(x,y);
        par[y] = x;
        size_[x] += size_[y];
    }
    int size(int x){
        x = find(x);
        return size_[x];
    }
    bool same(int x,int y){
        return find(x) == find(y);
    }
};

int main(){
    int n,m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        uf.unite(a,b);
    }
    int mx = 0;
    rep(i,n){
        chmax(mx,uf.size(i));
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 4360
#include <iostream>
using namespace std;
int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    
    if (a <= b && a <= c) {
        cout << a << ' ';
        if (b <= c) {
            cout << b << ' ' << c << endl;    
        }
        else {
            cout << c << ' ' << b << endl;
        }
    }
    else if (b <= a && b <= c) {
        cout << b << ' ';
        if (a <= c) {
            cout << a << ' ' << c << endl;    
        }
        else {
            cout << c << ' ' << a << endl;
        }
    }
    else {
        cout << c << ' ';
        if (a <= b) {
            cout << a << ' ' << b << endl;    
        }
        else {
            cout << b << ' ' << a << endl;
        }
    }
}



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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = 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 CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int main(){
    string k;
    cin>>k;
    int n = k.size();
    int c = count(ALL(k),'o') + (15-n);
    puts(c>=8 ? "YES" : "NO");
    return 0;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
# sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    a = gete(int)

    print(a+a**2+a**3)


if __name__ == "__main__":
    main()


Measured memory_bytes: 63988
N,M = (int(x) for x in input().split())
A_arr = [int(x) for x in input().split()]

mM_map = {0:1}
tmp = 0
for A in A_arr:
    tmp = (tmp+A)%M
    mM_map.setdefault(tmp, 0)
    mM_map[tmp] += 1

ans = 0
for v in mM_map.values():
    ans += v*(v-1)//2

print(ans)




Measured memory_bytes: 14424
S = int(input())
dp = [0] * (S + 1)
mod = pow(10, 9) + 7

for i in range(0, S + 1):
    if i == 0:
        dp[i] = 1
        continue
    if i < 3:
        # dp[i] = 0
        continue
    dp[i] += (dp[i - 3] + dp[i - 1]) % mod 
print(dp[S])

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


void input(); template<typename First,typename... Rest> void input(First&,Rest&...);
void inputVector(); template<typename First,typename... Rest>  void inputVector(std::vector<First>&,Rest&...);
#define loop(n) for(int i = 0;i < (int)(n);++i)


void calculate(){
    int N; std::string s,before;
    before = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    input(N,s);
    for(int i = 0;i < (int)s.size();++i)
    {
        int index = (s[i] - 65 + N) % 26;
        std::cout << before[index];
    }
    std::cout << '\n';
}

int main(int,char**){
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    calculate();
}



void input(){return;}
template<typename First,typename... Rest>
void input(First &first,Rest&... rest){
    std::cin >> first;
    input(rest...);
}

void inputVector(){return;}
template<typename First,typename... Rest> 
void inputVector(std::vector<First> &first,Rest&... rest){
    int N = first.size();
    for(int i = 0;i < N;i++){
        std::cin >> first[i];
    }
    inputVector(rest...);
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define MN 200005
using namespace std;
int n,m,a[MN],val[MN],ans,f[1<<16],sum[20];
int main(){
	scanf("%d",&n);int x,y,v;
	for(int i=1;i<n;i++)scanf("%d%d%d",&x,&y,&v),a[x]^=v,a[y]^=v;
	for(int i=0;i<n;i++)sum[a[i]]++;
	for(int i=1;i<=15;i++){
		ans+=sum[i]/2;
		if(sum[i]%2)val[m++]=i;
	}memset(f,0x3f,sizeof(f));f[0]=0;
	for(int i=1;i<(1<<m);i++){
		int x=0,cnt=0;
		for(int j=0;j<m;j++)if(i&(1<<j))x^=val[j],cnt++;
		if(!x)f[i]=cnt-1;
		for(int y=i-(i&(-i)),z=y;z;z=(z-1)&y,f[i]=min(f[i],f[z]+f[i^z]));
	}printf("%d\n",f[(1<<m)-1]+ans);
}


Measured memory_bytes: 768
n, k = map(int, input().split())
h = list(map(int, input().split()))
a = [0]*n
for i in range(1, n):
      hi = h[i]
      a[i] = min(a[j] + abs(hi - h[j]) for j in range(max(0, i - k), i))
print(a[-1])

Measured memory_bytes: 53600
import java.io.BufferedInputStream
import java.util.StringTokenizer

const val YES = "Yes"
const val NO = "No"

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> = Array<String>(size, init)
    // fun iterateTokens(): Iterator<String> {
    //     val reader = BufferedInputStream(System.`in`).bufferedReader()
    //     return reader.use { it.readText() }.splitToSequence(" ", "\n").iterator()
    // }
    fun iterateTokens(): StringTokenizer {
        val reader = BufferedInputStream(System.`in`).bufferedReader()
        return StringTokenizer(reader.use { it.readText() })
    }
    val tokens = iterateTokens()
    val N = tokens.nextToken().toLong()
    val A = LongArray(N.toInt())
    val B = LongArray(N.toInt())
    for (i in 0 until N.toInt()) {
        A[i] = tokens.nextToken().toLong()
        B[i] = tokens.nextToken().toLong()
    }
    solve(N, A, B)
}

fun solve(N: Long, A: LongArray, B: LongArray) {
    val n = N.toInt()
    val ab = Array<Pair<Long, Long>>(n) {
            A[it] to B[it]
        }.sortedBy { it.second }
    var time = 0L
    for (i in 0 until n) {
        time += ab[i].first
        if (time > ab[i].second) {
            println(NO)
            return
        }
    }
    println(YES)
    return
}


Measured memory_bytes: 111876
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int a,b,c;
    cin >>a>>b>>c;

    int x=max(max(a,b),c);
    cout << a+b+c-x <<endl;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  ll dp[n+1][2],ans=0;
  mem(dp);
  dp[0][1]=1;
  rep(i,n) {
    if(i+1<=n) {
      dp[i+1][0]+=dp[i][1];
      dp[i+1][1]+=dp[i][0];
    }
    if(i+m<=n) dp[i+m][0]+=dp[i][1];
  }
  REP(i,1,n+1) ans+=dp[i][0];
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


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

using namespace std;

int main()
{
    string s;
    cin >> s;
    if(s[2]==s[3] && s[4]==s[5]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3580
N ,K = map(int,input().split())
hate_num = [str(i) for i in map(int,input().split())]

start = N
while True :
    start_list = list(str(start))
    flag = True
    for i in start_list:
        if i in hate_num :
            flag = False
    if flag :
        print(start)
        break
    else :
        start += 1 

Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#include <cmath>

typedef long long ll;
const int N = 250 + 10;

ll a[N];
int idx;

int n;

void work() {
    ll b, mx;
    mx = 0;
    int idx = 0;
    for (int i = 0; i <= n * (n + 1) / 2 - 1; ++i) {
        scanf("%lld", &b);
        if (!(b & 1)) {
            a[idx ++] = b;
        } else {
            mx = std::max(mx, b);
        }
    }

    ll g = a[0];
    for (int i = 1; i < idx; ++i)
        g = std::__gcd(g, a[i]);

    std::sort(a, a + idx);

    ll z = mx / (a[idx - 1] / g) / (a[idx - 2] / g);
    z = (ll)sqrt((double)z);
    g /= z;

    printf("%lld\n", g);

    for (int i = 0; i < idx; ++i) {
        if (i) putchar(' ');
        printf("%lld", a[i] / g);
    }
    puts("");
}
int main() {
    while (1 == scanf("%d", &n)) {
        if (0 == n) break;
        work();
    }
    return 0;
}

Measured memory_bytes: 1060
from collections import defaultdict

N = int(input())
A = sorted(map(int,input().split()))

cnt = defaultdict(int)

for a in A:
    cnt[a] += 1
res = 0
for x in reversed(A):
    y = (1 << x.bit_length()) - x
    if x == y:
        k = cnt[x]//2
    else:
        k = min(cnt[x], cnt[y])
    res += k
    cnt[x] -= k
    cnt[y] -= k

print(res)


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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;



template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;


int main(){
    int N;
    cin >> N;
    int count = 1;
    rp(i, 0, N) {
        int a;
        cin >> a;
        if(count == a) count ++;
    }
    if(count == 1) {
        cout << -1 << endl;
        return 0;
    }
    cout << N - count + 1 << endl;
    return 0;;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍


int main(){
  	ll n;cin>>n;
    ll v[n],c[n];rep(i,0,n)cin>>v[i];rep(i,0,n)cin>>c[i];
	ll ans=0;
	rep(i,0,n)if(v[i]-c[i]>0)ans+=v[i]-c[i];
  	cout << ans << ednl;
}


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

int main(){
    string n;
    cin >> n;
    for(int i=0;i<3;i++){
        cout << (n[i]=='1'?'9':'1');
    }
    cout << endl;
}


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

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll ans = LLONG_MIN;
    ll ac = a * c;
    ans = max(ans, ac);
    ll ad = a * d;
    ans = max(ans, ad);
    ll bc = b * c;
    ans = max(ans, bc);
    ll bd = b * d;
    ans = max(ans, bd);
    if(a <= 0 and b >= 0) ans = max(ans, (ll)0);
    if(c <= 0 and d >= 0) ans = max(ans, (ll)0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
def main():
    a, b = map(int, input().split())
    diff = abs(max(b, a) - min(a, b))
    if diff % 2 != 0:
        print("IMPOSSIBLE")
    else:
        bigger = max(a, b)
        ans = bigger - (diff//2)
        print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940