akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
long long N, K, R, S, P;
string T;
long long p(char t, char m) {
    if (m == 'r' && t == 'p') {
        return P;
    }
    else if (m == 's' && t == 'r') {
        return R;
    }
    else if (m == 'p' && t == 's') {
        return S;
    }
    return 0;
}
long long memo[100010][26];
long long x(int i, char c) {
    if (i >= N) {
        return 0;
    }
    if (memo[i][c-'a'] != -1) return memo[i][c-'a'];
    char l[3] = {'r', 's', 'p'};
    long long res = 0;
    for (int j = 0; j < 3; j++) {
        if (l[j] != c) {
            res = max(res, x(i+K, l[j])+p(l[j], T[i]));
        }
    }
    return memo[i][c-'a'] = res;
}
int main () {
    cin >> N >> K >> R >> S >> P >> T;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 26; j++) {
            memo[i][j] = -1;
        }
    }
    long long ans = 0;
    for (int i = 0; i < K; i++) {
        ans += max({x(i, 'r'), x(i, 's'), x(i, 'p')});
    }
    cout << ans << endl;
}

Measured memory_bytes: 29824
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
using namespace std;
int actionFunction(vector<int> &spots,int jumps) {
    if(spots.size()<=1)return 0;
    vector<int> minCost(spots.size(),INT_MAX);
    minCost[0]=0;
    for(int i=1;i<spots.size();i++) {
        for(int jump=1;jump<=jumps;jump++) {
            minCost[i]=min({minCost[i],i-jump>=0?(minCost[i-jump]+abs(spots[i]-spots[i-jump])):INT_MAX});
        }
    }
    return minCost[spots.size()-1];
}
int main(void){
    vector<int> spots;
    int n,k,tmp;
    cin>>n>>k;
    for(int i=0;i<n;i++) {
        cin>>tmp;
        spots.push_back(tmp);
    }
    cout<<actionFunction(spots,k)<<endl;
    
}


Measured memory_bytes: 1144
#include<iostream>
#include<cmath>
#define MAX 100003
using namespace std;

void eratos ( int n, bool prime[]){
    for ( int i = 0; i <= n; i++ ) prime[i] = false;
    for ( int i = 3; i <= n; i += 2 ) prime[i] = true;
    prime[2] = true;
    int limit = (int)sqrt((double)n) + 1;
    for ( int i = 3; i <= limit; i += 2 ){
	if ( !prime[i] ) continue;
	for ( int j = i + i; j <= n; j += i ) prime[j] = false;
    }
}

int main(void){
    bool prime[MAX + 1];
    eratos(MAX, prime);

    int P[MAX];
    int size = 0;
    for ( int i = 2; i <= MAX; i++ ) if ( prime[i] ) P[size++] = i;

    int a, b, m, p, q, maxv, mp, mq;
    while(1){
	cin >> m >> a >> b;
	if ( a == 0 && b == 0 && m == 0 ) break;

	double r = 1.0*a/b;
	maxv = 0;
	mp = mq = -1;
	for ( int i = 0; i < size; i++ ){
	    p = P[i];
	    q = m/p;
	    for ( int q = m/p; q >= p; q-- ){
		if ( !prime[q] ) continue;
		if ( r > 1.0*p/q ) continue;
		if ( maxv < p*q ){
		    maxv = p*q;
		    mp = p;
		    mq = q;
		    q = p; continue;
		}
	    }
	}
	cout << mp << " " << mq << endl;

    }

    return 0;
}

Measured memory_bytes: 1004
n = int(input())
t, a = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]

diff = 1000000
index = 0
for i in range(n):
    tmpDiff = abs(a - (t-h[i]*0.006))
    if tmpDiff < diff:
        diff = tmpDiff
        index = i
print(index+1)

Measured memory_bytes: 3064
n=int(input())
x=n
ans=[]
for i in range(2,int(x**0.5)+1):
    if n%i==0:
        while n%i==0:
            ans.append(i)
            n//=i
if ans==[]:
    ans.append(x)
elif n!=1:
    ans.append(n)
print(str(x)+": "+" ".join(map(str,ans)))


Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
const int MAXN = 5005;

int n;
pi a[MAXN];
lint dp[MAXN][MAXN];

int main(){
	cin >> n;
	for(int i=0; i<n; i++) cin >> a[i].first >> a[i].second;
	sort(a, a+n, [&](const pi &a, const pi &b){
		return a.first + a.second < b.first + b.second;
	});
	memset(dp, 0x3f, sizeof(dp));
	dp[0][0] = 0;
	for(int i=0; i<n; i++){
		for(int j=0; j<=i; j++){
			if(dp[i][j] <= a[i].first){
				dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j] + a[i].second);
			}
			dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
		}
	}
	for(int i=n; i>=0; i--){
		if(dp[n][i] < 1e16){
			cout << i << endl;
			return 0;
		}
	}
}


