akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repn(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define sz(v) (ll)v.size()
#define vi vector<ll>
#define pi pair<ll,ll>
#define vpi vector<pair<ll,ll>>
using namespace std;

ll MOD=1e9+7;
ll g,h,l;
const ll N=100005, inf=1e9+5;

ll add(ll a,ll b); ll mul(ll a,ll b); ll binpo(ll a,ll b);

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll n;cin>>n;
    ll n2 = n-1;
    ll cnt=0;
    for(ll i = 2; i*i<=n2; i++){
        if(n2%i==0){
            // cout<<i<<" "<<n2/i<<endl;
            cnt+=2;
        }
        if(i*i==n2){
            cnt--;
        }
    }
    cnt+=2;
    if(n==2)cnt--;
    for(ll i=2;i*i<=n;i++){
        ll temp = n;
        if(i*i==n){
            cnt++;
            continue;
        }
        if(n%i==0){
            while(temp%i==0){
                temp/=i;
            }
            if(temp%i==1){
                cnt++;
                // cout<<i<<endl;
            }
        }
        temp =n ;
        ll i2 = temp/i;
        if(n%i2==0){
            while(temp%i2==0){
                temp/=i2;
            }
            if(temp%i2==1){
                cnt++;
                // cout<<i2<<endl;
            }
        }
    }
    cout<<cnt;
}

ll add(ll a,ll b)
{
    return (a%MOD+b%MOD)%MOD ;
}
ll mul(ll a,ll b)
{
    return (a* 1ll *b)%MOD ;
}
ll binpo(ll a,ll b)
{
    int ans = 1 ;
    while(b)
    {
        if( b % 2 != 0)
        {
            ans = mul(ans,a);
        }
        a = mul(a,a);
        b = b/2;
    }
    return ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,a[10001],sum=0;//sum累加前k大的数
    cin>>n>>k;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n-1;i++)
        for(int j=i+1;j<=n;j++)
        {
            if(a[i]<a[j]) swap(a[i],a[j]);//如果a[i]比a[j]小，交换
        }
    for(int i=1;i<=k;i++) sum+=a[i];//累加
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string.h>
using namespace std;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define Max(x,y,z) max(x,max(y,z))
#define Min(x,y,z) min(x,min(y,z))
#define fr(i,s,e) for(i=s;i<e;i++)
#define rf(i,s,e) for(i=s-1;i>=e;i--)
#define pb push_back
#define eb emblace_back
#define mp make_pair
#define ff first
#define ss second
//#define int   long long
#define ll   long long
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define vl vector<long long>
#define inf (1LL<<61)
#define vi vector<int>
#define vii vector< vector<int> >
#define vll vector< vector<long long> >
#define vpi vector< pair<int,int> >
#define vpl vector< pair<ll,ll> >
#define viii vector< vector<vector<int> > >
typedef pair<pair<int, int>,int> P;
#define cd complex<double>
#define PI 4*atan(1)
#define mod %1000000007
#define pi 3.14159265358979323846//20 decimals
#define ld long double

