akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
// #define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    
    ll s;
    cin>>s;
    map<ll,ll> mp;
    mp[s]++;
    rep2(i,2,10000000){
        if(s%2==0){
            s/=2;
            if(mp[s]>0){
                cout<<i<<endl;
                return 0;
            }
            mp[s]++;
        }
        else{
            s=3*s+1;
            if(mp[s]>0){
                cout<<i<<endl;
                return 0;
            }
            mp[s]++;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, X: "List[int]"):
    ret = 0
    for x in X:
        ret += min(abs(K - x), x) * 2
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    x = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, K, x)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	long N = sc.nextLong();
	long now = 0;
	int keta = 1;
	while(N > now) {
	    now = now + (long)Math.pow(26,keta);
	    keta++;
	}
	keta--;
	now = now - (long)Math.pow(26,keta);
	long shou = N-now-1; //その桁の初めから何番目か
	long[] name = new long[keta];
	for (int i=keta-1;i>=0;i--) {
	    name[i] = shou % 26;
	    shou = shou/26;
	}
	char[] abc = {'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'};
	for (int i=0;i<keta;i++) {
	    System.out.print(abc[(int)name[i]]);
	}
    }
}


Measured memory_bytes: 35756
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
    int N,m;
    cin >> N;
    m = N;
    vector<int> a;
    int Max = 0;
    while(N--){
        int x;
        scanf("%d",&x);
        
        //if(find(a.begin(),a.end(),x) == a.end() || (Max < x)){
            a.push_back(x);
            //Max = max(x,Max);
        //}else{
            //a.erase(find(a.begin(),a.end(),x));
        //}
        
    }
    //sort(a.begin(),a.end());
    for(int i=0; i<m-1;i++){
        if(a[i] == i+1 && a[i+1] == i+2){
            swap(a[i],a[i+1]);
            Max++;
        }
        
    }
    for(int i=0; i<m;i++){
        if(a[i] == i+1){
            Max++;
        }
        
    }
    cout << Max << endl;
    return 0;
}


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

#include <stdio.h>
#include <cctype>

int main(void)
{
	std::string st;
	getline(std::cin, st);
	
	
	
	for(int i = 0 ; i < st.size();i++ ){

		char ch = st[i];
		if (std::islower(ch)){	//?°?????????????
			ch = std::toupper(ch);		//??§????????§??????
		}
		else if (std::isupper(ch)){
			ch = std::tolower(ch);
		}
		else {
			//????????????
		}
		printf("%c", ch);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 1168
#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()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    LL N,W;cin >> N >> W;
    vector<LL> w(N);
    vector<LL> v(N);
    rep(i,N)cin >> w[i] >> v[i];
    vector<vector<LL>> dp(N+10,vector<LL>(100001,INF));
    dp[0][0] = 0;
    rep(i,N) rep(j,100001){
        if(j - v[i] >= 0)chmin(dp[i+1][j],dp[i][j - v[i]] + w[i]);
        chmin(dp[i+1][j],dp[i][j]);
    }

    LL ans = 0;
    for(int i = 100000;i >= 0;--i){
        if(dp[N][i] <= W){
            ans = i;
            break;
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 87296
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
int N;
int H[101010];
const ll mo=998244353;
ll fact2[101010];
const int NUM_=400001;
ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];

ll comb(ll N_, ll C_) {
	if(C_<0 || C_>N_) return 0;
	return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}

vector<ll> V[101010];

ll modpow(ll a, ll n = mo-2) {
	ll r=1;
	while(n) r=r*((n%2)?a:1)%mo,a=a*a%mo,n>>=1;
	return r;
}


template<class T> vector<T> fft(vector<T> v, bool rev=false) {
	int n=v.size(),i,j,m;
	
	for(i=0,j=1;j<n-1;j++) {
		for(int k=n>>1;k>(i^=k);k>>=1);
		if(i>j) swap(v[i],v[j]);
	}
	for(int m=2; m<=n; m*=2) {
		T wn=modpow(5,(mo-1)/m);
		if(rev) wn=modpow(wn);
		for(i=0;i<n;i+=m) {
			T w=1;
			for(int j1=i,j2=i+m/2;j2<i+m;j1++,j2++) {
				T t1=v[j1],t2=(ll)w*v[j2]%mo;
				v[j1]=t1+t2;
				v[j2]=t1+mo-t2;
				while(v[j1]>=mo) v[j1]-=mo;
				while(v[j2]>=mo) v[j2]-=mo;
				w=(ll)w*wn%mo;
			}
		}
	}
	if(rev) {
		ll rv = modpow(n);
		FOR(i,n) v[i]=(ll)v[i]*rv%mo;
	}
	return v;
}

template<class T> vector<T> MultPoly(vector<T> P,vector<T> Q,bool resize=false) {
	if(resize) {
		int maxind=0,pi=0,qi=0,i;
		int s=2;
		FOR(i,P.size()) if(norm(P[i])) pi=i;
		FOR(i,Q.size()) if(norm(Q[i])) qi=i;
		maxind=pi+qi+1;
		while(s*2<maxind) s*=2;
		P.resize(s*2);Q.resize(s*2);
	}
	P=fft(P), Q=fft(Q);
	for(int i=0;i<P.size();i++) P[i]=(ll)P[i]*Q[i]%mo;
	return fft(P,true);
}

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	
	fact2[1]=1;
	for(i=3;i<=101000;i+=2) fact2[i]=fact2[i-2]*i%mo;
	inv[1]=fact[0]=factr[0]=1;
	for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
	for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	
	cin>>N;
	FOR(i,2*N) {
		cin>>x;
		H[x]++;
	}
	priority_queue<pair<int,int>> P;
	FOR(i,100001) if(H[i]) {
		V[i].push_back(1);
		for(j=1;2*j<=H[i];j++) {
			V[i].push_back(comb(H[i],2*j)*fact2[2*j-1]%mo);
		}
		P.push({-(int)V[i].size(),i});
	}
	
	while(P.size()>1) {
		x=P.top().second;
		P.pop();
		y=P.top().second;
		P.pop();
		V[x]=MultPoly(V[x],V[y],1);
		V[y].clear();
		P.push({-(int)V[x].size(),x});
	}
	
	ll ret=0;
	x=P.top().second;
	FOR(i,V[x].size()) if(V[x][i]) {
		ll v=V[x][i]*(i==N?1:fact2[2*(N-i)-1])%mo;
		if(i%2) ret+=mo-v;
		else ret+=v;
	}
	cout<<ret%mo<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 26140
#include <bits/stdc++.h>
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

int main() {
	fastIO;
#ifdef LOCAL
	freopen("input.in", "rt", stdin);
#endif
	string str;
	cin >> str;
	for (int i = 0; i < str.size(); ++i) {
		if(str[i] == '?') str[i] = 'D';
	}
	cout << str;
	return 0;
}


Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define HAIRETU(N,A) for(int i=0;i<N;i++) cin >>A[i]
using namespace std;

int main(){
    int A, B, C, X, Y, cnt = 0;
    cin >> A >> B >> C >> X;
    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) cnt += 0;
            }
            Y = (X - 500 * i - 100 * j) / 50;
            if(0 <= Y && Y <= C) cnt += 1;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



int main(){
   IOS

    int k, a, b; cin>>k>>a>>b;

    for(int i = a; i <= b; i++){
        if(i %k == 0){
            cout<<"OK\n";
            return 0;
        }
    }  

    cout<<"NG\n";







}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1)
        res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



Measured memory_bytes: 3616
#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	string s;
    cin>>s;
    int len=s.size();
    if(s[0]==s[len-1]){
        if(len%2==1)printf("Second\n");
        else printf("First\n");
    }else{
        if(len%2==1)printf("First\n");
        else printf("Second\n");
    }
    return 0;
}

