akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
  
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
 
#define pb emplace_back
#define fi first
#define se second

using namespace std;
 
typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
 
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-8;
const ll MOD = 1e9+7;

template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }
ll in(){ ll x; scanf( "%lld" , &x ); return x; }
 
// head

string s;
string ans = "";

int main(){

  cin >> s;
  YYS( w , s ){
    if( w == 'B' ){
      if( !ans.empty() ){
	ans.pop_back();
      }
    } else {
      ans.push_back( w );
    }
  }

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


Measured memory_bytes: 256
import java.util.Scanner;

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

       int a = sc.nextInt();
       int b = sc.nextInt();
       int c = sc.nextInt();

       if (a <= c && c <= b) {
           System.out.println("Yes");
       } else {
           System.out.println("No");
       }
    }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  vector<int>v(4);
  for(int i = 0; i < 4; i++)v[i] = s[i] - '0';

  for(int j = 0; j < (1 << 3); j++){
    int tmp = v[0];
    for(int k = 0; k < 3; k++){
      if(j & (1 << k))tmp += v[k+1];
      else tmp -= v[k+1];
    }
    if(tmp == 7){
      cout << v[0];
      for(int k = 0; k < 3; k++){
        if(j & (1 << k))cout << '+';
        else cout << '-';
        cout << v[k+1];
      }
      cout << "=7" << endl;
      return 0;
    }
  }
}

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

typedef long long ll;

#define PB push_back
#define MP make_pair

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    string s; cin >> s;
    ll k; cin >> k;
    if (k > 1) {
        if (s.size() >= k) {
            bool works = true;
            for (int i = 0; i < k; ++i) {
                if (s[i] != '1') works = false;
            }
            if (works) {
                cout << 1 << "\n";
                return 0;
            }
        }
        for (auto i : s) {
            if (i != '1') {
                cout << i << "\n";
                break;
            }
        }
    } else cout << s[0] << "\n";
}

Measured memory_bytes: 3556
#include <iostream>
#include <vector>
using namespace std;
const long long mod=1e9+7;
int main(){
    long int N,M;
    cin >> N>> M;
    vector<long long int> dp(N,0);
    vector<bool> tf(N,true);
    for(long int i = 0; i< M; i++){
        long int tmp;
        cin >> tmp;
        tf[tmp-1] = false;
    }
    
    if(tf[0]) dp[0]=1;
    if(tf[0] && tf[1]){
        dp[1]=2;
    }else if(tf[0] == false && tf[1]){
        dp[1]=1;
    }
    //cout << dp[0] << endl;
    //cout << dp[1] << endl;
    for(long int i=2 ;i < N;i++){
        if(tf[i]){
            if(tf[i-1] && tf[i-2]){
                dp[i] = dp[i-1] + dp[i-2];
            }else if( (tf[i-2]==false) && tf[i-1]){
                dp[i] = dp[i-1];
            }else if( (tf[i-1]==false) && tf[i-2]){
                dp[i] = dp[i-2];
            }else{
                cout << 0 << endl;
                return 0;
            }
        }else{
            dp[i] = 0;
        }
        dp[i] %= mod;
        //cout << i+1 << "  " << dp[i] << endl;
    }
    

    cout << dp[N-1] <<endl;
    return 0;
}

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

int main(){


	long long n,a,b,x,y;
	cin>>n>>a>>b;
	x=n/(a+b);

	y=a*x;
	n=n-(a+b)*x;
	if(n>=a)
  y+=a;
  else y+=n;
  cout<<y;
	

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
        int num = 100*a + 10*b + c;
		System.out.println((num%4 == 0)?"YES":"NO");
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);

#define endl '\n'
#define D(x) cout << #x << " = " << (x) << endl;

int dp[100005][2];

