akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
// x^y≡x^(y%(p-1))mod p
// but there is a condition that x needs to be coprime to p
///assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    indexed_set; */
typedef long long int ll;
typedef pair<ll, ll> pii;
typedef vector<pii> vii;
#define  pb push_back
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fo(i,a,b) for(ll i = a; i<=b;i+=1)
#define rf(i,a,b)  for(ll i=a;i>=b;i--)
#define vll vector<ll>
#define tests() int test_cases ; cin >> test_cases ; while(test_cases--)
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define MAXN 100010
#define MOD 1000000007
#define mod 998244353
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define sp " "
#define MS(x,y) fill_n(*x, sizeof x / sizeof **x, y);
#define mem(x,y) memset(x,y,sizeof(x));
#define INF 1000000000000000000
#define IO                 \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0);
#define debug(x) cerr << (#x) << " is " << (x) << endl;

#ifndef ONLINE_JUDGE
#define cerr if(true)cerr
#endif

template<int D, typename T>
struct Vec : public vector<Vec<D - 1, T>> {
static_assert(D >= 1, "Vector dimension must be greater than zero!");
template<typename... Args>
	Vec(int n = 0, Args... args) : vector<Vec<D - 1, T>>(n, Vec<D - 1, T>(args...)) {
	}
};
template<typename T>
struct Vec<1, T> : public vector<T> {
	Vec(int n = 0, const T& val = T()) : vector<T>(n, val) {
	}
};

ll power(ll x, ll y,ll p)
{
    ll res = 1;     // Initialize result
    x = x % p;
    if (y==0)return 1;
    if(x==0)return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; // y = y/2
        x = (x*x) % p;  // Change x to x^2
    }
    return res;
}
int gcd(int a, int b) { if (a == 0)return b;return gcd(b % a, a);}

ll modinv(ll a,ll p){return power(a,p-2,p);}
ll h,w;
Vec<2,char> arr(1010,1010);

void solve(){
    cin>>h>>w;
    fo(i,1,h){
        fo(j,1,w){
            cin>>arr[i][j];
        }
    }
    Vec<2,ll> dp(h+1,w+1,0);
    fo(i,1,h){
        if (arr[i][1]=='.')
        {
            dp[i][1] = 1;
        }
        else break;
    }
    fo(j,1,w){
        if (arr[1][j]=='.')
        {
            dp[1][j] = 1;
        }
        else break;
    }
    fo(i,2,h){
        fo(j,2,w){
            if (arr[i][j]=='.')
            {
                (dp[i][j] = dp[i-1][j]+dp[i][j-1])%=MOD;
            }
        }
    }
    cout<<dp[h][w]<<endl;
    return ;
}
int main()

{
    IO;
    int T=1;
	// cin >> T;
	f(c,0,T){
		solve();
	}
    return 0;
}// make_pair make_tuple  tuple<int,int,int> continue resize insert count size else true isValid second first false erase


Measured memory_bytes: 9216
#include <cstdio>
#include <algorithm>
using namespace std;
long long a[100001];
int main() {
	long long N,x;
	scanf("%lld %lld",&N,&x);
	for(int i=0;i<N;i++) {
		scanf("%lld",&a[i]);
	}
	long long sum=0;
	for(int i=1;i<N;i++) {
		if(a[i-1]+a[i]>=x) {
			long long d=(a[i-1]+a[i])-x;
			if(a[i]>=d) {
				a[i]-=d;
			}else {
				a[i]=0;
			}
			sum+=d;
		}
	}
	printf("%lld\n",sum);
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
const ll p=1000000007;
int main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  int cnt=0;
  rep(i,n-1){
    if(s[i]==s[i+1])cnt++;
  }
  cout << min(n-1,cnt+2*k) << endl;
}


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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl '\n'
#define int long long

signed main()
{
    

    string s;
    cin>>s;

    cout<<s;
    if(s[sz(s)-1]=='s') cout<<"es";
    else cout<<"s";
    
    return 0;
}



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

#define rep(i, a, b) for(int i = (a); i < int(b); ++i)
#define rrep(i, a, b) for(int i = (a) - 1; i >= int(b); --i)
#define trav(it, v) for(auto &it : (v))
#define all(v) (v).begin(), (v).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define sz(x) (int)(x).size()

typedef double fl;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;

vector<int> adj[100005];
vector<int> adjLen[100005];
ll ans = 0;
int N;
int bestMinus;

int rec(int node, int parent){
	int ret = 1;
	int bestPotential = 1000000000;
	int maxSubtree = 0;
	vector<int> subtrees;
	rep(i,0,sz(adj[node])){
		int to = adj[node][i];
		int len = adjLen[node][i];
		if(to == parent)
			continue;
		int subtree = rec(to, node);
		subtrees.push_back(subtree);
		maxSubtree = max(maxSubtree, subtree);
		ll minSubtree = min(subtree, N-subtree);
		ans += 2 * (minSubtree * len);
		ret += subtree;
		if(subtree*2 <= N){
			bestPotential = min(bestPotential, len);
		}
		if(subtree*2 == N)
			bestMinus = min(bestMinus, len);
		//if(minSubtree*2 == N || minSubtree*2 == N-1)
		//	bestMinus = min(bestMinus, len);
	}
	maxSubtree = max(maxSubtree, N-ret);
	if(maxSubtree*2+1 <= N){
		bestMinus = min(bestMinus, bestPotential);
	}
	
	return ret;
}

int main(){
	ios::sync_with_stdio(0);
	cin >> N;
	rep(i,0,N - 1){
		int A, B, C;
		cin >> A >> B >> C;
		--A;--B;
		adj[A].push_back(B);
		adjLen[A].push_back(C);
		adj[B].push_back(A);
		adjLen[B].push_back(C);
	}
	bestMinus = 1000000000;
	rec(0, -1);
	ans -= bestMinus;
	cout << ans << endl;
}

