akhauriyash/Code-Regression huggingface dataset:
// timusg
#include <iostream>
#include <bits/stdc++.h>

int main(){
	using namespace std;
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int mod = 1e9 + 7;
	int cas = 1;
	//cin >> cas;
	while(cas--){
		int64_t a, b, c;
		cin >> a >> b >> c;
		int64_t sum = a + b;
		if(sum>= c){
			cout << "Yes\n";
		}
		else cout << "No\n";
	}
	
	return 0;
}  



Measured memory_bytes: 3480
// Problem : 
// 			D - Xor Sum 2
// 			Editorial
// 		
// Contest : AtCoder - AtCoder Regular Contest 098
// URL : https://atcoder.jp/contests/arc098/tasks/arc098_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int n;
	cin >> n;
	vl a(n);
	loop(i,n)
		cin>>a[i];
	int r=0;
	ll cxor=0,ans=0;
	loop(i,n)
	{
		while(r<n && (cxor&a[r])==0)
		{
			cxor^=a[r];
			r++;
		}
		cxor^=a[i];
		ans+=r-i;
	}
	cout<<ans;
}
// read the question correctly (ll vs int)
// template by bqi343

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



 int main(){
    int n;
    cin>>n;
    vector<char>k;
    int c=0;
    for(int i=0;i<n;i++){
       char p;
       cin>>p;
       k.push_back(p);
    }
    for(int i=0;i<n;i++){
       if(k[i+1]!=k[i]){
           c++;
       }
    }
  
   

     
cout<<c;
       
 }
    

Measured memory_bytes: 512
n,k = map(int,input().split())
a = list(map(int,input().split()))
s = a.index(1)

count = 0
now = 0
while now < n-1:
	now += k-1
	count += 1
	if now == s and (now+k) > n-1:
		now += k-2
		count += 1
print(count)

Measured memory_bytes: 13880
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

# L, R, U, D方向の照らされるマス数を事前に計算
L = [[0] * W for _ in range(H)]
R = [[0] * W for _ in range(H)]
U = [[0] * W for _ in range(H)]
D = [[0] * W for _ in range(H)]

for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      L[i][j] = 0
    elif j == 0:
      L[i][j] = 1
    else:
      L[i][j] = L[i][j - 1] + 1

for i in range(H):
  for j in reversed(range(W)):
    if S[i][j] == "#":
      R[i][j] = 0
    elif j == W - 1:
      R[i][j] = 1
    else:
      R[i][j] = R[i][j + 1] + 1

for i in range(H):
  for j in range(W):
    if S[i][j] == "#":
      U[i][j] = 0
    elif i == 0:
      U[i][j] = 1
    else:
      U[i][j] = U[i - 1][j] + 1

for i in reversed(range(H)):
  for j in range(W):
    if S[i][j] == "#":
      D[i][j] = 0
    elif i == H - 1:
      D[i][j] = 1
    else:
      D[i][j] = D[i + 1][j] + 1

ans = 0
for i in range(H):
  for j in range(W):
    ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)

print(ans)

Measured memory_bytes: 309512
s = input()
s_list = []

for i in s:
    s_list.append(i)
del s_list[-1]

while True:
    s_half = int(len(s_list)/2)
    s1 = s_list[:s_half]
    s2 = s_list[s_half:]
    if s1 == s2:
        print(s_half*2)
        break
    else:
        del s_list[-1]


