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

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define LL long long
#define pii pair<int,int>
#define SZ(x)  (int)x.size()
#define all(x) x.begin(),x.end()

using namespace std;

LL gcd(LL a, LL b) {return b ? gcd(b, a % b) : a;}
LL lcm(LL a, LL b) {return a / gcd(a, b) * b;}
LL powmod(LL a, LL b, LL MOD) {LL ans = 1; while (b) {if (b % 2)ans = ans * a % MOD; a = a * a % MOD; b /= 2;} return ans;}
const int N = 5e5 + 3;
const LL mod = 1e9 + 7;
int n;
int a[(1<<18)+30];
int b[(1<<18)+30];
int cnt=0;
bool sta[(1<<18)+30];
int cmp1(int x,int y){
	return a[x]>a[y];
}
int main() {
	ios::sync_with_stdio(false);
    cin>>n;
    int turn=n;
    for(int i=1;i<=(1<<n);i++)cin>>a[i];
    n=(1<<n);
    sort(a+1,a+1+n,[](int x,int y){return x>y;});
    vector<int>res,tmp;
    res.pb(1);
    sta[1]=1;
    for(int i=1;i<=turn;i++){
        tmp=res;
        int l=1;
        int now=0;
        while(l<=n&&now<tmp.size()){
            if(sta[l])l++;
            else if(a[tmp[now]]>a[l]){
                now++;
                res.pb(l);
                sta[l]=1;
                l++;
            }else{
            	l++;
            }
        }
        sort(all(res),cmp1);
        if(now!=tmp.size())return cout<<"No\n",0;
    }
    cout<<"Yes\n";
    return 0;
}
//5 4 4 4 3 3 3 2
//5 4 4 3
//5 4 4  3 4 3 

Measured memory_bytes: 3312
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      if i*500+j*100+k*50 == x:
        ans += 1
print(ans)

Measured memory_bytes: 3064
def lcm(a, b):
    ax = a
    bx = b
    if a<b:
        ax, bx = (bx, ax)
    while True:
        if ax%bx == 0:
            gcd = bx
            break
        else:
            c = bx
            bx = ax%bx
            ax = c
    return a*b // gcd

n = int(input())
lst = []
lst2 = []
for i in range(n):
    a = int(input())
    lst.append(a)

while True:    
    if n==1:
        print(lst[0])
        break
    lst2.append(lcm(lst[0], lst[1]))
    lst.pop(0)
    lst.pop(0)
    lst2.extend(lst)
    if len(lst2)==1:
        print(lst2[0])
        break
    lst.clear()
        
    lst.append(lcm(lst2[0], lst2[1]))
    lst2.pop(0)
    lst2.pop(0)
    lst.extend(lst2)
    if len(lst)==1:
        print(lst[0])
        break
    lst2.clear()

Measured memory_bytes: 3064
n,m = map(int,input().split())
pys = []
for i in range(m):
    pys.append([i+1])
    pys[i][len(pys[i]):len(pys[i])] = list(map(int,input().split()))

ms = []
for _ in range(n+1):
    ms.append([])

for py in pys:
    ms[py[1]].append(py)

for sm in ms:
    sm.sort(key=lambda x : x[2])
    for i in range(len(sm)):
        sm[i].append(i+1)


res = []
for _ in range(m+1):
    res.append([])

for m in ms:
    for shi in m:
        res[shi[0]]=[shi[1],shi[3]]

for i in range(1,len(res)):
    print(str(res[i][0]).zfill(6)+str(res[i][1]).zfill(6))

Measured memory_bytes: 50716
import bisect

n,m = map(int,input().split())	
aaa = [list(map(int,input().split())) for i in range(m)]
ab = sorted(aaa)
#ab = sorted(aaa, key=lambda x: x[0])
#print(ab)
l = []
l.append(ab[0][0]-1)
l.append(ab[0][1]-1)

p = 1

if m != 1:
    

    for i in range(1,m):
        a = ab[i][0]-1
        b = ab[i][1]-1
        if a != l[len(l)-2]:
            if a < l[len(l)-1]:
                l[len(l)-2] = a
                if b < l[len(l)-1]:
                    l[len(l)-1] = b
            else:
                l.append(a)
                l.append(b)
                p += 1
print(p)
                

Measured memory_bytes: 28676
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <math.h>
#include <vector>
#include <algorithm>
#include <stack>
#include <set>
#include <ctime>
#include <deque>
#include <unordered_map>
#include <map>
#include <random>
#include <cstdio>
#include <string>
#include <cctype>
#define int long long
#define pb push_back
#define eb emplace_back
#define rs resize
#define ld long double
#define vi vector<int>


using namespace std;

const double PI = atan2(0, -1);

void solve() {
    string s;
    cin >> s;
    if (s[3] == s[2] && s[4] == s[5])cout << "Yes";
    else cout << "No";
}


signed main() {
    ///  freopen("salesman.in", "r", stdin);
   //   freopen("salesman.out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed;
    cout.precision(30);
    int t = 1;
    while(t--)
    solve();
    //   system("pause");
}

Measured memory_bytes: 256
import numpy as np
N, K = map(int, input().split())
A = list(map(int, input().split()))
dp1 = np.zeros((N+1, K), dtype=bool)
dp1[0][0] = 1
for i, a in enumerate(A, 1):
    dp1[i, :] = dp1[i-1, :]
    dp1[i, a:] += dp1[i-1, :-a]
