akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#include <deque>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define BRK(x) { (x); break; }
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define FLOOR(x) ((int)floor(((double)x)))
#define CEIL(x) ((int)ceil(((double)x)))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mt make_tuple
#define fi first
#define se second
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


int N, K;
int D[10];


bool judge(int x){
	do {
		int d = x%10;
		if(any_of(RNG(D, K), [d](int y){ return (y == d); })) return false;
	} while(x/=10);
	return true;
}


int solve(){
	int ans = N;
	while(true)
		if(judge(ans)) return ans;
		else ans++;
	return -1;
}


signed main(){
	cin >> N >> K;
	rep(i, 0, K) cin >> D[i];

	cout << solve() << endl;

	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

S = input()
a_list = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]
# a_list = list(reversed(a_list))
c = 0
for a in a_list:
    c += 1
    if S == a:
        ans = 7 - c + 1

print(ans)


Measured memory_bytes: 2940
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
int inp() {
    int x = 0, c;
    for (; (uint)((c = getchar()) - '0') >= 10; ) { if (c == '-') return -inp(); if (!~c) throw ~0; }
    do { x = (x << 3) + (x << 1) + (c - '0'); } while ((uint)((c = getchar()) - '0') < 10);
    return x;
}

#define SUM(a,b) { a += (b); if(a >= 1000000007) a -= 1000000007; }
int dp[2][10001][201];
int in[201];
int main(){
	int N = inp() , W = inp();
	
	for(int i = 1 ; i <= N ; i++) in[i] = inp();
	sort(in+1,in+N+1,greater<int>());
	in[0] = 99999;
	int x = 0 , y = 1;
	dp[x][0][0] = 1;
	
	for(int i = 1 ; i <= N ; i++){
		for(int j = 0 ; j <= W ; j++) for(int k = 0 ; k <= N ; k++) dp[y][j][k] = 0;
		for(int j = 0 ; j <= W ; j++) for(int k = 0 ; k <= N ; k++) SUM(dp[y][j][i],dp[x][j][k]);
		
		int w = in[i];
		for(int j = w ; j <= W ; j++)
			for(int k = 0 ; k < i ; k++)
				SUM(dp[y][j][k],dp[x][j-w][k]);
		swap(x,y);
	}
	
	int sum = 0;
	for(int i = 0 ; i <= W ; i++){
		for(int j = 0 ; j <= N ; j++){
			if(W < i+in[j]) SUM(sum,dp[x][i][j]);
		}
	}
	cout << sum << endl;
}

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

int n;
int a[110], i, j, aux, mid;

void rotireeee(){
    rotate(a,a+1,a+n);
}

int main()
{
    cin>>n;
    mid=n/2;
    if(n==2) {
        cout <<-1 <<'\n';
        return 0;
    }
    for(i=0; i<n; i++)
        a[i]=i+1;

    for(i=0; i<n; i++)
    {
        rotireeee();
        if(n%2==0 && i>=mid)
        {
            aux=a[mid-1];
            a[mid-1]=a[mid];
            a[mid]=aux;
        }

        for(j=0; j<n-1; j++)
            cout << a[j]<<" ";
        cout<<'\n';

        if(n%2==0 && i>=mid)
        {
            aux=a[mid-1];
            a[mid-1]=a[mid];
            a[mid]=aux;
        }
    }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass : Scanner
{
    static void Main()
    {
        int X = RInt();
        int num = X;
        while (true)
        {
            bool frag = true;
            for (int i = 2; i <= Sqrt(X); i++)
            {
                if (num % i == 0) frag = false;
            }
            if (frag)
            {
                WriteLine(num); return;
            }
            num++;
        }
    }
}



class Scanner
{
    public static int RInt() => int.Parse(Console.ReadLine());
    public static long RLong() => long.Parse(Console.ReadLine());
    public static string RString() => Console.ReadLine();
    public static double RDouble() => double.Parse(Console.ReadLine());

    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static string[] RStrings() => Console.ReadLine().Split();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static T1 ReadStream<T1>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadStream<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadStream<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadStream<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}


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

#ifndef ONLINE_JUDGE
	#define W(x, y) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << y;
#else
	#define W(x, y)
#endif

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vll vector<pll>
// #define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi acosl(-1)
#define ld long double
#define prime (1000000000 + 7)
#define INF 1000000000

using namespace std;

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

    ll n, x, res = 0;
    cin >> n >> x;
    vl vet(n);
    for(int i = 0; i < n; ++i){
        cin >> vet[i];
        x -= vet[i];
        res++;
    }
    sort(vet.begin(), vet.end());
    while (x >= vet[0]){
        x -= vet[0];
        res++;
    }
    cout << res << endl;
    

    return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>


// I/O
int get_uint() {
    int n = 0;
    int c = getchar_unlocked();
    if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) n = 10 * n + (c & 0xf), c = getchar_unlocked();
    return n;
}
//

// Union Find
typedef struct UnionFind {
    int parent[100000];
    int rank[100000];
    int size[100000];
} UnionFind;

void uf_init(UnionFind *UF) {
    const int N = 100000;
    for(int i = 0; i < N; ++i) {
        UF->parent[i] = i;
        UF->rank[i] = 0;
        UF->size[i] = 1;
    }
}

