akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S divup_L(S a, T b){
  return (a+b-1)/b;
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int C[10], D, G, P[10];
int main(){
  int i, j, k, res=1073709056, x, y;
  rd(D);
  rd(G);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<D;Lj4PdHRW++){
      rd(P[Lj4PdHRW]);
      rd(C[Lj4PdHRW]);
    }
  }
  G /= 100;
  {
    int KL2GvlyY;
    for(KL2GvlyY=0;KL2GvlyY<(D-1) + 1;KL2GvlyY++){
      C[KL2GvlyY] /= 100;
    }
  }
  for(k=0;k<1<<D;k++){
    x = y = 0;
    j = -1;
    for(i=0;i<D;i++){
      if(k&1<<i){
        x += P[i];
        y += (i+1) * P[i] + C[i];
      }
      else{
        j = i;
      }
    }
    if(y >= G){
      chmin(res, x);
      continue;
    }
    if(j == -1){
      continue;
    }
    if(y + (j+1) * P[j] < G){
      continue;
    }
    chmin(res, x +divup_L((G-y),(j+1)));
  }
  wt_L(res);
  putchar_unlocked('\n');
  return 0;
}
// cLay varsion 20180730-1

// --- original code ---
// int D, G, P[10], C[10];
// {
//   int i, j, k;
//   int x, y, res = int_inf;
// 
//   rd(D,G,(P,C)(D));
//   G /= 100;
//   C[0..D-1] /= 100;
// 
//   rep(k,1<<D){
//     x = y = 0;
//     j = -1;
//     rep(i,D){
//       if(k&1<<i) x += P[i], y += (i+1) * P[i] + C[i];
//       else       j = i;
//     }
//     if(y >= G){ res <?= x; continue; }
//     if(j == -1) continue;
//     if(y + (j+1) * P[j] < G) continue;
//     res <?= x + (G-y) /+ (j+1);
//   }
// 
//   wt(res);
// }


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    if(a==b)
    {
        printf("Draw\n");
    }
    else if(b==1)
    {
        printf("Bob\n");
    }
    else if(a==1)
    {
        printf("Alice\n");
    }
    else if(b>a)
    {
        printf("Bob\n");
    }
    else if(a>b)
    {
        printf("Alice\n");
    }
    return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
r,c = [int(a) for a in input().split(' ')]
arr = []
Hsum=0
for x in range(r):
    i =[int(a) for a in input().split(' ')]
    i.append(sum(i))
    arr.append(i)
arr2=[]
for y in range(c+1):
    for z in range(r):
        Hsum += arr[z][y]
    arr2.append(Hsum)
    Hsum=0
arr.append(arr2)

for y in range(r+1):
    for z in range(c+1):
        if z == c:
            print(arr[y][z])
        else:
            print(arr[y][z],end = " ")

Measured memory_bytes: 8344
hoge = [int(input()) for i in range(6)]
k = hoge[-1]


ans = []
for i in range(5):
    for t in range(i+1,5):
        ans.append(abs(hoge[i]-hoge[t]))

if max(ans) > k:
    print(':(')
else:
    print('Yay!')

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;

int main() {
    ll N;
    cin >> N;
    ll ans = 100000;
    for (ll i = 1; i < N; i++) {
        ll p = i;
        ll j = N - i;
        ll inum = 0;
        ll jnum = 0;
        for (int k = 0; k < 7; k++) {
            inum += p % 10;
            jnum += j % 10;
            p = p / 10;
            j = j / 10;
        }
        if (inum + jnum < ans) {
            ans = inum + jnum;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 764
/*
 *  author : Atul Anand   
 *  created on : Wed Apr 01 2020
 */

import java.io.*;
import java.util.*;

public class Main{

    public static void main(String[] args) throws IOException {
        int N = in.nextInt();
        TreeMap<String, Integer> map = new TreeMap<>();
        for(int i = 0; i < N; i++){
            String s = in.next();
            map.put(s, map.getOrDefault(s, 0) + 1);
        }

        int maxVote = 0;
        for(int v: map.values()){
            maxVote = Math.max(maxVote, v);
        }

        for(String s: map.keySet()){
            if(map.get(s) == maxVote){
                println(s);
            }
        }
        
        in.close();
        out.close();
    }

    static int MIN = Integer.MIN_VALUE;
    static int MAX = Integer.MAX_VALUE;
    static Reader in = new Reader();
    static PrintWriter out = new PrintWriter(System.out);

    static void read(int arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextInt(); 
    	} 
    }
    
    static void read(long arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.nextLong(); 
    	} 
    }
    
    static void read(String arr[], int N) throws IOException { 
    	for(int i = 0; i < N; i++){ 
    		arr[i] = in.next(); 
    	} 
    }
    
    static void print(Object O) {  
    	out.print(O); 
    }
    
    static void println(Object O) { 
    	out.println(O); 
    }
    
    static void println(int arr[]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		print(arr[i]+" "); 
    	} 
    	println(""); 
    }

    static void println(int arr[][]) { 
    	for(int i = 0; i < arr.length; i++){ 
    		println(arr[i]); 
    	}
    }
    
    static void debug(Object O) { 
    	System.out.println(O); 
    }
}

