akhauriyash/Code-Regression huggingface dataset:
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//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;
	}
	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------------------------------------------
	static void solve(){//Here is the main function
		myout(nextInt() / 3);
	}
	//Method addition frame start



	//Method addition frame end
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int 
#define pb push_back
#define mp make_pair
#define endl "\n"
#define mem(x) memset(x, -1, sizeof(x))
const int MOD = 1e9+7;

template <typename T>
void print(T AA[], int nn){for(int ii=0; ii<nn; ii+=1){cout<<AA[ii]<<" ";}cout<<endl;}
template <typename T> inline void print(T nn){ cout << nn << endl;}
/* ----------------------------------------------------------------------------------- */

//CODECHEF TSHIRTS PROBLEM
const int N = 21;
int n, A[N][N], cache[N][1<<N];

int fn(int man, int women_mask){
    if(man==n){
        if(women_mask==(1<<n)-1) return 1;
        return 0;
    }
    int &ans = cache[man][women_mask];
    if(ans != -1) return ans;
    ans = 0;
    for(int i=0; i<n; i+=1){
        if(A[man][i]==1){
            if((women_mask&(1<<i)) == 0){
                ans += fn(man+1, women_mask|(1<<i));
                if(ans>=MOD) ans %= MOD;
            }
        }
    }
    return ans;
}

int32_t main(){

    IOS

    mem(cache);
    cin >> n;
    for(int i=0; i<n; i+=1){
        for(int j=0; j<n; j+=1){
            cin >> A[i][j];
        }
    }

    print(fn(0, 0));

    return 0;
}

Measured memory_bytes: 344320
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

