akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll x;
	cin>>x;
	if(x>=30) cout<<"Yes";
	else cout<<"No";
	
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int cur = 0;
  while (a>0 && c>0){
    if (cur%2==0){
      c-=b;
    }
    else{
      a-=d;
    }
    cur++;
  }
  if (a>0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    string s;
    cin>>s;
    int n=s.length();
    vector<ll> dp(n,0);
    int streak=0;
    for(int i=0;i<n; ){
        if(s[i]=='A'){
            streak++;
            if(i-1>=0)dp[i]=dp[i-1];
            i++;
        }else if(i+1<n&&s[i]=='B'&&s[i+1]=='C'){
            if(i-1>=0)dp[i+1]=streak+dp[i-1];
            else dp[i+1]=streak;
            i+=2;
        }else{
            streak=0;
            if(i-1>=0)dp[i]=dp[i-1];
            i++;
        }
    }
    out(dp[n-1]);
}

Measured memory_bytes: 5152
import sys

N = int(input())



#plan=list()
success = "Yes"

(t0,x0,y0)=(0,0,0)
for i in range(N):
    (t,x,y)=map(int, input().split())
    #plan.append([t,x,y])

    d=(x-x0)+(y-y0)
    dt=t-t0
    #print(d,dt)

    if d>dt or (d % 2 != dt %2):
        success = "No"
        break
 
    (t0,x0,y0)=(t,x,y)

print(success)

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

using namespace std;

#define int long long

int n, c;
int x[100010], v[100010];
int xr[100010];
int mx[100010], mxr[100010];

main()
{
    ios_base::sync_with_stdio(false);
    cin >> n >> c;
    for(int i = 0; i < n; i++) cin >> x[i] >> v[i];
    for(int i = 0; i < n; i++) xr[n-1-i] = c - x[i];
    int sum = 0;
    int pos = 0;
    for(int i = 0; i < n; i++){
        sum = sum - (x[i] - pos) + v[i];
        mx[i] = max((i) ? mx[i-1] : 0, sum);
        pos = x[i];
    }
    sum = 0;
    pos = 0;
    for(int i = 0; i < n; i++){
        sum = sum - (xr[i] - pos) + v[n-1-i];
        mxr[i] = max((i) ? mxr[i-1] : 0, sum);
        pos = xr[i];
    }
    sum = 0;
    pos = 0;
    int an = max(mx[n-1], mxr[n-1]);
    for(int i = 0; i < n - 1; i++){
        sum = sum - 2 * (x[i] - pos) + v[i];
        int tmp = sum + mxr[n-i-2];
        an = max(an, tmp);
        pos = x[i];
    }
    sum = 0;
    pos = 0;
    for(int i = 0; i < n - 1; i++){
        sum = sum - 2 * (xr[i] - pos) + v[n-1-i];
        int tmp = sum + mx[n-i-2];
        an = max(an, tmp);
        pos = xr[i];
    }
    cout << an << endl;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    int ans = 0;

    for(int i = 1; i <= N; i += 2) {
        int count = 0;
        for(int j = 1; j <= i; j++) {
            if(i % j == 0) count++;
        }
        if(count == 8) ans++;
    }

    cout << ans << endl;
}

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

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    pair<pair<string,int>,int> pr[n];
    for(int i=0;i<n;i++){
        string str;
        int x;
        cin>>str>>x;
        pr[i].f.f=str;
        pr[i].f.s=-x;
        pr[i].s=i+1;
    }
    sort(pr,pr+n);
    for(int i=0;i<n;i++){
        cout<<pr[i].s<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <complex>
#include <set>
#include <list>
#include <iomanip>
#include <map>
#include <memory.h>
#include <functional>


using namespace std;
static const double EPS = 1e-9;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a,0,sizeof(a))
#define minus(a) memset(a,0xff,sizeof(a))
#define chmax(a,b) a=min((a),(b))
#define chmin(a,b) a=max((a),(b))


#define MOD 1000000007

typedef pair<int,int>P;
#define INF (1<<29)
 
struct edge { 
	int from, to; 
	edge (int from, int to){
		this->from=from; this->to=to;
	}
};
 
int V,E;
typedef vector<edge> edges;
vector<edges> G;

string s;