Measured memory_bytes: 21888
x = int(input())
if x >= 1800:
    print(1)
elif x >= 1600:
    print(2)
elif x >= 1400:
    print(3)
elif x >= 1200:
    print(4)
elif x >= 1000:
    print(5)
elif x >= 800:
    print(6)
elif x >= 600:
    print(7)
else:
    print(8)

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

string S;
ll A;

int main(){
	cin>>A;
	ll A1 = A/500;
	ll A2 = A%500;
	A2 = A2/5;
	cout<<A1*1000+A2*5<<endl;
	
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    int N,A;
    cin >> N;
    int array[N];
    int array2[N];
    int i;
    for(i = 0;i<N;i++){
        cin >> A;
        array[i] = A;
    }
    for(i = 0;i<N;i++){
        array2[i] = 1; //生きている
    }
    
    int num = N;
    int min_num = 0;
    int random;
    int flug1 = 0;
    int flug2 = 0;
    for(i = 0;i<N;i++){
        if((array[min_num] > array[i] && array2[i] == 1)) min_num = i; //一番小さいモンスターの決定
    }
    while(flug1 == 0){
        for(i = 0;i<N;i++){
            if(i != min_num && array2[i] == 1){
                array[i] %= array[min_num];
                if(array[i] == 0){
                    array2[i] = 0;
                    num--;
                }
                else if(array[i] < array[min_num]){
                    min_num = i;
                }
            }
            if(num == 1){
                flug1 = 1;
                break;
            }
        }

    }
    
    cout << array[min_num] << "\n";
    return 0;
}



Measured memory_bytes: 1024
N = int(input().strip())
gridi = []
for i in range(N):
    array = list(map(int, input().strip().split()))
    gridi.append(array)
f="Yes"
grid=[]
for i in range(N+1):
    grid.append([0,0,0])
for i in range(1,N+1):
    grid[i][0]=gridi[i-1][0]
    grid[i][1]=gridi[i-1][1]
    grid[i][2]=gridi[i-1][2]
for i in range(N):
    dt=int(grid[i+1][0])-int(grid[i][0])
    dist=abs(grid[i+1][1]-grid[i][1])+abs(grid[i+1][2]-grid[i][2])
    if dist>dt:
        f="No"
    elif dist%2!=dt%2:
        f="No"
print(f)

Measured memory_bytes: 37192
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1 LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    int N;cin >> N;
    LL ans = 0;
    rep(i,N)ans += i;
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Edge
    {
        internal int from, to, cost;

        public Edge(int from, int to, int cost)
        {
            this.from = from;
            this.to = to;
            this.cost = cost;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int V = int.Parse(input[0]);
            int E = int.Parse(input[1]);
            int r = int.Parse(input[2]);

            Edge[] edges = new Edge[E];

            for (int i = 0; i < E; i++)
            {
                input = Console.ReadLine().Split(' ');
                int s = int.Parse(input[0]);
                int t = int.Parse(input[1]);
                int d = int.Parse(input[2]);

                edges[i] = new Edge(s, t, d);
            }

            BellmanFord(edges, V, r);

        }

        static void BellmanFord(Edge[] edges, int v, int start)
        {
            int INFTY = int.MaxValue, len = edges.Length;

            int[] dp = Enumerable.Repeat(INFTY, v).ToArray();
            dp[start] = 0;

            bool isUpdate = true, isNegative = false;
            int cnt = 0;

            while (isUpdate)
            {
                isUpdate = false;

                for (int j = 0; j < len; j++)
                {
                    Edge e = edges[j];

                    if (dp[e.from] != INFTY && dp[e.to] > dp[e.from] + e.cost)
                    {
                        dp[e.to] = dp[e.from] + e.cost;
                        isUpdate = true;
                    }
                }

                if (cnt++ == v)
                {
                    isNegative = true;
                    break;
                }
            }

            if (isNegative) Console.WriteLine("NEGATIVE CYCLE");
            else
            {
                StringBuilder sb = new StringBuilder();
                foreach (int d in dp)
                {
                    sb.AppendLine(d == INFTY ? "INF" : d.ToString());
                }
                Console.Write(sb);
            }
        }
    }
}

