akhauriyash/Code-Regression huggingface dataset:
n = int(input())
a = []
for i in range(n):
    m = int(input())
    a.append([])
    for i in range(m):
        a[-1].append(list(map(int,input().split())))

ans = 0
for i in range(2**n):
    s = bin(i)[2:].zfill(n)
    f = True
    for j,k in enumerate(a):
        for x,y in k:
            #仮定で正直者なのに証言に矛盾が生じている場合
            if s[x-1] != str(y) and s[j] == '1': f = False
    if f: ans = max(ans, s.count('1'))

print(ans)





Measured memory_bytes: 68792
#include<stdio.h>
#include<string>
#define LEN 100005

typedef struct pp{
    char name[100];
    int t;
}Pr;

Pr Q[LEN];
int head,tail,n;

void enqueue(Pr x){
    Q[tail] = x;
    tail = (tail+1)%LEN;
}

Pr dequeue(){
    Pr x = Q[head];
    head = (head+1)%LEN;
    return x;
}

int min(int a,int b){
    return a < b ? a:b; 
}

int main(){
    int elaps = 0,c;
    int q;
    Pr u;
    scanf("%d %d",&n,&q);

    for(int i = 0; i< n; i++){
        scanf("%s",Q[i].name);
        scanf("%d", &Q[i].t);
    }
    head = 0;
    tail = n;

    while(head != tail){
        u = dequeue();
        c = min(q,u.t);
        u.t -= c;
        elaps += c;
        if(u.t > 0){
            enqueue(u);
        }else{
            printf("%s %d\n",u.name,elaps);
        }
    }
    return 0;
}



Measured memory_bytes: 12740
n = int(input())
s = [input() for i in range(n)]

li = [0]*4

for i in range(n):
    if s[i] == 'AC':
        li[0] += 1
    elif s[i] == 'WA':
        li[1] += 1
    elif s[i] == 'TLE':
        li[2] += 1
    elif s[i] == 'RE':
        li[3] += 1
        
print('AC x '+str(li[0]))
print('WA x '+str(li[1]))
print('TLE x '+str(li[2]))
print('RE x '+str(li[3]))

Measured memory_bytes: 16324
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#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)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int H,W;
char S[403][403] = {0};
int visited[403][403] = {0};
LL black = 0;
LL white = 0;
int dir[4][2] = {{1,0},{-1,0},{0,1},{0,-1}};

void f(int i, int j, char pre){
    if(!(0<=i && i<H && 0<=j && j<W))return;
    if(visited[i][j])return;
    char now = S[i][j];
    if(now == pre)return;
    visited[i][j] = 1;
    if(now == '#')black++;
    if(now == '.')white++;
    f(i+1, j, now);
    f(i-1, j, now);
    f(i, j+1, now);
    f(i, j-1, now);
}

void f2(int i, int j){
    if(visited[i][j])return;
    visited[i][j] = 1;
    char now = S[i][j];
    if(now == '#')black++;
    if(now == '.')white++;
    REP(k,4){
        int ni = i+dir[k][0];
        int nj = j+dir[k][1];
        if(!(0<=ni && ni<H && 0<=nj && nj<W))continue;
        if(now == S[ni][nj])continue;
        f2(ni, nj);
    }
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>H>>W;
    REP(i,H)REP(j,W)cin>>S[i][j];
    LL ans = 0;
    REP(i,H)REP(j,W){
        black = 0;
        white = 0;
        f(i, j, 'X');
        ans += black * white;
    }
    PUTS(ans);
}

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


int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];

    int sum = 0;
    double avg = 0;
    rep(i, N){
        sum += a[i];
    }
    avg = 1.0 * sum / N;

    int index = -1;
    double mini = INF;
    rep(i, N){
        if(mini > abs(a[i] - avg)){
            mini = abs(a[i] - avg);
            index = i;
        }
    }
    cout << index << endl;

}


Measured memory_bytes: 256
def main1():
    N=int(input())
    A=list(map(int,input().split()))
    A.sort()
    ans=[0]*(10**6+1)
    if N ==1 :
        print(1)
        return 
    for i in  range(len(A)):
        ans[A[i]]+=1
        if ans[A[i]]==1:
            for j in range(A[i]*2,10**6+1,A[i]):
                ans[j]=2
    print(ans.count(1))
main1()

Measured memory_bytes: 32240
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;

int main() {
    long long int n,a,b;
    cin >> n >> a >> b;
    long long int x,y;
    x = n/(a+b);
    y = n%(a+b);
    cout << a*x+std::min(y,a) << endl;
}



Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2511&lang=jp
// references : http://mayokoex.hatenablog.com/entry/2016/05/03/233156
typedef long long ll;
#define INF 1<<30
#define LINF 1LL<<60
#define MAXT 1000100
struct edge {
	int from;
	int to;
	int cost;
	edge() {}
	edge(int f, int t, int c) :from(f), to(t), cost(c) {}
	bool operator < (const edge& o) const { return cost < o.cost; }
};

struct UnionFind {
	vector<int> par;
	int n, cnt;
	UnionFind(const int& x = 0) { init(x); }
	void init(const int& x) { par.assign(cnt = n = x, -1); }
	inline int find(const int& x) { return par[x] < 0 ? x : par[x] = find(par[x]); }
	inline bool same(const int& x, const int& y) { return find(x) == find(y); }
	inline bool unite(int x, int y) {
		if ((x = find(x)) == (y = find(y))) return false;
		--cnt;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}
	inline int count() const { return cnt; }
	inline int count(int x) { return -par[find(x)]; }
};