Measured memory_bytes: 196096
#include<bits/stdc++.h>
using namespace std;
main(){
 long long n,t[1000]={},a[1000]={},j;
 cin>>n;
 for(int i=0;i<n;i++){
  cin>>t[i]>>a[i];
  if(i){
   if((a[i-1]-1)/a[i]>(t[i-1]-1)/t[i]) j=(a[i-1]-1)/a[i]+1;
   else j=(t[i-1]-1)/t[i]+1;
   a[i]*=j;t[i]*=j;
  }
 }
 cout<<a[n-1]+t[n-1]<<endl;
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, atan2, degrees
from operator import mul
from functools import reduce
sys.setrecursionlimit(10**8)

INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


w, h, n = LI()
l, r, u, d = 0, w, h, 0
for _ in range(n):
    x, y, a = LI()
    if a == 1:
        l = max(l, x)
    elif a == 2:
        r = min(r, x)
    elif a == 3:
        d = max(d, y)
    else:
        u = min(u, y)




if u < d or r < l:
    print(0)
else:
    print((u - d) * (r - l))









Measured memory_bytes: 39664
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7; //924844033 1000000000 + 7;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum, ans, dp[100],a[200000],b[200000];
string str, ss;
bool f;
char c;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge { LL from, to, cost; };
vector<LL>vec;
vector<edge>ed;
vector<LL>v;
map<LL,LL>ma;
set<LL>st;
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

int main() {
	cin >> n >> m;
	if (n == m) {
		cout << 1 << endl;
		return 0;
	}
	last = -1;
	Rrep(i, 61) {
		if (last>0) {
			if (m&(1LL << i)) {
				ans += min((1LL << (i+1)) + (1LL << last) - n, (1LL << (last)));
				f = 1;
				break;
			}
		}
		if (last == -1) {
			if (n&(1LL << i) && m&(1LL << i)) {
				n -= (1LL << i);
				m -= (1LL << i);
			}
			else if (m&(1LL << i) && !(n&(1LL << i))) {
				ans += (1LL << i) - n;
				last = i;
			}
		}
	}
	if (!f) {
		ans += min((1LL << (0)) + (1LL << last) - n, (1LL << (last)));
	}
	cout << ans<< endl;
	return 0;
}


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

#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define track(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
#define allr(v) v.rbegin(),v.rend() 
//#define endl '\n'  
typedef  long long ll; 
typedef  unsigned long long ull; 
typedef vector< ll > edge; 
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll mod=1000000007;
const ll inf=1e15;
const ll N=3e5+10;
ll n,k;
ll v[60];
ll get(ll l,ll r)
{
	std::vector<ll> temp;
	for(ll i=0;i<=l;i++) temp.pb(v[i]);
	for(ll i=r;i<n;i++) temp.pb(v[i]);
	sort(all(temp));
	ll ans=0;
	ll lim=k-(ll)temp.size();
	if(lim<0) return 0;
	for(auto &i:temp)
	{
		if(i<0 and lim) lim--;
		else ans+=i;
	}
	return ans;

}
int main()
{
	boost;
	cin>>n>>k;
	for(ll i=0;i<n;i++) cin>>v[i];
	ll ans=0;
	for(ll l=-1;l<n;l++)	
	{
		for(ll r=l+1;r<=n;r++)
		{
			ans=max(ans,get(l,r));
		}
	}
	cout<<ans;
	
  	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

int main(){
    int n,m;
    std::cin >> n >> m;
    std::vector<int> k(m);
    std::vector<int> s(m,0);
    std::vector<int> p(m);
    rep(i,m){
        std::cin >> k[i];
        rep(j,k[i]){
            int b;
            std::cin >> b; b--;
            s[i] += (1<<b);
        }
    }
    rep(i,m) std::cin >> p[i];


    int ans = 0;
    for(int bits=0; bits<(1<<n); bits++){
        int cnt = 0;
        for(int i=0; i<m; i++){
            int sum = 0;
            for(int j=0; j<n; j++){
                if(bits&(1<<j) && s[i]&(1<<j)) sum++;
            }
            if(sum%2==p[i]) cnt++;
        }
        if(cnt==m) ans++;
    }

    std::cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3632
//-----------------------
// author : xyqkoala
// time : 2020-07-23
//-----------------------

#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve();


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


void solve(){
	LL n;
	cin>>n;
	unordered_map<int,int> t;
	for(LL i=2;i*i<=n;i++){
		if(n%i) continue;
		while(n%i==0){
			n = n/i;
			t[i]++;
		}
	}
	if(n>1) t[n]++;
	int res = 0;
	for(auto item:t){
		int cnt = 2 * item.second;
		int tcnt = sqrt(cnt);
		if((tcnt*(tcnt+1)>cnt)) tcnt--;
		res+=tcnt;
	}
	cout<<res<<endl;
}


Measured memory_bytes: 3672
N, M = map(int, input().split())
if N%2==0:
    for i in range(M):
        x = 0
        if i>=M/2:
            x = 1
        a = 1 + i
        b = N - i
        print(a+x, b)
else:
    n = (N//2)*2
    for i in range(M):
        a = 1 + i
        b = a + n - (2*i+1)
        print(a, b)

Measured memory_bytes: 69484
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>

using namespace std;

int main() {
    bool hasA = false, hasB = false;
    string s;
    cin >> s;
    for (char c: s) {
        if (c == 'A') hasA = true;
        else hasB = true;
    }

    cout << ((hasA && hasB) ? "Yes" : "No");

    return 0;
}


Measured memory_bytes: 256
S=io.read()
s=string.lower(S)

if S:sub(1,1)=="A" then
    Counter=0
    for i=2, #S do
        if S:sub(i,i)=="C" and 3<=i and i<=#S-1 then
            Counter=Counter+1
        end
    end
    if Counter==1 then
        checker=0
        for i=1, #S do
            if S:sub(i,i)~=s:sub(i,i) then
                checker=checker+1
            end
        end
        if checker==2 then
            print("AC")
            return
        end
    end
end
print("WA")

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

using namespace std;

#define int 		long long
#define endl 		"\n"
#define mod 		1000000007
#define inf 		1e18
#define IOS 		ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int32_t main() {

	IOS;

	int n;
	cin >> n;

	vector<pair<int, int>> v(n);

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

	bool ans = 0;

	for(int i = 1; i < n - 1 ;i++) {
		if(v[i].first == v[i].second && v[i-1].first == v[i-1].second && v[i + 1].first == v[i+1].second) {
			ans = 1;
			break;
		}
	}


	if(ans)
		cout << "Yes";
	else
		cout << "No";

	return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ar array
vector<ll> factors(long long n) {
    vector<ll> f;
    for (ll x = 2; x*x <= n; x++)
        while (n%x == 0) {
            f.push_back(x);
            n /= x;
        }
    if(n > 1) f.push_back(n);
    return f;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll x;
  cin >> x;
  vector<ll> v = factors(x), z;
  map<ll ,ll> mp;
  for(ll x : v)
    mp[x]++;
  for(auto x : mp)
    z.push_back(x.second);
  ll ans = 0;
  for(ll x : z){
    ll l=1LL, r=x+1LL;
    while(r-l>1LL){
      ll mid = (l+r)/2LL;
      if((mid*(mid+1LL))/2LL<=x){
        l = mid;
      }
      else
        r = mid;
    }
    ans += l;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;cin>>N;long long H=0;
  vector<long long>V(N);
  for(int X=0;X<N;X++){
    cin>>V[X];
    if(X!=0){
      if(V[X-1]>V[X]){
        H+=V[X-1]-V[X];V[X]+=V[X-1]-V[X];
      }
    }
  }
  cout<<H<<endl;
}

Measured memory_bytes: 4840
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
const int MOD = 998244353;
int main()
{
	int N, K;
	cin >> N >> K;
	vector<pair<int,int>> ablestep;
	vector<int> dp(N + 5, 0), presum(N + 5, 0);
	while (K--)
	{
		int a, b;
		cin >> a >> b;
		ablestep.push_back({ a,b });
	}
	dp[0] = 0; presum[0] = 0;
	dp[1] = 1; presum[1] = 1;
	for (int i = 1; i <= N; i++)
	{
		for (auto s : ablestep)
		{
			int l = i - s.second, r = i - s.first;
			if (l < 1)l = 1;
			if (l > r)continue;
			dp[i] += ((presum[r] - presum[l - 1])+MOD)%MOD;
				
			dp[i] %= MOD;
			
		}
		presum[i] = (presum[i-1] + dp[i]) % MOD;

	}
	cout << dp[N]%MOD << '\n';

}

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

int main(){
    
    int n;
    cin >> n;
    bool t [n] ;
    for(int i = 0; i < n; i++){
        int temp1 , temp2;
        cin >> temp1 >> temp2;
        if(temp1 == temp2){
            t[i] = true;
        } else {
            t[i] = false;
        }
    }
    for(int i = 0; i <=n-3 ; i++){
        if (t[i] && t[i+1] && t[i+2]){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";

    // string a;
    // cin >> a;
    // if(a.at(a.size()-1) == 's'){
    //     a = a + "es";
    // } else {
    //     a = a+ 's';
    // }
    // cout << a;
    return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int budget = min(A, B) + min(C, D);
	cout << budget << endl;
	return 0;
}

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

int main()
{
    int a[3];
    scanf("%d%d%d",a,a + 1,a + 2);
    sort(a,a + 3);
    int sum = 0;
    sum = a[2] - a[0] + a[2] - a[1];
    if(sum % 2)sum += 3;
    printf("%d\n",sum / 2);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>


void selectionSort(int *A, int N) {
    int count = 0;
    for (int i = 0; i < N - 1; i++) {
        int min_idx = i;
        for (int j = i + 1; j < N; j++) {
            if (A[min_idx] > A[j]) {
                min_idx = j;
            }
        }
        if (i != min_idx) {
            std::swap(A[i], A[min_idx]);
            count++;
        }
    }

    for (int i = 0; i < N; i++) {
        std::cout << A[i];
        if (i != N - 1) {
            std::cout << " ";
        } else {
            std::cout << std::endl;
        }
    }
    std::cout << count << std::endl;
    
    return;
}


int main(int argc, char ** argv) {
    int N;
    std::cin >> N;

    int arr[N];
    
    for (int i = 0; i < N; i++) {
        std::cin >> arr[i];
    }

    selectionSort(arr, N);
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;



int main(){
    int a,b;cin >> a >> b;
  	if(b==1){
      cout << 0 << endl;
      return 0;
    }
    for (int i = 1; i <= 20; i++) {
        if(a*i-i+1>=b){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}



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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  int N;
  cin >> N;
  long long ans = 1;
  vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    if (A[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  for (int i = 0; i < N; i++) {
    if(ans >= LLONG_MAX / A[i] || ans * A[i] >= 1000000000000000001){
      ans = -1;
      break;
    } else {
      ans *= A[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std;
int main()
{   long long int n,W;
    cin>>n>>W;
    long long int w[n+1];
    long long int v[n+1];
    for(int i=1;i<=n;i++)
    {cin>>w[i]>>v[i];}
    long long int dp[n+1][W+1];
    for(int i=0;i<=n;i++)
    dp[i][0]=0;
    for(int i=0;i<=W;i++)
    dp[0][i]=0;
    for(int i=1;i<=n;i++)
    {   for(int j=1;j<w[i];j++)
        dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        for(int j=w[i];j<=W;j++)
        dp[i][j]=max(dp[i-1][j-w[i]]+v[i],max(dp[i-1][j],dp[i][j-1]));
    }
    cout<<dp[n][W];
}

Measured memory_bytes: 79104
#include <iostream>

using namespace std;

int main() {
    long long int a, b;
    cin >> a >> b;
    if(a == 0 || b == 0 )
     return printf("Zero"),0;
    if(a <= 0 && b >= 0)
     return printf("Zero"),0;
    if(a > 0)
     return printf("Positive"),0;
    
    if((-b + a + 1)%2 == 0 )
     return printf("Positive"),0;
     
    printf("Negative");
    return 0;
}

Measured memory_bytes: 256
N = int(input())
x = 0

for i in range(1,N+1):

    if i%3 == 0:
            print("",i,end = "")
    else:
        x = i
        while (x):
            if x%10 == 3:
                print( "",i,end = "")
                break
            x //= 10
print()


Measured memory_bytes: 6160
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = 998244353LL;
const double pi = acos(-1.0);

void re(VI & v, int p, int c) {
	VI P, C;
	rep(i, p - 1)P.pb(v[i]);
	FOR(i, p - 1, p + c - 1)C.pb(v[i]);
	rep(i, sz(C))v[i] = C[i];
	FOR(i, c, p + c - 1)v[i] = P[i - c];
}

int main() {
	int n, r;
	while (cin >> n >> r && (n || r)) {
		VI a(n); rep(i, n)a[i] = n - i;
		rep(i, r) {
			int p, c; cin >> p >> c;
			re(a, p, c);
		}
		Cout(a[0]);
	}
}


Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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 const INF = 1001001001;


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

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

return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

trait ChMinMax {
    fn chmin(&mut self, other: Self);
    fn chmax(&mut self, other: Self);
}
impl<T> ChMinMax for T
where
    T: PartialOrd,
{
    fn chmin(&mut self, other: Self) {
        if *self > other {
            *self = other
        }
    }
    fn chmax(&mut self, other: Self) {
        if *self < other {
            *self = other
        }
    }
}

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, $var:ident $($r:tt)*) => {
        let $var = parse_val!($it, usize);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

#[cfg(debug_assertions)]
macro_rules! debug {
    ($( $args:expr ),*) => { eprintln!( $( $args ),* ); }
}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($( $args:expr ),*) => {
        ()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let s: Vec<_> = it
        .next()
        .unwrap()
        .chars()
        .map(|x| x.to_digit(10).unwrap())
        .collect();
    let n = s.len();
    let mut ps = vec![];
    for i in 0..s.len() - 1 {
        if s[i] != s[i + 1] {
            ps.push(max(n - i - 1, i + 1))
        }
    }
    println!("{}", ps.iter().min().unwrap_or(&n));
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 2912
#include <bits/stdc++.h>
#define int long long int
#define endl '\n'
using namespace std;
typedef long long ll;
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
 #define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) FOR(i,0,sz(v)-1) cout << v[i] << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll MOD = 1e10;
const ll N = 2e4 + 1;
const ll m = MOD;
struct comp
{
	bool operator() (const pi &a,const pi &b) const
	{
		int l1=a.se - a.fi + 1;
		int l2=b.se-b.fi + 1;
		if(l1==l2) return a.fi<b.fi;
		else
		return l1>l2;
	}
};
signed main()
{
	read(k); string s; cin>>s;
	if(s.size()<k)cout<<s<<endl;
	else
	FOR(i,0,k-1)cout<<s[i];
	if(s.size()>k)cout<<"..."<<endl;
	
}

Measured memory_bytes: 3628
n,k = map(int,input().split())
x = list(map(int,input().split()))
pos = []
neg = []
for i in x:
    if i < 0:
        neg.append(-i)
    else:
        pos.append(i)
neg = neg[::-1]

pos = [0] + pos
neg = [0] + neg

#print(pos)
#print(neg)

# posにいってからneg
res = float('inf')
for i in range(min(len(pos),k)):
    # posからi本灯して, negからK-i本灯す
    j = k - i
    if j >= len(neg):
        continue
    tmp = pos[i] * 2 + neg[j]
    res = min(res, tmp)

# negにいってからpos
for i in range(min(len(neg),k)):
    j = k - i
    if j >= len(pos):
        continue
    tmp = neg[i] * 2 + pos[j]
    res = min(res, tmp)

print(res)


Measured memory_bytes: 14480
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int N, D;
    cin >> N >> D;
    int X[N][D];
    
    for(int i = 0; i < N; i++){
        for(int j = 0; j < D; j++){
            cin >> X[i][j];
        }
    }
    
    double sum = 0;
    int s = 0;
    int count = 0;
    for(int i = 0; i < N; i++){
        for(int j = i+1; j < N; j++){
            for(int k = 0; k < D; k++){
                sum += pow(X[i][k]-X[j][k], 2);
            }
            sum = sqrt(sum);
            s = ceil(sum);
            if(s == sum)
                count++;
            sum = 0;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 256
N = gets.to_i
S = gets.chomp

c = Hash.new{|h, k| h[k] = [-1, -1]}
(0...N).each{|n|
  c[S[n]][0] = n if c[S[n]][0] == -1
  c[S[n]][1] = n
}

puts (0...N).to_a.map{|n| c.count{|k, v| v[0] <= n && n < v[1]}}.max


Measured memory_bytes: 1788
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    long long x;
    cin>>x;
    int k=log10l(x);
    long long r=pow(10,(int)log10l(x));
    if((x+1)%r==0)cout<<x/r+9*k<<endl;
    else cout<<x/r+9*k-1<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include "bits/stdc++.h"
using namespace std;
typedef long long unsigned int ll;

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()



int main() {
    int N,K,cnt=0;
    cin>>N>>K;
    vector<int> a(N);
    for(int i=0;i<N;i++)
        cin>>a.at(i);
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    for(int j=0;j<K;j++){
        cnt+=a.at(j);
    }
    cout<<cnt<<endl;

}

Measured memory_bytes: 256
import sys

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

for i in range(N):
    if A[i]%2 == 0:
        if not((A[i]%3 == 0) or (A[i]%5 == 0)):
            print('DENIED')
            sys.exit()

print('APPROVED')

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

ll dp[1010][1010];
ll comb[1010][1010];

#define N 1010
ll inv[N],fac[N],ifac[N];

int main(){
  ll n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;

  inv[0]=1;inv[1]=1;fac[1]=1;ifac[1]=1;fac[0]=1;ifac[0]=1;
  for(int i=2;i<=1010;i++){
    inv[i]=(-MOD/i)*inv[MOD%i]%MOD;
    fac[i]=fac[i-1]*i%MOD;
    ifac[i]=ifac[i-1]*inv[i]%MOD;
    //cout<<inv[i]<<" "<<fac[i]<<" "<<ifac[i]<<endl;
  }

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

  for(int i=a;i<=b;i++){
    for(int j=0;j<=n;j++){
      if(dp[i-1][j]==0) continue;
      if(j>0) dp[i][j]=(dp[i][j]+dp[i-1][j])%MOD;
      ll tmp=1;
      for(int k=1;k<=d&&j+i*k<=n;k++){
        tmp=tmp*fac[n-j-i*(k-1)]%MOD*ifac[i]%MOD*ifac[n-j-i*k]%MOD*inv[k]%MOD;
        if(k>=c){
          dp[i][j+i*k]=(dp[i][j+i*k]+dp[i-1][j]*tmp%MOD+MOD)%MOD;
        }
      }
    }
  }

  cout<<dp[b][n]<<endl;

  return 0;
}


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

using namespace std;

int main(){
    int n, m, s;
    scanf("%d%d%d", &n, &m, &s);
    printf("%d\n", s / std::max (n, m) + (s % std::max (n, m) == 0 ? 0 : 1));
}

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

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

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int main(){
  int N;
  cin >> N;
  vector<ll> A(N), B(N);
  REP(i,N) cin >> A[i] >> B[i];

  ll cnt = 0;
  for(int i = N - 1; i >= 0; --i) {
    cnt += ((A[i] + cnt + B[i] - 1) / B[i]) * B[i] - A[i] - cnt;
  }
  cout << cnt << endl;
  return 0;
}



Measured memory_bytes: 1792
t = list(map(int, input().split()))
s = [t[0] % 2 , t[1] % 2 , t[2] % 2]
if s[0] == s[1] and s[0] == s[2]:
    print(int((max(t[0] , t[1] , t[2]) *3 - (t[0] + t[1] + t[2])) / 2))
else:
    if s.count(0) > s.count(1):
        for i in range(3):
            if s[i] == 0:
                t[i] += 1
        print(int((max(t[0] , t[1] , t[2]) *3 - (t[0] + t[1] + t[2])) / 2) + 1)
    else:
        for i in range(3):
            if s[i] == 1:
                t[i] += 1
        print(int((max(t[0] , t[1] , t[2]) *3 - (t[0] + t[1] + t[2])) / 2) + 1)

Measured memory_bytes: 3064
s = input()

def agct(s):
    for t in s:
        if not t in 'ACGT':
            return False
    else:
        return True
count = 0
for i in range(len(s)):
    for j in range(i+1, len(s)+1):
        if agct(s[i:j]):
            count = max(count, len(s[i:j]))
print(count)

Measured memory_bytes: 3060
a = input().split(" ")
tk_hp= int(a[0])
tk_dmg= int(a[1])
aoki_hp= int(a[2])
aoki_dmg= int(a[3])

turn = 'tk'
while True:
  if turn == 'tk':
    aoki_hp -= tk_dmg
    turn = 'aoki'
  else:
    tk_hp -= aoki_dmg
    turn = 'tk'
    
  if aoki_hp <= 0:
    print('Yes')
    break
  elif tk_hp <= 0:
    print('No')
    break

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

using namespace std;

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

    int a,p;
    cin>>a>>p;
  
    int pie=a*3+p;
    cout<<pie/2;
    return 0;
}

Measured memory_bytes: 256
n,s=map(int,input().split())
a=list(map(int,input().split()))

#dp[n][s]
#nこめまで選んだ時の和がｓの組

dp=[[0]*(s+1) for _ in range(n)]
a.sort()
#for i in range(s+1):
#    dp[0][i]=2
if a[0]>s:
    print(0)
    exit()

mod=998244353
 

dp[0][0]=2
dp[0][a[0]]+=1

for i in range(1,n):
    for j in range(s+1):
        #i番目を入れて選択するパターン
        dp[i][j]=dp[i-1][j]*2%mod
        if j>=a[i]:
            dp[i][j]+=dp[i-1][j-a[i]]%mod

print(dp[-1][s]%mod)


    

    




Measured memory_bytes: 135324
#include<bits/stdc++.h>
using namespace std;
#define i64 long long int
int n,a[111];
int A,C;
i64 B,D;
vector<int> e[111];
int X[111],Y[111];
void init(){
	memset(a,0,sizeof(a));
}
void dfs(int x,int fat,int dep){
	int son = 0;
	for(auto y : e[x]){
		if(y == fat)continue;
		dfs(y, x, dep+1);
		son ++;
	}
	a[dep] = max(a[dep], son);
}
void chk_ans(){
	D = 1;
	for(B = 0; a[B]; B++){
		D *= a[B];
	}
	if(B < A || B == A && D < C)
		A = B,C=D;
}
int main(){
	scanf("%d",&n);
	for(int i=1; i<n; i++){
		int x,y;
		scanf("%d%d",&x,&y);
		X[i] = x;
		Y[i] = y;
		e[x].push_back(y);
		e[y].push_back(x);
	}
	A = n+1;
	for(int i=1; i<=n; i++){
		init();
		a[0] = 1;
		dfs(i, i, 1);
		chk_ans();
	}
	for(int i=1; i<n; i++){
		init();
		a[0] = 2;
		dfs(X[i], Y[i], 1);
		dfs(Y[i], X[i], 1);
		chk_ans();
	}
	cout << A << " " << C << endl;
	return 0;
}


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

using std::pair;
using std::make_pair;
typedef pair<int, int> Pair;

#define update_max(a, b) if ((a) < (b)) (a) = (b)
#define update_min(a, b) if ((a) > (b)) (a) = (b)

void run(int case_id = 0) {
  std::string a, b;
  std::cin >> a;
  std::cin >> b;
  int answer = 0;
  for (int i = 0; i < a.length(); ++ i) {
    answer += a[i] == b[i];
  }
  std::cout << answer << "\n";
}

void multi_cases_main() {
  int num_tests;
  std::cin >> num_tests;
  for (int t = 1; t <= num_tests; ++ t) {
    run(t);
  }
}

int main() {
  std::ios::sync_with_stdio(false);
  run();
  return 0;
}


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

int main() {
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    long double theta_min = M_PI * 2 * (M / 60.0);
    long double theta_hour = M_PI * 2 * ((H * 60.0 + M) / 720.0);

    long double c_2 = A * A + B * B - 2.0 * A * B * cos(abs(theta_hour - theta_min));

    long double c = sqrt(c_2);

    cout << fixed << setprecision(20) << c << endl;
}

Measured memory_bytes: 4164
import java.util.Map;
import java.util.TreeMap;
import java.io.*;
import java.util.*;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Collections;
import java.util.HashMap;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner();
        try (final FastWriter writer = new FastWriter()) {
            TreeMap<String, Long> cnt = new TreeMap<>();
            int N = scanner.nextInt();
            for (int i = 0; i < N; i++) {
                String s = scanner.next();
                cnt.putIfAbsent(s, 0l);
                cnt.put(s, cnt.get(s) + 1);
            }
            long max = Collections.max(cnt.values());
            for (Map.Entry<String, Long> entry : cnt.entrySet()) {
                if (entry.getValue().equals(max)) {
                    writer.println(entry.getKey());
                }
            }
        }
    }
}

class FastScanner {
    private final BufferedReader br;
    private StringTokenizer st;

    public FastScanner() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

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

    public int nextInt() {
        return Integer.parseInt(next());
    }

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

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

class FastWriter extends PrintWriter {
    public FastWriter() {
        super(new BufferedOutputStream(System.out));
    }

    public static void main(final String[] args) {
        try (final FastWriter w = new FastWriter()) {
            w.println(32);
        }
    }
}



Measured memory_bytes: 51352
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

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

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

ll S(ll n){
	if(n<10) return n;
	else return n%10+S(n/10);
}

double snuke(pair<ll,ll> p){
	return (double)p.first/p.second;
}

ll f(ll n){

	vector<pair<ll,ll> > res;

	//pair<ll,ll> y;
	// y.first = n;
	// y.second = S(n);
	// res.push_back(y);

	for(int d = 0; d < 15; d++){
		ll x = pow(10,d)*floor((double)n/pow(10,d)+1)-1;
		pair<ll,ll> y;
		y.first = x;
		y.second = S(x);
		res.push_back(y);
	}

	ll m=res[0].first;
	double ms = snuke(res[0]);

	for(int i = 0; i < res.size(); i++){
		//cout << snuke(res[i]) << endl;
		if(ms > snuke(res[i])){
			m = res[i].first;
			ms = snuke(res[i]);
		}
	}

	return m;
}

int main()
{
	ll k;
	cin >> k;
	ll a = 1;
	for(int i = 1; i <= k; i++){
		cout << a << endl;
		a = f(a+1);
	}

	return 0;
}


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

using ll = long long;

int main() {
    int n; cin >> n;
    vector<ll> a(n);
    ll odd_sum = 0, even_sum = 0;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
        (i & 1 ? odd_sum : even_sum) += max(a[i], 0LL);
    }
    { // corner
        const int ma_idx = max_element(begin(a), end(a)) - begin(a);
        if(a[ma_idx] <= 0) {
            cout << a[ma_idx] << endl;
            cout << n - 1 << endl;
            for(int i = n; i >= ma_idx + 2; --i) {
                cout << i << endl;
            }
            for(int i = 0; i < ma_idx; ++i) {
                cout << 1 << endl;
            }
            return 0;
        }
    }

    vector<bool> rm(n);
    for(int i = 0; i < n; ++i) {
        if(odd_sum >= even_sum) {
            rm[i] = i % 2 == 0 || a[i] < 0;
        } else {
            rm[i] = i % 2 == 1 || a[i] < 0;
        }
    }

    vector<int> rm_ans;
    while(rm[0]) {
        rm_ans.push_back(1);
        rm.erase(begin(rm));
    }
    while(rm.back()) {
        rm_ans.push_back(rm.size());
        rm.pop_back();
    }
    while(rm.size() > 1u) {
        vector<bool> nxt;
        for(int i = 0; i < (int)rm.size(); ++i) {
            if(!nxt.empty() && rm[i] && i + 1 < (int)rm.size() && !(nxt.back() ^ rm[i + 1])) {
                rm.erase(begin(rm) + i);
                rm.erase(begin(rm) + i);
                rm_ans.push_back(i + 1);
                i--;
            } else {
                nxt.push_back(rm[i]);
            }
        }
        rm = move(nxt);
    }

    cout << max(odd_sum, even_sum) << endl;
    cout << rm_ans.size() << endl;
    for(auto r : rm_ans) {
        cout << r << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    string S;
    cin >> S;
    int ans=0;
    rep(i,S.length()-1) if(S[i]!=S[i+1]) ans++;
    cout << ans << endl;
}

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

int main() {
    vector<vector<int>> c(3,vector<int>(3));
    rep(i, 3) rep(j, 3) cin >> c.at(i).at(j);

    bool ok = 
    (c.at(0).at(0) - c.at(0).at(1) == c.at(1).at(0) - c.at(1).at(1)) &&
    (c.at(1).at(0) - c.at(1).at(1) == c.at(2).at(0) - c.at(2).at(1)) &&
    (c.at(0).at(1) - c.at(0).at(2) == c.at(1).at(1) - c.at(1).at(2)) &&
    (c.at(1).at(1) - c.at(1).at(2) == c.at(2).at(1) - c.at(2).at(2));

    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3560
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: u32,
        b: u32,
    }
    if a + b >= 10 {
        println!("error");
    } else {
        println!("{}", a + b);
    }
}


Measured memory_bytes: 4352
#include<stdio.h>
int main()
{
	int n;
	scanf("%d", &n);
	int i;
	int a[200005];
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	int x = 0;
	for (i = 0; i < n; i++)
		x ^= a[i];
	for (i = 0; i < n - 1; i++)
		printf("%d ", x ^ a[i]);
	printf("%d\n", x ^ a[n - 1]);
	return 0;
}

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


#define ll long long int
#define ld long double
#define mod 1000000007
#define big 1e18+10
#define small -big
#define pb push_back



template <typename T>

void prarr(T a)
{
     cerr << "[ ";
     
     for(auto i : a){
         cerr << i << " ";
     }
     
     cerr << "]" << endl;
}


#define trace(...) _er(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void _er(const char* name, Arg1&& arg1){
	cerr << "[" << name << " : " << arg1 << "]" << endl;
}

template <typename Arg1, typename... Args>

void _er(const char* names, Arg1&& arg1, Args&&... args){
    
	const char* comma = strchr(names + 1, ',');
	cerr << "[" ; cerr.write(names, comma - names) << " : " << arg1 << "] ";
	_er(comma+2, args...);
}






void solve() {
    
   string N;
   cin >> N;
   
   ll sum = 0;
   ll a = 9;
   
   for(ll i = 0; i < N.size(); i++) {
            sum = (sum % a) * (10LL % a) % a;
            sum = (((sum % a) + ((N[i] - 48) % a)) % a);
   }
   
   if(sum == 0LL) {
        cout << "Yes" << endl;
   } else {
        cout << "No" << endl;
   }
}


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

    int t=1;
    //cin >> t;

    for(int i = 1; i <= t; i++) {  
   
         solve();
    }


    return 0;
        
}


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

vector<int> A;
int n;

int solve(int i,int m){
    if(m==0) return true;
    if(i>=n) return false;

    int res=solve(i+1,m)||solve(i+1,m-A[i]);
    return res;
}

int main(){
    int q,m;
    cin>>n;
    
    rep(i,n){
        int Ai;
        cin>>Ai;
        A.push_back(Ai);
    }
    cin>>q;
    rep(i,q){
        cin>>m;
        if(solve(0,m)) cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3160
def main():
    n, m, x = map(int, input().split())
    c = []
    a = []
    for _ in range(n):
        ac = list(map(int, input().split()))
        c.append(ac[0])
        a.append(ac[1:])
    answer = float("inf")
    for i in range(1, pow(2, n)):
        now = 0
        all_c = [0 for _ in range(m)]
        for j in range(n):
            if (i >> j) & 1:
                for k in range(m):
                    all_c[k] += a[j][k]
                now += c[j]
        if all(all_c[j] >= x for j in range(m)):
            answer = min(answer, now)
    print(answer if answer < float("inf") else -1)


if __name__ == '__main__':
    main()



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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

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

#define MP make_pair
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N;
	cin >> N;
	vector<LL> A(N);
	REP(i, N) cin >> A[i];

	vector<vector<LL>> dp(3, vector<LL>(N, 0));
	dp[0][0] = A[0];

	FOR(i, 1, N){
		dp[0][i] = dp[0][i - 1];
		if(!(i & 1) && i != N - 1){
			dp[0][i] += A[i];
		}
		dp[1][i] = dp[1][i - 1];
		if(i & 1){
			dp[1][i] += A[i];
			if(3 <= i) dp[1][i] = max(dp[0][i - 3] + A[i], dp[1][i]);
		}
		dp[2][i] = dp[2][i - 1];
		if(!(i & 1)){
			dp[2][i] += A[i];
			if(3 <= i) dp[2][i] = max(dp[1][i - 3] + A[i], dp[2][i]);
			if(4 <= i) dp[2][i] = max(dp[0][i - 4] + A[i], dp[2][i]);
		}
		// cerr << i << " : " << dp[0][i] << " " << dp[1][i] << " " << dp[2][i] << endl;
	}

	if(N % 2){
		cout << max({dp[0][N - 3], dp[1][N - 2], dp[2][N - 1]}) << endl;
	}
	else{
		cout << max({dp[0][N - 2], dp[1][N - 1]}) << endl;
	}

	return 0;
}


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

using namespace std;
using ll = long long int;
constexpr ll M = 1e9 + 7;
inline ll sum_1(const ll n) { return ((n * (n + 1)) / 2) % M; }
inline ll sum_2(const ll n) { return ((n * (n + 1) * (2 * n + 1)) / 6) % M; }
inline ll sum_3(const ll n) { return (((n * (n + 1)) / 2) % M * ((n * (n + 1)) / 2) % M) % M; }
inline ll sum_1(const ll i, const ll j) { return (sum_1(j) - sum_1(i - 1) + M) % M; }
inline ll sum_2(const ll i, const ll j) { return (sum_2(j) - sum_2(i - 1) + M) % M; }
inline ll sum_3(const ll i, const ll j) { return (sum_3(j) - sum_3(i - 1) + M) % M; }

ll pow_f(ll b, ll e) {
    ll ans = 1;
    b = b % M;
    while (e) {
        if (e&1) {
            ans = (ans * b) % M;
        }
        b = (b * b) % M;
        e >>= 1;
    }
    return ans;
}

ll nCr(ll n, ll r) {
    if (r > n || n < 0 || r < 0) { return 0; }
    if (n == r || r == 0) { return 1; }
    r = min(r, n-r);
    ll ans = 1;
    for (ll i = 1; i <= r; ++i) {
        ans = (ans * (n-i+1))/(i); 
    }
    return ans;
}

ll nCr(tuple<ll,ll> t) {
    auto n = get<0>(t);
    auto k = get<1>(t);
    return nCr(n+k-1, k);
}

template<typename T>
void print(T v) {
    cout << v << " ";
}

template<typename T>
void print(vector<T> v) {
    for (auto &i : v) {
        print(i);
    }
    cout << endl;
}

void solve() {
    string s, t;
    cin >> s >> t;
    if (t.substr(0, s.size()) == s) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifdef D_LOCAL
        freopen("in.in", "r", stdin);
        freopen("out.out", "w", stdout);
    #endif

    solve();

    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

int main(){

	int n;
	string s, t;

	cin >> n;
	cin >> s;
	cin >> t;


	for (int i = 0;i < n;i++) {
		cout << s[i] << t[i];
	}
	cout << endl;


}


Measured memory_bytes: 256