akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<30;

// Óé¢@N10^8Å5s­ç¢
const int N = 10240000; // MAXPRIME 
const int M = 3200;     // SQRT(N)
const int K = 1643297;   // NUMBER OF PRIMES, CHOOSE 9/8 * N / LOG(N)
vector<int> iterSieve() {
  static int p[K], table[M];
  for (int i = 2; i < M; ++i) p[i] = i;
  for (int i = 2; i*i < M; ++i)
    if (p[i])
      for (int j = i*i; j < M; j += i)
        p[j] = 0;
  p[0] = p[1] = 0;
  int num = remove(p, p+M, 0) - p;
  for (int m = M; m < N; m += M) {
    for (int x = m; x < m+M; ++x)
      table[x-m] = x;
    for (int i = 0, j; p[i]*p[i] < m+M; ++i) {
      if (p[i] >= m)          j = p[i] * p[i];
      else if (m % p[i] == 0) j = m;
      else                    j = m - (m % p[i]) + p[i];
      for (; j < m+M; j += p[i]) table[j-m] = 0;
    }
    num = remove_copy(table, table+M, p+num, 0) - p;
  }
  return vector<int>(p, p+num);
}

#define N 1000100

int main() {
  vector<int> v = iterSieve();
  int n;
  while(cin>>n,n) {
    for (int i=upper_bound(ALL(v), n)-v.begin()-1; v[i] >= 13; --i) {
      int a = v[i];
      if (v[i-1] == a-2 && v[i-2] == a-6 && v[i-3] == a-8) {
        cout << a << endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 6216
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    vector<ll> a(5);
    rep(i,0,5) cin >> a[i];
    ll k;
    cin >> k;

    bool ans(true);
    rep(i,0,5)
        rep(j,i,5){
            ll t = a[j] - a[i];
            if (t > k) ans = false;
        }

    if (ans) cout << "Yay!" << endl;
    else cout << ":(" << endl;

    return 0;
}


Measured memory_bytes: 256
import numpy as np
n,d=map(int,input().split()) 
x=np.array([list(map(int,input().split())) for i in range(n)])
a=0
for k in range(n):
    for i in range(k+1,n):
        if np.linalg.norm(x[k]-x[i]).is_integer():
            a+=1
print(a) 

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

int main(){
    ll N; cin>>N;
    ll a[N],b[N];
    REP(i,N){
        cin >> a[i] >> b[i];
    }
    
    ll ans = -1;
    sort(a,a+N);
    sort(b,b+N,greater<ll>());
    if(N%2==1){    
        ll check = (N-1)/2;
        ans = (b[check]-a[check])+1;
    }else{
        ll check1 = (N/2-1);
        ll check2 = N/2;
        ll left_t2 = (a[check1]+a[check2]);
        ll right_t2 = (b[check1]+b[check2]);
        ans = (right_t2-left_t2)+1;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 6716
/*
    author: Salam_35
    Created at :

*/

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

#define ll long long int
#define pb push_back
#define sc(n) scanf("%d",&n)
#define Max 100005
#define scan(n) scanf("%lld",&n)
#define pi acos(-1.0)
#define _fastio  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ALL(x) x.begin(),x.end()
#define sci(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define load(array,size)  for(ll i=0 ; i<size ; i++) cin>>array[i] ;
#define load1(array,size)  for(ll i=1 ; i<=size ; i++) cin>>array[i] ;
#define INF	1LL<<19
#define pll pair<ll,ll>
#define mst(arr,value) memset(arr,value,sizeof(arr));
#define tst() int testsalam;cin >> testsalam;while(testsalam--)
#define Mod 100000007
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;
#define endl '\n'
//void inversemod(ll n, ll mod, ll invmod[],ll MOD){for(int i=2; i<=n; ++i) invmod[i]=MOD-MOD/i*invmod[MOD%i]%MOD;}
//void bigmod( ll a, ll b ,ll mod){ll r = 1;a = a%mod;while(b){if( b%2 ) r = (r*a)%mod;b = b/2;a = (a*a)%mod; }return (ll)r;}

typedef vector<ll>vec;
typedef pair<ll,ll> pii;
typedef map<ll,ll>mpll;
typedef set<ll>seet;

int main()
{
	double x;
	cin >> x;
	double pr=100;
	int cn=0;
	int t=10;
	while(pr<x)
	{
		pr=(pr+pr*.01);
		pr=floor(pr);		
		cn++;
	}
	cout<<cn<<endl;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
int solve(string a)
{
	if(a[0] != 'R' && a[1] != 'R' && a[2] != 'R') return 0;
	if(a[0] == 'R' && a[1] == 'R' && a[2] == 'R') return 3;
	if(a[0] == 'R' && a[1] == 'R') return 2;
	if(a[1] == 'R' && a[2] == 'R') return 2; 
	return 1;
}
int main()
{
	string a;
	cin >> a;
	cout << solve(a) << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void) {
	int r, c;
	int num[110][110];
	cin >> r >> c;
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			cin >> num[i][j];
			num[i][c] += num[i][j];
			num[r][j] += num[i][j];
			num[r][c] += num[i][j];
		}
	}
	for (int i = 0; i < r + 1; i++) {
		for (int j = 0; j < c + 1; j++) {
			cout << num[i][j];
			if (j == c) cout << endl;
			else cout << " ";
		}
	}
	return 0;
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
auto rd=read<int>;
const int N=1000, M=2e5;
typedef unsigned long long u64;
struct Bitset {
	u64 v[16];
	bool test(int i) {return v[i>>6]>>(i&63)&1;}
	void set(int i) {v[i>>6]|=1llu<<(i&63);}
	void reset(int i) {v[i>>6]&=~(1llu<<(i&63));}
	void reset() {memset(v, 0, sizeof(v));}
	int lb() {
		for(int i=0; i<16; ++i) if(v[i]) return i*64+__builtin_clzll(v[i]);
		return -1;
	}
};
int n, m, a[M], b[M], head[N], next[M], rhead[N], rnext[M];
int queue[N], *qhead, *qtail, min[N], max[N];
bool rev[M], without[M];
Bitset e[N], vis;
Bitset work(const Bitset &a, const Bitset &b) {
	Bitset res;
#define WORK(i) res.v[i]=a.v[i]&~b.v[i];
	WORK(0) WORK(1) WORK(2) WORK(3)
	WORK(4) WORK(5) WORK(6) WORK(7)
	WORK(8) WORK(9) WORK(10)WORK(11)
	WORK(12)WORK(13)WORK(14)WORK(15)
#undef WORK
	return res;
}
void bfs(int u) {
	qhead=qtail=queue;
	if(vis.test(u)) return;
	vis.set(*qtail++=u);
	while(qhead!=qtail) {
		u=*qhead++;
		for(int i=0; i<16; ++i)
			for(u64 j=e[u].v[i]&~vis.v[i]; j; j&=j-1)
				vis.set(*qtail++=i*64+__builtin_ctzll(j));
	}
}
int main() {
	n=rd(), m=rd();
	memset(head, -1, n*sizeof(int));
	memset(rhead, -1, n*sizeof(int));
	for(int i=0; i<m; ++i) {
		a[i]=rd()-1, b[i]=rd()-1;
		next[i]=head[a[i]];
		head[a[i]]=i;
		rnext[i]=rhead[b[i]];
		rhead[b[i]]=i;
		e[a[i]].set(b[i]);
	}
	for(int i=0; i<n; ++i) {
		vis.reset();
		bfs(i);
		for(int j=rhead[i]; j!=-1; j=rnext[j]) rev[j]=vis.test(a[j]);
	}
	for(int i=0; i<n; ++i) {
		std::vector<int> out;
		for(int j=head[i]; j!=-1; j=next[j]) out.push_back(j);
		vis.reset();
		vis.set(i);
		for(int j: out) {
			bfs(b[j]);
			for(int *p=queue; p!=qtail; ++p) max[*p]=j;
		}
		std::reverse(out.begin(), out.end());
		vis.reset();
		vis.set(i);
		for(int j: out) {
			bfs(b[j]);
			for(int *p=queue; p!=qtail; ++p) min[*p]=j;
		}
		for(int j=head[i]; j!=-1; j=next[j]) without[j]=(min[b[j]]!=j)||(max[b[j]]!=j);
	}
	for(int i=0; i<m; ++i) puts(rev[i]^without[i]?"diff":"same");
	return 0;
}


Measured memory_bytes: 4864
from operator import xor, add
from itertools import accumulate

N = int(input())
A = [0] + list(map(int, input().split()))

Asum = list(accumulate(A, func=add))
Axor = list(accumulate(A, func=xor))

ans = 0
r = 0
for l in range(N):
    while r < N and Asum[r+1] - Asum[l] == Axor[r+1] ^ Axor[l]:
        r += 1
    ans += r - l
    if r == l:
        r += 1

print(ans)

Measured memory_bytes: 28748
s, count, m, pow10, ans = input(), [0 if i else 1 for i in range(2019)], 0, 1, 0
for c in reversed(s):
    m = (m + (ord(c) - ord('0')) * pow10) % 2019
    pow10 = pow10 * 10 % 2019
    ans += count[m]
    count[m] += 1
print(ans)


Measured memory_bytes: 68252
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    int MOD = 1000000007;
    String S = sc.nextLine();
    int n = S.length();
    long[][] dp = new long[100002][13];
    
    dp[0][0] = 1;
    int m = 1;
    for(int i = 1; i <= n; i++){
      char c = S.charAt(n-i);
      if(c == '?'){
        for(int j = 0; j < 10; j++){
          for(int k = 0; k < 13; k++){
            dp[i][(j*m+k)%13] += dp[i-1][k];
            dp[i][(j*m+k)%13] %= MOD;
          }
        }
      }else{
        int j = (int)(c - '0');
        for(int k = 0; k < 13; k++){
          dp[i][(j*m+k)%13] += dp[i-1][k];
          dp[i][(j*m+k)%13] %= MOD;
        }
      }
      m *= 10;
      m %= 13;
    }
    
    System.out.println(dp[n][5]);
  }
}

Measured memory_bytes: 40872
#B - Great Ocean View
N = int(input())
H = list(map(int, input().split()))
ans = 0
for i in range(N):
    isOk = True
    if i != 0:
        for j in range(i):
            if H[i] < H[j]:
                isOk = False
    if isOk:
        ans += 1
print(ans)

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

int main(void){
    string s;
    int count[4] = {}, count_all = 0;

    cin >> s;
    
    rep(i, 4){
        rep(j, 4){
            if(s[i] == s[j])
                count[i]++;
        }
    }

    rep(i, 4){
        if(count[i] == 2)
            count_all++;
    }

    if(count_all == 4)
        puts("Yes");
    else
        puts("No");

    return 0;
}


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


def solve(N, B):
    ans = 0
    last_b = float('inf')
    for b in B:
        ans += min(b, last_b)
        last_b = b
    ans += B[-1]
    return ans


if __name__ == '__main__':

    N = int(input())
    B = list(map(int, input().split()))

    ans = solve(N, B)

    print(ans)


Measured memory_bytes: 2940
#include<stdio.h>
int main()
{
    int a,b,c,d,e,k;
    scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&k);
    int h,j,q,w,r,t,y,u,i,o,p;
   if(a<b<c<d<e)
   {
       h=b-a; j=c-a; q=d-a; w=e-a;

    r=c-b;t=d-b;y=e-b;
    u=d-c;
    i=e-c;
    o=e-d;
    if(h<=k&&j<=k&&q<=k&&w<=k&&r<=k&&t<=k&&y<=k&&u<=k&&i<=k&&o<=k)
    {
        printf("Yay!");
    }
    else
    {
        printf(":(");
    }
   }


}


Measured memory_bytes: 128
fun main(args: Array<String>) {
    val N = readInputLine().toInt()
    
    if (N <= N / 100 * 100 + N / 100 * 10 + N / 100) {
        println(N / 100 * 100 + N / 100 * 10 + N / 100)
    } else {
        println((N / 100 + 1) * 100 + (N / 100 + 1) * 10 + (N / 100 + 1))
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 33740
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int H, W;
int c[10][10];
int main() {
    cin >> H >> W;
    Fill(c, INF);
    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            int cost; cin >> cost;
            c[i][j] = cost;
        }
    }

    int a[210][210];
    int b;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> b;
            a[i][j] = b;
        }
    }

    for (int k = 0; k < 10; k++)
    {
        for (int i = 0; i < 10; i++)
        {
            for (int j = 0; j < 10; j++)
            {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if(a[i][j] == -1) continue;
            ans += c[a[i][j]][1];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  N = 1e6 + 5;

void solve(){
	ll a,b;cin>>a>>b;
	cout<<a*b<<'\n';
}

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

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

int main() {
  int n, c;
  cin >> n >> c;
  vector<tuple<int, int, int>> p(n);
  for (int i = 0; i < n; i++) {
    int s, t, c;
    cin >> s >> t >> c;
    p.at(i) = make_tuple(c, s, t);
  }
  sort(p.begin(), p.end());
  for (int i = 1; i < n; i++) {
    if (get<0>(p.at(i)) == get<0>(p.at(i - 1)) and get<1>(p.at(i)) == get<2>(p.at(i - 1))) {
      get<1>(p.at(i))++;
    }
  }
  vector<pair<int, int>> e;
  for (int i = 0; i < n; i++) {
    e.emplace_back(get<1>(p.at(i)) - 1, 1);
    e.emplace_back(get<2>(p.at(i)), -1);
  }
  sort(e.begin(), e.end());
  int ans = 0, r = 0;
  for (auto x : e) {
    r += x.second;
    ans = max(ans, r);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3572
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
using namespace std;
int sosu[1000001];
vector<int> s;
int N;
int main(){
  for(int i=2;i<1000000;i++){
    if(sosu[i]) continue;
    s.push_back(i);
    for(int j=i+i;j<1000000;j+=i){
      sosu[j]=1;
    }
  }
  while(scanf("%d",&N),N){
    int res = 0;
    for(int i=0;i<=(int)s.size();i++){
      int h = N - s[i];
      //    printf("%d %d\n",s[i],h);
      if(h<0) break;
      if(h<s[i]) break;
      if(!sosu[h]) res ++;
    }
    printf("%d\n",res);
  }
}

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define debug(i) cout << i << endl;
#define debugarr(a) for(auto i : a) cout << i << " ";

#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int,int>
#define pll pair<ll, ll>
#define vpi vector<pi>

using namespace std;

int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    int mods[n+1];
    for(int i = 1; i <= n; i++) cin >> mods[i];

    vector<int> muls[n+1];
    int somas[n+1];
    memset(somas, 0, sizeof somas);
    
    int p = 1;
    while(p <= n) {
        for(int i = p; i <= n; i+=p) {
            muls[p].PB(i);
            somas[i] += 1;
        }
        p++;
    }

    int ans[n+1];
    memset(ans, 0, sizeof ans);

    /*for(int i = 1; i <= n; i++) {
        cout << "Multiplos de " << i << endl;
        for(int num : muls[i]) {
            cout << num << " ";
        }
        cout << endl;
    }*/

    vector<int> resps;

    for(int i = n; i >= 1; i--) {
        if(muls[i].size() == 1) {
            ans[i] = mods[i];
            if(ans[i] == 1) resps.PB(i);
        }else {
            int soma = 0;
            for(int mult : muls[i]) {
                if(mult == i) continue;
                soma += ans[mult];
            }
            //cout << "soma de " << i << ": " << soma << endl;
            if(soma % 2 == mods[i]) ans[i] = 0;
            else{
                resps.PB(i);
                ans[i] = 1;
            }
        }
    }
    
    cout << resps.size() << endl;
    for(int i = 0; i < resps.size(); i++) {
        cout << resps[i];
        if(i < resps.size() - 1) cout << " ";
    }
    if(resps.size() > 0)
    cout << endl;
}


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

int main(){
  while(1){
    int H, W;
    cin>>H>>W;
    if(H == 0 && W == 0) break;
    
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
        cout<<"#";
      }
      cout<<endl;
    }
    cout<<endl;
  }
  
  return 0;
}




Measured memory_bytes: 3060
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>

using namespace std;

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

map<string, int> mp;

struct P {
  string name;
  int val;
  bool operator<(P p) const {
    if (name.size() != p.name.size()) return name.size() < p.name.size();
    return name < p.name;
  }
};

int main() {
  int n;
  cin >> n;
  vector<P> p;
  rep (i, n) {
    string name;
    int val;
    cin >> name >> val;
    if (mp.count(name)) {
      p[mp[name]].val += val;
    } else {
      mp[name] = p.size();
      p.push_back((P){name, val});
    }
  }
  sort(p.begin(), p.end());
  rep (i, p.size()) cout << p[i].name << " " << p[i].val << endl;
}

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


int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){		
		int a, b, c;
		cin >> a >> b >> c;
		if (a * a == b * b + c * c || b * b == a * a + c * c || c * c == a * a + b * b){
			cout << "YES" << endl;
		}
		else{
			cout << "NO" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <fstream>
using namespace std;
typedef long long ll;

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

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	//数値の入力
		int n = sc.nextInt();
      	int t = sc.nextInt();
      	//配列
        int num[] = new int[n];
        for(int i = 0; i < n; i++){
        	num[i] = sc.nextInt();
        }
        int ans = t;
        for(int i = 1; i < n; i++){
        	if(num[i]-num[i-1]<=t){
            	ans += num[i]-num[i-1];
            }else{
              	ans = t+ans;
            }
        }
        System.out.println(ans);
     }
}

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

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, m, n) for (ll i = (m); i < (n); i++)
#define FORR(i, m, n) for (ll i = (m); i >= (n); i--)
#define INF 1e9
#define pb push_back
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((ll)(x).size())
#define SORT(x) sort((x).begin(), (x).end())
#define dump(x) cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl

int main(int argc, char const *argv[])
{
    ll n, a, b;
    cin >> n >> a >> b;
    ll x = 0;
    if (a + b - n < 0)
    {
        x = 0;
    }
    else
    {
        x = abs(a + b - n);
    }
    cout << min(a, b) << " " << x << endl;
    return 0;
}


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

using namespace std;

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

typedef pair<long long, long long> ii;

const int N = 1e5 + 5;

ii a[N];

int n;

vector<pair<ii, int>> queries;

long long mn = LLONG_MAX, sum, sum1, sum2;

ii used[N];

int main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n;
    for(int i = 1; i <= n; i++) {
        cin >> a[i].fi >> a[i].se;
        sum1 += a[i].fi; sum2 += a[i].se;
        queries.pb({{a[i].fi, i}, 1});
        queries.pb({{a[i].se, i}, 2});
    }
    mn = min(mn, sum1); mn = min(mn, sum2);
    sort(queries.begin(), queries.end());
    for(int i = 0; i < queries.size(); i++) {
        if(i < n - 2)
            sum += queries[i].fi.fi;
        if(queries[i].se == 1)
            used[queries[i].fi.se].fi = i;
        else
            used[queries[i].fi.se].se = i;
    }
    for(int i = 1; i <= n; i++) {
        if(used[i].fi >= n - 2 && used[i].se >= n - 2)
            mn = min(mn, sum + a[i].fi + a[i].se);
        else if(used[i].fi < n - 2 && used[i].se >= n - 2) {
            int pos = n - 2;
            if(used[i].se == n - 2) pos++;
            mn = min(mn, sum + a[i].se + queries[pos].fi.fi);
        }
        else if(used[i].fi >= n - 2 && used[i].se < n - 2) {
            int pos = n - 2;
            if(used[i].fi == n - 2) pos++;
            mn = min(mn, sum + a[i].fi + queries[pos].fi.fi);
        }
        else {
            int pos = n - 2, pos1 = n - 1;
            mn = min(mn, sum + queries[pos].fi.fi + queries[pos1].fi.fi);
        }
    }
    cout << mn;
}


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

