akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val r = n % 10
    if (r == 3) {
        println("bon")
    } else if (r == 0 || r == 1 || r == 6 || r == 8) {
        println("pon")
    } else {
        println("hon")
    }
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 34272
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    
    ans = []
    while N:
        mod = (N - 1) % 26
        ans.append(chr(ord('a') + mod))
        N -= 1
        N //= 26
    print(''.join(reversed(ans)))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 80648
#include<cstdio>
#include<cstring>
int num[100];
long long table[100][21];
int dp[100][21];
int N;
long long solve(int m,int n){
	if(dp[m][n])return table[m][n];
	long long res=0;
	if(m==N-1){
		if(n==num[N-1]) return table[m][n]=1;
		else return table[m][n]=0;
	}
	if(n+num[m]<=20) res+=solve(m+1,n+num[m]);
	if(n-num[m]>=0) res+=solve(m+1,n-num[m]);
	dp[m][n] = 1;
	return table[m][n]=res;
}

int main(){
	memset(dp, 0, sizeof(dp));
	
	scanf("%d",&N);
	for(int i=0;i<N;i++) scanf("%d",num+i);
	printf("%lld\n",solve(1,num[0]));
	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		int a,b;
		Scanner sc = new Scanner(System.in);

		a = sc.nextInt();
		b = sc.nextInt();

		int num1 = (int)a/b;
		int num2 = (int)a%b;
		double num3 = (double)a/(double)b;
		System.out.printf("%d %d %f",num1,num2,num3);

		sc.close();
	}

}

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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;



ll N = 0;
ll ret = 0;
vector<ll> A;

ll gcd(ll a, ll b) {
  if (b > a) return gcd(b, a);
  else if (b == 0) return a;
  else return gcd(b, a%b);
}

void input() {
  IN(N);
  ll tmp;
  REP(i, N) {
    IN(tmp);
    A.pb(tmp);
  }
}

void solve() {
  vector<ll> L(N);
  vector<ll> R(N);
  L[1] = A[0];
  FOR(i, 2, N) {
    L[i] = gcd(A[i-1], L[i-1]);
  }
  LN();
  R[N-2] = A[N-1];
  for (int i = N-3; i>=0; i--) {
    R[i] = gcd(A[i+1], R[i+1]);
  }

  REP(i, N) {
    ll b;
    if (i == 0) {
      b = R[i];
    } else if(i == N-1) {
      b = L[i];
    } else {
      b = gcd(L[i], R[i]);
    }
    ret = max(ret, b);
  }
  PRINT(ret);
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 2676
IDENTIFICATION DIVISION.
      PROGRAM-ID. 60A.
      DATA DIVISION.
      WORKING-STORAGE SECTION.
      01 INP PIC X(100).
      01 A. 
      	03 AN PIC X(1) OCCURS 10 TIMES.
      01 B. 
      	03 BN PIC X(1) OCCURS 10 TIMES.
      01 C. 
      	03 CN PIC X(1) OCCURS 10 TIMES.
      01 WKA  PIC X(1).
      01 WKB  PIC X(1).
      01 WKC  PIC X(1).
      01 IDX  PIC 9(2).

      PROCEDURE DIVISION.
      ACCEPT INP.
      UNSTRING INP DELIMITED BY " "
      INTO A B C.
      
      PERFORM VARYING IDX FROM 1 BY 1 UNTIL ( IDX > 10 ) OR ( AN(IDX) = SPACE )
      MOVE AN(IDX) TO WKA
      END-PERFORM.
      
      PERFORM VARYING IDX FROM 1 BY 1 UNTIL ( IDX > 10 ) OR ( BN(IDX) = SPACE )
      MOVE BN(IDX) TO WKB
      END-PERFORM.
      
      IF ( WKA = BN(1) ) AND ( WKB = CN(1) )
      	DISPLAY "YES"
      ELSE
      	DISPLAY "NO"      
      END-IF.
      
      STOP RUN.
      

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

int main()
{
  int N;cin>>N; 
  double ans = 0.0;
  for (int i=0;i<N;i++)
  {
    double a;cin>>a;
    ans  += 1.0/a;
  }
  ans = 1/ans;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    while (true) {
        if (n == 0 && x == 0)
            break;
        int count = 0;
        for (int i = 1; i < n; i++)
            for (int j = i + 1; j < n; j++)
                for (int k = j + 1; k <= n; k++)
                    if (i + j + k == x)
                        count++;    
        cout << count << endl;
        cin >> n >> x;
    }
    return 0;
}



Measured memory_bytes: 3096
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        for(int i = 1; i <= n; i++){
            if((int) (i * 1.08) == n){
                System.out.println(i);
                return;
            }
        }
        System.out.println(":(");
        scan.close();
    }
}


Measured memory_bytes: 27020
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<vector<int>> cnt(10, vector<int>(10));
	for (int i = 1; i <= N; i++) {
		cnt[to_string(i).front() - '0'][i % 10]++;
	}

	lint ans = 0;
	for (int i = 0; i < 10; i++) {
		for (int j = 0; j < 10; j++) {
			ans += 1LL * cnt[i][j] * cnt[j][i];
		}
	}

	cout << ans << "\n";

	return 0;
}

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