int count(int cur, int parent, int force, vector<vector<int>> &G) {
  if (dp[cur][force] == -1) {
    vector<int> v_next;
    for (auto next : G[cur]) {
      if (next != parent) {
        v_next.push_back(next);
      }
    }

    int cnt = 0;
    if (v_next.size() == 0) {
      cnt = force;
    } else if (v_next.size() == 1) {
      cnt = count(v_next[0], cur, force, G);
    } else if (v_next.size() > 1) {
      vector<int> with_force(v_next.size()), without_force(v_next.size());
      int sum_with = 0, sum_without = 0;

      for (int i = 0; i < v_next.size(); ++i) {
        int next = v_next[i];

        with_force[i] = count(next, cur, 1, G);
        without_force[i] = count(next, cur, 0, G);

        sum_with += with_force[i];
        sum_without += without_force[i];
      }

      // D(sum_with); D(sum_without);
      cnt = INT_MAX;
      for (int i = 0; i < v_next.size(); ++i) {
        int tmp = sum_with - with_force[i] + without_force[i];
        cnt = min(cnt, tmp);
        // D(i); D(tmp);
      }
    }

    dp[cur][force] = cnt;
    // cout << cur << " : " << cnt << " + " << force << " = " << cnt + force << endl;
  }


  return dp[cur][force];
}

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

  vector<vector<int>> G(n);
  for (int i = 0; i < n - 1; ++i) {
    int a, b;
    cin >> a >> b;

    G[a].push_back(b);
    G[b].push_back(a);
  }

  for (int i = 0; i < 100005; ++i) {
    dp[i][0] = dp[i][1] = -1;
  }

  int ans = INT_MAX;
  for (int i = 0; i < n; ++i) {
    if (G[i].size() >= 3) {
      ans = count(i, -1, 0, G);
      break;
    }
  }

  if (ans == INT_MAX) {
    ans = 1;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 16000
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

int n;
ll a[1000];

int main(){
	cin >> n;
	int ans = 0;
	rep(i,n)cin >> a[i];
	bool ok = true;
	while(ok){
		rep(i,n){
			if(a[i]%2)ok = false;
			else a[i]/=2;
		}
		if(!ok)break;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define vl vector<long long>
using namespace std;
using ll = long long;
using ld = long double;

// ----本問について----
// 問題：
// 問題文URL：
// ------------------

// ----ここから本問のソースコード----

// グローバル変数（入力）
ll n;
vl A, copyA;

ll MergeCount(ll l, ll r) { // [l,r)
  if (r == l + 1) { return 0; }
  if (r == l + 2) {
    if (A[l] > A[l + 1]) {
      swap(A[l], A[l + 1]); // 2個でソート
      return 1;
    }
    return 0;
  }
  ll m = (l + r) / 2;
  ll cl = MergeCount(l, m);
  ll cr = MergeCount(m, r);
  ll c = 0;

  // 最初はソートせずこれでよくね？と思ったがTLEしてしまった．
  /*
  for (int i=l; i<m; i++){
    for (int j=m; j<r; j++){
      if (A[i]>A[j]){
        c++;
      }
    }
  }
  */

  // ソートされていることを利用して楽に数えつつ，マージ
  ll i = l, j = m;
  // copyA = A; // TLEの原因！
  copy(A.begin() + l, A.begin() + r, copyA.begin() + l);
  ll index = l;

  // これもTLEした．（copyA = A;が原因なので後々これでもAC）
  ll temp = 0;
  while (i < m) {
    // iを固定してjがどこまでいけるか
    while (j < r && copyA[i] > copyA[j]) {
      A[index++]=copyA[j];  // マージ
      j++;
      temp++;
    }
    A[index++]=copyA[i];  // マージ
    c += temp;
    i++;
  }
  // j側の余ったやつをマージ．
  while (j<r){
    A[index++]=copyA[j++];
  }
  
  /*
  while (i < m && j < r) {
    if (copyA[i] > copyA[j]) {
      A[index++] = copyA[j++];
      c += m - i;
    } else {
      A[index++] = copyA[i++];
    }
  }
  // i側のあまりをマージ
  while (i < m) {
    A[index++] = copyA[i++];
  }
  // j側のあまりをマージ
  while (j < r) {
    A[index++] = copyA[j++];
  }
  */

  // cout << "MergeCount(" << l << ", " << r << ") = " << cl << "+" << cr << "+"
  // << c << "=" << cl + cr + c << endl;
  return cl + cr + c;
}

void solve() { cout << MergeCount(0, n) << endl; }

int main() {
  cin >> n;
  rep(i, n) {
    ll a;
    cin >> a;
    A.push_back(a);
  }
  copyA = A;
  solve();
  return 0;
}



Measured memory_bytes: 6196
#include <iostream>
using namespace std;
int seach(double in){
	if(1.1<=in)return 0;
	else if(0.6<=in)return 1;
	else if(0.2<=in)return 2;
	return 3;
}

int main() {
	int r[4]={0},l[4]={0};
	int c=0;
	double rin,lin;
	while(cin>>rin>>lin){
		c++;
		r[seach(rin)]++;
		l[seach(lin)]++;
	//	cout<<seach(rin)<<" "<<seach(lin)<<endl;
	}
	//cout<<endl;
	for(int i=0;i<4;i++){
		cout<<r[i]<<" "<<l[i]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define re return
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;  
int h,w;
string s[2010];
int mxh[2010][2010],mxw[2010][2010];
int main() { 
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>h>>w;
	for(int i=0;i<h;i++){
		cin>>s[i];
	}
	int nw;
	int be;
	for(int i=0;i<h;i++){
		nw=0;
		be=0;
		for(int j=0;j<w;j++){
		 	if(s[i][j]=='.')nw++;
			if(s[i][j]=='#'){
				mxh[i][be]=nw;
				mxh[i][j]=-nw;
				be=j+1;
				nw=0;
			}
		}
		mxh[i][be]=nw;
	}
	for(int i=0;i<w;i++){
		nw=0;
		be=0;
		for(int j=0;j<h;j++){
			if(s[j][i]=='.')nw++;
			if(s[j][i]=='#'){
				mxw[be][i]=nw;
				mxw[j][i]=-nw;
				be=j+1;
				nw=0;
			}
		}
		mxw[be][i]=nw;
	}
	int ans=0;
	
	for(int i=0;i<h;i++){
		for(int j=1;j<w;j++){
			mxh[i][j]+=mxh[i][j-1];
		}
	}
	for(int i=0;i<w;i++){
		for(int j=1;j<h;j++){
			mxw[j][i]+=mxw[j-1][i];
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			ans=max(ans,mxh[i][j]+mxw[i][j]-1);
		}
	}
	cout<<ans<<endl;
    return 0; 
}

Measured memory_bytes: 35840
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;

#define rep(i, n) for (int i = 0; i < (int)(n); 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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n, m;
  cin >> n >> m;
  vector <vector <ll>> a(n, vector <ll>(m));
  rep(i, n) {
    rep(j, m) {
      cin >> a.at(i).at(j);
    }
  }
  vector <ll> b(m);
  rep(i, m) {
    cin >> b.at(i);
  }
  rep(i, n) {
    ll ans = 0;
    rep(j, m) {
      ans += a.at(i).at(j)*b.at(j);
    }
    cout << ans << endl;
  }
}


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

int main(){
    int n;
    cin >> n;
    vector<int> v(n);
    iota(v.begin(), v.end(), 1);
    do{
        for(auto i = v.begin(); i != v.end(); i++){
            cout << (i != v.begin() ? " " : "") << *i;
        }
        cout << endl;
    }while(next_permutation(v.begin(), v.end()));
    return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  
  if ( A + B == C + D ) {
  cout << "Balanced" << endl;
  }
  else if (A + B > C + D ) {
    cout << "Left" << endl;
  }
  else if (A + B < C + D ) {
    cout << "Right" << endl;
  }
}

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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n, k;
	cin >> n >> k;
	vector<ll> a(n);
	for (auto &v : a) {
		cin >> v;
	}

	ll res = 0;
	for (int d = 60; d >= -1; d--) {
		if (d != -1 && !(k & (1LL << d))) {
			continue;
		}

		ll tmp = 0;
		for (int e = 60; e >= 0; e--) {
			ll mask = 1LL << e;
			ll num = 0;

			for (int i = 0; i < n; i++) {
				if (a[i] & mask) {
					num++;
				}
			}

			if (e > d) {
				if (k & mask) {
					tmp += mask * (n - num);
				} else {
					tmp += mask * num;
				}
			} else if (e == d) {
				tmp += mask * num;
			} else {
				tmp += mask * max(num, (n - num));
			}
		}

		res = max(res, tmp);
	}
	cout << res << endl;
	return 0;
}


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

#define FOR(i,a,b) for(int (i) = (a);(i) < (int) (b);(i)++)
#define PB push_back
#define MP make_pair
#define ALL(x) (x).begin(),(x).end()
typedef long long LL;

int N,L;
vector<string> vs;

int main()
{
	scanf("%d%d",&N,&L);
	FOR(i,0,N){
		char s [200];
		scanf("%s",s);
		vs.PB(s);
	}

	sort(ALL(vs));
	FOR(i,0,N){
		printf("%s",vs [i].c_str());
	}
	printf("\n");

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int res=0;
    int r=0;     
    int xsum=0,sum=0;
    for (int l=0;l<n;l++) {
        while (r<n&&((xsum^a[r])==sum+a[r])){
            xsum^=a[r];
            sum+=a[r];
            r++;
        }
        res+=r-l;
        if (r==l) r++;
        else{
            sum-=a[l];
            xsum^=a[l];
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 1792
from functools import reduce

def main():
    # 切り捨て
    # 4 // 3
    # 切り上げ
    #-(-4 // 3)
    
    # 初期値用:十分大きい数(100億)
    # 1e10

    # 初期値用:十分小さい数(-100億)
    # -1e10
    
    # 1文字のみを読み込み
    # 入力:2
    # a = input().rstrip()
    # 変数:a='2'
    
    # スペース区切りで標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a, b, c, d = (int(_) for _ in input().split())  
    # 変数:a=2 b=4 c=5 d =7
    
    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2 4 5 7
    # a = list(int(_) for _ in input().split())
    # 変数:a = [2, 4, 5, 7]    

    # 1文字ずつ標準入力を配列として読み込み
    # 入力:2457
    # a = list(int(_) for _ in input())
    # 変数:a = [2, 4, 5, 7]
    
    H,W = (int(_) for _ in input().split())
    C = []
    tmp = []
    for i in range(H):
        tmp = list(_ for _ in input())
        C.append(''.join(tmp))
        C.append(''.join(tmp))
    
    print('\n'.join(C))
if __name__ == '__main__':
    main()


Measured memory_bytes: 3684
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    string A; cin >> A;
    ll N = A.size();
    vl cnt(26,0);
    REP(i, N){
        cnt[A[i]-'a']++;
    }
    ll ans = N*(N-1)/2+1;
    REP(i, 26){
        ll c = cnt[i];
        ans -= c*(c-1)/2;
    }
    cout << ans << endstr;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int h, n; cin >> h >> n;
  vector<int> dp(30000, INF);
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i] >> b[i];
  dp[0] = 0;
  for(int i = 0; i < 30000; ++i) {
    rep(j, n) if(i+a[j] < 30000) chmin(dp[i+a[j]], dp[i]+b[j]);
  }
  int ans = INF;
  for(int i = h; i < 30000; ++i) chmin(ans, dp[i]);
  cout << ans << endl;
}

Measured memory_bytes: 3724
#include<bits/stdc++.h>
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define pb push_back
#define popb pop_back
#define popf pop_front
#define pf push_front
#define si size()
#define mp make_pair 
#define mt make_tuple
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound

#define ask(i,m,n) for(lli i=m;i<n;i++)
#define anket ios::sync_with_stdio(0), cin.tie(0),cout.tie(0)
 
#define endl "\n"
#define o0(a) cout<<a<<" "
#define o1(a) cout<<a<<"\n"
#define o2(a,b) cout<<a<<" "<<b<<"\n"
#define o3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define o4(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<"\n"
using namespace std;

#define prime1 1000000007
#define prime2 998244353

lli modadd(lli n,lli m , lli mod){
    lli sum = ((n+m)%mod+mod)%mod;
    return sum;
}

lli modsub(lli n,lli m,lli mod){
    lli diff = ((n-m+mod)%mod+mod)%mod;
    return diff;
}

lli modpro(lli n,lli m, lli mod){
    lli pro = ((n*m)%mod+mod)%mod;
    return pro;
}

lli powmod(lli x,lli y,lli mod){
    x %= mod;
    y %= mod;
    lli res = 1;
    while (y > 0) {
        if (y & 1)
            res = modpro(res , x,mod);
        y = y >> 1;
        x = modpro(x , x,mod);
    }
    return res;
}

lli moddiv(lli n,lli m,lli mod){
    //return n/m mod (mod) or n*(m)^-1 mod (mod)
    lli a = powmod(m,mod-2,mod);
    //this is because of fermats thm i.e. a^-1 = a^p-2 mod(p) check
    //multiplying p on both sides
    lli res = modpro(a,n,mod);
    return res;
}

vector<lli> prefix_function(string s) {
    lli n = (lli)s.length();
    vector<lli> pi(n);
    for (lli i = 1; i < n; i++) {
        lli j = pi[i-1];
        while (j > 0 && s[i] != s[j])
            j = pi[j-1];
        if (s[i] == s[j])
            j++;
        pi[i] = j;
    }
    return pi;
}


int main() {
	anket;
	lli k;
	cin>>k;
	lli s =0;
	ask(i,1,k+1){
	    ask(j,1,k+1){
	        ask(l,1,k+1){
	            s += __gcd(i,__gcd(j,l));
	        }
	    }
	}
	o1(s);
	return 0;
}




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

signed main() {
	int N, P;
	string S;
	cin >> N >> P >> S;

	// 例外
	if (P == 2 or P == 5) {
		long long ans = 0;
		for (int r = 0; r < N; r++) {
			if ((S[r] - '0') % P == 0) {
				ans += r + 1;
			}
		}
		cout << ans << endl;
		return 0;
	}

	// 各桁の数値のMODをとる
	vector<int> d(N+1);
	int ten = 1;
	for (int i = N - 1; i >= 0; i--) {
		int num = (S[i] - '0') * ten;
		d[i] = num % P;
		ten *= 10;
		ten %= P;
	}

	// 累積和をとる
	for (int i = N - 1; i >= 0; i--) {
		d[i] += d[i+1];
		d[i] %= P;
	}

	// 左を固定して答えを足し合わせていく
	long long ans = 0;
	map<int, int> mp;
	mp[0] = 1;
	for (int i = N - 1; i >= 0; i--) {
		ans += mp[d[i]];
		mp[d[i]]++;
	}

	cout << ans << endl;
}

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

int main(){
  char word;
  cin >> word;
  if (word == 'A') cout << 'T' << '\n';
  if (word == 'T') cout << 'A' << '\n';
  if (word == 'C') cout << 'G' << '\n';
  if (word == 'G') cout << 'C' << '\n';
  return 0;
}

Measured memory_bytes: 256
import math
a, b = list(map(int, input().split()))

c = str(a) + str(b)
c = int(c)

d = math.floor(c/4 + 1)
square = [i * i for i in range(c) if i * i == c ]

if len(square) != 0 :
    print('Yes')
else:
    print('No')




Measured memory_bytes: 9112
using System;
using System.Linq;

namespace WA055B
{
    class Program
    {
        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ').ToArray();

            var N = int.Parse(line[0]); var X = int.Parse(line[1]);

            int[] m = new int[N];

            int total = 0;

            for(var i = 0; i < N; i++)
            {
                m[i] = int.Parse(Console.ReadLine());

                total += m[i];
            }

            X -= total;

            Array.Sort(m);

            Console.WriteLine(N + (X / m[0]));
            
        }
    }
}


Measured memory_bytes: 13268
n = int(input())
a = list(map(int, input().split()))
ans = 1
a.sort()
for i in range(0, n):
    if ans * a[i] <= 1_000_000_000_000_000_000:
        ans *= a[i]
    else:
        ans = 1_000_000_000_000_000_001
        break
if ans <= 1_000_000_000_000_000_000:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 84576
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repi(i,a,b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;

int main() {
  string N;
  cin >> N;
  
  cout << "ABC"+N << endl;
}

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

int main() {
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  
  L = A + B;
  R = C + D;
    
    if(L > R){
      cout << "Left" << endl;
    }
  
    if(L == R){
      cout << "Balanced" << endl;
    }
  
    if(L < R){
      cout << "Right" << endl;
    }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
  int n,k;
  cin>>n>>k;
  long ans=0;
  vector<long>a(n);
  for(int i=0;i<n;++i)cin>>a[i];
  sort(begin(a),end(a),greater<>());
  for(int i=0;i<k;++i){
    ans+=a[i];
  }
  cout<<ans<<endl;
}


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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n;
	cin>>n;
	vector<ll> a(3*n),pf(3*n,0);
	for(ll& x:a) cin>>x;
	map<ll,ll> Map;
	int cnt=0;
	for(int i=0;i<3*n;++i)
		if(i<n){
			auto it=Map.find(a[i]);
			if(i) pf[i]=pf[i-1];
			if(it==Map.end()) Map.emplace(a[i],1);
			else it->second++;
			pf[i]+=a[i];
			cnt++;
		}
		else{
			auto it=Map.begin();
			pf[i]=pf[i-1];
			if(a[i]<=it->first) continue;
			if(cnt+1>n){
				pf[i]-=it->first;
				if(--it->second==0) Map.erase(it);
			}
			cnt++;
			it=Map.find(a[i]);
			if(it==Map.end()) Map.emplace(a[i],1);
			else it->second++;
			pf[i]+=a[i];
		}
	Map.clear();
	cnt=0;
	ll res=numeric_limits<ll>::min(),sf=0;
	for(int i=3*n-1;i>=n;--i)
		if(cnt<n){
			auto it=Map.find(a[i]);
			if(it==Map.end()) Map.emplace(a[i],1);
			else it->second++;
			sf+=a[i];
			cnt++;
			if(cnt==n) 
				res=max(res,pf[i-1]-sf);
		}
		else{
			auto it=Map.end();
			it--;
			if(a[i]>it->first) continue;
			if(cnt+1>n){
				sf-=it->first;
				if(--it->second==0) Map.erase(it);
			}
			cnt++;
			it=Map.find(a[i]);
			if(it==Map.end()) Map.emplace(a[i],1);
			else it->second++;
			sf+=a[i];
			res=max(res,pf[i-1]-sf);
		}
	cout<<res<<'\n';
}




Measured memory_bytes: 14284
#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 pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}

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

  	int n;
  	cin >> n;

  	ll s = 1;
  	for(int i = 1; i <= n; i++){
  		s *= i;
  		s %= mod;
  	}
  	cout << s << endl;
	return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    string S, T; cin >> S >> T;
    string ans = "";
    REP(i, N)
    {
        ans.push_back(S[i]);
        ans.push_back(T[i]);
    }
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        String inputA;
        String inputB;

        Scanner scanner = new Scanner(System.in);
        String inputData = scanner.nextLine();
        scanner.close();

        String[] editedInputData = inputData.split(" ");
        inputA = editedInputData[0];
        inputB = editedInputData[1];

        System.out.println(inputB + inputA);

    }
}

Measured memory_bytes: 21844
N=int(input())
A=list(map(int,input().split()))

memo={}
def dp(i,j,L,R):
    if (i,j,L,R) in memo:
        return memo[(i,j,L,R)]
    if i==j:
        memo[(i,j,L,R)]=0
        memo[(i,j,L,R)]=(L+R)*A[i]
        return (L+R)*A[i]
    elif i>j:
        return 0

    ans=10**18
    for k in range(i,j+1):
        test=dp(i,k-1,L,L+R)+dp(k+1,j,L+R,R)+A[k]*(L+R)
        ans=min(ans,test)

    memo[(i,j,L,R)]=0
    memo[(i,j,L,R)]=ans
    return ans

res=dp(1,N-2,1,1)
print(res+A[0]+A[-1])


Measured memory_bytes: 161240
#include <iostream>

using namespace std;

typedef long long ll;

int n, m;
ll dp[1005][1005];
string s[1005];
const ll mod = (int)1e9 + 7;

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for(int i = 1 ; i <= n ; ++i){
	cin >> s[i];
}
dp[1][1] = 1;
for(int i = 1 ; i <= n ; ++i){
	for(int j = 1 ; j <= m ; ++j){
		if(i > 1 && s[i - 1][j - 1] == '.'){
			dp[i][j] = (dp[i][j] + dp[i - 1][j]) % mod;
		}
		if(j > 1 && s[i][j - 2] == '.'){
			dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
		}
	}
}
cout << dp[n][m] << endl;

return 0;
}



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