int main(){
	cin >> s;
	if (((s.size() % 2) == 0) ^ (s[0] == s[s.size() - 1]))
		cout << "Second" << endl;
	else
		cout << "First" << endl;

	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
using namespace std;

int gcd(int a, int b){
  if(b == 0) return a;
  else return gcd(b, a%b);
}

int main(){
  string s;
  cin >> s;
  char tmp = '0';
  int count1 = 0, count2 = 0;
  for(int i = 0; i < s.length(); ++i){
    if(tmp != s[i]){
      count1++;
    }
    if(tmp == '0') tmp = '1';
    else tmp = '0';
  }

  tmp = '1';
  for(int i = 0; i < s.length(); ++i){
    if(tmp != s[i]){
      count2++;
    }
    if(tmp == '0') tmp = '1';
    else tmp = '0';
  }

  cout << min (count1, count2) << endl;
}


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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int i=(first);i<(last);++i){cout<<#a<<"["<<i<<"] = "<<(a)[i]<<endl;}
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007

using namespace std;

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

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

enum ACGT { A, C, G, T };

int main(void)
{
    int N;
    cin >> N;

    ll dp3[2][4][4][4];
    ll dp2[2][4][4];
    ll dp1[2][4];
    ll dp[2];

    int n = 3;
    int m0 = n & 1;
    dp[m0] = 0;
    REP(i, 4) {
        dp1[m0][i] = 0;
        REP(j, 4) {
            dp2[m0][i][j] = 0;
            REP(k, 4) {
                bool b0 = (i == A && j == G && k == C);
                bool b1 = (i == A && j == C && k == G);
                bool b2 = (i == G && j == A && k == C);
                dp3[m0][i][j][k] = !(b0 || b1 || b2);
                dp2[m0][i][j] += dp3[m0][i][j][k];
            }
            dp1[m0][i] += dp2[m0][i][j];
        }
        dp[m0] += dp1[m0][i];
    }
    PRINT(dp[m0]);
    n++;

    char S[] = { 'A', 'C', 'G', 'T' };
    while (n <= N) {
        m0 = n & 1;
        int m1 = (n - 1) & 1;
        dp[m0] = 0;
        REP(i, 4) {
            dp1[m0][i] = 0;
            REP(j, 4) {
                dp2[m0][i][j] = 0;
                REP(k, 4) {
                    bool b0 = (i == A && j == G && k == C);
                    bool b1 = (i == A && j == C && k == G);
                    bool b2 = (i == G && j == A && k == C);
                    if (b0 || b1 || b2) {
                        dp3[m0][i][j][k] = 0;
                    } else if (i == A && k == G) {
                        dp3[m0][i][j][k] = (MOD + dp2[m1][j][k] - dp3[m1][j][k][C]) % MOD;
                    } else if (i == A && j == G) {
                        dp3[m0][i][j][k] = (MOD + dp2[m1][j][k] - dp3[m1][j][k][C]) % MOD;
                    } else {
                        dp3[m0][i][j][k] = dp2[m1][j][k];
                    }
                    dp2[m0][i][j] = (dp2[m0][i][j] + dp3[m0][i][j][k]) % MOD;
                }
                dp1[m0][i] = (dp1[m0][i] + dp2[m0][i][j]) % MOD;
            }
            dp[m0] = (dp[m0] + dp1[m0][i]) % MOD;
        }
        PRINT(dp[m0]);
        n++;
    }
    cout << dp[N & 1] << endl;

    return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    x,y = map(int, input().split())
    a = [1, 3, 5, 7, 8, 10, 12]
    b = [4, 6, 9, 11]
    c = [2]
    if x in a and y in a:
        print ("Yes")
        exit()
    if x in b and y in b:
        print ("Yes")
        exit()
    if x in c and y in c:
        print ("Yes")
        exit()
    print ("No")


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

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

  int ki = 0,gu = 0,yo = 0;
  for(int i = 0;i < n;i++){
    if(a[i] % 2 == 1){
      ki++;
    }else{
      if(a[i] % 4 == 0){
        yo++;
      }else{
        gu++;
      }
    }
  }

  if(ki-yo >= 2){
    cout << "No" << endl;
    return 0;
  }else{
    if(ki-yo == 1){
      if(gu == 0){
        cout << "Yes" << endl;
      }else{
        cout << "No" << endl;
      }
      return 0;
    }
  }

  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 640
n,m = map(int,input().split())
b = [0]*m
for i in range(n):
    a = list(map(int,input().split()))
    for j in a[1:]:
        b[j-1] += 1

cnt = 0
for i in range(m):
    if b[i] == n:
        cnt += 1
print(cnt)

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

queue <string> Q;
     
int main() {

  string str;

  cin >> str;


  int count = 0;

  int m = str.size();
  int ic=0,cc[2]={},wc=0;
  for(int i=0;i<str.size();i++) {
    if(str[i] == '(' && str[m-1-i] != ')'){
      if(m-1-i == i) {
	str[m-1-i] = 'i';
	count++;
	continue;
      }
      str[m-1-i] = ')';
      count++;
    }
    
    if(str[i] == 'w' && str[m-1-i] != 'w'){
      str[m-1-i] = 'w';
      count++;
    }
    if(str[i] == 'i' && str[m-1-i] != 'i') {
      str[m-1-i] = 'i';
      count++;
    }

  }

  for(int i=m-1;i>=0;i--) {
    if(str[i] == ')' && str[m-i-1] != '(') {
      if(m-1-i == i) {
	str[m-i-1] = 'i';
	count++;
	continue;
      }
      str[m-i-1] = '(';
      count++;
    }
  }

  cout << count << endl;

  return 0;

}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using vp = vector<pii>;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) (ll)((x).size())
#define all(x) (x).begin(), (x).end()
#define each(a, x) for (auto&& a : (x))
#define _overload3(_1, _2, _3, name, ...) name
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) for (ll i = (a); i < (n); ++i)
#define rep(...) _overload3(__VA_ARGS__, rep3, rep2, rep1)(__VA_ARGS__)
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
template<typename T> inline void print(const T& x) {cout << x << "\n";}
template<typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template<typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
struct Init {Init() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(10);}} init;

int main() {
    ll k; cin >> k;
    if (k % 2 == 0 || k % 5 == 0) {
        print(-1);
        return 0;
    }
    ll l = 9 * k;
    if (k % 7 == 0) l /= 7;
    vi table(10000000, 0);
    ll i = 1;
    ll a = 10;
    while (true) {
        a %= l;
        if (a == 1) {
            print(i);
            break;
        }
        else if (table[a] == 0) {
            table[a] = 1;
        }
        else {
            print(-1);
            break;
        }
        a *= 10;
        i++;
    }
}

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