class Reader {
    BufferedReader reader;
    StringTokenizer tokenizer;

    Reader() {
        reader = new BufferedReader(new InputStreamReader(System.in));
        tokenizer = new StringTokenizer("");
    }

    String next() throws IOException {
        while (!tokenizer.hasMoreTokens() ) { 
            tokenizer = new StringTokenizer(reader.readLine()); 
        }
        return tokenizer.nextToken();
    }

    int nextInt() throws IOException { 
        return Integer.parseInt(next()); 
    }
    
    double nextDouble() throws IOException { 
        return Double.parseDouble(next());
    }
    
    long nextLong() throws IOException { 
        return Long.parseLong(next()); 
    }
    
    String nextLine() throws IOException { 
        return reader.readLine(); 
    }
    
    void close() throws IOException { 
        reader.close(); 
    }
}

Measured memory_bytes: 51380
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll MOD = 1000000007;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int dp[100000 + 10];
int main() {
  int H, N;
  cin >> H >> N;
  vector<int> A(N), B(N);
  REP(i, N) cin >> A[i] >> B[i];
  REP(j, 10000 + 10) dp[j] = INF;
  dp[0] = 0;
  REP(i, N) {
    REP(j, H + 1) {
      if (j + A[i] >= H) {
        chmin(dp[H], dp[j] + B[i]);
      }
      chmin(dp[j + A[i]], dp[j] + B[i]);
    }
  }
  cout << dp[H] << endl;
}

Measured memory_bytes: 3672
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}
signed main()
{
    IOS
    string s,t;
    cin>>s>>t;
    int ans=0;
    for(int i=0;i<(int)s.size();i++){
        if(s[i]!=t[i])ans++;
    }
    cout << ans << endl;
    return 0;
}
///Alhamdulillah


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

#define pb push_back
#define ff first
#define ss second

const long long MAXN = 1e5 + 21, inf = 1e18 + 21, LG = 21;

bool vis[MAXN];
int n;
int par[MAXN], h[MAXN], ind[MAXN];
vector<int> adj[MAXN];

bool cmp(int i, int j) {
    return h[i] < h[j];
}

void dfs(int root, int pr = 0) {
    h[root] = h[pr] + 1;
    par[root] = pr;
    for (auto y: adj[root])
	if (y ^ pr)
	    dfs(y, root);
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n;
    if (n % 2)
	return cout << "First" << '\n', 0;

    for (int i = 1; i < n; i++) {
	int v, u;
	cin >> u >> v;
	adj[u].pb(v);
	adj[v].pb(u);
	ind[i] = i;
    }

    ind[n] = n;

    dfs(1);

    sort(ind + 1 , ind + n + 1, cmp);

    for (int i = n; i; i--) {
	int v = ind[i];
	if (vis[v])
	    continue;
	if (par[v] == 0)
	    return cout << "First" << '\n', 0;
	if (vis[par[v]])
	    return cout << "First" << '\n', 0;
	else {
	    vis[v] = true;
	    vis[par[v]] = true;
	}
    }

    cout << "Second" << '\n';
    return 0;
}



Measured memory_bytes: 7040
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()
 
template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr long long inf = 3e18;

int N,M;
vector<int>G[500005],rG[500005];
bool used[500005];
vector<int>vs,vs2;
void dfs(int x){
	used[x]=true;
	for(int i:G[x])if(!used[i])dfs(i);
	vs.push_back(x);
}
void rdfs(int x){
	used[x]=true;
	vs2.push_back(x);
	for(int i:rG[x])if(!used[i])rdfs(i);
}
void scc(){
	rep(i,N)if(!used[i])dfs(i);
	vector<vector<int>>ans;
	memset(used,0,sizeof(used));
	rev(i,N)if(!used[vs[i]]){
		vs2.clear();rdfs(vs[i]);
		ans.push_back(vs2);
	}
	cout<<len(ans)<<"\n";
	for(auto i:ans){
		cout<<len(i)<<" ";
		for(int j:i)cout<<j<<" ";
		cout<<"\n";
	}
}
signed main(){
	cin.tie(0);ios::sync_with_stdio(false);
	cin>>N>>M;
	rep(i,M){
		int a,b;cin>>a>>b;G[a].push_back(b);rG[b].push_back(a);
	}
	scc();
}