int h, w, k;

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

    cin>>h>>w>>k;
    vector<string> s(h);
    for(int i=0; i<h; i++) cin>>s[i];

    vector<vector<int>> psum(h+1, vector<int>(w+1, 0));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            psum[i+1][j+1] = psum[i+1][j] + (s[i][j] == '1');
        }
    }

    for(int i=0; i<w; i++){
        for(int j=0; j<h; j++){
            psum[j+1][i+1] += psum[j][i+1];
        }
    }

    int ans = inf;
    for(int bit=0; bit<(1<<(h-1)); bit++){

        bool f = true;
        for(int j=0; j<w; j++){
            int ph = 0;
            for(int i=0; i<h; i++){
                // i, i + 1 のあいだに割れ目
                if((bit & (1 << i)) || i == h - 1){
                    int cur = psum[i+1][j+1] - psum[i+1][j] - psum[ph][j+1] + psum[ph][j];
                    if(k < cur){
                        f = false;
                    }
                    ph = i + 1;
                }
            }
        }

        if(!f) continue;

        int cnt = __builtin_popcount(bit);
        int pw = 0;
        // よこにいく
        for(int j=0; j<w; j++){
            int ph = 0;
            bool valid = true;
            
            for(int i=0; i<h; i++){
                // i, i + 1 のあいだに割れ目
                if((bit & (1 << i)) || i == h - 1){
                    int cur = psum[i+1][j+1] - psum[i+1][pw] - psum[ph][j+1] + psum[ph][pw];
                    if(k < cur){
                        valid = false;
                    }
                    ph = i + 1;
                }
            }

            if(!valid){
                pw = j;
                cnt++;
            }
        }

        chmin(ans, cnt);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <fstream>

using std::cin;
using std::cout;
using std::endl;
using std::terminate;

template<class T> inline T min(T X, T Y) {
    return X < Y ? X : Y;
}

template<class T> inline T pow(T base, T exponent) {
    if (exponent == 0) return 1;

    if (exponent % 2 == 1) {
        return base * pow(base, exponent - 1);
    } else {
        T tmp = pow(base, exponent / 2);
        return tmp * tmp;
    }
}

template<class T> inline T abs(T X) {
    return X > 0 ? X : -X;
}

void solve() {
    int N; cin >> N;
    int X[N];
    for (int i = 0; i < N; ++i) {
        cin >> X[i];
    }

    int ans = 1000005;
    for (int P = 1; P <= 100; ++P) {
        int tmp = 0;
        for (int i = 0; i < N; ++i) {
            tmp += pow(abs(X[i] - P), 2);
        }
        ans = min(ans, tmp);
    }

    cout << ans << endl;
}

int main() {

#ifdef DEV
    std::ifstream in("input");
    cin.rdbuf(in.rdbuf());

    int t; cin >> t;
    for (int x = 1; x <= t; ++x) {
        solve();
    }
#else
    solve();
#endif

    return 0;
}


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


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

int a[100005]={0};

int main(){
    int n, x;
    cin >> n >> x;
    for(int i=0;i<n;++i){
        cin >> a[i];
    }

    long long int ans = 0;
    for(int i=1;i<n;++i){
        int eat = min(a[i], max(0, (a[i] + a[i-1]) - x));
        ans += eat;
        a[i] -= eat;
        ans += max(0, a[i-1] - x);
        a[i-1] -= max(0, a[i-1] - x);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private const int MODULO = 1000000007;
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static string Solve(int n, string[] S)
        {
            int[] mins = Enumerable.Repeat(int.MaxValue, 26).ToArray();
            foreach (string s in S)
            {
                int[] counts = new int[26];
                foreach (char c in s) { ++counts[c - 'a']; }
                for (int i = 0; i < 26; ++i) { mins[i] = Math.Min(counts[i], mins[i]); }
            }
            var sb = new StringBuilder();
            for (int i = 0; i < 26; ++i) { sb.Append(new string((char)('a' + i), mins[i])); }
            return sb.ToString();
        }
        static void Main(string[] args)
        {
            int n = ReadInt();
            var S = new string[n];
            for (int i = 0; i < n; ++i) { S[i] = Read(); }
            Console.WriteLine(Solve(n, S));
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード

//ループ
#define REP(i, n) for(int i = 0; i < n; i++) //普通のループ
#define REPR(i, n) for(int i = n; i >= 0; i--) //逆ループ
#define FOR(i, m, n) for(int i = m; i < n; i++) //最初の数値を指定したループ

//型名省略
typedef long long ll;

using namespace std;

int main(){
    int a, b, c;
    
    cin >> a >> b >> c;
    if(a==b){
        if(c!=a){
            printf("Yes");
        }
        else if(c==a){
            printf("No");
        }
    }
    else if(b==c){
        if(a!=b){
            printf("Yes");
        }
        else if(a==b){
            printf("No");
        }
    }
    else if(c==a){
        if(b!=a){
            printf("Yes");
        }
        else if(b==a){
            printf("No");
        }
    }
    else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 256
<?php
    $line = intval(trim(fgets(STDIN)));
    $count=0;
    
    for($i=1;$i<10;$i++){
        for($j=1;$j<10;$j++){
            if($i*$j==$line){
                $count++;
            }
            
        }
    }
    if($count>0){
        echo "Yes";
    }else{
        echo "No";
    }
?>

Measured memory_bytes: 3700
n = int(input())
x, y = [int(i) for i in input().split()]

for i in range(n-1):
  t, a = [int(i) for i in input().split()]
  
  if t >= x and a >= y:
    x = t
    y = a



  else:
    c = max(-(-x//t), -(-y//a))

    x = t * c
    y = a * c
    
print(x+y)

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

int main(int argc, char const *argv[])
{
	int n, ans=0;
	string s;
	cin >> n >> s;

	for (int i = 0; i < s.size(); ++i)
	{
		if(s.at(i)=='x'&&i>0&&s.at(i-1)=='x') break;
		++ans;
	}
	cout << ans << endl;
	return 0;
}



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

int main() {
  ll n;
  cin >> n;
  vector<ll> p(n);
  ll mini = n+1;
  
  ll ans=0;
  rep(i, n){
    ll x;
    cin >> x;
    mini = min(mini,x);
    if(x == mini)
      ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4856
#include <stdio.h>
#include <math.h>

int main(){

  int D,G,i,j,P,C;
  scanf("%d" "%d", &D, &G);
  int p[D+1],c[D+1],psum[D+1];
  int N=pow(2,D);
  int A[N][D+1];
  int point[N],precost[N],cost[N];

  for(i=1;i<=D;i++){scanf("%d" "%d", &p[i],&c[i]);}
  
  for(i=1;i<=D;i++){psum[i]=100*i*p[i]+c[i];}

  int MAX=0;
  for(i=1;i<=D;i++){MAX=MAX+p[i];}
  
  for(j=0;j<N;j++){
    A[j][0]=j;point[j]=0;precost[j]=0;cost[j]=MAX;
    for(i=1;i<=D;i++){
      A[j][i]=A[j][0]%2;
      A[j][0]=(int)A[j][0]/2;
    }
  }

  for(j=0;j<N;j++){
    for(i=1;i<=D;i++){
      precost[j]=precost[j]+p[i]*A[j][i];
      point[j]=point[j]+psum[i]*A[j][i];
    }
  }

  for(j=0;j<N;j++){
    if(point[j]>=G){cost[j]=precost[j];}

    if(point[j]<G){
      for(i=1;i<=D;i++){
	P=point[j];C=precost[j];
	if(A[j][i]==0){
	  if(P+100*i*(p[i]-1)>=G){
	    while(P<G){P=P+100*i;C++;}
	    if(cost[j]>C){cost[j]=C;}
	  }
	}
      }
    }
  }

  int ANS=MAX;
  for(j=0;j<N;j++){
    if(ANS>cost[j]){ANS=cost[j];}
  }
  printf("%d",ANS);
  return 0;
}

  


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b;
    scanf("%d%d",&a,&b);
    if(a>=13){
        printf("%d\n",b);
    }else if(a>=6){
        printf("%d\n",b/2);
    }else{
        puts("0");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <string>
#include <sstream>
#include <cstring>
#include <cmath>

using namespace std;

#ifdef DEBUG
#define LOG(args) cout << args << "\n"
#define debug(x) x
#else
#define LOG(args)
#define debug(x)
#endif

#define vi vector<int>
#define ii pair<int, int>
#define vii vector< ii >
#define vvi vector< vi >
#define mp make_pair
#define pb push_back
#define ms(x, v) memset(x, v, sizeof(x))
#define all(x) x.begin(), x.end()
#define REP(x, n) for(int x = 0; x < n; x++)
#define REPV(x, v, n) for(int x = v; x < n; x++)
#define REVE(x, n) for(int x = n; x >= 0; x--)

typedef long long ll;

class SegmentTree
{
	int N;
	vi st;

	inline int left(int p) { return (p << 1); }
	inline int right(int p) { return (p << 1) + 1; }

	int query(int p, int L, int R, int i, int j)
	{
		if(i > R || j < L) return 0;
		else if(L >= i && R <= j) return st[p];
		int lft = query(left(p), L, (L + R) >> 1, i, j);
		int rgt = query(right(p), ((L + R) >> 1) + 1, R, i, j);
		return lft + rgt;
	}

	int update(int p, int L, int R, int idx, int val)
	{
		int i = idx, j = idx;
		if(i > R || j < L) return st[p];
		else if(L == i && R == j) return st[p] = val;
		int lft = update(left(p), L, (L + R) >> 1, idx, val);
		int rgt = update(right(p), ((L + R) >> 1) + 1, R, idx, val);
		return st[p] = lft + rgt;
	}

public:
	SegmentTree(int N) :N(N)
	{
		st.assign(4 * N, 0);
	}

	int query(int i, int j)
	{
		return query(1, 0, N - 1, i, j);
	}

	void update(int idx, int val)
	{
		update(1, 0, N - 1, idx, val);
	}
};

struct Query
{
	int l, r, idx;

	bool operator<(const Query &rhs) const
	{
		return r < rhs.r;
	}
};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	int N, Q;
	cin >> N >> Q;
	vi vals(N);
	for(auto &x : vals)
		cin >> x;
	vector<Query> queries(Q);
	REP(i, Q)
	{
		cin >> queries[i].l >> queries[i].r;
		queries[i].idx = i;
	}
	sort(all(queries));
	SegmentTree st(N);
	vi last(N + 5, -1), ans(Q);
	int qno = 0;
	REPV(i, 1, N + 1)
	{
		if(last[vals[i - 1]] != -1)
			st.update(last[vals[i - 1]] - 1, 0);
		st.update(i - 1, 1);
		last[vals[i - 1]] = i;
		while(queries[qno].r == i && qno < Q)
		{
			ans[queries[qno].idx] = st.query(queries[qno].l - 1, queries[qno].r - 1);
			qno++;
		}
		if(qno >= Q)
			break;
	}
	for(int v : ans)
		cout << v << "\n";
	return 0;
}













Measured memory_bytes: 23288
import java.util.*;
import java.io.*;
import java.text.*;
//Solution Credits: Taranpreet Singh
public class Main{
    //SOLUTION BEGIN
    void pre() throws Exception{}
    void solve(int TC) throws Exception{
        int n = ni(), k = ni();
        long[][] ways = new long[1+n][1+k];
        ways[0][0] = 1;
        for(int i = 1; i<= n; i++){
            int a = ni();
            int p = 0;
            long wa = 0;
            for(int j = 0; j<= k; j++){
                wa += ways[i-1][j];
                if(wa>=mod)wa-=mod;
                while(j-a>p){
                    wa += (mod-ways[i-1][p++]);
                    if(wa>=mod)wa-=mod;
                }
                ways[i][j] = wa;
            }
        }
        pn(ways[n][k]);
    }
    //SOLUTION END
    void hold()throws Exception{throw new Exception("Hold right there, Sparky!");}
    long mod = (long)1e9+7, IINF = (long)4e18;
    final int INF = (int)2e9, MX = (int)1e6+1;
    DecimalFormat df = new DecimalFormat("0.000000000000000");
    double PI = 3.1415926535897932384626433832792884197169399375105820974944, eps = 1e-8;
    static boolean multipleTC = false, memory = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        int T = (multipleTC)?ni():1;
        //Solution Credits: Taranpreet Singh
        pre();for(int i = 1; i<= T; i++)solve(i);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n(){return in.next();}
    String nln(){return in.nextLine();}
    int ni(){return Integer.parseInt(in.next());}
    long nl(){return Long.parseLong(in.next());}
    double nd(){return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next(){
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        String nextLine(){
            String str = "";
            try{   
                str = br.readLine();
            }catch (IOException e){
                e.printStackTrace();
            }  
            return str;
        }
    }
}    

Measured memory_bytes: 126164
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
const int sz = 500;
int id(int i, int j){
    return i * sz + j;
}
int dx[] = {-1, 0, 0, 1};
int dy[] = {0, -1, 1, 0};
int n;
bool ok(int i,int j){
    return 0<= i and i < n and 0 <= j and j < n;
}
int dist[sz * sz];
bool not_used[sz * sz];
void update(int x, int y){
    int temp = dist[id(x, y)] + not_used[id(x, y)];
    for(int i = 0; i < 4; i++){
        int xx = x + dx[i];
        int yy = y + dy[i];
        if(!ok(xx, yy))continue;
        if(dist[id(xx,yy)] > temp){
            dist[id(xx, yy)] = temp;
            update(xx, yy);
        }
    }
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            dist[id(i, j)] = min({i, j, n - 1- i, n - 1 - j});
            not_used[id(i, j)] = true;
        }
    }
    ll ans = 0;
    for(int tt = 0; tt < n * n; tt++){
        int p;
        cin >> p;
        p--;
        int x = p / n;
        int y = p % n;
        ll temp = dist[id(x, y)];
        ans += temp;
        not_used[id(x, y)] = false;
        update(x, y);
    }
    cout << ans << endl;
}


Measured memory_bytes: 23724
s = input()
if 'E' in s:
    if 'W' not in s:
        print('No')
        exit()
if 'E' not in s:
    if 'W' in s:
        print('No')
        exit()
if 'N' not in s:
    if 'S' in s:
        print('No')
        exit()
if 'N' in s:
    if 'S' not in s:
        print('No')
        exit()
print('Yes')

Measured memory_bytes: 9000
#include<bits/stdc++.h>
 
#define ll 			long long int 
#define pb          push_back
#define	endl		'\n'
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define dep(i,a,b)	for(int i=a;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;
 
#define N  105
 
 
ll dp[100005];
ll n,W;
 ll v[105],w[105];
	
 
 
void solve()
{
	
	cin>>n>>W;
	
	rep(i,0,n)
	{
		
		cin>>w[i];
		cin>>v[i];
	}

	
	//memset(dp,INT_MAX,sizeof(dp));
	rep(i,0,100005)
	dp[i]=INT_MAX;

	dp[0]=0;

	rep(i,0,n)
	{
		for(int j=100000;j>=0;j--)
		{
			if(j-v[i]>=0)
			{
				dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
			}
		}
	}
	/*rep(i,0,20)
	cout<<dp[i]<<" ";
	cout<<endl;*/
	for(int i=100000;i>=0;i--)
	{
		if(dp[i]<=W)
		{

			cout<<i;
			break;
		}
	}
	
 
}
	
	
 
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
	#ifndef ONLINE_JUDGE
    	// for getting input from input.txt
    	freopen("input.txt", "r", stdin);
    	// for writing output to output.txt
    	freopen("output.txt", "w", stdout);
	#endif
//cin>>TESTS;
	int p=1;
	while(TESTS--)
	{
		solve();
		p++;
	}
	return 0;
}

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

using lint = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int h, n;
    cin >> h >> n;
    vector<int> cost(n), mana(n);
    for (int i = 0; i < n; ++i) cin >> cost[i] >> mana[i];
    vector<int> dp(h+1, INT_MAX/2);
	dp[0] = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < h; ++j) {
			int cur = min(j + cost[i], h);
			dp[cur] = min(dp[cur], dp[j] + mana[i]);
		}
	}
	cout << dp[h] << '\n';
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;

int main() {
	map<char, int>mp;
	string w;
	bool ans = true;
	cin >> w;
	for (auto s : w) {
		mp[s]++;
	}
	for (auto itr : mp) {
		if (itr.second % 2 != 0)ans = false;
	}
	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*
created on 22/4/2020
*/
#include<bits/stdc++.h>
using namespace std;
#define Endl '\n'
typedef long long int lli;
void solve();
int main(int argc, char const *argv[]){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  solve();
}
vector<lli> adjList[100005];
int const w = 1;
int const b = 0;
lli dp[100005][2];
int const MOD = (1e9) + 7;
inline lli modmul(lli a, lli b){a%=MOD, b%=MOD; return (a*b)%MOD;}
inline lli modadd(lli a, lli b){a%=MOD, b%=MOD; return (a+b)%MOD;}
void dfs(lli v, lli p){
  dp[v][b] = 1;
  dp[v][w] = 1;
  for(lli u: adjList[v]){
    if(u==p)
      continue;
    dfs(u, v);
    dp[v][b] = modmul(dp[v][b], dp[u][w]);
    dp[v][w] = modmul(dp[v][w],modadd(dp[u][w], dp[u][b]));
  }
}
void solve(){
  lli N;
  cin>>N;
  for(int i=0;i<N-1;i++){
    int xi, yi;
    cin>>xi>>yi;
    adjList[xi].push_back(yi);
    adjList[yi].push_back(xi);
  }

  dfs(1, 0);
  cout<<modadd(dp[1][w], dp[1][b])<<Endl;
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i < (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
  string S; cin>>S;
  if(S=="ABC")cout<<"ARC"<<endl;
  else cout<<"ABC"<<endl;  
}


Measured memory_bytes: 3592
#include <iostream>
#include <sstream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>
#include <list>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
//#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))
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; }

using namespace std;

int main(void)
{
    string S; cin >> S;
    if (S == "ABC")cout << "ARC" << endl;
    else cout << "ABC" << endl;

    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=300005;
int n,m,Q,mo;
int x[N],y[N],v[N];
int fa[N],vis[2][1000005];
int get(int x){
	return x==fa[x]?x:fa[x]=get(fa[x]);
}
int gcd(int x,int y){
	return y?gcd(y,x%y):x;
}
void merge(int x,int y){
	fa[get(x)]=get(y);
}
bool check(int x,int y){
	return get(x)==get(y);
}
int main(){
	scanf("%d%d%d%d",&n,&m,&Q,&mo);
	int G=mo;
	For(i,1,m){
		scanf("%d%d%d",&x[i],&y[i],&v[i]);
		G=gcd(G,abs(v[i]-v[1]));
		--x[i]; --y[i];
	}
	mo=gcd(mo,3*G);
	int z=v[1]%G;
	For(i,0,6*n) fa[i]=i;
	For(i,1,m){
		v[i]=(v[i]-z)/G;
		For(j,0,1) For(k,0,2){
			merge(x[i]*6+j*3+k,y[i]*6+(1-j)*3+(2*k+v[i])%3);
			merge(y[i]*6+j*3+k,x[i]*6+(1-j)*3+(2*k+v[i])%3);
		}
	}
	int v=z;
	For(i,0,2*mo){
		vis[i&1][v]=1;
		v=2*v%mo;
	}
	while (Q--){
		int x,y,v,ans=0;
		scanf("%d%d%d",&x,&y,&v);
		--x; --y;
		For(j,0,1) For(k,0,2)
			if (check(y*6,x*6+j*3+k)&&vis[j][(v+z+(3-k)*G)%mo])
				ans=1;
		puts(ans?"YES":"NO");
	}
}

Measured memory_bytes: 12672
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	arr1, arr2 := make([][]int, n), make([][]int, n)
	for i := 0; i < n; i++ {
		arr1[i] = make([]int, 10)
		for j := 0; j < 10; j++ {
			var tmp int
			fmt.Scan(&tmp)
			arr1[i][j] = tmp
		}
	}
	for i := 0; i < n; i++ {
		arr2[i] = make([]int, 11)
		for j := 0; j < 11; j++ {
			var tmp int
			fmt.Scan(&tmp)
			arr2[i][j] = tmp
		}
	}
	mx := math.MinInt32
	for i := 1; i < 1 << uint(10); i++ {
		arr3 := make([]int, n)
		for j := 0; j < 10; j++ {
			if 1 & (uint(i) >> uint(j)) == 1 {
				for k := 0; k < n; k++ {
					arr3[k] += arr1[k][j]
				}
			}
		}
		sum := 0
		for j := 0; j < n; j++ {
			sum += arr2[j][arr3[j]]
		}
		if mx < sum {
			mx = sum
		}
	}
	fmt.Println(mx)
}

Measured memory_bytes: 1664
#include <stdio.h>
#include <algorithm>
#include <iostream>

using namespace std;

class Heap{
public:
	Heap(){
		array = new int[2000000];
		n = 0;
	}
	void insert(int data){
		array[n] = data;
		int tmp = n;
		while(tmp != 0 && array[tmp] > array[(tmp-1)/2]){
			std::swap(array[tmp], array[(tmp-1)/2]);
			tmp = (tmp-1)/2;
		}
		n++;
	}
	int extract(){
		int ret = array[0];
		n--;
		std::swap(array[0],array[n]);
		int tmp = 0;
		while(2*tmp+1 <= n-1){
			if(2*tmp+2 <= n-1){
				if(array[2*tmp+2] > array[tmp] && array[2*tmp+2] >= array[2*tmp+1]){
					std::swap(array[2*tmp+2],array[tmp]);
					tmp = 2*tmp+2;
				}else if(array[2*tmp+1] > array[tmp] && array[2*tmp+1] >= array[2*tmp+2]){
					std::swap(array[2*tmp+1],array[tmp]);
					tmp = 2*tmp+1;
				}else{
					break;
				}
			}else{
				if(array[tmp] < array[2*tmp+1]){
					std::swap(array[tmp],array[2*tmp+1]);
					tmp = 2*tmp+1;
				}else{
					break;
				}
			}
		}
		return ret;
	}

private:
	int* array;
	int n;
};

int main(){

	int insert_data;
	char buf[22];
	Heap heap;

	while(true){
		fgets(buf,22,stdin);
		if(buf[2] == 'd') break;
		if(buf[0] == 'i'){
			insert_data = 0;
			for(int i = 0; buf[i] != '\0';i++){
				if(buf[i] >= '0' && buf[i] <= '9'){
					insert_data = 10*insert_data + (buf[i] - '0');
				}
			}
			heap.insert(insert_data);
		}else{
			printf("%d\n",heap.extract());
		}
	}
}

Measured memory_bytes: 6920
getter = -> {
   require 'stringio'
  _in = StringIO.new
  while l = gets
    _in<< l
  end
  _in.string
}
s = getter.call.split(/\R/)
x,n = s[0].split(' ').map(&:to_i)
if n == 0
    _p = []
else
    *_p = s[1].split(' ').map(&:to_i)
end

def jdg(x, _p)
    return x if !_p.include?(x)
    right_check = ->{
        c = x + 1
        while _p.include?(c)
            c += 1
        end 
        [c - x , c]
    }.call

    left_check = ->{
        c = x - 1
        while _p.include?(c)
            c -= 1
        end
        [x - c, c]
    }.call
    
    return left_check[1] if (left_check[0] <= right_check[0])
    right_check[1]
end

puts jdg(x, _p)

Measured memory_bytes: 14364
#include<stdio.h>
int main(void)
{
	int i,n,a,b,c,d,e,goukei,max,min;
	scanf("%d",&n);
	while(n!=0) {
		max=0;
		min=10000;
		for(i=1;i<=n;i++) {
			scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
			goukei=a+b+c+d+e;
			if(goukei>max) {
				max=goukei;
			}
			if(goukei<min) {
				min=goukei;
			}
		}
		printf("%d %d\n",max,min);
	scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 600
#include <cassert>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
typedef int TInt;
typedef std::vector<TInt> TList;
TList Input()
{
    int Count;
    std::cin >> Count;
    TList List(Count);
    for(int i = 0; i < Count; ++i){
        std::cin >> List[i];
    }
    return List;
}
int main()
{
    TList A = Input();
    assert(A.size() >= 2);
    int Profit = A[1] - A[0];
    int i = 0;
    while(i < A.size()){
        int j;
        for(j = i + 1; j < A.size(); ++j){
            int Diff = A[j] - A[i];
            if(Diff < 0){
                i = j;
                break;
            }
            if(Diff > Profit) Profit = Diff;
        }
        if(j == A.size()) break;
    }
    
    
    std::cout << Profit << std::endl;
    return 0;
}

Measured memory_bytes: 1796
#include <bits/stdc++.h>
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Weverything"
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/irange.hpp>
#pragma clang diagnostic pop

using namespace std;

struct answer_t {
  answer_t(int64_t x_, int64_t y_, int64_t h_) : x(x_), y(y_), h(h_) {}
  int64_t x;
  int64_t y;
  int64_t h;
};

answer_t solve(int64_t n, std::vector<int64_t> xs, std::vector<int64_t> ys,
               std::vector<int64_t> hs) {
  for (int x = 0; x <= 100; ++x) {
    for (int y = 0; y <= 100; ++y) {
      int64_t h = -1;
      int64_t hMax = INT64_MAX;
      int i;
      for (i = 0; i < n && h <= hMax; ++i) {
        int64_t const hh = hs[i] + abs(x - xs[i]) + abs(y - ys[i]);
        if (hs[i] == 0 && hh > 0) {
          hMax = std::min(hh, hMax);
          continue;
        }

        if (h < 0) {
          h = hh;
          continue;
        }

        if (hh != h) {
          break;
        }
      }
      if (i >= n && h <= hMax) {
        return answer_t(x, y, h);
      }
    }
  }
  assert(false);
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t n;
  std::cin >> n;
  std::vector<int64_t> xs(n);
  std::vector<int64_t> ys(n);
  std::vector<int64_t> hs(n);
  for (int i = 0; i < n; i++) {
    std::cin >> xs[i];
    std::cin >> ys[i];
    std::cin >> hs[i];
  }
  auto const res = solve(n, std::move(xs), std::move(ys), std::move(hs));
  std::cout << res.x << " " << res.y << " " << res.h << std::endl;
  return 0;
}


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

int main(){
  string s;
  cin >> s;
  int count = 0;
  int start = 0;
  int a[3];
  for(int i=0;i < s.size();i++){
    if(s[i] == '/'){
        a[count] = atoi((s.substr(start+1,i-start)).c_str());
        start = i;
        count++;
    } 
  }
  //cout << a[1];
  if(a[1] <5) cout << "Heisei";
  else cout << "TBD";
  return 0;
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define MOD 1000000007
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef map<int, int> mint;
typedef vector<int> vint;
typedef vector<char> vch;
typedef vector<long long> vll;
typedef vector<string> vstr;


int mod(int a, int b){return (a%b+b)%b;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b){ll ans=1; rep(i, b){ans=ans*a%MOD;} return ans;}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};




template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}


vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll x, y;
    cin >> x >> y;

    ll cnt = 0;


    while(1){
        dpp(x);
        if(x > y) break;
        x *= 2;
        ++cnt;
    }

    ppp(cnt);

    return 0;
}


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

int main() {
	int n;
	int a[1 << 18];
	cin >> n;
	for (int i = 0; i < 1 << n; i++) {
		cin >> a[i];
	}
	for (int m = 1; m < 1 << n; m *= 2) {
		for (int i = 0; i < 1 << n; i += m + m) {
			if (a[i] != a[i + m]) {
				a[i] = abs(a[i] - a[i + m]);
			}
		}
	}
	cout << a[0] << endl;
	return 0;
}


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

#define _GLIBCXX_DEBUG

int main(){
    int N;
    vector<int> As(200010);

    cin >> N;
    As.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> As[i];
    }

    vector<int> Cs(N);
    copy(As.begin(), As.end(), Cs.begin());
    sort(Cs.begin(), Cs.end());

    for (int A: As) {
        if (A == Cs[N-1]) {
            cout << Cs[N-2] << '\n';
        } else {
            cout << Cs[N-1] << '\n';
        }
    }
    
    return 0;
}

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

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

    if(n != 100){
        cout << n;
        if(d == 1){
            cout << "00";
        }
        else if(d == 2){
            cout << "0000";
        }
    }
    else{
        if(d == 1){
            cout << "10100";
        }
        else if(d == 2){
            cout << "1010000";
        }
        else{
            cout << "101";
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#define int long 
using namespace std;

signed main() {
	int N;
	cin >> N;
	vector<int> vec(N);
	for(int i = 0;i < N;i++) {
		cin >> vec.at(i);
	}
	vector<int> cnt(N);
	for(int i = N - 1;i >= 0;i--) {
		if(i >= N / 2) {
			cnt.at(i) = vec.at(i);
		}
		else {
			int count = 0;
			for(int j = i * 2 + 1;j < N;j += i + 1) {
				count += cnt.at(j);
			}
			if(count % 2 == vec.at(i)) {
				cnt.at(i) = 0;
			}
			else {
				cnt.at(i) = 1;
			}
		}
	}
	int M = 0;
	for(int i = 0;i < N;i++) {
		if(cnt.at(i) == 1) {
			M++;
		} 
	}
	cout << M << endl;
	for(int i = 0;i < N;i++) {
		if(cnt.at(i) == 1) {
			cout << i + 1 << " ";
		}
	}
	cout << endl;
}


Measured memory_bytes: 3968
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).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 INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<pii,int> ppiii ;
typedef unsigned long long ull ;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
int main(){
	string str;
	cin>>str;
	char x=str[0];
	int ans=0;
	for(int i=1;i<str.size();i++){
		if(str[i]!=x){
			ans++;
			x=str[i];
		}
	}
	cout<<ans<<endl;
}

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

int main()
{
	string s;
	cin >> s;

	bool yes = true;
	for (int i = 1; i < s.size(); i += 2) {
		if (s[i] == 'i' && s[i - 1] == 'h') {
			continue;
		}
		yes = false;
	}

	if ((s.size() % 2) == 1) {
		yes = false;
	}

	if (yes) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <climits>
#include <list>
#include <cmath>
#include <algorithm>
using namespace std;

typedef long long int ll;
#define mod 1000000007

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

Measured memory_bytes: 3672
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1000000007;
constexpr int  mod = mo;
constexpr ll inf = 1ll<<62;
int main(){
    string s;
    cin>>s;
    int n = (int)s.size();
    vector<int> ans(n);
    for(int i=0;i<n;++i){
        int r,l;
        r= i;
        while(r<n-1 and s[r+1] == 'R')r++;
        l = r+1;
        while(l < n-1 and s[l+1] == 'L')l++;
        int rnum = r - i+1;
        int lnum = l - (r+1) + 1;
        for(int num =0;num < rnum;++num){
            if(num%2)ans[r+1]++;
            else ans[r]++;
        }
        for(int num =0;num < lnum;++num){
            if(num%2)ans[r]++;
            else ans[r+1]++;
        }
        i = l;
    }
    for(int i=0;i<n;++i){
        if(i)cout << " ";
        cout << ans[i];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
typedef long double ld;
typedef unsigned long long ull;
#define X first
#define Y second
template<class T> using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<class T, class X> using indexed_map = tree<T, X, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int M = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int modpow(int n, int k, int MOD);
 
/**************** code starts here ****************/
 
int n, m;
vector<int> adj[100005];
vector<int> indeg(100005);
vector<int> vis(100005);
vector<int> topo;

vector<int> dist(100005);
vector<int> par(100005);

void dfs(int now) {
	vis[now] = 1;
	for (int i: adj[now]) {
		if (!vis[i]) dfs(i);
	}
	topo.push_back(now);
}

void poppingfever() {
	cin >> n >> m;
	for (int i = 0; i < m+n-1; i++) {
		int x, y; cin >> x >> y;
		adj[x].push_back(y);
		indeg[y]++;
	}
 
	for (int i = 1; i <= n; i++) {
		if (indeg[i] == 0) {
			dfs(i);
			break;
		}
	}

	for (int i: topo) {
		for (int u: adj[i]) {
			if (dist[u] < dist[i]+1) {
				dist[u] = dist[i] + 1;
				par[u] = i;
			}
		}
	}

	for (int i = 1; i <= n; i++) {
		cout << par[i] << '\n';
	}
} 
 
/**************************************************/
 
signed main() {
	#ifdef fastfurioustransform
	freopen("inp.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	#endif
 
	ios::sync_with_stdio(0); cin.tie(0);
	//cout << fixed << setprecision(12);
 
	int t = 1;
	while(t--) {
		poppingfever();
	}
 
	return 0;
}
 
int modpow(int n, int k, int MOD) {
	int ans = 1; n %= MOD;
	while (k > 0) {
		if (k & 1) ans = (ans*n) % MOD;
		k >>= 1; n = (n*n) % MOD;
	}
	return ans;
}

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

using namespace std;

int main()
{
        int n, t;
        cin >> n >> t;
        int ans = 1e9 + 7;
        for (int i = 0; i < n; i++) {
                int a, b;
                cin >> a >> b;
                if (b <= t)
                        ans = min(ans, a);
        }
        if (ans == (int) 1e9 + 7)
                cout << "TLE" << endl;
        else
                cout << ans << endl;
        return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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

const int32 DIRECTED = 0;
const int32 UNDIRECTED = 1;

template<int32 isUNDIRECTED=0>
class Graph{
	struct Edge{
		int32 u, v, id;
		int64 c;
		Edge(int32 u, int32 v, int64 c=0, int32 id=0):u(u), v(v), c(c), id(id){}
	};

	int32 V, E;
	vector<vector<Edge>> G;
	vector<Edge> Es;
public:
	Graph(){}
	Graph(int32 V):V(V){G.resize(V);}
	Graph(const Graph<isUNDIRECTED>& g):V(g.V), E(g.E), G(g.G), Es(g.Es){}

	void add_edge(int32 u, int32 v, int64 c=0, int32 id=0){
		G[u].emplace_back(u, v, c, id);
		if(isUNDIRECTED) G[v].emplace_back(v, u, c, id);
		Es.emplace_back(u, v, c, id);
		E++;
	}

	const vector<Edge>& operator[](int32 k){
		return G[k];
	}
};

class SCC{
private:
	Graph<DIRECTED> orgG, revG, newG;
	vector<int32> ord, comp;
	vector<bool> used;
	vector<vector<int32>> vs;

	int32 V, nV;
public:
	SCC(){}
	SCC(int32 V):orgG(V), revG(V), comp(V, -1), used(V, 0), V(V){}

	void add_edge(int32 u, int32 v){
		orgG.add_edge(u, v);
		revG.add_edge(v, u);
	}

	void dfs(int32 v){
		used[v] = true;
		for(auto e : orgG[v]){
			if(!used[e.v]) dfs(e.v);
		}
		ord.push_back(v);
	}

	void rdfs(int32 v, int32 k){
		used[v] = true;
		comp[v] = k;
		for(auto e : revG[v]){
			if(!used[e.v]) rdfs(e.v, k);
		}
	}

	int32 build(){
		for(int32 i = 0;i < V;i++){
			if(!used[i]) dfs(i);
		}
		fill(used.begin(), used.end(), 0);
		int32 k = 0;
		for(int32 i = ord.size()-1;i >= 0;i--){
			if(!used[ord[i]]) rdfs(ord[i], k++);
		}
		nV = k;

		vs.resize(k, vector<int32>());
		for(int32 i = 0;i < V;i++)
			vs[comp[i]].push_back(i);

		newG = Graph<DIRECTED>(k);
		for(int32 i = 0;i < V;i++){
			for(auto e : orgG[i]){
				if(comp[i] != comp[e.v])
					newG.add_edge(comp[i], comp[e.v], e.c);
			}
		}
		return k;
	}

	int32 size(){
		return nV;
	}

	const Graph<DIRECTED>& graph(){
		return newG;
	}

	const vector<int32>& vertices(int32 v){
		return vs[v];
	}

	int32 operator[](int32 k){
		return comp[k];
	}
};

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int32 V, E;
	cin >> V >> E;
	SCC scc(V);
	REP(i, E){
		int32 u, v;
		cin >> u >> v;
		scc.add_edge(u, v);
	}
	scc.build();
	int32 Q;
	cin >> Q;
	REP(i, Q){
		int32 u, v;
		cin >> u >> v;
		cout << (scc[u] == scc[v]) << endl;
	}
}



Measured memory_bytes: 6852
#include <iostream>
using namespace std;
int main(void){
    int N, A[101];
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i];
    }
    
    int i = 0, minj, tmp, c = 0;
    for(int i = 0; i < N; i++){
        minj = i;
        for(int j = i; j < N; j++){
            if(A[j] < A[minj]) minj = j;
        }
        if(A[minj] == A[i]) continue;
        tmp = A[i];
        A[i] = A[minj];
        A[minj] = tmp; 
        c++;
    }
    for(int k = 0; k < N; k++){
        cout << A[k];
        if(k == N - 1) cout << endl;
        else cout << " ";
    }
    cout << c << endl;
}



Measured memory_bytes: 3100
main(require('fs').readFileSync('/dev/stdin', 'utf8').replace(/\r?\n$/, "").split(/\r?\n/));

function main(lines){
	lines.map(function(s){return s.split(" ").map(Number)}).every(function(a){
		h = a[0]; w = a[1];
		if(h+w == 0) return false;
		for(var y=0;y<h;y++){
			var str = "";
			for(var x=0;x<w;x++){
				str += (x+y)%2==0 ? "#" : ".";
			}
			console.log(str);
		}
		console.log();
		return true;
	});
}

Measured memory_bytes: 17756
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,t;
    cin >> n >> t;
    int a[n];
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }
    int button = 0;
    for (int i = 1; i < n; i++){
        if (a[i] - a[i-1] <= t) button += a[i] - a[i-1];
        else button += t;
    }
    cout << button + t << '\n';
}


Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
using namespace std;


int main(){
long  N;
cin >>N;
long a[N];
for (long i =1 ; i<N+1;i++){
cin >>a[i];
}
long res;
long count[(long)pow(10,5)+2]={0};
for (long i=1; i<N+1;i++){
count[a[i]-1]++;
count[a[i]]++;
count[a[i]+1]++;
}
long temp=0;
for(long X =0; X<pow(10,5)+2;X++){
if(temp<count[X]){
temp=count[X];
res=X;}
}
cout<<temp;
return 0;
}



Measured memory_bytes: 1792