int main()
{
	int n;
	cin >> n;
	vector<ll> t(n);
	for(int i = 0;i<n;i++)cin >> t[i];

	ll ans  = 1;
	for(int i = 0;i<n;i++)
	{
		ans =ans/ __gcd(t[i],ans)*t[i];
	}
	cout << ans << endl;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 mrand(chrono::steady_clock::now().time_since_epoch().count());
#define ii for(int i=1;i<=n;++i)
#define ji for(int j=1;j<=n;++j)
#define jj for(int j=1;j<=m;++j)
#define ij for(int i=1;i<=m;++i)
#define sz(x) ((ll)x.size())
#define all(x) x.begin(),x.end()
#define alll(x) x+1,x+1+n
#define asd cout<<"ok"<<endl;
#define endl '\n'

map<pair<string,string>,int> mp;
int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    string s1 = s.substr(0, n);
    string s2 = s.substr(n);
    reverse(all(s2));
    ll ans = 0;
    for(int i=0;i<1<<n;++i) {
        string t1, t2;
        for(int j=0;j<n;++j) if(i&(1<<j)) t1+=s1[j];else t2+=s1[j];
        mp[{t1,t2}]++;
    }
    for(int i=0;i<1<<n;++i) {
        string t1, t2;
        for(int j=0;j<n;++j) if(i&(1<<j)) t1+=s2[j];else t2+=s2[j];
        if(mp[{t1,t2}]) ans += mp[{t1,t2}];
    }
    cout << ans << endl;
}


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

int main(){
    int N,W;
    cin >> N >> W;

    int v[N],w[N];
    for(int i=0;i<N;i++)    cin >> v[i] >> w[i];

    int dp[N+1][W+1];
    for(int i=0;i<=W;i++)    dp[0][i] = 0;

    for(int i=1;i<=N;i++){
        for(int j=0;j<=W;j++){
            if(j<w[i-1]){
                dp[i][j] = dp[i-1][j];
            }else{
                dp[i][j] = max(dp[i-1][j],dp[i][j-w[i-1]]+v[i-1]);
            }
        }
    }

    cout << dp[N][W] << endl;

    return 0;
}


Measured memory_bytes: 7032
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();

        if( a % b == 0) {

          	System.out.println(a / b);
        } else {
      
        	System.out.println(a / b + 1);
    	}
    }
}


Measured memory_bytes: 21972
import java.util.*;
import java.util.regex.*;
import static java.lang.Math.*;
import static java.lang.System.out;

// AOJ5
public class Main {
	final Scanner sc=new Scanner(System.in);
	final int[] vx={0,1,0,-1}, vy={-1,0,1,0};
	static class Point{
		int x, y;
		Point(int x, int y){	this.x=x;	this.y=y;}
		Point(){	this.x=0; this.y=0;}
		@Override public String toString(){	return "("+this.x+","+this.y+")";}
		static boolean ok(int x,int y,int X,int Y,int min){	return (min<=x&&x<X)&&(min<=y&&y<Y);}
		static boolean ok(int x,int y,int X,int Y){	return ok(x,y,X,Y,0);}
	}
	public static void main(String[] args) {
		new Main().AOJ1154();
	}
	
	void AOJ1154(){
		final int MAX=300000;
		boolean[] list=list(MAX);
		//debug
		//for(int i=6; i<=MAX; i++)	if(list[i])	out.print(" "+i);
		//out.println();
		while(sc.hasNext()){
			int n=sc.nextInt();
			if(n==1)	break;
			out.print(n+":");
			for(int i=6; i<=n; i+=7){
				if(list[i] && n%i==0)	out.print(" "+i);
				if(list[i+2] && n%(i+2)==0)	out.print(" "+(i+2));
			}
			out.println();
		}
	}
	boolean[] list(int MAX){
		boolean[] b=new boolean[MAX+1];
		Arrays.fill(b, false);
		for(int i=6; i<=MAX; i+=7){
			b[i]=true;	b[i+2]=true;
		}
		for(int i=6; i<=MAX; i+=7){
			if(b[i])	for(int j=i+i; j<=MAX; j+=(i))	b[j]=false;
			if(b[i+2])	for(int j=i+i+4; j<=MAX; j+=(i+2))	b[j]=false;
		}
		return b;
	}
	
	void A(){
		while(true){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if(n == 0 && m == 0){
				break;
			}
			int [] taro = new int[n];
			int [] hanako = new int[m];
			int sum1 = 0,sum2 = 0;
			for(int i = 0; i < n; i++){
				taro[i] = sc.nextInt();
				sum1 += taro[i];
			}
			for(int i = 0; i < m ;i++){
				hanako[i] = sc.nextInt();
				sum2 += hanako[i];
			}
			Arrays.sort(taro);
			Arrays.sort(hanako);
			boolean flg = true;
			for(int i =0; i < n ;i++){
				for(int j = 0; j < m; j++){
					int temp1 = sum1 - taro[i] + hanako[j];
					int temp2 = sum2 - hanako[j] + taro[i];
					if(temp1 ==  temp2){
						flg = false;
						System.out.println(taro[i] + " " + hanako[j]);
						break;
					} 
				}
				if(! flg){
					break;
				}
			}
			if(flg){
				System.out.println(-1);
			}
		}
		
	}
}

Measured memory_bytes: 13000
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define rep(I,N) for(int I = 0; I < (int)(N); I++)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);