#define uf_same(UF, x, y) (uf_find((UF), (x)) == uf_find((UF), (y)))

int uf_find(UnionFind *UF, int x) {
    if(x == UF->parent[x]) return x;
    else return UF->parent[x] = uf_find(UF, UF->parent[x]);
}

void uf_unite(UnionFind *UF, int x, int y) {
    x = uf_find(UF, x), y = uf_find(UF, y);
    if(x == y) return;
    if(UF->rank[x] < UF->rank[y]) UF->parent[x] = y;
    else {
        UF->parent[y] = x;
        if(UF->rank[x] == UF->rank[y]) UF->rank[x]++;
        int tmp = x, x = y, y = tmp;
    }
    UF->size[y] += UF->size[x];
    UF->size[x] = 0;
}
//


int main(int argc, char **argv) {
    int n = get_uint();
    int m = get_uint();
    UnionFind UF;
    uf_init(&UF);
    for(int i = 0; i < m; ++i) {
        int s = get_uint();
        int t = get_uint();
        uf_unite(&UF, s, t);
    }
    int q = get_uint();
    for(int i = 0; i < q; ++i) {
        int s = get_uint();
        int t = get_uint();
        puts(uf_same(&UF, s, t) ? "yes" : "no");
    }
    return 0;
}



Measured memory_bytes: 2836
def main():
    from itertools import product

    a, b, c, d = input()

    for prd in product('+-', repeat=3):
        op1, op2, op3 = prd
        f = a + op1 + b + op2 + c + op3 + d
        if eval(f) == 7:
            print('{}=7'.format(f))
            return


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return 0
int main(){
    CIN(N);LL K;cin >>K;
    LL ans = 0;
    for(LL a = 1;a <=N;a++){
        ans += N/a*max(a-K,0LL);
        ans += max(0LL,N%a-max(K-1,0LL));
   }
    COUT(ans);
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < n; ++i)
#define FORR(i, m, n) for (ll i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;cin >> s;
    map<char,int> mp;
    int n=s.size();
    REP(i,n){
        if(mp[s[i]]){
            cout << "no" << endl;
            return 0;
        }
        mp[s[i]]++;
    }
    cout << "yes" << endl;
}

Measured memory_bytes: 3596
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
N,A,B = map(int,input().split())