using namespace std;

int main(){

    int c[3][3];
    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            cin >> c[i][j];
        }
    }

    int a[3] = {0};
    int b[3] = {0};

    for(int i = 0; i < 3; i++){
        b[i] = c[0][i] - a[0];
    }

    for(int i = 1; i < 3; i++){
        a[i] = c[i][0] - b[0];
    }

    bool valid = true;

    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            if(c[i][j] != a[i] + b[j]){
                 valid = false;
                 break;
            }
        }
    }

    if(valid){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}

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

#define REP(i,n) for(int i = 0;i<(int)n;i++)
#define FOR(i,a,b) for(int i = (a);i < (b);i++)
#define RFOR(i,a,b) for(int i = (a);i>(b);i--)

using namespace std;

int main(void){
    
    int high[100] = {0};
    int temp;
    REP(i, 10)
    cin >> high[i];
    REP(i,9)
    REP(j,9)
    {
        if(high[j] <high[j+1])
        {
            temp = high[j+1];
            high[j+1] = high[j];
            high[j] = temp;
        }
    }
    REP(i,3)
    printf("%d\n",high[i]);
    return 0;


}

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

#define ll long long
#define sz(x) (int)x.size();

using namespace std;

int n,x;
string s;
vector<pair<string,pair<int,int>>>v;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s>>x;
		v.push_back({s,{-x,i+1}});
	}
	sort(v.begin(), v.end());
	for(auto i:v){
		cout<<i.second.second<<'\n';
	}
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
const int MAX = 510000;


