akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<'\n';}}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main() {
    int x,y;cin>>x>>y;
    ll ans=0;
    if(x==1)ans+=300000;
    if(x==2)ans+=200000;
    if(x==3)ans+=100000;
    if(y==1)ans+=300000;
    if(y==2)ans+=200000;
    if(y==3)ans+=100000;
    if(x==1&&y==1)ans+=400000;
    out(ans);
}

Measured memory_bytes: 256
/*      ...वहां तूफान भी हार जाते हैं जहां कश्तियां जिद पर होती हैं !...        */
#include <bits/stdc++.h>
using namespace std;

#define fast ios_base::sync_with_stdio(false);   cin.tie(NULL); cout.tie(NULL);
#define fl(i,a,n) for(int i=a; i<n; i++)
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define test()  int tt;  cin>>tt;  while(tt--)
#define nl  cout<<"\n"
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)    {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}
const int mod=1e9+7;

int main()  {
    fast;
    string s,t;     cin>>s>>t;
    int len1=s.size(),len2=t.size();
    int dp[len1+1][len2+1];
    fl(i,0,len1+1)  {
        fl(j,0,len2+1)  {
            if(i==0 || j==0)    dp[i][j]=0;
            else if(s[i-1]==t[j-1])      dp[i][j]=1+dp[i-1][j-1];
            else    dp[i][j]=max(dp[i][j-1],dp[i-1][j]);
        }
    }
    string ans="";
    int i=len1,j=len2;
    while(i>0 && j>0)   {
        if(s[i-1]==t[j-1])  {
            ans=s[i-1]+ans;
            i--;    j--;
        }
        else if(dp[i][j-1]>=dp[i-1][j])     j--;
        else    i--;
    }
    cout<<ans;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using pii = pair<int,int>;
#define ALL(x) (x).begin(),(x).end()

struct Edge {
	Edge(ll t, ll a, ll b): to(t), cost_coin(a), cost_time(b) {}
	ll to, cost_coin, cost_time;
};

int main(){
	ll N, M, S;
	cin >> N >> M >> S;
	vector<vector<Edge>> edges(N);
	for(int i=0;i<M;i++) {
		ll u, v, a, b;
		cin >> u >> v >> a >> b;
		u--, v--;
		edges[u].emplace_back(v, a, b);
		edges[v].emplace_back(u, a, b);
	}

	vector<ll> C(N), D(N);
	for(int i=0;i<N;i++) {
		cin >> C[i] >> D[i];
	}

	const ll MAX_COIN = N * 50;
	constexpr ll INF = LLONG_MAX;
	vector<vector<ll>> cost(N, vector<ll>(MAX_COIN + 1, INF));

	struct Element {
		ll node, coin, cost_time;
		bool operator<(const Element &rhs) const {
			return cost_time < rhs.cost_time;
		}
		bool operator>(const Element &rhs) const {
			return cost_time > rhs.cost_time;
		}
		bool operator==(const Element &rhs) const {
			return cost_time == rhs.cost_time;
		}
	};

	priority_queue<Element, vector<Element>, greater<Element>> pq;

	S = min(S, MAX_COIN);
	cost[0][S] = 0;
	pq.push({0, S, 0});
	while(!pq.empty()) {
		Element t = pq.top();
		pq.pop();

		// この点tへの移動時間が, 既に探索したtへの移動時間よりも長い
		if(t.cost_time > cost[t.node][t.coin]) {
			continue;
		}

		for(const Edge &e : edges[t.node]) {
			// この辺を移動するのに必要なコインが手持ちにない
			if(e.cost_coin > t.coin) {
				continue;
			}
			ll new_cost_time = t.cost_time + e.cost_time;
			ll new_coin = t.coin - e.cost_coin;
			if(new_cost_time < cost[e.to][new_coin]) {
				cost[e.to][new_coin] = new_cost_time;
				pq.push({e.to, new_coin, new_cost_time});
			}
		}

		if(t.coin < MAX_COIN) {
			ll new_cost_time = t.cost_time + D[t.node];
			ll new_coin = min(MAX_COIN, t.coin + C[t.node]);
			if(new_cost_time < cost[t.node][new_coin]) {
				cost[t.node][new_coin] = new_cost_time;
				pq.push({t.node, new_coin, new_cost_time});
			}
		}
	}

	for(int i=1;i<N;i++) {
		cout << *min_element(cost[i].begin(), cost[i].end()) << endl;
	}
}

Measured memory_bytes: 7176
#include<iostream>
using namespace std;
typedef long long ll;
ll MOD = 1e9 + 7;
int main() {
	int N;
	cin >> N;
	ll T[N], A[N];
	for (int i = 0; i < N; i++) {
		cin >> T[i];
	}
	for (int i = 0; i<N; i++) {
		cin >> A[i];
	}
	if (T[N - 1] != A[0]) { cout << 0 << endl; }
	else {
		ll ans = 1;
		//4通りの場合分けが必要.ちゃんと気づいて
		for (int i = 1; i < N - 1; i++) {
			if (T[i] == T[i - 1] && A[i] == A[i + 1]) {
				ans *= min(T[i], A[i]);
				ans %= MOD;
			}
			else if (T[i] > T[i - 1] && A[i] == A[i + 1] && A[i] < T[i]) {  
				ans = 0;
				//高さが
			}
			else if (T[i] == T[i - 1] && A[i] > A[i + 1] && A[i] > T[i]) {  
				ans = 0;
			}
			else if (T[i] > T[i - 1] && A[i] > A[i + 1] && A[i] != T[i]) {   
				ans = 0;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 1920
import sys
import io, os
input = sys.stdin.buffer.readline
#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline

import math
N = 10**6+50

def main():

    n = int(input())
    A = list(map(int, input().split()))

    spf = [-1]*(N+1)
    for i in range(N+1):
        spf[i] = i
    for i in range(2, int(math.sqrt(N))+1):
        if spf[i] == i:
            for j in range(i*2, N+1, i):
                if spf[j] == j:
                    spf[j] = i

    S = [0]*N
    for a in A:
        s = set()
        while a != 1:
            p = spf[a]
            if p not in s:
                S[p] += 1
            s.add(p)
            a //= p
        #print(S[0:10])


    #print(S[0:10])
    flag = False
    for i in range(len(S)):
        if S[i] == n:
            print('not coprime')
            exit()
        elif S[i] >= 2:
            flag = True
        else:
            pass
    if flag:
        print('setwise coprime')
    else:
        print('pairwise coprime')

if __name__ == '__main__':
    main()


Measured memory_bytes: 185020
#include<iostream>
#include<algorithm>
using namespace std;
static const int N = 100;
int main(){
  int n,p[N+1],m[N+1][N+1];
  cin>>n;
  for(int i=1;i<=n;i++){
    cin>>p[i-1]>>p[i];
  }
  for(int i=1;i<=n;i++)m[i][i]=0;
  for(int l=2;l<=n;l++){
    for(int i=1;i<=n-l+1;i++){
      int j=i+l-1;
      m[i][j]=(1 << 21);
      for(int k=i;k<=j-1;k++){
	m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
      }
    }
  }
  cout << m[1][n] << endl;
  return 0;
}



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

long long int power(long long int x, long long int y, long long int p)  
{  
    long long int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  

int main() {
	long long int n;
	cin>>n;
	long long int x = (power(10, n, 1000000007) - 2*power(9, n, 1000000007) + power(8, n, 1000000007))%1000000007;
	if(x<0) cout<<1000000007+x;
	else cout<<x;
	return 0;
}


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

signed main() {
  int n; cin >> n;
  int v[n];
  for(int i = 0; i < n; i++) cin >> v[i];
  sort(v, v+n);
  cout << v[n-1] - v[0] << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>	
#define int long long int
#define mod 1000000007
using namespace std;
main()
{	
	int n,m;
	cin>>n>>m;
	char arr[n][m];
	int dp[n][m];
	memset(dp,0,sizeof dp);
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)
			cin>>arr[i][j];
		dp[0][0]=1;
	for(int i=1;i<n;i++){
		dp[i][0]=dp[i-1][0];
		if(arr[i][0]=='#')
			dp[i][0]=0;
	}
	for(int i=1;i<m;i++){
		dp[0][i]=dp[0][i-1];
		if(arr[0][i]=='#')
			dp[0][i]=0;
	}
	for(int i=1;i<n;i++){
		for(int j=1;j<m;j++){
			if(arr[i][j]=='#')
				dp[i][j]=0;
			else
				dp[i][j]+=dp[i-1][j]+dp[i][j-1];
			dp[i][j]%=mod;
		}
	}
	cout<<dp[n-1][m-1];
}

Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i<b; i++)
#define lli long long
#define pb push_back
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int main()
{
    fast
    string s1, s2;
    cin>>s1>>s2;
    int count =0;
    rep(i,0,s1.size()){
        if(s1[i]!=s2[i]){
            count++;
        }
    }
    cout<<count;
    return 0;
}


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

int main(){
	string a;
	int cnt = 0;
	cin>>a;
	for(int i = 0, j  = a.size() - 1; i <= j; i++, j-- ){
		if(a[i] != a[j]) cnt++;
		else continue;
	}
	cout<<cnt<<endl;

	return 0;
}



Measured memory_bytes: 256
import sys
import math
input = sys.stdin.readline


def main():
    sc = Scan()
    w, h, x, y = sc.intarr()
    flag = 0
    if w == 0 or h == 0:
        print('0 0')
        exit()
    if w/2 == x and h/2 == y:
        flag = 1
    s = w * h / 2
    print(s, flag)


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


main()


Measured memory_bytes: 3064
import sys
input = lambda : sys.stdin.readline().rstrip()

from heapq import heappush, heappop 

running = []
events = []
delete = set()

n, q = map(int, input().split())
for _ in range(n):
    s, t, x = map(int, input().split())
    time = max(s - x, 0)
    if t - x < 0:
        continue
    events.append((s - x, x, 1)) # 追加イベント
    events.append((t - x, x, 0)) # 削除イベント
events.sort()
ans = []
idx = -1
for _ in range(q):
    d = int(input())
    if d >= events[-1][0]:
        print(-1)
        #ans.append(-1)
        continue
    while events[idx + 1][0] <= d:
        idx += 1
        if events[idx][2] == 1:
            heappush(running, events[idx][1])
            delete.discard(events[idx][1])
        else:
            delete.add(events[idx][1])
    flag = 1
    while running:
        x = heappop(running)
        if x not in delete:
            heappush(running, x)
            print(x)
            #ans.append(x)
            flag = 0
            break
    if flag:
        print(-1)

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

int main() {
    int a, b, t; cin >> a >> b >> t;
    //cout << ((1+2*t) * b) / (2 *a) << endl;
    cout << b*(t/a) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int R, G, B, n;
    cin >> R >> G >> B >> n;
    int cnt = 0;

    rep(r, 3001) rep(g, 3001) {
        int remain = n - r * R - g * G;
        if (remain >= 0 && remain % B == 0) cnt++;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <unordered_map>
#include <map>
#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define REPI(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define INF numeric_limits<double>::infinity()
constexpr long MOD = 1e9 + 7;
using namespace std;
using P = pair<long, long>;
using VI = vector<long>;

VI ss = {0}, ts = {0};

int main() {
    string s, t;
    cin >> s >> t;
    
    REP(i,s.size()) {
        if (s[i] == 'A') {
            ss.push_back(1);
        } else {
            ss.push_back(2);
        }
    }
    
    REP(i,t.size()) {
        if (t[i] == 'A') {
            ts.push_back(1);
        } else {
            ts.push_back(2);
        }
    }
    
    REP(i,s.size()) {
        ss[i+1] += ss[i];
    }
    
    REP(i,t.size()) {
        ts[i+1] += ts[i];
    }

    long q;
    cin >> q;
    REP(i,q) {
        long a, b, c, d;
        cin >> a >> b >> c >> d;
        if ((ss[b] - ss[a-1]) % 3 == (ts[d] - ts[c-1]) % 3) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
}


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

struct edge {
  int to;
  double cost;
};

int N, V;
vector<edge> G[1010];

const int MAX_V = 101010;
const double INF = 1e18;

struct Dijkstra {
  double d[MAX_V];

  void dijkstra(int s) {
    using P = pair<double, int>;
    priority_queue<P, vector<P>, greater<P>> que;
    fill(d, d + V, INF);
    d[s] = 0.0;
    que.push(P(0, s));

    while (!que.empty()) {
      P p = que.top();
      que.pop();
      int v = p.second;
      if (d[v] < p.first)
        continue;
      for (int i = 0; i < G[v].size(); i++) {
        edge e = G[v][i];
        if (d[e.to] > d[v] + e.cost) {
          d[e.to] = d[v] + e.cost;
          que.push(P(d[e.to], e.to));
        }
      }
    }
  }
};

double dist(int x, int y, int a, int b) {
  return sqrt((x - a) * (x - a) + (y - b) * (y - b));
}

signed main() {
  int xs, ys, xt, yt;
  cin >> xs >> ys >> xt >> yt >> N;
  V = N + 2;
  vector<int> x(N + 2), y(N + 2), r(N + 2);
  x[0] = xs, x[N + 1] = xt;
  y[0] = ys, y[N + 1] = yt;
  r[0] = r[N + 1] = 0;
  for (int i = 1; i <= N; i++) {
    int xx, yy, rr;
    cin >> xx >> yy >> rr;
    x[i] = xx, y[i] = yy, r[i] = rr;
  }

  for (int i = 0; i < N + 2; i++) {
    for (int j = i + 1; j < N + 2; j++) {
      double d = dist(x[i], y[i], x[j], y[j]) - r[i] - r[j];
      d = max(d, 0.0);
      G[i].push_back({j, d});
      G[j].push_back({i, d});
    }
  }

  Dijkstra dij;
  dij.dijkstra(0);

  cout << fixed << setprecision(12) << dij.d[N + 1] << endl;
  return 0;
}


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

int main() {
	int N;
	long long DP[2][4][4][4] = {}, count = 0;
	DP[0][3][3][3] = 1;
	cin >> N;
	for (int i = 0; i < N; i++) {
        for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				for (int l = 0; l < 4; l++) DP[(i + 1) % 2][j][k][l] = 0;
            }
        }
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				for (int l = 0; l < 4; l++) {
					for (int m = 0; m < 4; m++) {
						if (!(k == 0 && l == 1 && m == 2) &&
							!(k == 0 && l == 2 && m == 1) &&
							!(k == 1 && l == 0 && m == 2) &&
							!(j == 0 && l == 1 && m == 2) &&
							!(j == 0 && k == 1 && m == 2)) {
							DP[(i + 1) % 2][k][l][m] += DP[i % 2][j][k][l];
							DP[(i + 1) % 2][k][l][m] = DP[(i + 1) % 2][k][l][m] % 1000000007;
						}
					}
				}
			}
		}
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 4; j++) {
			for (int k = 0; k < 4; k++) {
				count += DP[N % 2][i][j][k];
				count = count % 1000000007;
			}
		}
	}
	cout << count;
}

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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    string s;
    cin >> s;
    if(s[1] == 'B') cout << "ARC" << endl;
    else cout << "ABC" << endl;

    return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
int a, b, ans;
char o;

int main()
{
    do
    {
        scanf("%d %c %d", &a, &o, &b);
        switch (o)
        {
        case '+':
            ans = a + b;
            break;
        case '-':
            ans = a - b;
            break;
        case '*':
            ans = a * b;
            break;
        case '/':
            ans = a / b;
            break;
        default:
            break;
        }
        if ((int)o != 63)
        {
        printf("%d\n", ans);
        }
        
    } while ((int)o != 63);
}



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

const ll INF = 1LL << 60;
const int MOD = 1e9 + 7;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPR(i, b, e) for (int i = (b); i <= (e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    int ans = min(B / A, C);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#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 ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e7 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	int a, b;
	cin >> a >> b;
	cout << a * b << endl;

	return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
    int x,y,z;
    while(cin>>x>>y>>z)
    {
        if(x==y&&x!=z&&y!=z||y==z&&x!=y&&x!=z||x==z&&x!=y&&z!=y)
        {
            cout<<"Yes"<<endl;continue;
        }
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#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 (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  cin >> n;
  ll res = 1;
  while (res <= n) res *= 2;
  cout << res/2 << endl;
}

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

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  string s,t;cin>>s>>t;
  int ans=0;
  for(int i=0;i<3;i++)if(s[i]==t[i])ans++;
  cout<<ans<<endl;

  
  return 0;
}


Measured memory_bytes: 3584
#include <iostream>
#include <string>
#include <vector>

#define rep(i, n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int R;
  cin >> R;

  if (R < 1200)
    cout << "ABC" << endl;
  else if (R < 2800)
    cout << "ARC" << endl;
  else
    cout << "AGC" << endl;

  return 0;
}


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

const ll INF = 1 << 30;

ll A[55];

int main() {
    int N;
    cin >> N;
    int min_idx = -1, max_idx = -1;
    ll min_A = INF, max_A = -INF;
    bool all_p = true, all_m = true;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        if (min_A > A[i]) {
            min_idx = i;
            min_A = A[i];
        }
        if (max_A < A[i]) {
            max_idx = i;
            max_A = A[i];
        }
        if (A[i] < 0) all_p = false;
        else all_m = false;
    }
    if (all_p) {
        cout << N - 1 << endl;
        for (int i = 1; i < N; i++) {
            A[i] += A[i - 1];
            cout << i << ' ' << i + 1 << endl;
        }
        /*
        for (int i = 0; i < N; i++) cout << A[i] << ' ';
        cout << endl;
        */
        return 0;
    }
    else if (all_m) {
        cout << N - 1 << endl;
        for (int i = N - 1; i >= 1; i--) {
            A[i - 1] += A[i];
            cout << i + 1 << ' ' << i << endl;
        }
        /*
        for (int i = 0; i < N; i++) cout << A[i] << ' ';
        cout << endl;
        */
        return 0;
    }
    cout << 2 * N - 1 << endl;
    if (max_A > abs(min_A)) {
        for (int i = 1; i <= N; i++) {
            A[i - 1] += A[max_idx];
            cout << max_idx + 1 << ' ' << i << endl;
        }
        for (int i = 1; i < N; i++) {
            A[i] += A[i - 1];
            cout << i << ' ' << i + 1 << endl;
        }
    }
    else {
        for (int i = 1; i <= N; i++) {
            A[i - 1] += A[min_idx];
            cout << min_idx + 1 << ' ' << i << endl;
        }
        for (int i = N; i > 1; i--) {
            A[i - 2] += A[i - 1];
            cout << i << ' ' << i - 1 << endl;
        }
    }
    /*
    for (int i = 0; i < N; i++) cout << A[i] << ' ';
    cout << endl;
    */
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long int  //comment for large arrays
#define pll pair<int,int>
#define dbl long double
#define ff first
#define ss second
#define endl "\n"
#define mod 1000000007
#define eps 0.00000001
#define INF 10000000000000001
#define all(x) (x).begin(),(x).end()
#define LB(v,x) (lower_bound(all(v),x) - v.begin()) 
#define UB(v,x) (upper_bound(all(v),x) - v.begin())
#define size(x) (int)(x).size()
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define popb() pop_back()
#define popf() pop_front()
#define mp(x,y) make_pair((x),(y))
#define vec(dt) vector<dt>
#define vv(dt) vector<vector<dt>>
#define fastio(x) ios_base::sync_with_stdio(x); cin.tie(NULL)
#define init(v,s) memset(v,s,sizeof(v)) 
#define bug(x) cerr<<"LINE: "<<__LINE__<<" || click to see test details "<<#x<<" = "<<x<<endl
#define loop(i,s,n) for(int i=s;i<n;i++)
#define bugprint(v) for(auto it:v) cout<<it<<" "; cout<<endl 
using namespace std;


signed main()
{
	fastio(0);
	int n,w;
	cin>>n>>w;
	int value[n+1],weight[n+1],sum = 0;
	loop(i,1,n+1) 
	{
		cin>>weight[i]>>value[i];
		sum += value[i];
	}
	int dp[sum+1],ans = 0;
	loop(i,1,sum+1) dp[i] = INF;
	dp[0] = 0;
	loop(i,1,n+1)
	{
		for(int j=sum;j>0;j--)
			if(dp[j]!=INF)
				dp[j + value[i]] = min(dp[j + value[i]], dp[j] + weight[i]);
		dp[value[i]] = min(dp[value[i]], weight[i]);
	}
	
	loop(i,1,sum+1) if(dp[i]<=w) ans = i;
	cout<<ans<<endl;
	return 0;		
}

Measured memory_bytes: 1024
import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
#from itertools import permutations,combinations
def data(): return sys.stdin.readline().strip()
def mdata(): return list(map(int, data().split()))
def outl(var) : sys.stdout.write('\n'.join(map(str, var))+'\n')
def out(var) : sys.stdout.write(str(var)+'\n')
#from decimal import Decimal
from fractions import Fraction
#sys.setrecursionlimit(100000)
INF = float('inf')
mod = int(1e9)+7



n=int(data())
a=mdata()
k=1000
s=0
for i in range(n):
    if i>0 and a[i]>a[i-1]:
        k+=s*a[i]
        s=0
    if i<n-1 and a[i]<a[i+1]:
        s=k//a[i]
        k=k%a[i]
k+=s*a[-1]
out(k)



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

int main(){
  bool a[1000000];

  a[0]=a[1]=false;
  for(int i=2;i<1000000;i++){
    a[i]=true;
  }

  for(int i=2;i*i<1000000;i++){
    if(a[i]){
      for(int j=i*i;j<1000000;j+=i){
        a[j]=false;
      }
    }
  }

  int min,max;

  while(true){
    int m;
    cin>>m;

    if(cin.eof()){
      break;
    }

    for(int i=3;i<m;i++){
      if(a[i]){
        max=i;
      }
    }

    for(int i=m+1;i<=1000000;i++){
      if(a[i]){
        min=i;
        break;
      }
    }

    if(m==3){
      max=2;
    }

    cout<<max<<' '<<min<<endl;

  }

  return 0;
}



Measured memory_bytes: 4036
/* dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define    endl        '\n'
#define pii         pair<ll ,ll>
#define vll          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  200005
ll fact[N];
ll expo(ll base, ll exponent, ll mod) {                                //return base^exponent modulo modulus
    ll ans = 1;
    while(exponent !=0 ) {
        if((exponent&1) == 1) {
            ans = ans*base ;
            ans = ans%mod;
        }
        base = base*base;
        base %= mod;
        exponent>>= 1;
    }
    return ans%mod;
}
ll nCr(ll n,ll r)
{
    return ((fact[n]*expo(fact[r],hell-2,hell))%hell*expo(fact[n-r],hell-2,hell))%hell;
}
int main()
{
    ios
    ll n,m,i,j,ans=1;fact[0]=1;
    for(i=1;i<N;i++)fact[i]=(fact[i-1]*i)%hell;
    cin>>n>>m;
    map<ll,ll>m1;
    for(i=2;i<=sqrt(m);i++){
        ll cnt=0;
        if(m%i==0){
            while(m%i==0)m/=i,cnt++;
            m1[i]=cnt;
        }
    }
    if(m!=1)m1[m]++;
    for(auto i:m1){
       // cout<<i.F<<" "<<i.S<<"\n";
        ll r=i.S;
        ans*=(nCr(n+r-1,r));
        ans%=hell;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1792
many, feet = gets.chomp.split(" ").map(&:to_i)
flag = false
for i in 0..many do
  foot = 2 * i + 4 * (many - i)
  if foot == feet 
    flag = true
    break
  end
end

if flag
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 14292
from itertools import product

NS = input()
N = int(NS)
D = len(NS)

arr = ['0', '3', '5', '7']
ans = 0

for d in [int(''.join(dd)) for dd in product(arr, repeat=D) if '3' in dd and '5' in dd and '7' in dd]:
    if '0' in str(d):
        continue
    if d > N:
        break
    ans += 1

print(ans)


Measured memory_bytes: 11224
#include <bits/stdc++.h>
using namespace std;
int main(){
    int arr[3];
    for (int i = 0; i < 3; i++)
        cin >> arr[i];
    sort(arr, arr + 3);
    if (arr[0] == arr[1] && arr[0] == 5 && arr[2] == 7)
        cout << "YES\n";
    else
        cout << "NO\n";
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

using namespace std;

#define INF 2140000000
#define MOD 1000000007

bool fall(string s, vector<pair<char,char> > &td, int ind, char side) {

	for (int i = 0; i < td.size(); ++i) {
		if (td[i].first == s[ind]) {
			if (td[i].second == 'L') {
				ind--;
			}
			else {
				ind++;
			}
		}

		if (ind < 0 || ind > s.size() - 1) {
			break;
		}
	}

	int n = s.size();

	if ((side == 'L' && ind < 0) || (side == 'R' && ind >= n)) {
		return 1;
	}
	else {
		return 0;
	}

}

int clf(string s, vector<pair<char,char> > &td) {
	int l = 0;
	int r = s.size() - 1;

	if (!fall(s, td, l, 'L')) {
		return 0;
	}

	if (fall(s, td, r, 'L')) {
		return s.size();
	}

	while (l + 1 < r) {
		int k = (l + r) / 2;

		if (fall(s, td, k, 'L')) {
			l = k;
		}
		else {
			r = k;
		}
	}

	return l + 1;
}

int clr(string s, vector<pair<char,char> > &td) {
	int l = 0;
	int r = s.size() - 1;

	if (fall(s, td, l, 'R')) {
		return s.size();
	}

	if (!fall(s, td, r, 'R')) {
		return 0;
	}

	while (l + 1 < r) {
		int k = (l + r) / 2;

		if (!fall(s, td, k, 'R')) {
			l = k;
		}
		else {
			r = k;
		}
	}

	return s.size() - r;
}

int main() {
	int n, q;
	string s;

	cin >> n >> q >> s;
	vector<pair<char,char> > td(q);

	for (int i = 0; i < q; ++i) {
		cin >> td[i].first >> td[i].second;
	}

	int left = clf(s, td);
	int right = clr(s, td);

	cout << n - (left + right) << endl;
	
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
 
using namespace std;
 
long long N, ans;
 
int main()
{
    cin >> N;
    long long arr[N];
    for (long long i = 0 ; i < N ; i ++) {
        cin >> arr[i];
    }
    for (long long i = 0 ; i < N - 1 ; i ++) {
        if (arr[i + 1] < arr[i]) {
            ans += (arr[i] - arr[i + 1]);
            arr[i + 1] = arr[i + 1] + (arr[i] - arr[i + 1]);
        }
    }
    cout << ans;
    return 0;
}

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

using namespace std;

signed main()
{
    while(true)
    {
        int h,w;
        cin >> h >> w;
        if(h==0&&w==0)
        {
            return(0);
        }
        for(int i=0;i<w;i++)
        {
            cout << "#";
        }
        cout << endl;
        for(int i=0;i<h-2;i++)
        {
            cout << "#";
            for(int j=0;j<w-2;j++)
            {
                cout << "." ;
            }
            cout << "#" << endl;
        }
        for(int i=0;i<w;i++)
        {
            cout << "#";
        }
        cout << endl;
        cout << endl;
    }
}


Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	vector< vector<int> > mat(n, vector<int>(n));
	for(int i = 0; i < n; ++i){
		for(int j = 0; j < n; ++j){ cin >> mat[i][j]; }
	}
	ll answer = 0;
	for(int i = 0; i < n; ++i){
		for(int j = i + 1; j < n; ++j){
			answer += min(mat[i][j], mat[j][i]);
		}
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 1248
using System;
using System.Collections.Generic;
using System.Text;

namespace AtCoder.ABC170
{
    public class Problem2
    {
        public static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(" ");

            var X = decimal.Parse(input[0]);

            var Y = decimal.Parse(input[1]);

            var answer = "No";

            if (Y % 2 != 0)
            {
                Console.WriteLine(answer);

                return;
            }

            var k = (Y - (2 * X)) / 2;

            var t = (2 * X) - (Y / 2);

            if (k >= 0 && t >= 0 && k - (int)k == 0 && t - (int)t == 0)
            {
                answer = "Yes";
            }

            Console.WriteLine(answer);
        }
    }
}


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


vector< pair<int,int> > exist[20010];
int chk(int p,int q){
	int ans = 0;
	for(int i = -200 ; i <= 200 ; i++){
		for(int j = -200 ; j <= 200 ; j++){
			if( i*i+j*j < 1 ) continue;
			if( (p*p+q*q) % (i*i+j*j) == 0 ){
				for(int k = 0 ; k < exist[(p*p+q*q) / (i*i+j*j)].size() ; k++){
					int x =  exist[(p*p+q*q) / (i*i+j*j)][k].first;
					int y =  exist[(p*p+q*q) / (i*i+j*j)][k].second;
					if( i*x-y*j == p && i*y+j*x == q ) ans++;
				}
			}
		}
	}
	return ans == 8;
}
int main(){
	for(int i = -200 ; i <= 200 ; i++){
		for(int j = -200 ; j <= 200 ; j++){
			if( i*i + j* j <= 20000 ){
				exist[i*i+j*j].push_back(make_pair(i,j));
			}
		}
	}
	int T;
	cin >> T;
	while(T--){
		int x,y;
		cin >> x >> y;
		//cout << x << " " << y << " " << chk(x,y) << endl;
		if( chk(x,y) ) cout << "P" << endl;
		else cout << "C" << endl;
	}
}

Measured memory_bytes: 2176
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <map>
#define rg register
using namespace std;
typedef long long ll;
const int maxn=100010;
template <typename Tp> inline int getmin(Tp &x,Tp y){return y<x?x=y,1:0;}
template <typename Tp> inline int getmax(Tp &x,Tp y){return y>x?x=y,1:0;}
template <typename Tp> inline void read(Tp &x)
{
    x=0;int f=0;char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') f=1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    if(f) x=-x;
}
int n,tot,ex,ans,res,val[maxn],vis[maxn],is[2500],pri[2500];
ll tmp,a[maxn],pw[2500];
map<ll,int> ma;
map<ll,int>::iterator itr;
void init()
{
	for(int i=2;i<=2200;i++)
	{
		if(!is[i]) pri[++tot]=i;
		for(int j=1;j<=tot&&i*pri[j]<=2200;j++)
		{
			is[i*pri[j]]=1;
			if(i%pri[j]==0) break;
		}
	}
	for(int i=1;i<=tot;i++) pw[i]=(ll)pri[i]*pri[i]*pri[i];
}
ll find(ll x)
{
	ll res=1ll;
	int cnt;
	for(int i=1;i<=tot&&x>=pri[i];i++)
	{
		cnt=0;
		while(x%pri[i]==0) x/=pri[i],++cnt;
		if(cnt==1) res*=pri[i]*pri[i];
		if(cnt==2) res*=pri[i];
		if(res>1e10) return 1ll;
	}
	if(x^1)//big prime or prime*prime
	{
		cnt=(int)sqrt(x);
		if(x!=(ll)cnt*cnt)
		{
			res*=x;
			if(res>1e10) return 1ll;
			res*=x;
		}
		else res*=cnt;
		if(res>1e10) return 1ll;
	}
	return res;
}
int main()
{
	init();
	read(n);
	for(rg int i=1;i<=n;i++)
	{
		read(a[i]);
		for(int j=1;j<=tot&&a[i]>=pri[j];j++)
		  while(a[i]%pw[j]==0)
		    a[i]/=pw[j];
		if(a[i]^1ll) ++ma[a[i]];
		else ex=1;
	}
	sort(a+1,a+n+1);
	n=unique(a+1,a+n+1)-a-1;
	for(rg int i=(a[1]==1?2:1);i<=n;i++)
	{
		tmp=find(a[i]);
		itr=ma.find(tmp);
		if(itr!=ma.end()) res+=max(ma[a[i]],itr->second);
		else ans+=ma[a[i]];
	}
	ans+=ex+(res>>1);
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;
using ll=long long;

const int L = 30; 
void solve() {

    vector<ll> pw(L+1);
    pw[0] = 1;
    for (int i = 1; i <= L; i++) {
        pw[i] = pw[i-1]*3;
    }

    // 3 2 4 2
    // pw[i] may not between, depend y0,y1.
    auto f = [&](ll x0, ll x1){
        for (int i = L-1; i >= 0; x0%=pw[i], x1%=pw[i], i--) {
            int b0 = (x0 / pw[i])%3;
            int b1 = (x1 / pw[i])%3;
            if (b0 != b1) break;
            if (b0 != 1) continue;
            if (x0 > x1) swap(x0,x1);
            return 2ll * min(2ll*pw[i] - x1, x0 - (pw[i]-1));
        }
        return 0ll;
    };

    auto g = [&](ll x0, ll x1, ll y0, ll y1){
        for (int i = L-1; i >= 0; x0%=pw[i], x1%=pw[i], y0%=pw[i], y1%=pw[i], i--) {
            int b0 = (x0/pw[i]);
            int b1 = (x1/pw[i]);
            int c0 = (y0/pw[i]);
            int c1 = (y1/pw[i]);
            if (b0 != b1 && c0 != c1) return 0ll;
            if (b0 == b1 && c0 == c1) continue;
            if (c0 == c1) {
                swap(x0,y0);
                swap(x1,y1);
            }
            if (y0 > y1) {
                swap(y0,y1);
            }
            bool exist = (c0==0 && c1==2);
            for (; i >= 0; x0%=pw[i], x1%=pw[i], i--) {
                int b0 = (x0 / pw[i])%3;
                int b1 = (x1 / pw[i])%3;
                if (b0 != b1) return 0ll;
                if (b0 != 1 || !exist) {
                    y0%=pw[i], y1%=pw[i];
                    if(i) {
                        int c0 = (y0/pw[i-1]);
                        int c1 = (y1/pw[i-1]);
                        exist = exist || !(c0==2&&c1==0);
                    }
                    continue;
                }
                if (x0 > x1) swap(x0,x1);
                return 2ll * min(2ll*pw[i] - x1, x0 - (pw[i]-1));
            }
            return 0ll;
        }
        return 0ll;
    };

    auto h = [&](ll x0, ll x1, ll y0, ll y1){
        if (x0>x1)swap(x0,x1);
        if (y0>y1)swap(y0,y1);
        if (x1-x0 > y1-y0) {
            swap(x0,y0);
            swap(x1,y1);
        }
        for (int i = L-1; i >= 0; i--) {
            if (x0/pw[i] == x1/pw[i] && (x0/pw[i])%3 == 1) {
                if (y1/pw[i] - y0/pw[i] > 1) {
                    return 2ll*min(x0 - x0/pw[i]*pw[i] + 1, (x0/pw[i] + 1)*pw[i] - x1);
                }
            }
        }
        return 0ll;
    };

    int q; cin >> q;
    while (q--) {
        ll x,y,u,v;
        cin >> x >> y >> u >> v;
        x--;y--;u--;v--;
        ll res = abs(x-u) + abs(y-v);
        //res += f(x,u) + f(y,v);
        //res += g(x,u,y,v);
        res += h(x,u,y,v);
        cout << res << "\n";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 384
H, W, K = map(int, input().split())
mod = 10**9 + 7

dp = [[0] * W for _ in range(H + 1)]
dp[0][0] = 1


def fib(n):
    if n <= 1:
        return 1
    return fib(n-1) + fib(n-2)


for i in range(1, H+1):
    for j in range(W):
        left = j
        right = W - j - 1

        dp[i][j] = dp[i-1][j] * fib(left) * fib(right)

        if j > 0:
            dp[i][j] += dp[i-1][j-1] * fib(left-1) * fib(right)

        if j < W-1:
            dp[i][j] += dp[i-1][j+1] * fib(left) * fib(right - 1)

        dp[i][j] %= mod

print(dp[-1][K-1])

Measured memory_bytes: 73812
#include <bits/stdc++.h>
using namespace std;
char s[100];
int main(){
    int a, b, k;
    scanf("%d%d%d", &a, &b, &k);
    for(int i=0;i<k;i++){
        if(i%2 == 0){
            if(a%2 != 0) a--;
            b += a/2;
            a/=2;
        }
        else{
            if(b%2 != 0) b--;
            a += b/2;
            b/=2;
        }
    }
    printf("%d %d\n", a, b);
}

Measured memory_bytes: 3820
#include<bits/stdc++.h>
#define lg long long int
#define loop(i,s,e) for(lg i=s;i<=e;i++)
#define iloop(i,s,e) for(lg i=e;i>=s;i--)
#define pb push_back
#define mp make_pair
using namespace std;

lg min(lg a,lg b)
{return a<b?a:b;}
lg max(lg a,lg b)
{return a>b?a:b;}
lg lcm(lg a ,lg b)
{
    return (a*b)/__gcd(a,b);
}
int main()
{
    lg n;
    cin>>n;
    if(n%1000!=0) cout<<1000 - n%1000<<endl;
    else cout<<0<<endl;

}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
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; }
ll min(ll a, ll b){
    if(a < b) return a;
    else return b;
}
ll max(ll a, ll b){
    if(a > b) return a;
    else return b;
}
int main(){
    cout << fixed << setprecision(10);
    ll n,a,b;
    cin >> n >> a >> b;
    if((b - a)%2 == 0){
        cout << (b - a)/2 << endl;
    }else{
        //cout << min(n - a , b - 1) << endl;
        if(n -  a > b - 1){
            //cout << "Yes" << endl;
            cout <<a  + (b - (a - 1) - 1)/2 << endl;
        }else{
            //cout << "No" << endl;
            cout << n - b + 1 + (n - (a  + (n - b)) - 1)/2 << endl;
        }
    }
    return 0;
}

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

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

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define endl "\n"
#define int ll

struct DualSegT{
  int sz;
  vector<int>v;
  DualSegT(int n){
    sz=1;while(sz<n)sz*=2;
    v.resize(2*sz-1,0);
  }
  void add(int a,int b,int x){
    add_(a,b,x,0,0,sz);
  }
  void add_(int a,int b,int x,int k,int l,int r){
    if(b<=l||r<=a)return;
    if(a<=l&&r<=b){
      v[k]+=x;
      return;
    }
    add_(a,b,x,2*k+1,l,(l+r)/2);
    add_(a,b,x,2*k+2,(l+r)/2,r);
  }
  int get(int x){
    x+=sz-1;
    int res=0;
    for(int i=x;i>0;i=(i-1)/2)res+=v[i];
    res+=v[0];
    return res;
  }
};

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

  int n,q;
  cin>>n>>q;
  DualSegT seg(n);
  for(int i=0;i<q;i++){
    int query;
    cin>>query;
    if(query==0){
      int s,t,x;
      cin>>s>>t>>x;
      s--,t--;
      seg.add(s,t+1,x);
    }
    if(query==1){
      int s;
      cin>>s;
      s--;
      cout<<seg.get(s)<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 4952
#include <iostream>
using namespace std;
typedef long long ll;
ll h, w, c[10][10], a, res;
int main(void){
    // Your code here!
    cin >> h >> w;
    for (ll i = 0; i < 10; i++) {
        for (ll j = 0; j < 10; j++) {
            cin >> c[i][j];
        }
    }
    for (ll k = 0; k < 10; k++) {
        for (ll i = 0; i < 10; i++) {
            for (ll j = 0; j < 10; j++) {
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }
    for (ll i = 0; i < h; i++) {
        for (ll j = 0; j < w; j++) {
            cin >> a;
            if (a == -1) continue;
            res += c[a][1];
        }
    }
    cout << res << endl;
}


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

int main(){
    int n,a;
    cin >> n >> a;
    int sa = n%500;
    if(sa <= a){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> A(M), mp(N + 1, 0);
  rep(i, M) cin >> A[i], mp[A[i]]++;;
  int ans = INT_MAX;

  int cnt = 0;
  for(int i = 0; i <= X; i++){
    cnt += (mp[i]);
  }
  // cout << "debug: " << cnt << endl;
  ans = min(ans, cnt);

  cnt = 0;
  for(int i = X; i <= N; i++){
    cnt += (mp[i]);
  }
  // cout << "debug: " << cnt << endl;
  ans = min(ans, cnt);

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


Measured memory_bytes: 256
array_index = gets.chomp.to_i
array = gets.chomp.split(" ").map(&:to_i)

a_cards = []
b_cards = []

array.sort{|a, b|b<=>a}.each_with_index {|item, idx|
  a_cards << item if (idx%2 == 0)
  b_cards << item if (idx%2 == 1)
}

a_result = a_cards.inject{|sum, n| sum + n}
b_result = b_cards.inject{|sum, n| sum + n}

puts(a_result - b_result)

Measured memory_bytes: 1788
import sys
List = [int(input()) for i in range(5)]
s = 0
flag = True
for i in range(1, 10):
    if flag:
        for j in range(5):
            if List[j] % 10 == i:
                s += List.pop(j)
                flag = False
                break

for i in range(len(List)):
    s += (-(-List[i] // 10))*10
print(s)

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

int main(){
  int N,K;
  double p;
  long long sum = 0, max_sum = 0;
  vector<long long> expected,sum_expected;
  cin >> N >> K;
  rep(i,N){
    cin >> p;
    sum += p+1;
    sum_expected.push_back(sum);
  }

  max_sum = sum_expected.at(K-1);
  for(int i=1;i<N-K+1;i++){ 
    sum = sum_expected.at(i+K-1) - sum_expected.at(i-1);
    max_sum = max(max_sum,sum);
  }
  long double ans = max_sum / 2.0;
  cout << fixed << setprecision(12) << ans << endl;
}

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

using namespace std;

typedef long double db;
typedef long long ll;
typedef pair<db, db> pd;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;


#define printlist(ans) for(auto x: ans) cout << x << ' '; cout << endl;
#define printstring(ans)  for(auto x: ans) cout << x; cout << endl;


#define mod 1000000007
#define maxn 100005

ll tst;
void cleanData();

ll n, m, k, a[maxn];

void solve() {
	ll x;
	cin >> x;
	vector<pll> v;
	for (ll i = 0; ; i++)
	{
		ll t = i * i * i * i * i;
		if(t <= 1e18 && t >= 0){
			v.push_back(make_pair(t, i));
			v.push_back(make_pair(-t, -i));
		}
		else break;
	}
	
	for (ll i = 0; i < v.size(); i++)
	{
		for (ll j = 0; j < v.size(); j++)
		{
			if(v[i].first - v[j].first == x){
				cout << v[i].second << ' ' << v[j].second;
				return;	
			}
			else if(v[j].first - v[i].first == x){
				cout << v[j].second << ' ' << v[i].second;
				return;	
			}
		}
	}
}

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

	tst = 1;
	//cin >> tst;
	while (tst--) {
		solve();
	}

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

void cleanData() {}


Measured memory_bytes: 3792
#include <stdio.h>

int main(){
    int n, tmp;
    int i;

    scanf("%d", &n);

    for(i = n; i > 0; i--){
        tmp = i;
        while(tmp % 2 == 0){
            tmp = tmp / 2;
        }
        if(tmp == 1){
            break;
        }   
    }

    printf("%d\n", i);

    return 0;
}

Measured memory_bytes: 128
#define ll long long
#define pi acos(-1.0)
#define Go "\n"
#define bye return 0
#define Afor(i,b) for(int i=0;i<b;i++)
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll N,i;
    cin>>N;
    ll A[N];
    ll B[N]={0};
    Afor(i,(N-1))
    {
        cin>>A[i];
        B[A[i]-1]++;

    }
    Afor(i,N)
    {
        cout<<B[i]<<Go;
    }
    bye;

}


Measured memory_bytes: 6740