akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>

using namespace std;

struct Primecount{
	int p;
	int cnt;
};

int main(){
	queue<int> prime;
	queue<int> numberlist;
	for(int i = 2; i <= 1000; i++){
		numberlist.push(i);
	}
	while(numberlist.front() < 32){
		int now = numberlist.front();
		numberlist.pop();
		prime.push(now);
		int M = numberlist.size();
		for(int i = 0; i < M; i++){
			int next = numberlist.front();
			numberlist.pop();
			if(next%now != 0){
				numberlist.push(next);
			}
		}
	}
	int M = numberlist.size();
	for(int i = 0; i < M; i++){
		prime.push(numberlist.front());
		numberlist.pop();
	}
	M = prime.size();
	Primecount primecounter[prime.size()];
	for(int i = 0; i < M; i++){
		primecounter[i].p = prime.front();
		prime.pop();
		primecounter[i].cnt = 0;
	}
	int N;
	cin >> N;
	for(int i = 1; i < N+1; i++){
		int a = i;
		for(int j = 0; j < M; j++){
			int now = primecounter[j].p;
			while(a%now == 0){
				primecounter[j].cnt++;
				a /= now;
			}
		}
	}
	long ans = 1;
	for(int i = 0; i < M; i++){
		ans = (ans * long(primecounter[i].cnt+1)) % 1000000007;
	}
	cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
double half[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    half[1]=0.5;
    for(int i=2; i<MAX-10; i++)
        half[i]=half[i-1]*0.5;
    // for(int i=1;i<=10;i++)
    //  cout<<setprecision(10)<<fixed<<half[i]<<endl;
    int n,k;
    cin>>n>>k;
    double sum=0;
    for(ll i=1; i<=n; i++)
    {
        ll cur=i,cnt=0;
        double low=(1.0/((double)n));
        if(i>=k)
        {
            sum+=low;
            continue;
        }
        while(cur<k)
        {
            cur*=2ll;
            cnt++;
        }

        double x=half[cnt];

        sum+=(half[cnt]*low);
    }

    cout<<setprecision(10)<<fixed<<sum<<endl;


    return 0;
}


Measured memory_bytes: 11492
def main():
    a, b, c, d = (int(i) for i in input().split())
    i = 0
    while a > 0 and c > 0:
        if i % 2 == 0:
            c -= b
        else:
            a -= d
        i += 1
    if a <= 0:
        print("No")
    else:
        print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61840
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pii;
 
#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)
 
void ii(ll &x){ cin >> x; }
void is(string &x){ cin >> x; }
void oi(ll x){ cout << x << " "; }
void os(string x){ cout << x; }
void oie(ll x){ cout << x << endl; }
void ose(string x){ cout << x << endl; }
void oe(){ cout << endl; }
 
ll INF = 1e9+7;
 
int main(){
    ll a,b,c;
    ii(a);ii(b);ii(c);
    ll d=c-a-b;
    if(d>0 && 4*a*b<d*d){
        ose("Yes");
    }else{
        ose("No");
    }
    return 0;
}

Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;
use num_traits::*;
use superslice::*;
use std::ops::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

fn main() {
    input!{
        n: usize,
        a_vec: [usize; n]
    }

    let max = a_vec.iter().max().unwrap();
    let min = a_vec.iter().min().unwrap();

    println!("{}", max-min)
}


Measured memory_bytes: 2120
# pragma GCC optimize("Ofast")
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size)
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using lint = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){
    int n; cin >> n;
    int l, r;
    int sum = 0;
    rep(i,n){
        cin >> l >> r;
        sum+= r-l+1;
    }

    cout << sum;


    return 0;
}

Measured memory_bytes: 256
def main():
    num = int(input())
    CONST = 1000000007
    lis = [1] * 2100
    for i in range(3):
        lis[i] = 0
    for i in range(3,2020):
        for j in range(3,i):
            lis[i] += lis[i-j]
            lis[i] %= CONST
    print(lis[num])
if __name__ == '__main__':
    main()


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