dp2 = np.zeros((N+1, K), dtype=bool)
dp2[N][0] = 1
for i, a in zip(range(N-1, -1, -1), A[::-1]):
    dp2[i, :] = dp2[i+1, :]
    dp2[i, a:] += dp2[i+1, :-a]
ans = 0
for a, d1, d2 in zip(A, dp1[:-1], dp2[1:]):
    if a >= K:
        continue
    d2_ = np.zeros(K+a, dtype=np.int32)
    d2_[a:] = d2
    d2_cum = np.cumsum(d2_)
    d2_diff = d2_cum[a:] - d2_cum[:-a]
    d = d2_diff[::-1] * d1
    if (d == 0).all():
        ans += 1
print(ans)


Measured memory_bytes: 61840
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    int n,m;
    cin >> n >> m;
//    cout << n << " " << m << endl;
  	vector<int> s(m);
  	vector<int> c(m);
    for (int i = 0; i < m; i++) {
        cin >> s[i];
        cin >> c[i];
    }
/*
    for (int i = 0; i < m; i++) {
        cout << s[i] << " ";
    }
    cout << endl;
    for (int i = 0; i < m; i++) {
        cout << c[i] << " ";
    }
    cout << endl;
*/
    int f[n];
    int ans_ary[n];
    bool flgx[n];
  if(n == 0){
    n = 1;
  }
  for(int i = 0; i<3; i++){
        f[i] = n - i;
//        cout << f[i];
        ans_ary[i] = 0;
//        cout << ans_ary[i];
    	flgx[i] = false;
  }
//    cout << endl;
 
  
    for (int i = 0; i < m; i++) {
//        cout << "s[i] :" << s[i]  << endl;
//        cout << "ans_ary[s[i]] :" << ans_ary[s[i]]  << endl;
//        cout << "c[i] :" << c[i]  << endl;
        if(ans_ary[s[i]-1] == 0 || ans_ary[s[i]-1] == c[i]){
            ans_ary[s[i]-1] = c[i];
            flgx[s[i]-1] = true;
        }else{
            cout << "-1" << endl;
            return 0;            
        }
//        cout << ans_ary[i];
    }
//  cout << ans_ary[0] << " " << ans_ary[1] << " " << ans_ary[2] << endl;
//    cout <<  endl;
//  	cout << flgx[0] << " " << flgx[1] << " " << flgx[2] << endl;
    if( (flgx[0] == false && flgx[1] == false && flgx[2] == false && n-1 != 0)
       	||((ans_ary[0] == 0 || ans_ary[1] == 0 || ans_ary[2] == 0) && (flgx[0] != true && n-1 != 0) )
      	){  
        for(int i = 0; 0<n; i++){
    //		cout << i << flgx[i] << endl;
            if(flgx[i] == false){
                ans_ary[i] = 1;
    //            cout << i << ans_ary[i] << endl;
                break;
            }      
    //        cout << i << ans_ary[i] << endl;
        }
    }
 
//  cout << ans_ary[0] << " " << ans_ary[1] << " " << ans_ary[2] << endl;
//  cout << n << n-1 << endl;
  	bool flg = false;
    for(int i = 0; i<n; i++){
        if( (i == n-1 && ans_ary[n-1] == 0 && flgx[3-n] != true)
            ||ans_ary[i] != 0 || flg == true){
            cout << ans_ary[i];
          	flg = true;
        }
    }
  	if(flg == false){
      cout << "-1" << endl;
      return 0;
    }      
    cout << endl;
 
}

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

ans=0
B=[0]
for i in range(N):
    B.append(B[i]+A[i])

import collections
dic=dict(collections.Counter(B))

C=list(dic.values())

for k in C:
    if k >=2:
        ans += k*(k-1) // 2

print(ans)