vector<int> h[MAXT];
vector<edge> G;

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N, M;
	while (cin >> N >> M, N | M) {

		for (int t = 0; t < MAXT;t++)h[t].clear();
		for (int i = 0; i < N; i++) { int t; cin >> t; h[t].push_back(i); }
		G.clear();
		for (int i = 0; i < M;i++) {
			int a, b, c; cin >> a >> b >> c;
			a--;b--;
			G.push_back(edge(a, b, c));
		}
		sort(G.begin(), G.end());
		
		UnionFind uf(N);
		for (auto e : G) uf.unite(e.from, e.to);
		if (uf.count() > 1) { cout << 0 << endl; continue; }

		vector<int> f(N, 0);
		int cnt = 1;
		int last_t = -1;
		for (int t = 0; t < MAXT;t++) {
			if (h[t].size() == 0)continue;
			for (auto n : h[t]) { f[n] = 1; cnt++; }
			UnionFind uf(N);
			for (auto e : G) {
				if (f[e.from] == 1 || f[e.to] == 1)continue;
				uf.unite(e.from, e.to);
			}
			if (uf.count() != cnt) { last_t = t; break; }
		}
		if (last_t == -1)last_t = MAXT;

		uf = UnionFind(N);
		for (int i = 0; i < N;i++)f[i] = 0;
		ll ans = 0;
		for (int t = last_t; t < MAXT;t++)for (auto n : h[t]) f[n] = 1;
		/* Minimum spanning tree */
		for (auto e : G) {
			if (!(f[e.from] == 1 && f[e.to] == 1))continue;
			if (uf.same(e.from, e.to)) continue;
			ans += e.cost; uf.unite(e.from, e.to);
		}
		/*----------------------*/

		for (int t = last_t - 1; t >= 0;t--) {
			if (h[t].size() == 0)continue;
			for (auto n : h[t]) f[n] = 1;
			for (auto e : G) {
				if (!(f[e.from] == 1 && f[e.to] == 1))continue;
				if (uf.same(e.from, e.to)) continue;
				ans += e.cost; uf.unite(e.from, e.to);
			}
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 27036
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
#include<string.h>
#include <cmath>
#include <iomanip>
using namespace std;
#define inf 1000000007
#define int long long
#define rep(i,j,n) for(int i=j;i<n;i++)
typedef pair<int,int>  P;
struct edge{int from,to,cost;};
double pi = 3.141592653589793;
//使うやつはここから下に置こうな
int dp[114514][12]={};//点iから距離jのところが塗られている色
int c[114514],d[114541],V[114514];vector<int> v[114514];
bool solve(int a,int b,int c) {
    if(b<0)return false;
    if(dp[a][b]){
        return false;
    }
    dp[a][b]=c;
    for(int i=b-1;i>=0;i--){
        solve(a,i,c);
    }
    rep(i,0,v[a].size()){
        solve(v[a][i],b-1,c);
    }
    return true;
}
signed main(){
    int n,m;cin>>n>>m;
    rep(i,0,m){
        int a,b;cin>>a>>b;
        a--;b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    int q;cin>>q;
    
    rep(i,0,q){
        cin>>V[i]>>c[i]>>d[i];
    }
    reverse(V,V+q);reverse(c,c+q);reverse(d,d+q);
    rep(i,0,q){
        V[i]--;
        solve(V[i],c[i],d[i]);
    }
    rep(i,0,n){
        cout<<dp[i][0]<<endl;
    }
    return 0;
}

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

#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define FORR(i,a,b) for (int i = a; i > b; i--)
#define pi acos(-1.0)

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


int main(){
    int a, b, c;
    string ans;
    cin >> a >> b >> c;
    if(a + b == c || b + c == a || c + a == b){
        ans = "Yes";
    }else{
        ans = "No";
    }
    
    cout << ans << endl;
    return 0;
}










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

int main(void)
{
    int N, i;
    long long a[100001], b, zero;
    zero = 0;
    b = 1;
    cin >> N;
    for (i = 0; i < N; i++)
    {
        cin >> a[i];
        if (a[i] == 0)
            zero++;
    }
    if (zero > 0)
    {
        cout << "0\n";
        return 0;
    }
    for (i = 0; i < N; i++)
    {

        if (a[i] <= 1000000000000000000 / b)
        {
            b = b * a[i];
        }
        else
        {
            cout << "-1" << endl;
            return 0;
        }
    }
    cout << b << endl;
    return 0;
}


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

using namespace std;

using ll = long long;
const int mod = 1e9+7;
const int maxn = 1e5+7;
int a[maxn];
int n;
ll quick_pow(ll a, ll b){
	ll ret=1;
	while(b){
		if(b&1)ret=ret*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ret;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for(int i=1, x; i<=n; ++i){
		cin >> x;
		a[x]++;
	}
	if(a[0]>1){
		cout << 0<<"\n";
		return 0;
	}
	int num=0;
	for(int i=0; i<n; ++i){
		if(a[i]==2)num++;
		else if(a[i]>2){
			cout <<"0\n";
			return 0;
		}
	}
	num%=mod;
	cout << quick_pow(2, num)<<"\n";
}

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

using namespace std;
typedef long long ll;

string s1, s2;
short sz1, sz2;
short dp[3005][3005];

short solve(short i=0, short j=0) {
    if(i == sz1 || j == sz2) return 0;
    short& res = dp[i][j];
    if(~res) return res;
    res = solve(i+1, j);
    res = max(res, solve(i, j+1));
    if(s1[i] == s2[j])
        res = max(res, short(solve(i+1, j+1) + 1));
    return res;
}

void print(short i=0, short j=0) {
    if(i == sz1 || j == sz2) return;
    short& res = dp[i][j];

    if(res == solve(i+1, j)) { print(i+1, j); return; }
    if(res == solve(i, j+1)) { print(i, j+1); return; }
    if(s1[i] == s2[j]) {
        if(res == solve(i+1, j+1) + 1) {
            cout << s1[i];
            print(i+1, j+1);
            return;
        }
    }
    return;
}

int main()
{
    ios::sync_with_stdio(false);
    memset(dp, -1, sizeof(dp));
    cin >> s1 >> s2;
    sz1 = s1.size();
    sz2 = s2.size();
    solve();
    print(); cout << "\n";
    return 0;
}


Measured memory_bytes: 18432
#include <stdio.h>
#include <bitset>
#include <set>
using namespace std;
const int N=1000000;
int main(){
    int n,x,temp;
    bitset<N>b;
    set<int> prime;
    set<int>::iterator u;
    bool f;
    b.reset();
    prime.insert(2);
    for(long long int i=3;i<1000000;i+=2)if(!b[i]){
        prime.insert(static_cast<int>(i));
        for(long long int j=i*i;j<1000000;j+=i*2)b[j]=true;
    }
    while(true){
        scanf("%d%d",&n,&x);
        if(n==0&&x==0)return 0;
        b.reset();
        b[0]=true;
        u=prime.upper_bound(x);
        u--;
        while(n--){
            scanf("%d",&temp);
            while(temp<=x){
                if(b[*u])break;
                b|=b<<temp;
                temp<<=1;
            }
        }
        f=true;
        while(f&&u!=prime.begin()){
            if(b[*u]){
                f=false;
                printf("%d\n",*u);
            }
            u--;
        }
        if(f)printf("NA\n");
    }
}


Measured memory_bytes: 6868
import java.io.*;
import java.util.*;

public class Main {

    private  static void solver(InputReader sc, PrintWriter out) {
        int n= sc.nextInt();
        int k = sc.nextInt();
        int arr[] = new int[n];
        for(int i=0;i<n;i++){
            arr[i]= sc.nextInt();
        }
        int[] dp = new int[n];
        dp[0] = 0;
        dp[1] = Math.abs(arr[1]-arr[0]);
        for(int i=2;i<n;i++) {
            int min = Integer.MAX_VALUE;
            for (int j = i - 1; j >=(i-k) && j>=0; j--) {
                int mins = Math.abs(arr[i] - arr[j]) + dp[j];
                if(mins < min){
                    min = mins;
                }
            }
            dp[i] = min;
        }
        out.println(dp[n-1]);
    }
    public static void main(String[] args) throws Exception{
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        solver(in,out);
        out.close();
    }
    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong(){
            return Long.parseLong(next());
        }
        public void readLongArr(int n){
            long arr[] = new long[n];
            for(int i=0;i<n;i++){
                arr[i] = nextLong();
            }
        }
        public void readIntArr(int n){
            int arr[] = new int[n];
            for(int i=0; i<n; i++){
                arr[i] = nextInt();
            }
        }
    }
}

Measured memory_bytes: 33420
S = input()
alpha = [0] * 26
for s in S:
    alpha[ord(s) - 97] = 1

for i, value in enumerate(alpha):
    if value == 0:
        S = S + chr(i + 97)
        print(S)
        exit()

while len(S) > 1 or S[0] != 'z':
    idx = ord(S[-1]) - 97 + 1
    for i in range(idx, 26):
        if alpha[i] == 0:
            S = S[:-1] + chr(i + 97)
            print(S)
            exit()
    alpha[idx - 1] = 0
    S = S[:-1]

print(-1)


Measured memory_bytes: 9064
open System

// prelude
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

let read f () = readStr() |> f
let reads f () = readStr().Split() |> Array.map f

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let readPair f g () =
  let (a,b) = readStr().Split() |> pair
  (f a, g b)

let readTriple f g h () =
  let (a,b,c) = readStr().Split() |> triple
  (f a, g b, h c)

let inc n = n + 1
let dec n = n - 1

let inline flip f a b = f b a
let rec fix f = fun x -> (f (fix f)) x

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

module Array =
  let modify (arr: _ []) i f =
    arr.[i] <- f arr.[i]

module Array2D =
  let modify (arr: _ [,]) i j f =
    arr.[i, j] <- f arr.[i, j]

// start
let (N,M) = readPair int int ()
let A=reads int ()

let x = (N-(A |> Array.sum))
if x>=0 then x else -1
|> printfn "%d"

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

int p;
int a[3000];
int b[3000];
int lol[3000][3000] = {};
int fact[3000];
int ifact[3000];


int inv(int x){
    if (x == 1) return 1;
    int q = p / x, r = p % x;
    return (p*p - q*inv(r))%p;
}

int main(){
    cin >> p;
    for (int i = 0; i < p; i++) cin >> a[i];

    lol[0][0] = 1;
    fact[0] = 1;
    ifact[0] = 1;
    for (int i = 1; i < p; i++){
        fact[i] = (fact[i-1] * i) % p;
        ifact[i] = inv(fact[i]);
        for (int j = 1; j <= i; j++){
            lol[i][j] = (lol[i-1][j-1] - ((lol[i-1][j] * (i-1)) % p) + p) % p;
        }
    }
    int x, y;
    for (int i = 0; i < p; i++){
        x = 0;
        for (int j = 0; j < i; j++){
            y = (fact[i] * ifact[i-j]) % p;
            y = (y * b[j]) % p;
            x = (x + y) % p;
        }
        x = (a[i] + p - x) % p;
        x = (ifact[i] * x) % p;
        b[i] = x;
    }
    for (int i = 0; i < p; i++){
        int ans = 0;
        for (int j = i; j < p; j++) ans = (ans + b[j]*lol[j][i]) % p;
        cout << ans << ' ';
    }
    cout << '\n';
}


Measured memory_bytes: 34176
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


signed main()
{

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

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n;
    cin>>n;
    pair<int,int>p[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>p[i].first>>p[i].second;
    }
    sort(p+1,p+n+1);
    if(n%2)
    {
        vector<int>v;
        for(int i=1;i<=n;i++)
        {
            v.push_back(p[i].first);
        }
        sort(v.begin(),v.end());
        int x=v[n/2];
        v.clear();
        for(int i=1;i<=n;i++)
        {
            v.push_back(p[i].second);
        }
        sort(v.begin(),v.end());
        int y=v[n/2];
        cout<<y-x+1;
    }
    else
    {
        vector<int>v;
        for(int i=1;i<=n;i++)
        {
            v.push_back(p[i].first);
        }
        sort(v.begin(),v.end());
        int x=(v[n/2]+v[(n-1)/2]);
        v.clear();
        for(int i=1;i<=n;i++)
        {
            v.push_back(p[i].second);
        }
        sort(v.begin(),v.end());
        int y=(v[n/2]+v[(n-1)/2]);
        cout<<y-x+1;
        
    }
    
    
    
    
} 



Measured memory_bytes: 8460
import java.io.*
import java.util.*
import kotlin.math.*

fun main(){
	val f = BufferedReader(InputStreamReader(System.`in`))

	val (n,m) = f.readLine().split(" ").map{it.toInt()}
	val array = f.readLine().split(" ").map{it.toInt()}

	for(k in m until n){
		if(array[k] > array[k-m]) println("Yes")
		else println("No")
	}

	
}


Measured memory_bytes: 69124
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, a, b) for(int i = a, i##_len = (b); i < i##_len; ++i)

int main()
{
    string S;
    cin >> S;
    int res = 0;
    REP(i, 0, S.size()-1) if(S[i] != S[i+1]) ++res;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 512
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var n=Arr.shift()-0;
for(var i=0;i<n;i++){
   var arr=Arr[i].split(" ").map(Number);
   (function(xa, ya, ra, xb, yb, rb){
      var ans;
      var d=Math.sqrt(Math.pow(xa-xb,2)+Math.pow(ya-yb,2));
      if(d>ra+rb)ans=0;
      if(d<=ra+rb){
         ans=1;
         if(d<ra-rb)ans=2;
         if(d<rb-ra)ans=-2;
      }
      console.log(ans);
   }).apply(null,arr);
}

Measured memory_bytes: 7648
N = int(input())
H = list(map(int,input().split()))
dp = [float('inf') for i in range(N)]
#全ノードを取り敢えずinfにしておく
dp[0] = 0
for i in range(N-1):
    #足場を一個飛んだ時
    dp[i+1] = min(dp[i+1],dp[i] + abs(H[i+1] - H[i]))
    #足場を二個飛んだ時
    if i <= N-3:
        dp[i+2] = min(dp[i+2], dp[i] + abs(H[i + 2]-H[i]))
print(dp[N-1])

Measured memory_bytes: 53320
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < int(n); ++i)
#define REPE(i, a, b) for (int i = (a); i <= int(b); ++i)
using LL = long long;
typedef long long LL;

using cd = complex<double>;
cd s, t, a[1010];
double r[1010];

int n;
double d[1010][1010];

double dd[1010];
bool inq[1010];
double spfa(int s, int t) {
  fill(dd, dd + n, 1e15);
  dd[s] = 0;
  queue<int> q;
  q.push(s);
  while (q.size()) {
    int x = q.front(); q.pop(); inq[x] = false;
    REP(i, n) {
      if (dd[x] + d[x][i] < dd[i]) {
        dd[i] = dd[x] + d[x][i];
        if (!inq[i]) {
          inq[i] = true;
          q.push(i);
        }
      }
    }
  }
  return dd[t];
}

int main() {
  int x1, y1, x2, y2;
  scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
  s = cd(x1, y1);
  t = cd(x2, y2);
  int nc;
  scanf("%d", &nc);
  REP(i, nc) {
    int x, y;
    scanf("%d%d%lf", &x, &y, &r[i]);
    a[i] = cd(x, y);
  }
  n = nc + 2;
  REP(i, nc) REP(j, i) {
    double t = abs(a[i] - a[j]);
    double rr = r[i] + r[j];
    d[i][j] = d[j][i] = max(0.0, t - rr);
  }
  REP(i, nc) {
    double dis = abs(s - a[i]);
    d[i][nc] = d[nc][i] = max(0.0, dis - r[i]);
    dis = abs(t - a[i]);
    d[i][nc+1] = d[nc+1][i] = max(0.0, dis - r[i]);
  }
  d[nc][nc+1] = d[nc+1][nc] = abs(s - t);
  // REP(i, n) REP(j, n) printf("%.2f%c", d[i][j], " \n"[j == n -1]);
  printf("%.12f\n", spfa(nc, nc + 1));
  return 0;
}



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

using namespace std;

int main(void)
{
	int n;
	cin >> n;
	int a[n];
	map<int, int> m;
	long long count = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		m[a[i]]++;
		count += a[i];
	}
	int q;
	cin >> q;
	int b[q], c[q];
	for (int i = 0; i < q; i++) {
		cin >> b[i] >> c[i];
		if (m[b[i]] != 0) {
			int num = m[b[i]];
			m[c[i]] += num;
			m[b[i]] = 0;
			count += (c[i]-b[i])*num;
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 9004
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod = 998244353;
inline int add(int a,int b){a+=b;return a>=mod?a-mod:a;}
inline int sub(int a,int b){a-=b;return a<0?a+mod:a;}
inline int mul(int a,int b){return 1ll*a*b%mod;}
inline int qpow(int a,int b){int ret=1;for(;b;b>>=1,a=mul(a,a))if(b&1)ret=mul(ret,a);return ret;}
const int N = 1e7+5;
int n;
int fac[N],ifac[N],pw[N];
inline void init(int n = 1e7){
	fac[0]=ifac[0]=1;for(int i=1;i<=n;i++)fac[i]=mul(fac[i-1],i);
	ifac[n]=qpow(fac[n],mod-2);for(int i=n-1;i;i--)ifac[i]=mul(ifac[i+1],i+1);
	pw[0] = 1;for(int i=1;i<=n;i++)pw[i] = mul(pw[i-1],2);
}
inline int binom(int a,int b){
	return mul(fac[a],mul(ifac[b],ifac[a-b]));
}

int main()
{
	init();
	cin >> n;
	int ans = qpow(3,n);
	for(int i=(n>>1)+1;i<=n;i++){
		ans = sub(ans, mul(2, mul(binom(n,i),pw[n-i])));
	}
	cout << ans << endl;
}


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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int m, k;
	cin >> m >> k;
	int d = 1;
	REP(i, m)d *= 2;
	if (k >= d) {
		cout << -1 << endl;
		return 0;
	}
	
	if (m == 1) {
		if (k != 0)		cout << -1 << endl;
		else {
			cout << 0 << " " << 0 << " " << 1 << " " << 1 << endl;
		}

		return 0;
	}
	vi used(d);
	vi ans;
	int now = 0;
	auto next = [&]() {
		while (used[now]) {
			now++;
		}
		used[now] = 1;
		return now;
	};
	if (k == 0) {
		REP(i, d)ans.push_back(i);
		RREP(i, d)ans.push_back(i);
		REP(i, ans.size()) {
			cout << ans[i] << " ";
		}
		cout << endl;
		return 0;
	}
#define f(a) ans.push_back(a);
	REP(i, d / 4) {
		int a = next(), b = k ^ a;
		used[b] = 1;
		int c = next(), d = k ^ c;
		used[d] = 1;
		f(a);
		f(b);
		f(c);
		f(d);
		f(b);
		f(a);
		f(d);
		f(c);
	}

	REP(i, ans.size()) {
		cout << ans[i] << " ";
	}
	cout << endl;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n>>k;
  vector<int> p(n),c(n);
  for(int i=0;i<n;i++) cin>>p[i];
  for(int i=0;i<n;i++) cin>>c[i];
  for(int i=0;i<n;i++) p[i]--;
  long long ans=-1e18;
  for(int si;si<n;si++){
    int x=si;
    vector<int> s;
    long long tot=0;
    while(1){
      x=p[x];
      s.push_back(c[x]);
      tot+=c[x];
      if(x==si) break;
    }
   int l=s.size();
   long long t=0;
    for(int i=0;i<l;i++){
      t+=s[i];
      if(i+1>k) break;
      long long now=t;
      if(tot>0){
        long long e=(k-(i+1))/l;
        now+=tot*e;
      }
      ans=max(ans,now);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

int main(){

  int n;
  cin >> n;
  int a[n];
  for (int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a, a+n);
  int ans, s, t;
  ans = 0;
  s = a[0];
  for (int i = 1; i < n; i++){
    t = a[i];
    if (s != t){
      ans += t - s;
    }
    else{
      ans += 0;
    }
    s = t;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

#define MIN(a,b) ((a)<(b)?(a):(b))
#define MAX(a,b) ((a)>(b)?(a):(b))

struct NODE {
    int number;
    NODE* root;
};

struct EDGE {
    int n1;
    int n2;
    int w;
};

int findRoot(NODE& n) {
    NODE temp_node=n;
    while(temp_node.root!=nullptr) {
        temp_node=*(temp_node.root);
    }
    return temp_node.number;
}

int main()
{
    int n;
    int rt1,rt2;
    int i,j;
    int w;
    EDGE temp_e;
    NODE temp_node;
    vector<EDGE> e;
    vector<NODE> node;

    scanf("%d",&n);
    for(i=0; i<n; ++i) {
        temp_node.number=i;
        temp_node.root=nullptr;
        node.push_back(temp_node);
        for(j=0;j<n;++j) {
            scanf("%d",&w);
            if(w!=-1 && i<j) {
                temp_e.n1=i;
                temp_e.n2=j;
                temp_e.w=w;
                e.push_back(temp_e);
            }
        }
    }
    sort(e.begin(),e.end(),[](EDGE& lhs,EDGE& rhs) { return (lhs.w==rhs.w)?(lhs.n1<rhs.n1):(lhs.w<rhs.w); });
    w=0;
    for(auto itr=e.begin(); itr!=e.end(); ++itr) {
        rt1=findRoot(node[itr->n1]);
        rt2=findRoot(node[itr->n2]);
        if(rt1!=rt2) {
            w+=itr->w;
            node[MAX(rt1,rt2)].root = &node[MIN(rt1,rt2)];
        }
    }
    printf("%d\n",w);
    return 0;
}

Measured memory_bytes: 2744
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int n,l,i,x;
	cin>>n>>l;
	int a[n+1],sum=0,minx=1000;
	for(i=1;i<=n;i++){
		a[i]=l+i-1;
		sum+=a[i];
	}
	for(i=1;i<=n;i++){
		if(fabs(a[i])<minx) {
			minx=fabs(a[i]);
			x=a[i];
		}
	}
	cout<<sum-x;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a , b;
	while(scanf("%d %d",&a,&b))
	{
		if(a == 0 && a == b)
		{
			break;
		}
			for(int i = 0 ; i < a ; i ++)
			{
				for(int i = 0 ; i < b ; i ++)
			{
				printf("#");
			}
				printf("\n");
			}
				printf("\n");
		
	} 
	return 0;
}


Measured memory_bytes: 2100
a,b = map(int,input().split())

#a,bの最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

#a,bの最小公倍数
def lcm(a, b):
    return a * b // gcd (a, b)
print(lcm(a, b))

Measured memory_bytes: 3064
#include<stdio.h>

int	main(){
	int	i,	k,	x,	a,	b,	data[10000];
	for(i	=	2;	i	<=	10000;	i++){
		data[i]	=	1;
	}
	for(i	=	2;	i	*	i	<=	10000;	i++){
		if(data[i]){
			for(k	=	2	*	i;	k	<=	10000;	k	+=	i){
				data[k]	=	0;
			}
		}
	}
	while(1){
		a	=	0;
		b	=	0;
		scanf("%d",	&x);
		if(x	==	0)break;
		for(x;	x	>=	2;	x--){
			if(data[x]	==	1){
				b	=	a;
				a	=	x;
			}
			if(b	-	a	==	2)break;
		}
		printf("%d %d\n",	a,	b);
	}
	return	0;
}

Measured memory_bytes: 1064
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
int main(){
    ll n,a;
    cin>>n>>a;
    n%=500;
    if(n<=a)cout<<"Yes";
    else cout<<"No";
}


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

using namespace std;
 int main(){
     string a,b,c;
      cin >> a >> b >> c;
      
      char dif= 'A'-'a';
     printf("%c%c%c\n",a[0]+dif,b[0]+dif,c[0]+dif);
       return 0; 
       }

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

using namespace std;

struct Combination {
  int mod;
  vector< int64_t > mfact, rfact;

  Combination(int sz, int mod) : mfact(sz + 1), rfact(sz + 1), mod(mod) {
    mfact[0] = 1;
    for(int i = 1; i < mfact.size(); i++) {
      mfact[i] = mfact[i - 1] * i % mod;
    }
    rfact[sz] = inv(mfact[sz]);
    for(int i = sz - 1; i >= 0; i--) {
      rfact[i] = rfact[i + 1] * (i + 1) % mod;
    }
  }

  int64_t fact(int k) const {
    return (mfact[k]);
  }

  int64_t pow(int64_t x, int64_t n) const {
    int64_t ret = 1;
    while(n > 0) {
      if(n & 1) (ret *= x) %= mod;
      (x *= x) %= mod;
      n >>= 1;
    }
    return (ret);
  }

  int64_t inv(int64_t x) const {
    return (pow(x, mod - 2));
  }

  int64_t P(int n, int r) const {
    if(r < 0 || n < r) return (0);
    return (mfact[n] * rfact[n - r] % mod);
  }

  int64_t C(int p, int q) const {
    if(q < 0 || p < q) return (0);
    return (mfact[p] * rfact[q] % mod * rfact[p - q] % mod);
  }

  int64_t H(int n, int r) const {
    if(n < 0 || r < 0) return (0);
    return (r == 0 ? 1 : C(n + r - 1, r));
  }
};

using int64 = long long;
const int mod = 1e9 + 7;

int main() {
  int N, M, A[16];
  cin >> N >> M;
  for(int i = 0; i < M; i++) {
    cin >> A[i];
    --A[i];
  }

  Combination beet(1 << 17, mod);
  vector< int > sz;
  int mul = 1;
  for(int i = 0; i < N; i++) {
    sz.emplace_back(mul);
    mul *= 2;
  }
  int people = (1 << N) - 1;

  vector< int64 > dp(1 << sz.size());
  dp[0] = 1;

  for(int i = M - 1; i >= 0; i--) {
    vector< int64 > dp2(dp);
    for(int j = 0; j < (1 << sz.size()); j++) {
      if(dp[j] == 0) continue;
      int rem = people - A[i];
      for(int k = 0; k < sz.size(); k++) {
        if((j >> k) & 1) rem -= sz[k];
      }
      if(rem < 0) continue;
      for(int k = 0; k < sz.size(); k++) {
        if((j >> k) & 1) continue;
        (dp2[j | (1 << k)] += dp[j] * beet.C(rem, sz[k]-1) % mod * beet.mfact[sz[k]] % mod) %= mod;
      }
    }
    dp.swap(dp2);
  }

  int64 ret = 0;
  for(int i = 0; i < (1 << sz.size()); i++) {
    int rest = people;
    for(int j = 0; j < sz.size(); j++) {
      if((i >> j) & 1) rest -= sz[j];
    }
    auto add = (dp[i] * beet.mfact[rest]) % mod;
    if(__builtin_parity(i)) (ret += mod - add) %= mod;
    else (ret += add) %= mod;
  }
  (ret *= (1 << N)) %= mod;
  cout << ret << endl;
}


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

using namespace std;

#define pb push_back
#define fi first
#define se second
#define debug(x) cerr<<#x << " := " << x << endl;
#define bug cerr<<"-----------------------"<<endl;



typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int inf = 0x3f3f3f3f;
const ll inff = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9+7;
/**********showtime************/
            const int maxn = 1e5+9;
            vector<int>mp[maxn];
            int dis[maxn][4];
            void bfs(int s, int t) {
                memset(dis, inf, sizeof(dis));
                dis[s][0] = 0;
                queue<pii>que;
                que.push(pii(s, 0));
                while(!que.empty()) {
                    int u = que.front().fi, step = que.front().se;
                    que.pop();
                    for(int i=0; i<mp[u].size(); i++) {
                        int v = mp[u][i];
                        int nx = step + 1;
                        if(nx == 3) nx = 0;
                        if(dis[v][nx] > dis[u][step] + 1) {
                            dis[v][nx] = dis[u][step] + 1;
                            que.push(pii(v, nx));
                        }
                    }
                }
            }
int main(){
            int n,m;
            scanf("%d%d", &n, &m);
            for(int i=1; i<=m; i++) {
                int u,v;
                scanf("%d%d", &u, &v);
                mp[u].pb(v);
            }
            int s, t;
            scanf("%d%d", &s, &t);

            bfs(s, t);
            if(dis[t][0] < inf) printf("%d\n", dis[t][0]/3);
            else puts("-1");

            return 0;
}


Measured memory_bytes: 7296
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef vector<int> vi;
int main() {
  int h,w;
  cin >> h >>w;
  vi coins[h];
  vector<string> ans;
  rep(ih,h){
    rep(iw,w){
      int c; cin >>c;
      coins[ih].push_back(c);
    }
  }
rep(ih,h){
    rep(iw,w-1){
      if(coins[ih][iw]%2 ==1){
        coins[ih][iw]--;
        coins[ih][iw+1]++;
      stringstream ss;
      ss << ih+1 <<" "<<iw+1<<" "<<ih+1<<" "<<iw+2;
      string s=ss.str();
      ans.push_back(s);
        //cout<< ih+1 <<" "<<iw+1<<" "<<ih+1<<" "<<iw+2<<endl;
      }
    }
  }
rep(ih,h-1){
  if(coins[ih][w-1]%2 ==1){
  coins[ih][w-1]--;
  coins[ih+1][w-1]++;
  stringstream ss;
  ss << ih+1 <<" "<<w<<" "<<ih+2<<" "<<w;
  string s=ss.str();
  ans.push_back(s);
  //cout<< ih+1 <<" "<<w<<" "<<ih+2<<" "<<w<<endl;
  }
  
}
int n = ans.size();
  cout<<n<<endl;
  rep(i,n){
    cout<<ans[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 9972
#include<bits/stdc++.h>
#define LL long long
using namespace std;
const int N=100005;
int n,a[N];
//3 4 6 7
int Dis(int x,int y)
{
	return abs(x-(y+1)/2);
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	int ansl=a[1];
	for(int i=1;i<n;i++)
	  if(Dis(a[i],a[n])<Dis(ansl,a[n])) ansl=a[i];
	printf("%d %d\n",a[n],ansl);
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#define RPE(i,m,n) for(int i = m(int);i < n(int);i++)
#define rpe(i,n) RPE(i,0,n);
#define ll long long int;
using namespace std;

string s;

int main(){
	cin >> s;
	if (s == "Sunny") cout << "Cloudy" << endl;
	else if (s == "Cloudy") cout << "Rainy" << endl;
	else if (s == "Rainy") cout << "Sunny" << endl;



	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define vec vector < ll >
#define pb push_back
#define po pop_back
#define f(i,x,n) for(ll i=x;i<n;i++)
#define rf(i,x,n) for(ll i = x; i >= n; i--)
#define all(c) c.begin(),c.end()
using pii = pair<int,int>;
const int MOD = 1e9+7, N = 2e3 + 10; 
int main()
{   ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  	string s,t;cin>>s>>t;
  	int c=0;
  	f(i,0,s.length()){
  		if(s[i]==t[i])
  			c++;
  	}
  	if(c==s.length())
  		cout<<"Yes";
  	else cout<<"No";
	return 0;
} 

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  VI xs(3);
  cin >> xs;
  int mx = *max_element(ALL(xs));

  int ans = 0;
  for(int& x: xs){
	ans += (mx - x) / 2;
	x += (mx-x)/2 * 2;
  }

  int c = count(ALL(xs), mx);
  if(c == 1) ++ans;
  else if(c == 2) ans += 2;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>

using namespace std;

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

  cout << max(0, min(b,d) - max(a,c)) << endl;
}

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

using namespace std;

const int N = 1e2 + 8;
long long t[N] , p[N] , x[N] , sum , m , n;

int main()
{
	cin >> n;
	for(int i = 0 ; i < n ; i++)
	{
		cin >> t[i];
		sum += t[i];
	}
	cin >> m;
	for(int i = 0 ; i < m ; i++)
		cin >> p[i] >> x[i];
	for(int i = 0 ; i < m ; i++)
	{
		sum -= (t[p[i] - 1]);
		sum += (x[i]);
		cout << sum << endl;
		sum -= (x[i]);
		sum += (t[p[i] - 1]);
	}
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b) {
    cout << c << endl;
  }
  else if (b == c) {
    cout << a << endl;
  }
  else {
    cout << b << endl;
  }
}

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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int n;
vector<vector<int>> g;
vector<int> dist_a;
vector<int> dist_b;

void dfs(int s, int p, vector<int> &dist) {
    for (auto t : g[s]) {
        if (t == p) continue;
        dist[t] = dist[s] + 1;
        dfs(t, s, dist);
    }
}

int main() {

    cin >> n;
    g.resize(n);
    dist_a.resize(n, 0);
    dist_b.resize(n, 0);
    for (int i = 0; i < n - 1; ++i) {
        int a, b; cin >> a >> b;
        --a; --b;

        g[a].push_back(b);
        g[b].push_back(a);
    }

    // dfs
    dfs(0, -1, dist_a);
    dfs( n - 1, -1, dist_b);

    int fennec = 0;
    int snuke = 0;
    for (int i = 1; i <= n - 2; ++i) {
        if (dist_a[i] <= dist_b[i]) {
            fennec++;
        } else {
            snuke++;
        }
    }

    if (fennec > snuke) {
        puts("Fennec");
    } else {
        puts("Snuke");
    }
}


Measured memory_bytes: 15564
#include<stdio.h>
int main(void)
{
      int S;
      int h,m,s;
      scanf("%d",&S);

      h = S / 3600;
      S%= 3600;

      m = S / 60;
      S %= 60;

      s = S;
      if(0<=S && S<86400)
        printf("%d:%d:%d\n",h,m,s);
}

Measured memory_bytes: 1816
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define at(x,i) get<i>(x);
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n,m;cin >> n >>m;
    vvl dist(n,vl(n,inf));
    rep(i,m){
        ll a,b,c;cin >> a >>b >>c;
        dist[a][b]=c;
    }
    ll ans=INF;
    vvl dp(1<<n,vl(n,inf));
    dp[1][0]=0;
    rep(bit,1<<n){
        rep(i,n){
            if(bit&1<<i){
                rep(j,n){
                    if(i==j)continue;
                    if(bit&1<<j){
                        chmin(dp[bit][i],dp[bit-(1<<i)][j]+dist[j][i]);
                    }
                }
            }
        }
    }
    ll all=(1<<n)-1;
    rep(i,n){
        chmin(ans,dp[all][i]+dist[i][0]);
    }
    if(ans>inf/10)cout << -1 << endl;
    else cout << ans <<endl;
}


Measured memory_bytes: 7584
#include <cassert>
#include <iostream>
#include <string>

class TDllist
{
    int* FList; //[4000000];
    int FBegin;
    int FEnd;
public:
    TDllist()
    {
        FList = new int[4000000];
        FBegin = 2000000;
        FEnd  = 2000000;
    }
    ~TDllist()
    {
        delete[] FList;
    }
    void Insert(int X)
    {
        --FBegin;
        FList[FBegin] = X;
    }
    void Delete(int X)
    {
        int Index = FEnd;
        for(int i = FBegin; i < FEnd; ++i){
            if(X == FList[i]){
                Index = i;
                break;
            }
        }
        if(Index == FEnd) return;
        for(int i = Index; i < FEnd; ++i){
            FList[i] = FList[i+1];
        }
        FEnd--;
    }
    void DeleteFirst()
    {
        FBegin++;
    }
    void DeleteLast()
    {
        FEnd--;
    }
    void Show()const
    {
        std::cout << FList[FBegin];
        for(int i = FBegin + 1; i < FEnd; ++i){
            std::cout << " " << FList[i];
        }
        std::cout << std::endl;
    }
};

int main()
{
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    TDllist List;
    int n, X;
    std::cin >> n;
    std::string Command;
    for(int i = 0; i < n; ++i){
        // std::string Command;
        std::cin >> Command;
        if(Command == "insert"){
            // int X;
            std::cin >> X;
            List.Insert(X);
        }else
        if(Command == "delete"){
            // int X;
            std::cin >> X;
            List.Delete(X);
        }else
        if(Command == "deleteFirst")
        {
            List.DeleteFirst();
        }else
        if(Command == "deleteLast")
        {
            List.DeleteLast();
        }else{
            assert(false);
        }
    }
    List.Show();
    return 0;
}

Measured memory_bytes: 7152
#include<cstdio>
typedef long long ll;
const int mod=1000000007;
char s[200050];
bool d[200050];
int sum[200050];
int main(){
	int n,i,ans=1,cnt=0;
	scanf("%d%s",&n,s+1);
	if(s[1]=='W'||s[n<<1]=='W'){
		puts("0");
		return 0;
	}
	for(i=2,d[1]=0,sum[1]=1;i<=(n<<1);++i)sum[i]=sum[i-1]+!(d[i]=d[i-1]^(s[i]==s[i-1]));
	if(sum[n<<1]!=n){
		puts("0");
		return 0;
	}
	for(i=2;i<=(n<<1);++i)if(d[i]){
		ans=(ll)ans*(sum[i-1]-cnt)%mod;
		++cnt;
	}
	for(i=2;i<=n;++i)ans=(ll)ans*i%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1280
def main():
    N = int(input())
    A = [int(i) for i in input().split()]
    ans = 0
    A.sort()
    ans += A.pop()
    for i in range((N-2)//2):
        ans += 2*A.pop()
    if N % 2 == 1:
        ans += A.pop()
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 94304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


int main() {
	int n;
	cin >> n;
	if (n < 1200)cout << "ABC" << endl;
	else if (n <2800)cout << "ARC" << endl;
	else cout << "AGC" << endl;
}


Measured memory_bytes: 768