template <typename T, int B = 2>
class persistent_array {
public:
	static const int mask = (1 << B) - 1;
	struct node {
		T val;
		node* ch[1 << B];
		node() {
			for (int i = 0; i < (1 << B); i++) ch[i] = nullptr;
		}
		node(T v) : val(v) {}
		node(node* t) { memcpy(ch, t->ch, sizeof(node*) << B); }
	};
private:
	const int h, n;
	const T id;
	node *root;
	int get_h(int n) {
		int cnt = 0, tmp = 1;
		while (tmp < n) tmp <<= B, cnt++;
		return cnt;
	}
	node* fix(node *t, int p, T val, int x) {
		if (x < 0) return new node(val);
		t = t ? new node(t) : new node();
		int to = (p >> x) & mask;
		t->ch[to] = fix(t->ch[to], p, val, x - B);
		return t;
	}
	node* dfs(int p, int d, const vector<T>& v) {
		if ((int)v.size() <= (p << d)) return nullptr;
		if (d == 0) return new node(v[p]);
		node* t = new node;
		for (int i = 0; i < (1 << B); i++) {
			t->ch[i] = dfs((p << B) | i, d - B, v);
		}
		return t;
	}
	node* init(const vector<T>& v) {
		return dfs(0, h * B, v);
	}
public:
	persistent_array(int n_, T id_ = 0)
		: h(get_h(n_)), n(1 << (h * B)), id(id_), root(nullptr) {}
	persistent_array(const vector<T>& v, T id_ = 0)
		: h(get_h(v.size)), n(1 << (h * B)), id(id_), root(init(v)) {}
	T set(int p, T val) {
		root = fix(root, p, val, B * (h - 1));
		return val;
	}
	T operator[](int p) const {
		node* t = root;
		for (int i = (h - 1) * B; i >= 0; i -= B) {
			if (!t) return id;
			t = t->ch[(p >> i) & mask];
		}
		return t ? t->val : id;
	}
	void trip_version(node* t) {
		root = t;
	}
	node* get_version() const {
		return root;
	}
};

class persistent_union_find {
public:
	using pa = persistent_array<int>;
	using node = typename pa::node;
private:
	pa par;
	int find(int a) {
		return par[a] < 0 ? a : par.set(a, find(par[a]));
	}
public:
	persistent_union_find(int n) : par(n, -1) {}
	bool same(int a, int b) {
		return find(a) == find(b);
	}
	void unite(int a, int b) {
		a = find(a);
		b = find(b);
		if (a == b) return;
		if (par[a] > par[b]) swap(a, b);
		par.set(a, par[a] + par[b]);
		par.set(b, a);
	}
	int size(int a) {
		return -par[find(a)];
	}
	void trip_version(node* t) {
		par.trip_version(t);
	}
	node* get_version() {
		return par.get_version();
	}
};

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int n, q;
	cin >> n >> q;
	persistent_union_find uf(n);
	while (q--) {
		int com, x, y;
		cin >> com >> x >> y;
		if (com == 0) {
			uf.unite(x, y);
		}
		else {
			printf("%d\n", uf.same(x, y));
		}
	}
	return 0;
}



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

#define _p(...) (void)printf(__VA_ARGS__)
#define forr(x,arr) for(auto&& x:arr)
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) _rep3(i,0,n)
#define _rep3(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2,)(__VA_ARGS__)
#define _rrep2(i,n) _rrep3(i,0,n)
#define _rrep3(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define bit(n) (1LL<<(n))
#define sz(x) ((int)(x).size())
#define fst first
#define snd second
using ll=long long;using pii=pair<int,int>;
using vb=vector<bool>;using vs=vector<string>;
using vi=vector<int>;using vvi=vector<vi>;using vvvi=vector<vvi>;
using vl=vector<ll>;using vvl=vector<vl>;using vvvl=vector<vvl>;
using vd=vector<double>;using vvd=vector<vd>;using vvvd=vector<vvd>;
using vpii=vector<pii>;using vvpii=vector<vpii>;using vvvpii=vector<vvpii>;
template<typename T>T read(){T t;cin>>t;return t;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){o<<'('<<p.fst<<", "<<p.snd<<')';return o;}

void Main() {
  string s = read<string>();
  cout << ((sz(s) % 2) ^ (s[0] == s[sz(s)-1]) ? "First" : "Second") << endl;
}
int main() { cin.tie(nullptr); ios::sync_with_stdio(false); Main(); return 0; }


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

int N, M;
int A[200005], B[200005];

set<int> Adj[200005];

int cnt;

int used[200005];

void visit(int k) {
	cnt++; 
	for (auto y : Adj[k]) {
		if (used[y] == 0) {
			used[y] = 1; visit(y);
		}
	}
}

int main(void) {

	cin >> N >> M;

	for (int i = 1; i <= M; i++) { 
		cin >> A[i] >> B[i]; 
		Adj[A[i]].insert(B[i]);
		Adj[B[i]].insert(A[i]);
	}

	int ans = 1;

	for (int i = 1; i <= N; i++) {
		cnt = 0;
		if (used[i] == 0) { used[i] = 1; visit(i); }
		ans = max(ans, cnt);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 40240
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
    int ssize;
    string s, res;
	cin >> s;
    ssize = s.size();
    for (int i = 0; i < ssize; i++) {
        char ti, di;
        cin >> ti >> di;
    }
    res = s[0]+to_string(ssize-2)+s[ssize-1];
    cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long a,b;
    scanf("%ld%ld", &a, &b);

    if(a+b>=10) {
        printf("error\n");
    }
    else {
        printf("%ld\n", a+b);
    }    
    
    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1<<(i))))