ans = 0
for i in range(1,N+1):
    s = str(i)
    num = sum(map(int,list(s)))
    if A<=num<=B:
        ans += i

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 2940
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <memory>
#include <cstring>
#include <cassert>
#include <numeric>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cctype>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define REP2(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define REP(i, n) REP2(i, 0, n)
#define ALL(S) (S).begin(), (S).end()
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  int n;
  while (cin >> n && n){
    vector<string> vs(n);
    REP(i, n) cin >> vs[i];
    
    bool ok = true;
    int g[26][26];
    memset(g, 0, sizeof(g));

    REP(j, n) REP(i, j){
      
      REP(k, min(vs[i].size(), vs[j].size())) {
        if (vs[i][k] != vs[j][k]){
          g[vs[i][k] - 'a'][vs[j][k] - 'a'] = 1;
          break;
        } else if (k + 1 == min(vs[i].size(), vs[j].size()) && vs[i].size() > vs[j].size()){
          ok = false;
        }
      }
    }

    REP(k, 26)REP(i, 26)REP(j, 26){
      g[i][j] = g[i][j] || (g[i][k] * g[k][j]);
    }

    REP(i, 26)REP(j, i){
      if (g[i][j] && g[j][i]) ok = false;
    }
    if (ok){
      cout << "yes" << endl;
    } else {
      cout << "no" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1236
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <string>
#include <cstring>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;
const int MOD = 1e9+7;


#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())
//vvintを作る　マクロで　 #define vvint(N,M) vector<vector<int>>

using namespace std;


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

    int n;
    cin >> n;
    int num;
    vector<vector<pair<int,int> > > dict;
    for(int i = 0; i < n;i++){
        cin >> num;
        vector<pair<int,int> > tv;
        for(int l = 0; l < num;l++){
            int x,y;
            cin >> x >> y;
            tv.push_back(make_pair(x-1,y));
        }
        dict.push_back(tv);
    }
    int ans = 0;
    int cnt = 0;
    bool flag;
    for(int i = pow(2,n)-1; i >= 0; i--){
        vector<int> person(n,-1);
        cnt = 0;
        flag = true;
        // 2bit演算に直したい
        for(int l = 0; l < n;l++){
            if(i%int(pow(2,l+1)) >= pow(2,l+1)/2){
                cnt++;
                for(int k = 0; k < dict[l].size();k++){
                    if(i%int(pow(2,dict[l][k].first+1)) >= pow(2,dict[l][k].first+1)/2 && dict[l][k].second == 0){
                        flag = false;
                        break;
                    }else if(!(i%int(pow(2,dict[l][k].first+1)) >= pow(2,dict[l][k].first+1)/2) && dict[l][k].second == 1){
                        flag = false;
                        break;
                    }
                    if(person[dict[l][k].first] == -1){
                        person[dict[l][k].first] = dict[l][k].second;
                    }else{
                        if(person[dict[l][k].first] != dict[l][k].second){
                            flag = false;
                            break;
                        }
                    }
                }
            }
            if(!flag){
                break;
            }
        }
        if(flag) {
            ans = max(cnt,ans);
        }
    }
    
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
s = input()
from collections import defaultdict
dic = defaultdict(lambda : 0)
for i in s:
    dic[i] += 1
if len(dic.keys()) == 2:
    flag = 0
    for key in dic.keys():
        if dic[key] != 2:
            flag = 1
else:
    flag = 1
if flag == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3316
#include <stdio.h>
#include <stdlib.h>

int main()
{
    char num[4];
    int a[4];
    scanf("%s",num);
    for(int i = 0;i<4;i++){
        a[i] = num[i]-'0';
    }
    if(a[0]+a[1]+a[2]+a[3] == 7)
        printf("%d+%d+%d+%d=7\n",a[0],a[1],a[2],a[3]);
    else if(a[0]+a[1]+a[2]-a[3] == 7)
        printf("%d+%d+%d-%d=7\n",a[0],a[1],a[2],a[3]);
    else if(a[0]+a[1]-a[2]-a[3] == 7)
        printf("%d+%d-%d-%d=7\n",a[0],a[1],a[2],a[3]);
    else if(a[0]+a[1]-a[2]+a[3] == 7)
        printf("%d+%d-%d+%d=7\n",a[0],a[1],a[2],a[3]);
    else if(a[0]-a[1]+a[2]+a[3] == 7)
        printf("%d-%d+%d+%d=7\n",a[0],a[1],a[2],a[3]);
    else if(a[0]-a[1]+a[2]-a[3] == 7)
        printf("%d-%d+%d-%d=7\n",a[0],a[1],a[2],a[3]);
    else if(a[0]-a[1]-a[2]+a[3] == 7)
        printf("%d-%d-%d+%d=7\n",a[0],a[1],a[2],a[3]);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		int m = scan.nextInt();

		int m2 = h * 60 + m;
		int rev = 12 * 60;
		double hrot = (double)(m2)/rev;
		double mrot = (double)(m)/60;

		double hx = a * Math.sin(2 * Math.PI * hrot);
		double hy = a * Math.cos(2 * Math.PI * hrot);
		double mx = b * Math.sin(2 * Math.PI * mrot);
		double my = b * Math.cos(2 * Math.PI * mrot);
		double dx = hx - mx;
		double dy = hy - my;

		double dist = Math.pow(dx * dx + dy * dy, 0.5);

		System.out.println(dist);


	}

}

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

#define R register
#define ll long long
#define sum(a, b, mod) (((a) + (b)) % mod)

ll n, a[50];

ll f(ll l, ll r, ll x, ll y)
{
    ll ans = 1e18;
    if(r - l <= 1) return 0;
    for(int i = l + 1; i <= r - 1; i++)
        ans = std::min((f(l, i, x, x + y) + f(i, r, x + y, y) + a[i] * (x + y)), ans);
    return ans;
}

int main()
{   
    scanf("%lld", &n);
    for(int i = 1; i <= n; i++)
        scanf("%lld", &a[i]);
    printf("%lld\n", f(1, n, 1, 1) + a[1] + a[n]);
    return 0;
}


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

int main(){
    int n,count=0;
    cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    map<int,int> mp;
    for(int i=0;i<n;i++) mp[a[i]]++;
    for(auto p:mp){
        int x=p.first;
        int n=p.second;
        if(n<x) count+=n;
        else count+=n-x;
    }
    cout << count << endl;
}


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

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];
  }
  vector<int> dp(n);
  dp[0] = 0;
  dp[1] = abs(v[1]-v[0]);
  for(int i = 2;i<n;i++){
    dp[i] = min(dp[i-1]+abs(v[i-1]-v[i]),dp[i-2]+abs(v[i-2]-v[i]));
  }
  cout << dp[n-1];
  return 0;
}


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

int main() {

  int H,M,HH,MM,K;

  cin >>H>>M>>HH>>MM>>K;;
 int ans;
  int a;
  int b;
  a= 60*HH+MM;
  b= 60*H+M;
  ans = a-b-K;
   cout << ans << endl;
 return 0;
}


Measured memory_bytes: 3584
import java.util.Scanner;

class Main{
	
	public static void main(String args[]){
      
	  Scanner scanner = new Scanner(System.in);
      String input = scanner.nextLine();
      
      if(input.equals("AAA") == true){
        System.out.println("No");
	  }else if(input.equals("BBB") == true){
        System.out.println("No");
      }else{
        System.out.println("Yes");
      }
	}
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> c(N);
  for (int i = 0; i < N; i++) {
    cin >> c[i];  
  }
  sort(c.begin(), c.end());
  
  int a_sum, b_sum;
  a_sum = b_sum = 0;
  
  bool is_a = true;
  
  while (!c.empty()) {
    int v = c.back(); // 最大値
    c.pop_back(); // カード除去
    
    // 得点をいれる
    if (is_a) {
      a_sum += v;
    } else {
      b_sum += v;
    }
    // 攻守交代
    is_a = !is_a;
  }
  
  cout << (a_sum - b_sum) << endl;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 100005
#define eps 1e-12
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
	res = 0;T f = 1;char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}