int main(void){
	int w, n;
	cin >> w >> n;
	vector<int> v;
	rep(i, w){
		v.pb(i+1);
	}
	rep(i, n){
		int a,b;
		char c;
		cin >> a >> c >> b;
		swap(v[a-1], v[b-1]);
	}
	rep(i, v.size()){
		FIN(v[i]);
	}

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

Measured memory_bytes: 1224
#include<stdio.h>
#include<string.h>
int main(){
char ch;
while(1){
scanf("%c",&ch);
if(ch=='\n'){
printf("\n");
break;
}
if(ch>='a' && ch<='z') printf("%c",toupper(ch));
else if(ch>='A' && ch<='Z') printf("%c",tolower(ch));
else printf("%c",ch);
}
return 0;
}

Measured memory_bytes: 524
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>

using namespace std;

#define MAX 1000001

vector<int> vprimes;
bool *isPrime = new bool[MAX];

/* ツ素ツ青板青カツ青ャ O(n^2) */
void MakePrime(){
  isPrime[0]=false;
  isPrime[1]=false;
  isPrime[2]=true;
  for(int i = 2; i < MAX; ++i){
    isPrime[i] = true;
  }
  for(long long int i = 2; i < MAX; ++i){
    if( isPrime[i] ){
      for(long long int j = 2; i * j < MAX; ++j) {
	isPrime[i*j] = false;
      }
    }
  }
  for(int i = 0; i < MAX; ++i){
    if( isPrime[i] ){
      vprimes.push_back( i );
    }
  }
}

int main()
{
  MakePrime();
  int N,P;
  while(cin>>N>>P&&(N>=0)&&(P>=0)){
    vector<int> v;
    vector<int> primes;
    for(int i = 0; i < vprimes.size(); ++i){
      if(vprimes[i]>N){
	primes.push_back(vprimes[i]);
      }
    }
    for(int i = 0; i < primes.size(); ++i){
      for(int j = i; j < min(2*P,(int)primes.size()); ++j){
	v.push_back(primes[i]+primes[j]);
      }
    }
    sort(v.begin(),v.end());
    cout << v[P-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 2964
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

int main()
{
    int n;
    cin >> n;
    cout << n*n*n << endl;
    return 0;
}

Measured memory_bytes: 256
from operator import add

N, M, X = map(int, input().split(' '))

book_list = []
check = {}

for i in range(N):
    book_list.append(input().split(' '))


def search_min_cost(cost, skill, i):

    # スキルが超えていたらそれ以上は投資する必要がない
    if all([x >= X for x in skill]):
        return cost

    # もう本がない場合
    if len(book_list) == i:
        return -1

    book = book_list[i]

    book_cost = int(book[0])
    book_skill = list(map(int, book[1:]))

    # 本を使った後のスキル結果
    use_skill = list(map(add, skill, book_skill))
    use_cost = search_min_cost(cost + book_cost, use_skill, i + 1)

    # この本は使わなかった場合
    no_use_cost = search_min_cost(cost, skill, i+1)

    if use_cost == -1:
        return no_use_cost

    if no_use_cost == -1:
        return use_cost

    if use_cost > no_use_cost:
        return no_use_cost

    return use_cost


cost = search_min_cost(0, [0] * M, 0)
print(cost)


Measured memory_bytes: 9312
import java.util.Scanner;

class Main{
   
 public static void main(String... args){
      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int W = sc.nextInt();

      //dp[i] = maximum value by having exact weight of i.
      long[] dp = new long[W+1];
      for(int i = 0; i < N; i++){
        int weight = sc.nextInt();
        int value = sc.nextInt();
        for(int wt = W; wt >= 0; wt--){
          if(wt >= weight){
          	dp[wt] = Math.max(dp[wt], dp[wt - weight] + value);
          }
        }
      }
   
   	  //long ans = 0;
      //for(int i = 0; i <= W; i++){
      //	ans = Math.max(ans, dp[i]);
      //}
      System.out.println(dp[W]);
   
      if(sc != null)
        sc.close();
  }
}


Measured memory_bytes: 21972
from collections import defaultdict
D = defaultdict(int)
N = int(input())
M = 0
for i in range(N):
    s = input()
    D[s] += 1
    M = max(M,D[s])
ans = []
for i in D:
    if D[i] == M:
        ans.append(i)
ans.sort()
for i in ans:
    print(i)

Measured memory_bytes: 95524
n,d=map(int, input().split())

arr=[]
for i in range(n):
  arr.append(list(map(int,input().split())))

cnt = 0
for i, x in enumerate(arr[:-1]):
  for y in arr[i+1:]:
    sum_=sum([(x[k]-y[k])**2 for k in range(d)])**0.5
    if float(sum_).is_integer():
      cnt += 1
print(cnt)

Measured memory_bytes: 3064
N = gets.chomp.to_i
spots = gets.chomp.split(" ").map(&:to_i)

spots.unshift(0).push(0)

sum = 0
spots.inject { |prev, spot| sum += (spot - prev).abs; spot }

(1..N).each do |i|
  from = spots[i-1]
  current = spots[i]
  to = spots[i+1] 
  puts sum - (((to - current).abs + (current - from).abs) - (to - from).abs)
end


Measured memory_bytes: 12548
N = int(input())
S,T = input().split()

# N = 6
# S = 'abcabc'
# T = 'hogeho'


ls = list(S)
lt = list(T)
answer = []
for i in range(N):
    answer.append(ls[i])
    answer.append(lt[i])

print(''.join(answer))

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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

// pos[i][j] : マスiから初めたときにj回目のステップで得られる報酬の総和(1周分しか見ない，1周は必ず5000未満となるため)
int poscnt[5050];
ll pos[5050][5050];

ll N, K;
ll P[5050], C[5050];

vector<int> g[5050];

void dfs(int s, int v) {
    for (auto u : g[v]) {
        if (s == u) {
            // スタート地点まで戻ってきた
            pos[s][poscnt[s]+1] += pos[s][poscnt[s]] + C[s];
            poscnt[s]++;
            return;
        }
        else {
            pos[s][poscnt[s]+1] += pos[s][poscnt[s]] + C[u];
            poscnt[s]++;
            dfs(s, u);
        }
    }
}

int main() {
    cin >> N >> K;
    ll ans = 0;
    rep(i, N) {
        cin >> P[i];
        P[i]--;
        g[i].push_back(P[i]);
    }
    rep(i, N) {
        cin >> C[i];
        if (i == 0) ans = C[i];
        else ans = max(ans, C[i]);
    }

    rep(i, N) {
        dfs(i, i);
    }


    rep(i, N) {
        // i回目からスタートしたとき
        int cnt = min(K+1, poscnt[i]+1LL);
        rep(j, cnt) {
            // jステップ(+poscnt[i]*X)後の地点
            if (j > K) break;
            if (j == 0) {
                continue;
            }
            else  {
                ans = max(ans, pos[i][j] + max(0LL, pos[i][poscnt[i]]*((K-j)/poscnt[i])));
            }
        }
    }

    // rep(i, N) {
    //     cout << i << "->" << endl;
    //     rep(j, poscnt[i]+1) {
    //         cout << pos[i][j] << ", ";
    //     }
    //     cout << endl << endl;
    // }
    cout << ans << endl;
}


Measured memory_bytes: 201656
package main

import (
	"fmt"
)

func main() {
	in := ""
	fmt.Scanf("%s", &in)
  i := ([]byte(in))[0]
	if 'a' <= i && i <= 'z' {
		fmt.Println("a")
	} else {
		fmt.Println("A")
	}
}

Measured memory_bytes: 1836
#include <cstdio>
#include <cmath>
using namespace std;

int main()
{
  long long S;
  scanf("%lld",&S);
  long long r=(long long)(sqrt((long double)S)+1-1e-5);
  printf("%lld %lld %lld %lld %lld %lld\n",0ll,0ll,r,1ll,r*r-S,r);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <map>
using namespace std;

#define INF 1e9
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int gcd(int a, int b) {
    if(a % b == 0) {
        return b;
    }
    else {
        return(gcd(b, a % b));
    }
}


int main() {
    ll a, b, x;
    cin >> a >> b >> x;
    ll mini, maxi;
    if (a == 0) mini = -1;
    else mini = (a - 1) / x;
    maxi = b / x;
    cout << maxi - mini << endl;
}

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

int main()
{
	int  A = 10, B = 11, C = 12, D = 13, E = 14, F = 15;
	char x, y;
	cin >> x >> y;
	if (x > y) { cout << ">"; }
	else if (x < y) { cout << "<"; }
	else { cout << "="; }
    return 0;
}



Measured memory_bytes: 256
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
#pragma comment("-Wl,--stack=1024000000")
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#define eprintf(...) 0
#else
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#endif
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n,a[100005];
char c[100005];
int dp[100005][2];
int suf[100005];
inline int f(char x){
	return x=='+'?1:-1;
}
signed main(){
	cin>>n;cin>>a[1];
	for(int i=2;i<=n;i++){
		cin>>c[i]>>a[i];
	}
	for(int i=n;i>=1;i--)suf[i]=suf[i+1]+abs(a[i]);
	memset(dp,0xf7,sizeof dp);
	dp[1][0]=a[1];
	for(int i=2;i<=n;i++){
		dp[i][0]=max(dp[i-1][0]+f(c[i])*a[i],dp[i-1][1]+f(c[i])*a[i]);
		dp[i][1]=dp[i-1][1]-f(c[i])*a[i];
		if(c[i]=='-')dp[i][1]=max(dp[i][1],dp[i-1][0]+f(c[i])*a[i]);
	}
	ll ans=dp[n][0];
	for(int i=2;i<=n;i++)if(c[i]=='-')ans=max(ans,dp[i-1][1]+suf[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3456
import java.util.Scanner;
 
public class Main {

	public static final MyScanner in = new MyScanner();

	public static void main(String[] args) {

		int m1 = in.nextInt();
		in.nextInt();
		int m2 = in.nextInt();

		System.out.println(m1 == m2 ? 0 : 1);
	}

	public static class MyScanner{
		Scanner sc = new Scanner(System.in);
		String nextLine() {return sc.nextLine();}
		String next() {return sc.next();}
		int nextInt() {return Integer.valueOf(sc.next());}
		long nextLong() { return Long.valueOf(sc.next());}
	}
}

Measured memory_bytes: 22996
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	sort(h.begin(), h.end());
	long sum = 0;
	for (int i = 0; i < n - k; i++) {
		sum += h[i];
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 1024
n = gets.to_i
xys = n.times.map { gets.split.map(&:to_i) }

routes = [*0..n - 1].permutation
ans = 0

routes.each do |r|
  (n - 1).times do |i|
    a = r[i]
    b = r[i + 1]
    ans += Math.sqrt((xys[a][0] - xys[b][0])**2 + (xys[a][1] - xys[b][1])**2)
  end
end

puts ans / routes.count


Measured memory_bytes: 2172
import java.util.*;

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

    int n = sc.nextInt();

    String ans = "APPROVED";

    for(int i = 0; i < n; i++){
      int a = sc.nextInt();

      if((a % 2 == 0) && (a % 6 != 0) && (a % 10 != 0)){
        ans = "DENIED";
        break;
      }
    }

    System.out.println(ans);
  }
}

Measured memory_bytes: 21716
n = int(input())
#A = list(map(int, input().split()))
#l, r, d = map(int, input().split())
A = [0]*70000

for x in range(1,100):
  for y in range(1,100):
    for z in range(1,100):
      t = x*x + y*y + z*z +x*y + y*z + z*x
      A[t] += 1

for i in range(1,n+1):
  print(A[i])
                    

Measured memory_bytes: 9708
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	int N;
	cin>>N;
	if(N==1){
		cout<<"Hello World"<<endl;
	}
	else{
		int A,B;
		cin>>A>>B;
		cout<<A+B<<endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
    int y, m, d;
    scanf("%d/%d/%d", &y, &m, &d);

    string ans = "TBD";
    if (y < 2019)
        ans = "Heisei";
    else if (y == 2019 && m <= 4)
        ans = "Heisei";

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
int n,k;
long long sum=0,mx=0;
cin>>n>>k;
vector<double>dp(n);
for (int i=0;i<n;i++)
{
    long long a;
    cin>>a;
    dp[i]=a+1;
    sum+=dp[i];
    if (i>=k-1)
    {
        if (i!=k-1)
            sum-=dp[i-k];
         mx=max(mx,sum);
    }
 
}
cout<<fixed<<setprecision(6)<<mx/2.0;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> list(n);
  for(int i=0; i<n; i++) {
    cin >> list.at(i);
  }
  int ans = 0;
  for(int i=1; i<n-1; i++) {
    if(list.at(i) != min({list.at(i-1),list.at(i),list.at(i+1)})) {
      if(list.at(i) != max({list.at(i-1),list.at(i),list.at(i+1)})) {
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String b = sc.next();
      if(b.contains("A")){
        System.out.println(b.replace("A","T"));
      }if(b.contains("T")){
        System.out.println(b.replace("T","A"));
      }if(b.contains("C")){
        System.out.println(b.replace("C","G"));
      }if(b.contains("G")){
        System.out.println(b.replace("G","C"));
      }
    }
}

Measured memory_bytes: 35612
//INCLUDE
//------------------------------------------
#include <bits/stdc++.h>
//DEFINE
//------------------------------------------
#define ll long long
#define ld long double
#define ALLv(a)  (a).begin(),(a).end()
#define ALL(a,n)  (a),(a)+n
#define vi vector<long long>
#define vd vector<long double>
#define vs vector<string>
//CONST
//------------------------------------------
#define INF 1010000000000000017LL
#define MOD 1000000007LL
#define EPS 1e-12
#define PI 3.14159265358979323846
//REPEAT
//------------------------------------------
#define   FOR(i,m,n) for(ll (i)=(m);   (i)<(n);  (i)++)
#define   REP(i,n)   for(ll (i)=0;     (i)<(n);  (i)++)
#define  REPS(i,x)   for(ll (i)=1;     (i)<=(x); (i)++)
#define  RREP(i,x)   for(ll (i)=(x)-1; (i)>=0;   (i)--)
#define RREPS(i,x)   for(ll (i)=(x);   (i)> 0;   (i)--)
#define  WREP(i,in,j,jn) REP(i,in)REP(j,jn)
//-----------------------------------------
#define ifYN(x) cout<<(x?"Yes":"No")<<"\n" 
#define dcml(n) fixed<<setprecision(n)

 
ll GCD(ll a,ll b) { return b ? GCD(b,a%b) : a; } 
ll LCM(ll a,ll b) { return a/GCD(a,b)*b; } 
ll Factorial(ll n){ ll m=1;while(n>=1)m*=n--;return m; } 
ll modPow(ll x,ll n,ll mod=MOD){ 
    return (!n?1:!n%2?modPow(x*x,n/2,mod)%mod:x%mod*modPow(x,n-1,mod)%mod); 
} 
ll GetDigit(ll num){ 
    ll digit=0; 
    while(num!=0){num/=10;digit++;} 
    return digit; 
} 


using namespace std;
//-------------------------------------------
typedef pair<ll,ll> P;
struct Edge{
  ll to,dist;
};
ll N;
ll d[2000];
vector<Edge> G[2000];

void dijkstra(ll u){
  REP(i,N)d[i]=INF;
  priority_queue<P,vector<P>,greater<P>> que;
  que.push({0,u});
  while(!que.empty()){
    auto r=que.top();que.pop();
    if(r.first>=d[r.second])continue;
    d[r.second]=r.first;
    
    for(Edge& e: G[r.second]){
      ll dist=d[r.second]+e.dist;
      if(dist>=d[e.to])continue;
      que.push({dist,e.to});
    }
  }
}

int main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll A,B;cin>>A>>B;
  if(A<10&&B<10)cout<<A*B;
  else cout<<-1;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const int INF=1e9;
int n,m;
int col[5001][5001];
int slt[5001][5001];
int cnt[5001][5001];
int main(){
	scanf("%d%d",&n,&m);
	REP(i,m){
		int a,b,x;
		scanf("%d%d%d",&a,&b,&x);a--;b--;
		col[b][a]++;col[b][a+x+1]--;
		slt[b][a-b]++;slt[b+x+1][a-b]--;
	}
	REP(i,n)for(int j=1;j<n;j++){
		col[i][j]+=col[i][j-1];
		slt[j][i]+=slt[j-1][i];
	}
	REP(i,n)REP(j,n){
		if(col[j][i])cnt[j][i]+=col[j][i];
		if(slt[j][i])cnt[j+1][i+j]-=slt[j][i];
	}
	REP(i,n)for(int j=1;j<n;j++)cnt[j][i]+=cnt[j-1][i];
	int ans=0;
	REP(i,n)for(int j=0;j<=i;j++)if(cnt[j][i])ans++;
	cout<<ans<<endl;
}

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

bool isPrime[1500000];

void setPrime() {
	isPrime[0] = isPrime[1] = false;
	for (int i = 2; i < 1500000; i++) { isPrime[i] = true; }
	for (int i = 2; i < 1500000; i++) {
		if (isPrime[i]) {
			for (int j = i * 2; j < 1500000; j += i) {
				isPrime[j] = false;
			}
		}
	}
}

int main() {
	setPrime();
	int n;
	while (cin >> n) {
		if (!n) break;
		if (isPrime[n]) { cout << 0 << endl; continue; }
		
		int l, r;
		for (l = n - 1; !isPrime[l]; l--);
		for (r = n + 1; !isPrime[r]; r++);
		cout << r - l << endl;
	}
	return 0;
}

Measured memory_bytes: 4452
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<string>
#include<unordered_map>
#include<set>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j,k
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define sort(a) sort(a.begin(),a.end())
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define sizeoof(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll i,ans=1;rep(i,0,n)ans*=x;return ans;}
/*階乗*/ll fact(ll x){ll i,ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)/fact(r)/fact(n-r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;ll i;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
llfor;///////////////////////////////////////////////////////////
int main(){
 ll n,m;
 sc(n);sc(m);
 ll ans=0;
 //while(n!=0||m!=0){
  if(n>0){
   if(m>=n*2){
    ans+=n;
   // puts("1");pr(ans);
    m-=n*2;
   }
   else{
    ans+=m/2;
   // puts("2");pr(m/2);
    m=0;
   }
  }
  if(m/4!=0){
   ans+=m/4;
   //puts("3");pr(m/4);
   m/=4;
  }
 // else break;}
  pr(ans);
return 0;}


Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<queue>
#include<utility>
#include<functional>
#define INF 1 << 30
using namespace std;
typedef pair<int, int> PII;
typedef priority_queue<PII, vector<PII>, greater<PII> > PQ;

int root[101][101], n, k; //not use 0;

void newboat()
{
	int c, d, e;
	cin >> c >> d >> e;
	if (root[c][d] > e)	root[c][d] = root[d][c] = e;
	return;
}

int solve()
{
	int a, b;
	cin >> a >> b;
	bool though[101][101];
	int cost[101]; //not use 0;
	PQ cand;
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= n; j++) though[i][j] = false;
		cost[i] = INF;
	}

	cand.push(make_pair(0, a));
	while (!cand.empty()){
		PII now = cand.top();
		cand.pop();
		if (cost[now.second] != INF) continue;
		cost[now.second] = now.first;

		for (int i = 1; i <= n; i++){
			if (root[now.second][i] != INF && !though[now.second][i] && cost[i] == INF){
				though[now.second][i] = though[i][now.second] = true;
				cand.push(make_pair(now.first + root[now.second][i], i));
			}
		}
	}
	return (cost[b] == INF) ? -1 : cost[b];
}

int main()
{
	while (true){
		cin >> n >> k;
		if (!n && !k) break;
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= n; j++){
				root[i][j] = INF;
			}
		}
		for (int i = 0; i < k; i++){
			bool in;
			cin >> in;
			if (in) newboat();
			else cout << solve() << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1264
#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 5;

char base[ N ];
int pos[ N ];

void say_no() { puts( "-1" ); exit( 0 ); }

int main(){
	base[ 0 ] = '0'; scanf( "%s", base + 1 );
	int n = static_cast< int >( strlen( base + 1 ) );
	if ( base[ 1 ] == '0' ) say_no();
	for ( int i = 0 ; i <= n ; ++ i )
		if ( base[ i ] != base[ n - i ] )
			say_no();
	
	int len = 0;
	for ( int i = 0 ; i <= n ; ++ i ) {
		if ( base[ i ] == '0' )
			continue;
		pos[ ++ len ] = i;
	}

	for ( int i = 1 ; i <= len ; ++ i )
		printf( "%d %d\n", i, i + 1 );
	int cur = len + 1;
	for ( int i = 2 ; i <= len ; ++ i ) {
		for ( int j = 0 ; j < pos[ i ] - pos[ i - 1 ] - 1 ; ++ j )
			printf( "%d %d\n", i, ++ cur );
	}
	return 0;
}

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

const int DIM = 3e5 + 5;

priority_queue<int> prq;

int arr[DIM];
long long dp1[DIM], dp2[DIM];

int main( void ) {
    
    int n;
    cin >> n; n *= 3;
    
    for( int i = 1; i <= n; i ++ )
        cin >> arr[i];
    
    for( int i = 1; i <= n; i ++ ) {
        dp1[i] = dp1[i - 1] + arr[i];
        prq.push( -arr[i] );
        
        if( prq.size() > n / 3 ) {
            dp1[i] -= -prq.top();
            prq.pop();
        }
    }
    
    while( prq.empty() == false )
        prq.pop();
    
    for( int i = n; i >= 1; i -- ) {
        dp2[i] = dp2[i + 1] + arr[i];
        prq.push( arr[i] );
        
        if( prq.size() > n / 3 ) {
            dp2[i] -= prq.top();
            prq.pop();
        }
    }
    
    long long ans = numeric_limits<long long> :: min();
    for( int i = n / 3; i + (n / 3) <= n; i ++ )
        ans = max( ans, dp1[i] - dp2[i + 1] );
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6648
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(){
    int A,B,C;
    cin>>A>>B>>C;
    if(A==B)cout<<C<<endl;
    else if(A==C) cout<<B<<endl;
    else cout<<A<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
	string w;
	int A[1000]={};
	cin >> w;
	for (int i = 0; i < w.size(); ++i)
	{
		//cout << (int)w[i]<<endl;
		A[(int)w[i]-97]++;
	}
	for (int i = 0; i < 30; ++i)
	{
		//cout << A[i] << endl;
		if(A[i]%2==1) {
			cout <<"No"<<endl; 
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
use std::cmp::Ordering;
use std::fmt::Write;
use std::io::*;

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
struct Key<'a>(&'a str);

impl<'a> Ord for Key<'a> {
  fn cmp(&self, other: &Self) -> Ordering {
    match self.0.len().cmp(&other.0.len()) {
      Ordering::Equal => self.0.cmp(&other.0),
      other => other
    }
  }
}

impl<'a> PartialOrd for Key<'a> {
  fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
    Some(self.cmp(other))
  }
}

fn main() {
  let input = {
    let mut buf = vec![];
    stdin().read_to_end(&mut buf);
    unsafe { String::from_utf8_unchecked(buf) }
  };
  let mut lines = input.split('\n');

  let n = lines.next().unwrap().parse().unwrap();

  let mut products = std::collections::BTreeMap::new();

  for line in lines.take(n) {
    let mut iter = line.split(' ');
    let key = Key(iter.next().unwrap());
    let amount: u32 = iter.next().unwrap().parse().unwrap();

    *products.entry(key).or_insert(0) += amount;
  }

  let mut result = String::with_capacity(products.len() * 4);
  for (Key(k), v) in products {
    writeln!(result, "{} {}", k, v);
  }
  print!("{}", result);
}



Measured memory_bytes: 5048
process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', function (chunk) {
    var line = chunk.toString().split(' ');
    var menseki = line[0] * line[1];
    var syu = line[0] * 2 + line[1] * 2;
    console.log(menseki + ' ' + syu);
});

Measured memory_bytes: 15556
import java.util.*;

class Main {

    static final Scanner in = new Scanner(System.in);

    static char s[], t[];
    static int dp[][];
    static int N, M;

    public static void main(String[] args) {

        String temp = in.next();
        s = temp.toCharArray();

        temp = in.next();
        t = temp.toCharArray();

        N = s.length;
        M = t.length;
        dp = new int[N + 1][M + 1];

        for (int i = 0; i <= N; i++)
            Arrays.fill(dp[i], -1);

        

        // ..filling the array with -1
        

        topDownLCS();
        Stack<Character> stack = new Stack<>(); 
        int i = N,j = M;
        while(i >0 && j > 0){
            if(s[i-1] == t[j-1]){
                stack.push(s[i-1]);
                i--;
                j--;
            }
            else{
                if(dp[i-1][j] > dp[i][j-1]){
                    i--;
                }
                else{
                    j--;
                }
            }
        }

        String lcs = "";
        while(!stack.isEmpty()){
            lcs += stack.pop();
        }
        System.out.println(lcs);

    }

    static void topDownLCS(){

        //..filling the 0th column with zeroes
        for (int i = 0; i <= N; i++)
            dp[i][0] = 0;

        //.. filling the 0th row with zeroes    
        for (int j = 0; j <= M; j++)
            dp[0][j] = 0;

        for(int n = 1;n <= N ;n++){

            for(int m = 1;m <= M;m++){

                if(s[n-1] == t[m - 1])
                    dp[n][m] = 1 + dp[n-1][m-1];
                else{
                    int ansA = dp[n-1][m];

                    int ansB = dp[n][m-1];

                    dp[n][m] = Math.max(ansA,ansB);
                }  

            }
        }
    }

    static int LCS(int n, int m) {

        // ..if atleast one of the strings are empty
        if (n == 0 || m == 0)
            return 0;

        if (dp[n][m] != -1)
            return dp[n][m];

        if (s[n - 1] == t[m - 1])
            dp[n][m] = 1 + LCS(n - 1, m - 1);
        else {
            // ..reduces size of string A by one
            int ansA = LCS(n - 1, m);

            // ..reduces size of string B by one
            int ansB = LCS(n, m - 1);

            dp[n][m] = Math.max(ansA, ansB);
        }

        return dp[n][m];
    }

}


Measured memory_bytes: 88724
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;

int64_t X, Y;

const int64_t MAX = 2000010;
const int64_t MOD = 1000000007;
int64_t fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int64_t i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

int64_t COM(int64_t n, int64_t k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

void solve()
{
    std::cin >> X >> Y;

	if ((X + Y) % 3 != 0)
	{
		std::cout << "0" << std::endl;
		return;
	}

	int64_t m = (2 * X - Y) / 3;
	int64_t n = (-X + 2 * Y) / 3;

	COMinit();
	std::cout << COM(m + n, m) << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	solve();
}


Measured memory_bytes: 50504