akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef long long int64;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
template<class T,class U>bool chmax(T &a, const U &b){if (a<b){a=b;return true;}return false;}
template<class T,class U>bool chmin(T &a, const U &b){if (b<a){a=b;return true;}return false;}
template<class T,class U>void vcin(T &v, U n){rep(i, n){typename T::value_type a;cin >> a;v.pb(a);}}
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cii(k);
    int64 ans=0;
    function<int64(int64, int64)> gcd = [&gcd](int64 x, int64 y){
        return !y ? x : gcd(y, x % y);
    };
    rep1(i, k){
        rep1(j, k){
            rep1(y, k){
                ans += gcd(gcd(i, j), y);
            }
        }
    }
    co(ans);

    return 0;
}


Measured memory_bytes: 3644
#include <iostream>

int main() {
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;

    if(std::abs(a - c) <= d) {
        std::cout << "Yes" << std::endl;
    } else if(std::abs(a - b) <= d && std::abs(b - c) <= d) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Arrays;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    double[] v = new double[N];
    int i = 0;
    int ptr = 1;
    int avgs = 0;

    for(i = 0; i < N; i++){
    	v[i] = sc.nextInt();
    }
    Arrays.sort(v);

    if(N == 2){
    	System.out.println((v[0] + v[1]) / 2);
    }else{
	    for(i = 2; i < N; i++){
	    	v[0] = (v[0] + v[1]) / 2;
	    	v[1] = v[i];
	    }
	    System.out.println((v[0] + v[1]) / 2);
	}
  }
}

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

void call(int n); 
int main(){

	int S[14]={0};
	int H[14]={0};
	int C[14]={0};
	int D[14]={0};
	int n=0,num=0;
	char mark;

	cin >> n;

	for(int i=0;i<n;i++){
		cin >> mark >> num;

		if(mark=='S'){
			S[num]=1;
		}else if(mark=='H'){
			H[num]=1;
		}else if(mark=='C'){
			C[num]=1;
		}else if(mark=='D'){
			D[num]=1;
		}
	}

	for(int i=1;i<14;i++){
		if(S[i]==0){
			cout << "S " << i << endl;
		}
	}
	for(int i=1;i<14;i++){
		if(H[i]==0){
			cout << "H " << i << endl;
		}
	}
	for(int i=1;i<14;i++){
		if(C[i]==0){
			cout << "C " << i << endl;
		}
	}
	for(int i=1;i<14;i++){
		if(D[i]==0){
			cout << "D " << i << endl;
		}
	}
	
	



return 0;
}

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

int main() {
  ll N;
  string s;
  cin >> N >> s;
  
  ll x=s.size();
  ll red=0;
  for (ll i=0;i<x;i++) {
    if (s.at(i)=='R') {
      red++;
    }
  }
  
  if (red>x-red) {
    cout << "Yes";
  }
  else {
    cout << "No";
  }
}
  


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int x = saori.saori_hayami();
		int sum = 0;
		int min = MAX;
		int count = 0;
		int[] m = new int[n];
		for(int i = 0;i < n;i++){
			m[i] = saori.saori_hayami();
			min = Math.min(min, m[i]);
			sum += m[i];
			count++;
		}
		int sa = x - sum;
		boolean flg = true;
		while(flg){
			if(sa >= min){
				sa -= min;
				count++;
			} else {
				flg = false;
			}
		}
		System.out.println(count);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leadinz zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
ll bin_pow(ll a,ll b,ll m)
{
    ll res=1;
    a%=m;
    while(b>0){
        if(b&1)res=res*a%m;
        b>>=1;
        a=a*a%m;
    }
    return res;
}
bool miller_rabin(ll d,ll n)
{
    ll a=2+rand()%(n-4);
    ll x=bin_pow(a,d,n);
    if(x==1 || x==n-1)return true;
    while(d!=n-1){
        x=(x*x)%n;
        d*=2;
        if(x==1)return false;
        if(x==n-1)return true;
    }
    return false;
}
bool prime(ll n,ll k)
{
    if(n==1 || n==4)return false;
    if(n<=3)return true;
    ll d=n-1;
    while(d%2==0)d/=2;
    for(int i=0;i<k;i++){
        if(!miller_rabin(d,n))return false;
    }
    return true;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int pos=s.find("A");
    int mx=-1;
    for(int i=pos;i<s.size();i++){
        if(s[i]=='Z')mx=max(mx,(i-pos+1));
    }
    cout<<mx;
}


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

using namespace std;
int a[10010];

int main(){
    int n,m,sum=0;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        cin>>a[i];
        sum+=a[i];
    }
    if(sum<=n)
        printf("%d\n",n-sum);
    else
        printf("-1\n");
    return 0;
}

Measured memory_bytes: 3640
#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 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))
//-------------------------------------------------------