using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    ll x;
    cin >> n >> x;
    ll X[n];
    rep(i, n) {
        ll a;
        cin >> a;
        X[i] = abs(a - x);
    }
    ll Gcd = X[0];
    rep(i, n){
        Gcd = __gcd(Gcd, X[i]);
    }
    cout << Gcd << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

class UnionFind {
    struct UFNode {
        int par;
        int rank;
    };
    vector<UFNode> nodes;
public:
    UnionFind(int n): nodes(n) {
        for (int i = 0; i < n; i++) {
            nodes[i].par = i;
            nodes[i].rank = 0;
        }
    };
    int root(int x) {
        return nodes[x].par == x ? x : root(nodes[x].par);
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    void unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (nodes[x].rank < nodes[y].rank) {
            nodes[x].par = y;
        } else {
            nodes[y].par = x;
            if (nodes[x].rank == nodes[y].rank) nodes[x].rank++;
        }
    }
    //~UnionFind() {cout << nodes.size() << endl;}
};

void solve() {
    int n,m,k,l;
    cin >> n >> m;
    VVI c(m);
    REP(i,0,n) {
        cin >> k;
        REP(j,0,k) {
            cin >> l;
            c[l-1].push_back(i);
        }
    }
    UnionFind uf(n);
    REP(i,0,m) {
        REP(j,1,c[i].size()) uf.unite(c[i][0], c[i][j]);
    }
    REP(i,1,n) if (!uf.same(0,i)) {
        cout << "NO" << endl;
        return;
    }
    cout << "YES" << endl;
    return;
}