int K,Q;
int64 X;
vector<pair<int64,int64> > v;
void Solve() {
	read(X);read(K);
	int64 r;
	for(int i = 1 ; i <= K ; ++i) {
		read(r);
		v.pb(mp(r,-1));
	}
	int64 a,b;
	read(Q);
	for(int i = 1 ; i <= Q ; ++i) {
		read(a);read(b);
		v.pb(mp(a,b));
	}
	sort(v.begin(),v.end());
	int64 MinX = 0,MinY = 0,MaxX = X,MaxY = X;
	int64 pre = 0,k = -1;
	for(auto t : v) {
		MinY = MinY + (t.fi - pre) * k;
		if(MinY < 0) {
			MinX -= MinY;
			MinY = 0;
		}
		if(MinY > X) MinY = X;
		MaxY = MaxY + (t.fi - pre) * k;
		if(MaxY > X) {
			MaxX -= (MaxY - X);
			MaxY = X;
		}
		if(MaxY < 0) MaxY = 0;
		if(t.se == -1) k *= -1;
		else {
			if(t.se <= MinX) {out(MinY);enter;}
			else if(t.se >= MaxX) {out(MaxY);enter;}
			else {out(MinY + t.se - MinX);enter;}
		}
		pre = t.fi;
	}
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Solve();
}


Measured memory_bytes: 6512
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

#define vi vector<int>
#define vl vector<long>
#define vvi vector<vector<int>>
#define vvl vector<vector<long>>
#define pint pair<int, int>
#define plong pair<long, long>

int main() {
    double R;
    cin>>R;
    cout << setprecision(10) <<  R * 2 * 3.141592 << endl;
}

Measured memory_bytes: 3784
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <set>

std::set<int> reachable(const std::vector<int>& xs) {
  std::set<int> res{0};
  for (int x: xs) {
    std::set<int> tmp;
    for (auto ri: res) {
      tmp.insert(ri-x);
      tmp.insert(ri+x);
    }
    res.swap(tmp);
  }
  return res;
}

int main() {
  char buf[8192];
  scanf("%s", buf);
  std::string s = buf;
  s += "TT";

  int x, y;
  scanf("%d %d", &x, &y);

  size_t i = 0;
  while (s[i] == 'F') {
    ++i;
    --x;
  }

  std::vector<int> xs, ys;
  bool xp = false;
  while (i < s.length()) {
    assert(s[i] == 'T');
    ++i;

    int tmp = 0;
    while (s[i] == 'F') {
      ++i;
      ++tmp;
    }

    (xp? xs:ys).push_back(tmp);
    xp = !xp;
  }

  puts((reachable(xs).count(x) && reachable(ys).count(y))? "Yes":"No");
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] num = new int[10000000];
		int i = 0;
		while ( sc.hasNext() ) {
			String[] line = sc.nextLine().split(",");
			int n = Integer.parseInt(line[0]);
			double w = Double.parseDouble(line[1]) , h = Double.parseDouble(line[2]);
			if ( 25 <= ( w / ( h * h ) ) )
				num[i++] = n;
		}
		for ( int j = 0; num[j] != 0; j++ )
			System.out.println(num[j]);
	}
}

Measured memory_bytes: 50000
#include<iostream>

using namespace std;

int arr[100005];
int cost[100005];

int main()
{
	int n;
	cin>>n;
	for(int i = 1; i<=n; i++)
	{
			cin>>arr[i];
			cost[i]=1000000000;
	}
	cost[1]=0;
	for(int i = 1; i<=n; i++)
	{
		int x = arr[i+1]-arr[i];
		x = x>0?x:-x;
		cost[i+1]=min(cost[i+1],cost[i]+x);

		x = arr[i+2]-arr[i];
		x = x>0?x:-x;
		cost[i+2]=min(cost[i+2],cost[i]+x);
	}
	cout<<cost[n];
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
//#define int long long

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

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    int a, b, k;
    cin >> a >> b >> k;

    vector<int> ans;
    REP(i, 100) if(a % (i+1) == 0 && b % (i+1) == 0) ans.pb(i+1);
    cout << ans[ans.size() - k] << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <chrono>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)
#define rrep(i, j, n) for (int i = (int)n - 1; j <= i; --i)

constexpr ll MOD = 1000000007;
constexpr int INF = 0x3f3f3f3f;
constexpr ll INFL = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  int n, k, a;
  cin >> n >> k;
  unordered_map<int, int> mp;
  rep(i, 0, n) {
    cin >> a;
    mp[a]++;
  }
  vector<int> cnt;
  for (auto p : mp) { cnt.push_back(p.second); }
  sort(cnt.begin(), cnt.end());
  int ans = 0;
  rep(i, 0, (int)cnt.size() - k) ans += cnt[i];
  cout << ans << endl;
#ifdef LOCAL
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=500005;
const int hval[4]={12345678,23456781,34567812,45678123};
const int mod[4]={515880193,998244353,int(1e9+7),int(1e9+9)};
class Hash{
public:
	int h[4];
	Hash(){memset(h,0,sizeof(h));}
	bool operator < (const Hash &o)const{
		if(h[0]!=o.h[0])return h[0]<o.h[0];
		if(h[1]!=o.h[1])return h[1]<o.h[1];
		if(h[2]!=o.h[2])return h[2]<o.h[2];
		return h[3]<o.h[3];
	}
	Hash operator + (const Hash &o)const{
		Hash res;
		rep(i,4){
			res.h[i]=h[i]+o.h[i];
			if(res.h[i]>=mod[i])res.h[i]-=mod[i];
		}
		return res;
	}
	Hash operator - (const Hash &o)const{
		Hash res;
		rep(i,4){
			res.h[i]=h[i]-o.h[i];
			if(res.h[i]<0)res.h[i]+=mod[i];
		}
		return res;
	}
	Hash operator * (const Hash &o)const{
		Hash res;
		rep(i,4)res.h[i]=1LL*h[i]*o.h[i]%mod[i];
		return res;
	}
}H,iH,one,pw[maxn],ipw[maxn],sum[maxn];
int n;
int pos[maxn];
map<Hash,int>cnt;
char s[maxn];

