akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <string>
#include <deque>
#include <memory.h>

#define rep(idx, max)			for(int idx = 0, idx##Max = (max); idx < idx##Max; idx ++)
#define rrep(idx, min, max)	for(int idx = (min), idx##Max = max; idx < idx##Max; idx ++)
#define erep(idx, min, max)	for(int idx = (min), idx##Max = max; idx <= idx##Max; idx ++)
#define rev(idx, max)			for(int idx = (max) - 1; idx >= 0; idx --)
#define rrev(idx, min, max)	for(int idx = (max) - 1, idx##Min = (min); idx >= idx##Min; idx --)
#define erev(idx, min, max)	for(int idx = (max), idx##Min = (min); idx >= idx##Min; idx --)
#define foreach(it, obj)	for(auto it = obj.begin(), it##End = obj.end(); it >= it##End; it ++)
#define CLIP(x, min_, max_)	std::max(min_, std::min(max_, x))

using namespace	std;

typedef std::vector<int>	VEC;

VEC	g_signal;
VEC	g_codeBook;

#define	MAX_SIG_LEN	32768
#define	MAX_CB_LEN	32
#define	MAX_MOD_VAL	256

inline int Pow2i(int x)	{	return(x * x);	}
int	Solve()
{
	static	int	cache[MAX_SIG_LEN][MAX_MOD_VAL];
	
	::memset(cache, 0x7F, sizeof(cache));	// Fill chache with '0x7F', thus all element of 'cache' will be 0x7F7F7F7F.
	cache[0][128]	= 0;
	
	rep(i, g_signal.size())
	{
		rep(y, MAX_MOD_VAL)
		{
			if(cache[i][y] == 0x7F7F7F7F)	{	continue;	}
			rep(k, g_codeBook.size())
			{
				int yn = CLIP(y + g_codeBook[k], 0, 255);
				cache[i + 1][yn]	= min(cache[i + 1][yn], cache[i][y] + ::Pow2i(g_signal[i] - yn));
			//	::printf("y: %d, cb: %d, yn: %d, c_{i}: %d, c_{i+1}: %d\n", y, g_codeBook[k], yn, cache[i][y], cache[i + 1][yn]);
			}
			//::puts("");
		}
	}
	return(*min_element(cache[g_signal.size()], cache[g_signal.size()] + MAX_MOD_VAL));
}

int main()
{
	int sigLen, cbLen;
	while(cin >> sigLen >> cbLen, sigLen)
	{
		g_codeBook.resize(cbLen);
		g_signal.resize(sigLen);
		rep(i, g_codeBook.size())	{	cin >> g_codeBook[i];	}
		rep(i, g_signal.size())	{	cin >> g_signal[i];	}
		::printf("%d\n", ::Solve());
	}
}

Measured memory_bytes: 34044
n = int(input())
a = list(map(int, input().split()))
c_4 = 0
c_2 = 0
for i in range(n):
  if a[i] % 4 == 0:
    c_4 += 1
  elif a[i] % 2 == 0:
    c_2 += 1
if c_4 >= n // 2:
  print('Yes')
elif c_4 * 2 + c_2 >= n:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 15020
#include <stdio.h>
#include <string.h>

#define WEATHER_LEN 8

int main(void) {
    char weather[WEATHER_LEN];
    int len;

    fgets(weather, WEATHER_LEN, stdin);
    len = strlen(weather);
    if (weather[len-1] == '\n') {
        weather[len-1] = '\0';
        len--;
    }

    if (strncmp(weather, "Sunny", 5) == 0) {
        printf("Cloudy\n");
    } else if (strncmp(weather, "Cloudy", 6) == 0) {
        printf("Rainy\n");
    } else if (strncmp(weather, "Rainy", 5) == 0) {
        printf("Sunny\n");
    } else {
        printf("Illegal weather: %s\n", weather);
    }

    return 0;
}


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

int main() {

  string S;
  cin >> S;

  vector<int> s(26);

  for (int i = 0; i < S.size(); i++) {
    s[(int) S.at(i) - 97]++;
  }

  string result = "";
  
  for (int i = 0; i < 26; i++) {
    if (s[i] == 0) {
      result += char(i+97);
      break;
    }
  }

  if (result == "") {
    cout << "None" << endl;
  } else {
    cout << result << endl;
  }

}

Measured memory_bytes: 512
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        String s = sc.next();
        String s0 = s.substring(0, (s.length() - 1) / 2);
        String s1 = s.substring((s.length() + 1) / 2);
        System.out.println(isKaibun(s0) && s0.equals(s1) ? "Yes" : "No");
    }

    static boolean isKaibun(String str) {
        return str.length() <= 1 ? true :
                str.charAt(0) == str.charAt(str.length() -1) ? isKaibun(str.substring(1, str.length() - 1)) : false;
    }
}


Measured memory_bytes: 22608
let cnt = ref 0