int main() {
    solve();
    
    return 0;
}
// 18:35-

Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int keisansu;
   
  cin >> keisansu;
  
  int a;
  int b;
  int count=0;
  for (int i = 0; i < keisansu; i++) {
    cin >> a;
    cin >> b;
    count+=b-a+1;

  }
  cout<<count;;
}

Measured memory_bytes: 3584
#include <stdio.h>
#include <cmath>
#include <algorithm>

#define NUM 1100000

int main(){
	int limit;
	int* table = new int[NUM];

	for(int i=0; i < NUM;i++)table[i] = 1;
	table[0] = 0;
	table[1] = 0;

	limit = sqrt(NUM);

	for(int i=2;i<=limit;i++){
		if(table[i] == 1){
			for(int k=2*i;k < NUM; k += i){
				table[k] = 0;
			}
		}
	}

	int n,count;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		count = 0;
		for(int i=2; i<= (n/2); i++){
			if(table[i] == 1 && table[n-i] == 1)count++;
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 6916
n,a,b = map(int,input().split())
ans = 0
c = n % (a + b)

if a == 0 and b == 0:
    print(0)
else:
    ans = int(n / (a + b)) * a
    if 0 <= c <= a:
        print(ans + c)
    elif a <= c <= a + b:
        print(ans + a)
    else:
        print("What??")


Measured memory_bytes: 3060
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

int main() {
  ios::sync_with_stdio(false);
  ll N, K;
  cin >> N >> K;
  vector<PL> ns(N);
  FOR(n,ns) {
    cin >> n.first >> n.second;
  }
  ll ans = 0;
  FOR(n,ns) {
    if((n.first | K) == K) {
      ans += n.second;
    }
  }
  for(ll p=1; p <= K; p <<= 1) {
    if(!(p & K)) {
      continue;
    }
    ll k = (K ^ p) | (p - 1);
    ll v = 0;
    FOR(n,ns) {
      if((n.first | k) == k) {
        v += n.second;
      }
    }
    ans = max(ans, v);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
import math

takahashi_hp, t_atack, aoki_hp, a_attack = map(int, input().split())

t_atk_count = aoki_hp / t_atack
a_atk_count = takahashi_hp / a_attack

if math.ceil(a_atk_count) >= math.ceil(t_atk_count):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9052
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
using namespace std;
int n;
int A[105];
int ans;
int bubbleSort(int A[],int n){
    ans = 0;
    bool flag=1;
    for(int i=0;flag;i++){
    flag=0;
    for(int j=n-1;j>=i+1;j--){
     if(A[j]<A[j-1]){
         swap(A[j],A[j-1]);
         flag=1;
         ans++;
     }    
    }    
}
    return ans;
}
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&A[i]);
    }
    ans=bubbleSort(A,n);
    for(int i=0;i<n;i++){
        if(i){
            printf(" ");
        }
    printf("%d",A[i]);
    }
    printf("\n%d\n",ans);
    return 0;
}


Measured memory_bytes: 3220
/*
    Friday | 24 July 2020
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define TryUntillAC ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
int main(){
    TryUntillAC
    ll n; cin>>n;
    if(n >= 400 and n < 600)
    {
        cout<<"8";
    }
    else if (n >= 600 and n < 800)
    {
        cout << "7";
    }
    else if (n >= 800 and n < 1000)
    {
        cout << "6";
    }
    else if (n >= 1000 and n < 1200)
    {
        cout << "5";
    }
    else if (n >= 1200 and n < 1400)
    {
        cout << "4";
    }
    else if (n >= 1400 and n < 1600)
    {
        cout << "3";
    }
    else if (n >= 1600 and n < 1800)
    {
        cout << "2";
    }
    else if (n >= 1800 and n < 2000)
    {
        cout << "1";
    }
}

Measured memory_bytes: 3648
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>
#include <cmath>

int N, L;
char direc[100][10];
int posion[100];
int posionnow[201];
int main()
{
	using namespace std;

	while (true)
	{
		cin >> N >> L;
		if (N == 0 && L == 0) {
			break;
		}

		for (int i = 0; i < N; i++)
		{
			cin >> direc[i] >> posion[i];
		}

		int time = 0;
		int count = 0;
		int nowover = -1;
		while (count < N) {
			++time;

			nowover = -1;
			for (int i = 0; i < 201; i++)
			{
				posionnow[i] = -1;
			}

			for (int i = 0; i < N; i++)
			{
				if ((posion[i] <= 0 || posion[i] >= L)) {
					continue;
				}

				if (direc[i][0] == 'L') {
					--posion[i];
				}
				else {
					++posion[i];
				}

				if (posionnow[posion[i]] != -1) {
					if (direc[i][0] == 'L') {
						direc[i][0] = 'R';
						direc[posionnow[posion[i]]][0] = 'L';
					}
					else {
						direc[i][0] = 'L';
						direc[posionnow[posion[i]]][0] = 'R';
					}

				}
				else {
					posionnow[posion[i]] = i;
				}

				if ((posion[i] <= 0 || posion[i] >= L)) {
					++count;
					if (nowover == -1 || direc[nowover][0] == 'R') {
						nowover = i;
					}
				}
			}

		}
		cout << time << ' ' << nowover + 1 << endl;
	}
	return 0;

}


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

int main()
{
    ll D, N; cin >> D >> N;
    //cout << "D = " << D << ",N = " << N << endl;
    if (N == 100) N = 101;
    ll ans = 0;
    if (D == 0) {
        ans = N;
        cout << ans << endl;
    }
    else if (D == 1) {
        ans = 100 * N;
        cout << ans  << endl;
    }
    else if (D == 2) {
        ans = 100 * 100 * N;
        cout << ans << endl;
    }


}


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

int main(){
    int n,m;
    m=1;
    int ans=0;
    cin>>n>>m;
    if(n>=m){cout<<0<<endl;return 0;}
    int b[m];
    for(int i=0;i<m;i++){
        cin>>b[i];
    }
    sort(&b[0],&b[m]);
    for(int i=0;i<m-1;i++){
        b[i]=b[i+1]-b[i];
    }
    sort(b,&b[m-1]);
    for(int i=0;i<(m-n);i++)ans+=b[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {
    public static void main(String [] args) {
        Scanner sc = new Scanner(System.in);
        long X, Y;
        X = sc.nextLong();
        Y = sc.nextLong();
        //B=sc.nextInt();
        long num = 1, num2 = X;
        while (true) {
            num2 *= 2;
            if (num2 <= Y) num++;
            else break;
        }
        System.out.println(num);
    }
}

Measured memory_bytes: 21844
n = int(input())
H = list(map(int,input().split()))
H.append(0)
count = 0
while max(H) != 0:
    for i in range(n):
        if H[i] != 0 and H[i+1] != 0:
            H[i] -= 1
        elif H[i] != 0 and H[i+1] == 0:
            H[i] -= 1
            count += 1
        else:
            continue
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
int main()
{
	int n,a[100001],c=0,i;
	cin>>n;
	for (i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	a[0]=a[1];
	a[n+1]=a[n];
	for (i=1;i<=n;i++)
	{
		if (a[i]==i)
		{
			c++;
			if (a[i+1]!=i)
			{
				swap(a[i+1],a[i]);
			}
			else
			{
				swap(a[i-1],a[i]);
			}
		}
	}
	cout<<c<<endl;
	return 0;
}

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

int n;
int r,c,q;
int r1,c1,r2,c2;
int tmp;
vector<int> seg[1000];

int query(int x, int a, int b, int k, int l, int r){
  if(r<=a || b<=l)return (1<<31) - 1;
  if(a<=l && r<=b)return seg[x][k];
  else{
    return min(query(x,a,b,2*k+1,l,(l+r)/2),query(x,a,b,2*k+2,(l+r)/2,r));
  }
}

int main(){
  while(1){
    cin >> r >> c >> q;
    if(!r && !c && !q)break;

    if(r>=c){
      n = 1;
      while(n<r)n *= 2;
      for(int i=0;i<c;i++){
	seg[i].clear();
	for(int j=0;j<2*n-1;j++)seg[i].push_back( (1<<31)-1 );
      }
      for(int i=0;i<r;i++){
	for(int j=0;j<c;j++){
	  cin >> tmp;
	  int k = i;
	  k += n-1;
	  seg[j][k] = tmp;
	  while(k>0){
	    k = (k-1) / 2;
	    seg[j][k] = min(seg[j][k*2+1], seg[j][k*2+2]);
	  }
	}
      }
      while(q--){
	cin >> r1 >> c1 >> r2 >> c2;
	int ans = (1<<31) - 1;
	for(int i=c1;i<=c2;i++)ans = min(ans,query(i,r1,r2+1,0,0,n));
	cout << ans << endl;
      }
    }else{
      n = 1;
      while(n<c)n *= 2;
      for(int i=0;i<r;i++){
	seg[i].clear();
	for(int j=0;j<2*n-1;j++)seg[i].push_back( (1<<31)-1 );
      }
      for(int i=0;i<r;i++){
	for(int j=0;j<c;j++){
	  cin >> tmp;
	  int k = j;
	  k += n-1;
	  seg[i][k] = tmp;
	  while(k>0){
	    k = (k-1) / 2;
	    seg[i][k] = min(seg[i][k*2+1], seg[i][k*2+2]);
	  }
	}
      }
      while(q--){
	cin >> r1 >> c1 >> r2 >> c2;
	int ans = (1<<31) - 1;
	for(int i=r1;i<=r2;i++)ans = min(ans,query(i,c1,c2+1,0,0,n));
	cout << ans << endl;
      }
    }
  }
}

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

ll N,M;
struct edge {
    ll from;
    ll to;
    ll cost;
};
edge edges[2000];
ll dist[2000];
const ll INF = 2000000000000;

int main() {
    std::cin >> N>>M;
    for (int i = 0; i < M; i++) {
        std::cin >> edges[i].from>>edges[i].to>>edges[i].cost;
        edges[i].from-=1;
        edges[i].to-=1;
        edges[i].cost = -edges[i].cost;
    }
    for (int i = 0; i < N; i++) {
        dist[i]=INF;
    }
    dist[0]=0;
    for (int j = 0; j < N-1; j++) {
        for (int i = 0; i < M; i++) {
            dist[edges[i].to]=min(dist[edges[i].to],dist[edges[i].from]+edges[i].cost);
        }
    }
    ll goal = dist[N-1];
    for (int i = 0; i < M; i++) {
        dist[edges[i].to]=min(dist[edges[i].to],dist[edges[i].from]+edges[i].cost);
    }
    if(goal > dist[N-1]){
        std::cout << "inf" << std::endl;
    }else{
        std::cout << -goal << std::endl;
    }
    
    
}


Measured memory_bytes: 256
#include <stdio.h>

int
main(void)
{
  int n, i = 1;
  scanf("%d", &n);

  while (i <= n) {
    int x = i;
    if (x % 3 == 0) {
      printf(" %d", i);
    } else {
      while (x) {
        if (x % 10 == 3) {
          printf(" %d", i);
          break;
        }
        x = x / 10;
      }
    }
    i += 1;
  }
  printf("\n");
}

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

using namespace std;

int main()
{   
	string b;
  	cin>>b;
  	string a;
	cin>>a;
	
	int count=0;
	
	for(int i=0;i<b.size();i++)
	{	
		count=0;
		for(int j=0;j<a.size();j++)
		{
			if(a[j]==b[(i + j) % b.size()])
			{
				count++;
			}
			
		}
		if(count==a.size())
			{
				cout<<"Yes"<<endl;
				break;
			}
		if(i==(b.size()-1))cout<<"No"<<endl;
	}
	
	return 0;
}


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

int main(){
	int a, b, c, r = 0;
	cin >> a >> b >> c;
	for (int i = a; i <= b; i++) {
		if (c%i == 0) {
			r++;
		}
	}
	cout << r << endl;

	return 0;
}

Measured memory_bytes: 3092
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  int n,x;
  cin>>n>>x;
  int a[n];
  long long sum = 0;
  for(int i = 0;i<n;i++){
    int tmp;
    cin>>a[i];
  }
  long ans = 0;
  for(int i = 1;i<n;i++){
    if((a[i-1] + a[i] )>x){
      long tmp = a[i-1] + a[i] -x;
      ans += tmp;
      a[i] = a[i] - tmp;
      if(a[i] < 0){
	a[i-1] += a[i];
	a[i] = 0;
      }
    }
  }
  cout<<ans<<endl;
      
  return 0;
}


Measured memory_bytes: 640