int main() {
  int N;
  cin >> N;
  map<int, bool> A;
  string ans = "YES";
  for (int i = 0; i < N; i++) {
    int b;
    cin >> b;
    if (A[b])
      ans = "NO";
    else
      A[b] = true;
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 9600
C = input()
alphabet = ["a", "b", "c", "d", "e", "f", "g",
            "h", "i", "j", "k", "l", "m", "n",
            "o", "p", "q", "r", "s", "t", "u",
            "v", "w", "x", "y", "z"]
print(alphabet[alphabet.index(C)+1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int d[3]={a,b,c};
	int e[3]={0,0,0};
	int cnt=0;
	for(int i=0;i<3;i++){
		cnt=0;
		for(int j=0;j<3;j++){
			if(d[i]>d[j]){
				cnt++;
			}
		}
		for(;;){
			if(e[3-cnt-1]==0){
				e[3-cnt-1]=d[i];
				break;
			}
			else{
				cnt++;
			}
		}
	}
	int ans=0;
	if((e[1]-e[2])%2==0){
		ans=e[0]-e[1];
		ans=ans+(e[0]-(e[2]+ans))/2;
	}
	else{
		e[0]++;
		e[2]++;
		ans++;
		ans=ans+e[0]-e[1];
		ans=ans+(e[0]-(e[2]+ans-1))/2;
	}
	cout<<ans;
}

Measured memory_bytes: 256
// Problem : D - Katana Thrower
// Contest : AtCoder - AtCoder Beginner Contest 085
// URL : https://atcoder.jp/contests/abc085/tasks/abc085_d
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
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 vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int n, h;
	cin >> n >> h;
	vi v(n),a(n);
	loop( i, n)
	cin >> v[i] >> a[i];
	sort(all(a));
	sort(all(v));
	int ind=n;
	if(v[n-1]>=h)
	{
		cout<<1<<nl;
		return 0;
	}
	loop( i, n)
	{
		if(a[i]>v[n-1])
		{
			ind =i;	
			break;
		}
	} 
	ll sum=0,count=0;
	rep1(i,ind,n)
	{
		sum+=a[i];
		count++;
		if(sum>=h)
		{
			cout<<count<<nl;
			return 0;
		}
	}
//	int rem=((h-sum)%v[n-1]==0)?0:1;
	ll ans=(h-sum+v[n-1]-1)/v[n-1]+count;
	cout<<ans<<nl;
	
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

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

using namespace std;
using p = pair<long long, int>;
#define INF 100000000

int main(){
int n;
	cin >> n;
	vector<long long> a(n),b(n),c(n);
	
	rep(i,n)  cin >> a[i];
	rep(i,n)  cin >> b[i];
	rep(i,n)  cin >> c[i];
	
	sort(a.begin(),a.end()); sort(b.begin(),b.end()); sort(c.begin(),c.end());
	long long count = 0;
	rep(i,n){
		long long pre = lower_bound(a.begin(),a.end(),b[i]) - a.begin();
		long long over = c.end() - upper_bound(c.begin(), c.end(),b[i]);
		count += pre*over;
	}
	cout << count << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int div=0;
    long long ans=1;
    long long a[n];
    bool zero=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]==0)zero=1;
    }
    if(zero){
        cout<<"0"<<endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        if(a[i]>1000000000000000000/ans){
            cout<<"-1"<<endl;
            return 0;
        }
        ans*=a[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4400
s = input()
ans = (1, 2) if s[0] == s[1] else (-1, -1) 
for i in range(len(s)-2):
    if s[i] == s[i+1]:
        ans = (i+1, i+2)
        break
    if s[i] == s[i+2]:
        ans = (i+1, i+3)
        break
print(*ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

int main() {
  cpp_int a,b;
  cin>>a>>b;
  if(a>b){
    cout<<"GREATER"<<'\n';
  }
  else if(a<b){
    cout<<"LESS"<<'\n';
  }
  else{
    cout<<"EQUAL"<<'\n';
  }
  return(0);
}

Measured memory_bytes: 256
#include<cstdio>
const int N=3e5+5;
int k,n,a[N];
int main(){
	scanf("%d%d",&k,&n);
	if(k&1){
		for(int i=1;i<=n;++i)a[i]=k+1>>1;
		for(int i=1,it=n;i<=n/2;++i){
			if(a[it]==0){
				--a[it-1];
				if(a[it-1]==0)--it;else{
					for(int i=it;i<=n;++i)a[i]=k;
					it=n;
				}
			}else --a[it];
		}
		for(int i=1;i<=n;++i)if(a[i])printf("%d ",a[i]);
	}else{
		printf("%d",k/2);
		for(int i=1;i<n;++i)printf(" %d",k);
	}
	return 0;
}

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

#define ll long long

inline ll read() {
    ll x = 0, f = 1; char ch = getchar();
    for(; ch < '0' || ch>'9'; ch = getchar())
        if(ch == '-') f = -f;
    for(; ch >= '0' && ch <= '9'; ch = getchar())
        x = x * 10 + ch - '0';
    return x * f;
}

inline void chkmin( int &a, int b ) { if(a > b) a = b; }

inline void chkmax( int &a, int b ) { if(a < b) a = b; }

#define _ read()

#define ln endl

const int N = 1e6 + 6;
int n, dp[N];

int main()
{
	n = _;
	dp[0] = 1;
	for( int j = 100; j <= 105; j++ )
		for( int i = j; i <= n; i++ ) 
			if(dp[i - j])
				dp[i] = 1;
	cout << dp[n];
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <math.h>
//#include <map>
#include <iomanip>
#include <vector>

using namespace std;



int main()
{
	int n;
	char egara;
	int rank;
	bool S[14] = {false};
	bool H[14] = {false};
	bool C[14] = {false};
	bool D[14] = {false};
	
	cin >> n;
	for (int i=0; i<n; i++)
	{
		cin >> egara >> rank;
		if (egara == 'S')
		{
			S[rank] = true;
		} else if (egara == 'H') {
			H[rank] = true;
		} else if (egara == 'C') {
			C[rank] = true;
		} else if (egara == 'D') {
			D[rank] = true;
		}
	}
	
	for (int i=1; i<=13; i++)
	{
		if (S[i] == false)
		{
			cout << "S " << i << endl;
		}
	}
	for (int i=1; i<=13; i++)
	{
		if (H[i] == false)
		{
			cout << "H " << i << endl;
		}
	}
	for (int i=1; i<=13; i++)
	{
		if (C[i] == false)
		{
			cout << "C " << i << endl;
		}
	}
	for (int i=1; i<=13; i++)
	{
		if (D[i] == false)
		{
			cout << "D " << i << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;
typedef int64_t i64;

#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

i64 calc (i64 *a, i32 n, i32 x) {
  for (i32 i = 0; i < n; ++i) {
    x = a[i] - x;
  }
  return x;
}

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  i64 *a = ALLOC (n, i64);
  for (i32 i = 0; i < n; ++i) {
    scanf ("%" SCNi64, a + i);
  }
  i64 l = -1;
  i64 r = a[0] + 1;
  while (r - l > 1) {
    i64 m = (l + r) / 2;
    i64 v = calc (a, n, m);
    if (v < m) {
      r = m;
    } else {
      l = m;
    }
  }
  i64 x = l;
  for (i32 i = 0; i < n; ++i) {
    printf ("%" PRIi64, 2 * x);
    x = a[i] - x;
    putchar (i == n - 1 ? '\n' : ' ');
  }
}

int main (void) {
  run();
  return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
long long int mod97=1000000007;
double pi=3.1415926536;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
bool rev(long long int a,long long int b)
{
    if(a>b)return true;
    else return false;
}
bool compa(pair<string,pair<int,int>>a,pair<string,pair<int,int>>b)
{
    if(a.first==b.first)
    {
        if(a.second.first>b.second.first)
        return true;
        else
        return false;
    }
    if(a.first<b.first)
    return true;
    else 
    return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    long long int a,b,c;
    cin>>a>>b>>c;
    long long int k;cin>>k;
    long long int x=0,y=0;
    for(long long int i=0;i<=k;i++)
    {
        for(long long int j=0;j+i<=k;j++)
        {
            long long int nc=c*pow(2,i),nb=b*pow(2,j);
            if(nc>nb && nb>a)
            {
                cout<<"Yes";return;
            }
        }
    }
    cout<<"No";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    int count=1;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 4108
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	static void solve(){//Here is the main function
		int K = nextInt();
		int[] s = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
		myout(s[K - 1]);
	}
	//Method addition frame start



	//Method addition frame end

	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	@SuppressWarnings("unchecked")
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
}


Measured memory_bytes: 32816
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

# R, S, P -> 0, 1, 2

dp = [[0,0] for _ in range(N)]
for i in range(N):
    if T[i] == "r":
        dp[i] = [P, 2]
    elif T[i] == "s":
        dp[i] = [R, 0]
    elif T[i] == "p":
        dp[i] = [S, 1]
    
    
    if K <= i:
        if dp[i][1] == dp[i-K][1]:
            dp[i][0] = 0
            dp[i][1] = 3
ans = 0
for a, command in dp:
    ans += a
print(ans)

Measured memory_bytes: 13300
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)

int main(){
  long long a,b,c,d;
  cin >> a >> b >> c >> d;
  long long ans = a*c;
  ans = max(ans,a*d);
  ans = max(ans,b*c);
  ans = max(ans,b*d);
  cout << ans;
  return 0;
}

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

using namespace std;

long long y[100010];
long long res_y[100010];

vector<int> apply(vector<int> p, vector<int> q) {
    vector<int> c(p.size(), -1);
    for (int i = 0; i < q.size(); i++) {
        c[i] = p[q[i]];
    }
    return c;
}

void solve(long long N, vector<long long> x, long long M, long long K, vector<long long> a) {
    for (int i = 0; i < M; i++) a[i]--;
    vector<int> p(N - 1);
    for (int i = 0; i < N - 1; i++) p[i] = i;

    vector<int> q = p;

    for (int i = 0; i < M; i++) {
        swap(p[a[i]], p[a[i] - 1]);
    }
    for (int bit = 0; bit < 63; bit++) {
        if (K >> bit & 1) {
            q = apply(q, p);
        }
        p = apply(p, p);
    }

    for (int i = 0; i < N - 1; i++) y[i] = x[i + 1] - x[i];
    for (int i = 0; i < N - 1; i++) {
        res_y[i] = y[q[i]];
    }

    long long ans = x[0];
    for (int i = 0; i < N - 1; i++) {
        cout << ans << endl;
        ans += res_y[i];
    }
    cout << ans <<  endl;


}

int main() {
    long long N;
    scanf("%lld", &N);
    vector<long long> x(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &x[i]);
    }
    long long M;
    scanf("%lld", &M);
    long long K;
    scanf("%lld", &K);
    vector<long long> a(M);
    for (int i = 0; i < M; i++) {
        scanf("%lld", &a[i]);
    }
    solve(N, x, M, K, a);
    return 0;
}



Measured memory_bytes: 7880
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if((a+b)%2==0){
    cout<<(a+b)/2<<endl;
    return 0;
  }
  cout<<"IMPOSSIBLE"<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		boolean g = true;
		int t = 0;
		String a = sc.next();
		String b = sc.next();
		String[] strArray1 = a.split("");
		String[] strArray2 = b.split("");
		Arrays.sort(strArray1);
		Arrays.sort(strArray2,Collections.reverseOrder());
		int m1 = strArray1.length;
		int m2 = strArray2.length;
		if(m1 > m2) m1 = m2;
		for(int i = 0;i < m1;i++) {
			if(strArray1[i].compareTo(strArray2[i]) < 0) {
				g  = false;
				break;
			}
			if(strArray1[i].compareTo(strArray2[i]) == 0) t++;
		}
		if(t == m1 && m1 < m2) {
			System.out.println("Yes");
		}
		else if(g) {
			System.out.println("No");
		}
		else if(!g) {
			System.out.println("Yes");
		}
		sc.close();
	}
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int n;
    ll a[200001];
    int l=0;
    ll tmp = 0;

    ll ans = 0;

    Scd(n);
    Rep(i,n){
        Scll(a[i]);
    }

    Rep(i,n){
        while( tmp&a[i] ){
            tmp &= ~a[l++];
        }
        tmp |= a[i];
        ans += (i-l+1);
    }
    printf ("%llu\n", ans);

    return 0;
}



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


#define M 1000000007
#define pb push_back
#define mp make_pair
#define s second
#define f first
#define mod 998244353
#define sz(v) (int)(v).size()

#define pii pair<int, int>
#define vi vector<int>
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(0)

ll add(ll a,ll b)
{
	a%=M;
	b%=M;
	ll p = (a+b)%M;
	return (p+M)%M;
}

ll mul(ll a,ll b)
{
	a%=M;
	b%=M;
	ll p = (a*b)%M;
	return (p+M)%M;
}


int main()
{
	fastio;
	ll i,j,n,k,a[200010];
	cin>>n>>k;
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=k;i<n;i++)
	{
		if(a[i]>a[i-k])
			cout<<"Yes"<<endl;
		else
			cout<<"No"<<endl;
	}
    return 0;
}





Measured memory_bytes: 5216
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int n, y;
	cin >> n >> y;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			int k = n - i - j;
			if (k < 0) continue;
			if (10000*i + 5000*j + 1000*k == y) {
				cout << i << " " << j << " " << k << endl;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int N,M;
  cin>>N;
  int cnt = 0;
  M = N;
  while(M>=1){
    cnt = cnt + M % 10;
    M /= 10;
  }
  //cout << cnt << endl;
  if(N % cnt == 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3640
tailrec fun gcd(a: Long, b: Long): Long = if (b == 0L) a else gcd(b, a % b)

fun factorize(n0:Long):List<Pair<Long,Int>>{
    val res = mutableListOf<Pair<Long, Int>>()
    var i = 2L
    var n = n0
    while (i * i <= n) {
        if (n % i != 0L){
            i++
            continue
        }
        var c = 0
        while ( n % i == 0L){
            n /= i
            c++
        }
        res.add(i to c)
        i ++
    }
    if (n != 1L){
        res.add(n to 1)
    }
    return res
}


fun calc(a:Long, b:Long):Int = factorize(gcd(a, b)).size + 1

fun main(args:Array<String>) {
    val (a, b) = readLine()!!.split(" ").map { it.toLong() }
    val ans = calc(a, b)
    println(ans)
}


Measured memory_bytes: 37828
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#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 Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define endl "\n"
typedef long long ll;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl

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

  int N; cin >> N;
  const ll mod = 1000000000+7;
  ll res = 1;
  reps(i, 1, N+1) {
    res = res*i%mod;
  }
  cout << res << endl;

  return 0;
}


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

using namespace std;

int main()
{
    constexpr int EMPTY = -99;
    while (true) {
        int n, l;
        cin >> n >> l;
        if (n == 0 && l == 0) {
            break;
        }
        // 0 と l はトンネルの端っこ
        // fst：左向き，snd：右向き
        vector<pair<int, int>> v(l + 1, make_pair(EMPTY, EMPTY));
        // アリさんは1から数える
        for (int i = 1; i <= n; ++i) {
            char c;
            int p;
            cin >> c >> p;
            if (c == 'L') {
                v[p].first = i;
            }
            else {
                v[p].second = i;
            }
        }

        // アリさんの次の位置を求める
        auto move_ = [EMPTY, l](const vector<pair<int, int>>& v) {
            vector<pair<int, int>> r(v.size(), make_pair(EMPTY, EMPTY));
            for (int i = 0; i < v.size(); ++i) {
                // 左に移動
                if (i > 0) {
                    r[i - 1] = make_pair(v[i].first, r[i - 1].second);
                }
                // 右に移動
                if (i < l) {
                    r[i + 1] = make_pair(r[i + 1].first, v[i].second);
                }
            }
            for (auto&& i : r) {
                // 同じ位置にいる場合は衝突してるので，向きを変更
                if (i.first != EMPTY && i.second != EMPTY) {
                    swap(i.first, i.second);
                }
            }

            return r;
        };

        int count = 0;
        while (true) {
            auto result = move_(v);
            // 今出て行ったアリさんを記録
            int left = result[0].first;
            int right = result[l].second;
            count += 1;
            // 出て行ったアリさんを実際にどかす
            result[0] = result[l] = make_pair(EMPTY, EMPTY);
            // トンネルに誰もいなければ終了
            if (accumulate(begin(result), end(result), true,
                           [](bool b, const pair<int, int>& a) {
                               return b && a.first == EMPTY &&
                                      a.second == EMPTY;
                           })) {
                // 左優先
                cout << count << " " << (left == EMPTY ? right : left) << endl;
                break;
            }
            v = result;
        }
    }
}


Measured memory_bytes: 3024
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
bool is_perfect_square(ll n) {
    return ll(sqrt(n)) * ll(sqrt(n)) == n;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int q;
    cin >> q;
    while(q--) {
        ll a, b;
        cin >> a >> b;
        ll rt_ab = ll(sqrt(a * b));
        if(is_perfect_square(a * b)) {
            cout << 2 * rt_ab - 2 - (a != b) << endl;
        } else {
            cout << 2 * rt_ab - ((a * b - 1) / rt_ab == rt_ab) - 1 << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    int N, ans;
    int block = 0;
    int BlockFlag = 0;
    scanf("%d", &N);
    vector<int> a(N);
    REP(int,i,0,N) scanf("%d", &a.at(i));
    int j = 1;
    REP(int,i,0,N){
        if ( a.at(i) == j ){
            j++;
            BlockFlag = 1;
            block++;
        }
    }
    if ( BlockFlag == 1 ) ans = N - block;
    else if ( BlockFlag == 0 ) ans = -1;
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define sz 100002
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define pi pair<int,int>
#define PQ priority_queue<double, vector<double>, greater<double> >q
#define _sort(v) sort(v.begin(),v.end())
#define MP map<ll int,ll int>mp
#define MEM(x) memset(x,0,sizeof(x))
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define VEC() vector<ll int>v
#define VEC(n) ll int x; vector<ll int>v;for(int i=0;i<n;i++){cin>>x;v.pb(x);}
#define TEST() int test;cin>>test; while(test--)
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
//Upper_bound   auto x=upper_bound(v[a].begin(),v[a].end(),les);les=*x; if(x==v[a].end())break;
//ll int LCM(ll int a,ll int b) { ll int gcd=__gcd(a,b);ll int lcm=a*b/gcd;return lcm;}
//ll int bigmod(ll int b, ll int p, ll int m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ ll int res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//ll mod_inverse(ll a, ll mod){return bigmod(a,mod-2,mod);}
//void seive() { prime[np++]=2;for(i=3; i<=sz; i+=2){if(mark[i]==0){ prime[np++]=i;for(j=i*i; j<=sz; j+=i) mark[j]=1; } }}
//string add(string s1,string s2) {string s;int j=s1.size()-1,c=0,m; for(int i=s2.size()-1; i>=0; i--) {if(j>=0)m=s2[i]-'0'+s1[j]-'0'+c;else m=s2[i]-'0'+c; if(m>9) { s+=m%10+'0';c=m/10; } else {  c=0;s+=m+'0'; }j--; } if(c!=0) {s+=c+'0'; }reverse(s.begin(),s.end());return s;}
//int pos;string mul(int n) {string s;for(int i=0; i<pos; i++) { s+="0"; }pos++;int c=0,m; for(int i=s1.size()-1; i>=0; i--) { m=(s1[i]-'0')*n+c;if(m>9) { s+=m%10+'0';c=m/10;} else { c=0; s+=m+'0';} }while(c!=0) { s+=c%10+'0';c=c/10;}    reverse(s.begin(),s.end());return s;}

int main()
{
    string s,t;
    ll int mx=0;
    cin>>s>>t;
    for(int i=0;i<=s.size()-t.size();i++)
    {ll int cnt=0;
        for(int j=0;j<t.size();j++)
        {
            if(s[i+j]==t[j])cnt++;
        }
        mx=max(mx,cnt);
    }
    cout<<t.size()-mx<<endl;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int iinf = 1 << 28;
const long long llinf = 1ll << 60;
const double PI = 3.14159265;

int main() {
    int n; cin>>n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) cin>>v[i];
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            ans += v[i]*v[j];
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int g(int a,int b) {
	return a%b?b%a?a>b?g(a%b,b):g(a,b%a):a:b;
}
int d=0;
int main(int n,int X,int x) {
	scanf("%d%d",&n,&X);
	while(n--) {
		scanf("%d",&x);
		d=g(d,abs(x-X));
	}
	printf("%d",d);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>
#include<math.h>
#include<string.h>
typedef long long int ll;
typedef struct{
    int x,y,c;
}list;
int str_comp(const void*a,const void*b){return ((list*)b)->c-((list*)a)->c;}
int int_comp(const void*a,const void*b){return *(int*)a-*(int*)b;}
void yes(){printf("Yes\n");}
void no(){printf("No\n");}

int main(void)
{
    int a,b,m;
    int aa[100000],bb[100000];
    list xyc[100000];


    scanf("%d %d %d",&a,&b,&m);
    for(int i=0;i<a;i++){
        scanf("%d",&aa[i]);
    }
    for(int i=0;i<b;i++){
        scanf("%d",&bb[i]);
    }
    for(int i=0;i<m;i++){
        scanf("%d %d %d",&xyc[i].x,&xyc[i].y,&xyc[i].c);
    }
    qsort(xyc,m,sizeof(list),str_comp);
    int min1=INT_MAX,mini=0;
    for(int i=0;i<m;i++){
        int tmp=aa[xyc[i].x-1]+bb[xyc[i].y-1]-xyc[i].c;
        if(min1>tmp){
            min1=tmp;
        }
    }
    qsort(aa,a,sizeof(int),int_comp);
    qsort(bb,b,sizeof(int),int_comp);
    int min2=aa[0]+bb[0];
    if(min1>min2)printf("%d\n",min2);
    else printf("%d\n",min1);

    return 0;
}

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

int main(){
     long long int a,b;
    cin >> a >> b;
    long long int x=a*b;
    //最大公約数を求めて、積/最大公約数にすればよい
    if(a<b){
        long long int tmp=a;
        a=b;
        b=tmp;
    }
    long long int r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    cout << x/b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
    #include<ext/pb_ds/assoc_container.hpp> 
    #include<ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    using namespace std;
    template <typename T>
    using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
    #define int long long  
    typedef long double ld;
    #define pb push_back
    #define f(i,a,b) for(int i=a;i<b;i++)
    #define fd(i,a,b) for(int i=a-1;i>=b;i--)
    #define pf push_front
    #define fi first
    #define se second
    #define INF 1e10
    const double pi=3.14159265358979323;
    const int mod=998244353;
    const int MAX=1e7+5;
    int gcd(int a, int b) 
    { 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
    } 
    void swap(int a,int b)
    {
      int temp=a;
      a=b;
      b=temp;
    } 
    int  binpow(int  a,int  b) 
    {
    int res = 1;
    while (b > 0) {
        if (b%2 == 1)
            res = (res * a)%mod;
        a = (a* a)% mod;
        b >>= 1;
    }
    return res;
}
    int modinv(int y)
    {
        return binpow(y,mod-2);
    }

    int fact[500000+5];
    void precal()
    {
    fact[0]=1;
    for(int i=1;i<500000+5;i++)
    {
        fact[i]=(i*fact[i-1])%mod;
    }
}   
    bool isPrime(int n) 
    { 
    // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
   
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (int i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
  
    return true; 
    } 
    signed main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    #ifndef ONLINE_JUDGE
     if(fopen("INPUT.txt","r"))
      {
      freopen ("INPUT.txt" , "r" , stdin);
      freopen ("OUTPUT.txt" , "w" , stdout); 
      }
    #endif  
    // -------------------------------------Code starts here--------------------------------------------------------------------- 
    int t=1; 
   // cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        int a[n];
        int xx=0;
        f(i,0,n)
        {
            cin>>a[i];
            xx=xx^a[i];
        }
        f(i,0,n)
        {
            cout<<(xx^a[i])<<" ";
        }
        cout<<endl;
    }   
}
  

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll modpow(ll n, ll r) {
    ll ret = 1;
    ll p = n;
    while (r > 0) {
        if (r & 1)
            ret = (ret * p) % MOD;
        p = (p * p) % MOD;
        r /= 2;
    }
    return ret;
}

struct Combination {
    Combination(ll n) {
        mNumTbl.resize(n + 1);
        mInverseNumTbl.resize(n + 1);
        mNumTbl[0] = 1;
        mInverseNumTbl[0] = 1;
        FOR(i, n + 1, 1) {
            mNumTbl[i] = (mNumTbl[i - 1] * i) % MOD;
        }
        FOR(i, n + 1, 1) {
            mInverseNumTbl[i] = modpow(mNumTbl[i]);
        }
    }

    ll get(ll n, ll r) {
        if (n < r || n < 0)
            return 0;
        return (((mNumTbl[n] * mInverseNumTbl[r]) % MOD) * mInverseNumTbl[n - r]) % MOD;
    }

    ll modpow(ll n) {
        ll s = 1, p = n;
        for (ll i = 0; (1LL << i) <= MOD - 2; ++i, p = (p * p) % MOD) {
            if (((MOD - 2) & (1 << i)) == 0)
                continue;
            s *= p;
            s %= MOD;
        }
        return s;
    }

    vector<ll> mInverseNumTbl;
    vector<ll> mNumTbl;
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll K;
    cin >> K;
    string S;
    cin >> S;
    ll N = S.length();

    Combination cmb(N + K + 10);
    ll ans = 0;
#if false

#else
#if true
    REP(i, N + K) {
        //        cout << cmb.get(i + 1, N - 1) << " ";
        ll p = cmb.get(N + K - i - 1, N - 1) * modpow(25LL, K - i);

        p %= MOD;
        //        p = (p * modpow(26LL, N + K - (i + 1))) % MOD;
        p = (p * modpow(26LL, i)) % MOD;
        // cout << p << endl;
        ans = (ans + p) % MOD;
    }
#else
    {
        //! 0の前にi個入れる
        REP(i, K + 1) {
            ll p = modpow(26LL, i);
            //! 他はN箇所から選んでいれる
            ll q = (MOD + cmb.get(N + K - i, K - 1) ) % MOD;
            q = (q * modpow(25LL, K - i)) % MOD;
           // cout << p << " " << q << endl;
            ans = (ans + (p * q) % MOD) % MOD;
        }
    }
#if false
    {
        //! 0の前に入れない
        REP(i, K) {
            ll p = cmb.get(N + (i + 1) - 1, (i + 1)) * modpow(25LL, i + 1) % MOD;
            p = (p * modpow(26LL, K - (i + 1))) % MOD;
            ans = (ans + p) % MOD;
        }
    }
    {
        //! 0の前に入れる
        REP(i, K) {
            ll p = modpow(N + i - 1, i) * modpow(25LL, i) % MOD;
            p = (p * modpow(26LL, K - i)) % MOD;
            ans = (ans + p) % MOD;
        }
    }
#endif
#endif
#endif
    cout << ans << endl;


    return 0;
}

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

using ll = long long;
const int INF = INT_MAX;//2147483647
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var)  std::cout<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for(int i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(int i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define pb push_back
inline double isnatural(double a) { return a>=0 && ceil(a)==floor(a); }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/


int main() {

	int N,W;
	cin >> N >> W;
	vector<ll> v(N,0),w(N,0);
	rep(i,N){
		cin >> w[i] >> v[i];
	}

	//dp[i][j] 商品iまで使える状態　価値jの中での重さ最小値
	vector<vector<ll>> dp(N+1,vector<ll>(1e5+1,INF));
	//vector<vector<ll>> dp(N+1,vector<ll>(11,99));
	rep(i,N+1){
		dp[i][0]=0;
	}

	rep(i,N){
		repeq(j,1e5){
			chmin(dp[i+1][j],dp[i][j]);
			if(j-v[i]>=0){
				chmin(dp[i+1][j],dp[i][j-v[i]]+w[i]);
			}
		}
		//debug(dp);
	}

	for(int j=1e5;j>=0;j--){
		if(dp[N][j]<=W){
			p(j);
			break;
		}
	}

	return 0;
}



Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////



int main(){
    ll n,h,w;cin>>n>>h>>w;
    ll a=n-h+1,b=n-w+1;
    if(a<0||b<0){
        cout<<0<<endl;
        return 0;
    }else{
        cout<<a*b<<endl;
    }
    
    
    return 0;
}






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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&b==c){
        cout<<"1"<<"\n";
    }else if(a==b&&b!=c){
        cout<<"2"<<"\n";
    }else if(a==c&&c!=b){
        cout<<"2"<<"\n";
    }else if(b==c&&c!=a){
        cout<<"2"<<"\n";
    }
    else{
        cout<<"3"<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
#import string,itertools,fractions,heapq,re,array,bisect
#from math import *
#from collections import Counter


import sys
stdin = sys.stdin

A, B, C = map(int, stdin.readline().strip().split())

rr =         B * C if A % 2 == 1 else 0
rr = min(rr, A * B if C % 2 == 1 else 0)
rr = min(rr, C * A if B % 2 == 1 else 0)

print rr


Measured memory_bytes: 2568
#include "bits/stdc++.h"
using namespace std;

#define rep(i,N) for(int i=0;i<(int)N;++i)
#define rep1(i,N) for(int i=1;i<=(int)N;++i)

using int64 = long long;
using i64 = long long;

const int inf = 1 << 30;
const i64 inf64 = 1ll << 60;

const int mod = 1e9 + 7;

template<typename T>
vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
   return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int dy[] = { 0, 1, 0, -1 };
int dx[] = { -1, 0, 1, 0 };

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

template <typename T> 
ostream& operator<<(ostream& os, const vector<T>& v) {
   os << "[";
   for (auto& e : v) os << e << ", ";
   return os << "]";
}

template <typename T>
struct Edge {
   int from, to;
   T cost;
};

template <typename T>
vector<T> bellman_ford(vector<Edge<T>>& edges, int V, int s) {
   const auto inf = numeric_limits<T>::max();
   vector<T> dist(V, inf);
   dist[s] = 0;
   for (int i = 0; i < V - 1; ++i) {
      for (auto& e : edges) {
         if (dist[e.from] == inf) continue;
         dist[e.to] = min(dist[e.to], dist[e.from] + e.cost);
      }
   }
   for (auto& e : edges) {
      if (dist[e.from] == inf) continue;
      if (dist[e.from] + e.cost < dist[e.to]) return vector<T>();
   }
   return dist;
}


int main() {
   int V, E, r; cin >> V >> E >> r;
   vector<Edge<i64>> edges(E);
   rep(i, E) cin >> edges[i].from >> edges[i].to >> edges[i].cost;

   auto d = bellman_ford(edges, V, r);
   if (d.size() == 0) {
      cout << "NEGATIVE CYCLE" << endl;
   } else {
      for (auto& e : d) {
         if (e == numeric_limits<i64>::max()) cout << "INF" << endl;
         else cout << e << endl;
      }
   }
}



Measured memory_bytes: 3168
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in=new Scanner(System.in);
		int j=0;
		while(in.hasNext())
		{
			String d5="";
			String d4="";
			String d3="";
			String d2="";
			String d1="";
			char ch[]=in.next().toCharArray();
			int n=ch.length;
			if(n==1)
			{
				d5=sol('0');
				d4=sol('0');
				d3=sol('0');
				d2=sol('0');
				d1=sol(ch[0]);
			}
			else if(n==2)
			{
				d5=sol('0');
				d4=sol('0');
				d3=sol('0');
				d2=sol(ch[0]);
				d1=sol(ch[1]);
			}
			else if(n==3)
			{
				d5=sol('0');
				d4=sol('0');
				d3=sol(ch[0]);
				d2=sol(ch[1]);
				d1=sol(ch[2]);
			}
			else if(n==4)
			{
				d5=sol('0');
				d4=sol(ch[0]);
				d3=sol(ch[1]);
				d2=sol(ch[2]);
				d1=sol(ch[3]);
			}
			else if(n==5)
			{
				d5=sol(ch[0]);
				d4=sol(ch[1]);
				d3=sol(ch[2]);
				d2=sol(ch[3]);
				d1=sol(ch[4]);
			}
			if(j==1)
				System.out.println();
			for(int i=0;i<8;i++)
				System.out.println(d5.charAt(i)+""+d4.charAt(i)+""+d3.charAt(i)+""+d2.charAt(i)+""+d1.charAt(i));
			j=1;
		}
	}
	public static String sol(char c)
	{
		if(c=='1')
			return "* =* ***";
		else if(c=='2')
			return "* =** **";
		else if(c=='3')
			return "* =*** *";
		else if(c=='4')
			return "* =**** ";
		else if(c=='5')
			return " *= ****";
		else if(c=='6')
			return " *=* ***";
		else if(c=='7')
			return " *=** **";
		else if(c=='8')
			return " *=*** *";
		else if(c=='9')
			return " *=**** ";
		else 
			return "* = ****";
	}
}

Measured memory_bytes: 12000
fun main(args: Array<String>) {
    readLine()!!
    val numList = readLine()!!.split(" ").map { it.toInt() }.toMutableList()
    var canChange = true
    var ans = "YES"

    for (i in numList.indices) {
        if (numList[i] != i + 1) {
            val where = numList.indexOf(i + 1)
            if (where == -1) {
                ans = "NO"
                break
            }
            if (canChange) {
                numList[where] = numList[i]
                numList[i] = i + 1
                canChange = false
            }else{
                ans = "NO"
                break
            }
        }
    }
    print(ans)
}

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



int main() {
	int n;
  	cin>>n;
  
  	//Nの数だけAを読み込む
  	vector<int>  a(n);
  	for(int i=0;i<n;i++)
     cin>>a[i];
  
  	int min=a[0],max=a[0];
      
      for(int i=0;i<n;i++){
      if(min>a[i])
        min=a[i];
      if(max<a[i])
        max=a[i];
      }        
  
	cout<<max-min<<endl;
  
  
    }
 

Measured memory_bytes: 256
object Main extends App{
  import scala.io.StdIn._
  import scala.math.abs
  var stack = Nil : List[Int]
  val n = readLine.trim.toInt
  val slimes = readLine.trim.split(' ').map(_.toInt)
  var length = 1
  var prev = 0
  for (slime ← slimes){
    if (prev == slime){
      length += 1
    }else{
      if (length > 1) stack = length::stack
      prev = slime
      length = 1
    }
  }
  if (length > 1)  stack = length :: stack
  println(stack.map{_ / 2}.sum)
}

Measured memory_bytes: 25536
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

ll num[55];
ll paty[55];

// レベルlevelで下からx層を食べる時のパティーの個数
ll f(int level, ll x) {
  if(level == 0) {
    return x > 0 ? 1 : 0;
  }
  ll ret = 0;
  if(x >= num[level-1] + 2) {
    return paty[level-1] + 1 + f(level-1, x-num[level-1]-2);
  } else {
    return  f(level-1, x-1);
  }
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, X;
  cin >> N >> X;
  num[0] = 1;
  paty[0] = 1;
  FOR(i,1,55) {
    num[i] = 2 * num[i - 1] + 3;
    paty[i] = 2 * paty[i - 1] + 1;
  }
  cout << f(N, X) << endl;
}

Measured memory_bytes: 384