int power(int x,int pow,int mod){
	int res=1;
	for(;pow;pow>>=1){
		if(pow&1)res=1LL*res*x%mod;
		x=1LL*x*x%mod;
	}
	return res;
}

int main(){
	scanf("%d%s",&n,s+1);
	rep(i,4){
		H.h[i]=hval[i];
		iH.h[i]=power(hval[i],mod[i]-2,mod[i]);
		one.h[i]=1;
	}
	pw[0]=ipw[0]=one;
	REP(i,2*n){
		pw[i]=pw[i-1]*H;
		ipw[i]=ipw[i-1]*iH;
	}
	REP(i,n){
		pos[i]=pos[i-1];
		sum[i]=sum[i-1];
		if(s[i]=='<')pos[i]--;
		else if(s[i]=='>')pos[i]++;
		else if(s[i]=='+')sum[i]=sum[i]+pw[pos[i]+n];
		else sum[i]=sum[i]-pw[pos[i]+n];
	}
	ll ans=0;
	for(int i=n;i>=1;i--){
		cnt[sum[i]]++;
		if(pos[i-1]<0)ans+=cnt[(sum[n]*ipw[-pos[i-1]])+sum[i-1]];
		else ans+=cnt[(sum[n]*pw[pos[i-1]])+sum[i-1]];
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 56576
import java.util.*;
class Main{
  public static void main(String[]z){
    Scanner x=new Scanner(System.in);
    int i=0;
    while(x.hasNext()){
      String s=x.nextLine();
      if(s.equals(new StringBuffer(s).reverse().toString()))i++;
    }
    System.out.println(i);
  }
}

Measured memory_bytes: 12000
if __FILE__==$0
	inf=Float::INFINITY

	reads_i=lambda{||gets.chomp.split(" ").map(&:to_i)}
	num=reads_i[]
	h=num[0]; w=num[1]
	ans=Float::INFINITY
	for i in 1..h-1
		hbound=(h-i)/2
		wbound=(w/2)
		cmp=[i*w,(h-i)*wbound,(h-i)*(w-wbound)]
		cmp.sort!()
		if ans>cmp[2]-cmp[0]
			ans=cmp[2]-cmp[0]
		end
		cmp=[i*w,hbound*w,((h-i)-hbound)*w]
		cmp.sort!()
		if ans>cmp[2]-cmp[0]
			ans=cmp[2]-cmp[0]
		end
	end
	for i in 1..w-1
		wbound=(w-i)/2
		hbound=(h/2)
		cmp=[i*h,(w-i)*hbound,(w-i)*(h-hbound)]
		cmp.sort!()
		if ans>cmp[2]-cmp[0]
			ans=cmp[2]-cmp[0]
		end
		cmp=[i*h,wbound*h,((w-i)-wbound)*h]
		cmp.sort!()
		if ans>cmp[2]-cmp[0]
			ans=cmp[2]-cmp[0]
		end
	end
	p ans
end

Measured memory_bytes: 1788
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=100000;

int want[3]; int n;
int a[MAXN][3];

int kind[MAXN];
priority_queue<pair<int,int> > q[4][4];

vector<vector<int> > paths;
void genpaths(vector<int> &path,int to) {
	if(path.back()==to) { paths.PB(path); return; }
	REP(j,4) {
		bool ok=true; REPSZ(z,path) if(path[z]==j) ok=false; if(!ok) continue;
		path.PB(j); genpaths(path,to); path.pop_back();
	}
}

void run() {
	REP(j,3) scanf("%d",&want[j]); n=0; REP(j,3) n+=want[j];
	REP(i,n) REP(j,3) scanf("%d",&a[i][j]);

	REP(i,n) kind[i]=3;
	REP(i,n) REP(j,3) q[3][j].push(MP(a[i][j],i));

	ll ret=0;
	REP(j,3) REP(rep,want[j]) {
		paths.clear(); { vector<int> path(1,3); genpaths(path,j); }
		//printf("p:"); REPSZ(k,paths) { printf(" "); REPSZ(z,paths[k]) { if(z!=0) printf("-"); printf("%d",paths[k][z]); } } puts("");
		int bk=-1; ll best=LLONG_MIN;
		REPSZ(k,paths) {
			ll cur=0; bool ok=true;
			FORSZ(z,1,paths[k]) {
				int x=paths[k][z-1],y=paths[k][z];
				while(SZ(q[x][y])!=0&&kind[q[x][y].top().second]!=x) q[x][y].pop();
				if(SZ(q[x][y])==0) { ok=false; break; }
				cur+=q[x][y].top().first;
			}
			//if(ok) printf("j=%d rep=%d k=%d cur=%lld\n",j,rep,k,cur);
			if(ok&&cur>best) bk=k,best=cur;
		}
		assert(bk!=-1);
		FORSZ(z,1,paths[bk]) {
			int x=paths[bk][z-1],y=paths[bk][z];
			assert(SZ(q[x][y])!=0&&kind[q[x][y].top().second]==x);
			int at=q[x][y].top().second; if(x!=3) ret-=a[at][x]; ret+=a[at][y]; kind[at]=y; REP(yy,3) if(yy!=y) q[y][yy].push(MP(a[at][yy]-a[at][y],at));
			//printf("\t%d: %d->%d\n",at,x,y);
		}
	}
	printf("%lld\n",ret);
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 7008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i))
#define mat(type, c, m, n) vector<vector<type>> c(m, vector<type>(n));for(auto& r:c)for(auto& i:r)cin>>i;
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a), i##_len=(n); i>i##_len; --i)
#define each(x,y) for(auto &(x):(y))
#define var(type, ...)type __VA_ARGS__;Scan(__VA_ARGS__);
template<typename T> void Scan(T& t) { cin >> t; }
template<typename First, typename...Rest>void Scan(First& first, Rest&...rest) { cin >> first; Scan(rest...); }
#define vec(type, c, n) vector<type> c(n);for(auto& i:c) cin>>i;
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
#define em emplace
#define pb pop_back
#define fi first
#define se second
#define get(a, i) get<i>(a)
#define bit_count __builtin_popcount
#define mt make_tuple
inline string zero(int a,string s,char c='0'){return string(a-len(s),c)+s;}
inline string zero(int a,int t,char c='0'){return zero(a, to_string(t), c);}
inline string zero(int a,ll t,char c='0'){return zero(a, to_string(t), c);}
#define mini min_element
#define maxi max_element
#define sum accumulate
#define chmax(a,b) if(a<b)a=b
#define chmin(a,b) if(a>b)a=b
template <class T> inline void print(T t){cout << t << '\n';}
template <class H, class... T> inline void print(H h, T... t){cout << h << " ";print(t...);}
int len_n, ans = 0;
void f(int a, vi vn, vi v) {
	if (a >= len_n) {
		if (v[3] >= 1 && v[5] >= 1 && v[7] >= 1) {
			++ans;
		}
		return;
	}
	int t = vn[a];
	for (int x: {3, 5, 7}) {
		if (t >= x) {
			vi v2(all(v));
			++v2[x];
			vi vn2(all(vn));
			if (t > x) {
				vn2[a + 1] += (t - x) * 10;
			}
			f(a + 1, vn2, v2);
		}
	}
}
int solve() {
	var(string, n);
	len_n = len(n);
	if (stoll(n) < 357)
		return 0;
	vi vn(10, 0);
	rep(i, 0, len_n) {
		vn[i] = n[i] - '0';
	}
	vi v(10, 0);
	f(0, vn, v);
	rep(i, 1, len_n - 2) {
		vn[i] = '9';
		f(i, vn, v);
	}
	return ans;
}
int main() {
	print(solve());
	return 0;
}


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

