akhauriyash/Code-Regression huggingface dataset:
N,M = map(int,input().split())
AB = []
Buffer = []
for i in range(N):
  Buffer = list(map(int,input().split()))
  AB.append(Buffer)
AB.sort()
cure = 0
count = 0
for i in range(M):
  if AB[cure][1] <= 0:
    cure += 1
  AB[cure][1] -=1
  count += AB[cure][0]
print(count)

Measured memory_bytes: 27760
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    A, B, C, D = map(int, readline().split())
    if A + B > C + D:
        print('Left')
    elif A + B == C + D:
        print('Balanced')
    else:
        print('Right')


if __name__ == '__main__':
    main()


Measured memory_bytes: 9180
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

using namespace std;

#define lli long long int
#define REP(i,n) for(int i=0;i<n;i++)
#define REP2(i,n) for(int i=1;i<=n;i++)
#define DEBUG 0

lli px[90001],py[90001];
lli  d[90001];

int main(){

	lli h,w,D;
	cin>>h>>w>>D;

	REP(i,h)REP(j,w){
		lli num;
		cin>>num;
		px[num]=i;
		py[num]=j;
	}

	for(lli i=D+i;i<=h*w;i++){
		d[i]=d[i-D]+abs(px[i]-px[i-D])+abs(py[i]-py[i-D]);
	}

	lli q;
	cin>>q;
	REP(i,q){
		lli l,r;
		cin>>l>>r;
		cout<<d[r]-d[l]<<endl;
	}

	return 0;
}

Measured memory_bytes: 3200
# -*- coding: utf-8 -*-
# 整数の入力
p=str(input())
if p[0] ==p[1] ==p[2] ==p[3]:
    print("No") 
elif p[0] ==p[3] and p[1] == p[2]:
    print("Yes")
elif p[0] == p[1] and p[2] == p[3]:
    print("Yes")
elif p[0] ==p[2] and p[1] == p[3]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
/* Bismillahirrahmanirrahim */
/* Author : Jehian Norman Saviero (@Reiva5) */
#include <bits/stdc++.h>

// MACROS SAMPAH
#define Jehian using
#define Norman namespace
#define Saviero std

Jehian Norman Saviero;

// MACROS TYPE
typedef long l;
typedef long long ll;
typedef unsigned long ul;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pi;
typedef pair<l,l> pl;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<l> vl;
typedef vector<ll> vll;

// MACROS FOR PRINT
#define nl printf("\n")
#define sp printf(" ")

// MACROS FOR ATTRIBUTE
#define fi first
#define se second

// MACROS FOR FUNCTION AND METHOD
#define eb emplace_back
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define ALL(x) (x).begin(), (x).end()
#define ALLN(x,n) (x), (x)+(n)
#define CUBE(x) (SQR(x)*(x))
#define SET(x,y) for (int _qwe = sizeof(x)/sizeof(x[0]); _qwe; ) x[--_qwe] = (y)
#define SQR(x) ((x)*(x))
#define SSORT(x,sz) sort(ALLN(x,sz))
#define RESET(x) memset((x), 0, sizeof(x))
#define VSORT(x) sort(ALL(x))

// MACROS READ INPUT
#define sci(x) scanf("%d", &x)
#define scl(x) scanf("%ld", &x)
#define scll(x) scanf("%lld", &x)
#define scul(x) scl(x)
#define scull(x) scll(x)