Measured memory_bytes: 9696
let () = Scanf.scanf "%d\n" @@ fun n ->
  let hs = Array.init n @@ fun _ -> Scanf.scanf "%d " @@ fun h -> h in
  print_endline @@
  match
    Array.fold_right (fun h (b, h') ->
      if h <= h'
      then (b, h)
      else (b && h - 1 <= h', h - 1)) hs (true, max_int)
  with
  | (true, _) -> "Yes"
  | (false, _) -> "No"



Measured memory_bytes: 5120
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
#define debug(x) cerr << #x << " = " << x << "\n";
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, m;
    string s[52] = {};
    cin >> n >> m;
    fr(n) cin >> s[i];
    fr(n) for (int j = 0; j < m; j++) if (s[i][j] == '#') {
        bool y = 0;
        if (i && s[i - 1][j] == '#') y = 1;
        if (i + 1 < n && s[i + 1][j] == '#') y = 1;
        if (j && s[i][j - 1] == '#') y = 1;
        if (j + 1 < m && s[i][j + 1] == '#') y = 1;
        if (!y) {cout << "No"; return 0;}
    }
    cout << "Yes";
}


Measured memory_bytes: 256
import itertools
import math

n = int(input())
dots = []
for _ in range(n):
    dots.append(list(map(int, input().split(" "))))

nums = [_ for _ in range(n)]
total = 0
for v in itertools.permutations(nums, n):
    dist = 0
    for i in range(n-1):
        dist += math.sqrt((dots[v[i]][0] - dots[v[i+1]][0]) **
                          2 + (dots[v[i]][1] - dots[v[i+1]][1])**2)
    total += dist

print(total/math.factorial(n))


Measured memory_bytes: 3064
N, Y = map(int, input().split())
for i in range(N+1):
    y = Y-10000*i
    for j in range(N-i+1):
        y_ = y-5000*j
        if y_//1000 == N-i-j:
            print(i, j, N-i-j)
            exit()
print(-1, -1, -1)

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

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;

const int MAX_V = 10e4;

struct edge{int to,cap,rev;};

std::vector<edge> G[MAX_V];
bool used[MAX_V];

void add_edge(int from,int to,int cap){
  G[from].push_back((edge){to,cap,G[to].size()});
  G[to].push_back((edge){from,0,G[from].size()-1});
}

int dfs(int v,int t,int f){
  if(v==t) return f;
  used[v]= true;
  for(int i=0;i<G[v].size();i++){
    edge &e = G[v][i];
    if(!used[e.to] && e.cap>0){
      int d=dfs(e.to,t,min(f,e.cap));
      if(d>0){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow =0;
  for(;;){
    memset(used,0,sizeof(used));
    int f=dfs(s,t,INF);
    if(f==0) return flow;
    flow += f;
  }
}

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

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

  while(true){
  for(int i=0;i<MAX_V;i++) {
    G[i].erase(G[i].begin(), G[i].end());
    used[i]=false;
  }
  int m,n;
  cin >> m >> n;
  if(m==0 && n==0) break;
  bool can[1000][1000];//can[i][j]:b[i]テ」ツ?罫[j]テ」ツ?ォテ・ツ可イテ」ツつ甘・ツスツ禿」ツ?ヲテ・ツ渉ッティツδス
  int b[1000],r[1000];
  for(int i=1;i<=m;i++) cin >> b[i];
  for(int i=1;i<=n;i++) cin >> r[i];
  for(int i=1;i<=m;i++){
    for(int j=1;j<=n;j++){
      can[i][j] = (gcd(b[i],r[j])>1);
    }
  }
  int s=m+n+1,t=s+1;

  for(int i=1;i<=m;i++){
    add_edge(s,i,1);
  }

  for(int i=1;i<=n;i++){
    add_edge(m+i,t,1);
  }

  for(int i=1;i<=m;i++){
    for(int j=1;j<=n;j++){
      if(can[i][j]){
        add_edge(i,m+j,1);
      }
    }
  }
  cout << max_flow(s,t) << endl;
}
}

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

#define PI 3.1415926535897

int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    
    int n, m;
    cin>>n>>m;
    vector<int> adj[n+1];
    for (int i=0; i<m; i++){
        int a, b;
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    queue<int> q;
    q.push(1);
    vector<bool> visited(n+1, false);
    visited[1] = true;
    int ans[n+1];
    while(!q.empty()){
        int u = q.front(); q.pop();
        for (auto v:adj[u]){
            if (visited[v]) continue;
            visited[v] = true;
            q.push(v);
            ans[v] = u;
        }
    }
    bool all = 1;
    for (int i=1; i<=n; i++){
        all &= visited[i];
    }
    if (all){
        cout<<"Yes"<<endl;
        for (int i=2; i<=n; i++){
            cout<<ans[i]<<endl;
        }
    }
    else{
        cout<<"No"<<endl;
    }
    return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

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

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

typedef long long ll;

void solve(std::string S) {
    if (S == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }
}

int main() {
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 3628
s = list(map(int,input().split()))
flag = False
if s[0]+s[1] == s[2]:
    flag = True
elif s[0]+s[2]==s[1]:
    flag = True
elif s[0] == s[1]+s[2]:
    flag = True

if flag:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int n; cin >> n;
	string x; cin >> x;
	int cnt = 0;
	for(int i = 0; i < n; ++i) {
		if(x[i] == '1') ++cnt;
	}
	int c[] = {cnt - 1, cnt + 1};
	int _2[n][2];
	if(c[0] != 0) _2[n - 1][0] = (1 % c[0]);
	_2[n - 1][1] = (1 % c[1]);
	for(int i = n - 2; i >= 0; --i) {
		for(int j = 0; j < 2; ++j) {
			_2[i][j] = _2[i + 1][j] << 1;
			if(c[0] != 0) _2[i][j] %= c[j];
		}
	}
	int num[2] = {};
	for(int i = 0; i < n; ++i) {
		if(x[i] != '1') continue;
		for(int j = 0; j < 2; ++j) {
			num[j] += _2[i][j];
			if(c[0] != 0) num[j] %= c[j];
		}
	}
	for(int i = 0; i < n; ++i) {
		if(x[i] == '1') {
			if(c[0] == 0) {
				cout << 0 << '\n';
				continue;
			}
			int a = (c[0] + ((num[0] - _2[i][0]) % c[0])) % c[0];
			int ans = 1;
			while(a > 0) {
				a %= __builtin_popcount(a);
				++ans;
			}
			cout << ans << '\n';
		} else {
			int a = (num[1] + _2[i][1]) % c[1];
			int ans = 1;
			while(a > 0) {
				a %= __builtin_popcount(a);
				++ans;
			}
			cout << ans << '\n';
		}
	}
	return 0;
}


Measured memory_bytes: 5288
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), D = sc.nextInt();
		double[][] point = new double[N][D];
		for(int i = 0; i < N; i++) {
			for(int j = 0; j < D; j++) {
				point[i][j] = sc.nextDouble();
			}
		}
		int cnt = 0;
		for(int i = 0; i < N; i++) {
			for(int j = i + 1; j < N; j++) {
				// dist (i, j)
				double dist = 0;
				for(int k = 0; k < D; k++) dist += (point[i][k] - point[j][k]) * (point[i][k] - point[j][k]);
				int dist_i = (int)Math.sqrt(dist);
				if((int)dist == dist_i * dist_i) cnt++;
			}
		}
		System.out.println(cnt);
	}
}


Measured memory_bytes: 23252
#include<stdio.h>
#include<vector>
typedef std::pair<int,int>P;
int main()
{
	int n,i,x;
	while(scanf("%d",&n),n)
	{
		std::vector<std::pair<int,int> >v;
		for(i=0;i<n;++i)
		{
			scanf("%d",&x);
			if(i&1)
			{
				if(v.back().first==x)v.back().second++;
				else
				{
					P p(v.back());v.pop_back();
					if(!v.empty())v.back().second+=1+p.second;
					else v.push_back(P(x,p.second+1));
				}
			}
			else
			{
				if(!v.empty()&&v.back().first==x) v.back().second++;
				else v.push_back(P(x,1));
			}
		}
		for(x=i=0;i<v.size();++i)if(!v[i].first)x+=v[i].second;
		printf("%d\n",x);
	}
	return 0;
}

Measured memory_bytes: 0
//#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<functional>
#include<vector>

#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int n;
ll a, b;

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    cin >> n;
    a=b=1;
    forn(i, n)
    {
        ll x, y;
        cin >> x >> y;
        ll times = max((a+x-1)/x, (b+y-1)/y);
        a = x*times;
        b = y*times;
        //cout << a << " " << b << endl;
    }
    cout << a + b << endl;

}


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

typedef long long ll;

const int Maxn = 100005;

int n;
int a[Maxn];
ll my[Maxn];

int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
        a[i] *= 2;
    }
    my[0] = 0;
    for (int i = 0; i < n; i++)
        my[i + 1] = a[i] - my[i];
    my[0] = my[n] / 2;
    for (int i = 1; i < n; i++)
        if (i % 2) my[i] -= my[0];
        else my[i] += my[0];
    for (int i = 0; i < n; i++)
        printf("%lld%c", my[i], i + 1 < n? ' ': '\n');
    return 0;
}


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