let insertion_sort (n:int) ?(gap=1) (a:int array) =
  for i=gap to n-1 do
    let v = a.(i) in
    let j = ref (i - gap) in
    while !j >= 0 && a.(!j) > v do
      a.(!j+gap) <- a.(!j);
      j := !j - gap;
      incr cnt;
    done;
    a.(!j+gap) <- v
  done;
  a

let shell_sort (array:int array) (n: int) =
  let rec gen_gaps = function
      [] -> gen_gaps [1]
    | h::t when h > n -> t
    | h::_ as l -> gen_gaps ((float_of_int h |> ( *. ) 2.25 |> int_of_float) ::l) in
  let gaps = if n > 701 then gen_gaps [701;301;132;57;23;10;4;1]
    else List.filter ((>=) n) [701;301;132;57;23;10;4;1] in
  let m = List.length gaps in
  let rec loop a = function
      [] -> a
    | h::t -> loop (insertion_sort n ~gap:h a) t in
  let a = loop array gaps in
  Printf.printf "%d\n" m;
  Array.iteri
    (fun i x -> Printf.printf (if i=m-1 then "%d\n" else "%d ") x)
    (Array.of_list gaps);
  Printf.printf "%d\n" !cnt;
  a

let () =
  let n = read_int () in
  let rec read a = function
      i when i = n -> a
    | i -> a.(i) <- (read_int ());
      read a (i+1) in
  let a = read (Array.make n 0) 0 in
  Array.iter (Printf.printf "%d\n") (shell_sort a n)

Measured memory_bytes: 12464
list_1 = [int(input()) for i in range(5)]
k = int(input())

list_1.sort(reverse=True)
ans = 0

for j in list_1:
    ind = list_1.index(j)
    while ind <= 3:
        ind += 1
        if k < j - list_1[ind]:
            ans += 1
        
if ans == 0:
    print('Yay!')
else:
    print(':(')

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

#define TRUE 1
#define FALSE 0

void shift_num(int *num) {
	int i = 0;
	while (*(num + i) != -1) {
		*(num + i) = *(num + i + 1);
		i++;
	}
}

int main(void) {
	int n, sw;
	int *num, *answer;
	scanf("%d", &n);
	num = (int *)malloc(sizeof(int)*(n+1));
	answer = (int *)malloc(sizeof(int)*n);
	for (int i = 0; i < n; i++) {
		scanf("%d", num + i);
	}
	num[n] = -1;
	for (int i = 0; i < n; i++) {
		sw = FALSE;
		for (int j = n - 1 - i; j >= 0; j--) {
			if (num[j] == j + 1) {
				answer[i] = j + 1;
				shift_num(num + j);
				sw = TRUE;
				break;
			}
		}
		if (sw == FALSE) {
			break;
		}
	}
	if (sw == TRUE) {
		for (int i = n - 1; i >= 0; i--) {
			printf("%d\n", answer[i]);
		}
	}
	else if (sw == FALSE) {
		printf("%d\n", -1);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

struct abcd {int a; int b; int c; int d;};

void dfs(vector<abcd>& v, vector<int>& acc, int N, int M, ll& minv){
  if(acc.size() == N + 1) {
    ll s = 0;
    for(auto ab : v) {
      if(acc[ab.b] - acc[ab.a] == ab.c) {
        s += ab.d;
      }
    }
    chmax(minv, s);
    return;
  }
  
  for(int i=acc.back(); i<=M; i++) {
    acc.push_back(i);
    dfs(v, acc, N, M, minv);
    acc.pop_back();
  }
}

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  int N, M, Q;
  cin >> N >> M >> Q;
  //N = 10; M = 10;
  vector<abcd> v(Q);
  rep(i, Q) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    v.push_back({a, b, c, d});
  }
  
  vi acc;
  ll minv = 0;
  acc.push_back(1);
  dfs(v, acc, N, M, minv);
  fin(minv);
}

Measured memory_bytes: 3660
#include<stdio.h>
int a, b;
int main(){
  scanf("%d%d", &a, &b);
  if(a==0 || b==0){
    puts("Zero");
  }else if(a<0 && b>0){
    puts("Zero");
  }else if(a>0){
    puts("Positive");
  }else if((a&1)^(b&1)){
    puts("Positive");
  }else{
    puts("Negative");
  }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

ll solve(ll n, vector<ll> a, vector<ll> b) {
    vector<pll> p;
    vector<ll> dp(n + 1, -(1ll << 60));
    dp[n] = 0;
    REP(i, 3) {
        RREPS(j, n) {
            if (0 <= j - a[i]) {
                chmax(dp[j - a[i]], dp[j] + b[i]);
            }
        }
    }
    ll ans = 0;
    REP(i, n + 1) {
        chmax(ans, dp[i] + i);
    }
    return ans;
}

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    while(cin >> n){
        vector<ll> a(3), b(3);
        REP(i, 3) cin >> a[i];
        REP(i, 3) cin >> b[i];
        cout << solve(solve(n, a, b), b, a) << endl;
    }
    return 0;
}


Measured memory_bytes: 195584
using System;

namespace ABC105B
{
    class Program
    {
        static string ans = "No";
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Recursive(n);