Measured memory_bytes: 81856
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
int main(){
	int i,w,h,n;
	int sum=0;
	scanf("%d%d%d",&w,&h,&n);
	int x[n+1];
	int y[n+1];
	for( i=1;i<=n;i++){
		scanf("%d%d",&x[i],&y[i]);
	}
	for(int i=1;i<n;i++){
	if(x[i+1]==x[i]){/*????????´???*/
		sum+=abs(y[i+1]-y[i]);
	}
	else if(y[i+1]==y[i]){/*???????¨?????????´??????*/
		sum+=abs(x[i+1]-x[i]);
	}
	else if((x[i+1]-x[i])*(y[i+1]-y[i])>0){
		/*?????±???????????¨???,????\????????????¨???*/
			sum+=max(abs(x[i+1]-x[i]),abs(y[i+1]-y[i]));
		}
		else{/*?????±,????\????????????¨???*/
			sum+=abs(x[i+1]-x[i])+abs(y[i+1]-y[i]);
		}
	}
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 1032
object Main extends App {

  import scala.io.StdIn._
  val n = readLine.trim.toInt
  val Array(a, b) = readLine.trim.split(' ').map(_.toInt)
  val c = readLine.trim.toInt
  val toppings = Array.tabulate(n){_ ⇒ Topping(b, readLine.trim.toInt)}
  println(
    toppings.sortBy(-_.caloriePerPrice).foldLeft(Pizza(a, c)){case (pizza, topping) ⇒ if (pizza.caloriePerPrice > topping.caloriePerPrice) pizza else pizza.addTopping(topping)}.caloriePerPrice.toInt
  )
  case class Pizza(price: Int, calorie: Int){
    def caloriePerPrice:Double = calorie.toDouble / price
    def addTopping(topping: Topping): Pizza = Pizza(price + topping.price, calorie + topping.calorie)
  }
  case class Topping(price: Int, calorie: Int){
    def caloriePerPrice: Double = calorie.toDouble / price
  }
}



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


#define ALL(a) 		(a.begin() , a.end())
#define ll 			int
#define ff          first
#define ss          second
#define pb          push_back
#define ar 			array
#define mp 			make_pair
#define f(i,a,b)   	for(ll i =a;i<=b;i++)
#define inf 		INT_MAX
#define pll 		pair<ll,ll>
#define mat 		vector<vector<ll>>
/*
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define deb(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 //debug & operator << (debug & dd, P p) { dd << "(" << p.x << ", " << p.y << ")"; return dd; }

 */
 

//const ll INF = 1e18;
void init(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE 
		freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#endif
}
 
bool checkp2(ll n){
	return n && !(n & (n-1));
}

ll numsetbit(ll n){
	ll count = 0;
	for(;n;count++){
		n = n & (n-1);
	}
	return count;
}
 
ll power(ll x , ll n , ll mod){
    x = x % mod;
	ll po = 1;
	while(n){
		if(n & 1){
			po = (po*x) % mod;
		}
		n = n>>1;
		x = ((x % mod) * (x % mod)) % mod;
	}
	return po;
}
 
bool isPrime(ll x){
	if(x < 2)
		return 0;
	for(ll y = 2; y * y <= x; y++){
		if(x % y == 0){
			return 0;
		}
	}
	return true;
}


const ll mxn = (int)1e6;
ll spf[mxn+10];

void solve(){
	//cout<<"stating\n";
	spf[1] = 1;
	//cout<<"hmm\n";
	for(ll i = 2;i<=mxn;i++){
		spf[i] = i;
	}
	//cout<<"hello\n";
	for(ll i = 4;i<=mxn;i+=2){
		spf[i] = 2;
	}
	//cout<<"hii\n";
	for(ll i = 3;i*i <= mxn;i++){

		if(spf[i] == i){
			for(ll j = i*i;j<=mxn;j+=i){
				if(spf[j] == j){
					spf[j] = i;
				}
			}
		}

	}

		ll n;
		cin>>n;
	//cout<<n<<endl;
		vector<ll> a(n);
		for(ll i =0;i<n;i++){
			cin>>a[i];
		}

		ll hash[mxn] = {0};
	bool flag = 0;
		for(ll i = 0;i<n;i++){

			ll x = a[i];
			ll temp = spf[x];

			while(x != 1){
				temp = spf[x];
				if(x % temp == 0){
					if(hash[spf[x]] == 1){
						flag = 1;
					}
					hash[spf[x]]++;
				}
				while(x % temp == 0){
					x = x/temp;
				}
				if(flag)
					break;
			}
			if(flag)
				break;
		}
		//debug()<< deb(flag);
		if(!flag){
			cout<<"pairwise coprime\n"<<endl;
			return;
		}
		ll answer = a[0];
		for(ll i=  1;i<n;i++){
			answer = __gcd(answer , a[i]);
		}
		if(answer == 1){
			cout<<"setwise coprime\n";
			return;
		}

		cout<<"not coprime\n"<<endl;



}

int main(){
	
	init();
	ll t = 1;
	//cin>>t;
	for(ll i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
		//cout<<"solve\n";
		solve();
	}
}

Measured memory_bytes: 14776
s = input()
if s=="AKIHABARA" or s=="KIHABARA" or s=="AKIHABAR" or s=="AKIHABRA" or s=="AKIHBARA" or s=="AKIHABR" or s=="AKIHBAR" or s=="AKIHBRA" or s=="KIHABAR" or s=="KIHABRA" or s=="KIHBARA" or s== "AKIHBR" or s=="KIHABR" or s=="KIHBAR" or s=="KIHBRA" or s=="KIHBR":
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>

using namespace std;

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

//const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main(){
	string S;
	cin >> S;
	S[3] = '8';
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if(a < b){ a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if(a > b){ a = b; return 1; } return 0; }
int main()
{
  int a,b,c,d;cin >> a >> b >> c >> d;
  while(1) {
    c -= b;
    if(c <= 0) {
      cout << "Yes" << "\n";
      break;
    }
    a -= d;
    if(a <= 0) {
      cout << "No" << "\n";
      break;
    }    
  }
  return 0;
}


Measured memory_bytes: 3636
package com.example.itp1.one

import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    try {
        val a_b: Array<Int> = sc.nextLine().split(" ")
                .map{it.toInt()}
                .toTypedArray()
        val a = a_b[0]
        val b = a_b[1]
        val s = a * b
        val c = (a + b) * 2
        println(String.format("%d %d", s, c))
    } catch (e: Exception) {
        println(e)
    }
}