int main()
{
	FAST;
	string s;
	ll i;
	cin >> s;
	fr(i,1,4)
	{
		if(s[i] == s[i-1])
		{
			cout << "Bad";
			return 0;
		}
	}
	cout << "Good";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long s,x[10];
    cin>>s;
    for(int i=0;i<10;i++)
    {
        x[i]=s%10;
        s=s/10;
    }
    int y,min=10000;
    for(int i=0;i<8;i++)
    {
        y=x[i]+10*x[i+1]+100*x[i+2];
        if(abs(753-y)<min)
        {
            min=abs(753-y);
        }
    }
    cout<<min<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    string s;
    cin >> s;
    bool cflag = false;
    bool fflag = false;
    bool cf = false;

    for(int i = 0;i < s.size();i++){
        if(s.at(i) == 'C')
            cflag = true;
        else if(s.at(i) == 'F' and cflag){
            fflag = true;
        }
    }

    if(cflag and fflag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;


    

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// Useful constants
#define INF  (int)1e9
#define EPS   1e-9
#define MOD 1000000007ll
#define PI 3.14159
// for input-output
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
// iteration macros: have advantage of auto-casting and not recomputing arguments
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
// input macro
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}
//output macro
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
// shortcut for data type
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define mp make_pair
#define F first
#define S second
#define uset unordered_set
#define umap unordered_map

//--namespace
using namespace std;
//--useful function
ll gcd(ll a, ll b){ll temp;while (b > 0){temp = a%b;a = b;b = temp;} return a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
ll fpow(ll  b, ll exp, ll mod){if(exp == 0) return 1;ll t = fpow(b,exp/2,mod);if(exp&1) return t*t%mod*b%mod;return t*t%mod;}
ll divmod(ll i, ll j, ll mod){i%=mod,j%=mod;return i*fpow(j,mod-2,mod)%mod;}
// --clock funtion
clock_t time_p=clock();
void TimeTaken()
{
    time_p=clock()-time_p;
    cerr<<"Completion time : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
// --solve function
void solve() {

}
typedef unsigned long long int ull;
//--main function
int main(){
	ull x,y,c=0;
	cin>>x>>y;
	while(x<=y){
		x=x*2;
		c++;
	}
	cout<<c;
	return 0;

//   TimeTaken();
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<limits.h>

int main(void){
    int N;
    scanf("%d", &N);
    int i;
    int max = INT_MIN;
    int min = INT_MAX;
    int temp;
    for(i=0; i<N; i++) {
        scanf("%d", &temp);
        if(temp > max) {
            max = temp;
        }
        if(temp < min) {
            min = temp;
        }
    }
    printf("%d\n", max - min);
    return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
using ll = long long;
using uint = unsigned;
using ull = unsigned long long;
using P = pair<int,int>;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

ll dp[110][100100];

int main() {
    int N; cin >> N;
    ll W; cin >> W;
    vector<ll> w(N);
    vector<int> v(N);
    rep(i,N) cin >> w[i] >> v[i];
    int vmx = 0;
    rep(i,N) vmx += v[i];
    rep(i,110)rep(j,100100) dp[i][j] = LINF;
    dp[0][0] = 0;
    rep(i,N) {
        rep(j,vmx+1) {
            dp[i+1][j] = min(dp[i][j],dp[i+1][j]);
            if (j-v[i]>=0) dp[i+1][j] = min(dp[i+1][j],dp[i][j-v[i]]+w[i]);
        }
    }
    ll ans = 0;
    rep(i,vmx+1) if (dp[N][i]<=W) ans = i;
    cout << ans << endl;
    return 0;
}







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

 int main()
     {
    string s;
    cin>>s;
    for(int i=0;i<19;i++)
    {
        if(s[i]==',')
            {cout<<" ";
            continue;}
        cout<<s[i];
    }
   return 0;
     }


Measured memory_bytes: 3612
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		int X=x;
		for(int i=0;i<2;i++){
			X*=x;
		}
		System.out.println(X);
	}

}

Measured memory_bytes: 25956
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
#include <ctime>
#include <numeric>
#include <cstdint>

using llint = long long int;

template<typename T>
void dump(const T& arr){
  std::cout << "[";
  for(const auto& elem: arr){
    std::cout << elem << ", ";
  }
  std::cout << "]" << std::endl;
}

void solve(void){
  int n;
  std::cin >> n;

  llint cnt = 0;
  for(int a=1; a<n; a++){
    for(int b=1; a*b<n; b++){
      cnt++;
    }
  }
  std::cout << cnt << std::endl;
  return;

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





Measured memory_bytes: 3648
N = gets.chomp.to_i
result =
  if N <= 9
    N
  elsif N <= 99
    9
  elsif N <= 999
    9 + (N - 99)
  elsif N <= 9999
    9 + 900
  elsif N <= 99999
    9 + 900 + (N - 9999)
  else
    9 + 900 + 90000
  end

puts "#{result}\n"

Measured memory_bytes: 1788
a_,b_,m=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=min(a)+min(b)
for i in range(m):
    x,y,c=map(int,input().split())
    t=a[x-1]+b[y-1]-c
    if t<ans:
        ans=t
print(ans)

Measured memory_bytes: 18612
import sys
input = sys.stdin.readline
def main():
    h,W = map(int,input().split())
    c = [tuple(input()) for _ in range(h)]
    c = tuple(c)
    ans = 0
    w = [0 for _ in range((h+1)**2)]
    dp = [0 for _ in range((h+1)**2)]
    for j in range(W-1):
        for x in range(h,0,-1):
            for y in range(h,0,-1):
                w[(x-1)*(h+1)+y-1] = w[x*(h+1)+y]
                if c[h-x][j] == c[h-y][j+1]:
                    w[(x-1)*(h+1)+y-1] += 1
        for x in range(h+1):
            for y in range(h+1):
                if x == 0 or y == 0:
                    if x == y:
                        dp[x*h+y] = 0
                    elif x == 0:
                        dp[x*(h+1)+y] = dp[x*(h+1)+y-1]+w[x*(h+1)+y-1]
                    else:
                        dp[x*(h+1)+y] = dp[(x-1)*(h+1)+y]+w[(x-1)*(h+1)+y]
                    continue
                dp[x*(h+1)+y] = min(dp[x*(h+1)+y-1]+w[x*(h+1)+y-1],dp[(x-1)*(h+1)+y]+w[(x-1)*(h+1)+y])
        ans += dp[-1]
    print(ans)
    
if __name__ == "__main__":
    main()

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

int main(){
  double R;
  cin>>R;
  double ans;
  ans=2*3.1415*R;
 cout<<setprecision(6)<<ans<<endl;
}


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

int main(){
   string S;
   cin >> S;
   //
   for(int i=0;i<4;i++) S[i] = S[i]-'0';
   if(1<= S[0]*10+S[1] && S[0]*10+S[1]<=12  && 1<= S[2]*10+S[3] && S[2]*10+S[3]<=12) cout << "AMBIGUOUS" << endl;
   else if(1<= S[0]*10+S[1] && S[0]*10+S[1]<=12) cout << "MMYY" << endl;
   else if(1<= S[2]*10+S[3] && S[2]*10+S[3]<=12) cout << "YYMM" << endl;
   else cout << "NA" << endl;

}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cout << fixed << setprecision(15);
#ifndef ONLINE_JUDGE
    freopen("../input.txt", "r", stdin);
    freopen("../output.txt", "w", stdout);
#endif
    ll n;
    cin>>n;
    ll ans=0;
    for(ll i=2;i*i<=n;i++){
        ll num=0;
        if(n%i==0){
            num=0;
            while(n%i==0){
                n/=i;
                num++;
            }
        }
        for(ll j=1;;j++){
            if(num<j){
                break;
            }

            else{
                num-=j;
                ans++;
            }
        }
    }
    if(n!=1){
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

vector<int> x1 = {0,3,6,0,1,2,0,2};
vector<int> x2 = {1,4,7,3,4,5,4,4};
vector<int> x3 = {2,5,8,6,5,8,8,6};

int main(){
  vector<int> A(9);
  vector<bool> B(9,false);
  int N;

  for(int i=0; i<9; i++) cin >> A[i];
  
  cin >> N;
  for(int i=0; i<N; i++){
    int b; cin >> b;
    for(int j=0; j<9; j++){
      if(A[j] == b) B[j] = true;
    }
  }


  for(int i=0; i<8; i++){
    if(B[x1[i]] && B[x2[i]] && B[x3[i]]){
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

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

int main() {
	int m, d, M, D; scanf("%d%d%d%d", &m, &d, &M, &D);

	printf("%d\n", !(m == M));
	return 0;
}


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

struct Node {
  int key;
  Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while ( x != NIL ) {
    y = x;
    if ( z ->key < x->key ) {
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if ( y == NIL ) {
    root = z;
  } else {
    if ( z->key < y->key ) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node *u) {
  if ( u == NIL ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node *u) {
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main() {
  int n, i, x;
  string com;

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    cin >> com;
    if ( com == "insert" ) {
      scanf("%d", &x);
      insert(x);
    } else if ( com == "print" ) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 26692
#include <iostream>
#include <string>
using namespace std;
int main(){

  int n,tmp=0;
  string s;
  cin>>n>>s;
  for(int i=0;i<n;i++){
    if(s[i]=='o') tmp=0;
    else tmp++;
    if(tmp==2){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<n<<endl;
  return 0;

}

Measured memory_bytes: 3340
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i,j,n) for(int i=j;i<=n;i++)
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k,a;
    cin>>a;
     k=a/2;
    cout<<k*(a-k);
    
    
} 

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>

using namespace std;

struct node{
	int key;
	node *right,*left,*parent;
};

node *root,*nil,*z;

void preorder(node *id){
	if(id == nil)return;
	cout << " " << id->key;
	preorder(id->left);
	preorder(id->right);
}

void inorder(node *id){
	if(id == nil)return;
	inorder(id->left);
	cout << " " << id->key;
	inorder(id->right);
}

void print(){
	inorder(root);
	cout << endl;
	preorder(root);
	cout << endl;
}

void insert(int k){
	node *p = nil;
	node *r = root;
	node *z = (node *)malloc(sizeof(node));
	z->key = k;
	z->left = nil;
	z->right = nil;
	while(r != nil){
		p = r;
		if(z->key < r->key){
			r = r->left;
		}else{
			r = r->right;
		}
	}
	z->parent = p;
	if(p == nil){
		root = z;
	}else if(z->key < p->key){
		p->left = z;
	}else{
		p->right = z;
	}
}

node* find(int k,node *i){
	while(i != nil && i->key != k){
		if(i->key > k){
			i = i->left;
		}else{
			i = i->right;
		}
	}
	return i;
}

int main(void){
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		string order;
		int key;
		cin >> order;
		if(order == "print"){
			print();
		}else if(order == "insert"){
			cin >> key;
			insert(key);
		}else if(order == "find"){
			cin >> key;
			node* res = find(key,root);
			if(res != nil)cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}
}


Measured memory_bytes: 21988
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<climits>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

template <typename Monoid >
struct SegmentTree{
  using F = function< Monoid(Monoid,Monoid) >;

  int sz;
  vector<Monoid> seg;

  const F f;
  const Monoid M;

  SegmentTree(int n,const F f,const Monoid &M) : f(f),M(M){
    sz = 1;
    while(sz<n) sz<<=1;
    seg.assign(sz*2,M);
  }
  void set(int k,const Monoid &v){
    seg[k+sz] = v;
  }
  void build(){
    for(int k=sz-1;k>0;k--){
      seg[k] = f(seg[2*k],seg[2*k+1]);
    }
  }
  void update(int k,const Monoid &v){
    k += sz;
    seg[k] = v;
    while(k >>= 1){
      seg[k] = f(seg[2*k],seg[2*k+1]);
    }
  }
  Monoid que(int a,int b){
    Monoid L=M,R=M;
    for(a+=sz, b+=sz;a<b;a>>=1,b>>=1){
      if(a&1) L = f(L,seg[a++]);
      if(b&1) R = f(seg[--b],R);
    }
    return f(L,R);
  }
  Monoid operator[](const int &k) const{
    return seg[k+sz];
  }
};
signed main(){
  int n,q,t,x,y;
  cin >> n >> q;
  SegmentTree<int> seg(n,[](int a,int b){return min(a,b);},INT_MAX);
  for(int i=0;i<q;i++){
    cin >> t >> x >> y;
    if(t==0) seg.update(x,y);
    else cout <<seg.que(x,y+1)<<endl;
  }
}



Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  ll x,y;
  cin >> x >> y;
  ll ans = 0;
  while(x <= y) { ans++; x*=2; }
  COUT(ans);
  return 0;
}


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

int main()
{
	int n,w;
	cin>>n>>w;//n個数w重量制限
	long long  item[2][101];
	for(int i=0;i<n;i++){
		cin>>item[0][i+1]>>item[1][i+1];
	}
	long long dp[101][100001]={};//i番目まで重量j以下100001
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=w;j++)
		{
			dp[i][j]=max(dp[i-1][j],max((j>=1?dp[i][j-1]:0),j-item[0][i]>=0?dp[i-1][j-item[0][i]]+item[1][i]:0));
		}
	}
	cout<<dp[n][w]<<endl;
	return 0;
}

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

#define INF int(1e9+5)
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=6005;
int n,cnta,cntb;
char s[maxn];
string val[maxn];
int mat[maxn],a[maxn],b[maxn],nxt[maxn];

int main(){
	scanf("%d%s",&n,s);
	rep(i,2*n){
		if(s[i]=='a')a[cnta++]=i;
		else b[cntb++]=i;
	}
	rep(i,n)mat[a[i]]=b[i],mat[b[i]]=a[i];
	nxt[2*n]=2*n;
	for(int i=2*n-1;i>=0;i--){
		nxt[i]=nxt[i+1];
		if(i<mat[i]){
			int cur=i;
			while(cur<2*n){
				if(s[cur]=='a')val[i]+="ab",cur=nxt[mat[cur]+1];
				else{
					int cur2=cur+1,cnt=1;
					val[i]+="b";
					while(cnt){
						if(s[cur2]=='b'&&cur2<mat[cur2])val[i]+="b",cnt++;
						else if(s[cur2]=='a'&&mat[cur2]<cur2&&mat[cur2]>=cur)val[i]+="a",cnt--;
						cur2++;
					}
					cur=nxt[cur2];
				}
			}
			if(val[i]>val[nxt[i]])nxt[i]=i;
		}
	}
	printf("%s\n",val[nxt[0]].c_str());
	return 0;
}

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

typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<vector<pair<int, ll>>> g (n + 1);
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        ll w;
        cin >> u >> v >> w;
        g[u].push_back({ v, w });
        g[v].push_back({ u, w });
    }
    vector<ll> colors(n + 1, -1);
    queue<int> q;
    q.push(1);
    colors[1] = 0;
    while (!q.empty()) {
        int f = q.front();
        q.pop();
        for (auto &v : g[f]) {
            if (colors[v.first] < 0) {
                q.push(v.first);
                colors[v.first] = (colors[f] + v.second) % 2;
            }
        }
    }
    for (int i = 1; i <= n; i++)
        cout << colors[i] << endl;
    return 0;
}


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

int main(){
    char S[100];
    int K;
    cin >> S >> K;
    for(int i=0;i<sizeof(S);i++){
        if(S[i]!='1'){
            cout << S[i] << "\n";
            break;
        }
        if(i==(K-1)){
            cout << "1" << "\n";
            break;
        }
    }
}

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

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    int[] A = new int[N * 3];
    for (int i = 0; i < N * 3; i++) A[i] = scanner.nextInt();
    Arrays.sort(A);
    reverse(A);

    long res = 0;
    for (int i = 1; i < N * 2; i += 2) res += A[i];
    System.out.println(res);
  }

  private static void reverse(int[] a) {
    int i = 0;
    int j = a.length - 1;
    while (i < j) {
      int tmp = a[i];
      a[i] = a[j];
      a[j] = tmp;
      i++;
      j--;
    }
  }
}


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

int main() {
  int n;
  cin >> n;
  string S[100005];
  rep(i, 0, n) cin >> S[i];

  ll ans = 0;
  rep(i, 0, n) sort(S[i].begin(), S[i].end());
  sort(S, S + n);
  ll tmp = 1;
  rep(i, 1, n) {
    if (S[i-1] == S[i]) tmp++;
    else {
      ans += tmp * (tmp - 1) / 2;
      tmp = 1;
    }
  }
  ans += tmp * (tmp - 1) / 2;
  cout << ans << endl;
}


Measured memory_bytes: 7296
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx2")
#pragma GCC optimize("Os")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
void vok()
{
    FAST
    FO
    FI
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}
int main()
{
    vok();
    int x,n;
    IN x>>n;
    vector<int> v(n);
    map<int,bool> vis;
    loop(i,0,n)
    {
        IN v[i];
        vis[v[i]]=1;
    }
    int temp=1;
    if(!vis[x])
    {
        OUT x<<endl
        return 0;
    }
    while(1)
    {
        loop(i,x-temp,x+temp+1)
        {
            if(!vis[i])
            {
                OUT i<<endl
                return 0;
            }
        }
        temp++;
    }
    return 0;
}

Measured memory_bytes: 3664
// C++ program to print all 
// permutations with duplicates allowed 
#include <bits/stdc++.h> 
using namespace std; 


// Function to print permutations of string 
// This function takes three parameters: 
// 1. String 
// 2. Starting index of the string 
// 3. Ending index of the string. 
vector<string> ans;
void permute(string a, int l, int r) 
{ 
	// Base case 
	if (l == r) 
		ans.push_back(a); 
	else
	{ 
		// Permutations made 
		for (int i = l; i <= r; i++) 
		{ 

			// Swapping done 
			swap(a[l], a[i]); 

			// Recursion called 
			permute(a, l+1, r); 

			//backtrack 
			swap(a[l], a[i]); 
		} 
	} 
} 

// Driver Code 
int main() 
{ 
	int n;
	cin >> n;
	vector<int> a(n);
	vector<int> b(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < n; ++i) {
		cin >> b[i];
	}
	string str = "";
	string s = "0123456789";
	for (int i = 1; i <= n; ++i) {
		str += s[i]; 
	} 
	int nn = str.size(); 
	permute(str, 0, nn-1);
	//for (int i = 0; i < (int)ans.size(); ++i) {
		//cout << ans[i] << " ";
	//}
	sort(ans.begin(),ans.end());
	int p = (int)ans.size();
	int first = 0;
	int second = 0;
	for (int i = 0; i < p; ++i) {
		bool d = 1;
		for (int j = 0; j < (int)ans[i].size(); ++j) {
			if (s[a[j]] != ans[i][j]) {
				d = 0;
				break;
			} 
		}
		if (d) {
			first = i;
		}
		d = 1;
		for (int j = 0; j < (int)ans[i].size(); ++j) {
			if (s[b[j]] != ans[i][j]) {
				d = 0;
				break;
			} 
		}
		if (d) {
			second = i;
		}
	} 
	//cout << first << " " << second << endl;
	cout << abs(first - second);
	return 0; 
} 



Measured memory_bytes: 2424
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int N,a[200000],flag=1;
	scanf("%d",&N);
	for(int i=0;i<N;i++)
	scanf("%d",&a[i]);
	sort(a,a+N);
	for(int i=N-1;i>0;i--)
	{
		if(a[i]==a[i-1])
		{
			flag=0;
			break;
		}
	}
	if(flag==1)	printf("YES\n");
	else	printf("NO\n");
}


Measured memory_bytes: 896
def aa
    a,b,c = gets.chomp.split(/\s/).map{|x| x.to_i}

    #if a > c # del ww
    #    puts 0
    #    exit
    #end

    if a > b # add w
        puts 0
        exit
    end

    if a*c <= b
        puts c
        exit
    end

    puts b/a
end

aa


Measured memory_bytes: 2044
n = int(input())
X = list(map(int, input().split()))
m = min(X)
M = max(X)

ans = float("inf")
for p in range(m, M + 1):
    cnt = 0
    for i in range(n):
        cnt += (X[i] - p) ** 2

    ans = min(ans, cnt)
print(ans)


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

int parity(int n){
  if(n*n*n*n%10 == 1)
    return 1;
  else
    return 0;
}

long long power(int x, int y){
  if(y < 0)
    return 0;
  else{
    int64_t n = 1ll;
    for(int i = 0; i < y; i++)
      n *= x;
    return n;
  }
}
int digit(int x, int y){
  return x%power(10,y+1)/power(10,y);
}
int card(int n){
  int cnt = 0;
  while(n > 0){
    int n0 = n%10;
    n /= 10;
    if(n0 <= 3 && n%10 == 1){
      cnt++;
      n /= 10;
    }
  }
  return cnt;
}

long long bnps(int n, int a, int d){
  long long an = 0;
  for(int i = 0; i < d; i++){
    an += a%power(n,i+1)/power(n,i)*power(10,i);
  }
  return an;
}

int left(vector<int> vec, int k){
  int a = 0;
  int b = vec.size()-1;
  if(vec.at(a) > k)
    return 0;
  else if(vec.at(a) == k)
    return a;
  else if(vec.at(b) < k)
    return -1;
  else{
    bool bk = true;
    while(bk){
      int c = (a+b)/2;
      if(vec.at(c-1) < k && vec.at(c) == k){
        return c;
        bk = false;
      }
      else if(vec.at(c-1) >= k)
        b = c;
      else if(vec.at(c) < k)
        a = c;
      else{
        return c;
        bk = false;
      }
    }
  }
}

int right(vector<int> vec, int k){
  int a = 0;
  int b = vec.size()-1;
  if(vec.at(a) > k)
    return -1;
  else if(vec.at(b) == k)
    return b;
  else if(vec.at(b) < k)
    return b;
  else{
    bool bk = true;
    while(bk){
      int c = (a+b)/2;
      if(vec.at(c) == k && vec.at(c+1) > k){
        return c;
        bk = false;
      }
      else if(vec.at(c+1) <= k)
        a = c;
      else if(vec.at(c) > k)
        b = c;
      else{
        return c;
        bk = false;
      }
    }
  }
}
int main() {
  int r;
  cin >> r;
  cout << r*r << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define BIG 1000000010
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
typedef long long int ll;


int main(){
  string s;
  cin>>s;
  for(int i=s.size()-2;i>=0;i--){
    if(i%2==1) continue;
    if(s.substr(0,i/2)==s.substr(i/2,i/2)){cout<<i<<endl;return 0;}
  }
  return 0;
}



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

struct N
{
    int p;
    double v;
    bool operator < (N b) const
    {
        return v<b.v;
    }
};

N P[1010];

int main()
{
    int t,a,n,h;
    scanf("%d%d%d",&n,&t,&a);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&h);
        P[i].p=i+1;
        P[i].v=abs(a-(t-h*0.006));
    }
    sort(P,P+n);
    printf("%d\n",P[0].p);
    return 0;
}



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

template<typename T>
struct PriorityQueue {
  vector<T> data;
  int n, size;
  const int noval = -INT_MAX;
  PriorityQueue(int n): data(n, noval), n(n), size(0) {}
  void push(T key) {
    data[size] = key;
    upheap(size);
    size++;
  }
  T pop() {
    T ret = data[0];
    size--;
    if (size == 0) {
      data[0] = noval;
      return ret;
    }
    data[0] = data[size];
    data[size] = noval;
    downheap(0);
    return ret;
  }
  void upheap(int node) {
    if (node == 0) return;
    int parent = (node - 1) / 2;
    if (data[parent] < data[node]) {
      swap(data[parent], data[node]);
      upheap(parent);
    }
  }
  void downheap(int node) {
    int left = 2 * node + 1;
    int right = 2 * node + 2;
    int largest = -1;
    // 左の子，自分，右の子で最大のノードを選ぶ
    if (left < size && data[left] > data[node]) {
      largest = left;
    } else {
      largest = node;
    }
    if (right < size && data[right] > data[largest]) {
      largest = right;
    }
    if (largest != node) { // 自分以外が大きい場合取替
      swap(data[node], data[largest]);
      downheap(largest);
    }
  }
  void build() {
    for (int i = n / 2; i >= 0; i--) {
      downheap(i);
    }
  }
};


int main(void) {
  PriorityQueue<int> pq(2000000);
  while (true) {
    string s;
    cin >> s;
    if (s == "insert") {
      int k;cin >> k;
      pq.push(k);
    } else if (s == "extract") {
      cout << pq.pop() << endl;
    } else {
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 10584
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1);





int main() 
{
  ll N; cin>>N;
  for(int n=1;n<=N;n++)
  {
    ll ans=0;
    for(int x=1;x*x<n;x++)
    {
      for(int y=1;x*x+y*y+x*y<n;y++)
      {
        for(int z=1;x*x+y*y+z*z+x*y+y*z+z*x<=n;z++)
        {
          if(x*x+y*y+z*z+x*y+y*z+z*x==n) ans++;
        }
      }
    }
    cout<<ans<<endl;
  }  
  return 0;
}


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


using namespace std ; 

int main ( ) 
{
	int x ; 
	cin >> x ; 
	if ((x/100 )== (x%10)) 
	{
		cout << "Yes" ; 
		
	}
	else 
	cout << "No" ; 
		return 0 ; 
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    ll n,m;
    cin>>n>>m;
    vector<pair<ll,ll>>v(n);
    for(int i=0;i<n;i++){
        cin>>v[i].first>>v[i].second;
    }
    sort(v.begin(),v.end());
    ll sum=0;
    ll cnt=0;
    ll k;
    //超えるまで
    for(int i=0;i<m;i++){
        sum+=v[i].first*v[i].second;
        cnt+=v[i].second;
        if(cnt>=m) {
            k=i;
            break;
    }
    }
    sum=sum-v[k].first*v[k].second;
    cnt=cnt-v[k].second;
    for(int i=0;i<v[k].second;i++){
        sum+=v[k].first;
        cnt+=1;
        if(cnt==m){
            break;
        }
    }
    cout<<sum<<endl;


    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i, n) for (int i = 0; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
	ll A,B;
	cin >> A >> B;
	ll start=0;
	ll startValue = 0;

	if(A==B){

		cout << A << endl;
		return 0;

	}else if(A&1){
		start = B - ((B - A)%4);
		startValue = A;
	} else {
		start = B - ((B - (A+1))%4);
		startValue = 1;
	}

	ll x = startValue; 
  for(ll i=start+1;i<=B;i++){
		x = x^i;
	}
	cout << x << endl;
}

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

vector<vector<int> > calcNext(const string &S) {
    int n = (int)S.size();
    vector<vector<int> > res(n+1, vector<int>(10, n));
    for (int i = n-1; i >= 0; --i) {
      for (int j = 0; j < 10; ++j) res[i][j] = res[i+1][j];
      res[i][S[i] - '0'] = i;
    }
    return res;
}
int main(){
  int n;
  string S;
  cin >> n >> S;
  
  vector<vector<int> > next = calcNext(S);
  // dp[3][2]は2番めの文字を2文字目に選部場合の数であることに注意
  vector<vector<long long> > dp(n+1, vector<long long>(4, 0));
  dp[0][0] = 1;
  for (int i = 0; i < n;i++){
    for (int j = 0; j < 10; j++){
      if (next[i][j] >= n) continue;
      dp[next[i][j]+1][1] += dp[i][0];
      dp[next[i][j]+1][2] += dp[i][1];
      dp[next[i][j]+1][3] += dp[i][2];
    }
  }

  long long res = 0;
  for (int i = 0; i <= n; i++){
    res += dp[i][3];
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 4480
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main( int argc, char* argv[]) {
  int N, M;
  cin >> N >> M;
  int B = M/N;
  for( int b=B; b>=1; --b ){
    if( M%b == 0 ){
      cout << b << endl;
      return 0;
    }
  }
}
   

Measured memory_bytes: 256
#include <iostream>
int main(){
  int N,ans,temp,sumnor=0,sumpow=0;
  std::cin>>N;
  for(int i=0;i<N;i++){
    std::cin>>temp;
    sumnor+=temp;
    sumpow+=temp*temp;
  }
  ans=(sumnor*sumnor-sumpow)/2;
  std::cout<<ans<<std::endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main()
{
    double d,a,s,x,y;
    x = 0.0;
    y = 0.0;
    s = M_PI/2;
    while(scanf("%lf,%lf",&d,&a) != EOF){
        x -= d*cos(s);
        y += d*sin(s);
        s += a/180*M_PI;
    }
    int ax = x;
    int ay = y;
    printf("%d\n%d\n",ax,ay);
    return 0;
}



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

typedef long long ll;

ll N,K,a[20],basic,ans,dp=1e18;

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

    cin >> N >> K;
    for(ll i=1;i<=N;i++){
        cin >> a[i];
    }

    for(ll i=(1<<N);i>0;i--){
        ll bits = __builtin_popcount(i);      //count how many bits

        if(bits==K){                            //randomly pick K buildings
            ll head = 31-__builtin_clz(i);      //first building
            basic = 0;
            for(ll j=1;j<N-head;j++){
                basic = max(basic,a[j]);
            }
            ans = 0;
            for(ll j=head;j>=0;j--){
                if(i&(1<<j)){
                    if(a[N-j]<=basic){          //not tall enough or ngam ngam tall enough
                        ans += (basic - a[N-j]);
                        basic++;
                    }
                    else basic = a[N-j]+1;
                }
                else basic = max(basic,a[N-j]+1);      //taller than basic
            }

            dp = min(ans,dp);
        }
    }

    cout << dp << endl;

    return 0;
}


Measured memory_bytes: 256
//Bismillahir-Rahmanir-Rahim
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int llu;
#define f1(i,n) for(i=1;i<=n;i++)
#define f(i,n) for(i=0;i<n;i++)
#define Max 100009
#define Mx 1e10
#define pb push_back
#define mp make_pair
using namespace std;
int main()
{
    	ll n,mn=0,mx=0,x,i,t=0,j=0,k=0;
    	string s;
    	cin>>s;
    	n=s.size();
    	f(i,n)
    	{
    	    t=0;
    	    f(j,n)
    	    {
    	        if(s[i]==s[j])
                  t++;
    	    }
    	    if(t%2!=0)
            {
                k=1;
                break;
            }
    	}
    	if(k==1)
            cout<<"No\n";
        else cout<<"Yes\n";

}







Measured memory_bytes: 3596
suit = {"S": 0, "H": 1, "C": 2, "D": 3}
suit_keys = list(suit.keys())
deck = [[suit_keys[i] + " " + str(j + 1) for j in range(13)] for i in range(4)]
for _ in range(int(input())):
    card = input().split()
    deck[suit[card[0]]][int(card[1]) - 1] = ""
for i in range(4):
    for j in range(13):
        if deck[i][j] != "":
            print(deck[i][j])



Measured memory_bytes: 5604
#include <bits/stdc++.h>
#if 1
#define int long long
#define MAX LLONG_MAX
#define MIN LLONG_MIN
#define stoi stoll
#else
#define MAX INT_MAX
#define MIN INT_MIN
#endif
#define ALL(obj) (obj).begin(), (obj).end()
#define fi first
#define se second
const int NIL = -1;
const int MOD = 1000000007;
#define REP(i,n) for (int i=0; i < (n); ++i)
#define FOR(i,a,b) for (int i=(a); i < (b); ++i)
using namespace std;

int pow(int x, int n) {int res=1; while(n){if(n&1)res*=x;x*=x;n>>=1;} return res;}
int get_gcd(int a, int b){while(1){if (a < b) swap(a, b); if (b == 0) return a; a %= b;}}
int get_lcm(int a, int b){return a * b / get_gcd(a, b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//-------------------------テンプレここまで-------------------------//

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

  int X, Y;
  cin >> X >> Y;

  int i = 0;
  int A = X;
  while (A <= Y) {
    A <<= 1;
    i++;
  }

  cout << i << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; inline void fileio(const char* in, const char* out) { freopen(in, "r", stdin); freopen(out, "w", stdout); } 
#define TD typedef
#define forx(i,n) for(int i = 0; i < (n); ++i)
#define forxr(i,n) for(int i = (n)-1; i >= 0; --i)
TD long long ll; TD long double ld; TD pair<int,int> pii; TD pair<ll,ll> pll; TD vector<int> VI; TD vector<bool> VB; TD vector<ll> VL;
const char nl = '\n'; const int INF = 0x3f3f3f3f; const ll LINF = 0x3f3f3f3f3f3f3f3fll; const ld EPS = 1e-9, PI = acos(-1);
#define ff first
#define ss second
#define all(c) c.begin(),c.end()

bool is_pal(string a) {
  cerr << "checking " << a << nl;
  auto b = a.begin();
  auto e = a.rbegin();
  for (int i = 0; i < a.size()/2; ++i) {
    if (b[i] != e[i]) return false;
  }
  return true;
}

int main() {
  atexit([](){ cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << nl; });
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cout << fixed << setprecision(12);
  // Emily <3
  string s;
  cin >> s;
  const int n = s.size();
  if (is_pal(s) && is_pal(s.substr(0, n/2)) && is_pal(s.substr(n/2+1))) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

ll GCD(ll x,ll y){
  if(x == y)return x;
  if(x < y)swap(x,y);
  ll r = x%y;
  if(r)return GCD(y,r);
  else return y;
}

ll LCM(ll x,ll y){
  return x/GCD(x,y)*y;
}

signed main(){
  ll N,M;
  cin >> N >> M;
  string S,T;
  cin >> S >> T;
  ll ans = LCM(N,M);
  ll LN = ans/N;
  ll LM = ans/M;
  set<int> s;
  map<int,char> m;
  FOR(i,0,N){
    s.insert(LN*i);
    m[LN*i] = S[i];
  }
  FOR(i,0,M){
    if(s.count(LM*i)){
      if(m[LM*i] != T[i]){
        cout << -1 << endl;
        return 0;
      }
    }
  }
  cout << ans << endl;
}

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

using namespace std;

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

//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);

    int n;
    cin >> n;
    cout << (n >= 30 ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 3648
from itertools import accumulate
import math
from collections import deque
from collections import defaultdict
from itertools import permutations
import heapq
import bisect
from collections import Counter
from itertools import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**10
from functools import reduce

h,w,n = map(int,input().split())
sr,sc = map(int,input().split())
s = input()
t = input()
l = 1
r = w
u = 1
d = h
for s,t in zip(s[::-1],t[::-1]):
    if t == "R":
        l = max(l-1,1)
    elif t == "L":
        r = min(r+1,w)
    elif t =="U":
        d = min(d+1,h)
    else:
        u = max(u-1,1)

    if s == "L":
        l += 1
    elif s =="R":
        r -=1
    elif s =="U":
        u+=1
    else:
        d-=1
    if l > r or u > d:
        print('NO')
        exit()
if u <= sr <= d and l <= sc <= r:
    print("YES")
else:
    print("NO")

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

int main(){
	int mount[10];
	int i;
	for (i = 0; i < 10; i++) {
		cin >> mount[i];
	}
	int top = 0;
	int second = 0;
	int third = 0;

	for (i = 0; i < 10; i++) {
		if (third <= mount[i]){
			third = mount[i];
			if (second < mount[i]){
				third = second;
				if (top <= mount[i]){
					second = top;
					top = mount[i];
				}
				else
				{
					second = mount[i];
				}
			}
		}
	}

	cout << top << endl << second << endl << third << endl;
	cin >> i;
	return 0;
}

Measured memory_bytes: 3088
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

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

int a[200001];
ll s[200001]; 
int main(){
    int n;
    ll k;
    cin >> n >> k;
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }
    k++;
    int id = 0;
    ll cnt = 1;
    bool flag = 1;
    while(1){
        if(cnt==k)break;
        if(s[id]!=0&&flag){
            ll P = cnt- s[id];
            ll Z = k-cnt;
            Z %= P;
            cnt = k-Z;
            flag = 0;
        }
        if(cnt==k)break;
        
        s[id] = cnt;
        id = a[id];
        cnt++;
        // cerr << id << " " << cnt << endl;
    }
    cout << id+1 << endl;
    return 0;
}

Measured memory_bytes: 5564
#include<stdio.h>
#include<string.h>
int a[2],k;
bool op=0;
int main ( ){
    scanf("%d%d%d",&a[0],&a[1],&k);
    while(k--){
        if(a[op]&1)a[op]--;
        a[op]>>=1;a[op^1]+=a[op];
        op^=1;
    }
    printf("%d %d\n",a[0],a[1]);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

typedef pair<int,int> P;

int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
int h,w,n;
bool filled[6000][6000];

int compress(int* x1,int* x2,int len){
	vector<int> xs;
	for(int i = 0;i < n;i++){
		for(int j = -1;j <= 1;j++){
			int nx1 = x1[i] + j,nx2 = x2[i] + j;
			if(nx1 >= 0 && nx1 < len) xs.push_back(nx1);
			if(nx2 >= 0 && nx2 < len) xs.push_back(nx2);
		}
	}
	sort(xs.begin(),xs.end());
	xs.erase(unique(xs.begin(),xs.end()),xs.end());
	for(int i = 0;i < n;i++){
		x1[i] = find(xs.begin(),xs.end(),x1[i]) - xs.begin();
		x2[i] = find(xs.begin(),xs.end(),x2[i]) - xs.begin();
	}
	return xs.size();
}

int main(){
	while(1){
		cin >> w >> h;
		if(!h && !w) break;
		cin >> n;
		for(int i = 0;i < 6000;i++) for(int j = 0;j < 6000;j++) filled[i][j] = 0;
		int x1[1000],x2[1000],y1[1000],y2[1000];
		for(int i = 0;i < n;i++){
			int a,b,c,d;
			cin >> a >> b >> c >> d;
			x1[i] = a;
			y1[i] = b;
			x2[i] = c - 1;
			y2[i] = d - 1;
		}
		w = compress(x1,x2,w);
		h = compress(y1,y2,h);
		for(int i = 0;i < n;i++){
			for(int j = x1[i];j <= x2[i];j++){
				for(int k = y1[i];k <= y2[i];k++){
					filled[j][k] = true;
				}
			}
		}
		/*for(int i = h - 1;i >= 0;i--){
			for(int j = 0;j < w;j++){
				cout << filled[j][i];
			}
			cout << endl;
		}*/
		queue<P> que;
		int cnt = 0;
		for(int i = 0;i < w;i++){
			for(int j = 0;j < h;j++){
				if(filled[i][j]) continue;
				cnt++;
				que.push(P(i,j));
				while(!que.empty()){
					int sx = que.front().first,sy = que.front().second;
					que.pop();
					for(int i = 0;i < 4;i++){
						int x = sx + dx[i],y = sy + dy[i];
						if(x >= 0 && x < w && y >= 0 && y < h && !filled[x][y]){
							que.push(P(x,y));
							filled[x][y] = true;
						}
					}
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 38260