            Console.WriteLine(ans);
        }

        static void Recursive(int n)
        {
            if (n == 0)
            {
                ans = "Yes";
                return;
            }
            else if (n < 3)
            {
                return;
            }
            Recursive(n - 4);
            Recursive(n - 7);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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() {
    string s,t;
    cin >> s >> t;
    unordered_map<char,vector<char>> m;
    unordered_map<char,vector<char>> n;
    rep(i,s.length()){
        if(find(m[s[i]].begin(),m[s[i]].end(),t[i]) == m[s[i]].end())m[s[i]].push_back(t[i]);
        if(find(n[t[i]].begin(),n[t[i]].end(),s[i]) == n[t[i]].end())n[t[i]].push_back(s[i]);
    }
    for(auto a : m){
        if(a.second.size() >= 2){
            cout << "No\n";
            return 0;
        }
    }
    for(auto a : n){
        if(a.second.size() >= 2){
            cout << "No\n";
            return 0;
        }
    }
    cout << "Yes\n";
    return 0;
}

Measured memory_bytes: 776
//Heaplax
//别让自己后悔
#include<bits/stdc++.h>
#define N 100001
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
const int S=(1<<19)-1;
int n,ans,f[N];
int cnt,head[N],nxt[N+N],to[N+N];
void dfs(int u,int fa)
{
	int mx=0;
	for(int i=head[u],v;i;i=nxt[i])
		if((v=to[i]) != fa)
		{
			dfs(v,u);
			mx=max(mx,f[u]&f[v]);
			f[u]|=f[v];
		}
	int mn=0;
	while((f[u]>>mn&1) || ((1<<mn)<=mx))++mn;
	while(f[u]>>mn&1)++mn;
	// f[u]=(f[u]>>mn<<mn)|(1<<mn);
	// ans=max(ans,mn);
	for(int i=30;;--i)
		if(i<mn || (mx>>i&1))
		{
			++i;
			// f[u]&=S-((1<<i)-1);
			// f[u]|=1<<i;
			f[u]=(f[u]>>i<<i)|(1<<i);
			ans=max(ans,i);
			// cerr<<u<<" "<<i<<endl;
			break;
		}
}
int main()
{
	re(n);
	for(int i=1,u,v;i<n;++i)
	{
		re(u),re(v);
		add_edge(u,v);
		add_edge(v,u);
	}
	dfs(1,0);
	printf("%d\n",ans);
}
/*
10
1 2
2 3
3 4
4 5
5 6
6 7
4 8
8 9
9 10
*/


Measured memory_bytes: 7168
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int x;
	int ans=0;
	while(n--)
	{
		cin>>x;
		if(x%2==0)
		{
			while(x%2!=1)
			{
				x/=2;
				ans++;
			}
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String C = sc.next();
        String[] alphabets = {"a", "b", "c", "d", "e", "f", "g", "h"
                , "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s"
                , "t", "u", "v", "w", "x", "y", "z"};
        for (int i = 0; i < alphabets.length; i++) {
            if (C.equals(alphabets[i])) {
                if (i == alphabets.length -1) {
                    System.out.println(alphabets[0]);
                } else {
                    System.out.println(alphabets[i + 1]);
                }
            }
        }
    }
}

Measured memory_bytes: 22612
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())

A1 *= T1
B1 *= T1
A2 *= T2
B2 *= T2

if A1 > B1:
    A1, A2, B1, B2 = B1, B2, A1, A2

if A1 + A2 == B1 + B2:
    print('infinity')
elif A1 + A2 < B1 + B2 or A1 == A2:
    print(0)
else:
    def check(c):
        return c * (A1 + A2) + A1 >= c * (B1 + B2) + B1
    
    l = 0
    h = B1 + B2
    while l < h:
        mid = l + (h - l) // 2
        if check(mid):
            h = mid
        else:
            l = mid + 1

    
    print(2*l-(l * (A1 + A2) + A1 != l * (B1 + B2) + B1))


Measured memory_bytes: 38384
import java.util.Scanner;

class Main {
    public void cubic() {
        Scanner sc = new Scanner(System.in);
        int arg = sc.nextInt();

        int i=0;
        int h=0;
        for (i = arg; i >= 3600; h++) {
            i -= 3600;
        }
   //     System.out.println("i="+i);

        int m = 0;
        for (; i >= 60; m++) {
            i -= 60;
        }
                                        
        System.out.println(h+":"+m+":"+i);
    }
    