int main() {
	ll K, A, B;
	scll(K), scll(A), scll(B);
	ll curr = 1;
	if (A >= B-1) {
		printf("%lld\n", K+curr);
		return 0;
	}
	if (K-(A-curr) > 0) {
		K -= (A - curr);
		curr = A;
	}
	curr += (B-A) * (K/2);
	K &= 1;
	curr += K;
	printf("%lld\n", curr);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

void rotate (string &s)
{
    s=s[s.size()-1]+s.substr(0,s.size()-1);
}

main()
{
    fast;
    int i,j;
    string s,t;
    cin>>s;
    cin>>t;
    int ans=0;
    for (i=0;i<s.size();i++)
    {
        int f=0;
        for (j=0;j<s.size();j++)
        {
            if (s[j]!=t[j])
            {
                f=1;
                break;
            }
        }
        if (f==0)
        {
            ans=1;
            break;
        }
        rotate(s);
    }
    if (ans)
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

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

int main(void){
  string at, s, con;
  cin >> at >> s >> con;
  char ans = s.at(0);
  cout << 'A' << ans << 'C' << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <vector>
#include <iostream>

const int mod = 1e9 + 7;

int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<std::string> g(n);
  for (int i = 0; i < n; ++i) std::cin >> g[i];
  std::vector<std::vector<int>> dp(n);
  for (int i = 0; i < n; ++i) {
    dp[i].resize(m);
    for (int j = 0; j < m; ++j) {
      if (g[i][j] == '#') continue;
      if (i) dp[i][j] += dp[i - 1][j];
      if (j) dp[i][j] += dp[i][j - 1];
      if (!i && !j) dp[i][j] = 1;
      dp[i][j] %= mod;
    }
  }
  printf("%d\n", dp[n - 1][m - 1]);
  return 0;
}


Measured memory_bytes: 5248
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import permutations
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7


#############
# Main Code #
#############

def build_tree(N, edge_list):

    G = [[] for i in range(N)]

    for i in range(len(edge_list)):
        a, b = edge_list[i]
        G[a - 1].append(b - 1)
        G[b - 1].append(a - 1)

    # 葉（末端の数）
    leaves = []
    for i in range(N):
        if len(G[i]) == 1:
            leaves.append(i)

    return G, leaves

N = getN()
query = [[] for i in range(N - 1)]
for i in range(N - 1):
    query[i] = getList()

d = list(sorted(getList()))

edges, leaves = build_tree(N, query)

v = leaves[0]

# 最も理想的な場合のsum = d[0] + d[1] + ... + d[-2]
ans = -d[-1]
nodes = [0] * N

# 葉の先端から辿っていく
def dfs(now):
    global ans
    if nodes[now] > 0:
        return
    nodes[now] = d.pop()
    ans += nodes[now]
    for i in edges[now]:
        if nodes[i] > 0:
            continue
        dfs(i)

dfs(v)
print(ans)
print(*nodes)

Measured memory_bytes: 77144
#include <stdio.h>

int main(){
    int H, W;
    scanf("%d%d", &H, &W);
    while(!(H == 0 && W == 0)){
        for(int i=0; i<H; i++){
            for(int j=0; j<W; j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
        scanf("%d%d", &H, &W);
    }
    return 0;
}

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

#define ll long long

int dp[3003][3003];
string s, t;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/

	cin >> s >> t;
	int n = s.length(), m = t.length();
	dp[0][0] = dp[0][1] = dp[1][0] = 0;

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			if (s[i - 1] == t[j - 1]) {
				dp[i][j] = 1 + dp[i - 1][j - 1];
			}
			else {
				dp[i][j] = max (dp[i - 1][j], dp[i][j - 1]);
			}
		}
	}

	int len = dp[n][m], len_ptr = len - 1, i = n, j = m;
	char ans[len + 1];
	ans[len] = '\0';

	while (i != 0 && j != 0) {
		if (s[i - 1] == t[j - 1]) {
			ans[len_ptr] = s[i - 1];
			i--; j--; len_ptr--;
		}
		else {
			if (dp[i - 1][j] >= dp[i][j - 1]) {
				i--;
			}
			else {
				j--;
			}
		}
	}

	cout << ans;
	return 0;
}

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

int main(){
    //inport
    int A,B;
    cin >> A >> B;

    //process
    int sum = 0;
    for(int i=0;i<2;i++){
        if(A>B){
            sum+=A;
            A--;
        }else{
            sum+=B;
            B--;
        }
    }

    //output
    cout << sum << endl;

    return 0;
}


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

int main(){
  int N,C,K;
  cin >> N >> C >> K;
  vector<int> t(N);
  for(int i = 0; i < N; i++) cin >> t.at(i);
  //到着順に並び替える
  sort(t.begin(),t.end());
  int c_bus = 0;
  int passenger = 0;
  int depart_time = 0;
  for(int i = 0; i < N; i++){
    if(t.at(i) <= depart_time && passenger < C){
      passenger++;
      continue;
    }
    if(t.at(i) > depart_time || passenger == C){
      c_bus++;
      depart_time = t.at(i) + K;
      passenger = 1;
    }
  }
  cout << c_bus << endl;
  
}

Measured memory_bytes: 640
// A - Table Tennis Training
#include <bits/stdc++.h>

using namespace std;

int main(int argc, char *argv[])
{
	long long n, a, b, ans = 0;
	cin >> n >> a >> b;
	if ((b - a) % 2 == 0) {
		ans = (b - a) / 2;
	} else {
		ans = min(a, n - b + 1) + (b - a - 1) / 2;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int m = sc.nextInt();
        int mod = 1_000_000_007;
        
        //
        ArrayList<Integer> b = new ArrayList<>();
        int tmp = m;
        for(int i=2; i*i<=m; i++){
            if(tmp%i==0){
                int cnt = 0;
                while(tmp%i==0){
                    cnt++;
                    tmp /= i;
                }
                b.add(cnt);
            }
        }
        if(tmp!=1)b.add(1);
        
        Mod_nCr mn = new Mod_nCr(mod, 200000);
        
        long ans = 1;
        for(int cnt : b){
            //System.out.println("cnt : "+cnt);
            long res = mn.nCr(n+cnt-1, cnt);
            ans *= res;
            ans %= mod;
        }
        
        System.out.println(ans);
        
    }
}

class Mod_nCr{
    int mod;
    long[] fact;
    long[] rfact;
    
    public Mod_nCr(int mod, int max){
        this.mod = mod;
        fact = new long[max];
        rfact = new long[max];
        
        fact[0] = 1;
        rfact[0] = 1;
        
        for(int i=1; i<max; i++){
            fact[i] = (fact[i-1]*i)%mod;
            rfact[i] = mod_inverse(fact[i], mod);
        }
    }
    
    //
    private long mod_pow(long x, long p, long m){
        long a = 1;
        while(p>0){
            if(p%2==1){
                a = a*x%m;
            }
            x = x*x%m;
            p /= 2;
        }
        return a;
    }
    
    private long mod_inverse(long a, long m){
        return mod_pow(a, m-2, m);
    }
    
    //
    public long nCr(int n, int r){
        return fact[n]*rfact[r]%mod * rfact[n-r]%mod;
    }
}



Measured memory_bytes: 27860
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 2000 + 10;
int N, M;
char A[MAXN][MAXN];

int main() {
	register int i, j;
	scanf("%d%d", &N, &M);
	for(i = 1; i <= N; ++i)
		scanf("%s", A[i] + 1);
	for(i = 1; i <= N; ++i)
		for(j = 1; j <= M; ++j) {
			if(A[i][j] == '#' && A[i][j + 1] == '#' && A[i + 1][j] == '#') return puts("Impossible"), 0;
			if(A[i][j] == '#' && A[i - 1][j] == '#' && A[i][j - 1] == '#') return puts("Impossible"), 0;
		}
	puts("Possible");
	return 0;
}

Measured memory_bytes: 128
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int a,b; cin >> a >> b;
	if(b>=a){
		printf("unsafe\n");
	}else{
		printf("safe\n");
	}
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const double INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

template<typename T> T add(T x, T y){ if(abs(x+y) < EPS*(abs(x)+abs(y))) return 0; return x + y; }
template<typename T> inline bool semieq(T x, T y){ return abs(x - y) < EPS; }
template<typename T> inline bool semige(T x, T y){ return y - x < -EPS; }
template<typename T> inline bool semile(T x, T y){ return x - y < -EPS; }

const int MAX_N = 10;
const int n = MAX_N;
double x[MAX_N+1];
double v[2];

int main()
{
  while(~scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &x[0], &x[1], &x[2], &x[3], &x[4], &x[5], &x[6], &x[7], &x[8], &x[9], &v[0], &v[1])){
    double len = 0.0;
    rep(i, n) len += x[i];
    double left  = 0.0;
    double right = INF;
    double t;
    while(semile(left, right)){
      t = (left + right) / 2.0;
      if((v[0] + v[1]) * t > len) right = t;
      else left = t;
    }
    rep(i, n-1) x[i+1] += x[i];
    cout << upper_bound(x, x+n, v[0] * t) - x + 1<< endl;
  }

  return 0;
}