string S[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>s;
	FOR(i,7) {
		if(S[i]==s) cout<<(7-i)<<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: 256
#include<bits/stdc++.h>
using namespace std;
int i,j,n,m,k,in[15][15],a,b,c;
int main(){
  for(;i<15;i++)for(j=0;j<15;j++)in[i][j]=2;
  for(cin>>n,i=0;i<n;i++){
    cin>>k;
    for(j=0;j<k;j++){
      cin>>a>>b;
      a--;
      in[i][a]=b;
    }
  }

  int ans=0;
  for(i=0;i<(1<<n);++i){
    vector<int> d(n);
    for(j=0;j<n;j++)if(i>>j&1)d[j]=1;
    bool res=true;
    for(j=0;j<n;j++){
      if(d[j]){
        for(k=0;k<n;k++){
          if(in[j][k]==2)continue;
          if(in[j][k]!=d[k])res=false;
        }
      }
    }
    if(res)ans=max(ans,__builtin_popcount(i));
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;


int main(void){
    int n;
    string s;
    long long na[5];
    for(int i=0;i<5;i++){
        na[i] =0;
    }

    cin >> n;
    for(int i=0;i<n;i++){
        cin >> s;
        if(s[0]=='M'){na[0]++;}
        if(s[0]=='A'){na[1]++;}
        if(s[0]=='R'){na[2]++;}
        if(s[0]=='C'){na[3]++;}
        if(s[0]=='H'){na[4]++;}
    }

    long long ans=0;
    for(int i=0;i<5;i++){
        for(int j=i+1;j<5;j++){
            for(int k=j+1;k<5;k++){
                ans = ans + na[i] * na[j] * na[k];
            }
        }
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

int n,p;
vector<int> ans;
int main(){
	while(1){
		cin >> n >> p;
		if(n + p == 0) break;
		int sp = p;
		int np[50]={0};
		int win = -1;
		while(1){
			for(int i = 0;i < n;i++){
				if(p>0){
					p--;
					np[i]++;
					if(np[i] == sp) win = i;
				}else{
					p+=np[i];
					np[i] = 0;
				}
				if(win >= 0) break;
			}
			if(win >= 0) break;
		}
		ans.push_back(win);
	}
	for(int i = 0;i < ans.size();i++){
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 3048
LI=lambda:list(map(int,input().split()))
MI=lambda:map(int,input().split())
I=lambda:input()
ans=0
n=int(I())
a,b=LI(),LI()
for i in range(n):
  c=min(a[i],b[i])
  ans+=c
  b[i]-=c
  c=min(a[i+1],b[i])
  ans+=c
  a[i+1]-=c
print(ans)

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

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int ans = 0;
    int n; cin >> n;
    vector<int> a(n); rep(i,n) cin >> a[i];
    int q; cin >> q;
    int key;
    rep(i,q){
        cin >> key;
        if (binary_search(a.begin(), a.end(), key)) ans++; 
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3428
#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 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))
//-------------------------------------------------------

string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S;
	int win=15-S.size();
	FORR(c,S) if(c=='o') win++;
	if(win>=8) cout<<"YES"<<endl;
	else cout<<"NO"<<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: 764
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef pair<int, pi> pii;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define fax(i, a) for (int i = 0; i < (a); i++)
#define f0x(i, a, b) for (int i = (a); i < (b); i++)
#define faxd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define f0xd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)
#define memeset memset

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rsz resize

const int MOD = 1000000007; // 998244353
const ll INF = 1e18;
const int MX = 200005;
const ld PI = 4*atan((ld)1);

template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
ll h[MX];
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n; cin >> n;
   fax(i,n) {
	   cin >> h[i];
   }
   //~ fax(i,n) cout << h[i] << " ";
   for(int i = n-2; i >= 0; i--){
	   //~ cout << h[i] << " " << h[i+1] << "\n";
	   if(h[i] > h[i+1]){
		   h[i]--;
	   }
   }
   //~ fax(i,n) cout << h[i] << " ";
   for(int i = 0; i < n-1; i++){
	   if(h[i] > h[i+1]){
		   cout << "No" << "\n";
		   return 0;
	   }
   }
   cout << "Yes";
}


Measured memory_bytes: 1024
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2")
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vpll> vvpll;
typedef unordered_map<ll, ll> um;
typedef unordered_set<ll> us;

#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ts ll t; in(t) while (t--) solve();
#define ks ll t; in(t) FOR(i, 1, t + 1) cout << "Case #" << i << ": ", solve();
#define endl '\n'
#define ln cout << endl;
#define in(x) cin >> x;
#define out(x) cout << x << endl;
#define flush cout << flush;
#define reset(a, b) memset(a, b, sizeof(a));
#define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define FORI(i, a, b, c) for (ll i = a; i < b; i += c)
#define FORD(i, a, b) for (ll i = a; i > b; --i)
#define FOREACH(it, v, r) for (auto it = v.begin() + r; it != v.end(); it++)
#define FORALL(it, v) for (auto it : v)
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define vin(v, x) vll v(x); FOR(i, 0, x) in(v[i])
#define all(v) v.begin(), v.end()
#define allr(v, r) v.begin(), v.begin() + r
#define showv(v) FORALL(it, v) cout << it << ' '; ln
#define prllv(v) FORALL(it, v) out(it)
#define show2d(v) FORALL(it, v) { FORALL(j, it) cout << j; ln }
#define showm(v) FORALL(it, v) cout << it.F << ": " << it.S << ", "; ln
#define sortv(v) sort(all(v));
#define revv(v) reverse(all(v));
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define gcd __gcd
#define checkbit(n, i) (n >> i) & 1
#define bitcount __builtin_popcount
#define firstbitindex __builtin_ctz
#define lastbitindex __builtin_clz
#define bitparity __builtin_parity
#define findv(v, x) (find(all(v), x) != v.end())
#define findsm(u, x) (u.find(x) != u.end())
#define findstr(s, x) (s.find(x) != string::npos)
#define sz(a) a.size()
#define precise(x) cout << fixed << setprecision(x);

const ll N = 5e4, MOD = 1e9 + 7, MAX = 1e7 + 1;
const double EPS = 1e-9, PI = acos(-1);
const int INFi = 0x7f7f7f7f;

//<<------Declare Variables Here----->>//
ll n, d[2], c;
string s;

//<<-----Implement Functions Here---->>//
void solve()
{
	in(n)
    while (n--)
    {
        in(d[0] >> d[1])
        if (d[0] == d[1])
            c++;
        else
            c = 0;
        if (c == 3)
        {
            out("Yes")
            while (n--)
                in(d[0] >> d[1])
            return;
        }
    }
    out("No")
}

//<<----------Start of Main---------->>//
signed main()
{
	fastio
	// ts
    solve();
}

Measured memory_bytes: 3620
#include<stdio.h>
int main(void){
	int a,b,c,x;
	scanf("%d %d %d",&a,&b,&c);
	if(a>b){
		x=a;
		a=b;
		b=x;
	}
	if(b>c){
		x=c;
		c=b;
		b=x;
	}
	if(a>b){
		x=b;
		b=a;
		a=x;
	}
	printf("%d %d %d\n",a,b,c);
	return 0;
}

Measured memory_bytes: 596
import itertools
N, L = map(int, input().split())

taste = [L + i for i in range(N)]

output = [0] * N

summation = sum(taste)

import itertools

for i, item in enumerate(list(itertools.combinations(taste, N - 1))):
    output[i] = [sum(item), abs(summation - sum(item))]

print(sorted(output, key=lambda x: x[1])[0][0])

Measured memory_bytes: 3064
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n, m = MAP()
c = LIST()

price = [float("INF")] * (n+1)
price[0] = 0

for i in range(n+1):
    for j in range(m):
        if i - c[j] < 0:
            continue
        price[i] = min(price[i], price[i-c[j]] + 1)

print(price[-1])




Measured memory_bytes: 7268
#include <iostream>
#include <map>;

using namespace std;

map <int,long long> ans;

int main(){
    int n;
    long long k;
    cin>>n>>k;
    while (n--){
        int a,b;
        cin>>a>>b;
        ans[a]+=b;
    }
    map <int,long long> ::iterator it;
    for (it=ans.begin();it!=ans.end();it++){
        k-=it->second;
        if (k<=0){
            cout<<it->first;
            return 0;
        }
    }
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define all(v) ALL(v)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
#define CININIT cin.tie(0),ios::sync_with_stdio(false)
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }

constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll N,T;

ll ans = 0;
int main(){
    cin>>N>>T;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    vector<ll> mini(N),maxi(N);
    mini[0]=A[0];
    maxi[0]=A[0];
    for(int i=1;i<N;i++){
        mini[i]=min(mini[i-1],A[i]);
        maxi[i]=max(maxi[i-1],A[i]);
    }

    int minidx=-1;
    int maxidx=-1;
    ll maxd = 0;
    for(int i=1;i<N;i++) if(A[i]-mini[i]>maxd) maxd = A[i]-mini[i];


    rep(i,N) if(A[i]-mini[i]==maxd){
        ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
   while (true){
       int n, m; cin >> n >> m;
       if(n == 0 and m == 0) return 0;
       else{
           vector<int> price(n);
           REP(i, n) cin >> price[i];
           int ans = 0;
           REP(i, n){
               REP(j, n){
                   if(j == i) continue;
                   else{
                       int tmp = price[i] + price[j];
                       if(ans < tmp and tmp <= m) ans = tmp;
                   }
               }
           }
           if(ans == 0) cout << "NONE" << endl;
           else cout << ans << endl;
       }
       
   }

}


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

using namespace std;

int main(){
    int N,ans=0;
    cin >> N;
    unordered_map<long long int, int> mp;
    for(int i=0;i<N;i++){
        int A;
        cin >> A;
        if(mp[A] == 0){
            mp[A] = 1;
            ans++; 
        }else{
            mp[A] = 0;
            ans--;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 4388
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define INF 999999999
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;



int main(){
  int a, p;
  cin >> a >> p;
  cout << (a*3+p)/2 << endl;
  return 0;
}

Measured memory_bytes: 256
import random


def gcd(a, b):
    if a == 0:
        return b
    return gcd(b % a, a)


def lcm(a, b):
    return (a * b) / gcd(a, b)



#a = list(map(int, input().split()))
n=int(input())
s=input()
l=0
r=n-1
c=0
while(l<r):
    if s[l]=='R':
        l+=1
    if s[r]=='W':
        r-=1
    if s[l]=='W' and s[r]=='R':
        c+=1
        l+=1
        r-=1

print(c)

Measured memory_bytes: 9772
#include<bits/stdc++.h>
#include<unordered_map>
#include<string>
#include<map>
#include<algorithm>
typedef long long int ll;
using namespace std;
#define MAXN   10001
#define MOD 1000000007
#define X first
#define Y second
ll t,n,i,j;
int main()
{
    cin>>n;
    vector <ll > a(n+1);
    vector <ll > b(n);
    for(i=0;i<(n+1);i++)
        cin>>a[i];
    for(i=0;i<n;i++)
        cin>>b[i];
    ll ans=0,c;
    for(i=0;i<n;i++){
        if(b[i]<a[i]){
            ans+=b[i];
        }
        else{
            c=b[i]-a[i];
            if(c>a[i+1]){
                ans+=a[i]+a[i+1];
                a[i]=0;a[i+1]=0;
            }
            else{
                a[i+1]-=c;
                ans+=b[i];
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int MOD = 1000000007;

LL N,M,S,L;
LL a,b,c,d;
string s;
LL gcd(LL a,LL b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int main(){
    cin>>a>>b>>c>>d;
    LL g=d/gcd(c,d)*c;
    LL aa=a-1-((a-1)/c+(a-1)/d-(a-1)/g);
    LL ba=b-(b/c+b/d-b/g);
    cout<<ba-aa;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;
const int MOD=1000000007;

vector<vector<char> > s;

int main(int argc, char**argv){
    int h, w;
    cin >> h >> w;
    s = vector<vector<char> >(h, vector<char>(w, 0));
    for (int i = 0; i < h; i++){
        for (int k = 0; k < w; k++){
            cin >> s[i][k];
        }
    }

    bool ans = true;
    for (int i = 0; i < h; i++){
        for (int k = 0; k < w; k++){
            bool ok = false;
            if (s[i][k] == '.') ok = true;
            if (i > 0 && s[i-1][k] == '#') ok = true;
            if (i < h-1 && s[i+1][k] == '#') ok = true;
            if (k > 0 && s[i][k-1] == '#') ok = true;
            if (k < w-1 && s[i][k+1] == '#') ok = true;
            ans = ans & ok;
        }
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;


    return 0;
}



Measured memory_bytes: 256
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    from collections import defaultdict
    def factorization(n, arr):
        temp = n
        for i in range(2, int(-(-n**0.5//1))+1):
            if temp%i==0:
                cnt=0
                while temp%i==0:
                    cnt+=1
                    temp //= i
                arr[i] += cnt

        if temp!=1:
            arr[temp]+= 1

        if n ==1:
            arr[temp] += 1

        return arr

    n = int(input())
    mod = 10**9 + 7
    arr = [0]*(n+1)
    for i in range(2, n+1):
        arr = factorization(i, arr)
    
    ans = 1
    for a in arr:
        ans *= (a+1)
        ans %= mod
    
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9724
#include <iostream>


int main()
{
	double r,a,b;
	std::cin >> r;
	a = r*r*3.141592653589;
	b = 2 * r*3.141592653589;

	printf("%.5lf\n",a);
	std::cout << " ";
	printf("%.5lf\n",b);
    return 0;
}

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

int main() {
    string s, t;
    cin >> s >> t;
    ll ans = s.size();
    rep(i,s.size()-t.size()+1) {
        string tmp = s.substr(i,t.size());
        ll cnt = 0;
        rep(j,t.size()) if (tmp[j] != t[j]) cnt++;
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int n, a, b;
  cin >> n >> a >> b;
  
  int k = (a+n-1) / n; // taking ceil
  
  if (k*n >= a and k*n <= b) cout << "OK" << endl;
  else cout << "NG" << endl;
}

Measured memory_bytes: 3524
nums = list(map(int, input().split()))
nums.sort()

count = 0
while nums[0] != nums[1] or nums[1] != nums[2]:
    if nums[1] != nums[2]:
        nums[1] += 1
        nums[0] += 1
        count += 1
    else:
        nums[0] += 2
        count += 1
    nums.sort()
print(count)

Measured memory_bytes: 3064
N = int(input())
dp = [i for i in range(100000+1)]
arr_6 = [6**i for i in range(11)]
arr_9 = [9**i for i in range(11)]
for index in range(100000+1):
  tmp = [v for v in arr_6 if index >= v]
  if len(tmp) != 0:
    tmp = tmp[-1]
    dp[index] = min(dp[index], dp[index - tmp] + 1)

  tmp = [v for v in arr_9 if index >= v]
  if len(tmp) != 0:
    tmp = tmp[-1]
    dp[index] = min(dp[index], dp[index - tmp] + 1)

print(dp[N])

Measured memory_bytes: 7192
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int, int> pii;
int main() {
    int n,k,q; cin >> n >> k >> q;
    vector<int> vec(n, k-q);
    rep(i, q){
        int a; cin >> a;
        a--;
        vec.at(a)++;
    }
    rep(i,n){
        if(vec.at(i) > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef unsigned long long ll;

ll N, n, M, K;

int main(){
    cin >> N >> M;
    cout << (3*N + M)/2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

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() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin>>n;
  vector<tuple<ll,ll,ll>> vt;
  REP(i,n) {
    ll x,y,p;
    cin>>x>>y>>p;
    vt.emplace_back(x,y,p);
  }
  vector mind_v(n, vecll(1<<n)), mind_h(n, vecll(1<<n));
  REP(i,1<<n) {
    REP(j,n) {
      auto&&[xj,yj,pj] = vt[j];
      ll mn_v = abs(xj);
      ll mn_h = abs(yj);
      REP(k,n) {
        if ((i>>k)&1) {
          auto&&[xk,yk,pk] = vt[k];
          mn_v = min(mn_v, abs(xk-xj));
          mn_h = min(mn_h, abs(yk-yj));
        }
      }
      mind_v[j][i] = mn_v * pj;
      mind_h[j][i] = mn_h * pj;
    }
  }
  vecll min_cost(n+1, 1e18);
  REP(i,1<<n) {
    int cnt = 0;
    REP(j,n) {
      if ((i>>j)&1) ++cnt;
    }
    for (int U = (1 << n) - 1; U >= 0; --U) {
      U &= i;
      ll cost = 0;
      REP(j,n) {
        cost += min(mind_v[j][U], mind_h[j][i^U]);
      }
      min_cost[cnt] = min(min_cost[cnt], cost);
    }
  }
  REP(i,n+1) {
    cout<<min_cost[i]<<"\n";
  }
  return 0;
}


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


int main()
{
	int K;
	cin>>K;
	queue<ll> que;
	for(ll i=1;i<=9;i++)
	{
		que.push(i);
	}
	while(K>0)
	{
		if(K<=que.size())
		{
			rep(i,K-1)
			{
				que.pop();
			}		
			cout<<que.front()<<endl;
			break;
		}
		ll v=que.front();
		que.pop();
		ll r=v%10;
		for(ll j=-1;j<=1;j++)
		{
			if(r+j>=0&&r+j<=9)
			{
				que.push(v*10+r+j);
			}
		}
		K--;
	}
	return 0;
}


Measured memory_bytes: 3876
import java.util.*;

import static java.lang.Math.*;

class Main {
    final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        int n = sc.nextInt();

        long ans = 0;
        for (int i = 1; i <= n; i++) {
            long last = (long)Math.floor(n / i) * i;
            ans += (i + last) * last / i / 2;
        }
        System.out.println(ans);

    }
}


Measured memory_bytes: 35732
import java.util.*;

public class Main {
    public static void main(final String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();

        double area = (double) w * h / 2;
        boolean flag = (w == 2 * x) && (h == 2 * y);
        System.out.println(area + " " + (flag ? 1 : 0));
    }
}

Measured memory_bytes: 38956
#include <stdio.h>

int main(){
	int a, b=0, c=0;
	scanf("%d", &a);
	
	if (a<105){
		b = 0;
	} else {
		for(int i=1; i<=a;i++){		
			if(i%2 == 0)
				continue;
			
			c = 0;
		
			for(int j=1;j<=i;j++){
				if(i%j==0)
					c++;
				if (c>8)
					break;
			}
		
			if (c==8)
				b++;
		}
	}
	
	printf("%d\n", b);
	
	return 0;
	
}


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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define F first
#define S second
#define pb push_back
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int) a.size())
#define REP(i,n) for(int i=0;i<(n);i++)
#define MP make_pair
#define SORT_UNIQUE(v) v.resize(unique(ALL(v))-v.begin())
#define GET_POS(v,a) lower_bound(ALL(v),a)-v.begin();

const int maxn=2005;
const int INF=0x3f3f3f3f;

int a[maxn];
bitset<2000005> b;

int main(){
    int n;
    cin>>n;
    REP(i,n) cin>>a[i];
    int sum=0;
    REP(i,n) sum+=a[i];
    b[0]=1;
    REP(i,n){
        b=b|(b<<a[i]);
    }
    int tmp=sum/2;
    while(!b[tmp]) tmp--;
    cout<<sum-tmp<<'\n';
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
double ans;
int n,cnt=0;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++){
		if(i%2!=0) cnt++;
	}
	ans=(double)cnt/n;
	printf("%.10lf\n",ans);
	return 0;
}

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

int main()
{
    priority_queue<int> q;
    while (1)
    {
        string s;
        cin >> s;
        if (s == "insert")
        {
            int x;
            cin >> x;
            q.push(x);
        }
        else if (s == "extract")
        {
            cout << q.top() << endl;
            q.pop();
        }
        else
        {
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 6944
#include <bits/stdc++.h>
// atoi : atoi(変数名.c_str())
// to_string(数値)
// %0桁数d とすると表示桁数が「桁数」に満たない場合に0埋めされる
// find(): int i = 変数名.find(“文字列”) 何番目にあるかを得る
// cout << (条件 ? "Yes" : "No") << endl;
// printf("%02d:%02d:%02d",hour,minute,second);
// 降順 sort(a.begin(),a.end(),greater<int>());
// bitset<ビット数> 変数名;  // すべてのビットが0の状態で初期化される
// bitset<ビット数> 変数名("ビット列");  // 指定したビット列で初期化される
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  long n;
  cin >> n;
  if(n == 0){
    cout << 0 << endl;
    return 0;
  }
  long top = 0;
  long btm = 0;
  int i=0;
  bitset<40> byn;
  byn.reset();
  bitset<40> data;
  data.reset();
  while(!(btm <= n && n <= top)){
    byn.set(i);
    if(i % 2 == 0){
      top += byn.to_ullong();
    }else{
      btm -= byn.to_ullong();
      data.set(i);
    }
    byn.reset(i);
    i++;
  }
  
  //cout << btm << endl;
  //cout << btm - n << endl;
  bitset<40> tmp(n- btm);
  //cout << tmp << endl << endl;
  bitset<40> ans = (tmp ^ data);
  for(int j=39; j>=0;j--){
    if(ans[j]){
      while(j>=0){
        cout << ans[j];
        j--;
      }
      cout << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define N 100005
using namespace std;
 
typedef long long ll;
ll n, c, s, ans, a[N], b[N], mx[N], mx2[N];
int main()
{
	ll i, j;
	cin >> n >> c;
	for (i = 0; i < n; i++) {
		scanf ("%lld %lld", &a[i], &b[i]);
	}
	for (i = n - 1; i >= 0; i--) {
		s += b[i];
		mx[i] = max(mx[i + 1], s - (c - a[i]));
		mx2[i] = max(mx2[i + 1], s - (c - a[i]) * 2);
	}
	ans = max(mx[0], mx2[0]);
	s = 0;
	for (i = 0; i < n; i++) {
		s += b[i];
		ans = max(ans, s - a[i] * 2 + mx[i + 1]);
		ans = max(ans, s - a[i] + mx2[i + 1]);
	}
	cout <<ans;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define maxn 4086 
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;

inline int read(){
	int x = 0, f = 1;char ch = getchar();
	while(ch > '9' || ch < '0'){if(ch == '-') f = -1;ch = getchar();}
	while(ch >= '0' && ch <= '9'){x = x * 10 + ch -'0';ch = getchar();}
	return x * f;
}
int t;
int main(){
	int i, j, x, mx, ans;
	ll a ,b, c,d;
	a = read(), b = read(), c = read(),d = read();
	printf("%lld\n",max(max(a*c,a*d),max(b*c,b*d)));
}

Measured memory_bytes: 3760
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	//int a, b,c; cin >> a >>b;
	string s; cin >> s;
	if (s[0] == s[2])cout << "Yes";
	else cout << "No";
	


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
### constants

MIN_X = MIN_Y = -10.0
MAX_X = MAX_Y = 10010.0

### classes

class Pt
  attr_accessor :x, :y

  def initialize(x, y)
    @x = x
    @y = y
  end

  def +(pt)
    Pt.new(@x + pt.x, @y + pt.y)
  end

  def -(pt)
    Pt.new(@x - pt.x, @y - pt.y)
  end

  def -@
    Pt.new(-@x, -@y)
  end
  
  def *(t)
    Pt.new(@x * t, @y * t)
  end
  
  def /(t)
    Pt.new(@x / t, @y / t)
  end

  def dot(v)
    @x * v.x + @y * v.y
  end
  
  def cross(v)
    @x * v.y - @y * v.x
  end

  def to_s
    "(#{@x},#{@y})"
  end
end

### subroutines

def cross_lines(a0, a1, b0, b1)
  da = a1 - a0
  db = b1 - b0

  op01 = da.cross(db)
  return nil if op01 == 0.0

  v = b0 - a0
  op0 = v.cross(da)
  op1 = v.cross(db)

  t0 = op1 / op01
  t1 = op0 / op01

  [db * t1 + b0, t0, t1]
end

def convex_cut(cpol, pt0, pt1)
  n = cpol.length
  v = pt1 - pt0
  cpol0 = []

  for i in (0...n)
    cpt0 = cpol[i]
    cr0 = v.cross(cpt0 - pt0)
    if cr0 >= 0.0
      cpol0 << cpt0
    end
    
    cpt1 = cpol[(i + 1) % n]
    cr1 = v.cross(cpt1 - pt0)
    if cr0 * cr1 < 0.0
      pt, t0, t1 = cross_lines(pt0, pt1, cpt0, cpt1)
      cpol0 << pt
    end
  end

  #p cpol0.map{|pt| pt.to_s}; exit
  cpol0
end
 
### main

loop do
  n = gets.to_i
  break if n == 0

  pts = n.times.map{Pt.new(*gets.split.map(&:to_f))}
  #p pts.map{|pt| pt.to_s}

  cpol = []
  cpol << Pt.new(MIN_X, MIN_Y)
  cpol << Pt.new(MAX_X, MIN_Y)
  cpol << Pt.new(MAX_X, MAX_Y)
  cpol << Pt.new(MIN_X, MAX_Y)
  
  for i in (0...n)
    cpol = convex_cut(cpol, pts[i], pts[(i + 1) % n])
    break if cpol.empty?
  end
  #p cpol.map{|pt| pt.to_s}; exit
  
  puts (cpol.empty? ? 0 : 1)
end

Measured memory_bytes: 6160
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define pr(...) GET_MACRO(__VA_ARGS__,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__)
#define Pr(a) (#a)<<"="<<(a)<<" "
#define pr1(a) cerr<<Pr(a)<<endl
#define pr2(a,b) cerr<<Pr(a)<<Pr(b)<<endl
#define pr3(a,b,c) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<endl
#define pr4(a,b,c,d) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<endl
#define pr5(a,b,c,d,e) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<endl
#define pr6(a,b,c,d,e,f) cerr<<Pr(a)<<Pr(b)<<Pr(c)<<Pr(d)<<Pr(e)<<Pr(f)<<endl
#define int long long
#define double long double
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
ostream& operator<<(ostream& o,vector<auto> &a){int i=0;for(auto t:a)o<<(i++?" ":"")<<t;return o;}
istream& operator>>(istream& i,vector<auto> &a){for(auto &t:a)i>>t;return i;}
void prArr(auto a,string s=" "){int i=0;for(auto t:a)cout<<(i++?s:"")<<t;cout<<endl;}


signed main(){
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  vector<int> A;
  int q;
  cin>>q;
  while(q--){
    int cmd;
    cin>>cmd;
    
    if(cmd == 0){
      int x;
      cin>>x;
      A.push_back(x);
    }
    if(cmd == 1){
      int p;
      cin>>p;
      cout<<A[p]<<endl;
    }
    if(cmd == 2){
      A.pop_back();
    }
  }
  
  return 0;
}



Measured memory_bytes: 4940
function myout(text){console.log(text);}//standard output
function Main(input) {
	//input = parseInt(input);
	//input = input.trim().split(" ");
	input = input.trim().split("\n");
	//input = input.trim().split(" ").map((a)=>Number(a));
	//input = input.trim().split("\n").map((a)=>Number(a));
  var list = [0];//2017数の累積
  var count = 0;
  var output = [];
  for(var i = 1; i <= 100000; i++){
    if(i % 2 == 1 && isPrime(i) && isPrime((i + 1) / 2)){
       count++;
    }
    list.push(count);
  }
  
  var Q = parseInt(input[0]);
  for(var i = 1; i <= Q; i++){
    var L = parseInt(input[i].split(" ")[0]);
    var R = parseInt(input[i].split(" ")[1]);
    var add = list[R] - list[L];
    if(isPrime(L) && isPrime((L + 1) / 2)){
       add++;
       }
    output.push(add);
  }
  //myout(list[13]);
  //myout(list[12]);
  //myout(list[91]);
  myout(output.join("\n"));
}

//素数判定(高速)
function isPrime(val){
	if(val == 1 || (val != 2 && val % 2 == 0)){
		return false;
	}else if(val == 2){
		return true;
	}
	var root = Math.floor(Math.sqrt(val));
	for(var i = 3; i <= root; i += 2){
		if(val % i == 0){
			return false;
		}
	}
	return true;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 30796
#include<stdio.h>
#include<stdlib.h>
int cmpnum(const void * n1, const void * n2)
{
  if (*(int *)n1 > *(int *)n2)
  {
    return 1;
  }
  else if (*(int *)n1 < *(int *)n2)
  {
    return -1;
  }
  else
  {
    return 0;
  }
}

int main(void)

{
  int n,k;
  int a[1010];
  scanf("%d %d",&n,&k);

  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  qsort(a,n, sizeof(int), cmpnum);
  int sum=0;
  for(int i=0;i<k;i++){
    sum+=a[i];
  }
  printf("%d\n",sum);
  return 0;
}


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

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int h,a;
    cin>>h>>a;
    int ans = h/a;
    h %=a;
    if(h>0)
        ans++;
    cout<<ans; 


}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main()
{
  string s, t;
  cin >> s;
  t = s;
  reverse(t.begin(), t.end());
  if(t == s){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>

int factorize(long long n, long long p[], int m[])
{
	int k;
	long long i;
	for (i = 2, k = 0; i * i <= n; i++) {
		if (n % i != 0) continue;
		p[k] = i;
		for (m[k] = 0; n % p[k] == 0; m[k]++, n /= p[k]);
		k++;
	}
	if (n > 1) {
		p[k] = n;
		m[k++] = 1;
	}
	return k;
}

int main()
{
	long long N;
	scanf("%lld", &N);
	if (N == 1) {
		printf("1\n");
		fflush(stdout);
		return 0;
	}

	long long p[101];
	int m[101], k = factorize(N * 2, p, m);
	
	int i, j, l[101] = {};
	long long x = 1, y, ans = N * 2;
	m[k] = 1;
	while (l[k] == 0) {
		y = N * 2 / x;
		if (x >= y && x <= ans) {
			for (i = 1; x * i <= ans; i++) if ((x * i - 1) % y == 0 || (x * i + 1) % y == 0) break;
			if (x * i <= ans) {
				if ((x * i - 1) % y == 0) ans = x * i - 1;
				else ans = x * i;
			}
		}
		
		for (i = 0; i < k && l[i] == m[i]; i++);
		for (j = 0; j < m[i]; j++) x *= p[i];
		for (l[i] = m[i], i--; i >= 0; l[i--] = 0) {
			for (j = 0; j < m[i]; j++) x /= p[i];
		}
	}
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1736
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
    public static void main(String[]args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        while(true) {
            try {
                String line = br.readLine();
                String[] lines = line.split(" ", 0);
                int a = Integer.parseInt(lines[0]);
                char op = lines[1].charAt(0);
                int b = Integer.parseInt(lines[2]);

                if (op == '+') {
                    System.out.println(a + b);
                } else if (op == '-') {
                    System.out.println(a - b);
                } else if (op == '*') {
                    System.out.println(a * b);
                } else if (op == '/') {
                    System.out.println(a / b);
                } else break;
            } catch (NumberFormatException e) {
                break;
            } catch (IOException e) {
                break;
            }
        }


    }
}


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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
	int d;
	cin>>d;
	int c[26];
	rep(i, 26) cin>>c[i];
	int s[365][26];
	rep(i, d) rep(j, 26) cin>>s[i][j];

	int t[365];

	ll sc=0;
	int las[26];
	rep(i, 26) las[i]=-1;

	rep(k, d){
		int mx=INT_MIN, tt=0;
		rep(i, 26){
			int prof=c[i]*(k-las[i])+s[k][i];
			if(prof>mx){
				mx=prof;
				tt=i;
			}
		}
		t[k]=tt;
	}

	rep(i, 26) las[i]=-1;
	rep(i, d){
		sc+=s[i][t[i]];
		las[t[i]]=i;
		rep(j, 26) sc -= c[j]*(i-las[j]);
	}

	rep(_, 10000){
		int td=rand()%d, tt=rand()%26;
		int ot=t[td];
		t[td]=tt;

		int nsc=0;
		rep(i, 26) las[i]=-1;
		rep(i, d){
			nsc+=s[i][t[i]];
			las[t[i]]=i;
			rep(j, 26) nsc -= c[j]*(i-las[j]);
		}

		//if(nsc<sc || rand()%100==0)
		if(nsc>sc)
			sc=nsc;
		else t[td]=ot;

		//cout<<"sc"<<sc<<endl;
	}

	rep(i, d) cout<<(t[i]+1)<<endl;

	return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    int n;
    cin >> n;

    vector<int> a(n), b(n);
    map<int, int> mp;
    rep(i, n) {
        cin >> a[i];
        mp[a[i]] = i%2;
        b[i] = a[i];
    }

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

    int ans = 0;
    rep(i, n) {
        if(mp[b[i]] != i%2) {
            ans++;
        }
    }

    ans /= 2;
       
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760