Measured memory_bytes: 512
bingo=[]
karibingo=[]
for i in range(3):
    a=list(map(int,input().split()))
    bingo.append(a)
N=int(input())
for i in range(N):
    b=int(input())
    for j in range(3):
        for k in range(3):
            if bingo[j][k]==b:
                karibingo.append([j,k])
def bingohantei():
    count3 = 0
    if [0,2] in karibingo and [1,1] in karibingo and [2,0] in karibingo:
        return True
    for i in range(3):
        count=0
        count2=0
        if [i,i] in karibingo:
            count3+=1
        if count3==3:return True
        for j in range(3):
            if [i,j] in karibingo:
                count+=1
            if [j,i] in karibingo:
                count2+=1
            if count==3 or count2==3:return True
if bingohantei():
    print("Yes")
else:print("No")

Measured memory_bytes: 3064
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

X = int(readline())

div_500,mod_500 = divmod(X, 500)
div_5,mod_5 = divmod(mod_500, 5)

print(div_500*1000 + div_5*5)

Measured memory_bytes: 3060
n = int(input())
s = [input() for i in range(n)]

ac = 0
wa = 0
tle = 0
re = 0

for j in range(n):
  if s[j] == "AC":
    ac += 1
  if s[j] == "WA":
    wa += 1
  if s[j] == "TLE":
    tle += 1
  if s[j] == "RE":
    re += 1
    
    
print("AC x ",ac) 
print("WA x ",wa)
print("TLE x ",tle)
print("RE x ",re)

Measured memory_bytes: 16216
def main():
    ans, a = [], []
    H, W = map(int, input().split())

    for i in range(H):
        a += [list(map(int, input().split()))]

    x, y, dx = 0, 0, 1

    while True:
        nx, ny = x, y
        if x+dx < 0 or W <= x+dx:
            nx = x
            ny = y+1 
            dx *= -1
        else:
            nx = x+dx
            ny = y

        if H <= ny:
            break

        if a[y][x] % 2 == 1:
            a[y][x] -= 1
            a[ny][nx] += 1
            ans += [str(y+1) + " " + str(x+1) + " " + str(ny+1) + " " + str(nx+1)]
        x, y = nx, ny

    print (len(ans))

    for i in ans:
        print (i)

main()


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

int main(void)
{
  int n, t;
  cin >> n >> t;
  int a[n];
  int min_a = 1000000000, cnt = 0, dis = 0;
  for (int i = 0; i < n; i++){
    cin >> a[i];
    min_a = min(a[i], min_a);
    if (dis < a[i] - min_a){
      dis = a[i] - min_a;
      cnt = 0;
    }
    if (dis == a[i] - min_a and a[i] - min_a > 0) cnt++;
  }
  cout << cnt << "\n";

  return (0);
}

Measured memory_bytes: 640
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_7_C