    public static void main(String[] args){
    new Main().cubic();
    }
}

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

const int C = 1000000;
bool isprime[C];
vector<int> V;

bool prime(int x) {
  if (x < C) return isprime[x];
  for (auto y : V) {
    if (x % y == 0) return false;
  }
  return true;
}

int main() {
  fill(isprime, isprime+C, true);
  isprime[0] = isprime[1] = false;
  for (auto i = 2; i < C; i++) {
    if (isprime[i]) {
      V.push_back(i);
      int j = 2;
      while (i*j < C) {
        isprime[i*j] = false;
        j++;
      }
    }
  }
  int n;
  cin >> n;
  int A[10010];
  for (auto i = 0; i < n; i++) {
    cin >> A[i];
  }
  int ans = 0;
  for (auto i = 0; i < n; i++) {
    if (prime(A[i])) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4320
N = int(input())
A = list(map(int,input().split()))
print(*A)
for i in range(1,N):
    v = A[i]
    j = i-1
    while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
    A[j+1] = v
    print(*A)


Measured memory_bytes: 5980
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

    /**
     * 本処理を実行します。
     */
    public static void execute() {
        Scanner sc = new Scanner(System.in);

        int n = nextInt(sc);
        Map<Integer, Integer> annMap = new HashMap<>(n);

        for (int i = 0; i < n; i++) {
            putCountMap(annMap, sc.nextInt());
        }

        int m = nextInt(sc);

        for (int i = 0; i < m; i++) {
            Integer t = nextInt(sc);
            Integer annT = annMap.get(t);

            if (annT == null || annT == 0) {
                out("NO");
                return;
            } else {
                annMap.put(t, annT - 1);
            }
        }

        out("YES");
    }

    private static void putCountMap(Map<Integer, Integer> map, int value) {
        if (map.containsKey(value)) {
            map.put(value, map.get(value) + 1);
        } else {
            map.put(value, 1);
        }
    }

    /**
     * 次の標準入力をintで受け取ります。
     * @return 標準入力値(int)
     */
    public static int nextInt(Scanner sc) {
        return sc.nextInt();
    }

    /**
     * 次の標準入力をStringで受け取ります。
     * @return 標準入力値(String)
     */
    public static String nextString(Scanner sc) {
        return sc.next();
    }

    /**
     * 次の標準入力を指定回数分intで受け取ります。
     * @param n 取得回数
     * @return 取得した標準入力値の配列(int)
     */
    public static int[] nextInts(Scanner sc, int n) {
        int[] arr = new int[n];

        for (int i = 0; i < n; i++) {
            arr[i] = nextInt(sc);
        }

        return arr;
    }

    /**
     * 標準出力にオブジェクトを出力します。
     * @param o 出力対象
     */
    public static void out(Object o) {
        System.out.println(o);
    }

    public static void main(String[] args) {
        execute();
    }
}

Measured memory_bytes: 130852
#include<stdio.h>
int main()
{
    int a=0,b=0,c=0,i,k;
    scanf("%d %d %d",&a,&b,&c);
    if(a<b)
    {
        k=a;a=b;b=k;
    }
    if(a<c)
    {
        k=a;a=c;c=k;
    }
    if(b<c)
    {
        k=b;b=c;c=k;
    }
    k=a-b;b=a;c=c+k;
    while(a!=c)
    {
        if((a-c)%2==1)
        {a++;b++;}
        else
            c=c+2;
        k++;
    }
    printf("%d\n",k);
    return 0;
}


Measured memory_bytes: 128
import sys

n, m = map(int, input().split())
key = [-1 for i in range(n)]
for i in range(m):
  s, c = map(int, input().split())
  if key[s-1] == -1:
    key[s-1] = c
  else:
    if key[s-1] == c:
      continue
    else:
      print(-1)
      sys.exit()

for i in range(n):
  if key[i] == -1:
    if i != 0:
      key[i] = 0
    elif n == 1:
      key[i] = 0
    else:
      key[i] = 1
  key[i] = str(key[i])

ans = int("".join(key))
if 10**(n-1) <= ans < 10**n:
  print(ans)
elif n == 1 and ans == 0:
  print(0)
else:
  print(-1)

Measured memory_bytes: 3064
using System;

namespace ABC073B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int res = 0;

            for (int i = 0; i < N; i++)
            {
                string[] bufs = Console.ReadLine().Split(' ');
                int left = int.Parse(bufs[0]);
                int right = int.Parse(bufs[1]);
                res += right - left + 1;
            }

            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <string>
#include <queue>

using namespace std;

int main() {
	queue<int> q;
	string a;
	while (true) {
		getline(cin, a);
		if (a[0] == '0') {
			break;
		}
		int counter = 0;
		int b = 0;
		int sum = 0;
		for (int i = 0; i <= a.size(); i++) {
			if (a[i] >= '0' && a[i] <= '9') {
				b *= 10;
				b += a[i] - '0';
			} else {
				if (b > 10) {
					b = 10;
				} else if (b == 1) {
					counter++;
				}
				sum += b;
				b = 0;
			}
		}
		while (counter > 0) {
			if (sum + 10 <= 21) {
				sum += 10;
				counter--;
			} else {
				break;
			}
		}
		if (sum > 21) {
			sum = 0;
		}
		q.push(sum);
	}
	while (!q.empty()) {
		cout << q.front() << endl;
		q.pop();
	}
	return 0;
}

Measured memory_bytes: 1180
import math
a, b, h, m = map(int, input().split())
tha, thb = math.pi / 6 * (h + m / 60), m / 30 * math.pi
print((a**2 + b**2 - 2*a*b*math.cos(max(tha, thb) - min(tha, thb)))**0.5)

Measured memory_bytes: 9484
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();
        int k = sc.nextInt();
        System.out.println(e-a > k ? ":(" : "Yay!");
    }
}