int main()
{ 
  string s ; 
  cin >> s ;
  bool answer = true ;
  sort(s.begin(), s.end()) ;
  for(int i = 0 ; i < s.size() - 1 ; i++)
  {
    if(s.at(i) == s.at(i + 1))
    {
      answer = false ;
      break ;
    }
  }

  if(answer)
  {
    cout << "yes" << endl ;
  }
  else
  {
    cout << "no" << endl ;
  }
}


Measured memory_bytes: 256
import sys

def input():
    return sys.stdin.readline().rstrip()

if __name__ == "__main__":
    s = list(input())

    if s[0] != "A":
        print("WA")
        exit()

    if s[2:-1].count("C") != 1:
        print("WA")
        exit()

    idx = s[2:-1].index("C") + 2
    l =  s[1: idx] + s[idx+1:]
    for e in l:
        if e.isupper():
            print("WA")
            exit()

    print("AC")


Measured memory_bytes: 3060
import sys
from math import factorial
from collections import Counter
from fractions import Fraction
import heapq, bisect, fractions
import math
import itertools
sys.setrecursionlimit(10 ** 5 + 10)
INF = 10**15 +5
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
MOD = 10**9 + 7

a, b, c, k = MAP()
k -= a
res = a
if k <0:
    res += k
if k>0:
    k -= b
    
if k>0:
    k -= c
    res -=c
    if k<0:
        res -=k
print(res)

Measured memory_bytes: 72528
#include <stdio.h>

int main(void)
{
	int	S = 0;
	int	h = 0;
	int m = 0;

	scanf("%d", &S);
	while (S >= 3600)
	{
		h++;
		S -= 3600;
	}
	while (S >= 60)
	{
		m++;
		S -= 60;
	}
	printf("%d:%d:%d\n", h, m, S);
	return (0);
}



Measured memory_bytes: 2048
import math

k = int(input())

ans = 0
for i in range(1,k+1):
    for j in range(i,k+1):
        for h in range(j,k+1):
            if i == j and j == h:
                ans += math.gcd(math.gcd(i,j),h)
            elif i == j and j != h:
                ans += math.gcd(math.gcd(i,j),h) * 3
            elif i != j and j == h:
                ans += math.gcd(math.gcd(i,j),h) * 3
            else:
                ans += math.gcd(math.gcd(i,j),h) * 6