Measured memory_bytes: 3060
let a_s, ws, w, m = Scanf.scanf "%d %d" @@ fun n m -> Array.(make (n + 1) 0, make (n + 1) 0, ref 0, m)
let _ = for _ = 1 to m do Scanf.scanf " %d %s" @@ fun p s -> if a_s.(p) = 0 then if s = "AC" then (a_s.(p) <- 1; w := !w + ws.(p)) else ws.(p) <- ws.(p) + 1 done; Printf.printf "%d %d\n" (Array.fold_left (+) 0 a_s) !w

Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,k;
	cin>>n>>k;
	long long rem=0;
	long long ans=0;
	while(n>0){
		rem=n%k;
		n/=k;
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int n, h[100005], m, a, b, ans;
bool die[100005];

int main() {
	fastio; cin >> n >> m;
	FOR(i, 1, n) cin >> h[i];
	FOR(i, 1, m) {
		cin >> a >> b;
		if (h[a] >= h[b]) die[b] = 1;
		if (h[b] >= h[a]) die[a] = 1;
	}
	FOR(i, 1, n) if (!die[i]) ans++;
	cout << ans;
}


Measured memory_bytes: 4104
#include<iostream>
#include<string>
using namespace std;
string o;
void rec(string str){
  //cout << str << endl;
  string buf=str;
  if(buf.find("mmewe")!=-1){
    buf.replace(buf.find("mmewe"),5,"me");
    rec(buf);
  }else if(buf.find("emeww")!=-1){
    buf.replace(buf.find("emeww"),5,"ew");
    rec(buf);
  }else{
    if(buf==""||buf=="mew") o="Cat";
    else o="Rabbit";
  }
}
int main(){
  string str;
  cin >> str;
  rec(str);
  cout << o << endl;
  return 0;
}

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

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll amari = n % (a + b);
    ll ans;
    ans = ((n - amari) / (a + b)) * a;
    if(amari <= a) {
        ans += amari;
    } else {
        ans += a;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3584
#include<stdio.h>

int main(void){
	
	int a[10001],n,i,min,max;
	long sum;
	
	sum=0;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		if(i==0){
			min=a[i];
			max=a[i];
		}
		else if(min>a[i]){
			min=a[i];
		}
		else if(max<a[i]){
			max=a[i];
		}
		sum+=(long)a[i];
	}
	printf("%d %d %ld\n",min,max,sum);
	
	return 0;
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T = int> void print(vector<T> v){for(auto a:v)cout<<a<<" ";cout<<endl;}

/*
*/

ll x,n,p[110],a[110]={},l=1e9,ans=0;

int main(void){
	cin>>x>>n;
	rep(i,n)cin>>p[i];
	rep(i,n)a[p[i]]=1;
	reg(i,0,101)if(abs(x-i)<l && a[i]==0){
		ans=i;
		l=abs(x-i);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <string>
#include <cmath>
#include <complex>
#include <numeric>
#include <cassert>

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>

#define PI 3.14159265358979323846
#define int64 long long
#define uint64 unsigned long long
#define coutfix(i) cout << fixed << setprecision(i)		//coutの浮動小数出力の桁数設定
using namespace std;

int main()
{
	uint64 nn, mm, ans = 0;
	cin >> nn >> mm;
	vector<pair<int64, int64>> memo(nn);
	for(int64 ii = 0;ii < nn;ii++)
	{
		cin >> memo[ii].first >> memo[ii].second;
	}
	sort(memo.begin(), memo.end());
	for(int64 ii = 0;ii < nn;ii++)
	{
		if(memo[ii].second <= mm)
		{
			mm -= memo[ii].second;
			ans += memo[ii].second * memo[ii].first;
		}
		else
		{
			ans += mm * memo[ii].first;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define ll long long int
#define ld long double
#define MAX 1001
#define MOD 1000000007
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int main(){

    fast;

    ld n;
    cin >> n;

    cout << 2*3.14159265359*n << endl;

}










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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
const ll LINF = 1e11;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

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

    int n;
    cin >> n;
    vi v = vi(n);
    vi c = vi(n);
    for (int i = 0; i < n; ++i) cin >> v[i];
    for (int i = 0; i < n; ++i) cin >> c[i];
    int ans = 0;

    for (int i = 0; i < n; ++i) {
        if(v[i] > c[i]){
            ans += v[i] - c[i];
        }
    }

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


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

using namespace std;
#define maxn 100010
#define cmax(_a, _b) (_a < (_b)? _a = (_b) : 0)
char s[maxn];
int fail[maxn], ans;
void build(char *s, int n)
{
  fail[1] = 0;
  int p = 0, p2 = 0;
  for (int i = 2; i <= n; ++i)
  {
    while (p && s[i] != s[p + 1]) p = fail[p];
    while (p2 && s[i] != s[p2 + 1]) p2 = fail[p2];
    s[i] == s[p + 1] ? ++p : 0;
    s[i] == s[p2 + 1] ? ++p2 : 0;
    while (2 * p2 > i) p2 = fail[p2];
    fail[i] = p;
    cmax(ans, p2);
  }
}
int main()
{
  int n; cin >> n >> s + 1;
  for (int i = 1; i <= n; ++i)
  {
    build(s + i - 1, n - i + 1);
  }
  printf("%d\n", ans);
  return 0;
}


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

int main(void) {
	int n; cin >> n;
	vector<int> A(n);
	for (int i = 0; i < n; i++) scanf("%d", &A[i]);
	sort(A.begin(), A.end());

	bool flag = true;
	for (int i = 1; i < n; i++) {
		if (A[i - 1] == A[i]) {
			flag = false;
			break;
		}
	}
	cout << (flag ? "YES" : "NO") << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
    string s;
    cin >> s;
    cout << s[0] << s.length() -  2 << s[s.length()-1] << endl;
    return 0;
}

Measured memory_bytes: 768
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
// #define double long double
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   200005
#define MAX 300005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
//#define endl "\n"
#define inf 1e+15
int a[N]={0};
signed main(){
  fast;
  int n , m,l,r,ans=0;
  cin>>n>>m;
  for(int i=0;i<m;i++){
  	   cin>>l>>r;
  	   a[l]+=1;
  	   a[r+1]-=1;
  }
  for(int i=1;i<=n;i++){
  	a[i] += a[i-1] ;
  	if(a[i]==m) ans++;
  }
  cout<<ans<<endl;

}
  


Measured memory_bytes: 1024
# -*- Coding: utf-8 -*-

x = int(input())
min_sosu = x
flg_found = False

for i in range(x, 1000000):
    for j in range(2, i*i):
        if i%j == 0 and j < x:
            break
        if i%j == 0 and j >= x and i == j:
            min_sosu = i
            flg_found = True
            print(min_sosu)
            break
    if flg_found:
        break


Measured memory_bytes: 2940
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    for i in range(1, 10):
        for j in range(1, 10):
            if i*j == n:
                print('Yes')
                exit()
    print('No')




if __name__ == '__main__':
    main()

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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a ? gcd (b % a, a) : b; }

int n;
int m;

int sxor[1 << 16];
int scnt[1 << 16];
int ans[1 << 16];
vii v[100000];

ii merge (ii a, ii b) {
	re mp (a.fi ^ b.fi, a.se + b.se + scnt[a.fi & b.fi]);
}

ii go (int x, int p, int up) {
	ii cur (0, 0);
	for (int i = 0; i < sz (v[x]); i++) {
		int y = v[x][i].fi;
		int z = v[x][i].se;
		if (y == p) continue;
		cur = merge (cur, go (y, x, z));
	}
	if (x != p && sxor[cur.fi] != up) cur = merge (cur, mp (1 << (sxor[cur.fi] ^ up), 0));
/*	printf ("%d %d %d = %d %d | ", x, p, up, cur.fi, cur.se);
	for (int j = 0; j < 16; j++) printf ("%d", (cur.fi >> j) & 1);
	printf ("\n");*/
	re cur;
}

int main () {
	scanf ("%d", &n);
	for (int i = 0; i < n - 1; i++) {
		int a, b, c;
		scanf ("%d%d%d", &a, &b, &c);
		v[a].pb (mp (b, c));
		v[b].pb (mp (a, c));
	}
	for (int i = 0; i < (1 << 16); i++) {
		int cur = 0, cnt = 0;
		for (int j = 0; j < 16; j++)
			if ((i >> j) & 1) {
				cur ^= j;
				cnt++;
			}	
		sxor[i] = cur;
		scnt[i] = cnt;
	}
	ii res = go (0, 0, 0);
	ans[0] = 0;
	for (int i = 1; i < (1 << 16); i++) {
		ans[i] = scnt[i];
		for (int j = 1; j < 16; j++)
			if ((i >> j) & 1)
				for (int k = 1; k < j; k++) 
					if ((j ^ k) < j)
						ans[i] = min (ans[i], ans[i ^ (1 << j) ^ (1 << k) ^ (1 << (j ^ k))] + int ((i >> k) & 1) + int ((i >> (j ^ k)) & 1));
	}
	printf ("%d\n", ans[res.fi] + res.se);
	return 0;
}

Measured memory_bytes: 13952
import math

K = int(input())
g = 0
for i in range(1, K+1):
    for j in range(1, i+1):
        for k in range(1, j+1):
            a = math.gcd(i, j)
            b = math.gcd(a, k)
            if i != j != k:
                g += b*6
            elif i == j == k:
                g += b
            else:
                g += b*3

print(g)


Measured memory_bytes: 9192
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

using i8 = ::std::int_least8_t;
using i32 = ::std::int_least32_t;
using i64 = ::std::int_least64_t;
using u8 = ::std::uint_least8_t;
using u32 = ::std::uint_least32_t;
using u64 = ::std::uint_least64_t;
using isize = ::std::ptrdiff_t;
using usize = ::std::size_t;

template<class T>
class rep {
	const T f, l;

public:
	class itr {
		friend rep;
		T i;
		itr(T x) noexcept : i(x) {}

	public:
		void operator++() noexcept { ++i; }
		T operator*() const noexcept { return i; }
		bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	rep(const T first,const T last) noexcept : f(first), l(last) {}
	itr begin() const noexcept { return itr(f); }
	itr end() const noexcept { return itr(l); }
};
class revrep {
	const usize f, l;

public:
	class itr {
		friend revrep;
		usize i;
		itr(usize x) noexcept : i(x) {}

	public:
		void operator++() noexcept { --i; }
		usize operator*() const noexcept { return i; }
		bool operator!=(const itr x) const noexcept { return i != x.i; }
	};
	revrep(usize first, usize last) noexcept : f(first), l(last) {}
	itr begin() const noexcept { return itr(l - 1); }
	itr end() const noexcept { return itr(f - 1); }
};
template <class T> bool maxi(T &a, const T &b) {
	return a <= b ? (a = b, 1) : 0;
}
template <class T> bool mini(T &a, const T &b) {
	return b <= a ? (a = b, 1) : 0;
}
template <class T> bool smaxi(T &a, const T &b) {
	return b <= a ? 0 : (a = b, 1);
}
template <class T> bool smini(T &a, const T &b) {
	return a <= b ? 0 : (a = b, 1);
}
template <class T> using vec_alias = ::std::vector<T>;
template <class T> auto md_vec(usize n, const T &value) {
	return ::std::vector<T>(n, value);
}
template <class... Args> auto md_vec(usize n, Args... args) {
	return ::std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> const T &as_const(const T &v) noexcept { return v; }

#include <algorithm>
#include <iostream>
#include <utility>

template <class T> T difference(const T &a, const T &b) {
	return a <= b ? b - a : a - b;
}

class pos {
public:
	u32 x, y, h;
};

u32 is_valid(const pos &p, const pos &c) {
	const u32 dx = difference(p.x, c.x), dy = difference(p.y, c.y);
	if (p.h < dx + dy)
		return !c.h;
	else
		return c.h == p.h - dx - dy;
}

int main() {
	usize n;
	::std::cin >> n;
	::std::vector<pos> a(n);
	for (auto &e : a)
		::std::cin >> e.x >> e.y >> e.h;
	::std::sort(a.begin(),a.end(),
		[](const pos &l,const pos &r){
		return l.h > r.h;});

	for (const auto x : rep<u32>(0, 101)) {
		for (const auto y : rep<u32>(0, 101)) {
			const pos p = {
				x,
				y,
				a[0].h + difference(a[0].x,x) + difference(a[0].y,y)
			};
			if (::std::all_of(a.cbegin(), a.cend(),
				[p](const pos &c) {return is_valid(p, c);}))
				return ::std::cout << p.x << " " << p.y << " "
				<< p.h << ::std::endl, 0;
		}
	}

	return 0;
}


Measured memory_bytes: 256
object Main extends App{
  var ans = 0
  var num = readLine
  if(num.split(" ")(2).toInt <= num.split(" ")(0).toInt+num.split(" ")(1).toInt+1){
    ans = num.split(" ")(1).toInt + num.split(" ")(2).toInt
  }else{
    ans = num.split(" ")(0).toInt + 2*num.split(" ")(1).toInt + 1
  }
  println(ans);
}


Measured memory_bytes: 27208
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
typedef long long ll;
using namespace std;
int main(){
	ll n,k,res;
	scanf("%lld%lld",&n,&k);
	ll t=n;
	n%=k;
	if(n==0)
		cout<<0;
	else{
		for(int i=1;i<1e5;i++){
			t=min(t,abs(n-k));
		}
		cout<<t;
	}
	
	return 0;
} 

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


int main(void){
    
    int H,N;
    cin >> H >> N;
    int A[N],B[N];
    for (int i = 0; i < N; ++i) cin >> A[i] >> B[i];
    long long DP[N+1][H+1];
    
    for(int i = 0; i < N + 1;i++){
        for(int j = 0; j < H + 1;j++){
            DP[i][j] = INT_MAX;
            //cout << i <<" "<< j <<endl;
            //cout << DP[i][j] <<endl;
        }
        
    }
    //cout << DP[1][0] << endl;
    //for(int i = 0; i < H+1;i++)DP[N][i] = 0;
    DP[0][0] = 0;
    
    for(int i = 0; i < N ;i++){
        for(int j = 0; j <= H;j++){
            //cout <<"a"<< i << endl;
            //cout << DP[i+1][j]<<endl;
            DP[i+1][j] = min(DP[i+1][j],DP[i][j]);
            //cout << "i+1 "<<min(j + A[i],H) <<endl;
            //cout << DP[i + 1][min(j + A[i],H)] << endl;
            DP[i + 1][min(j + A[i],H)] = min(DP[i + 1][min(j + A[i],H)],DP[i+1][j]+B[i]);
            //cout << i << endl;
        }
        //cout << i << endl;
    
    }
    
    cout << DP[N][H] <<endl;
    
    
}


Measured memory_bytes: 78464
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+20;
int a[N],n;
bool check(int k)
{
	for(int i=0;i<n-1;i++)
	{
		if((a[n-i]<=k&&a[n-i-1]<=k)||(a[n+i]<=k&&a[n+i+1]<=k))return 1;
		if((a[n-i]>k&&a[n-i-1]>k)||(a[n+i]>k&&a[n+i+1]>k))return 0;
	}
	return a[1]<=k;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<(n<<1);i++)
	  scanf("%d",&a[i]);
	int l = 1,r=(n<<1)-1;
	while(l<r)
	{
		int mid = l + r >> 1 ;
		if(check(mid)) r = mid;
		else l = mid + 1;
	}
	printf("%d\n",l);
	return 0;
}

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

int main(){

long double a,b ,x,y;

cin >> a >> b;

x = a * b;

y = (long long int)x;

cout << (long long int)y << endl;

}



Measured memory_bytes: 3732
#pragma GCC optimize(3, "Ofast", "inline")

#include <bits/stdc++.h>

#define start ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define int ll
#define ls st<<1
#define rs st<<1|1
#define pii pair<int,int>
#define rep(z, x, y) for(int z=x;z<=y;++z)
#define repd(z, x, y) for(int z=x;z>=y;--z)
#define com bool operator<(const node &b)const
using namespace std;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
const int maxn = (ll) 3e5 + 5;
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
int T = 1;

void solve() {
    int n, x, t;
    cin >> n >> x >> t;
    cout << (n / x + (n % x != 0)) * t << '\n';
}

signed main() {
    start;
    while (T--)
        solve();
    return 0;
}

Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <map>
#include<set>
#include <cmath>
using namespace std;



int main() {
	int n;
	cin >> n;
	int count = 0;
	vector<int> a(n);
	int v;
	for (int i = 0; i < n;i++) {
		cin >> a.at(i);
	}
	for (int i = 1;i< n;i++) {
		for (int j = i;j >= 1;j--) {
			if (a.at(j) < a.at(j-1)) {
				v = a.at(j);
				a.at(j) = a.at(j-1);
				a.at(j-1) = v;
				count++;
			}
		}
	}
	for (int i = 0; i < n;i++) {
		cout << a[i];
		if (i < n-1)cout << " ";
		else cout << endl;
	}
	cout << count << endl;
}



Measured memory_bytes: 3084
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        var str = ReadLine();
        var back = string.Join("", str.Reverse());
        var w = new[]
        {
            "remaerd",
            "maerd",
            "resare",
            "esare"
        };
        
        for (var i = 0; i < str.Length;)
            if (back.Substring(i, 5) == w[1] ||
                back.Substring(i, 5) == w[3])
                i += 5;
            else if (back.Substring(i, 6) == w[2])
                i += 6;
            else if (back.Substring(i, 7) == w[0])
                i += 7;
            else { WriteLine("NO"); return; }
        WriteLine("YES");
    }
}


Measured memory_bytes: 15384
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin>>N;
    int A[N],B[N],C[N];
    int sum=0;
    for(int i=0;i<N;i++)cin>>A[i];
    for(int i=0;i<N;i++)cin>>B[i];
    for(int i=0;i<N;i++)cin>>C[i];
    for(int i=0;i<N;i++){
        sum+=B[A[i]-1];
        if(i>0&&A[i]==A[i-1]+1)sum+=C[A[i]-2];

    }
    cout<<sum<<endl;
}

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

typedef long long ll;
typedef pair<int, int> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod 1e9+7

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int main() {
  map<P, int> mp;
  rep(i, 0, 6) {
    int h, w;
    cin >> h >> w;
    mp[P(min(h, w), max(h, w))]++;
  }
  vector<P> v;
  for(auto x : mp) {
    if(x.second % 2 == 1) {
      cout << "no" << endl;
      return 0;
    }
    rep(i, 0, x.second / 2) v.pb(x.first);
  }
  int f = 0;
  if(v[0].first == v[1].first) {
    if(v[0].second == v[2].first && v[1].second == v[2].second) f = 1;
    if(v[0].second == v[2].second && v[1].second == v[2].first) f = 1;
  }
  if(v[0].first == v[1].second) {
    if(v[0].second == v[2].first && v[1].first == v[2].second) f = 1;
    if(v[0].second == v[2].second && v[1].first == v[2].first) f = 1;
  }
  if(v[0].second == v[1].first) {
    if(v[0].first == v[2].first && v[1].second == v[2].second) f = 1;
    if(v[0].first == v[2].second && v[1].second == v[2].first) f = 1;
  }
  if(v[0].second == v[1].second) {
    if(v[0].first == v[2].first && v[1].first == v[2].second) f = 1;
    if(v[0].first == v[2].second && v[1].first == v[2].first) f = 1;
  }
  if(f) cout << "yes" << endl;
  else cout << "no" << endl;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
typedef int ll;
const ll N=2e5+5,inf=1e9;
ll dp[N],prfx[N],best[1<<26];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;cin>>s;
    ll n=s.size();
    for(ll i=0;i<n;i++)prfx[i+1]=prfx[i]^(1<<(s[i]-'a'));
    for(ll i=0;i<(1<<26);i++)best[i]=inf;
    dp[0]=best[prfx[0]]=0;
    for(ll i=1;i<=n;i++){
        dp[i]=inf;
        for(ll bit=-1;bit<26;bit++){
            ll cur = prfx[i];
            if(bit>=0)cur^=(1ll<<bit);
            dp[i]=min(dp[i] , best[cur]+1);
        }
        best[prfx[i]]=min(best[prfx[i]],dp[i]);
    }
    cout<<dp[n];
}

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

using namespace std;
using ll = long long;

ll sqint(ll num){

    ll l = 0;
    ll r = 1e10;

    while(r - l > 1){
        ll mid = (r + l) / 2;
        (mid * mid <= num ? l : r) = mid;
    }
    return l;
}

template<class T> ostream& operator<<(ostream& os, const vector<T> arr){ for(int i = 0; i < (int)arr.size(); i++)cout << arr[i] << (i == (int)arr.size() -1 ? "" : " "); return os;}

int main()
{
    int n; cin >> n;
    int d = (sqint(8 * n + 1) - 1) / 2;
    if((2 * d + 1) * (2 * d + 1) != 8 * n + 1) {
        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    cout << d + 1 << endl;

    vector<vector<int>> res(d + 1);
    int nax = 1;
    for(int i = 0; i <= d; i++) {
        vector<int> ans;
        vector<int> nxt;
        for(int j = 0; j < i; j++)ans.push_back(res[j].back()),res[j].pop_back();
        for(int j = i; j < d; j++)ans.push_back(nax), nxt.push_back(nax++);
        
        cout << ans.size() << " " << ans << endl;
        reverse(nxt.begin(), nxt.end());
        res[i] = nxt;
    }

}

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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> L(M);
    vector<int> R(M);
    for (int i = 0; i < M; i++) cin >> L[i] >> R[i];

    vector<int> C(N + 1);
    for (int i = 0; i < M; i++) {
        C[L[i] - 1]++;
        C[R[i]]--;
    }
    for (int i = 0; i < N; i++) C[i + 1] += C[i];
    cout << count(C.begin(), C.end(), M) << endl;
}

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

int main() {
  string a,b;
  cin >> a >> b;
  a=a+b;
  int n = stoi(a);
  bool ans=false;
  for(int i=1;i<500;i++){
    if(n==i*i)ans=true;
  }
  if(ans)cout << "Yes";
  else cout << "No";
}


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

int main(){
  int N, A, B;
  string S;
  cin >> N >> A >> B >> S;
  int nA=0, nB=0;
  for(int i=0; i<N; i++){
    if(S.at(i)=='c'){
      cout << "No" << endl;
    }
    else if(S.at(i)=='a'){
      if(nA+nB<A+B){
        cout << "Yes" << endl;
        nA++;
      }
      else{
        cout << "No" << endl;
      }
    }
    else{
      if(nA+nB<A+B && nB<B){
        cout << "Yes" << endl;
        nB++;
      }
      else{
        cout << "No" << endl;
      }
    }
  }
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int Link[100010],t=1,c[100010],ans[100010],n,k;
bool vis[100010];
struct dsa
{
	int l,r,fla;
}a[100010];
struct das
{
	int v,nex;
}e[200010];
void Insert(int xx,int yy)
{
	e[++t].nex=Link[xx];
	e[t].v=yy;
	Link[xx]=t;
}
bool dfs(int now,int fa)
{
	a[now].l=-1e9;a[now].r=1e9;a[now].fla=2;
	int s=0,s1=0;
	for (int i=Link[now];i;i=e[i].nex)
	{
		if (e[i].v==fa) continue;
		if (!dfs(e[i].v,now)) return false;
		a[now].l=max(a[now].l,a[e[i].v].l);
		a[now].r=min(a[now].r,a[e[i].v].r);
		if (a[e[i].v].fla==0) s++;
		else if (a[e[i].v].fla==1) s1++;
    }
    a[now].l--;a[now].r++;
    if (s&&s1) return false;
    if (a[now].l>a[now].r||(vis[now]&&(c[now]<a[now].l||c[now]>a[now].r))) return false;
    if (vis[now]) a[now].l=c[now],a[now].r=c[now];
    if (s) a[now].fla=1;else if (s1) a[now].fla=0;
    if (vis[now]&&a[now].fla!=2&&c[now]&1!=a[now].fla) return false;
    if (a[now].l==a[now].r&&a[now].fla!=2&&a[now].l&1!=a[now].fla) return false; 
    if (vis[now]) a[now].fla=c[now]&1;
    return true;
}
void dfs1(int now,int fa,int val)
{
	ans[now]=val;
	for (int i=Link[now];i;i=e[i].nex)
	{
		if (e[i].v==fa) continue;
		if (val+1<=a[e[i].v].r) dfs1(e[i].v,now,val+1);
		else dfs1(e[i].v,now,val-1);
    }
} 
int main()
{
	scanf("%d",&n);    
	for (int i=1;i<n;i++)
	{
		int xx,yy;
		scanf("%d%d",&xx,&yy);
		Insert(xx,yy);
		Insert(yy,xx);
    }	
	scanf("%d",&k);
    for (int i=1;i<=k;i++)
    {
    	int xx,yy;
    	scanf("%d%d",&xx,&yy);
    	c[xx]=yy;
    	vis[xx]=true;
    }
    if (!dfs(1,0)) cout<<"No\n";
    else 
    {
    	printf("Yes\n");
    	if (a[1].fla!=2&&a[1].l&1!=a[1].fla) dfs1(1,0,a[1].l+1);
    	else dfs1(1,0,a[1].l);
    	for (int i=1;i<=n;i++)
    		printf("%d\n",ans[i]);
    }
    return 0;
}
    	

Measured memory_bytes: 12800
import heapq
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]
AB.sort()
h = []
i = 0
ans = 0
for m in range(M-1,-1,-1):
    while i<N and AB[i][0]+m <= M:
        heapq.heappush(h,-AB[i][1])
        i += 1
    if len(h) != 0:
        ans -= heapq.heappop(h)

print(ans)

Measured memory_bytes: 72920
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.StringTokenizer;


public class Main {
	static long [][]dp;
	static char inp[][];
	static int h;
	static int w;
	public static long ans(int i ,int j) {
		if(i==h&&j==w)return 1;
		if(i>h||j>w)return 0;
		if(inp[i][j]=='#')return 0;
		if(dp[i][j]!=-1)
			return dp[i][j];
		long r=ans(i,j+1);
		long d=ans(i+1,j);	
		return dp[i][j]=(r+d)%((long)1e9+7);	
			
	}
	
	public static void main(String[] args) throws IOException {
        Scanner sc=new Scanner(System.in);
        PrintWriter pw =new PrintWriter(System.out);
        h=sc.nextInt()-1;
        w=sc.nextInt()-1;
        inp=new char[h+1][w+1];
        dp=new long [h+1][w+1];
        for(int i=0;i<=h;i++) {
        	StringBuilder s=new StringBuilder(sc.next());
        	for(int j=0;j<=w;j++) {
        		inp[i][j]=s.charAt(j);
                 }}
        for(long x[]:dp)
        	Arrays.fill(x, -1);
        pw.println(ans(0,0));
        pw.flush();
	
        
	}
	
	static class Scanner {
		 
		StringTokenizer st;
		BufferedReader br;
 
		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
 
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}

}


Measured memory_bytes: 48816
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define pb push_back
#define vl vector<ll>
#define pll pair<ll,ll>
#define mp make_pair
using namespace std; 
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int main()
{
    ll n,k;
    cin>>n>>k;
    double dig = (double)log(n)/log(k);
    cout<<(ll)floor(dig)+1<<endl;

}

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

using namespace std;

const int N=1e6+3;

const double eps=0.000000001;

#define pb push_back
#define all(x) (x).begin(),(x).end()
typedef long long ll;

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

const int inf=1e9,mod=1e9+7;

int n,a[N],b[N],k,q,u,v,x,y,tc,c,l,r,ans;

char s[N];

void IO(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("test.txt","r",stdin);
	#endif
}

map<string,int> m;

int main(){
	//IO();
	string s;
	cin >> n;
    int mx=0;
	for(int i=0;i<n;i++){
		cin >> s;
		m[s]++;
		mx=max(mx,m[s]);
	}
	vector<string> v;
	for(auto &x:m)
        if (x.second==mx)
            v.push_back(x.first);
	for(auto &x:v)
        printf("%s\n",x.c_str());
}


Measured memory_bytes: 26868
#include <stdio.h>
int main(void){
	int t[10];
	int tb;
	int i;
	
	for(i = 0;i < 10;i++)
		t[i] = 0;
	
	while(scanf("%d",&tb) != EOF){
		if(tb > 0){
			for(i = 0;i < 10;i++){
				if(t[i] == 0){
					t[i] = tb;
					break;
				}
			}
		}else{
			for(i = 9;i >= 0;i--){
				if(t[i] != 0){
					printf("%d\n",t[i]);
					t[i] = 0;
					break;
				}
			}
		}
	}
		
	return 0;
}

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int x = 0, y = 0;
    x = (a + d - 1) / d;
    y = (b + c - 1) / b;
    cout << (x >= y ? "Yes" : "No") << endl;
}


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

#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define mp make_pair

typedef long long ll;
typedef unsigned long long int ull;
typedef long double ld;

typedef pair<int, int> pii;

typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<int> vi;

typedef map<string, int> msi;
typedef map<int, int> mii;
typedef map<int, ll> mill;
typedef map<int, vi> mivi;

const int MAXN = 1e5 + 30;
const int MOD = 1e9 + 7;

int fac[MAXN + 1];
int inv[MAXN + 1];
bool mark[MAXN + 1];
vi pf;

int n, m;
int ans = 1;

void fast_io() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
}

int mult(int a, int b) {
	return (1LL * a * b) % MOD;
}

int modpow(int x, int y) {
	int res = 1;
	while(y) {
		if(y & 1) res = mult(res, x);
		x = mult(x, x);
		y >>= 1;
	}
	return res;
}

int nCr(int n, int r) {
	return mult(mult(fac[n], inv[r]), inv[n - r]);
}

void prepare() {
	fac[0] = inv[0] = 1;
	for(int i = 1; i <= MAXN; i++) {
		fac[i] = mult(i, fac[i - 1]);
		inv[i] = modpow(fac[i], MOD - 2);
	}
	
	memset(mark, true, sizeof(mark));
	mark[0] = mark[1] = false;
	for(int i = 2; i <= MAXN; i++) {
		if(mark[i]) {
			pf.pb(i);
			for(int j = (i << 1); j <= MAXN; j += i)
				mark[j] = false;
		}
	}
}

vi find(int x) {
	vi res;
	for(int i = 0; (1LL * pf[i] * pf[i] <= x); i++) {
		if(x % pf[i]) continue;
		int cnt = 0;
		while(x % pf[i] == 0) x /= pf[i], cnt++;
		res.pb(cnt);
	}
	if(x > 1) res.pb(1);
	return res;
}

int main() {
	fast_io();
//	freopen("input/ABC110D.txt", "r", stdin);
	
	prepare();
	
	cin >> n >> m;
	
	vi fac = find(m);
	for(auto cnt : fac) {
		ans = mult(ans, nCr(n + cnt - 1, n - 1));
	}
	
	cout << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 4612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
#include <cctype>
#define _GLIBCXX_DEBUG
#define ll long long

using namespace std;


int main() {
    int x;
    cin >> x;
    cout << 180 * (x - 2) << endl;
}

Measured memory_bytes: 3644
import std.stdio, std.algorithm, std.range, std.array, std.conv, std.string;

void main() {
    int[][] C;
    foreach (i; 0..3) {
        C ~= readln.split.to!(int[]);
    }
    writeln(
        C[0][1] - C[0][0] == C[1][1] - C[1][0]
     && C[0][1] - C[0][0] == C[2][1] - C[2][0]
     && C[0][2] - C[0][0] == C[1][2] - C[1][0]
     && C[0][2] - C[0][0] == C[2][2] - C[2][0]
     ? "Yes" : "No");
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

	int N=in();
	vector<ll> A(N+1),B(N);
	REP(i,N+1){
		A[i] = in<ll>();
	}
	REP(i,N){
		B[i] = in<ll>();
	}
	ll sum = 0;
	for(int i=0;i<N;i++){
		if((A[i]-B[i])>=0){
			sum += B[i];
		}
		else{
			sum += A[i];
			ll old_Ap = A[i+1];
			A[i+1] -= (B[i]-A[i]);
			A[i+1] = max(0LL,A[i+1]);
			sum += old_Ap-A[i+1];
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <vector>
#include <string>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define f first
#define s second

const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

vector<vector<int> > cc;

int num(int x1, int y1, int x2, int y2) {
  int ans = cc[y2][x2];
  if (x1 > 0) ans -= cc[y2][x1-1];
  if (y1 > 0) ans -= cc[y1-1][x2];
  if (x1 > 0 && y1 > 0) ans += cc[y1-1][x1-1];
  return ans;
}

int main() { _
  int h,w,k; cin >> h >> w >> k;
  vector<string> choc(h);
  for (int i = 0; i < h; i++) {
    cin >> choc[i];
  }
  cc.resize(h, vector<int>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cc[i][j] = (int)(choc[i][j] - '0');
      if (i > 0) cc[i][j] += cc[i-1][j];
      if (j > 0) cc[i][j] += cc[i][j-1];
      if (i > 0 && j > 0) cc[i][j] -= cc[i-1][j-1];
    }
  }
  int ans = 1e4;
  for (int i = 0; i <= (1 << (h-1))-1; i++) {
    if (ans < __builtin_popcount(i)) {
      cout << ans << endl;
      return 0;
    }
    int it = i;
    vector<pair<int, int> > rg;
    int rs = 0, re = 0;
    for (; re < h-1; re++) {
      if (it & 1) {
        rg.push_back(make_pair(rs, re));
        rs = re + 1;
      }
      it >>= 1;
    }
    rg.push_back(make_pair(rs, re));
    int cs = 0, colc = 0;
    bool fail = false;
    for (int col = 0; col < w; col++) {
      for (pair<int, int> p : rg) {
        if (num(cs, p.f, col, p.s) > k) {
          if (cs == col) fail = true;
          colc++;
          cs = col;
          col--;
          break;
        }
      }
      if (fail) break;
    }
    if (fail) continue;
    ans = min(ans, colc+__builtin_popcount(i));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
/**
 *
 * AtCoder Beginner Contest 103 - Problem B: String Rotation (https://abc103.contest.atcoder.jp/tasks/abc103_b)
 *
 * Find if the string T is a rotation of the string S.
 *
 * String solution: let X = S + S. Check if T is a substring of X.
 */
#include <iostream>

using namespace std;

const int MAX { 100010 };
int as[MAX];

void solve(int N)
{
    auto ans = 0;

    for (int i = 0; i < N; ++i)
        ans += (as[i] - 1);

    cout << ans << endl;
}

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    for (int i = 0; i < N; ++i)
        cin >> as[i];

    solve(N);

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

void solve(int test_case) {
	int n,cnt=0,ans=0;
	cin>>n;
	string s;
	cin>>s;
	for(char c:s) {
		if(c=='I')cnt++,ans=max(ans,cnt);
		if(c=='D')cnt--,ans=max(ans,cnt);
	}
	cout<<ans;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("in", "r", stdin);
	//freopen("out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
}	


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int main(void){
  int a, b;
  cin >> a >> b;
  cout << max(a + b, max(a - b, a*b)) << endl;

  return 0;
}


ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


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

int main() {

	string s; cin >> s;
	string  ans = "Yes";
	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0) {
			if (s[i] == 'L') ans = "No";
		}
		else {
			if (s[i] == 'R') ans = "No";
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3612
M = 10 ** 9 + 7

S = int(input())

# inverse
def calc_inverse(n, law):
	if n == 1:
		return 1
	
	pre_r = law
	pre_x = 0
	pre_y = 1
	cur_r = n
	cur_x = 1
	cur_y = 0
	
	while True:
		d = pre_r // cur_r
		r = pre_r % cur_r
		
		nxt_r = r
		nxt_x = pre_x - d * cur_x
		nxt_y = pre_y - d * cur_y
		
		if nxt_r == 1:
			ret = nxt_x
			while ret < 0:
				ret += law;
			return ret;
		elif nxt_r == 0:
			return None
		
		pre_r = cur_r;
		pre_x = cur_x;
		pre_y = cur_y;
		cur_r = nxt_r;
		cur_x = nxt_x;
		cur_y = nxt_y;

facts = [1]
facts_i = [1]
def cache_facts(n, M):
	f = facts[-1]
	fi = facts_i[-1]
	for i in range(len(facts), n + 1):
		f = (f * i) % M
		fi = (fi * calc_inverse(i, M)) % M
		facts.append(f)
		facts_i.append(fi)

cache_facts(S, M)

total = 0
if S >= 3:
	total += 1

for l in range(2, S + 1):
	r = S - 3 * l
	if r >= 0:
#		print(l, r, facts[r + l - 1], facts_i[r], facts_i[l - 1])
		total = (total + facts[r + l - 1] * facts_i[r] * facts_i[l - 1]) % M

print(total)


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

int main() {
    int h, v, w, b, i, K=50;
    char map[2*K][2*K];
    cin >> w >> b;
    cout << 2 * K << " " << 2 * K << endl;
    
    for(h=0; h<2*K; h++){
        for(v=0; v<2*K; v++){
            if(h < K) map[h][v] = '#';
            else map[h][v] = '.';
        }
    }
    
    for(i=0; i<w-1; i++) map[i%2 + 2*(i/K)][2*(i%K)] = '.';
    
    for(i=0; i<b-1; i++) map[2*K - i%2 - 2*(i/K) - 1][2*(i%K)] = '#';
    
    for(h=0; h<2*K; h++){
        for(v=0; v<2*K; v++) cout << map[h][v];
        cout << endl;
    }
}

Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author khokharnikunj8
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        D solver = new D();
        solver.solve(1, in, out);
        out.close();
    }

    static class D {
        boolean[] isPrime;
        int[] calculate;

        private void pre() {
            isPrime = new boolean[2 * 100005];
            Arrays.fill(isPrime, true);
            isPrime[1] = false;
            for (int i = 2; i < 2 * 100005; i++) {
                if (!isPrime[i]) continue;
                for (int j = 2 * i; j < 2 * 100005; j += i) isPrime[j] = false;
            }
            calculate = new int[100005];
            for (int i = 1; i < 100005; i++) {
                calculate[i] += calculate[i - 1];
                if ((i & 1) == 1 && isPrime[i] && (isPrime[(i + 1) / 2])) calculate[i]++;
            }
        }

        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            pre();
            int q = in.scanInt();
            while (q-- > 0) {
                int l = in.scanInt(), r = in.scanInt();
                out.println(calculate[r] - calculate[l - 1]);
            }
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}



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

int main()
{
	int A,B,C;
	cin >> A >> B >> C;
	int ans = 0;
	while(A%2==0 && B%2==0 && C%2==0 && ans<=100000)
	{
		ans++;
		int tA = (B+C)/2;
		int tB = (A+C)/2;
		int tC = (A+B)/2;
		A = tA, B = tB, C = tC;
	}
	if(ans>100000) ans = -1;
	cout << ans << '\n';
}

Measured memory_bytes: 256