Measured memory_bytes: 23892
use proconio::input;

fn main() {
	input! {
		n: usize,
		t: usize,
		tn: [usize; n],
	}

	let mut sum = 0usize;
	for i in 1..n {
		sum += std::cmp::min(tn[i] - tn[i-1], t);
	}
	println!("{}", sum + t);
}


Measured memory_bytes: 5500
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> box(3, 0);
  int N;
  cin >> box[0] >> box[1] >> box[2] >> N;
  int ans = 0;
  int rest = 0;
  for (int i = 0; i <= N; i++) {
    for (int j = 0; j <= N; j++) {
      rest = N - box[0] * i - box[1] * j;
      if (rest >= 0 && (rest % box[2] == 0)){
       ++ans;
      //  cout << i << " "<<j <<" " <<rest % box[2]<<endl;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

int A[SIZE];

int main() {
  int N, M, V, P;

  scanf("%d%d%d%d", &N, &M, &V, &P);

  for (int i=0; i<N; i++) {
    scanf("%d", A+i);
  }

  sort(A, A+N);

  ll S = 0, Ssize = 0;

  int ans = P - 1;

  for (int i=N-P; i>=0; i--) {
    debug(A[i]);
    int x = A[i];

    if (A[N-P] > x + M) break;

    ll t = (V - 1) - (P - 1) - i;

    debug(t);

    if (t <= 0) {
      ans++;
    } else {
      debug(Ssize * (x + M));
      debug(Ssize * (x + M) - S);
      debug(t * V);
      if ( (Ssize * (x + M) - S) >= t * M )
        ans++;
    }

    S += A[i];
    Ssize++;
  }

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Scanner;
public class Main {
	static ArrayList<Integer> list;
	static ArrayList<Integer> listA;
	
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		list = new ArrayList<Integer>();
		listA = new ArrayList<Integer>();
		makePrimeList();
		makePrimeListA();
		while(true) {
			int n = stdIn.nextInt();
			if(n == 0) {
				 break;
			}
			if(n < 13) {
				System.out.println(0);
				continue;
			}
			int fm = 0;
			boolean al = false;
			
			
			for(int i = 0; i < listA.size(); i++) {
				if(al && listA.get(i) > n) {
					break;
				}
				if(listA.get(i) <= n) {
					al = true;
					fm = listA.get(i);
				}
			}
			System.out.println(fm);
			
		}
	}
	
	public static void makePrimeList() {
		boolean[] isPrime = new boolean[10000001];
		for(int i = 2; i < isPrime.length; i++) {
			isPrime[i] = true;
		}
		
		for(int i = 2; i< isPrime.length; i++) {
			if(isPrime[i]) {
				for(int j = i + i; j < isPrime.length; j += i) {
					isPrime[j] = false;
				}
			}
		}
		
		for(int i = 0; i < isPrime.length; i++) {
			if(isPrime[i]) {
				list.add(i);
			}
		}
	}
	
	public static void makePrimeListA() {
		for(int i = 0; i < list.size()-3; i++) {
			int a = list.get(i);
			int b = list.get(i + 1);
			int c = list.get(i + 2);
			int d = list.get(i + 3);
			
			if(a + 2 == b && a + 6 == c && a + 8 == d) {
				listA.add(d);
			}
		}
	}
	

}

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

using namespace std;

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

	vector<int> a(N, 0);

	int cnt, cnt2;
//	bool check = true;

	cin >> a[0];
	vector<int> b{ a[0] };

	for (cnt = 1; cnt < N; cnt++)
	{
		cin >> a[cnt];
		if (a[cnt]<=b[b.size()-1])
		{
			b.push_back(a[cnt]);
		}
		else
		{
			for (cnt2 = 0; cnt2 < b.size(); cnt2++)
			{
				if (a[cnt] > b[cnt2])
				{
					b[cnt2] = a[cnt];
					//				check = false;
					break;
				}
			}
		}
		
//		check = true;
	}

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

	return 0;
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
#define ll long long
#define ull unsigned long long
#define lli long long int
#define pb push_back
#define all(x) x.begin(),x.end()
ll mob=1000000007;
using namespace std;
int main()
{ 

string g;
cin>>g;
int q;cin>>q;int k=0;
deque<char> j;
FOR(i,(int)g.length())
j.push_back(g[i]);
while(q--)
{
    int n;
    cin>>n;
    if(n==1)
    {k++;
       
    }
    else if(n==2&& k%2==0)
    {
        int t;
        cin>>t;
        if(t==1)
        {
            char f;
            cin>>f;
           
            j.push_front(f);
            
        }
        else
        {
           char f;
            cin>>f;
           
            j.pb(f);
        }
    }
    else if(n==2&& k%2!=0)
    {   int t;
        cin>>t;
        if(t==2)
        {
             char f;
            cin>>f;
            j.push_front(f);
            
        }
        else
        {
             char f;
            cin>>f;
           j.pb(f);
        }
        
    }
}


if(k%2==0)
for(auto it=j.begin();it!=j.end();it++) cout<<*it;
else
{
  for(auto it=j.rbegin();it!=j.rend();it++) cout<<*it;
}

return 0;
}











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

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


int main() {
	cin.sync_with_stdio(false);
	ll A, B, C;
	cin >> A >> B >> C;
	if (A % 2 != 0 || B % 2 != 0 || C % 2 != 0) {
		cout << 0 << endl;
		return 0;
	}
	if (A == B&&B == C) {
		cout << -1 << endl;
		return 0;
	}
	int count = 0;
	while (A % 2 == 0 && B % 2 == 0 && C % 2 == 0) {
		
		ll a = B / 2 + C / 2;
		ll b = A / 2 + C / 2;
		ll c = A / 2 + B / 2;
		A = a;
		B = b;
		C = c;
		count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>

const int N = 1000000;
bool u[N];
int m;

int main() 
{
	scanf("%d", &m);
	int r = 7 % m, i = 1;
	while (r && !u[r]) {
		u[r] = 1;
		r = (10 * r + 7) % m;
		++i;
	}
	if (r) printf("-1\n");
	else printf("%d\n", i);
	return 0;
}


Measured memory_bytes: 2676
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class Combination:
    def __init__(self, n, mod):

        g1 = [1, 1]
        g2 = [1, 1]
        inverse = [0, 1]
        for i in range(2, n + 1):
            g1.append((g1[-1] * i) % mod)
            inverse.append((-inverse[mod % i] * (mod//i)) % mod)
            g2.append((g2[-1] * inverse[-1]) % mod)
        self.MOD = mod
        self.N = n
        self.g1 = g1
        self.g2 = g2
        self.inverse = inverse

    def __call__(self, n, r):
        if (r < 0 or r > n):
            return 0
        r = min(r, n-r)
        return self.g1[n] * self.g2[r] * self.g2[n-r] % self.MOD


class Mod:
    def __init__(self, m):
        self.m = m

    def add(self, a, b):
        return (a + b) % self.m

    def sub(self, a, b):
        return (a - b) % self.m

    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, pow(b, self.m-2, self.m))

    def pow(self, a, b):
        return pow(a, b, self.m)

@mt
def slv(N, K, A):

    M = Mod(10**9+7)
    C = Combination(10**5, 10**9+7)

    fmin = 0
    A.sort()
    for i in range(N):
        if N-1-i < K-1:
            break
        fmin = M.add(fmin, M.mul(C(N-1-i, K-1), A[i]))

    fmax = 0
    A.sort(reverse=True)
    for i in range(N):
        if N-1-i < K-1:
            break
        fmax = M.add(fmax, M.mul(C(N-1-i, K-1), A[i]))

    return M.sub(fmax, fmin)


def main():
    N, K = read_int_n()
    A = read_int_n()
    print(slv(N, K, A))


if __name__ == '__main__':
    main()


Measured memory_bytes: 98724
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;



int main() {
int a,b;
cin>>a>>b;
if(a*b%2==0){
    cout<<"Even"<<endl;
}
else{
    cout<<"Odd"<<endl;
}

return 0;
}




Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, huga, ans int
	a := []int{}
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&huga)
		if huga%2 == 0 {
			a = append(a, huga)
		}
	}
	if len(a) == 0 {
		fmt.Println(ans)
	} else {
		for _, i := range a {
			for {
				if i%2 == 1 || i == 1 {
					break
				}
				i = i / 2

				ans += 1
			}
		}
		fmt.Println(ans)
	}
}


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

using namespace std;

#define long long long
#define INF ((long) 2e18)
#define MOD ((long) (1e9 + 7))
#define umap unordered_map

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

    long t = 1;
    //cin >> t;

    while (t--) {
        long k;
        cin >> k;

        long x = 7 % k;
        long ans = 1;
        for (long i = 0; i < 2e6; i++) {
            if (x == 0) {
                printf("%lld\n", ans);
                return 0;
            }
            x = (10*x + 7) % k;
            ans++;
        }
        puts("-1");
    }
}


Measured memory_bytes: 3748
#include <iostream>
#include <string>

using namespace std;

int main(int argc, char const *argv[]) {
  string s;
  cin >> s;
  s.erase(s.begin(), s.begin() + s.find('A'));
  s.erase(s.begin() + s.rfind('Z')+1, s.end());
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

int n, k, a[11];

int main() {
	scanf("%d%d", &n, &k);
	for(int i=0;i<k;i++) {
		int x; scanf("%d", &x);
		a[x] = 1;
	}
	for(int i=n;;i++) {
		int chk = 1;
		int ti = i;
		while(ti) {
			if(a[ti % 10]) chk = 0;
			ti /= 10;
		}
		if(chk) {
			printf("%d\n", i);
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
using namespace std;
#define rep(i, n) for(int i=0; i<n; ++i)
typedef long long ll;
//必要な宣言
#define MAX 100000

//問題をよく読もう！
//論理的に考えよう！
//サンプルを確認しよう!
//絶対に諦めるな！
//工夫をしろ！
int main() {
  int N;
  cin >> N;

  if(!(N%2)) {
    cout << N << endl;
    return 0;
  }

  cout << N*2 << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 文字列の入力

		String s = null;
		switch(sc.next()){
			case "A":
				s="T";
				break;
			case "C":
				s="G";
				break;
			case "G":
				s="C";
				break;
			case "T":
				s="A";
				break;
		}

		// 出力
		System.out.println(s);
	}
}

Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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 gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

void solve()
{
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=1;i<=n;++i){
		ll x=n/i;
		ans+=x*(2*i+i*(x-1))>>1;
	}
	cout<<ans;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 3640
package main

import "fmt"

func main() {
	var n, t int
	fmt.Scan(&n, &t)
	ar := make([]int, n)
	for i := range ar {
		fmt.Scan(&ar[i])
	}
	sum := 0
	max := 0
	for _, v := range ar {
		if max <= v {
			sum += t
		} else {
			sum += v + t - max
		}
		max = v + t
	}
	fmt.Println(sum)
}


Measured memory_bytes: 4992
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			int r = sc.nextInt();
			
			if (n == 0 && r == 0) {
				break;
			}
			ArrayList<Integer> list = new ArrayList<Integer>();
			for (int i = 0; i < n; i++) {
				list.add(i+1);
			}
			for (int i = 0; i < r; i++) {
				int p = sc.nextInt();
				int c = sc.nextInt();
				for (int j = 0; j < c; j++) {
					int pop = list.remove(n+1-p-c);
					list.add(pop);
				}
			}
			System.out.println(list.get(list.size() - 1));
		}
	}
}

Measured memory_bytes: 30020
use std::io::*;
use std::str::FromStr;

// 入力関数
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect(("failed to parse token"))
}

fn main() {
    let a:i32 = read();
    let b:i32 = read();
    let c:i32 = read();
    let k:i32 = read();

    let mut k_flag:i32 = 0;
    let mut counter:i32 = 0;
    for i in (0..a) {
        if k_flag == k {
            break
        }
        counter +=1;
        k_flag += 1;
    }

    for i in (0..b) {
        if k_flag == k {
            break
        }
        k_flag += 1;
    }

    for i in (0..c) {
        if k_flag == k {
            break
        }
        counter -= 1;
        k_flag += 1;
    }

    println!("{}", counter);
}

Measured memory_bytes: 2120
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll A, B, N;
    cin >> A >> B >> N; 
    ll x = min(N, B-1);
    cout << A*x/B-A*(x/B);
}

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

int n;
bool ans = true;

int main() {
  cin >> n;
  vector<string> w(n);
  rep (i, n) {
    cin >> w[i];
  }
  rep (i, n-1) {
    if (w[i][w[i].size()-1] != w[i+1][0]) ans = false;
  }
  sort(w.begin(), w.end());
  rep (i, n-1) {
    if (w[i] == w[i+1]) ans = false;
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 3636
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt(),K=sc.nextInt(),X=sc.nextInt(),Y=sc.nextInt();
		int ans = 0;
		
		if(N>K){
	        ans = (X*K) + (Y*(N-K));
	    }
	    
	    else if(N<=K){
	        ans = X*N;
	    }
		
	    System.out.println(ans);
	}
}

Measured memory_bytes: 21844
#include <iostream>

using namespace std;
int main(){
	string s, t; cin >> s >> t;
	int a, b; cin >> a >> b;
	string u; cin >> u;
	if (s==u){
		a--;
	}
	else {
		b--;
	}
	cout << a << " " << b;
	return 0;
}

Measured memory_bytes: 256
/* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FASTIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define mp make_pair
#define pb push_back
#define sz(v) ((int)v.size())
#define all(v) v.begin(), v.end()
void parseArray(ll* A,ll n){ for ( ll K = 0; K < n; K++){ cin >> A[K]; } }
ll modInverse(ll a, ll b){ return 1<a ? b - modInverse(b%a, a)*b/a : 1; }
ll gcd(ll a, ll b){ return b?gcd(b, a % b):a; }
ll lcm(ll a, ll b){ return (a*b)/gcd(a, b); }
ld dist(ld x, ld y, ld a, ld b){ return sqrt((x-a)*(x-a) + (y-b)*(y-b)); }
void debug(ll* a, ll n) { for ( ll k = 0; k < n; k++ ){ cerr << a[k] << " ";} cout << "\n"; }
#define PI 3.14159265358979323846


int main(){
	FASTIO;
	ll n; cin >> n;
	ll occ[n + 1]; memset(occ, 0, sizeof occ);
	ll a[n - 1]; parseArray(a, n - 1);
	for ( int k = 0; k < n - 1; k++ ) occ[a[k]]++;
	for ( int k = 1; k <= n; k++ )
		cout << occ[k] << "\n";
	return 0;
}

Measured memory_bytes: 6716
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
   long long int i,n,j,k,x,y,sum=0;
   vector<long long int>v,u,w;
   cin>>k>>n;

   for(i=0;i<n;i++)
   {
       cin>>x;
       v.push_back(x);
   }

   for(i=0;i<v.size()-1;i++)
   {
       u.push_back(v[i+1]-v[i]);
   }
   u.push_back(v[0]+k-v[v.size()-1]);
   sort(u.begin(),u.end());
   for(i=0;i<u.size()-1;i++)
   {
       sum+=u[i];
   }
   cout<<sum<<endl;


    return 0;
}


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

long long my(long long x) {
    long long y;
    if(x % 2 == 0){
    y = x / 2 * (x + 1);
    }
  if(x % 2 == 1){
    y = (x + 1) / 2 * x;
    }
  
    return y;
}


int main() {
  long long N;
  cin >> N;
  long long a, b, c;
  long long ans;
  a = N / 3;
  b = N / 5;
  c = N / 15;
  
  ans = my(N) - 3 * my(a) - 5 * my(b) + 15 * my(c);
  
  cout << ans;
  
  
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,x;
	int a[111];
	cin>>n>>x;
	for(int i=0;i<n;i++)
	  cin>>a[i];
	for(int i=0;i<n;i++)
	{
		x-=a[i];
		if(x==0)
		{
		  cout<<i+2;
		  return 0;
	    }
	    else
	      if(x<0)
	      {
	      	cout<<i+1;
	      	return 0;
		  }
	}
	cout<<n+1;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<static_cast<int>(n);++i)
#define per(i, n) for(int i=static_cast<int>(n)-1;i>=0;--i)
#define eee(a) (cerr<<"[@"<<__LINE__<<"] "<<(#a)<<": "<<(a)<<'\n');
#define ppp(a) (cout<<(a)<<'\n'); 
#define cop(a) for(auto x:(a)){cerr<<(x)<<'\n';}
using ll = long long;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll inverse(ll n,ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}
template<class T>inline bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename T1,typename T2>ostream& operator<<(ostream& s,const pair<T1, T2>& p){return s <<"("<<p.first<<", "<<p.second<<")";}
template<typename T> ostream& operator<<(ostream& s,const vector<T>& v){s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i<v.size()-1)s<<", ";}s<<']';return s;}
template<typename T> istream& operator>>(istream& s,vector<T>& v){for(T& x:v)s>>x;return s;}

int main(){
    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    
    int a, b;
    cin >> a >> b;
    rep(i, 100000){
        if((int)(i*0.08) == a and (int)(i*0.10) == b){
            cout << i << '\n';
            return 0;
        }
    }
    cout << -1 << '\n';
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define pb push_back
#define pi acos(-1.0)

int main()
{
    ll i, j, a, b, k, n, m, cnt = 0;
    string s;
    cin >> n >> s;
    for(i = 0; i < n - 2; i++){
        if(s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
            cnt++;
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 3632
import java.util.*;

public class Main{
	static Scanner s=new Scanner(System.in);
	public static void main(String[] $){
		String v=s.next();
		for(char c='a';c<='z';++c){
			if(v.indexOf(c)<0){
				System.out.println(v+c);
				return;
			}
		}

		TreeSet<Character> set=new TreeSet<>();
		set.add(v.charAt(v.length()-1));

		for(int i=v.length()-2;i>=0;--i){
			char c=v.charAt(i);
			Character h=set.higher(c);
			if(h!=null){
				System.out.println(v.substring(0,i)+h);
				return;
			}
			set.add(c);
		}

		System.out.println(-1);
	}
}

Measured memory_bytes: 23508
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define MOD (1000000007)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

const ll INF = 1LL << 60;

int main(){
  int n; cin >> n;
  vi a(n); rep(i, n) cin >> a[i];

  sort(all(a));
  reverse(all(a));

  int ans1 = a[0];
  int ans2 = 0;
  for (int i = 1; i < n; i++) {
    if(abs((ans1+1)/2 - a[i]) <= abs((ans1+1)/2 - ans2)) ans2 = a[i];
  }

  std::cout << ans1 << " " << ans2 << '\n';
}


Measured memory_bytes: 640
from collections import Counter

N = int(input())
A = list(map(int, input().split()))

def canMake():
    if N == 2:
        return A == [1, 1]

    cntA = Counter(A)
    mi = min(A)
    mx = max(A)

    if mi < mx // 2:
        return False

    if mx % 2 == 0 and cntA[mi] > 1:
        return False
    if mx % 2 == 1 and cntA[mi] > 2:
        return False

    for i in range(mi + 1, mx + 1):
        if cntA[i] < 2:
            return False

    return True

print('Possible' if canMake() else 'Impossible')


Measured memory_bytes: 3316
#include<stdio.h>
int main()
{
char a[3],b[3];
  int c;
gets(a);
gets(b);
  for(int j=0;j<3;j++)
  {
  if(a[j]==b[j]) c=c+1;
  }
  printf("%d",c);
return 0;
}

Measured memory_bytes: 128