#define setbit1(n,i) ((n)|(1<<(i)))
#define togglebit(n,i) ((n)^(1<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
   
int main()
{
    fastread;
    ll n;
    cin>>n;
    cout<<(n+1)/2;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int k, x;
  cin >> k >> x;
  for(int i = x - k + 1; i <= x + k - 1 - 1; i++){
    cout << i << ' ';
  }
  cout << x + k - 1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

bool linerSearch(vector<int> s, int key){
    for(int i=0; i<s.size(); i++){
        if(s[i] == key) return true;
    }

    return false;
}

int main(){
    int n; cin >> n;
    vector<int> s(n);
    for(int i=0; i<n; i++) cin >> s[i];

    int q; cin >> q;
    vector<int> t(q);
    for(int i=0; i<q; i++) cin >> t[i];

    int ans = 0;

    for(int i=0; i<q; i++){
        if(linerSearch(s, t[i])) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3220
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC target("avx,avx2,fma,sse,sse2")
#pragma GCC optimization ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;

#define N 200007

typedef tree<int, null_type, less<int>,rb_tree_tag,
tree_order_statistics_node_update> new_data;
int main()
{
    char a;
    cin>>a;
    cout<<char(a+1)<<endl;
}


Measured memory_bytes: 3532
#include<stdio.h>
int main()
{
    long long int n;

    scanf("%lld", &n);

    long long int p = n%11;

    long long int d = n / 11;

    long long int l = d*2;

    if(p!=0 && p<=6)
    {
        l++;
    }

    else if(p!=0 && p>=7)
    {
        l=l+2;
    }

    else if(p==0)
    {
        l=l;
    }

    printf("%lld", l);

    return 0;

}

Measured memory_bytes: 1672
#include <iostream>
#include <cstdlib>
#include <sstream>
#include <stdlib.h>
#include <string>

using namespace std;

bool flag = 0;
bool data[20][20][16][4] = {0};
string inp[20];
int R, C;


void dfs(int x, int y, int m, int d){
  if(x == C){
    x = 0;
  } else if (x == -1){
    x = C-1;
  }

  if(y == R){
    y = 0;
  } else if (y == -1){
    y = R-1;
  }

  if(data[x][y][m][d] == 1) {
    return;
  } else{
    data[x][y][m][d] = 1;
  }

  if(inp[y][x] == '@'){
    flag = 1;
  }

  if('0' <= inp[y][x] && inp[y][x] <= '9'){
    if(d==0){
      dfs(x-1, y, inp[y][x]-'0', d);
    }else if(d==1){
      dfs(x+1, y, inp[y][x]-'0', d);
    }else if(d==2){
      dfs(x, y-1, inp[y][x]-'0', d);
    }else {
      dfs(x, y+1, inp[y][x]-'0', d);
    }
  } else if (inp[y][x] == '_'){
    if(m==0){
      dfs(x+1, y, m, 1);
    } else {
      dfs(x-1, y, m, 0);
    }
  } else if (inp[y][x] == '|'){
    if(m == 0){
      dfs(x, y+1, m, 3);
    } else {
      dfs(x, y-1, m, 2);
    }
  } else if (inp[y][x] == '.'){
    if(d == 0) {
      dfs(x-1, y, m, d);
    } else if (d == 1){
      dfs(x+1, y, m, d);
    } else if (d == 2){
      dfs(x, y-1, m, d);
    } else {
      dfs(x, y+1, m, d);
    }
  } else if (inp[y][x] == '<') {
    dfs(x-1, y, m, 0);
  } else if (inp[y][x] == '>'){
    dfs(x+1, y, m, 1);
  } else if (inp[y][x] == '^'){
    dfs(x, y-1, m, 2);
  } else if (inp[y][x] == 'v'){
    dfs(x, y+1, m, 3);
  } else if (inp[y][x] == '?'){
    dfs(x-1, y, m, 0);
    dfs(x+1, y, m, 1);
    dfs(x, y-1, m, 2);
    dfs(x, y+1, m, 3);
  } else if(inp[y][x] == '+'){
    if(m == 15){
      if(d == 0){
        dfs(x-1, y, 0, d);
      } else if (d == 1){
        dfs(x+1, y, 0, d);
      } else if (d == 2){
        dfs(x, y-1, 0, d);
      } else if (d == 3){
        dfs(x, y+1, 0, d);
      }
    } else {
      if(d == 0){
        dfs(x-1, y, m+1, d);
      } else if (d == 1){
        dfs(x+1, y, m+1, d);
      } else if (d == 2){
        dfs(x, y-1, m+1, d);
      } else if (d == 3){
        dfs(x, y+1, m+1, d);
      }
    }
  } else if (inp[y][x] == '-'){
    if(m == 0){
      if(d == 0){
        dfs(x-1, y, 15, d);
      } else if (d == 1){
        dfs(x+1, y, 15, d);
      } else if (d == 2){
        dfs(x, y-1, 15, d);
      } else if (d == 3){
        dfs(x, y+1, 15, d);
      }
    } else {
      if(d == 0){
        dfs(x-1, y, m-1, d);
      } else if (d == 1){
        dfs(x+1, y, m-1, d);
      } else if (d == 2){
        dfs(x, y-1, m-1, d);
      } else if (d == 3){
        dfs(x, y+1, m-1, d);
      }
    }
  }
}

int main(){
  cin >> R >> C;

  for(int i = 0;i < R;i++){
    cin >> inp[i];
  }

  dfs(0, 0, 0, 1);

  if(flag == 1){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}

Measured memory_bytes: 4132
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
ld n,x[8],y[8],ans,L,N;
int main(void){
    cin>>n;
    for(int i=1;i<n;i++){
        N+=i;
    }
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
    }
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            L=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);
            ans+=pow(L,0.5);
        }
    }
    cout<<setprecision(15)<<ans/N*(n-1)<<endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String N = sc.next();
      long sum = 0;
      for(int i=0;i<N.length();i++){
        String s = N.substring(i,i+1);
        int n = Integer.parseInt(s);
        sum+=n;
        sum%=9;
      }
      if(sum==0){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
}

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

int main(){
  int a, b, c, k;
  scanf("%d%d%d%d", &a, &b, &c, &k);
  int ans = 0;
  if (a>k) ans = k;
  else{
    k-=a; ans = a;
    if (b<k){
      k -= b;
      ans -= k;
    }
  }
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 3824
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <algorithm>
#define MAX 100000
using namespace std;
typedef long long ll;
int a[2000001],b[2000001],c[100001];
int main()
{	
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		c[a[i]]++;//等于a[i]的数的数量 
	}
	for(int i=1;i<100001;i++)
	{
		c[i]=c[i]+c[i-1];//小于等于自己的数数量 
	}
	for(int i=0;i<n;i++)
	{
		b[c[a[i]]-1]=a[i];//有c[a[i]]小于等于a[i]，因此a[i]就放到这个位置上
		c[a[i]]-- ;//减去一个等于自己的数 
	}
	for(int i=0;i<n;i++)
	{
		if(i==n-1){
			printf("%d\n",b[i]);
		}else{
			printf("%d ",b[i]);
		}
	}
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define INF (int)1e8
#define EPS 1e-9

using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;

int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N;
  cin >> N;

  int sum = findSumOfDigits(N);
  string res = (N % sum == 0) ? "Yes" : "No";

  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ll N;
    cin >> N;
    ll C[500], S[500], F[500];
    for(int i=1;i<N;i++)
        cin >> C[i] >> S[i] >> F[i];

    for(int j=1;j<=N-1;j++){
        ll ans = 0;
        for(int i=j;i<N;i++){
            if(ans <= S[i])    // 始発に乗る
                ans += S[i] - ans;
            else if((ans - S[i]) % F[i] != 0)    // Fi間隔の列車に乗る
                ans += F[i] - (ans - S[i]) % F[i];
            ans += C[i];
        }
        cout << ans << endl;
    }
    cout << 0 << endl;

}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
sorted_a = []
for i in range(n):
    sorted_a.append([a[i], i])

sorted_a.sort()
# print(sorted_a)
ans = []
for i in range(n):
    ans.append(sorted_a[i][1]+1)
print(*ans)


Measured memory_bytes: 30172
def main():
    # input
    m=0
    n, W = map(int, input().split())
    v, w = [0], [0]
    for _ in range(n):
        wi, vi = map(int, input().split())
        v.append(vi)
        w.append(wi)
    cond = []
    b_list = []
    for _ in range(m):
        a, b = map(int, input().split())
        cond.append([b, a])
        b_list.append(b)
    cond.sort(reverse=True)

    # prepare
    for i in range(m):
        a, b = cond[i][1], cond[i][0]
        v[a] += v[b]
        w[a] += w[b]

    # process
    b_tuple = tuple(b_list)
    # del vi, wi, a, b
    dp = [[0]*(W+1) for _ in range(n+1)]
    skip = 0
    for i in range(1, n+1):
        if i in b_tuple:
            skip += 1
            continue
        for j in range(1, W+1):
            if j>=w[i]:
                dp[i][j] = max(dp[i-1-skip][j], dp[i-1-skip][j-w[i]]+v[i])
            else:
                dp[i][j] = dp[i-1-skip][j]
    print(max(max(dp)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 118896
from functools import reduce

N, X = map(int, input().split())
x = list(map(int, input().split()))
for i in range(N):
  x[i] -= X
#print(x)

def gcd(a, b):
  while b:
    a, b = b, a % b
  return a

def gcd_list(numbers):
  return reduce(gcd, numbers)

print(abs(gcd_list(x)))


Measured memory_bytes: 14596
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <numeric>

using namespace std;

using ll = long long;

ll mod = 1000000007;

int n;

map<pair<int, string>, ll> memo;

ll dfs(int i, string s) {
    if (i == n) {
        return 1;
    }

    auto t = make_pair(i, s);

    if (memo.count(t)) {
        return memo[t];
    }

    ll ret = 0;

    if (s.size() <= 1) {
        ret = (ret + dfs(i + 1, s + 'A')) % mod;
        ret = (ret + dfs(i + 1, s + 'G')) % mod;
        ret = (ret + dfs(i + 1, s + 'T')) % mod;
        ret = (ret + dfs(i + 1, s + 'C')) % mod;
    } else if (s.size() == 2) {
        ret = (ret + dfs(i + 1, s + 'A')) % mod;
        ret = (ret + dfs(i + 1, s + 'T')) % mod;
        
        if (s != "AC") {
            ret = (ret + dfs(i + 1, s + 'G')) % mod;
        }

        if (s != "AG" && s != "GA") {
            ret = (ret + dfs(i + 1, s + 'C')) % mod;
        }
    } else {
        string t = s.substr(1);
        ret = (ret + dfs(i + 1, t + 'A')) % mod;
        ret = (ret + dfs(i + 1, t + 'T')) % mod;

        if (t != "AC") {
            ret = (ret + dfs(i + 1, t + 'G')) % mod;
        }

        if (t != "AG" && t != "GA" && !(s[0] == 'A' && s[1] == 'G') && !(s[0] == 'A' && s[2] == 'G')) {
            ret = (ret + dfs(i + 1, t + 'C')) % mod;
        }
    }

    return memo[t] = ret;
}

int main() {
    cin >> n;

    cout << dfs(0, "") << endl;
}


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

class Dice{
    public:
    int val[6];

    Dice(int a[]){
        copy(a,a+6,val);
    }

    int show(){
        return val[0];
    }

    void move(char c){
        if(c == 'E') {
            int tmp = val[0];
            val[0] = val[3];
            val[3] = val[5];
            val[5] = val[2];
            val[2] = tmp;
        }
        if(c == 'W') {
            int tmp = val[0];
            val[0] = val[2];
            val[2] = val[5];
            val[5] = val[3];
            val[3] = tmp;
        }
        if(c == 'N') {
            int tmp = val[0];
            val[0] = val[1];
            val[1] = val[5];
            val[5] = val[4];
            val[4] = tmp;
        }
        if(c == 'S') {   
            int tmp = val[0];
            val[0] = val[4];
            val[4] = val[5];
            val[5] = val[1];
            val[1] = tmp;
        }
    }
};

int main() {
    int a[6];
    rep(i,6) cin >> a[i];
    string str;
    cin >> str;
    Dice d(a);
    for(auto &s : str){
        d.move(s);
    }
    cout << d.show() << endl;
    return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int n = s.size();
	if (n == 1) {
		cout << "YES" << endl;
		return 0;
	}
	int a = 0, b = 0, c = 0;
	rep(i, n) {
		if (s[i] == 'a') a++;
		if (s[i] == 'b') b++;
		if (s[i] == 'c') c++;
	}
	vector<int> def = { a,b,c };
	sort(all(def));
	if (def[2] - def[0] > 1) {
		cout << "NO" << endl;
	}
	else cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long LL;
const int N=3000;
LL n,mo,fac[N+10],inv[N+10],pw[N+10],f[N+10][N+10];
LL mul(LL x,LL y,LL mod=mo) {
    x%=mod;
    LL z=1;
    while (y) {
        if (y&1) z=z*x%mod;
        y>>=1;
        x=x*x%mod;
    }
    return z;
}
void prework() {
    fac[0]=1;
    for (int i=1;i<=N;i++) fac[i]=fac[i-1]*i%mo;
    inv[N]=mul(fac[N],mo-2);
    for (int i=N-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mo;
}
LL C(LL x,LL y) {
    if (y>x||y<0) return 0;
    return fac[x]*inv[y]%mo*inv[x-y]%mo;
}
void work() {
    LL ans=0;
    for (int i=0;i<=n;i++) pw[i]=mul(2,mul(2,i,mo-1));
    f[0][0]=1;
    for (int i=1;i<=n+1;i++) {
        f[i][0]=0;
        for (int j=1;j<=i;j++)
            f[i][j]=(f[i-1][j-1]+f[i-1][j]*j)%mo;
    }
    for (int i=0;i<=n;i++) {
        LL now=mul(mo-1,i)*C(n,i)%mo*pw[n-i]%mo;
        LL nowx=mul(2,n-i),sumx=0;
        for (LL j=0,sx=1;j<=i;j++,sx=sx*nowx%mo)
            sumx=(sumx+sx*f[i+1][j+1])%mo;
        now=now*sumx%mo;
        ans=(ans+now)%mo;
    }
    ans=(ans%mo+mo)%mo;
    printf("%lld\n",ans);
}
int main() {
    scanf("%lld%lld",&n,&mo);
    prework();
    work();
    return 0;
}


Measured memory_bytes: 69248
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9+5;
const ll INF=1e18+5;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  ll n,a[200005]={},k,now=1,x,y,cnt,amari;
  cin >> n >> k;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  vector<ll> v;
  map<ll,ll> mp;
  mp[1]++;
  v.push_back(1);
  while(true) {
    now=a[now-1];
    mp[now]++;
    v.push_back(now);
    if(mp[now]==2) {
      break;
    }
  }
  int f=0;
  for(ll i=0; i<v.size(); i++) {
    if(f&&v[i]==now) {
      y=i;
      break;
    }
    if(!f&&v[i]==now) {
      x=i;
      f=1;
    }
  }
  if(k<=x) {
    cout << v[k] << endl;
  }
  else {
    k-=x;
    cnt=y-x;
    amari=k%cnt;
    cout << v[x+amari] << endl;
  }
}


Measured memory_bytes: 18544
#include<cstdio>
#include<algorithm>
using namespace std;
bool field[15][10005];
int r, c;
int maxium = 0;
int sumup()
{
    //按照列来统计，只取统计一列中正面或背面朝上更多的，相当于把这一列反面
    int sum = 0, cnt;
    for(int j = 0; j < c; j++){
        cnt = 0;
        for(int i = 0; i < r; i++){
            cnt += field[i][j];
        }
        sum += max(cnt, r - cnt);
    }
    return sum;
}
void rev(int n)
{
    for(int j = 0; j < c; j++){
        field[n][j] = !field[n][j];
    }
}
int dfs(int n)
{
    if(n == r)
        return maxium = max(maxium, sumup());
    rev(n);
    dfs(n + 1);
    rev(n);
    dfs(n + 1);
}
int main()
{
    while(scanf("%d%d", &r, &c) == 2 && r){
        for(int i = 0; i < r; i++){
            for(int j = 0; j < c; j++){
                scanf("%d", &field[i][j]);
            }
        }
        int res = dfs(0);
        printf("%d\n", res);
    }
    return 0;
}



Measured memory_bytes: 2692
import copy
s = input().split()

n = int(s[0])
m = int(s[1])
x = int(s[2])

s_list = [[0 for i in range(m+1)] for j in range(n)]

for i in range(n):
    r = input().split()
    s_list[i][0] = int(r[0])
    for j in range(1,m + 1):
        s_list[i][j] = int(r[j])


gen = [0] * (m + 1)
kakaku = -1

for i in range(2 ** n):
    kari = copy.copy(gen)
    for j in range(n):
        if ((i >> j) & 1):
            for l in range(m+1):
                kari[l] += s_list[j][l]

    check = 0
    for j in range(1,m + 1):
        if kari[j] < x:
            check = 1
            break
    if check == 0 and (kari[0] < kakaku or kakaku == -1):
        kakaku = kari[0]

print(kakaku)

Measured memory_bytes: 9364
import java.util.Scanner;
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int i = 1;
while(true) {
    int x = sc.nextInt();
    if(x == 0) break;
    System.out.println("Case " + (i++) + ": " + x);
}
}
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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; }

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;
}

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

  string s;
  cin >> s;

  string ans;
  ans = "";
  rep(i, s.length()){
    ans += 'x';
  }

  cout << ans << endl;

  

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define null NULL
#define mp make_pair
#define pb(a) push_back(a)
#define sz(a) ((int)(a).size())
#define all(a) a.begin() , a.end()
#define fi first
#define se second
#define relaxMin(a , b) (a) = min((a),(b))
#define relaxMax(a , b) (a) = max((a),(b))
#define SQR(a) ((a)*(a))
#define PI 3.14159265358979323846
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

const int SZ = 100;
char tbl[SZ][SZ + 1];

void Fill(int rs, int re, int cs, int ce, char val){
  for(int i = rs;i < re;++i)
    for(int j = cs;j < ce;++j)
      tbl[i][j] = val;
}

int main(){
  int a, b;  // . #
  scanf("%d%d", &a, &b);
  --a, --b;

  Fill(0, SZ / 2, 0, SZ, '.');
  Fill(SZ / 2, SZ, 0, SZ, '#');

  deque<pii> cells;
  for(int i = 0;i < SZ;i += 2)
    for(int j = 0;j < SZ;j += 2)
      cells.pb(mp(i, j));

  while(a > 0){
    auto cell = cells.back();
    cells.pop_back();
    tbl[cell.fi][cell.se] = '.';
    --a;
  }

  while(b > 0){
    auto cell = cells[0];
    cells.pop_front();
    tbl[cell.fi][cell.se] = '#';
    --b;
  }

  printf("%d %d\n", SZ, SZ);
  for(int i = 0;i < SZ;++i)
    printf("%s\n", tbl[i]);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

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

int main() {
	int n/*,ai[100]*/;
	cin >> n;

	vector<int> ai(n);

	for (int i = 0; i < n; i++) {
		cin >> ai[i];
	}
	/* for (int a = 0; a < n - 1; a++) {
		for (int b = a+1; b < n; b++) {
			if (ai[a] <= ai[b]) {
				int c = ai[a];
				ai[a] = ai[b];
				ai[b] = c;
			}
		}
	}*/

	sort(ai.rbegin(), ai.rend());

	/*rep(k, n) {
		cout << ai[k];
	}
	return 0;*/

	int suma=0, sumb=0;

	for (int j = 0; j < n; j++) {
		if (j % 2 == 0) {
			suma += ai[j];
		}
		else {
			sumb += ai[j];
		}
	}

	cout << suma - sumb;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
 
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> pii;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie();
	
	vector<ll> v;
	ll n, maxi = INT_MIN, mini = INT_MAX;
	cin >> n;
	for (ll i = 0; i < n; i++) {
		ll x;
		cin >> x;
		v.pb(x);
		maxi = max(maxi, x);
		mini = min(mini, x);
	}
	ll ans = INT_MAX;
	for (ll i = mini; i <= maxi; i++) {
		ll res = 0;
		for (auto x : v) {
			res += (x - i) * (x - i);
		}
		ans = min(ans, res);
	}
	cout << ans << '\n';
	
	return 0;
}


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



//// A
int main() {
    string s, t; cin >> s >> t;
    int a, b; cin >> a >> b;
    string res; cin >> res;
    if(res == s){
        a--;
        cout << a << " " << b;
    }else{
        b--;
        cout << a << " " << b;
    }
    return 0;

}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N;
    cin >> N;
    vector<int> v(N);
    for(int i = 0; i < N; ++i) {
        cin >> v[i];

    }

    LL res = 0;
    map<LL, int> mp;
    for(int i = N - 1; i >= 0; --i) {
        res += mp[v[i] + (i + 1)];
        mp[(i + 1) - v[i]]++;

    }
    cout << res << endl;
    return 0;
}



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

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

  int n;
  string s;
  cin >> n >> s;

  int ans = 0;
  for(int i = 1; i < n; ++i) {
    string x = s.substr(0, i);
    string y = s.substr(i, n-i);

    int cnt = 0;
    for(char c = 'a'; c <= 'z'; ++c) {
      bool isFoundx = false, isFoundy = false;
      rep(j, x.length()) {
        if(c==x[j]) isFoundx = true;
      }
      rep(j, y.length()) {
        if(c==y[j]) isFoundy = true;
      }
      if(isFoundx && isFoundy) ++cnt;
    }
    ans = max(ans, cnt);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
abcd = gets.chomp

["+", "-"].each do |s3|
  ["+", "-"].each do |s2|
    ["+", "-"].each do |s1|
      sss = String.new(abcd)
      sss[3,0] = s3
      sss[2,0] = s2
      sss[1,0] = s1
      if eval(sss) == 7
        puts sss + "=7"
        exit
      end
    end
  end
end


Measured memory_bytes: 1788
s = raw_input()
countA = 0
flag = 0
count = 0
for c in s:
	if c == 'A':
		if(flag == 2):
			countA = 1
			flag = 1
		else:
			countA += 1
			flag = 1
	else:
		if(flag == 1 and c =='B'):
			flag = 2
		elif(flag == 2 and c == 'C'):
			count += countA
			flag = 1
		else:
			flag = 0
			countA = 0
print(count)

Measured memory_bytes: 2948
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define inf 1000000000
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#define meM(y,a) memset(y,a,sizeof y)
#define sC(a) scanf("%d",&a)
#define alL(a) a.begin(),a.end()
#define prinT(a,sz)  cout<<a[0];for(int i=1;i<sz;i++)cout<<" "<<a[i];cout<<endl
#define ranD srand(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int>pi;
typedef pair<ll,ll>pll;
//int fx[]={0,0,1,-1};
//int fy[]={1,-1,0,0};
//int gx[]={0,0,1,1,1,-1,-1,-1};
//int gy[]={1,-1,0,1,-1,0,1,-1};
const int N=100010;

int main()
{
    IOS;
    string s;cin>>s;
    int n=s.length();
    int cnt=0;
    int i=0;
    int ss=0,t=0;
    while(i<n)
    {
//        cout<<"i = "<<i<<endl;
        while(s[i]=='S'){
            ss++,i++;
            if(i==n)break;
        }
        while(s[i]=='T'){
            i++,t++;
            if(i==n)break;
        }
        cnt+=min(ss,t);
        ss=max(ss-t,0);
        t=0;
    }
    cout<<n-cnt*2<<endl;
}
/*
sttssttsst
SSSSTTSSTTTS
*/







Measured memory_bytes: 3640
N = int(input())
A = input()
A = [x for x in A]
B = input()
B = [x for x in B]
C = input()
C = [x for x in C]

total = 0

for i in range(N):
  if(A[i]==B[i] and A[i]!=C[i]):
      total = total+1
  if(A[i]==C[i] and A[i]!=B[i]):
      total =  total + 1
  if(B[i]==C[i] and A[i]!=B[i]):
      total = total + 1
  if(A[i]==B[i] and A[i]==C[i]):
      total = total
  if(A[i]!=B[i] and A[i]!=C[i] and B[i]!=C[i]):
      total = total + 2

print(total)


Measured memory_bytes: 3064
#include<iostream>
using namespace std;
 int main(){
 int k,a,b;
   cin>>k>>a>>b;
   bool he=false;
   for(int i=a;i<=b;i++){
     if(i%k==0){
       cout<<"OK";
       he=true;
       break;}}
   if(!he){
     cout<<"NG";}
 
 }

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

bool finished = false;

const int MALE = 1;
const int FEMALE = 2;
const int END_OF_GAME = 3;

int get ( int x ) {
  string tmp;
  cout << x << endl;
  cin >> tmp;
  
  if ( tmp == "Male" ) return MALE;
  if ( tmp == "Female" ) return FEMALE;
  if ( tmp == "Vacant" ) exit(0);
  
  return 0;
}

int main() {

  int n;
  
  cin >> n;
  
  int g1 = get(0);
  std::ignore = get(n-1);
  
  if ( g1 == MALE ) {
    // M W M W
    int l = 0 ;
    int r = n - 1;
    while ( l + 1 < r ) { 
      int med = ( l + r ) / 2;
      int tmp = get ( med );
      
      if ( med % 2 == 0 ) {
        if ( tmp == MALE )
          l = med;
        else
          r = med;
      }
      else {
          if ( tmp == FEMALE )
            l = med;
          else
            r = med;
      }
    }
  }
  else {
    // W M W M 
    int l = 0 ;
    int r = n - 1;
    while ( l + 1 < r ) { 
      int med = ( l + r ) / 2;
      int tmp = get ( med );
      
      if ( med % 2 == 1 ) {
        if ( tmp == MALE )
          l = med;
        else
          r = med;
      }
      else {
          if ( tmp == FEMALE )
            l = med;
          else
            r = med;
      }
    }
    
  }
  
  

  return 0;
}


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

int main(){
  int n;
  std::cin >> n;
  std::vector<int> p;
  int temp;
  int cnt = 0;
  while(std::cin >> temp)
    p.push_back(temp);
  for(auto i = p.begin()+1; i < p.end()-1; ++i)
    if((*(i-1)<*i && *i<*(i+1))||(*(i+1)<*i && *i<*(i-1)))
      ++cnt;
  std::cout << cnt << std::endl;
  return 0;
}


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

using namespace std;

#define int long long

void solve() {
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int t;
        cin >> t;
        n -= t;
    }
    if (n < 0) cout << -1;
    else cout << n;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 3652
class UnionFind():
  def __init__(self,n):
    self.n=n
    self.parents=[-1]*n
  def find(self,x):
    if self.parents[x]<0:
      return x
    else:
      self.parents[x]=self.find(self.parents[x])
      return self.parents[x]
  def unite(self,x,y):
    x=self.find(x)
    y=self.find(y)
    if x==y:
      return
    if self.parents[x]>self.parents[y]:
      x,y=y,x
    self.parents[x]+=self.parents[y]
    self.parents[y]=x
  def size(self,x):
    return -size.parents[self.find(x)]
  def same(self,x,y):
    return self.find(x)==self.find(y)
  def members(self,x):
    root=self.find(x)
    return [i for i in range(self.n) if self.find(i)==root]
  def roots(self):
    return [i for i,x in enumerate(self.parents) if x<0]
  def group_count(self):
    return len(self.roots())
  def all_group_members(self):
    return {r:self.members(r) for r in self.roots()}
n,m=map(int,input().split())
p=list(map(int,input().split()))
uf=UnionFind(n)
for _ in range(m):
  x,y=map(int,input().split())
  uf.unite(x-1,y-1)
ans=0
for i in range(n):
  if p[i]-1==i or uf.same(i,p[i]-1):
    ans+=1
print(ans)

Measured memory_bytes: 14452
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 1e5 + 10 , P = 1e9 + 7;
int l[N] , r[N] , a[N] , b[N] , n;

int main(){
  cin >> n;
  rep(i,1,n+1) cin >> a[i];
  rep(i,1,n+1) cin >> b[i];
  rep(i,1,n+1) l[i] = 1 , r[i] = P;
  rep(i,1,n+1) {
    if(a[i] != a[i-1])
      l[i] = a[i] , r[i] = a[i];
    else
      r[i] = a[i];
  }
  per(i,1,n+1) {
    if(b[i] != b[i+1])
      l[i] = max(l[i] , b[i]) , r[i] = min(r[i] , b[i]);
    else
      r[i] = min(r[i] , b[i]);
  }
  int ans = 1;
  rep(i,1,n+1) {
    if(l[i] <= r[i])
      ans = ll(ans) * (r[i] - l[i]+ 1) % P;
    else
      ans = 0;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, hun, ten, one;
  cin >> a;
  hun = a /100;
  ten = (a - 100 * hun) / 10;
  one = a - 100 * hun - 10 * ten;
  cout << hun + ten + one << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long int lli;
typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<pll> vop;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define REP(i,a,b) for( long long i=a;i<b;i++)
#define REPR(i,a,b) for(int i=a;i>=b;i--)
#define adb(a) for(auto ii:a) cout << ii << " "; cout << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define endl "\n"
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define PI 3.14159265358979323846
const ll MAXN = 100007;
const ll p = 1000000007;

struct LessSecond
{
    template<typename T, typename U>
    bool operator()(const std::pair<T, U> &x, const std::pair<T, U> &y) const
    {
        return x.second < y.second;
    }
};

ll power(ll a, ll b, ll m) { ll ans = 1; a = a % m; while (b) { if (b & 1) ans = (ans * a) % m; b /= 2; a = (a * a) % m; } return ans; }

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

ll modInverse(ll a, ll m) { ll g = __gcd(a, m); return power(a, m - 2, m); }


int main()
{


    fastIO;
    int test = 1;
    //cin >> test;
    while (test--)
    {
        int n, ans = 0;
        cin >> n;
        map<int, int>m;
        REP(i, 1, 101)
        {
            REP(j, 1, 101)
            {
                REP(k, 1, 101)
                {
                    int x = i * i + j * j + k * k + i * j + j * k + i * k;
                    m[x]++;
                }
            }
        }
        REP(i, 1, n + 1)
        cout << m[i] << endl;
    }
    return 0;
}



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

int main() {
  int N;
  vector<int> a;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int b;
    cin >> b;
    a.push_back(b);
  }
  int mb = a.at(0);
  int mbindex = 0;
  int min = -1;
  int count = 0;
  for (int i = 0; i < N; i++) {
    if (a.at(i) == count + 1) count += 1;
  }
  if (count == 0)
    cout << -1;
  else
    cout << N - count;
  return 0;
}

Measured memory_bytes: 1400
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] a = new int[N];
		int[] b = new int[N];
		int ans = 0;

		for(int i=0; i<N; i++) {
			a[i] = sc.nextInt();
			b[i] = 0;
			while(a[i]%2 == 0) {
				a[i] = a[i]/2;
				b[i] ++;
			}
			ans += b[i];
		}
		System.out.println(ans);

	}

}


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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    ll N;
    cin >> N;
    ll A[100100], B[100100];
    REP(i,N+1) cin >> A[i];
    REP(i,N) cin >> B[i];

    ll count = 0;
    REP(i,N){
        if(A[i] <= B[i]){
            count += A[i];
            B[i] -= A[i];
            if(A[i+1] <= B[i]){
                count += A[i+1];
                A[i+1] = 0;
            }
            else{
                count += B[i];
                A[i+1] -= B[i];
            }
        }
        else{
            count += B[i];
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,ans=0;
    string s;
    cin>>s;
    for(i=0;i<s.size();i++)
    {
        if(s[i]=='+')
            ans++;
        else
            ans--;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3632