Measured memory_bytes: 1228
#include<stdio.h>
#include<string.h>
char s[100000];
int main(){
	int n;
	scanf("%d",&n);
	scanf("%s",&s);
	int length=strlen(s);
	for(int i=0;i<length;i++){
		if(s[i]+n>'Z'){
			s[i]=s[i]-(26-n);
		}else{
			s[i]+=n;
		}
		
	}
	printf("%s",s);
}

Measured memory_bytes: 1676
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

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

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

template<class T> bool chmin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool chmax(T &a, T b) { return a < b ? (a = b, true) : false; }



int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	int p[n];
	forn(i, n)cin >> p[i];
	int ans = 0;
	for1(i, n - 2){
		if(p[i] > p[i - 1] && p[i] < p[i + 1])ans++;
		if(p[i] < p[i - 1] && p[i] > p[i + 1])ans++;
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
// /*
// power code taken from geeks for geeks
// */
// cout << setprecision (2) << fixed << 1.2;

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;

const ll INF = 1e18 + 5;
const ll MAX_N = 1e6 + 5;
const ll MODD = 1e9 + 7;

ll max(ll a,ll b){return a>b?a:b;}
ll min(ll a,ll b){return a<b?a:b;}
double max(double a,double b){return a>b?a:b;}
double min(double a,double b){return a<b?a:b;}

ll modd(ll a){if(a<0LL) return a*-1LL;return a;}
double modd(double a){if(a<0.0) return a*-1.0;return a;}

ll modulo(ll a){return (a + MODD) % MODD; }

ll power(ll k, ll p){
    if (p == 0)
        return 1LL;
 
    ll P = power(k, p/2LL);
    P = (P * P) % MODD;
 
    if (p % 2 == 1)
        P = (P * k) % MODD;
 
    return P;
}



struct p_str {
    ll a, b;
};


void solve() {
    ll n;
    cin >> n;
    ll a[n];
    for(ll i = 0; i < n; i++) {
        cin >> a[i];
    }

    
    ll cnt[MAX_N];
    memset(cnt, 0, sizeof(cnt));

    
    for(ll i = 0; i < n; i++) {
        ll no = a[i];
        for(ll j = 2; j * j <= no; j++) {
            bool f = 0;
            while(no % j == 0) {
                no /= j;
                f = 1;
            }
            if(f) {
                cnt[j]++;
            }
        }
        if(no > 1) {
            cnt[no]++;
        }
    }

    // cout << "here " << endl;

    bool f = 1;
    for(ll i = 2; i < MAX_N; i++) {
        if(cnt[i] > 1) {
            f = 0;
            break;
        }
    }
    if(f) {
        cout << "pairwise coprime\n";
        return;
    }

    ll g = a[0];
    for(ll i = 1; i < n; i++) {
        g = __gcd(g, a[i]);
    }
    if(g == 1) {
        cout << "setwise coprime\n";
    }
    else {
        cout << "not coprime\n";
    }

}


int main(){


  

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    



    ll t=1;


    // cin>>t;
    


    while(t--){

        solve();
    }
    return 0;
}

Measured memory_bytes: 19252
#include<stdio.h>
int main(void)
{
	float a,s,d,f,g;
	while(scanf("%f",&a)!=EOF){
		if(a>91.00){
			printf("heavy\n");
		}
		else if(a>81){
			printf("light heavy\n");
		}
		else if(a>75){
			printf("middle\n");
		}
		else if(a>69){
			printf("light middle\n");
		}
		else if(a>64){
			printf("welter\n");
		}
		else if(a>60){
			printf("light welter\n");
		}
		else if(a>57){
			printf("light\n");
		}
		else if(a>54){
			printf("feather\n");
		}
		else if(a>51){
			printf("bantam\n");
		}
		else if(a>48){
			printf("fly\n");
		}
		else{
			printf("light fly\n");
		}
	}
	return 0;
}

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

int main(){

    int n;
    string s;
    cin >> n >> s;
    s = 'o' + s;
    for(int i = 1; i <= n; i++){
        if(s[i] == 'x'){
            if(s[i - 1] == 'x'){
                cout << i - 1 << endl;
                return 0;
            }
        } 
    }
    cout << n << endl;

    return 0;
}


Measured memory_bytes: 3368
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}