print(ans)

Measured memory_bytes: 9208
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
cost1 = 0
cost2 = 0
for i in range(1, N-X+1):
    if X + i in A:
        cost1 += 1

for i in reversed(range(X)):
    if i in A:
        cost2 += 1

print(min(cost1, cost2))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  int N;
  cin >> N;

  vector<double> x(N),y(N);
  for(int i = 0;i < N;i++) {
    cin >> x.at(i) >> y.at(i);
  }

  vector<int> v(N);
  for(int i = 0;i < N;i++) {
    v.at(i) = i+1;
  }

  double sum = 0;
  do{
    double dis = 0;
    for(int i = 0;i < N-1;i++) {
      int from = v.at(i),to = v.at(i+1);
      dis += sqrt((x.at(from-1)-x.at(to-1))*(x.at(from-1)-x.at(to-1)) + (y.at(from-1)-y.at(to-1))*(y.at(from-1)-y.at(to-1)));
    }
    sum += dis;
  }while(next_permutation(v.begin(),v.end()));

  for(int i = N;i >= 1;i--) {
    sum /= i;
  }

  cout << fixed << setprecision(10);
  cout << sum << endl;

}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int i,n,x;
	scanf("%d",&n);
	for(i = 3;i <= n;i++){
		if(i % 3 == 0){
			printf(" %d",i);
		}else{
			for(x = i;x != 0;x/=10){
				if(x % 10 == 3){
					printf(" %d",i);
					break;
				}
			}
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
#include<deque>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < n;i++)
#define ALL(a)  (a).begin(),(a).end()
const int MOD = 1000000007;
int main() {
	ll n, k; cin >> n >> k;
	ll m = n % k;
	cout << min(m, abs(m - k)) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 101
#define ll long long
using namespace std;
ll dp[maxn], l, k, res = 0;
int main()
{
    
    cin >> l >> k;
    dp[0] = 0;
    dp[1] = 1;
    dp[2] = 0;
    dp[k] = 1;
    for (int i = 3; i <= l; i++)
    {
        if (dp[i - 2] > 0)
            dp[i] += dp[i - 2];
        if (i - k - 1 > 0)
            if (dp[i - k - 1] > 0)
                dp[i] += dp[i - k - 1];
    }
    for (int i = 1; i <= l; i++)
        res += dp[i];
    printf("%lld\n",res);
}


Measured memory_bytes: 3232
#include<iostream>
using namespace std;
int main () {
	int kingaku[] = {6000, 4000, 3000, 2000};
    for (int i = 0; i < 4; i++){
	    int t, n;
	    cin >> t >> n;
        cout << kingaku[t-1] * n << endl;
	}

return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define deb(x) cout<<#x<<" "<<x<<endl;
#define deb2(x, y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define deb3(x, y, z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

template <typename T>void print(T v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<v.size(); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(w)<<*i<<" ";cout<<endl;}
template <typename T>void print_vv(T v){if(v.size()==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<v[0].size(); j++)cout<<setw(w)<<j<<" ";cout<<endl;for(auto i= 0; i<v.size(); i++){cout<<i<<" {";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(w)<<v[i][j]<<",";}cout<<"},"<<endl;}cout<<endl;}
template <class T, class U> void print_m(map<T,U> m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}

int main(){
    int a, b;
    while(cin>>a>>b){
        for(double i=1; i<2000; ++i){
            if((int)(i*0.08) == a && (int)(i*0.1)==b){
                cout<<(int)i<<endl;
                return 0;
            }
        }
        cout<<-1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds; 
using ll = long long int;
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock      cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
typedef tree<pair<ll,ll>, null_type, less<pair<ll,ll>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order() - 0 indexing
// order_of_key() - number of elements strictly smaller
ll power(ll x, ll y){
    ll res=1;x=x;
    while(y>0){
        if(y&1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}  
ll logtwo(ll n){
    if(n==1)
        return 0;
    return logtwo(n/2)+1;
}
//---------------------------------------GL HF------------------------------------------------------
// -------------------------------------ManavJ07----------------------------------------------------
signed main()
{
	fastio();   
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
	int t=1;
	//cin>>t;
	while(t--)
	{
		ll N;
		cin>>N;
		ll ar[N];
		cn(ar,N);
		ll ans=0;
		for(ll i=0;i<N;i+=2)
			ans+=(ar[i]%2);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3692
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;

int main (){
  ll N;
  cin >> N;
  int A[100001],B[100001],C[100001];
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  for(int i=0;i<N;i++){
    cin >> B[i];
  }
  for(int i=0;i<N;i++){
    cin >> C[i];
  }
  sort(A,A+N);
  sort(B,B+N);
  sort(C,C+N);
  ll ans=0;
  ll s,t;
  for(ll i=0; i<N;i++){
    s=lower_bound(A,A+N,B[i])-A;
    t=upper_bound(C,C+N,B[i])-C;
    ans+=(s)*(N-t);
  }
  cout << ans;
}

Measured memory_bytes: 1408
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
int main(void)
{
  int x[101],top=0,i;
  char s[200];
  while(scanf("%s",s)!=EOF)
  {
    if(s[0]=='+')
    {
      top--;
      x[top]=x[top]+x[top+1];
    }
    else if(s[0]=='-')
    {
      top--;
      x[top]=x[top]-x[top+1];
    }
    else if(s[0]=='*')
    {
      top--;
      x[top]=x[top]*x[top+1];
    }
    else
    {
      top++;
      x[top]=atoi(s);
    }
  }
  printf("%d\n",x[1]);
  return 0;
}



Measured memory_bytes: 2100
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    int n;
    cin>>n;
    int val[100005] = {};
    int i;
    FOR0(i, n)
    {
        int temp;
        cin>>temp;
        val[temp]++;
    }
    int cur = 0;
    int ans = 0;
    FOR(i, 1, 100001)
    {
        if( cur == n - cur) ans++;
        cur += val[i];
    }
    cout<<ans;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 640
#include<iostream>
#include<sstream>
#include<cmath>
#include<algorithm>
using namespace std;


double dp[1<<12][12];

int main(){
	string s;
	int size;
	int r[12];
	int n;
	while(getline(cin,s)){
		stringstream ss(s);
		ss>>size;
		n=0;
		while(ss>>r[n])n++;
		for(int i=0;i<(1<<n);i++)for(int j=0;j<n;j++)dp[i][j]=1e10;
		for(int j=0;j<n;j++)dp[1<<j][j]=r[j];
		for(int i=0;i<(1<<n);i++){
			for(int j=0;j<n;j++){
				if(!(i>>j&1))continue;
				for(int k=0;k<n;k++){
					if(i>>k&1)continue;
					dp[i|1<<k][k]=min(dp[i|1<<k][k],dp[i][j]+2*sqrt(r[j]*r[k]));
				}
			}
		}
		bool ok=false;
		for(int j=0;j<n;j++){
			if(dp[(1<<n)-1][j]+r[j]<=size)ok=true;
		}
		cout<<(ok?"OK":"NA")<<endl;
	}
	return 0;
}

Measured memory_bytes: 1596
import math
import sys
import bisect
#input=sys.stdin.readline
#t=int(input())
t=1
for _ in range(t):
    n=int(input())
    #n,d=map(int,input().split())
    #l=list(map(int,input().split()))
    s=input()
    f=0
    dw=[]
    dr=[]
    for i in range(n):
        if s[i]=='W':
            dw.append(i)
        else:
            dr.append(i)
    ind=0 
    cnt=0
    #print(dr[-1::-1],dw)
    for i in range(len(dr)-1,-1,-1):
        if ind>=len(dw):
            break
        
        if dr[i]>dw[ind]:
            cnt+=1
            ind+=1
    print(cnt)        
            
            

Measured memory_bytes: 80932
#include<cstdio>

using namespace std;

int main()
{
	int n, k;

	scanf("%d %d", &n, &k);

	if (n + 1 >= k * 2)
	{
		printf("YES\n");
	}

	else
	{
		printf("NO\n");
	}

	return 0;
}

Measured memory_bytes: 128
# 数直線上のxとA1-1, A2-2, ...との距離と言い換えられる
n = int(input())
A = list(map(int, input().split()))
A = sorted([a - (i+1) for i, a in enumerate(A)])
x = A[n//2]
print(sum(map(lambda a: abs(a-x), A)))

Measured memory_bytes: 26180
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch) {
	if (ch == 'A')return 1;
	else if (ch == 'C')return 2;
	else if (ch == 'G')return 3;
	else if (ch == 'T')return 4;
	else return 0;
}

long long getKey(char str[]) {
	long long sum = 0, p = 1, i;
	for (i = 0; i < strlen(str); i++) {
		sum += p*(getChar(str[i]));
		p *= 5;
	}
	return sum;
}

int h1(int key) { return key%M; }
int h2(int key) { return 1 + (key % (M - 1)); }

int find(char str[]) {
	long long key, i, h;
	key = getKey(str);
	for (i = 0;; i++) {
		h = (h1(key) + i*h2(key)) % M;
		if (strcmp(H[h], str) == 0)return 1;
		else if (strlen(H[h]) == 0)return 0;
	}
	return 0;
}

int insert(char str[]) {
	long long key, i, h;
	key = getKey(str);
	for (i = 0; ; i++) {
		h = (h1(key) + i*h2(key)) % M;
		if (strcmp(H[h], str) == 0)return 1;
		else if (strlen(H[h]) == 0) {
			strcpy(H[h], str);
			return 0;
		}
	}
	return 0;
}

int main() {
	int i, n, h;
	char str[L], com[9];
	for (i = 0; i < M; i++)H[i][ 0 ] = '\0';
	scanf("%d",&n);
	for (i = 0; i < n; i++) {
		scanf("%s %s", com, str);

		if (com[0] == 'i') {
			insert(str);
		}
		else {
			if (find(str)) {
				printf("yes\n");
			}
			else {
				printf("no\n");
			}
		}
	}
	return 0;
}

Measured memory_bytes: 16984
#include<stdio.h>

int main(void)
{
	int n,c=0;
	scanf("%d",&n);
	if(n>=105)
		c++;
	if(n>=135)
		c++;
	if(n>=165)
		c++;
	if(n>=189)
		c++;
	if(n>=195)
		c++;
	printf("%d",c);
	return 0;
}

Measured memory_bytes: 128