Measured memory_bytes: 47600
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    vector<vector<int>> A(3, vector<int>(3));
    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++){
            cin >> A.at(i).at(j);
        }
    }
    int N;
    cin >> N;
    for (int Q = 0; Q < N; Q++){
        int a;
        cin >> a;
        for (int i = 0; i < 3; i++){
            for (int j = 0; j < 3; j++){
                if (A.at(i).at(j) == a){
                    A.at(i).at(j) = -1;
                }
            }
        }
    }
    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++){
            if (A.at(i).at(j) != -1){
                break;
            }
            if (j == 2){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++){
            if (A.at(j).at(i) != -1){
                break;
            }
            if (j == 2){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    if (A.at(0).at(0) == -1 && A.at(1).at(1) == -1 && A.at(2).at(2) == -1){
        cout << "Yes" << endl;
    }
    else if (A.at(2).at(0) == -1 && A.at(1).at(1) == -1 && A.at(0).at(2) == -1){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll mod = 1e9+7;


void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


/* 注意 

    1LL<<60 * N とかのオーバーフローに気を付けろ
    制約がヒントになる、ちゃんと全ての制約を見ろ

*/

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

    int H, N; cin >> H >> N;
    vector<ll> a(N+1, 0), b(N+1, 0);
    repr(i, 1, N+1) cin >> a[i] >> b[i];

    ll const inf = 1LL<<58;
    vector<vector<ll>> dp(N+5, vector<ll>(H+10005, inf));
    rep(i, N+1) dp[i][0] = 0;
    
    repr(i, 1, N+1) rep(j, H+10005) {
        if (j >= a[i]) {
            chmin(dp[i][j], dp[i][j-a[i]]+b[i]);
            chmin(dp[i][j], dp[i-1][j]);
        }
        if (j <= a[i]) {
            chmin(dp[i][j], dp[i-1][j]);
            chmin(dp[i][j], b[i]);
        }
    }

    ll ans = inf;
    repr(j, H, H+10005) chmin(ans, dp[N][j]);
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 161280
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>

using namespace std;

int main()
{
	char c;

	scanf("%s", &c);

	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
	{
		printf("vowel\n");
	}else
	{
		printf("consonant\n");
	}

	return 0;
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pi 3.1415926535
#define ld long double
ld calcAngle(long double h,long  double m)  
{  
  
  
    ld hour_angle = 0.5*(h*60+m);
    ld min_angle  = 6*m; 
    ld angle = abs(hour_angle - min_angle);  
  
    angle = min(360.0 - angle, angle);  
  
    return angle;  
}
int main(){
  
  long double a, b, h , m;
  cin >> a >> b >> h>> m;
  ld theta = calcAngle(h,m);
  ld angle = (ld)theta/180.0;
  angle *= M_PI;
  ld ans = (ld)sqrt((ld)a*a+(ld)b*b-(ld)2*a*b*cos((ld)angle));
  cout<<fixed<<setprecision(9)<<ans<<"\n";
  
  return 0;
	
}


Measured memory_bytes: 4168
import bisect
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))
d=0
for t in b:
    d+=bisect.bisect_left(a,t)*(n-bisect.bisect_right(c,t))
print(d)

Measured memory_bytes: 29100
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
  ll a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  if(e-a>k) {
cout<<":("<<endl;
  }
  else {
cout<<"Yay!"<<endl;
  }
}


Measured memory_bytes: 3588
#include<cstdio>
#include<cstring>

int n,m;
char s[100001],t[100001];

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

int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s",s); scanf("%s",t);
	if (s[0]!=t[0]) {printf("-1\n"); return 0;}
	for (int i=1; i<n; i++)
		if (1ll*m*i%n==0&&s[i]!=t[1ll*m*i/n]) {printf("-1\n"); return 0;}
	printf("%lld\n",1ll*n*m/gcd(n,m));
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define pb push_back
#define ff first
#define ss second
using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<ll, ll>;
int n;
int val[200005];
vector<int> g[200005];
int len = 1;
int ans[200005];
vector<int> s;
void dfs(int u, int p = -1) {
  ans[u] = len;
  for (int v : g[u]) {
    if (v == p)
      continue;
    if (val[v] > s[len - 1]) {
      int prev = s[len];
      s[len] = val[v];
      len++;
      dfs(v, u);
      len--;
      s[len] = prev;
    } else {
      int pos = lower_bound(s.begin(), s.begin() + len, val[v]) - s.begin();
      // cout << v << ' ' << pos << endl;
      int prev = s[pos];
      s[pos] = val[v];
      dfs(v, u);
      s[pos] = prev;
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> val[i];
  for (int i = 0; i < n - 1; i++) {
    int u, v;
    cin >> u >> v;
    g[u].pb(v);
    g[v].pb(u);
  }
  s.resize(200005);
  s[0] = val[1];
  dfs(1);
  for (int i = 1; i <= n; i++) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 30828
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;

int main() {
  int N;
  cin >> N;
  bool nnnx = N / 10 % 111 == 0;
  bool xnnn = N % 1000 % 111 == 0;
  cout << (nnnx || xnnn ? "Yes" : "No") << endl;
}


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

int main(void){
	int a[50] = {0};
	int n,p,dp,i = 0;

	while(cin >> n >> p, n){
		i = 0; dp = p;
		memset(a, 0, sizeof(a));
		while(1){
			if(dp){ a[i]++; dp--;}
			else{ dp = a[i]; a[i] = 0;}
			if(a[i] == p) break;
			if(++i == n) i = 0;
		}
	cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using static System.Math;
using System.Linq;
using static System.Array;

namespace ConsoleApp2
{
    class Program
    {
        static string S;
        static long ans;
        static void Main(string[] args)
        {
            //N = long.Parse(Console.ReadLine());
            var AB = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
            var B = AB[0];
            var A = AB[1];
            var X = AB[2];

            var ans = (A / X) - (Max(B - 1, 0) / X);
            if(B == 0)
            {
                ans++;
            }

            Console.WriteLine(ans);
        }
       
    }


}


Measured memory_bytes: 28088
# D - Wizard in Maze
import sys
from collections import deque
from typing import List, Tuple


class WarpableMaze:
    __slots__ = ["height", "width", "road", "wall", "unsearched", "grid"]

    def __init__(
        self,
        height: int,
        width: int,
        grid: List[bytes],
        road: str = ".",
        wall: str = "#",
    ) -> None:
        self.height = height + 4
        self.width = width + 4
        self.road = road
        self.wall = wall
        self.unsearched = 1 << 30
        self.grid = self._flatten_grid(grid)

    def _flatten_dxy(self, x: int, y: int) -> int:
        return self.width * x + y

    def _flatten_coordinate(self, h: int, w: int) -> int:
        return self._flatten_dxy(h + 2, w + 2)

    def _flatten_grid(self, grid: List[bytes]) -> str:
        flat_grid = self.wall * (self.width * 2)
        for row in grid:
            flat_grid += self.wall * 2 + row.decode() + self.wall * 2
        flat_grid += self.wall * (self.width * 2)
        return flat_grid

    def bfs(self, start_2d: Tuple[int, int], goal_2d: Tuple[int, int]) -> int:
        start = self._flatten_coordinate(*start_2d)
        goal = self._flatten_coordinate(*goal_2d)

        w = self.width
        walk_to_warp = {
            -w: (-2 * w - 2, -2 * w - 1, -2 * w, -2 * w + 1, -w - 1),
            w: (w + 1, 2 * w - 1, 2 * w, 2 * w + 1, 2 * w + 2),
            -1: (-w - 2, -2, w - 2, w - 1, 2 * w - 2),
            1: (-w + 1, -2 * w + 2, -w + 2, 2, w + 2),
        }

        convert = lambda c: self.unsearched if c == self.road else -1
        dist = list(map(convert, self.grid))
        dist[start] = 0
        queue = deque([start])
        while queue:
            x = queue.popleft()
            cur_dist = dist[x]
            if x == goal:
                break

            for walk, warp in walk_to_warp.items():
                nx = x + walk
                if dist[nx] > cur_dist:
                    dist[nx] = cur_dist
                    queue.appendleft(nx)
                    continue
                if dist[nx] >= 0:
                    continue

                for dx in warp:
                    nx = x + dx
                    if dist[nx] > cur_dist + 1:
                        dist[nx] = cur_dist + 1
                        queue.append(nx)

        return dist[goal] if dist[goal] != self.unsearched else -1

    def debug(self):
        print("<DEBUG>", file=sys.stderr)
        for row in zip(*[iter(self.grid)] * self.width):
            print(*row, file=sys.stderr)


def main():
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline

    H, W = map(int, readline().split())
    CH, CW = map(int, readline().split())
    DH, DW = map(int, readline().split())
    (*S,) = read().split()

    maze = WarpableMaze(H, W, S)
    start, goal = (CH - 1, CW - 1), (DH - 1, DW - 1)
    print(maze.bfs(start, goal))
    # maze.debug()


if __name__ == "__main__":
    main()


Measured memory_bytes: 220748
function main(_stdin) {
    const stdin = _stdin.trim().split('\n');
    const n = Number(stdin.shift());
    const S = stdin.shift().split(' ').map(Number);
    const cnt = [0];

    mergeSort(S, 0, n, cnt);

    console.log(S.join(' '));
    console.log(cnt[0]);
}

function merge(A, left, mid, right,cnt){
    const lefts = A.slice(left, mid);
    const rights = A.slice(mid, right);
    lefts.push(Infinity);
    rights.push(Infinity);

    let leftsIdx = 0;
    let rightsIdx = 0;

    for (let i = left; i < right; i++) {
        cnt[0] += 1;
        if(lefts[leftsIdx] <= rights[rightsIdx]) {
            A[i] = lefts[leftsIdx];
            leftsIdx++;
        } else {
            A[i] = rights[rightsIdx];
            rightsIdx++;
        }
    }
}


function mergeSort(A, left, right, cnt) {
    if (left + 1 < right) {
        const mid = Math.floor((left + right) / 2);
        mergeSort(A, left, mid, cnt);
        mergeSort(A, mid, right, cnt);
        merge(A, left, mid, right,cnt);
    }
}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 130396
import bisect
while True:
    n, m = map(int, input().split())
    if n == 0:break
    a = [tuple(map(int, input().split())) for _ in range(n)]
    a.sort(key = lambda x:x[1], reverse = True)
    a.sort(key = lambda x:x[0])
    v = 0
    for i in range(1, m + 1):v += a[bisect.bisect_left(a,(i,0))][1]
    print(v)


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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

int H, W;
VC2 s;

int di[] = {1, 0, -1, 0};
int dj[] = {0, -1, 0, 1};

bool isOk(int i, int j) {
    REP(k, 4) {
        int ni = i + di[k];
        int nj = j + dj[k];
        if(ni >= 0 && nj >= 0 && ni < H && nj < W) {
            if(s[ni][nj] == '#') {
                return true;
            }
        }
    }
    return false;
}

int main() {
    std::cin >> H >> W;
    s.resize(H, VC(W));

    REP(i, H) {
        REP(j, W) {
            std::cin >> s[i][j];
        }
    }

    bool res = true;
    REP(i, H) {
        REP(j, W) {
            if(s[i][j] == '#') {
                if(!isOk(i, j)) {
                    res = false;
                    break;
                }
            }
        }
        if(!res) {
            break;
        }
    }

    if(res) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

int N, C, S, F, T[500] = {0};
ll t = 0;

int main()
{
  cin >> N;

  REP(i, N - 1)
  {
    cin >> C >> S >> F;
    T[i] = S + C;
    REP(j, i)
    {
      int d = max(0, T[j] - S);
      int s = S + (int)((d + F - 1) / F) * F;
      T[j] = s + C;
    }
  }

  REP(i, N)
  {
    cout << T[i] << '\n';
  }

  return 0;
}


Measured memory_bytes: 256
/***********************************************************
 *This code By @1353055672(Ligen)                          *
 *[Warning]You're not excepted to understand this code!    *
 *CSP-S 2019 RP++                                          *
 ***********************************************************/
// #pragma GCC optimize(3)
#define ADD_STACK int size = 512 << 20;\
	char *pp = (char*)malloc(size) + size;  \
	__asm__("movl %0, %%esp\n" :: "r"(pp))
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<fstream>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<bitset>
#include<ctime>
#include<vector>
#define ll long long
#define ull unsigned long long
#define mn 200020
#define Max(x,y) (((x)>(y))?(x):(y))
#define Min(x,y) (((x)<(y))?(x):(y))
#define Abs(x) (((x)<(0))?(-(x)):(x))
#define infll (ll)(1e18)
#define infint (1<<30)
#define mod (int)(1e9+7)
#define FOR(a,b,c) for (register int a=b;a<=c;++a)
#define FORD(a,b,c) for (register int a=b;a>=c;--a)
using namespace std;
// char buf[1<<20],*p1=buf,*p2=buf;
// #define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
inline ll read(){
	ll x=0,f=1;char c;
	for(c=getchar();c<'0'||c>'9';f=((c=='-')?-1:f),c=getchar());
	for(;c>='0'&&c<='9';x=x*10+c-'0',c=getchar());
	return x*f;
}
template<typename T>
inline void write(T a){
	if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
	while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
}
inline void write_(){return;}
template<typename T,typename... Args>
inline void write_(T a,Args... b){write(a);putchar(' ');write_(b...);}
inline void writeln(){putchar('\n');return;}
template<typename T,typename... Args>
inline void writeln(T a,Args... b){write(a);putchar(' ');writeln(b...);}
//need c++11

//inline void write(ll a){
//    if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
//    while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
//}
//inline void write_(ll a){write(a);putchar(' ');}
//inline void writeln(ll a){write(a);putchar('\n');}
inline ll gcd(ll a,ll b){return a==0?b:gcd(b%a,a);}
inline ll lcm(ll a,ll b){return 1ll*a/gcd(a,b)*b;}
inline ll Pow(ll n,ll a){ll b=1;while(a){if(a&1)b=1ll*b*n%mod;n=1ll*n*n%mod;a>>=1;}return b;}
//---------------------Head Files--------------------------//

signed main(){
#ifdef LOCAL_LIGEN
	freopen("0.in","r",stdin);
	// freopen("0.out","w",stdout);
	double be=clock();
#endif
	int a=read(),b=read();
	if(a>9)return writeln(-1),0;
	if(b>9)return writeln(-1),0;
	writeln(a*b);
#ifdef LOCAL_LIGEN
	double en=clock();
	printf("Time: %.0lfms\n",en-be);
	fclose(stdin);fclose(stdout);
#endif
	return 0;
}


Measured memory_bytes: 256
A, B = map(int, input().split())
sa = B-A
if (A%2==0 and B%2 ==1):
    if(sa%4==1):
        ans = 1
    else:
        ans = 0
elif(A%2==0 and B%2==0):
    if(sa%4==2):
        ans = B+1
    else:
        ans = B
elif(A%2==1 and B%2 ==1):
    if(sa%4==2):
        ans = A-1
    else:
        ans = A
elif(A%2==1 and B%2 ==0):
    if(sa%4==1):
        ans = A^0^B
    else:
        ans = A^1^B
print(ans)

Measured memory_bytes: 3064
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;

const int L=2001;

const LL inf=1LL<<60;
int N,M;
LL dist[L];
LL a[L];
LL b[L];
LL c[L];
int main() {
	scanf("%d%d",&N,&M);

	for(int i=0;i<M;i++){
		scanf("%lld%lld%lld",a+i,b+i,c+i);
		a[i]--;b[i]--;
	}
	fill(dist,dist+N,-inf);
	dist[0]=0;
	for(int i=0;i<=N;i++){
		for(int j=0;j<M;j++){
			if(dist[a[j]]!=-inf&&dist[b[j]]<dist[a[j]]+c[j]){
				dist[b[j]]=dist[a[j]]+c[j];
				if(b[j]==N-1&&i>=N){
					puts("inf");
					return 0;
				}
			}
		}
	}
	printf("%lld\n",dist[N-1]);

	return 0;
}



Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
	int i,j,k,ans=0,n;
	cin>>n;
	int a[n];
	for(i=0;i<n;i++)
		cin>>a[i];
	sort(a,a+n);
	for(i=0;i<n;i=j)
	{
		k=1;
		for(j=i+1;j<n;j++)
		{
			if(a[i]==a[j])
				k++;
			else
				break;
		}
		if(k>a[i])
			ans=ans+(k-a[i]);
		if(k<a[i])
			ans=ans+k;
		//cout<<k<<endl;
	}	
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 640
import std;
enum inf(T)()if(__traits(isArithmetic,T)){return T.max/4;}
T scan(T=long)(){return readln.chomp.to!T;}
void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;}
T[] scanarr(T=long)(){return readln.chomp.split.to!(T[]);}
alias Queue=DList;auto enq(T)(ref Queue!T q,T e){q.insertBack(e);}T deq(T)(ref Queue!T q){T e=q.front;q.removeFront;return e;}
alias Stack=SList;auto push(T)(ref Stack!T s,T e){s.insert(e);}T pop(T)(ref Stack!T s){T e=s.front;s.removeFront;return e;}
struct UnionFind(T){T[T]u;ulong[T] rank;@property{bool inc(T e){return e in u;}auto size(){return u.keys.length;}auto dup(){T[] child=u.keys;T[] parent=u.values;auto res=UnionFind!T(child);child.each!(e=>res.add(e));size.iota.each!(i=>res.unite(child[i],parent[i]));return res;}}this(T e){e.add;}this(T[] es){es.each!(e=>e.add);}auto add(T a,T b=a){assert(b.inc);u[a]=a;rank[a];if(a!=b)unite(a,b);}auto find(T e){if(u[e]==e)return e;return u[e]=find(u[e]);}auto same(T a,T b){return a.find==b.find;}auto unite(T a,T b){a=a.find;b=b.find;if(a==b)return;if(rank[a]<rank[b])u[a]=b;else{u[b]=a;if(rank[a]==rank[b])rank[a]++;}}}
struct PriorityQueue(T,alias less="a<b"){BinaryHeap!(T[],less) heap;@property{bool empty(){return heap.empty;}auto length(){return heap.length;}auto dup(){return PriorityQueue!(T,less)(array);}T[] array(){T[] res;auto tp=heap.dup;foreach(i;0..length){res~=tp.front;tp.removeFront;}return res;}void push(T e){heap.insert(e);}void push(T[] es){es.each!(e=>heap.insert(e));}}T look(){return heap.front;}T pop(){T tp=look;heap.removeFront;return tp;}this(T e){ heap=heapify!(less,T[])([e]);}   this(T[] e){ heap=heapify!(less,T[])(e);}}
//END OF TEMPLATE

void main(){
    long s,w;
    scan(s,w);
    (w<s?"safe":"unsafe").writeln;
}


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

int main()
{
    int h, w;
    while (true)
    {
        cin >> h >> w;
        if ((h == 0) && (w == 0))
            break;
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                int key;
                if (i % 2 == 0)
                    key = 0;
                else
                    key = 1;

                if (j % 2 == key)
                    cout
                        << "#";
                else
                    cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll=long long;
using vec=vector<ll>;
using Graph = vector<vector<ll>>;
#define loop(i,n) for(ll i=0;i<n;i++)
#define Loop(i, m, n) for(ll i = m;i < n;i++)
#define pool(i,n) for(ll i=n-1;i>=0;i--)
#define Pool(i, m, n) for(ll i=n-1;i>=m;i--)
#define MAX 99999999999ll
#define MIN -99999999999ll
#define setbit bitset<8>
#define flagcount __builtin_popcount
#define flag(x) (1<<x)
#define flagadd(bit,x) bit|=flag(x)
#define flagpop(bit,x) bit&=~flag(x) 
#define flagon(bit,i) bit&flag(i)
#define flagoff(bit,i) !(bit & (1<<i))
#define all(v) v.begin(),v.end()
#define low2way(v,x) lower_bound(all(v),x)
#define high2way(v,x) upper_bound(all(v),x)
#define count2way(v,x) high2way(v,x)-low2way(v,x)
#define lower(v,x) low2way(v,x)-v.begin() //1番左が0、もし見つから無いならｎを出力
#define higher(v,x) high2way(v,x)-v.begin()-1 //1番左が0、もし見つからないならn-1を出力（注意）
#define putout(a) cout<<a<<endl
#define putout2(a,b) putout(a);putout(b)
#define putout3(a,b,c) putout(a);putout(b);putout(c)
#define putout4(a,b,c,d) putout(a);putout(b);putout(c);putout(d)
#define putout5(a,b,c,d,e) putout(a);putout(b);putout(c);putout(d);putout(e)
#define Gput(a,b) G[a].push_back(b)
#define cin1(a) cin>>a
#define cin2(a,b) cin>>a>>b
#define cin3(a,b,c) cin>>a>>b>>c
#define cin4(a,b,c,d) cin>>a>>b>>c>>d
#define cin5(a,b,c,d,e) cin>>a>>b>>c>>d>>e

ll ctoi(char c){
	if(c>='0'&&c<='9'){
		return c-'0';
	}
	return 0;
}
int main() {
cout << fixed << setprecision(16);
  ll n;
  cin>>n;
  putout(n*n);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;

int main(void) {
  ll a,b,c;
  cin >> a >> b >> c;
  if((c-a-b)*(c-a-b)>4*a*b && (c-a-b)>0)cout << "Yes" <<endl;
  else cout << "No" <<endl;
  
}




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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	int N; cin >> N;
	int ans = (N-2)*180;
	
	cout << ans << endl;


	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
#define vall(x) (x).begin(), (x).end()
using namespace std;
using lli = long long int;
void YESNO(bool), YesNo(bool);
template <class T1, class T2>
bool chmin(T1 &l, const T2 &r);
template <class T1, class T2>
bool chmax(T1 &l, const T2 &r);
template <class T1, class T2>
void vadd(vector<T1> &v, T2 x);

#define int long long int

vector<int> e[100005];
bool leaf[100005];
bool dfs(int u, int p)
{
  bool use = false;
  for (auto s : e[u])
  {
    if (s != p)
    {
      bool pained = dfs(s, u);
      if (!pained && !use)
      {
        use = true;
      }
      else if (!pained && use)
      {
        cout << "First" << endl;
        exit(0);
      }
    }
  }
  return use;
}
void solve(long long N, std::vector<long long> a, std::vector<long long> b)
{
  rep(i, N - 1) a[i]--, b[i]--;
  rep(i, N - 1) e[a[i]].push_back(b[i]), e[b[i]].push_back(a[i]);
  cout << (dfs(0, -1) ? "Second"
                      : "First")
       << endl;
}
signed main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<long long> a(N - 1);
  std::vector<long long> b(N - 1);
  for (int i = 0; i < N - 1; i++)
  {
    scanf("%lld", &a[i]);
    scanf("%lld", &b[i]);
  }
  solve(N, std::move(a), std::move(b));
  return 0;
}

// -- lib
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }

template <class T1, class T2>
bool chmin(T1 &l, const T2 &r)
{
  return (l > r) ? (l = r, true) : false;
}

template <class T1, class T2>
bool chmax(T1 &l, const T2 &r)
{
  return (l < r) ? (l = r, true) : false;
}

template <class T1, class T2>
void vadd(vector<T1> &v, T2 x)
{
  for (auto &s : v)
    s += T2(x);
}


Measured memory_bytes: 7936
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <cstring>

using namespace std;


int main()
{
  int n, q;
  cin >> n >> q;

  std::queue<string> names;
  std::queue<int> times;


  for(int i =0; i<n; ++i){
    std::string N;
    int T;
    cin >> N >> T;
    names.push(N);
    times.push(T);
  }

  string n1;
  int t1;
  int sum = 0;
  while(!times.empty()){
    n1 = names.front();
    t1 = times.front();


    names.pop();
    times.pop();

    if(q < t1){
      names.push(n1);
      times.push(t1-q);
      sum += q;
    }else{
      cout << n1 << " " << sum + t1 << endl;
      sum += t1;
    }
  }
    return 0;
}


Measured memory_bytes: 5640
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

#define PI 3.14159265359
#define rep(i,a) for(int i=0;i<a;i++)

//int型を受け取ってその桁数を返す
int check_digits(int n, int m) {
	int digits = 0;
	while (n != 0) {
		n /= m;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum = 0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}


//入力された文字列が回文か判断してboolを返す
bool is_kaibun(string s) {
	string s_r(s.rbegin(), s.rend());
	return (s == s_r);
}


void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }


//提出言語もしっかり確認して…
//問題文を落ち着いて読む！
//型に注意！！
//出力例もちゃんと全部見る！！！！！
int main() {
	int n;
	cin >> n;
	map<string, int> s;
	string temp;
	rep(i, n) {
		cin >> temp;
		s[temp]++;
	}

	cout << s.size() << endl;



	system("pause");
	return 0;
}


Measured memory_bytes: 19288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)

int main(){
    double a,b; cin >> a >> b;
    if(a > b) cout << "GREATER" << endl;
    else if(a < b) cout << "LESS" << endl;
    else cout << "EQUAL" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
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; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int X, Y, Z;
	cin >> X >> Y >> Z;

	X -= Z;
	cout << X / (Z + Y) << endl;


	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define L long long
#define LL long long
#define SS string
#define PB push_back
#define pp pair<L,L>
#define f(x, n , i) for (i = x ; i <= n ; i++)
#define setE(a, x , size) memset(a,x,size);
#define N 100500
#define INFY 1000000000000000000
#define EMPTY ""
#define mapss map<pair<L,L>,SS>
#define mapsi map<pair<L,L>,L>
#define reverse(s) reverse(s.begin(),s.end())
#define fr (s , e , i) for (i = s , i >= e ; i--)
using namespace std;
// L matrix[101][N];
// mapss visited;
SS s1,s2;
L visitedix[3005][3005];
SS visited[3005][3005];
L print[3005][3005];
L recursivedpFindLcs(L len1, L len2)
{
    
    if (visitedix[len1][len2])
    return print[len1][len2];
    visitedix[len1][len2] = 1;
    if (len1 == 0 || len2 == 0)
    return 0;
    if (s1[len1-1] == s2[len2-1])
    {
        print[len1][len2] +=  (1 + recursivedpFindLcs(len1-1,len2-1));
    }
    else
    {
        L m1 , m2;
        m1 = recursivedpFindLcs(len1-1,len2);
        m2 = recursivedpFindLcs(len1,len2-1);
        if (m1 > m2)
        print[len1][len2] += m1;
        else
        print[len1][len2] += m2;
    }
    return print[len1][len2];
}
int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    SS s, t;
    cin >> s >> t;
    s1 = s;
    s2 = t;
    L answer = recursivedpFindLcs(s1.length() , s2.length());
    L i = s.length(), j = t.length();
    SS answers;
    // f(0,s.length(),i)
    // {
    //     f(0,t.length(),j)
    //     cout << print[i][j] << " ";
    //     cout << "\n";
    // }
    // i = s.length();
    // j = t.length();
    // cout << i << " " << j<< "\n";
    while (1)
    {
        if (i == 0 || j == 0)
        break;
        if (s[i-1] == t[j-1])
        {
            // cout << s[i-1]; 
            answers += s[i-1];
            i--;
            j--;
        }
        else if (print[i-1][j] > print[i][j-1])
        i--;
        else
        j--;
    }
    reverse(answers);
    cout << answers;
    return 0;
}

Measured memory_bytes: 212096
#include<stdio.h>                                                                                                                                                        

int main(void) {
    int physics, chemistry, biology, earth, history, geography;
    scanf("%d", &physics);
    scanf("%d", &chemistry);
    scanf("%d", &biology);
    scanf("%d", &earth);
    scanf("%d", &history);
    scanf("%d", &geography);

    int sum = 0;
    int min = 100;

    if(min > physics)   min = physics;
    if(min > chemistry) min = chemistry;
    if(min > biology)   min = biology;
    if(min > earth)     min = earth;
    sum = physics + chemistry + biology + earth - min;

    if(history >= geography) sum += history;
    else                     sum += geography;

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

    return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define ll long long
#define ull unsigned long long
#define dd double
#define oo 1001007000
#define ff float
#define ooo 4223352036854775007
#define iii pair<ll,ll>
#define vii vector<ll>
#define viii vector<iii>
#define sss pair<str,str>
#define str string
#define sii set<ll>
#define siii set<iii>
#define r0 return 0
#define pb push_back
#define sz size
using namespace std;

const char E='\n';
const int N=200005;
const int NN=2005;
const ll md=998244353;


int main(){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
    ll dp[N]={0};
    dp[1]=1;
    int n;
    cin >> n;
    int k;
    cin >> k;
    iii seg[20];
    for (int i=1;i<=k;i++){
        cin >> seg[i].first >> seg[i].second;
    }
    int l,r;
    for (int i=2;i<=n;i++){
        for (int j=1;j<=k;j++){
            l=max(1ll,i-seg[j].second);
            r=max(0ll,i-seg[j].first);
            dp[i]+=dp[r]-dp[l-1];
            dp[i]%=md;
        }


        dp[i]+=dp[i-1];
    }




    cout << dp[n]-dp[n-1];
    r0;
}
/*








*/


Measured memory_bytes: 5252
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using P = pair<ll,ll>;
using um = unordered_map<ll,ll>;
#define fl cout<<flush;
#define endl '\n'
template <typename T> inline void prt(T v){cout<<v<<'\n';}
template <typename T> inline bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> inline bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1e9+7;
const ll MOD2=998244353;
const ld pi=3.14159265358979323846;
const ld eps=1e-10;
#define debug(v) cout<<#v<<": ",prt(v);
template <typename A,typename B>
inline void prt(pair<A,B> p){cout<<"("<<p.first<<", "<<p.second<<")\n";}
template <typename A,typename B,typename C>
inline void prt(tuple<A,B,C> p){cout<<"("<<get<0>(p)<<", "<<get<1>(p)<<", "<<get<2>(p)<<")\n";}
inline void prt(bool p){if(p)cout<<"True"<<'\n';else cout<<"False"<<'\n';}
template <typename T> 
inline void prt(vector<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(deque<T> v){cout<<'{';for(ll i=0;i<v.size();i++){cout<<v[i];if(i<v.size()-1)cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename A,typename B>
inline void prt(unordered_map<A,B> v){cout<<'{';ll c=0;for(auto &p: v){cout<<p.first<<":"<<p.second;c++;if(c!=v.size())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(set<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}
template <typename T> 
inline void prt(multiset<T> v){cout<<'{';for(auto i=v.begin();i!=v.end();i++){cout<<*i;if(i!=--v.end())cout<<", ";}cout<<'}'<<'\n';}
signed main(void){
    cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll ans=0;
    for(ll i=0;i<N;++i){
        ans+=(i+1)*(i+2)/2;
    }
   // debug(ans);
    for(ll i=0;i<N-1;++i){
        ll u;
        cin >> u;
        ll v;
        cin >> v;
        if(v<u)swap(u,v);
        ans-=u*(N-v+1);
    }
    prt(ans)
;fl
    return 0;
}



Measured memory_bytes: 3672
import re
import sys
import math
import itertools
from sys import stdin

def main():
    """
     解答をこちらに
    """
    n, l = list(map(int, input().split()))
    t = list(range(l, l+n))
    t_abs = list(map(abs,t))
    eat_ap = t_abs.index(min(t_abs))
    t.pop(eat_ap)
    print(sum(t))


if __name__ == "__main__":
    main()


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

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

int MOD=1e9+7;
ll INF=1e18;

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

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

    vector<vector<int>> f(n+10, vector<int>(n+10, 0));
    for(int i=0; i<n; i++) f[i][0]=a[i];
    for(int i=1; i<n; i++){
        for(int j=0; j<n; j++){
            f[j][i]=min(f[j][(i-1+n)%n], a[(j-i+n)%n]);
        }
    }

    /*
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            cout << f[j][i] << " ";
        }
        cout << endl;
    }
    */

    ll ans=INF;
    for(ll i=0; i<n; i++){
        ll sum=i*x;
        for(int j=0; j<n; j++){
            sum+=f[j][i];
        }
        ans=min(ans, sum);
        //cout << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 16128
n = int(input())
 
s = list(map(int,input().split(" ")))
 
count = 0
for x in range(n):
  if s[x]%2 == 0 and (s[x]%5 != 0 and s[x]%3 != 0):
    count += 1
    
if count == 0:
  print("APPROVED")
else:
  print("DENIED")

Measured memory_bytes: 38384
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <map>
using namespace std;

#define lint long long int
#define N_MAX 200000


int main()
{
    int k, a, b;
    cin >> k >> a >> b;
    
    int dest = 0;
    while (1) {
        dest += k;
        if (a <= dest) {
            if (dest <= b) cout << "OK";
            else cout << "NG";
            cout << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>

using namespace std;

void failure () {
  cout << "No" << endl;
  exit(0);
}

void success () {
  cout << "Yes" << endl;
  exit(0);
}

const int MAX_N = 1e5 + 5;

int deg [MAX_N];
vector<int> adj [MAX_N];

int vis [MAX_N];
int chc [MAX_N];
void dfs (int u) {
  vis[u] = 1;
  for (int nxt : adj[u]) {
    if (!vis[nxt]) {
      chc[u]++;
      dfs(nxt);
    }
  }
}

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

  int n, m;
  cin >> n >> m;

  for (int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;

    deg[u]++;
    deg[v]++;

    adj[u].push_back(v);
    adj[v].push_back(u);
  }

  int excess = 0;
  vector<int> fours;
  for (int i = 1; i <= n; i++) {
    if (deg[i] % 2 == 1) failure();
  }

  for (int i = 1; i <= n; i++) {
    if (deg[i] >= 6) success();
    if (deg[i] == 4) fours.push_back(i);
  }

  if ((int) fours.size() >= 3) success();
  if ((int) fours.size() <= 1) failure();

  dfs(fours[0]);
  if (chc[fours[0]] > 1) success();
  failure();
}


Measured memory_bytes: 8448