int main(){
	int sum;
	int a,b;
	int m,n;
	while(cin>>m,m!=0){
		cin>>n;
		sum=0;
		for(int i=0;i<n;i++){
			cin>>a>>b;
			sum+=b-a;
		}
		if(m<=sum)cout<<"OK"<<endl;
		else cout<<m-sum<<endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>

using namespace std;

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

int main() {
    int N, A, B;
    cin>>N;
    cin >> A;
    for(int i = 0; i < N-1; i++) {
        cin>>B;
        A=gcd(A,B);
    }
    cout<<A;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
	 int x,s=0,k=0,l=1;
	cin>>x;
	for( int i=sqrt(x);i>=1;i--){
		for( int j=2;j<=x;j++){
			s=j;
			k=1;	
			while(s!=0){
				s--;
				k=k*i;
				if(k<=x) l=max(l,k);
			}
		}
	}
	cout<<l;
	return 0;
}


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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
map<ll int, int> d;
int n,m;
int main(){
	cin >> n;
	REP(i,n){
		ll int tmp;
		cin >> tmp;
		if(d.find(tmp) == d.end()) d[tmp] = 0;
		d[tmp]++;
	}
	cin >> m;
	bool flag = true;
	if(n < m) flag = false;
	REP(i,m){
		ll int t;
		cin >> t;
		if(d.find(t) == d.end() || d[t] == 0) flag = false;
		d[t]--;
	}
	if(flag) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 12800
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=500010;

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

    ll n,k;
    cin>>n>>k;
    ll ar[n];
    for(ll i=1;i<=n;++i){
        cin>>ar[i];
    }
    if(k<=n){
        ll curr=1;
        while(k--){
            curr=ar[curr];
        }
        cout<<curr;
    }
    else{
        vector<ll> path;
        set<ll> s;
        ll curr=1;
        while(1)
        {
            if(s.find(curr)!=s.end()){break;}
            s.insert(curr);
            path.pb(curr);
            curr=ar[curr];
        }
        int idx=0;
        for(idx=0;idx<path.size();++idx){
            if(path[idx]==curr){break;}
            --k;
        }
        vector<ll> ch;
        while(idx<path.size()){
            ch.pb(path[idx]);++idx;
        }
        k=k%ch.size();
        cout<<ch[k];
    }

    return (0);
}


Measured memory_bytes: 14452
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define tr(con, it) \
    for (auto it = con.begin(); it != con.end(); it++)
#define present(con, ele) (con.find(ele) != con.end())
#define cpresent(con, ele) (find(all(con), ele) != con.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double lf;
typedef pair<int, int> pi;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
int32_t main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long long int n, ans = 1;
    cin >> n;
    vll prime(n + 1, -1);
    for (ll i = 2; i <= n; i++)
    {
        if (prime[i] == -1)
        {
            for (ll j = i; j <= n; j += i)
            {
                prime[j] = i;
            }
        }
    }
    unordered_map<ll, ll> M;
    for (ll i = 2; i <= n; i++)
    {
        M.clear();
        ll num = i, tp = 1;
        while (num != 1)
        {
            M[prime[num]]++;
            num /= prime[num];
        }
        tr(M, it)
        {
            tp = ((*it).second + 1) * tp;
        }
        ans += tp * i;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 81340
#![allow(non_snake_case)]
#![allow(unused_imports)]
 
use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;

#[fastout]
fn main() {
    input!{
        N: Chars,
    }

    let last_word = N[N.len()-1];

    if last_word == '2' || last_word == '4' || last_word == '5' || last_word == '7' || last_word == '9' {
        println!("hon")
    } else if last_word == '0' || last_word == '1' || last_word == '6' || last_word == '8' {
        println!("pon")
    } else {
        println!("bon")
    }
}


Measured memory_bytes: 2200
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int n,a=2,b=1,c=3,d;
  cin>>n;
  for(int i=0;i<n;i++){
    c=c+b;
    d=b;
    b=b+a;
    a=d;
  }
  cout<<a<<endl;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.parseLong;
//import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

import java.io.PrintWriter;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int a = parseInt(sc.next());
		int b = parseInt(sc.next());
		int k = parseInt(sc.next());
		sc.close();
		PrintWriter pw = new PrintWriter(out);
		for (i = a; i <=b; i++) {
			if(i<a+k || b-k<i) {
				pw.println(i);
			}
		}
		pw.flush();
	}
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;


const ll MOD = 1e9+7;
 
template <ll MOD>
struct modint{
    ll x;
    modint() : x(0) {}
    modint(ll a): x((a % MOD + MOD) % MOD) {}
    
    
 
    bool operator!() const{return !x;}
 
    bool operator<(const modint &a) const{
        modint res(*this);
        return res.x < a.x;
    }
    
    bool operator>(const modint &a) const{
        modint res(*this);
        return res.x > a.x;
    }
 
    modint &operator+=(const modint &a){
        if((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
 
    modint &operator-=(const modint &a){
        if((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
 
    modint &operator*=(const modint &a){
        (x *= a.x) %= MOD;
        return *this;
    }
 
    modint &operator/=(const modint &a){
        *this *= a.inv();
        return *this;
    }
 
    modint &operator%=(const modint &a){
        x %= a.x;
        return *this;
    }
 
    modint operator-() const{ return modint(-x); }
 
    modint operator+(const modint &a) const{ return modint(*this) += a; }
    modint operator-(const modint &a) const{ return modint(*this) -= a; }
    modint operator*(const modint &a) const{ return modint(*this) *= a; }
    modint operator/(const modint &a) const{ return modint(*this) /= a; }
    modint operator%(const modint &a) const{ return modint(*this) %= a; }
    bool operator==(const modint &a) const{ return x == a.x; }
    bool operator!=(const modint &a) const{ return x != a.x; }
 
 
    modint pow(ll n) const{
        modint res(1), a(x);
        while(n > 0){
            if(n & 1) res *= a;
            a *= a;
            n /= 2;
        }
        return res;
    }
 
    modint inv() const{
        return this->pow(MOD-2);
    }
 
    friend ostream &operator<<(ostream &os, const modint &m){
        return os << m.x;
    }
 
    friend istream &operator>>(istream &is, modint &m){
        ll t;
        is >> t;
        m = modint<MOD>(t);
        return (is);
    }
    
    static ll get_mod(){ return MOD; }
};
using mint = modint<MOD>;

signed main(){
    ll n;
    cin >> n;
    ll cnt[61] = {};

    rep(i,0,n){
        ll a;
        cin >> a;
        rep(j,0,61){
            cnt[j] += a % 2;
            a /= 2;
        }
    }

    mint ans = 0;
    rep(i,0,61){
        mint temp = 1,pow2 = 2;
        temp *= pow2.pow(i);
        temp *= (n - cnt[i]);
        temp *= cnt[i];
        ans += temp;
    }

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


Measured memory_bytes: 256
import heapq
import math

class Heapq:
    def __init__(self, arr, desc=False):
        if desc:
            arr = [-a for a in arr]
        self.sign = -1 if desc else 1
        self.hq = arr
        heapq.heapify(self.hq)

    def pop(self):
        return heapq.heappop(self.hq) * self.sign

    def push(self, a):
        heapq.heappush(self.hq, a * self.sign)

    def top(self):
        return self.hq[0] * self.sign


n, m = map(int,input().split())
a = list(map(int, input().split()))

q = Heapq(a, desc=True)

for i in range(m):
    qi = q.pop()
    q.push(math.floor(qi/2))

ans = 0

for i in range(n):
    ans += q.pop()

print(ans)

Measured memory_bytes: 14528
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int n,m;
vector<int> siz;
vector<int> par;
int find(int node)
{
	while(node!=par[node])node=par[node];
	return node;
}
void uni(int a,int b)
{
	a=find(a);b=find(b);
	if(a==b)return;
	if(siz[a]<siz[b])swap(a,b);
	siz[a]+=siz[b];
	par[b]=a;
}
bool same(int a,int b)
{
	a=find(a);b=find(b);
	return a==b;
}
int32_t main()
{
	n=in();m=in();
	siz=vector<int>(n,1);
	par=vector<int>(n);
	iota(par.begin(),par.end(),0);
	int a[m],b[m];
	for(int i=0;i<m;i++)
	{
		a[i]=in();b[i]=in();
		a[i]--;b[i]--;
	}
	
	vector<int> ans;
	int t=n*(n-1);t/=2;
	ans.push_back(t);
	
	for(int i=m-1;i>=1;i--)
	{
		if(!same(a[i],b[i]))
		{
			t-=siz[find(a[i])]*siz[find(b[i])];
			uni(a[i],b[i]);
		}
		ans.push_back(t);
	}
	reverse(all(ans));
	for(auto i:ans)cout<<i<<'\n';
	
	
	
}

Measured memory_bytes: 7452
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
    unsigned long long int n=0,a,i;
    cin>>a;
    for(i=1;i<=a;i++)
    {
        if(i%3==0 || i%5==0)
            continue;
        else
            n+=i;
    }
    cout<<n<<endl;
    return 0;
}


Measured memory_bytes: 3592
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
const int MAXN=100;
int n,A[MAXN+5];
int main()
{
	scanf("%d",&n);
	int last=-1,len=0;
	int ans=0;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&A[i]);
		if(A[i]!=last)
		{
			ans+=len/2;
			last=A[i];len=1;
		}
		else
			len++;
	}
	ans+=len/2;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN (long)(-922337203685477587LL)
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=-922337203685477587LL;
  cin >> n >> k;
  
  vi p(n),c(n);
  REP(i,n){
    cin>>p[i];
    p[i]--;
    }
  REP(i,n) cin>>c[i];

  vvi data(n, vi(n));  // N * M の2次元配列
  for(ll i=0;i<n;i++){
    for(ll j=0;j<n;j++){
      data[i][j]=-922337203685477587LL;
    }
  }

  ll nowmasu=-1;
  ll score=0;
  for(ll i=0;i<n;i++){//最初に選ぶマス
    nowmasu=i;
    score=0;
    //data[i][i]=0;//score
    ll cnt=0;
    for(ll j=0;j<min(k,n);j++){
      if (data[i][p[nowmasu]]!=-922337203685477587LL)break;
      nowmasu=p[nowmasu];
      score+=c[nowmasu];
      cnt++;
      data[i][nowmasu]=score;
      ans=max(ans,score);
    }
    //今のnowmasuは必ず最初の地点
    if (k!=cnt){
      ll nnum=(k-cnt)/cnt;
      score*=nnum;
      if (nnum!=0)ans=max(ans,score);
      ll kk=k-nnum*cnt;
      
      for(ll j=0;j<kk;j++){
        nowmasu=p[nowmasu];
        score+=c[nowmasu];
        ans=max(ans,score);
      }
    }

    

  }


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

/*
2 4
2 1
10 -7
*/

Measured memory_bytes: 198808
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>

using namespace std;

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

#define BIL ((ll)1e9)
#define MOD ((ll)1e9+7)
#define INF (1LL<<60)           //1LL<<63でオーバーフロー

int main(int argc,char* argv[]){
    int n;
    cin >> n;

    vector<ll> l(n);
    for(auto &x:l)
        cin >> x;
    
    sort(l.begin(),l.end());
    
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(l.at(i)==l.at(j))
                continue;
            for(int k=j+1;k<n;k++){
                if(l.at(j)==l.at(k))
                    continue;
                if(l.at(i)+l.at(j)>l.at(k))
                    ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
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);
}

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  int a, b;

  cin >> a >> b;
  if (a <= b * 2)
    pr(0);
  else
    pr(a - b * 2);

  return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(all(a));

  vector<ll> v;
  rep(i, n) {
    int pos = i;
    while (pos < n) {
      if (pos + 1 < n && a[i] == a[pos + 1])
        pos++;
      else
        break;
    }
    int cnt = pos - i + 1;
    if (cnt >= 2) v.eb(a[i]);
    if (cnt >= 4) v.eb(a[i]);
    i = pos;
  }

  reverse(all(v));

  if (v.size() < 2)
    cout << "0" << endl;
  else
    cout << v[0] * v[1] << endl;
}


Measured memory_bytes: 1276
package main

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

func solve() {
	n := scanInt()
	search := prime_factors(n)
	jud := map[int]int{}
	flag := false
	count := 0
	for _, s := range search {
		jud[s] = 1
	}
	for {
		flag = false
		for k, v := range jud {
			if n%pow(k, v) == 0 {
				n /= pow(k, v)
				jud[k]++
				flag = true
				break
			}
		}
		if flag {
			count++
			continue
		}
		break
	}

	fmt.Println(count)
	return
}

var sc = bufio.NewScanner(os.Stdin)

func scanString() string {
	sc.Scan()
	return sc.Text()
}
func scanInt() int {
	sc.Scan()
	a, err := strconv.Atoi(sc.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}
func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanString(), 64)
	return f
}
func Permute(nums []int) [][]int {
	n := factorial(len(nums))
	ret := make([][]int, 0, n)
	permute(nums, &ret)
	return ret
}
func permute(nums []int, ret *[][]int) {
	*ret = append(*ret, makeCopy(nums))

	n := len(nums)
	var i, j int
	for {
		for i = n - 2; i >= 0; i-- {
			if nums[i] < nums[i+1] {
				break
			}
		}
		if i < 0 {
			return
		}
		for j = n - 1; ; j-- {
			if nums[j] > nums[i] {
				break
			}
		}
		nums[i], nums[j] = nums[j], nums[i]
		for k, l := i+1, n-1; k < l; {
			nums[k], nums[l] = nums[l], nums[k]
			k++
			l--
		}
		*ret = append(*ret, makeCopy(nums))
	}
}

func factorial(n int) int {
	ret := 1
	for i := 2; i <= n; i++ {
		ret *= i
	}
	return ret
}

func pow(n, m int) int {
	ret := 1
	for i := 0; i < m; i++ {
		ret *= n
	}
	return ret
}
func makeCopy(nums []int) []int {
	return append([]int{}, nums...)
}
func gcd(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func eratosthenes(n int) []int {
	search := make([]bool, n+1)
	ans := []int{}
	for i := 2; i < n+1; i++ {
		search[i] = true
	}
	for i := 2; i*i < n+1; i++ {
		for j := 2; i*j < n+1; j++ {
			search[i*j] = false
		}
	}
	for i := 2; i < n; i++ {
		if search[i] {
			ans = append(ans, i)
		}
	}
	return ans
}
func prime_factors(n int) []int {
	factors := make([]int, 0)
	i := 2
	for i*i <= n {
		r := n % i
		if r != 0 {
			i += 1
		} else if r == 0 {
			n /= i
			factors = append(factors, i)
		}
	}
	if n > 1 {
		factors = append(factors, n)
	}
	return factors
}

func main() {
	sc.Split(bufio.ScanWords)
	solve()
}


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

using namespace std;

#define ll long long
#define vi  vector<int>
#define vvi vector<vi>
#define pi  pair<int,int>
#define mp  make_pair
#define pb  push_back
#define MOD 1e9 + 7
#define PAI  3.1415
#define all(x) (x).begin(),(x).end()
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define pr(x) cout << x << endl
#define Endl endl
#define rep(i,n) for(int i = 0 ; i < n; i++)

const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int ddx[8] = {-1,0,1,-1,1,-1,0,1};
const int ddy[8] = {-1,-1,-1,0,0,1,1,1};
const int inf = 99999999;
const ll linf = 1LL << 62;

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

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

int main(){

  int a,b ; cin >> a >> b;
  if(a <= b)pr(a);
  else pr(a-1);

  return 0;
}


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

int main(void) {

	// TODO: submit前にprintf-debugの削除確認！
	int r, g, b, n;
	//long long N, M;
	//double d, e;
	//string s, t;
	//vector<int> v;
	//vector<pair<int, int>> pl;

	//while() {}
	//for(int i=0; i<N; i++) {}
	
	cin >> r >> g >> b >> n;
	int ans = 0;

	for(int ri=0; ri*r<=n; ri++) {
		int rNum = ri * r;
		for(int gi=0; gi*g+rNum<=n; gi++) {
			int gNum = gi * g;
			int left = n - (rNum + gNum);
			int mod = left % b;
			if(mod == 0) ans++;
		}
	}

	cout << ans;
	// cout << "[deb: val ]" << val <<endl;
	return 0;
}



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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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

signed main(){
    int n;
    cin>>n;
    vint a(n);rep(i,n)cin>>a[i];

    deque<int>d;
    rep(i,n){
        if(i&1)d.push_back(a[i]);
        else d.push_front(a[i]);
    }
    if(n%2==0)reverse(all(d));
    rep(i,n){
        if(i)cout<<" ";
        cout<<d[i];
    }cout<<endl;
    return 0;
}


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

using namespace std;

void out(int A[], int N)
{
    for(int i = 0; i < N; i++){
        if(i > 0){
            cout << " ";
        }
        cout << A[i];
    }
    cout << endl;
}

void insertionSort(int A[], int N) 
{
    for(int i = 1; i < N; i++){
        int a = A[i];
        int j = i - 1;
        for(; j >= 0 && A[j] > a ; j--){
            A[j + 1] = A[j];
        }
        A[j + 1] = a;
        out(A, N);
    }
}

int main()
{
    int N;
    int A[1000];
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    out(A, N);
    insertionSort(A, N);
    return 0;
}


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

using namespace std;
 
const int inf = 1e8;
#define ll long long
#define fr(i,a,n) for (int i=a;i<n;i++)
#define rfr(i,n,a) for (int i=n;i>=a;i--)
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define endl "\n"
typedef vector<int> VI;
typedef vector<ll> VL;

int n, m, k;
int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m;
	int cnt = 0;
	while (n) {
		for (int i = 22;i <= m;i++) {
			int cp = i;
			int d1 = i % 10,d10 = (i / 10) % 10;
			if (d1 < 2 || d10 < 2)
				continue;
			if (d1 * d10 == n) {
				cnt++;
			}
		}
		n--;
	}	
	cout << cnt << endl;
	return 0;
}

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

int main()
{
  int n;
  double d;
  cin >> n >> d;
  int cnt = 0;  
  while(n--){
    double x,y,res;
    cin >> x >> y;
    res = sqrt(x*x + y*y);
    if(res <= d) cnt++;
  }
  cout << cnt;
  return 0;
}


Measured memory_bytes: 3820
n=int(input())
a_list=list(map(int,input().split()))
ans=0
for i in range(n):
    for j in range(n):
        for k in range(n):
            if i==j or j==k or i==k:
                ans+=0
            elif a_list[i]==a_list[j]or a_list[k]==a_list[i] or a_list[j]==a_list[k]:
                ans+=0
            else:
                #print(i,j,k)
                if max(a_list[i],a_list[j],a_list[k]) < a_list[i]+a_list[j]+a_list[k]-max(a_list[i],a_list[j],a_list[k]):
                    #print(a_list[i],a_list[j],a_list[k])
                    ans+=1
print(ans//6)

Measured memory_bytes: 9220
function maxCards(arr,max){
   for(var i=0;i<n-(k-1);i++){
      var x=1;
      var j=0;
      while(j<k){
         x*=arr[i+j];
         j++;
      }
      max=Math.max(max,x);
   }
   return max;
}
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var I=0;
while(true){
   var nk=Arr[I].split(" ").map(Number);
   I++;
   var n=nk[0];
   var k=nk[1];
   if(n==0 && k==0)break;
   var c=[];
   for(var i=0;i<n;i++){
      c.push(Arr[I]);
      I++;
   }
   var maxA=1;
   maxA=maxCards(c,maxA);
   var maxB=1;
   for(var i=0;i<n;i++){
      for(var j=i+1;j<n;j++){
         var memo=c[i];
         c[i]=c[j];
         c[j]=memo;
         maxB=maxCards(c,maxB);
         c[j]=c[i];
         c[i]=memo;
      }
   }
   console.log((maxA>maxB)?"NO GAME":maxB-maxA);
}

Measured memory_bytes: 9920
const p = (...args) => {
  process.env.NODE_ENV === "test" ? console.log(...args) : ""
}

const solve = (k, xs) => {
  if (xs.length == 1) {
    return xs[0]
  }
  let r = Infinity
  for (var i = 0; i < xs.length - k + 1; i++) {
    let p = xs[i]
    let n = xs[i + k - 1]
    let pa = Math.abs(p)
    let na = Math.abs(n)
    if (n * p > 0) {
      r = Math.min(r, Math.max(na, pa))
    } else {
      let a = pa * 2 + na
      let b = na * 2 + pa

      r = Math.min(r, a, b)
    }
  }
  return r
  // ...
}
const main = (input) => {
  const [head, rest] = input.split("\n")
  const [n, k] = head.split(" ").map(Number)

  return solve(k, rest.split(" ").map(Number))
}

if (process.env.NODE_ENV !== "test") {
  const input = require("fs").readFileSync("/dev/stdin", "utf8")
  console.log(main(input.trim()))
}

if (process.env.NODE_ENV === "test") {
  // module.exports = (input) => solve(input.trim())
  // main(``)
  // solve(1, [2, 3, 4])
}


Measured memory_bytes: 17612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define fi first
#define se second
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    int a,b;
    cin>>a>>b;
    if(a==1&&b==1) cout<<1000000<<'\n';
    else
    {
        int ans=0;
        if(a<=3) ans+=(4-a)*100000;
        if(b<=3) ans+=(4-b)*100000;
        cout<<ans<<'\n';
    }
    
    return 0;
}

Measured memory_bytes: 256