Measured memory_bytes: 32656
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int r;
  cin >> r;
  if(r<1200) {
    cout << "ABC" << endl;
  }
  else if(r<2800) {
    cout << "ARC" << endl;
  }
  else {
    cout << "AGC" << endl;
  }
}

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

int main (void) {
	int n; string r;
	map<string, int> s;
	cin >> n;
	while (n --) {
		cin >> r;
		s[r] ++;
	}
	cout << "AC x " << s["AC"] << endl;
	cout << "WA x " << s["WA"] << endl;
	cout << "TLE x " << s["TLE"] << endl;
	cout << "RE x " << s["RE"] << endl;
}



Measured memory_bytes: 3624
#include<bits/stdc++.h>
#include<iostream>
#include<fstream>
#define ll long long
using namespace std;

int main(){
    int N;  ll W;
    cin >> N >> W;
    int V = 0;
    vector<int> w(N+1,0), v(N+1, 0);
    for(int i=1; i<=N; i++){
        cin >> w[i] >> v[i];
        V += v[i];
    }

    vector<vector<ll>> dp(N+1, vector<ll>(V+1, 1e18));
    dp[0][0] = 0;
    for(int i=1; i<=N; i++) for(int j=0; j<=V; j++){
        dp[i][j] = min(dp[i][j], dp[i-1][j]);
        if(v[i] <= j){
            dp[i][j] = min(dp[i][j], dp[i-1][j-v[i]] + w[i]);
        }
    }

    ll ans = 1e9;
    for(int i=V; i>=0; i--){
        if(dp[N][i] <= W){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 80256
#include<stdio.h>

int main(){
	
	int N,i,odd=0;
	long long int A[100010];
	
	scanf("%d",&N);
	for(i=1;i<=N;i++){
		scanf("%lld",&A[i]);
		if(A[i]%2==1){
			odd++;
		}
	}
	
	if(odd%2==0){
		printf("YES");
	}else {
		printf("NO");
	}
	
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#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++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define sz(x) (int)(x.size())
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;

bool comp(pi A, pi B){
    if(A.S==B.S){
        return A.F<B.F;
    }
    return A.S<B.S;
}

int32_t main(){
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<pair<int, int> >a(n);
    REP(i,0,n){
        int A, B;
        cin>>A>>B;
        a[i]={A,B};
    }
    sort(a.begin(),a.end(),comp);
    int cur=0;
    int f=1;
    for(int i=0;i<n;i++){
        cur+=a[i].F;
        if(cur>a[i].S){
            f=0;
            break;
        }
    }
    if(f)cout<<"Yes\n";
    else cout<<"No\n";


    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);

int main() {
	double a, b, x;
	cin >> a >> b >> x;
	double h = x / (a * a);
	if (h >= b / 2) {
		double ans = atan2(b - h, a / 2) * 180 / pi;
		printf("%.10f", ans);
	}
	else {
		double j = 2 * x / (a * b);
		double ans = atan2(b, j) * 180 / pi;
		printf("%.10f", ans);
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define inf (int)(1e9+7)
#define mod (ll)(1e9+7)
#define eb emplace_back
#define eps 1e-10
#define F first
#define S second

int main() { //cast caution
    int w, h, x, y; cin >> w >> h >> x >> y;
    cout << fixed << setprecision(10);
    cout << 1.0 * w * h / 2 << " ";
    cout << (w == 2 * x && h == 2 * y) << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef unsigned long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
    cin>>N;
    vec a(N), so(N);
    rep(i,N) {
        cin>>a.at(i);
        so.at(i) = a.at(i);
    }
    sort(so.begin(),so.end());
    reverse(so.begin(),so.end());
    rep(i,N){
        cout<<(a.at(i) == so.at(0) ? so.at(1) : so.at(0))<<endl;
    }
}


Measured memory_bytes: 4736
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 3010
int n, m, l, r, t;
ll dp[2][N];
string s;

ll inv[N], fact[N], ifact[N];
 
void init_fact(ll n = N){
    inv[1] = 1;
    for(int i = 2; i < n; i++) inv[i] = inv[mod%i] * (mod - mod/i) % mod;
	fact[0] = ifact[0] = 1;
	for(int i = 1; i < n; i++){
		fact[i] = (fact[i-1]*i)%mod;
		ifact[i]=(ifact[i-1]*inv[i])%mod;
	}
}

ll comb(ll a, ll b){
	return fact[a+b]*ifact[a]%mod*ifact[b]%mod;
}

ll comb_nk(ll n, ll k){
	return comb(n-k, k);
}

int main(){
	cin>>n>>m>>s;
	init_fact();
	dp[0][0] = 1;
	rep(i, m){
		int a, b;
		cin>>a>>b;
		a--;
		if(b<=r) continue;
		mset(dp[!t], 0);
		int d = min(r, a)-l, e = r-l-d;
		l = a;
		int c = 0;
		r = max(r, a);
		while(r<b) c += s[r++]-'0';
		for(int j = 0; j <= d; j++){
			for(int k = j; k-j <= e; k++){
				(dp[!t][k-j+c]+=dp[t][k]*comb_nk(d, j))%=mod;
			}
		}
		t = !t;
	}
	ll res = 0;
	rep(i, r-l+1) (res+=dp[t][i]*comb_nk(r-l, i))%=mod;
	//rep(i, r-l+1) cerr<<dp[t][i]<<" "<<comb_nk(r-l, i)<<endl;
	cout<<res<<endl;

	return 0;
}


Measured memory_bytes: 384
import Data.List
main=do
 s<-getLine
 k<-readLn
 let a=map(:[])s
 let b=zipWith(:)s$tail a
 let c=if length b==0 then [] else zipWith(:)s$tail b
 let d=if length c==0 then [] else zipWith(:)s$tail c
 let e=if length d==0 then [] else zipWith(:)s$tail d
 let ans=nub$sort$a++b++c++d++e
 putStrLn$ans!!(k-1)

Measured memory_bytes: 4476
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    return divisors

ans = -float('inf')
N,M = map(int,input().split())
for div in make_divisors(M):
  if M//div >= N: ans = max(ans, div)
print(ans)

Measured memory_bytes: 3060
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    int M, N; scanf("%d %d\n", &M, &N);
    int[][] A = new int[][M];
    foreach (i; 0 .. M) {
        A[i] = readln.chomp.split(" ").map!(to!int).array;
    }

    const dy = [1, 0, -1, 0],
          dx = [0, 1, 0, -1];
    
    void eat(ulong y, ulong x) {
        A[y][x] = 2;
        foreach (i; 0 .. 4) {
            auto ny = y + dy[i],
                 nx = x + dx[i];
            if (ny < 0 || ny >= M) continue;
            if (nx < 0 || nx >= N) continue;
            if (A[ny][nx] == 2) continue;
            if (A[ny][nx] == 1) {
                A[ny][nx] = 0;
            } else {
                assert(A[ny][nx] == 0);
                A[ny][nx] = 1;
            }
        }
    }

    bool sweet(out ulong ey, out ulong ex) {
        foreach (y; 0 .. M) {
            foreach (x; 0 .. N) {
                if (A[y][x] != 1) continue;
                if (0 <= y - 1 && A[y - 1][x] != 2) continue;
                if ( (0 <= x - 1 && A[y][x - 1] != 2) &&
                     (x + 1 < N && A[y][x + 1] != 2) ) continue;
                ey = y; ex = x;
                return true;
            }
        }
        foreach (y; 0 .. M) {
            foreach (x; 0 .. N) {
                if (A[y][x] != 2) {
                    ey = y;
                    ex = x;
                    return false;
                }
            }
        }
        assert(0);
    }

    int C = 0;
    for (int _ = 0; _ < M * N; _++) {
        ulong y, x;
        if (sweet(y, x)) {
            C++;
            eat(y, x);
        } else {
            eat(y, x);
        }
    }
    writeln(C);
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz 100005
#define all(x) x.begin(),x.end()
#define l_b lower_bound
#define u_b upper_bound
#define pb push_back
#define MOD 1000000007
void fastio(void);

int main(){
    fastio();
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    int n,la,lb;
    string st;
    cin>>n>>st;
    vector<int> r,w;
    for(la=0;la<n;la++){
        if(st[la]=='R')
            r.pb(la);
        else
            w.pb(la);
    }

    if(w.empty() || r.empty()){
        cout<<0<<endl;
        return 0;
    }

    int left, right, cnt=0;

    for(left=0, right=r.size()-1;w[left]<r[right] && left<w.size() && right<r.size();left++, right--){
        cnt++;
    }

    cout<<cnt<<endl;


    return 0;
}

void fastio(void){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

Measured memory_bytes: 4740
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
	#define endl '\n'
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline void goodbye(const T& val) { cout << val << endl; exit(0); }

const ll MAX_N = (int)1e5 + 777;
const ll BITS  = 61;

ll basis[BITS], a[MAX_N], n;

ll add(ll val)
{
	for(ll j = BITS - 1; j >= 0; --j)
	{
		ll bit = 1LL << j;

		if(val & bit)
		{
			if(basis[j])
			{
				val ^= basis[j];
			}
			else
			{
				basis[j] = val;
				return 1;
			}
		}
	}

	return 0;
}

ll fxor;

ll possible(ll val, ll j0)
{
	for(ll j = BITS - 1; j >= j0; --j)
	{
		ll bit = 1LL << j;

		if(val & bit)
		{
			if(basis[j])
			{
				val ^= basis[j];
			}
			else
			{
				return 0;
			}
		}
	}

	return 1;
}

ll cost(ll x)
{
	return x + (fxor ^ x);		
}

void solve()
{
	cin >> n;

	for(int i = 0; i < n; ++i)
	{
		cin >> a[i];
		add(a[i]);

		fxor ^= a[i];
	}

	DBG(fxor);

	for(ll j = 0; j < BITS; ++j)
	{
		ll bit = 1LL << j;

		if(fxor & bit)
			add(bit);
	}

	ll cur = 0;

	for(ll j = BITS - 1; j >= 0; --j)
	{
		ll bit = 1LL << j;

		if(!possible(cur ^ bit, j))
			continue;

		if(!possible(cur, j))
		{
			cur ^= bit;
			continue;
		}

		ll alt = cur ^ bit;

		if(cost(alt) > cost(cur))
			cur = alt;
	}

	cout << cost(cur) << endl;
}

int main()
{
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int main(void){
    string s;
    cin>>s;
    long long ans=s.size(),sum_s=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='T'){
            if(sum_s!=0){
                sum_s--;
                ans-=2;
            }
        }
        else if(s[i]=='S')sum_s++;
    }
    cout<<ans<<endl;
    return 0;
}


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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

// const int INF = 1001001001;
// long long max => LLONG_MAX

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;

    if(m1 == m2) cout << 0 << endl;
    else cout << 1 << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define all(v) v.begin(),v.end()
#define PI acos(-1)
#define EPS 1e-15
#define f first
#define s second
 

 
int main(){
	int n;
	cin >> n;
	vector<string> d(2);
	cin >> d[0] >> d[1];
	
	int idx = 0;
	ll res = 1;
	if(d[0][0] == d[1][0]){
		idx += 1;
		res *= 3;
	}else{
		idx +=2;
		res *= 6;
	}
	
	while(idx < n){
		if(d[0][idx-1] == d[1][idx-1]){
			if(d[0][idx] == d[1][idx]){
				idx += 1;
				res *= 2;
			}else{
				idx += 2;
				res *= 2;
			}
		}else{
			if(d[0][idx] == d[1][idx]){
				idx += 1;
				res *= 1;
			}else{
				idx += 2;
				res *= 3;
			}
		}
	}
	res %= 1000000007;
	cout << res << endl;
	return 0;
}


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

int area[100000];
int num[1000000];

int main(){
    char ch,ch_tmp;
    int n = 0;
    int j;

    ch_tmp = getc(stdin);
    area[n] = -1;
    n++;
    ch = getc(stdin);

    while(ch != '\n'){
        if(ch == 'L' && ch != ch_tmp){
            area[n] = 2;
            area[n-1] = 1;
        }else{
            if(ch == 'L') area[n] = -2;
            else if(ch == 'R') area[n] = -1;
        }
        ch_tmp = ch;
        n++;
        ch = getc(stdin);
    }

    //initializel
    for(int i = 0;i < n;i++){
        num[i] = 0;
        // /cout << area[i] <<" ";
    }

    cout <<endl;

    
    //process
   for(int i = 0;i < n;i++){
       if(area[i] == -1){
           j = i + 2;
           while(area[j] < 0){
               j += 2;
           }
           num[j] = num[j] + 1;
       }else if(area[i] == -2){
           j = i - 2;
           while(area[j] < 0){
               j -= 2;
           }
           num[j] = num[j] + 1;
       }else if(area[i] > 0){
            num[i] = num[i] + 1;
       }
   }

    //output
    for(int i = 0;i < n;i++){
        cout << num[i] << " ";
    }

    return 0;
}

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

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;

const int mod = 998244353;
const ll inf = 3e18 + 5;

int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }  

int main(){
    int r;
    cin >> r;
    cout << r*r;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N, M;
  std::cin >> N >> M;

  ll cnt = std::min(N, M / 2);
  N -= cnt;
  M -= cnt * 2;

  cnt += M / 4;
  print(cnt);

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
#define sz(x) (int)(x).size()
/* --- */
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int k = 3 * max({a, b, c}) - (a + b + c);
	if (k & 1) cout << (k + 3) / 2 << '\n';
	else cout << k / 2 << '\n';
}



Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Arrays;
import java.util.Collections;
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int A = scan.nextInt();
    int B = scan.nextInt();
    if (A + B == 3) {
      System.out.println(3);
    }
    else if (A + B == 5) {
      System.out.println(1);
    }
    else{
      System.out.println(2);
    }
  }
}



Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    int N, A;
    cin >> N >> A;
    YESNO(N % 500 <= A, "Yes", "No");
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int SIZE=2000000;
bool is_prime[SIZE];
int main() {
    memset(is_prime,-1,sizeof(is_prime));
    for(int i=2;i*i<SIZE;i++) {
        if(!is_prime[i]) continue;
        for(int j=i*2;j<SIZE;j+=i) is_prime[j]=0;
    }
    vector<int> prime;
    for(int i=2;i<SIZE;i++) if(is_prime[i]) prime.push_back(i);
    int n;
    while(scanf("%d",&n),n) {
        int pos=lower_bound(prime.begin(),prime.end(),n)-prime.begin();
        if(prime[pos]==n) {printf("0\n");continue;}
        printf("%d\n",prime[pos]-prime[pos-1]);
    }
}

Measured memory_bytes: 5620
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<P,int>
#define vpp vector<PP>
#define fi first
#define se second
#define INF (1<<30)
#define MOD 1000000007
#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 all(x) (x).begin(),(x).end()
int main(){
    int n;
    cin>>n;
    int ans=INF;
    REP(i,n){
        int t;
        cin>>t;
        int p=0;
        while(!(t%2)){
            p++;
            t/=2;
        }
        ans=min(ans,p);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n, m;
    cin >> n >> m;
    vll x(n), y(n), z(n);
    rep(i, n) cin >> x[i] >> y[i] >> z[i];

    ll ans = 0;
    rep(i, 8) {
        vll s(n, 0);
        rep(j, n) {
            if ((i >> 0) & 1) s[j] += x[j];
            else s[j] -= x[j];
            if ((i >> 1) & 1) s[j] += y[j];
            else s[j] -= y[j];
            if ((i >> 2) & 1) s[j] += z[j];
            else s[j] -= z[j];
        }
        sort(rall(s));
        ll ans_t = 0;
        rep(j, m) ans_t += s[j];
        ans = max(ans, ans_t);
    }

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int64, int64>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 3e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<endl;
#define zero(n) cout<<setfill('0')<<right<<setw(n)
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

struct UnionFind {
  vector< int > par;
	vector< int > memo;
  UnionFind(int n = 1) {
    init(n);
  }

  void init(int n = 1) {
    par.resize(n);
		memo.resize(n);
    for(int i = 0; i < n; i++) {
      par[i] = -1;
			memo[i] = 1;
		}
  }
  
  int root(int n) {
    if (par[n] < 0) return n;
    return par[n] = root(par[n]);
  }

  bool merge(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x, y);
    par[x] += par[y];
    par[y] = x;

    return true;
  }

  bool issame(int x, int y) {
    return root(x) == root(y);
  }

	int getSize(int x){
		return memo[x] = (-par[root(x)]);
	}
};

vector<int> e[MAX_N];
int memo[MAX_N];

signed main() {
  INIT;
	VAR(int,n,m);
	vector<int> a(m),b(m);
	REP(i,m){
		cin>>a[i]>>b[i];
		--a[i];--b[i];
	}

	int ans = n * (n-1) / 2;
	UnionFind uf(MAX_N);
	RREP(i,m){
		memo[i] = ans;
		if (!uf.issame(a[i],b[i])) {
			ans -= uf.getSize(a[i]) * uf.getSize(b[i]);
		}
		uf.merge(a[i], b[i]);
	}

	REP(i,m){
		OUT(memo[i])BR;
	}
	
  return 0;
}


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

using int64 = long long;
using uint64 = unsigned long long;

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

    std::string s;
    std::cin >> s;

    if ((s[0] == s.back()) == (s.size() & 1)) std::cout << "Second" << std::endl;
    else std::cout << "First" << std::endl;

    return 0;
}


Measured memory_bytes: 512
#import sys
#input = sys.stdin.readline
def main():
    S = input()
    N = len(S)
    now = S[0]
    comp = ""
    ans = 1
    need = 0
    for i in range(1,N):

        if need == 0:
            comp = S[i]
        else:
            comp += S[i]
            need = 0
        if now != comp:
            ans += 1
            now = comp
        else:
            need = 1
    print(ans)
if __name__ == '__main__':
    main()


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

using namespace std;

int n;  
int x[10], y[10];

double dist(int i, int j) {
  double dx = x[i] - x[j];
  double dy = y[i] - y[j];
  return pow(dx * dx + dy * dy, 0.5);
}
  
void solve() {
  cin>>n;
  for(int i=1; i<=n; i++) cin>>x[i]>>y[i];
  double sum=0.0;
  vector<int> v(n);
  rep(i, n) v[i] = i+1;
  do {
    rep(i,n-1) sum += dist(v[i], v[i+1]);
  } while(next_permutation(v.begin(), v.end()));
  int factorial = 1;
  for(int i=2; i<=n; i++) factorial*=i;
  cout<<fixed<<setprecision(7)<<sum/factorial;
}

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

Measured memory_bytes: 4216
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define ULL unsigned long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
#define less Less
#define EPS 1e-4
#define arg ARG
#define cpdd const pdd
#define rank Rank
#define KK 500
#define N 100005
int main(){
    int cnt[100005];
    fill(cnt,cnt+100005,0);
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i = 0;i<m;i++){
        int x,y;
        scanf("%d %d",&x,&y);
        cnt[x]++;
        cnt[y]++;
    }
    for(int i = 1;i<=n;i++){
        if(cnt[i]&1){
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");
}
/*
1-n 0
2-n 1
3-n 2
-3 0
-2 1
-1 2
0 3
*/
/*
1 0
2 -10  01
3 -20 -1 1 0 2


*/
/*

k*cnt[i]-k*cnt[j]=i-j;
k*cnt[i]-i=k*cnt[j]-j
1 2 3 4 5
1 2 3 4 5 6
1 2 3 4 5    3
1 2 3 5 6    4 
1 2 3 4 6
3
0 1 2
0 2 2.5

1 2 3 4 5
1 2 3 4 5
1 3
1 4
1
*/
/*
AC
AGCG
AGCGU
AT
*/

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define Rep(i, N) for(int i = 0; i < N; i++)
#define Reps(i, x, N) for(int i = x; i < N; i++)

inline int llabs(int n) { return n < 0 ? -n : n; }

signed main()
{
  int N, M;

  int A[55], B[55], C[55], D[55];

  cin >> N >> M;
  Rep(i, N) {
    cin >> A[i] >> B[i];
  }
  Rep(i, M) {
    cin >> C[i] >> D[i];
  }

  Rep(i, N) {
    int mpos = 0;
    Reps(j, 1, M) {
      if(llabs(A[i] - C[j]) + llabs(B[i] - D[j]) < llabs(A[i] - C[mpos]) + llabs(B[i] - D[mpos])) {
	mpos = j;
      }
    }

    cout << mpos + 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256