ans = 0
for i in range(N-1):
    d = max(0, (A[i] + A[i+1]) - x)
    
    ans += d
    if A[i+1] >= d:
        A[i+1] -= d
    else:
        d -= A[i+1]
        A[i+1] = 0
        A[i] -= d
    
print(ans)


Measured memory_bytes: 14068
n, a = map(int, input().split())
l = [int(i) for i in input().split()]

dp = [[[0] * 2501 for j in range(51)] for i in range(51)]

dp[0][0][0] = 1

for i in range(n):
    for j in range(51):
        for k in range(2501):
            if k >= l[i] and j >= 1:
                dp[i+1][j][k] = dp[i][j][k] + dp[i][j-1][k-l[i]]
            else:
                dp[i+1][j][k] = dp[i][j][k]

print(sum([dp[n][m][a*m] for m in range(1, n+1)]))

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

int main() {
    string n;
    cin >> n;
    int size = n.size();
    int sum=0;
    rep(i,size){
        sum+=n[i]-'0';
    }
    if(sum%9==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#include <atcoder/fenwicktree.hpp>

#define foreach(i,v) for(auto&& i: v)
#define all(x) (x).begin(), (x).end()

typedef std::vector< std::string > VS;
typedef std::vector<int> VI;
typedef long long ll;

template <class C> C& mini(C& a, C b) { if (b < a) a = b; return a; }
template <class C> C& maxi(C& a, C b) { if (a < b) a = b; return a; }

using namespace std;

template <typename T> void read(T& x) { x.read(); }
template <typename T> void read(vector<T>& v) { for (T& x: v) read(x); }
template <typename X, typename Y> void read(pair<X, Y>& p) { read(p.first); read(p.second); }
template <> void read(int& x) { scanf("%d", &x); }
template <> void read(unsigned int& x) { scanf("%u", &x); }
template <> void read(long long& x) { scanf("%lld", &x); }
template <> void read(unsigned long long& x) { scanf("%llu", &x); }
template <typename T> void readv(vector<T>& v) { int N; read(N); v.resize(N); read(v); }
template <typename T, typename ...Ts> void read(T& x, Ts&... args) { read(x); read(args...); }

int main(int argc, const char* argv[]) {
    int N, Q;
    read(N, Q);
    VI A(N);
    read(A);
    atcoder::fenwick_tree<unsigned long> fw(N);
    for (int i = 0; i < N; i++)
        fw.add(i, A[i]);

    while (Q --> 0) {
        int t, a, b;
        read(t, a, b);
        if (t == 0) {
            fw.add(a, b);
        } else {
            printf("%lu\n", fw.sum(a, b));
        }
    }
    return 0;
}


Measured memory_bytes: 10132
while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break
    for i in range(H):
        for j in range(W):
            if i==0 or i==H-1 or j==0 or j==W-1:
                print("#",end="")
            else:
                print(".",end="")
        print()
    print()



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

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;


const ll mod = 1000000007;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
// bool debug=false;

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

int main(){
  ll N, X;
  cin >> N >> X;
  vector<ll> L(N);
  for(int i = 0; i < N; i++) {
    cin >> L[i];
  }
  int ans = 1;
  ll D = 0;
  for(int i = 0; i < N; i++) {
    D += L[i];
    if(D <= X) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

using ll=long long; 

bool fld[101][101];

void solve(){
	int w,h,n;
	memset(fld, 0, sizeof fld);
	cin>>w>>h>>n;
	int cnt=0;
	for(int k=0; k<n; k++){
		int a,b,c;
		cin>>a>>b>>c;
		if(c==1){
			for(int i=a-1; i>=0; i--){
				for(int j=0; j<h; j++){
					if(fld[i][j]==0){
						fld[i][j]=1;
						cnt+=1;
					}
				}
			}
		}
		if(c==2){
			for(int i=a; i<w; i++){
				for(int j=0; j<h; j++){
					if(fld[i][j]==0){
						fld[i][j]=1;
						cnt+=1;
					}
				}
			}
		}
		if(c==3){
			for(int i=b-1; i>=0; i--){
				for(int j=0; j<w; j++){
					if(fld[j][i]==0){
						fld[j][i]=1;
						cnt+=1;
					}
				}
			}
		}
		if(c==4){
			for(int i=b; i<h; i++){
				for(int j=0; j<w; j++){
					if(fld[j][i]==0){
						fld[j][i]=1;
						cnt+=1;
					}
				}
			}
		}
	}

	cout<<w*h-cnt<<endl;
}

signed main(){
	//while(1)
	solve();
}

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

typedef long long ll;

const int N = 1e5+5;

int k;
ll a[N];

int main(){
	cin >> k;
	for(int i = 1;i <= k;i++){
		cin >> a[i];
	}
	if(a[k] > 2){
		printf("-1\n");
		return 0;
	}
	ll l = 2 , r = 2;
	a[0] = 1;
	for(int i = k;i > 0;i--){
		ll j = a[i - 1];
		ll x = l - (l % j);
		if(x != l)x += j;
		r += a[i] - 1;
		ll y = r - (r % j);
		l = x;
		r = y;
		if(l > r){
			printf("-1\n");
			return 0;
		}
	}
	printf("%lld %lld\n" , l , r);
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <tuple>
#include <cmath>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <stack>
#include <map>

#define mt make_tuple

using namespace std;

int sum_digit(int n) {
	return n ? sum_digit(n/10) + n%10 : n;
}

int main() {
	int n;
	cin >> n;
	int mn = -1u/2;
	for(int i=1;i<=n/2;i++) {
		int a = sum_digit(i) + sum_digit(n-i);
		if(mn > a) mn = a;
	}
	cout << mn;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <iostream>
#include <queue>

using namespace std;

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64; // 9e18
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

//const double PI = 3.141592653589793238463;
//const int MAXN = 1000500;
//const int MAXVALUE = 1000000500;
//const long double EPS = 1e-7;
const i64 INF = 1e18;
i64 mod = 1e9 + 7;


i64 T, n, m, k;
//vector <vector<i64>> a;
//vector <i64> a;
//vector <i64> b;
//vector <i64> dp;

vector<i64> parent;
vector<i64> sz;

void make_set(i64 v) {
    parent[v] = v;
    sz[v] = 1;
}

int find_set(i64 v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

void union_sets(i64 a, i64 b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (sz[a] < sz[b]) {
            swap(a, b);
        }
        parent[b] = a;
        sz[a] += sz[b];
    }
}


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


    //cin >> T;
    T = 1;

    for (i64 tt = 0; tt < T; ++tt) {

        cin >> n >> m;

        parent.resize(n + 1);
        sz.resize(n + 1);

        for (i64 i = 1; i <= n; ++i) {
            make_set(i);
        }

        for (i64 i = 0; i < m; ++i) {
            i64 x, y;
            cin >> x >> y;
            union_sets(x, y);
        }

        for (i64 i = 1; i <= n; ++i) {
            parent[i] = find_set(i);
        }

        map<i64, i64> mx;
        for (i64 i = 1; i <= n; ++i) {
            if (mx.count(parent[i])) {
                mx[parent[i]] += 1;
            }
            else {
                mx[parent[i]] = 1;
            }
        }

        i64 res = 1;
        for (auto x : mx) {
            res = max(res, x.second);
        }

        cout << res << endl;

    }
    return 0;
}

Measured memory_bytes: 18340
while True:
  a, b = map(int, input().split())
  if a == b == 0:
    break

  for i in range(a):
    for j in range(b):
      if (i + j) % 2 == 0:
        print('#', end = '')
      else:
        print('.', end = '')
    print()
  print()


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

long long n,p;
int ans;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> p;
	if (n>50){
		cout << "1\n";
		return 0;
	}
	if (n==1){
		cout << p << "\n";
		return 0;
	}
	for (int i=1;;i++){
		long long now=1;
		for (int j=1;j<=n;j++){
			now*=i;
		}
		if (now>p){
			break;
		}
		if (!(p%now)){
			ans=max(ans,i);
		}
	}
	cout << ans << "\n";
}

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

using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)


//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);


void solve()
{
    int n;
    cin >> n;
    int a[2][n];
    REP(i, 2) REP(j, n) cin >> a[i][j];
    int dowmSum = 0;
    int ans = 0;
    for(int i = 0; i < n; i++){
        dowmSum += a[1][i];
    }
    ans = dowmSum + a[0][0];
    int cost = ans;
    for(int i = 1; i < n; i++){
        cost += a[0][i]-a[1][i-1];
        ans = max(ans, cost);
    }
    cout << ans << "\n";
}

int main()
{
    solve();
    return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

typedef long long LL;
typedef pair<int, int> pii;

const int INTINF = 1e9;
const LL LLINF = 1e18;

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

long long lcm(long long a, long long b)
{ // bracket to avoid overflow
    return a * (b / gcd(a, b));
}

void solve()
{
    int N;
    cin >> N;
    LL A = 1;
    LL B = 1;

    REP0(i, N)
    {
        LL x, y;
        cin >> x >> y;
        // n s.t. nx >= A and ny >= B
        // => n = max(ceil(A/x), ceil(B/x))
        LL n = max((A + x - 1) / x, (B + y - 1) / y);
        A = n * x;
        B = n * y;
    }

    cout << A + B << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 256
// by DenyTianly
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>

using namespace std;

#define iScf(n) scanf("%d", &n)
#define dug() printf("ok!\n")
#define iNxtL() puts("")
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define nrep(i, val, n) for(int i = val; i < n; i++)
#define ipq priority_queue
typedef long long LL;
typedef unsigned long long ULL;

const int inf = 1 << 26;
const LL INF = 1LL << 60;

inline void quick_IO() { ios::sync_with_stdio(false); cout.tie(0); cin.tie(0); }
inline int read(){
	int x = 0, f = 1;
	char ch = getchar();

	for(; ch < '0' || ch > '9'; ch = getchar())
		if(ch == '-') f = -f;

	for(; ch >= '0' && ch <= '9'; ch = getchar())
		x = x*10+ch-'0';

	return x*f;
}

// Don't hack me, please ~
// #define _Isopen_File_
// #define _Is_Close_STD_

int main(){

#ifdef _Isopen_File_
	freopen(".in","r",stdin);
	// freopen(".out","w",stdout);
#endif

#ifdef _Is_Close_STD_
	ios::sync_with_stdio(false);
	cin.tie(0);
#endif
	int md = 1e9+7;
	int n;
	LL as=1LL;
	scanf("%d", &n);
	for ( LL i = 1LL; i <= (LL)n; i ++) {
		as=(as*i)%md;
	}
	printf("%lld\n", as);

	return 0;
}

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

signed main() {
  string s, t;
  cin >> s >> t;

  int n = (int)s.size();
  int m = (int)t.size();

  int ans = INT_MAX;
  for (int i = 0; i + m <= n; i++) {
    int tmp = 0;
    for (int j = 0; j < m; j++) {
      if(s[i + j] != t[j]) tmp++;
    }
    ans = min(ans, tmp);
  }

  cout << ans << '\n';
}


Measured memory_bytes: 3648
//This is getting accepted!
#include<bits/stdc++.h>
#define ll long long
#define oo 1000000009
#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define INA(a,n) for (int i = 1; i <= (n); ++i) cin >> a[i];
#define ITE(x) for(auto it = (x).begin(); it != (x).end(); ++it)
#define isset(x, i) (((x)>>(i))&1)
#define setbit(x, i) ((x)^(1ll<<(i)))
#define clearbit(x, i) ((x)&(~(1ll<<(i))))
#define twoexp(i) (1ll<<(i))
#define MAX(a,b) ((a) > (b) ? (a) : (b))
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define ABS(a) ((a) >= 0 ? (a) : -(a))
#define FI first
#define SE second
#define son1 (id*2)
#define son2 (id*2+1)

using namespace std;

const int MOD = 1000000007;
const double EPS = 1e-8;
const double PI = 2 * acos(0);
const int MAXN = 1e5 + 6;

struct DSU // disjoint-set union
	{
	// DSU NOTE:
	// 		1. vertex can be 0- or 1-indexed, both possible.
	//		2. by default, use get_parent_simple ( O(logN)). Change to ~O(1) by replace all get_parent_simple => get_parent_compress
		int *parent;
		int *ssize;
		
		DSU(int n) {
			parent = new int[n+2];
			ssize  = new int[n+2];
			
			for (int i = 0; i <= n; ++i) {
				parent[i] = i;
				ssize[i]  = 1;
			}
		
		}

		int get_parent_simple(int x) {
			
			while (x != parent[x]) {
				x = parent[x];
			}
			return x;
		}

		int get_parent_compress(int x) {
			
			if (x == parent[x])
				return x;
				
			parent[x] = get_parent_simple(parent[x]);
			return parent[x];
		}

		void join_set(int x, int y) {
			int pa_x = get_parent_simple(x);
			int pa_y = get_parent_simple(y);
			
			if (pa_x != pa_y) {
				if (ssize[pa_x] > ssize[pa_y]) {
					swap(pa_x, pa_y);
				}
				parent[pa_x] = pa_y;
				ssize[pa_y] += ssize[pa_x];
			}
		}

	};
	
DSU dsu(MAXN);
int n;
vector<int> vec[MAXN];
int newest[MAXN];
vector<int> group[MAXN];
int gcnt;

void input() {
	int u, v, w, x, y, qtype;
	
	cin >> n;
	FOR(i, 1, n) {
		cin >> x >> y;
		vec[x].push_back(y);
	}
	
}


void preprocess() {
	
	gcnt = 0;
	
}

void process(int itest) {
	int u, v, w, x, y, qtype;
	
	for(int i = 1; i < MAXN; ++i) {
		sort(vec[i].begin(), vec[i].end());
		
		for(auto j : vec[i]) {
			if (newest[j] > 0) {
				dsu.join_set(newest[j], i);
			}
			
			newest[j] = i;
		}
		
	}
	
	for (int i = 1; i < MAXN; ++i)
		if (vec[i].size()) {
			int pa = dsu.get_parent_simple(i);
			group[pa].push_back(i);
		}
	
	ll res = 0;
	
	for (int i = 1; i < MAXN; ++i)
		if (group[i].size() > 1) {
			set<int> yunique;
			int sz = 0;
			
			for (auto x : group[i]) {
				for (auto v : vec[x]) {
					yunique.insert(v);
				}
				sz += vec[x].size();
			}
			
			res += 1ll * group[i].size() * yunique.size() - sz;
		}
	
	cout << res << endl;
	
}

void oneTest() {
	
	input();
	preprocess();
	process(0);
	
}

void multiTest() {
	
	int t;
	cin >> t;
	
	for (int it = 1; it <= t; ++it) {
		input();
		preprocess();
		process(it);
	}
}

int main(){
    #ifndef ONLINE_JUDGE
//    freopen("../out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	oneTest();
//	multiTest();

    return 0;

}


Measured memory_bytes: 10236
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD = 1000000007;

int main() {
  int N;
  cin >> N;
  vector<tuple<int, int, int>> abc(N);
  for (int i=0; i<N; i++) cin >> get<0>(abc.at(i)) >> get<1>(abc.at(i)) >> get<2>(abc.at(i));
  vector<int> memo_A(N), memo_B(N), memo_C(N);
  memo_A.at(0) = get<0>(abc.at(0));
  memo_B.at(0) = get<1>(abc.at(0));
  memo_C.at(0) = get<2>(abc.at(0));
  for (int i=1; i<N; i++) {
    memo_A.at(i) = max(memo_B.at(i-1)+get<0>(abc.at(i)), memo_C.at(i-1)+get<0>(abc.at(i)));
    memo_B.at(i) = max(memo_A.at(i-1)+get<1>(abc.at(i)), memo_C.at(i-1)+get<1>(abc.at(i)));
    memo_C.at(i) = max(memo_B.at(i-1)+get<2>(abc.at(i)), memo_A.at(i-1)+get<2>(abc.at(i)));
  }
  cout << max(memo_A.at(N-1), max(memo_B.at(N-1), memo_C.at(N-1))) << endl;
}

Measured memory_bytes: 2560
# 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>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr long long MOD = 1000000000 + 7;
constexpr long long INF = 1e17 - 10;
const double PI = acos(-1);
#define fir first
#define sec second
typedef pair<LL, LL> Pll;
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; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Mfor(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, s, t, q, ans, sum, a[200001];
struct Edge { LL to,cost; };
string str, ss;
char c[10000000];
bool f[30];
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;
	rep(i, n) {
		cin >> c[i];
		if (c[i] == 'Y')
			f[0] = 1;
	}
	if(f[0])
	cout << "Four" << endl;
	else cout << "Three" << endl;
	return 0;
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b, a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a,b);}
ll MOD=1000000007;

// double pow(double n, double r){
//   double ans=1;
//   rep(i,r){
//     ans*=n;
//   }
//   return ans;
// }

int main(){
  int n,k;
  cin>>n>>k;
  double ans=0;
  for(int i=1;i<n+1;i++){
    if(i>=k){
      ans+=(double)1;
    }else{
      int tmp=i;
      double now=1.0;
      while(tmp<k){
        tmp*=2;
        now/=2.0;
      }
      ans+=now;
    }
  }
  cout<<fixed<<setprecision(10)<<ans/n<<endl;
}

Measured memory_bytes: 256
n, k = [int(x) for x in input().split()]

res = 0
for i in range(1, n+2):
    if i < k:
        continue
    max_sum = -(i**2)/2 + n*i + i/2
    min_sum = (i**2)/2 - i/2
    res += max_sum - min_sum + 1
    res = res % (10**9+7)
print(int(res))

Measured memory_bytes: 9080
N = int(input())
tmp = input().split()
right = [int(i) for i in tmp]

ans = sum(right)
left = []

for i in range(N):
    left.append(right.pop(0))
    if ans > abs(sum(left) - sum(right)):
        ans = abs(sum(left) - sum(right))
    else:
        break
print(ans)

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

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

	int X, Y, Z, K;
	cin >> X >> Y >> Z >> K;
	
	vector<uint64_t> A(X), B(Y), C(Z);

	for (auto&i : A) {
		cin >> i;
	}
	for (auto&i : B) {
		cin >> i;
	}
	for (auto&i : C) {
		cin >> i;
	}

	sort(A.begin(), A.end(), greater<uint64_t>());
	sort(B.begin(), B.end(), greater<uint64_t>());
	sort(C.begin(), C.end(), greater<uint64_t>());

	vector<uint64_t> ans;

	for (int a = 0; a < X; a++) {
		for (int b = 0; b < Y; b++) {
			if ((a + 1)*(b + 1) > K)break;
			for (int c = 0; c < Y; c++) {
				if ((a + 1)*(b + 1)*(c+1) > K)break;
				ans.push_back(A.at(a)+B.at(b)+C.at(c));
			}
		}
	}

	sort(ans.begin(), ans.end(), greater<uint64_t>());

	for (int i = 0; i < K; i++) {
		cout<<ans.at(i)<<"\n";
	}

	return 0;
}

Measured memory_bytes: 1404
#include <bits/stdc++.h>
using namespace std;
int main(){
  vector<int> dish(5);
  int ans = 0;
  for(int i=0;i<5;i++){
    cin>>dish.at(i);
    ans+=dish.at(i);
  }
  vector<int> cost;
  for(int i=0;i<5;i++){
    for(int j=0;j<10;j++){
      if(dish.at(i)%10==0){
        cost.push_back(j);
        break;
      }
      else{
        dish.at(i)++;
      }
    }
  }
  sort(cost.begin(),cost.end());
  for(int i=0;i<cost.size()-1;i++){
    ans+=cost.at(i);
  }
  cout<<ans<<endl;
  return 0;
}
  

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

int main(){
    int cnt_1=0,cnt=0,cnt_0=0,ans;
    char s[1000000];
    scanf("%s",s);
    for (int i=0; i<strlen(s); i++) {
        if (s[i]=='0') {
            cnt_0++; //0のカウント
        }else if(s[i]=='1'){
            cnt_1++;
        }
    }
    if (cnt_0>=cnt_1) {
        ans=cnt_1*2;
    }else{
        ans=cnt_0*2;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
fun main(arr:Array<String>) {
    val (blackCount, idx) = readLine()!!.split(" ").map { it.toInt() }
    val minIdx = idx - (blackCount - 1)
    val maxIdx = idx + (blackCount - 1)
    val ans = (minIdx..maxIdx).joinToString(" ")
    println(ans)
}


Measured memory_bytes: 37876
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#define PI 3.141592653589793

double angle(double x1 , double y1 , double x2 , double y2 , double x3 , double y3){
	double ax , ay , bx , by , a , b , ip , ia;
	ax = x1 - x2;
	ay = y1 - y2;
	bx = x3 - x2;
	by = y3 - y2;
	a = sqrt(ax*ax + ay*ay);
	b = sqrt(bx*bx + by*by);
	ip = ax * bx + ay * by;
	ia = acos(ip/(a*b));
	return ia;
}

int main(void){
	double xa,ya,xb,yb,xc,yc,xd,yd,ia;
	while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf" , &xa,&ya,&xb,&yb,&xc,&yc,&xd,&yd)!=EOF){
		ia = angle(xa,ya,xb,yb,xc,yc) + angle(xb,yb,xc,yc,xd,yd) + angle(xc,yc,xd,yd,xa,ya) + angle(xd,yd,xa,ya,xb,yb);
		if(fabs(ia - 2 * PI) < 1e-6) printf("YES");
		else printf("NO");
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, A, B, MIN;
ll res;

int main(){
	cin >> N;
	MIN = intmax;
	while (N--) {
		cin >> A >> B;
		if (A > B)MIN = min(MIN, B);
		res += A;
	}
	if (MIN == intmax) {
		cout << 0 << endl;
	}
	else {
		cout << res - MIN << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)

int N;
int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N){
        int ans=0;
        int a,n,c;
        cin>>c>>a>>n;
        if(a!=0&&n!=0&&c!=0){
            ans+=min({a,n,c});
            int temp=min({a,n,c});
            a-=temp;
            n-=temp;
            c-=temp;
        }
        // cout<<c<<" "<<a<<" "<<n<<endl;
        if(a!=0&&c!=0){
            ans+=min(c/2,a);
            if(c/2>a)c-=a*2,a=0;
            else c=0,a-=(c/2);
        }
        // cout<<c<<" "<<a<<" "<<n<<endl;
        if(c!=0){
            ans+=(c/3);
            c-=(c/3)*3;
        }
        // cout<<c<<" "<<a<<" "<<n<<endl;
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3228
# include"stdio.h"
int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    int n=a+b;
    if(b+c<n) n=b+c;
    if(a+c<n) n=a+c;
    printf("%d\n",n);
}


Measured memory_bytes: 1676
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <string>

int main() {
  int a, b, c, d;
  scanf("%d %d %d %d", &a, &b, &c, &d);

  while (true) {
    c -= b;
    if (c <= 0) return puts("Yes"), 0;
    a -= d;
    if (a <= 0) return puts("No"), 0;
  }
}


Measured memory_bytes: 1640
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	list := getStdinIntArr()
	K := list[0]
	S := list[1]

	sum := 0
	for z := 0; z <= K; z++ {
		for y := 0; y <= K; y++ {
			if y+z <= S && (S-(y+z)) <= K {
				sum++
			}
		}
	}

	fmt.Printf("%d\n", sum)
}

func getStdin() string {
	sc.Scan()
	return sc.Text()
}
func getStdinInt() int {
	sc.Scan()
	rtn, _ := strconv.Atoi(sc.Text())
	return rtn
}
func getStdinIntArr() []int {
	sc.Scan()
	str := sc.Text()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}


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

#define int long long

#define _   int v, int tl, int tr, int l, int r
#define tm  (tl + tr >> 1)
#define sol v+v, tl, tm, l, r
#define sag v+v+1, tm+1, tr, l, r
#define pb push_back
#define mp make_pair
#define st first
#define nd second
typedef pair < int , int > pp;
const int mod = 1e9 + 7;
const int N   = 1e5 + 5;

pp P[N];
int A[N], W[N], w, F[N], dp[N], n;

int qry(int x){
    int t = 1;
    for(; x <= n; x += x&-x)
        t = (t + F[x]) % mod;
    return t;
}
void up(int x, int t){
    for(; x > 0; x -= x&-x)
        F[x] = (F[x] + t) % mod;
}

signed main(){
    int m;
    cin >> n >> m;
    for(int i=1; i<=n; i++) scanf("%lld", &A[i]);
    int p = 0;
    for(int j=1, i=1; i<=m; i++){
        int x;
        scanf("%lld", &x);
    	for(; j <= n && A[j] < x; j++){
            if(i == 1) continue;
            P[++w] = mp(A[j] - p, x - A[j]);
            W[w] = P[w].nd;
        }
    	p = x;
    }    
    
    sort(P+1 , P+w+1);
    sort(W+1 , W+w+1);
    int ans = 1;
    int predp = 0;
    for(int i=w; i>=1; i--){
        if(P[i] == P[i+1]) continue;
        int ind = lower_bound(W+1 , W+w+1 , P[i].nd) - W;

        int dp = qry(ind+1);
        up(ind, dp);	
		if(P[i].st == P[i+1].st)
        	up(ind, mod-predp);
		else
            ans = (ans + predp) % mod;
    
        predp = dp;
    }
    
    cout << (ans + predp) % mod;
    return 0;
}

Measured memory_bytes: 4224
N = int(input())
if 1 <= N <= 100:
    for i in range(0,25):
        for v in range(0,14):
            if (4 * i) + (7 * v) == N:
                print('Yes')
                break
        if (4 * i) + (7 * v) == N:
            break
    else:
        print('No')
else:
    print('No')

Measured memory_bytes: 3060