??¨?¨????
??¨?¨??????????????°???????????????°???????????????????????????
??¨????????°r??¨?????°c???r ?? c ???????´????????????¨?????????????????§???????????¨??????????¨?????????\????????°????????¨???????????????????????°?????????????????????????????????
"""

if __name__ == '__main__':
    # ??¨??????????????\???
    size = [int(x) for x in input().split(' ')]
    row = size[0]
    column = size[1]
    data = []
    for r in range(row):
        current_row = [int(x) for x in input().split(' ')]
        assert(len(current_row) == column)
        data.append(current_row)

    # ????¨?????????????
    for d in data:
        d.append(sum(d))
    # ????¨?????????????
    totals = [0] * len(data[0])
    for line in data:
        for i, d in enumerate(line):
            totals[i] += d
    data.append(totals)

    # ???????????????
    for line in data:
        print(' '.join(map(str, line)))

Measured memory_bytes: 7752
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>

#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(), v.end()
#define sz(v) int(v.size())

using namespace std;
using ll = int64_t;

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

  ll A, B, C;
  cin >> A >> B >> C;
  if (A == B && B == C)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


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

int main(){
    int n,k=1;
  cin >> n;
  vector<int> a(n),b(n);
  rep(i,n)
    cin >> a[i];
  rep(i,n){
      b[a[i]-1]=i+1;
  }
  rep(i,n)
  cout << b[i] << endl;
}

Measured memory_bytes: 1664
#include <stdio.h>

int nn[3];
void print3n(){
  printf("%d %d %d\n", nn[0], nn[1], nn[2]);
  return;
}

int cmbNKS(int k, int sum, int num){
  static int cmb[3][7500] = {0};
  if(num==0){
    if(sum==0){
      return 1;
    }else{
      return 0;
    }
  }else if(num<0 || sum<0){
    return 0;
  }
  if(cmb[num-1][sum-1] != 0) return cmb[num-1][sum-1];
  if(k*num < sum){
    return -1;
  }
  
  int i=k, ans=0, n;
  while(i>=0){
    if((n = cmbNKS(k, sum-i, num-1)) == -1) break;
    ans += n;
    i--;
  }

  cmb[num-1][sum-1] = ans;
  return ans;
}

int main()
{
  int k, s;
  
  scanf("%d%d", &k, &s);
  
  printf("%d", cmbNKS(k, s, 3));
  return 0;
}


Measured memory_bytes: 128
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    
    let mut iter = buf.split_whitespace();
    
    iter.next();
    iter.next();
    let mut strings: Vec<&str> = iter.collect();
    
    strings.sort();
    println!("{}", strings.concat());
}

Measured memory_bytes: 4352
#include <iostream>
 
using namespace std;
 
int main() {
    int a, d = 0; cin >> a;
    for (int i = 0; i < a; i++) {
        int b; cin >> b;
        d++;
        for(int j = 2; j * j <= b; j++) {
            if (b % j == 0) {
                d--;
                break;
            }
        }
    }
    cout << d << endl;
}


Measured memory_bytes: 3092
#include <iostream>
#include <string>

using namespace std;

int main(void)
{
	string s;
	cin >> s;
	for (int i = 0; i < 4; i++) cout << s[i];
	cout << " ";
	for (int i = 4; i < 12; i++) cout << s[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
h, w = map(int, input().split())

def defs(h, w):
    ans = 10 ** 12
    for i in range(1, h):
        sa = i * w
        h2 = h - i

        for j in range(2):
            if j == 0:
                sb = h2 * (w // 2)
                sc = h2 * (w - (w // 2))
            else:
                sb = (h2 // 2) * w
                sc = (h - i - (h2 // 2)) * w

            s_max = max(sa, sb, sc)
            s_min = min(sa, sb, sc)

            ans = min(ans, s_max - s_min)
    return ans

print(min(defs(h, w), defs(w, h)))


Measured memory_bytes: 3064
//ABC102C
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
#include <unordered_map>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<long long int> a(n), b(n);
	for(int i=0;i<n;i++){
		cin >> a.at(i);
		b.at(i) = a.at(i)-i;
	}
	sort(b.begin(),b.end());
	long long int x = b.at(n/2);
	long long int ans = 0;
	for(int i=0;i<n;i++){
		ans += abs(b.at(i)-x);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final long n = scanner.nextLong();
        final Map<Long, Long> map = primeFactorization(n);
        long all = 0;
        for (final long value : map.values()) {
            for (long tmp = 1; ; tmp++) {
                if (tmp * (tmp + 1) / 2 > value) {
                    all += tmp - 1;
                    break;
                }
            }
        }
        System.out.println(all);
    }

    private static Map<Long, Long> primeFactorization(long n) {
        final double sqrt = Math.sqrt(n);
        final Map<Long, Long> countMap = new HashMap<>();
        for (long i = 2; i <= sqrt; i++) {
            if (n % i == 0) {
                countMap.compute(i, (k, v) -> v = v == null ? 1 : v + 1);
                n /= i;
                i--;
            }
        }

        if (n != 1) {
            countMap.compute(n, (k, v) -> v = v == null ? 1 : v + 1);
        }

        return countMap;
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

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

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

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

            return tokenizer.nextToken("\n");
        }
    }
}


Measured memory_bytes: 33872
#include <iostream>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	ll H, N, A, sum = 0;
	std::cin >> H >> N;

	for (ll i = 0; i < N; ++i)
	{
		std::cin >> A;
		sum += A;
	}
	if (sum >= H)
		std::cout << "Yes" << std::endl;
	else
		std::cout << "No" << std::endl;

	return 0;
}


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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline void chmin(T &l,T r){l=min(l,r);}
template <typename T>inline void chmax(T &l,T r){l=max(l,r);}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
    
int main(){
    int n;
    string x;
    int q;
    cin>>n>>x>>q;
    map<int,int> lr;
    REP(i,n){
        if(x[i]=='0')continue;
        if(i==0||x[i-1]=='0'){
            lr[i+1]=i;
        }
        else{
            int bg=lr[i];
            lr.erase(i);
            lr[i+1]=bg;
        }
        
    }
    REP(qq,q){
        int l,r,b;
        cin>>l>>r>>b;
        l--;
        if(b==1){
            while(true){
                auto it=lr.upper_bound(l);
                if(it==lr.end()||r<it->se){
                    if(lr.count(l)){
                        lr[r]=lr[l];
                        lr.erase(l);       
                    }
                    else lr[r]=l;
                    break;
                }
                else{
                    //       cout<<" "<<it->se<< " "<<it->fi<<endl;
                    chmin(l,it->se);
                    chmax(r,it->fi);
                    lr.erase(it->fi);
                    //cout<<" "<<r<<endl;
                }
            }
        }
        else{
            while(true){
                auto it=lr.upper_bound(l);
                if(it==lr.end()||r<=it->se){
                    break;
                }
                else{
                    if(it->se<l)lr[l]=lr[it->fi];
                    if(r<it->fi)lr[it->fi]=r;
                    else{
                        lr.erase(it->fi);
                    }
                }

            }
        }
        //        for(auto &it:lr)cout<<it.se<<" "<<it.fi<<endl;
        cout<<lr.size()<<endl;
    }
    return 0;
}

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

int main(void) {
    int n, x;
    int count;
    
    while(true) {
        count = 0;
        cin >> n >> x;
        
        if(n == 0 && x == 0) {
            break;
        }
        
        for(int i = 1; i <= n; ++i) {
            for(int j = i + 1; j <= n; ++j) {
                for(int k = j + 1; k <= n; ++k) {
                    if(i + j + k == x)   count += 1;
                }
            }
        }
        cout << count << endl;
    }
    return 0;
}



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

using namespace std;
int main(){
    int k=0;
    string s;
    cin>>s;
    if(s[0]=='S') cout<<"Cloudy"<<endl;
    else if(s[0]=='C') cout<<"Rainy"<<endl;
    else  cout<<"Sunny"<<endl;
return 0;
}



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

#define int long long

struct UnionFind{
  int n;
  vector<int> r,p;
  UnionFind(){}
  UnionFind(int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
  int find(int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }
};

struct Edge {
  int from, to, cost;
  bool operator<(const Edge &e) const {
    return cost < e.cost;    
  }
};

signed main() {
  int N, M, K;
  cin >> N >> M >> K;

  vector<int> c(N);
  for ( int i = 0; i < N; i++ ) cin >> c[i], c[i]--;

  vector<Edge> G(M);
  for ( int i = 0; i < M; i++ ) {
    int a, b, w;
    cin >> a >> b >> w;
    a--; b--;
    G[i] = Edge{a, b, w};
  }

  sort(G.begin(), G.end());

  UnionFind uf(N+K+1);  
  int ans = 0;
  int cnt = 0;
  for ( int i = 0; i < M; i++ ) {
    int a = G[i].from, b = G[i].to, w = G[i].cost;
    int ac = c[a], bc = c[b];

    if ( ac == -1 ) ac = K+a;
    if ( bc == -1 ) bc = K+b;

    if ( uf.same(ac, bc) ) continue;
    uf.unite(ac, bc);
    ans += w;
    cnt++;

    if ( cnt >= K-1 ) break;
  }

  if ( cnt >= K-1 ) cout << ans << endl;
  else cout << -1 << endl;
  
  return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <vector>
#include <utility>
using namespace std;

int n;
int a[199999];
bool b[199999];
bool ok(int k) {
  for (int i = 0; i < 2 * n - 1; ++i) {
    b[i] = a[i] >= k;
  }
  
  vector<pair<bool, bool>> v;
  for (int i = 0; i < n - 1; ++i) {
    v.push_back(make_pair(b[n - 1 + i], b[n + i]));
    v.push_back(make_pair(b[n - 1 - i], b[n - 2 - i]));
  }
  
  for (auto p : v) {
    if (p.first == p.second) return p.first;
  }
  
  return b[0];
}

int main() {
  cin >> n;
  for (int i = 0; i < 2 * n - 1; ++i) cin >> a[i];
  
  int lo = 0;
  int hi = 2 * n;
  
  while (hi - lo > 1) {
    int mid = (lo + hi) / 2;
    if (ok(mid)) {
      lo = mid;
    } else {
      hi = mid;
    }
  }
  
  cout << lo << endl;
}

Measured memory_bytes: 2180
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
#define rep(i,a,b) for(int (i) = (a); (i) <= (b); i++)
#define repd(i,a,b) for(int (i) = (a); (i) >= (b); i--)
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++)
#define mp make_pair
#define pb push_back
#define countbits __builtin_popcount
using namespace std;
#define is_digit(c) ((c) >= '0' && (c) <= '9')
#define is_upper(c) ((c) >= 'A' && (c) <= 'Z')
#define is_lower(c) ((c) >= 'a' && (c) <= 'z')
#define readchar() ((char)fgetc(stdin))
#define printchar(c) fputc((c), stdout)
void readline(char *s) {int len=0;char c;for(c=readchar(); c!='\n'; s[len++]=c, c=readchar());s[len]=0;}
void readstr(char *s) {int len=0;char c;for(c=readchar(); c!=' '&&c!='\n'; s[len++]=c, c=readchar());s[len]=0;}
void printstr(const char *s) {int len=strlen(s);rep(i,0,len-1) printchar(s[i]);}
void to_lower(char *s, int L, int R) {rep(i,L,R) if (is_upper(s[i])) s[i]=s[i]-'A'+'a';}
void to_upper(char *s, int L, int R) {rep(i,L,R) if (is_lower(s[i])) s[i]=s[i]-'a'+'A';}
ll readll() {
	char c;ll ans=0, x=1;for (c=readchar(); !is_digit(c)&&c!='-'; c=readchar());
	if (c=='-') x=-1, c=readchar();for (; is_digit(c); ans=ans*10+c-'0', c=readchar());return ans*x;
}
void printll(ll x) {
	int a[25], cnt=0;if (x==0) { printchar('0'); return; }if (x<0) printchar('-'), x=-x;
	for (; x; a[cnt++]=x-x/10*10, x/=10);repd(i,cnt-1,0) printchar(a[i]+'0');
}
#define readint() ((int)readll())
#define printint(x) printll((ll)(x))
int h,w,n,a[10005];
int color[105][105];
int main() {
	h=readint();w=readint();n=readint();
	rep(i,1,n) a[i]=readint();
	int x=1,y=1;
	bool forward=1;
	rep(i,1,n) {
		while (a[i]--) {
//			cerr<<x<<" "<<y<<" "<<i<<" "<<forward<<endl;
			color[x][y]=i;
			if (forward) y++; else y--;
			if (y>w) {y=w;x++;forward=0;}
			if (y<1) {y=1;x++;forward=1;}
		}
	}
	rep(i,1,h) rep(j,1,w) {
		printint(color[i][j]);printchar(j==w?'\n':' ');
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
using namespace std;

#define MAX 4810

int N;
int a[MAX];
int v[MAX];

int main() {
    cin >> N;
    for ( int i = 1; i <= N; i++ ) {
        cin >> a[i];
    }
    
    for ( int i = 1; i <= 9; i++ ) {
        v[i] = 0;
    }
    
    for ( int i = 1; i <= N; i++ ) {
        if ( 1 <= a[i] && a[i] <= 399 ) {
            v[1]++;
        } else if ( 400 <= a[i] && a[i] <= 799 ) {
            v[2]++;
        } else if ( 800 <= a[i] && a[i] <= 1199 ) {
            v[3]++;
        } else if ( 1200 <= a[i] && a[i] <= 1599 ) {
            v[4]++;
        } else if ( 1600 <= a[i] && a[i] <= 1999 ) {
            v[5]++;
        } else if ( 2000 <= a[i] && a[i] <= 2399 ) {
            v[6]++;
        } else if ( 2400 <= a[i] && a[i] <= 2799 ) {
            v[7]++;
        } else if ( 2800 <= a[i] && a[i] <= 3199 ) {
            v[8]++;
        } else if ( 3200 <= a[i] && a[i] <= 4800 ){
            v[9]++;
        }
    }
    
    int mini = 0, maxi = 0;
    for ( int i = 1; i <= 8; i++ ) {
        if ( v[i] != 0 ) {
            mini++;
        }
    }
    
    maxi = mini + v[9];
    
    if ( mini == 0 && v[9] != 0 ) {
        mini = 1;
    }
    
    cout << mini << " " << maxi << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef long double ld;
const double pi=acos(-1.0);
const ll mod=pow(10,9)+7;
const ll INF=pow(2,31)-1;
using str=string;
typedef pair<int,int> P;
typedef vector<int> vi;

ll gcd(ll a,ll b){
    ll v0=a,v1=b,v2=a%b;
    while(v2!=0){
        v0=v1;
        v1=v2;
        v2=v0%v1;
    }
    return v1;
}

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

int main(){
    ios::sync_with_stdio(false);
    int l,r;
    long ans=LONG_MAX;
    cin >> l >> r;
    if(r-l>2019) cout << 0 << endl;
    else{
        for(int i=l;i<r;i++){
            for(int j=i+1;j<=r;j++){
                ans=min(ans,(long)i*j%2019);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

int main(){
    string S, T;
    cin >> S >> T;
    vector<string> vec;
    string ans;
    int l = S.size()-T.size()+1;
    for (int i = 0; i < max(0, l); i++) {
        bool ok = true;
        for (int j = 0; j < T.size(); j++) {
            if (S[i+j] != '?' && S[i+j] != T[j]) ok = false;
        }
        if (ok) {
            string s = S;
            for (int k = i; k < i + T.size(); k++) {
                if (s[k] == '?') s[k] = T[k-i]; 
            }
            for (int k = 0; k < s.size(); k++) {
                if (s[k] == '?') s[k] = 'a';
            }
            vec.push_back(s);
        }
    }

    if (vec.size() == 0) cout << "UNRESTORABLE" << endl;
    else {
        for (int i = 0; i < vec.size(); i++) {
            if (i == 0) ans = vec[0];
            else {
                if (vec[i] < ans) ans = vec[i];
            }
        }
        cout << ans << endl;
    }
}

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

using namespace std;

int n,m;
vector<vector<int>> adj;
stack<int> ordering;
vector<bool> vis;

void dfs(int i){
	if(vis[i]) return;
	vis[i]=true;
	for(int j : adj[i]) dfs(j);
	ordering.push(i);
}

int main (){
	cin >> n >> m;
	adj=vector<vector<int>>(n);
	vis=vector<bool>(n,false);
	for(int i=0; i<m; ++i){
		int a,b;
		cin >> a >> b;
		--a;--b;
		adj[a].push_back(b);
	}
	for(int i=0; i<n; ++i) dfs(i);
	vector<int> dp(n,0);
	while(!ordering.empty()){
		int i=ordering.top(); ordering.pop();
		for(int j : adj[i]) dp[j]=max(dp[j], dp[i]+1);
	}
	int ans=0;
	for(int i : dp) ans=max(ans, i);
	cout << ans;
		
	return 0;
}



Measured memory_bytes: 11604
N = int(input())
jobs = []
for _ in range(N):
    A, B = map(int, input().split())
    jobs.append((B, A))
jobs.sort(reverse=True)
now = 10 ** 9
for b, a in jobs:
    if now < b:
        now -= a
    else:
        now = b - a
print("Yes" if now >= 0 else "No")


Measured memory_bytes: 29496
import math
import itertools

n=int(input())
plot=[]
for i in range(n):
  plot.append(list(map(int,input().split())))

data=[]
for case in itertools.permutations(range(n)):
  dist = 0.0
  for i in range(n-1):
    x1,y1=plot[case[i]]
    x2,y2=plot[case[i+1]]
    dist += math.sqrt((x1-x2)**2+(y1-y2)**2)
  data.append(dist)
print(sum(data)/len(data)) 

Measured memory_bytes: 41948
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  string s;
  cin>>s;
  int n=s.size()+1;
  vecint v(n,-1);
  if(s[0] == '<') v[0] = 0;
  if(s.back() == '>') v.back() = 0;
  for(int i:irange(0,n-2)) {
    if(s.substr(i,2) == "><") {
      v[i+1] = 0;
    }
  }
  for(int i:irange(0,n-1)) {
    if(s[i] == '<') {
      v[i+1] = v[i] + 1;
    }
  }
  for(int i:irange(0,n-1)) {
    int j=(n-1)-i-1;
    if(s[j] == '>') {
      v[j] = max(v[j], v[j+1] + 1);
    }
  }
  ll sum=0;
  for(int e:v) {
    sum += e;
  }
  cout<<sum<<endl;
  return 0;
}


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

long long s[51];
long long sum = 0;
long long C[51][51]; 
void init(){
	C[1][0] = C[1][1] = 1;
	for(int i = 2;i<=50;i++){
		C[i][0] = 1;
		for(int j = 1;j<=i;j++){
			C[i][j] = C[i-1][j]+C[i-1][j-1];
		}
	}
}

int main(){
	int n,a,b;
	
	init();
	cin >> n >> a >> b;
	for(int i = 0;i < n;i++){
		cin >> s[i];
	}
	if(a==n){
		cout << "1" << endl;
		return 0;
	}
	sort(s,s+n);
	for(int i = n-1;i>n-1-a;i--){
		sum+=s[i];
	}
	cout << fixed << setprecision(6) << sum*1.0/a << endl;
	if(s[n-a]>s[n-a-1]){
		cout << "1" << endl;
		return 0;
	}
	int cnts = 0,cntm = 0;
	for(int i = n-a;i < n;i++){
		if(s[i]==s[n-a]) cntm++;
	}
	for(int i = n-a-1;i>=0;i--){
		if(s[i]==s[n-a]) cnts++;
	}
	cnts+=cntm;
	long long ans = 0;
	if(s[n-a]==s[n-1]){
		for(int i = a;i<=b;i++){
			if(i<=cnts) ans+=C[cnts][i];
			else break;
		}
	}
	else{
		ans+=C[cnts][cntm];
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#include  "bits/stdc++.h"
using namespace std;
#define I_AM_SPEED  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define printclock  cerr <<"Time : "<<(double)clock()/(double)CLOCKS_PER_SEC<<" sec\n";
#define mp(a , b)   make_pair(a , b)
#define eb(a)       emplace_back(a)
#define anal         '\n'
#define mod 1000000007
//const double PI = acos(-1.0);
typedef long long ll;
typedef unsigned long long ull;

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
  

//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
      
int main(){
I_AM_SPEED;


//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
          
      char ch;
      cin >> ch;
      if(isupper(ch)){
           cout << "A";
      }
      else{
         cout << "a";
      }
//_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-
printclock; 
return  0 ;      
}        



   

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

int main(){
    long long int s;
    cin >> s;
    long long int n=1000000000;
    cout << 0 << " " << 0 << " " << n << " " ;
    long long int a=(s+n-1)/n,b=-s+n*a;
    cout << b << " " << 1 << " " << a;
    cout << endl;
}

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

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

	int max = 0;
	int num;
	for (int i = 0; i < 3; i++) {
		if (max < n[i]) {
			max = n[i];
			num = i;
		}
	}

	int ans = 0;
	if (num == 0) {
		ans = n[1]+n[2];
	} else if (num == 1) {
		ans = n[0]+n[2];
	} else {
		ans = n[0]+n[1];
	}
	for (int i = 0; i < k; i++) {
		n[num] *= 2;
	}
	ans += n[num];
	cout << ans << endl;
	return 0;
}
  

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

#define MAX(p,q) ((p>q)?(p):(q))
#define MIN(p,q) ((p<q)?(p):(q))

#define REP0(i,n) for(i=0;i<n;i++)
#define REP1(i,n) for(i=1;i<n;i++)

int main(void)
{
  char s[11];
  int d[11];
  scanf("%s",s);
  int l;
  l = strlen(s);//\0を抜いた文字列の長さ
  int i,j;
  REP0(i,l) d[i]=s[i]-'0';
  long long ans=0,v;
  //+を入れるか入れないかをbit探索
  REP0(i,1<<(l-1))//文字より一字少ない
  {
    v=d[0];
    REP0(j,l-1)
    {
      if((i>>j)&1)
      {
        v=v*10+d[j+1];

      }
      else
      {
        ans+=v;
         v=d[j+1];
        }
      }
      ans+=v;
    }

  printf("%lld",ans);
  return 0;
}


Measured memory_bytes: 128
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
#include<stack>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
vector<vector<char>>s;
int main() {
	int h, w;
	cin >> h >> w;
	int h1 = h + 2;
	int  w1 = w + 2;
	s = mat(char, h1, w1, '#');
	int whitenum = 0;
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> s[i][j];
			if (s[i][j] == '.')whitenum++;
		}
	}
	auto looked = mat(bool, h1, w1, false);
	vector < pair<int, int>>move = { {0,1}, {1,0}, {0,-1},{-1,0} };

	queue<tuple<int, int, int>> st;
	st.push(tuple<int, int, int>{ 1, 1, 1 });
	looked[1][1] = true;
	int lpn = -1;
	int loopnum = 0;
	while (!st.empty()) {
		loopnum++;
		auto cell = st.front();
		st.pop();
		int i = get<0>(cell);
		int j = get<1>(cell);
		int dist = get<2>(cell);

		if (i == h && j == w) {
			lpn = dist;
			break;
		}
		else {
			for (auto m : move) {
				int ni = i + m.first;
				int nj = j + m.second;
				if (looked[ni][nj] == false && s[ni][nj] == '.') {
					st.push(tuple<int, int, int> { ni, nj, dist + 1 });
					looked[ni][nj] = true;
				}

			}
		}

	}

	if (lpn != -1) cout << whitenum - lpn;
	else cout << -1;
	return 0;
}





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

void dfs(vector<vector<int>> &t, vector<int> &v, int u, int parent, int c){
	v[u] = c;
	for(int i = 0; i < t[u].size(); i++){
		if(t[u][i] != parent){
			dfs(t, v, t[u][i], u, 1 - c);
		}
	}
}

int next(int n){
	if(n % 3 == 1){
		return n + 1;
	}
	if(n % 3 == 2){
		return n + 2;
	}
}

int main(){
	int N, i;
	scanf("%d", &N);
	vector<vector<int>> t(N, vector<int>(0));
	for(i = 1; i < N; i++){
		int a, b;
		scanf("%d%d", &a, &b);
		a--;
		b--;
		t[a].push_back(b);
		t[b].push_back(a);
	}
	vector<int> v(N, -1);
	dfs(t, v, 0, -1, 0);
	vector<int> Ol_num(2, 0);
	for(i = 0; i < N; i++){
		Ol_num[v[i]]++;
	}
	int n1 = 0, n2 = 0, n3 = 0;
	for(i = 0; i < N; i++){
		if(i % 3 == 0){
			n1++;
		}
		if(i % 3 == 1){
			n2++;
		}
		if(i % 3 == 2){
			n3++;
		}
	}
//	printf("(n1, n2, n3) = (%d, %d, %d)\n", n1, n2, n3);
	vector<int> ans(N, -1);
	if(n1 + n2 <= Ol_num[0]){
//		printf("test1\n");
		int now = 1;
		for(i = 0; i < N && now <= N; i++){
			if(v[i] == 0){
				ans[i] = now;
				now = next(now);
			}
		}
		now = 3;
		for(i = 0; i < N; i++){
			if(ans[i] == -1){
				ans[i] = now;
				now += 3;
			}
		}
	}
	else if(n1 + n2 <= Ol_num[1]){
//		printf("test2\n");
		int now = 1;
		for(i = 0; i < N && now <= N; i++){
			if(v[i] == 1){
				ans[i] = now;
				now = next(now);
			}
		}
		now = 3;
		for(i = 0; i < N; i++){
			if(ans[i] == -1){
				ans[i] = now;
				now += 3;
			}
		}
	}
	else{
//		printf("test3\n");
		int now1 = 1, now2 = 2;
		for(i = 0; i < N; i++){
			if(v[i] == 0 && now1 <= N){
				ans[i] = now1;
				now1 += 3;
			}
			if(v[i] == 1 && now2 <= N){
				ans[i] = now2;
				now2 += 3;
			}
		}
		int now = 3;
		for(i = 0; i < N; i++){
			if(ans[i] == -1){
				ans[i] = now;
				now += 3;
			}
		}
	}
	for(i = 0; i < N; i++){
		printf("%d ", ans[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 22656
#include <bits/stdc++.h>
using namespace std;
#define N 200100
const int mod=1e9+7;

int n,c[N],L[N],now[N],dp[N];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&c[i]);
	n=unique(c+1,c+n+1)-c-1;
	for (int i=1;i<=n;i++) L[i]=now[c[i]],now[c[i]]=i;
	dp[0]=1;
	for (int i=1;i<=n;i++) {
		dp[i]=dp[i-1];
		if (L[i]) dp[i]=(dp[i]+dp[L[i]])%mod;
	}
	printf("%d\n",dp[n]);
	return 0;
}


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

const int MAXN = 1010;
const int MOD = 1e9 + 7;

char entrada[MAXN][MAXN];
int dp[MAXN][MAXN],vis[MAXN][MAXN];
int N,M;

int solve(int x,int y){

	if(x >= N || y >= M) return 0;
	if(entrada[x][y] == '#') return 0;

	if(vis[x][y]) return dp[x][y];
	if(x == N - 1 && y == M - 1) return dp[x][y] = 1;

	vis[x][y] = 1;
	return dp[x][y] = (solve(x+1,y) + solve(x,y+1)) % MOD;

}

int main(){

	scanf("%d %d",&N,&M);
	for(int i = 0;i<N;i++){
		scanf("%s",entrada[i]);
	}

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

	return 0;

}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const int INF = 1e+9;
 
int main()
{
	int a, p = 0;
	cin >> a >> p;
    int sum = (a * 3) + p;
    int ans = 0;
    if (sum > 1)
    {
        ans = sum / 2;
    }

    cout << ans << "\n";

	return 0;
}

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

int main(){
   int n, m = 0;
   int a[101];
   vector<int> ans;

   for(int i=1 ; i <= 100 ; i++){
       a[i] = 0;
   }
   while( cin >> n ){
       a[n]++;
   }
   for(int i=1 ; i <= 100 ; i++){
       m = max( a[i] , m );
   }
   for(int i=1 ; i <= 100 ; i++){
       if( m == a[i] ) ans.push_back(i);
   }
   sort( ans.begin() , ans.end() );
   for(int i=0 ; i < ans.size() ; i++ ){
       cout << ans[i] << endl;
   }
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define MOD 1000000007LL
#define endl "\n"
#define fst first
#define snd second
const ll UNDEF = -1;
const ll INF=1e18;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
ll n;
const ll MAXN=1e6+2;
ll f[MAXN];
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	scanf("%lld",&n);
	f[0]=1;
	f[1]=n;
	ll prefixsum=f[0]+f[1];
	for (ll x=2;x<=n;x++) {
		ll ans=prefixsum-f[x-2]+(n-2+1)*(n-1)+(n-x+1);
		ans%=MOD;
		if (ans<0) ans+=MOD;
		prefixsum=(prefixsum+ans)%MOD;
		f[x]=ans;
		//printf("x:%lld ans:%lld\n",x,ans);
	}
	printf("%lld\n",f[n]);
}



Measured memory_bytes: 8064
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;


// Combination Table
ll C[51][51]; // C[n][k] -> nCk

void comb_table(int N){
  for(int i=0; i <= N; ++i){
    for(int j=0; j <= i; ++j){
      if(j==0 or j==i) C[i][j] = 1LL;
      else C[i][j] = C[i-1][j-1] + C[i-1][j];
    }
  }
}

int main(){
  int N, A, B;
  cin >> N >> A >> B;
  const int NMAX=50;
  ll v[NMAX];

  for(int i=0;i<N;i++) cin >> v[i];

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

  double max_ave = 0.0;
  for(int i=0;i<A;i++) max_ave += v[i];
  max_ave /= A;

  int a_th_val_num = 0; // nCrのnに相当
  int a_th_val_pos = 0; // nCrのrに相当
  for(int i = 0; i < N; i++){
    if(v[i] == v[A-1]){
      a_th_val_num++;
      if(i<A) a_th_val_pos++;
    }
  }

  ll cnt=0LL;
  if(a_th_val_pos==A){
    for(a_th_val_pos=A;a_th_val_pos<=B;a_th_val_pos++)
      cnt += C[a_th_val_num][a_th_val_pos];
  }else
    cnt += C[a_th_val_num][a_th_val_pos];

  cout.precision(20);
  cout << fixed << max_ave << endl;
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
func main(){
    array := nextInts(3)
    for i := 2; i > 0; i-- {
    	for j := 0; j < i; j++ {
    		if (array[j] > array[j+1]) {
    			array[j], array[j+1] = array[j+1], array[j]
    		}
    	}
    }
    fmt.Printf("%v %v %v\n", array[0], array[1], array[2])
}

/* templates */

func Max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func Min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func Sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}

func Abs(a float64) float64 {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}

func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	return p[i].b < p[j].b
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}

func nextString() string {
	return nextReader()
}

func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}

func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}

func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}



Measured memory_bytes: 1132
#include<stdio.h>
int main(void){
  int n,i,j;
  scanf("%d",&n);
  for(i=0;i<26;i++){
    for(j=0;j<15;j++){
  if(4*i+7*j==n){ printf("Yes");
      return 0;
                }
    }
  }
   printf("No");
  return 0;
}

Measured memory_bytes: 128
def m():
    N = int(input())
    M = 100
    dp = [[[0] for _ in range(M)] for _ in range(M)]
    ANS = [0] * (N+1)
    for i in range(1, M+1):
        for j in range(1, M+1):
            for k in range(1, M+1):
                a = pow(i,2) + pow(j,2) + pow(k,2)
                b = i*j + j*k + k*i
                tmp = a + b
                if tmp > N:
                    continue
                ANS[tmp] +=1
    for i in range(1, N+1):
        print(ANS[i])
m()

Measured memory_bytes: 70620