int main(){
  ll N; scanf("%lld", &N);
  ll ans = 0;
  for (ll i = 1; i <= N; i++){
    ll cnt = N / i;
    ans += i * cnt * (cnt + 1) / 2;
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 3824
import java.util.*;

public class Main{
	public static void main(String args[]) {
		Scanner input  = new Scanner(System.in);
		int n = input.nextInt();
		int arr[][] = new int[n][3];
		for(int i=0;i<n;i++) {
			int a = input.nextInt();
			int b = input.nextInt();
			int c = input.nextInt();
			arr[i] = new int[]{a,b,c};
		}
		System.out.println(func_dp(arr,n));
	}
	static int func_dp(int arr[][],int n) {
		int dp[][] = new int[n][3];
		dp[0][0] = Math.max(arr[0][1], arr[0][2]);
		dp[0][1] = Math.max(arr[0][0], arr[0][2]);
		dp[0][2] = Math.max(arr[0][1], arr[0][0]);
		for(int i=1;i<n;i++) {
			dp[i][0] = Math.max(dp[i-1][1], dp[i-1][2])+arr[i][0];
			dp[i][1] = Math.max(dp[i-1][0], dp[i-1][2])+arr[i][1];
			dp[i][2] = Math.max(dp[i-1][1], dp[i-1][0])+arr[i][2];
		}
		return (Math.max(dp[n-1][0], Math.max(dp[n-1][1], dp[n-1][2])));
	}
}


Measured memory_bytes: 100116
let read_lines () =
  let rec iter xs =
    try read_line() :: xs |> iter
    with End_of_file -> xs
  in iter [] |> List.rev

let split_nums str =
  Str.split (Str.regexp " ") str
  |> List.map int_of_string

let print_array a =
  let n = Array.length a in
  for i = 0 to n - 2 do
    Printf.printf "%d " a.(i)
  done;
  Printf.printf "%d\n" a.(n-1)

let insertion_sort lst =
  let array = Array.of_list lst in
  let n = Array.length array in
  for i = 1 to n - 1 do
    print_array array;
    let v = array.(i) in
    let j = ref (i - 1) in
    while !j >= 0 && array.(!j) > v do
      array.(!j+1) <- array.(!j);
      j := !j - 1;
    done;
    array.(!j+1) <- v;
  done;
  print_array array


let print_answer (x, y) =
  let fmt x =
    let s = Printf.sprintf "%.3f" x in
    if s = "-0.000" then "0.000"
    else s
  in
  Printf.printf "%s %s\n" (fmt x) (fmt y)

let () =
  let _ = read_int () in
  read_line ()
  |> split_nums
  |> insertion_sort

Measured memory_bytes: 4088
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X, Y = MAP()

for i in range(0, X+1):
    kame = i
    ru = X - kame
    if kame * 4 + ru * 2 == Y:
        print("Yes")
        exit()
print("No")    

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

#define F first
#define S second

#define debug(x) cerr << #x << " : " << x << endl;

#define _all(x) x.begin(), x.end()
#define _sz(x) ((int)x.size())

typedef long long ll;


// code //


void solve() {
	
	
}

int main() {
	string n;
	cin >> n;
	int sum;
	for(int i=0; i<_sz(n); ++i) {
		sum += n[i]-48;
		sum %= 9;
	}
	
	cout << (!sum ? "Yes" : "No");
	
}


Measured memory_bytes: 3748
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<string>
#include<functional>
using namespace std;
typedef	long long int ll;

int main(){
    double rtn;
    double n, m, d;
    cin >> n >> m >> d;
    if(d != 0)rtn = 2.0*(n-d)*(m-1.0)/(n*n);
    else rtn = (n-d)*(m-1.0)/(n*n);
    printf("%.10lf\n", rtn);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int c[4005][4005];

int lcs(string s, string s2) {
	int m = s.size();
	int n = s2.size();
	int ret = 0;

	memset(c, 0, sizeof(c));
	s = ' ' + s;
	s2 = ' ' + s2;

	REP(i,1,m+1) c[i][0] = 0;
	REP(j,1,n+1) c[0][j] = 0;

	REP(i,1,m+1) {
		REP(j,1,n+1) {
			if(s[i] == s2[j]) c[i][j] = c[i-1][j-1] + 1;
			ret = max(ret,c[i][j]);
	    }
    }

	return ret;
}

int main() {
	string a, b;
	while(cin >> a >> b) {
		cout << lcs(a, b) << endl;
	}
	return 0;
}

Measured memory_bytes: 63884
#include <iostream>
#include <cmath>

using namespace std;

int main(void){
	int debt = 100000;
	float const rate = 0.05;
	int term = 0;
	cin >> term;
	for (int i=0; i<term; ++i){
		float tmp = debt * (1 + rate) / 1000;
		debt = (int)(ceil(tmp) * 1000);
	}
	cout << debt << endl;
	return 0;
}

Measured memory_bytes: 1164
N,C,K=map(int,input().split())
cus=[None]*N
for i in range(N):
  t=int(input())
  cus[i]=[t,t+K]
cus=sorted(cus,key=lambda x:x[1])

last=-1
ans=0
rest=0
for i in range(N):
  if rest==0 or last<cus[i][0]:
    last=cus[i][1]
    ans+=1
    rest=C-1
  elif rest>0:
    rest-=1
print(ans)


Measured memory_bytes: 22104
c = []
for i in range(3):
    ci = list(map(int, input().split()) )
    c.append(ci)

found = False

for a1 in range(c[0][0]+1):
    b1 = c[0][0] - a1
    b2 = c[0][1] - a1
    b3 = c[0][2] - a1
    a2 = c[1][0] - b1
    a3 = c[2][0] - b1

    c22 = a2 + b2
    c23 = a2 + b3
    c32 = a3 + b2
    c33 = a3 + b3

    if c22 == c[1][1] and c23 == c[1][2] and c32 == c[2][1] and c33 == c[2][2]:
        found = True
        break

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

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

#define ll long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (ll)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 500005

int main(){
sp;
int n,x;
cin>>n;
ll sum=0;
ll a[n];
for(int i=1; i<=n; ++i){
    cin>>a[i];
    sum+=a[i];
}
sort(a+1,a+n+1);
    if(sum-a[n]<=a[n])cout<<"No";
     else cout<<"Yes";
return 0;}


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

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

int main() {
    int K;
    cin >> K;
    long long res = 0;
    for (int i = 1; i<=K; i++) {
        for (int j = 1; j<=K; j++) {
            for (int z = 1; z<=K; z++) {
                res += gcd(i, gcd(j, z));
            }
        }
    }
    cout << res << endl;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	ll a; double _b;
	read(a, _b);
	ll b = round(_b * 100);
	die(a*b/100);
}


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

int m,f,r;


int main(){
    while(1){
        cin>>m>>f>>r;
        if(m==-1 && f==-1 && r==-1)break;
        if(m==-1 || f==-1){
            cout<<"F"<<endl;
        }
        else if(m+f>=80){
            cout<<"A"<<endl;
        }
        else if(65<=m+f && m+f<80){
            cout<<"B"<<endl;
        }
        else if(50<=m+f && m+f<65){
            cout<<"C"<<endl;
        }
        else if(30<=m+f && m+f<50){
            if(r>=50){
                cout<<"C"<<endl;
            }
            else cout<<"D"<<endl;
        }
        else{
            cout<<"F"<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3084
import math

number_list = [int(i) for i in input().split()]

even_counter = 0

for i in number_list:
        if i % 2 == 0:
                even_counter = even_counter + 1

def even_checker(n_list):
        for i in n_list:
                if i % 2 == 0:
                        return i

def odd_checker(n_list):
        for i in n_list:
                if i % 2 == 1:
                        return i

if even_counter == 3 or even_counter == 0:
        goal = max(number_list)
        number_list.remove(goal)
        bigger = max(number_list)
        smaller = min(number_list)
        first_count = 0
else:
        if even_counter == 2:
                alone = odd_checker(number_list)
        elif even_counter == 1:
                alone = even_checker(number_list)
        number_list.remove(alone)
        bigger = max(number_list)
        smaller = min(number_list)
        if bigger > alone:
                first_count = math.ceil((bigger - alone)/2)
                goal = alone + first_count * 2
        else:
                first_count = 0
                goal = alone

second_count = goal - bigger
third_count = int((goal - (smaller + second_count))/2)

print(first_count+second_count+third_count)


Measured memory_bytes: 3064
import math

a,b,C = (int(x) for x in input().split())

S = a * b * math.sin(math.radians(C)) / 2
L = math.sqrt(a ** 2 + b ** 2 - 2  * a * b * math.cos(math.radians(C))) + a + b
h = b * math.sin(math.radians(C))

print(round(S, 8), round(L, 8), round(h, 8))


Measured memory_bytes: 5728
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int X = sc.nextInt();
        int Y = sc.nextInt();
        int Z = sc.nextInt();
        int sum = Z;

        for(int i=1; i<=100000; i++){
            sum += Y + Z;
            if(sum>X){
                System.out.println(i-1);
                break;
            }
            else if(sum==X){
                System.out.println(i);
                break;
            }
        }
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main() 
{
  long x,n,m,sum=0;
  cin>>n>>m;
  for(long i=0;i<m;i++)
  {
  	cin>>x;
  	sum+=x;
  }
  if(sum>n)
  cout<<"-1\n";
  else
  cout<<n-sum<<"\n";
}

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

int main(){
	int n,k;
	cin>>n>>k;
	k--;
	int h[n];
	for(int i=0;i<n;i++) cin>>h[i];
	sort(h,h+n);
	int m=h[n-1]-h[0];
	for(int i=0;i<n-k;i++){
		m=min(m,h[i+k]-h[i]);
	}
	cout<<m;
	return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)


int main() {
	cin.sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	int t[50][50] = {};
	int a, b;
	rep(i, M) {
		cin >> a >> b;
		t[a-1][b-1]++;
		t[b-1][a-1]++;
	}
	rep(i, N) {
		int count = 0;
		rep(j, N) {
			if (t[i][j]) {
				count+=t[i][j];
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int inf=1e9;
struct edge{
	int k,w,next;
}e[1000005];
int n,m,home[205],cnt=-1,T;
char a[105][105];
void add(int x,int y,int w){
	cnt++;
	e[cnt].k=y;
	e[cnt].w=w;
	e[cnt].next=home[x];
	home[x]=cnt;
}
void insert(int x,int y,int w){
	add(x,y,w);add(y,x,0);
}
int q[205],d[205];
void bfs(){
	memset(d,-1,sizeof(d));
	d[0]=0;
	int tou=0,wei=1,k;
	q[0]=0;
	while(tou<wei){
		k=q[tou++];
		for(int i=home[k];~i;i=e[i].next) if(e[i].w&&d[e[i].k]==-1){
			d[e[i].k]=d[k]+1;
			q[wei++]=e[i].k;
		}
	}
}
int h[205];
int dfs(int k,int flow){
	if(k==T||!flow) return flow;
	int used=0,w;
	for(int &i=home[k];~i;i=e[i].next)if(d[e[i].k]==d[k]+1){
		w=flow-used;
		w=dfs(e[i].k,min(w,e[i].w));
		used+=w;
		e[i].w-=w;
		e[i^1].w+=w;
	}
	if(used<flow) d[k]=-1;
	return used;
}
int dinic(){
	int flow=0;
	for(int i=0;i<=T;i++) h[i]=home[i];
	while(1){
		for(int i=0;i<=T;i++) home[i]=h[i];
		bfs();
		if(d[T]==-1) return flow>n*m?-1:flow;
		flow+=dfs(0,inf);
	}
}
int main(){
	memset(home,-1,sizeof(home));
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%s",a[i]+1);
	T=n+m+1;
	for(int i=1;i<=n;i++){
		for(int p=1;p<=m;p++){
			if(a[i][p]=='o'){
				add(i,p+n,1);
				add(p+n,i,1);
			}
			if(a[i][p]=='S'){
				insert(0,i,inf);
				insert(0,p+n,inf);
			}
			if(a[i][p]=='T'){
				insert(i,T,inf);
				insert(p+n,T,inf);
			}
		}
	}
	printf("%d",dinic());
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			String[] str = sc.nextLine().split("[\\s]");
			boolean flag = false;
			
			for(int i = 0; i < 26; i++){
				
				for(int j = 0; j < str.length; j++){
					char[] c = str[j].toCharArray();
					
					for(int k = 0; k < c.length; k++){
						if(Character.isLowerCase(c[k])){
							if(c[k] == 'z')
								c[k] = 'a';
							else
								c[k] = (char)(c[k] + 1);
						}
					}
					str[j] = new String(c);
					if(str[j].equals("this") || str[j].equals("the") || str[j].equals("that"))
						flag = true;
				}
				if(flag)
					break;
			}
			int i = 0;
			for(String tmp:str){
				System.out.print(tmp);
				if(i == (str.length) - 1)
					break;
				System.out.print(" ");
				i++;
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 17220
n,m=map(int,input().split())
li=[]
for i in range(m):
  dk,*d=list(map(int,input().split()))
  li.append(d)
p=list(map(int,input().split()))
ans=0
for i in range(2**n):
  sw=bin(i)[2:].zfill(n)
  for j in range(m):
    cnt=0
    for k in li[j]:
      if sw[k-1]=='1':
        cnt+=1
    if cnt%2!=p[j]:
      break
  else:ans+=1
print(ans)

Measured memory_bytes: 74064
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner in = new Scanner(System.in);
        int a = in.nextInt(), b = in.nextInt(), c = in.nextInt(), d = in.nextInt();
        while (a > 0 && d > 0) {
            c = c - b;
            if (c <= 0) {
                System.out.println("Yes");
                break;
            }
            a = a - d;
            if (a <= 0) {
                System.out.println("No");
                break;
            }
        }
    }

}


Measured memory_bytes: 27036
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n;
  cin>>n;
  string event;
  getline(cin,event,'\n');
  int i=0,out,b,score;
  while(n>0){
    out = 0;
    b = 0;
    score=0;
    while(out<3){
      getline(cin,event,'\n');
      if(event=="HIT"){
	b*=2;
	b+=1;
	if(b>8){
	  b-=8;
	  score++;
	}
      }
      if(event=="HOMERUN"){
	while(b>0){
	  score+=b%2;
	  b/=2;
	}
	score++;
      }
      if(event=="OUT"){
	out++;
      }
    }
    cout<<score<<endl;
    n--;
  }
  return 0;
}

Measured memory_bytes: 0
import bisect
import collections
import itertools


def getint(): return int(input())
def getints(): return list(map(int, input().split()))
def getint2d(rows): return [getints() for _ in range(rows)]
def getgrid(rows): return [input() for _ in range(rows)]
def array1d(n, value): return [value for _ in range(n)]
def array2d(n, m, value): return [array1d(m, value) for _ in range(n)]


def partial_sum(xs):
    if not xs:
        return [0]
    ys = [0, xs[0][1]]
    for i in range(1, len(xs)):
        xs[i][1] += xs[i-1][1]
        ys.append(xs[i][1])
    return ys

n,w=getints()
items=getint2d(n)
w0 = items[0][0]
kind0=list(sorted(filter(lambda s: s[0] == w0,     items), reverse=True))
kind1=list(sorted(filter(lambda s: s[0] == w0 + 1, items), reverse=True))
kind2=list(sorted(filter(lambda s: s[0] == w0 + 2, items), reverse=True))
kind3=list(sorted(filter(lambda s: s[0] == w0 + 3, items), reverse=True))

kind0 = partial_sum(kind0)
kind1 = partial_sum(kind1)
kind2 = partial_sum(kind2)
kind3 = partial_sum(kind3)



res = 0

for n0 in range(len(kind0)):
    for n1 in range(len(kind1)):
        for n2 in range(len(kind2)):
            for n3 in range(len(kind3)):
                weight = n0*w0 + n1*(w0+1) + n2*(w0+2) + n3*(w0+3)
                if weight > w: continue
                tmp = kind0[n0] + kind1[n1] + kind2[n2] + kind3[n3]
                res = max(res, tmp)

print(res)


Measured memory_bytes: 42732
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  while(cin>>N,N) {
    int t[N+1][N+1];
    FOR(i,1,N+1) FOR(j,0,N+1) cin >> t[i][j];
    int dp[1<<N]; FOR(i,0,1<<N) dp[i] = 1e9;
    dp[0] = 0;
    FOR(i,1,1<<N) {
      // j+1????????????????????\
      FOR(j,0,N) {
        if((i>>j)&1) {
          // k?????????????????¢?????????????????£???
          FOR(k,0,N) {
            dp[i] = min(dp[i], dp[i^(1<<j)] + t[j+1][0]); // ?£???????????????´???
            if(k != j && (i>>k)&1) {
              dp[i] = min(dp[i], dp[i^(1<<j)] + t[j+1][k+1]);
            }
          }
        }
      }
    }
    cout << dp[(1<<N)-1] << endl;
  }
  return 0;
}

Measured memory_bytes: 3380
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k,n;scanf("%d%d",&k,&n);
    int a[n],b[n];
    for(int i=0;i<n;i++)scanf("%d",&a[i]);
    for(int i=0;i<n-1;i++)b[i]=a[i+1]-a[i];
    b[n-1]=a[0]+k-a[n-1];
    sort(b,b+n);
    printf("%d\n",k-b[n-1]);
    return 0;
}

Measured memory_bytes: 1792
//shara's here
//私は大きな男の子
//SPEEEEEEEEEED IS KEEEEEEEEEEY
//REEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEAAAAAAAAAAAAAAAAAAAADDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
#include <bits/stdc++.h>
using namespace std;
//fold
typedef string s;
typedef long long ll;
typedef long double ld;
const ll INF = 1e18 + 10;
const ll MINF = -(1e18 + 10);
#if defined(BANYANYA)
#include "/home/xsharawi/Desktop/cpp/debug.hpp"
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
#define pb push_back
#define vl vector<ll>
#define vll vector<vector<ll> >
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
//endfold
int main(){
    ll x,ans=0;
    cin>>x;
    for(ll i=0;i*i<=x;i++){
	ans=i*i;	
	}
	cout<<ans<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/


Measured memory_bytes: 384
#include<iostream>
#include<map>
using namespace std;
int main()
{
int k,n;
cin>>k>>n;
int arr[n],ans1(0),ans2(0);
map<int,int>vis;
for(int i=0; i<n; ++i)
{
cin>>arr[i];
vis[arr[i]]=1;
}
for(int i=k; ; --i)
{
if(!vis[i])
{
ans1=i;
break;
}
}
for(int i=k; ; ++i)
{
if(!vis[i])
{
ans2=i;
break;
}
}
if(abs(k-ans1)>abs(k-ans2))
cout<<ans2;
else
cout<<ans1;
}


Measured memory_bytes: 3204
#include <bits/stdc++.h> 
using namespace std; 
const int MAX_N = 2e5 + 5;
int n, a[3];
char s[MAX_N][10];
int ans[MAX_N]; 
int main() {
	scanf("%d", &n); 
	for (int i = 0; i < 3; i++) scanf("%d", a + i); 
    bool flag = 0; 
    for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
    for (int i = 1; i <= n; i++) {
        int x = s[i][1] - 'A', y = s[i][2] - 'A';
        if (a[x] < a[y]) a[x]++, a[y]--, ans[i] = x;
        else if (a[y] < a[x]) a[x]--, a[y]++, ans[i] = y; 
        else { 
            if (a[x] == 1 && !a[3 - x - y]) { 
                if (i == n || (s[i + 1][1] != 3 - x - y + 'A' && s[i + 1][2] != 3 - x - y + 'A')) { 
                    a[x]--, a[y]++, ans[i] = y; 
                } else {
                    int x1 = s[i + 1][1] - 'A', x2 = s[i + 1][2] - 'A';
                    if (x1 == x || x2 == x) ans[i] = x, a[x]++, a[y]--;
				    else ans[i] = y, a[x]--, a[y]++;
				}
			}
			else a[x]--, a[y]++, ans[i] = y; 
		} 
		if (a[x] < 0 || a[y] < 0) { flag = 1; break; }
    } 
	if (!flag) { 
		puts("Yes"); 
		for (int i = 1; i <= n; i++) printf("%c\n", ans[i] + 'A'); 
	} else puts("No"); 
	return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> a(3*n);
	rep(i,3*n) cin >> a[i];
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	ll sum = 0;
	for(int i = 1; i <=2*n; i+=2){
		sum += a[i];
	}
	cout << sum << endl;
}

Measured memory_bytes: 4576
import sys
sys.setrecursionlimit(100000)

n,m=map(int,input().split())
f=lambda x:int(x)-1

langs=[[] for _ in range(m)]
speakers=[[] for _ in range(n)]
used_langs=[False]*m
used_speakers=[False]*n

for i in range(n):
  *l,=map(f,input().split()[1:])
  speakers[i].extend(l)
  for j in l:
    langs[j].append(i)

def dfs(n):
  if used_speakers[n]:
    return
  used_speakers[n]=True
  for i in speakers[n]:
    if used_langs[i]:continue
    used_langs[i]=True
    for j in langs[i]:
      dfs(j)

dfs(0)
if not False in used_speakers:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 36812
#include<bits/stdc++.h>
using namespace std;
int main(){
 	int k,i,j,l;
  	cin>>l;
  	int ans = 0;
  	for(i=1;i<=l;++i)
      	for(j=1;j<=l;++j)
          	for(k=1;k<=l;++k)
				ans += __gcd(__gcd(i,j),k);
  	cout<<ans<<"\n";
}			


Measured memory_bytes: 3624
n, m = [int(w) for w in input().split()]

lb = [False] * n
lb[0] = True
lbn = [1] * n

for i in range(m):
    x, y = [int(w)-1 for w in input().split()]
    if lb[x] and lbn[x] > 0:
        lb[y] = True
    lbn[x] -= 1
    lbn[y] += 1

    if lb[x] and lbn[x] == 0:
        lb[x] = False

print(len([_ for _ in lb if _]))


Measured memory_bytes: 11156
#include <iostream>
#include <bits/stdc++.h>
#define PB push_back
#define INF 1e9+5;
#define F(i,a,b)  for(i=a;i<b;i++)
#define FE(i,a,b)  for(i=a;i<=b;i++)
#define FR(i,a,b) for(i=a;i>b;i--)
#define LL long long
#define MAX(a,b) (a<b?b:a)
#define ABS(x) (x<0?(-x):x)
#define ALL(c) (c).begin(),(c).end()
#define WATCH(x) cout << (#x) << " is " << (x) << endl
#define vi vector<int>
#define vs vector<string>
#define d0(x) cout<<(x)<<" "
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define d6(a,b,c,d,e,f) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<" "<<(f)<<endl
using namespace std;
string ConvertToBin(LL s)
{
    string res = "";
    while(s != 0) {
        res += (char)('0' + s % 2);
        s /= 2;
    }
    reverse(res.begin() , res.end());
    return res;
}

void PrintVec(vector<int> &v)
{
    for(vector<int>::iterator it = v.begin() ; it != v.end(); ++it)
    cout<<*it<<" ";
}

vector<int> Populate(vector<int> &v,int n)
{
    int num;
    for(int i=0;i<n;i++)
    {
        cin>>num;
        v.push_back(num);
    }
    return(v);
}

int sumofdigits(int n)
{
    int sm=0;
    while(n)
    {
        sm=sm+(n-(n/10)*10);
         n=n/10;
    }
    return(sm);
}

bool isprime(int n)
{
    int i=0;
    FE(i,2,sqrt(n))
    {
        if(n%i==0)
        return(false);
    }
    return(true);
}

long long dp[100001][101];
long long fun(long long price[],long long weight[],long long w,long long n)
{
    if(w<0 || n<0)
    return(0);
    if(dp[w][n])
    return(dp[w][n]);
    if(weight[n]>w)
    {
    dp[w][n]=(fun(price,weight,w,n-1));
    return(dp[w][n]);
    }
    else
    {
    dp[w][n]=(max(price[n]+fun(price,weight,w-weight[n],n-1),fun(price,weight,w,n-1)));
    return(dp[w][n]);
    }

}



/*--------------------------time to code-------------------------------*/



int main()
{
    int n,w;
    cin>>n>>w;
    long long  price[n];
    long long weight[n];
    long long pr,wei;
    for(int i=0;i<n;i++)
    {
        cin>>wei>>pr;
        price[i]=pr;
        weight[i]=wei;
    }
    memset(dp,0,sizeof(dp));
    cout<<(fun(price,weight,w,n-1))<<endl;
    return(0);
}









Measured memory_bytes: 79104
S = input()

dreamdeleted=False

while len(S) > 0:
    if dreamdeleted == True:
        if S[0:6] == 'eraser':
            S = S[6:len(S)]
            dreamdeleted=False
            continue
        if S[0:5] == 'erase':
            S = S[5:len(S)]
            dreamdeleted=False
            continue
        if S[0:2] == 'er':
            S = S[2:len(S)]
            dreamdeleted=False
            continue
    if S[0:6] == 'eraser':
        S = S[6:len(S)]
        continue
    if S[0:5] == 'dream':
        S = S[5:len(S)]
        dreamdeleted = True
        continue
    if S[0:5] == 'erase':
        S=S[5:len(S)]
        continue
    print('NO')
    break
if len(S) == 0:
    print ('YES')


Measured memory_bytes: 3316
function main(lines) {
  const S = lines[0];
  const T = lines[1];

  const len = S.length;
  let res = 0;
  if (S !== T) {
    for (let i = 0; i < len; i++) {
      if (S[i] !== T[i]) res++;
    }
  }
  
  console.log(res);
}


main( require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n") );



function splitN(s) {
  return s.split(' ').map(Number);
}

Measured memory_bytes: 32896