akhauriyash/Code-Regression huggingface dataset:
import unittest


class TestD(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(5, 2, 4), [5, 4, 1, 0])

    def test_2(self):
        self.assertEqual(think(3, 1, 3), [3, 0])

    def test_3(self):
        self.assertEqual(think(7, 3, 7), [7, 8, 4, 2, 0, 0])

    def test_4(self):
        self.assertEqual(think(10, 4, 8), [10, 12, 10, 8, 4, 1, 0, 0, 0])


def solve():
    n, x, y = read()
    result = think(n, x, y)
    write(result)


def read():
    return read_int(3)


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(n, x, y):
    result = [0] * n
    for i in range(1, n):
        for j in range(i + 1, n + 1):
            minimum_distance = min(j - i, 1 + abs(x - i) + abs(y - j))
            result[minimum_distance] += 1
    return result[1:]


def write(result):
    for r in result:
        print(r)


if __name__ == '__main__':
    # unittest.main()
    solve()

Measured memory_bytes: 56536
/**
 * @author: Mackenzie
**/

#include <bits/stdc++.h>

using namespace std;

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < (int)n; i++)
#define pb push_back
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#else
    fastIO;
#endif
    ll n, d;
    cin >> n >> d;
    int ans = 0;
    forn(i, n) {
        ll x, y;
        cin >> x >> y;
        if(x * x + y * y <= d*d)ans++;
    }
    cout << ans << endl;
    return 0;
}


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

#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)

using namespace std;
using ll = long long;
using pos = pair<ll, ll>;

ll x, t;

void solve();

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

void solve() {
	cin >> x >> t;
	cout << max(x - t, (ll)0) << endl;
}

Measured memory_bytes: 256
import heapq


class PrimalDual:
    def __init__(self, n: int):
        """頂点数をnとする。"""
        self.INF = 10 ** 9 + 7
        self.n = n
        self.graph = [[] for _ in range(n)]

    def add_edge(self, _from: int, to: int, capacity: int, cost: int):
        """辺を追加
        1. _fromからtoへ向かう容量capacity、単位コストcostの辺をグラフに追加する。
        2. toから_fromへ向かう容量0、単位コスト-costの辺をグラフに追加する。
        """
        forward = [to, capacity, cost, None]
        forward[3] = backward = [_from, 0, -cost, forward]
        self.graph[_from].append(forward)
        self.graph[to].append(backward)

    def min_cost_flow(self, s: int, t: int, f: int) -> int:
        """s-tパス上に流量fを流すときの最小費用流を求める。
        計算量: O(|F||E|log|V|)
        """
        res = 0
        potential = [0] * self.n
        prv_v = [0] * self.n
        prv_e = [None] * self.n
        while f > 0:
            # ポテンシャルを用いたダイクストラ法
            dist = [self.INF] * self.n
            dist[s] = 0
            q = [(0, s)]  # q = [(sからのコスト, 現在地)]
            while q:
                cost, _from = heapq.heappop(q)
                if dist[_from] < cost:
                    continue
                for edge in self.graph[_from]:
                    to, capacity, cost, _ = edge
                    p_diff = potential[_from] - potential[to]
                    if capacity > 0 and dist[_from] + cost + p_diff < dist[to]:
                        dist[to] = dist[_from] + cost + p_diff
                        prv_v[to] = _from
                        prv_e[to] = edge
                        heapq.heappush(q, (dist[to], to))

            if dist[t] == self.INF:
                return -1
            for i in range(self.n):
                if dist[i] != self.INF:
                    potential[i] += dist[i]
            d = f
            v = t
            while v != s:
                d = min(d, prv_e[v][1])
                v = prv_v[v]
            f -= d
            res += potential[t] * d
            v = t
            while v != s:
                edge = prv_e[v]
                edge[1] -= d
                edge[3][1] += d
                v = prv_v[v]
        return res


n, m, f = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(m)]


pd = PrimalDual(n)
for edge in edges:
    pd.add_edge(*edge)
    
ans = pd.min_cost_flow(0, n - 1, f)
print(ans)


Measured memory_bytes: 6144
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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

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

vector<ll> A;
vector<ll> S;

const ll A_MAX = 100000LL;

bool cond(const ll border, const ll N, const ll M) {
    ll acc = 0;
    for (int i = 1; i <= N; i++) {
        ll one = A[i];
        ll cand = border - one;
        auto it = lower_bound(A.begin() + 1, A.end(), cand);
        // printf("border: %lld, cnt: %lld\n", border, N - (it - A.begin()));
        acc += N - (it - A.begin() - 1);
    }
    return acc >= M;
}

ll calc_border(const ll N, const ll M) {
    ll left = -1, right = A_MAX + A_MAX + 1, mid;
    while (right - left > 1) {
        mid = left + (right - left) / 2LL;
        if (cond(mid, N, M)) {
            left = mid;
        } else {
            right = mid;
        }
    }
    return left;
}

ll solve(const ll border, const ll N, const ll M) {
    ll ans = 0;
    ll cnt = 0;
    for (int i = N; i >= 1 ; i--) {
        ll one = A[i];
        ll cand = border - one;
        auto it = upper_bound(A.begin() + 1, A.end(), cand);
        ll num = (N - (it - A.begin() - 1));
        // printf("one: %lld, num: %lld\n", one, num); 
        cnt += num;
        ans += S[N] - S[N - num];
        ans += one * num;
    }
    if (cnt < M) {
        ans += border * (M - cnt);
    }
    return ans;
}

int main(void) {
    ll N, M;
    cin >> N >> M;

    A.resize(N + 1, 0);
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());

    ll border = calc_border(N, M);
    // cout << border << endl;

    S.resize(N + 1, 0);
    for (int i = 0; i < N; i++) {
        S[i + 1] = S[i] + A[i + 1];
    }

    cout << solve(border, N, M) << endl;

    return 0;
}


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

int by(void);

int i,n,q,*s,*t,aaa;

int main(){

  int cnt=0;
  
  scanf("%d",&n);
  s = malloc(sizeof(int)*(n+1));
  for(i=0;i<n;i++)scanf("%d",&s[i]);

  scanf("%d",&q); 
  t = malloc(sizeof(int)*(q+1));
  for(i=0;i<q;i++)scanf("%d",&t[i]);

  
for(i=0;i<q;i++){
  aaa=by();
  if(aaa!=-1)cnt++;
  //printf("linear:%d\n",aaa);
 }

 printf("%d\n",cnt);
 
 free(s);
 free(t);

 return 0;
}


int by(void){

  int left=0,right=n,mid;
 
  while(left<right){
    mid = (left+right)/2;
    if(s[mid]==t[i])return mid;
    else if(t[i]<s[mid])right = mid;
    else left = mid + 1;
  }
    
  return -1;

}



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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b, c, d;
  int n;
  cin >> n;
  string s;
  set<string>st;
  while(n--) {
    cin >> s;
    st.insert(s);
  }
  cout << (int)st.size() << endl;
}

Measured memory_bytes: 19216
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <string>

using namespace std;

int N, A, X[51];
long long ans = 0, dp[51][51][3005];

int main() {

	cin >> N >> A;

	for (int i = 1; i <= N; i++) {
		cin >> X[i];
	}
	
	dp[0][0][0] = 1;

	for (int j = 1; j <= N; j++) {
		for (int k = 0; k <= N; k++) {
			for (int s = 0; s <= 3000; s++) {
				//cout << "j: " << j << " k: " << k << " X[j]: " << X[j] << endl;
				if (s < X[j]) {
					dp[j][k][s] = dp[j - 1][k][s];
				}
				else if (X[j] <= s && 1 <= k) {	//k>=1でないと、選ぶ選ばないの話ができない
					dp[j][k][s] = dp[j - 1][k][s] + dp[j - 1][k-1][s-X[j]];
				}else{
					dp[j][k][s] = 0;
				}
			}
		}
	}

	for (int k = 1; k <= N; k++) {
		ans += dp[N][k][k*A];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 60160
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static ArrayList<ArrayList<Integer>> g = new ArrayList<>();

	public static void main(String[] args) {
		int N = sc.nextInt();
		for (int i = 0; i < N; i++) {
			g.add(new ArrayList<>());
		}
		for (int i = 0; i < N - 1; i++) {
			int u = Integer.parseInt(sc.next()) - 1;
			int v = Integer.parseInt(sc.next()) - 1;
			g.get(u).add(v);
			g.get(v).add(u);
		}
		long[] value = new long[N];
		for (int i = 0; i < N; i++) {
			value[i] = Integer.parseInt(sc.next());
		}
		for (int i = 0; i < N; i++) {
			value[i] -= Integer.parseInt(sc.next());
		}
		int[] parent = new int[N];
		Arrays.fill(parent, -1);
		ArrayList<Integer> q = new ArrayList<>();
		q.add(0);
		for (int i = 0; i < N; i++) {
			int cur = q.get(i);
			for (int adj : g.get(cur)) {
				if (adj == parent[cur]) continue;
				parent[adj] = cur;
				q.add(adj);
			}
		}
		long[] sum = new long[N];
		for (int i = N - 1; i >= 0; i--) {
			int cur = q.get(i);
			sum[cur] = value[cur];
			for (int adj : g.get(cur)) {
				if (adj == parent[cur]) continue;
				sum[cur] += sum[adj];
			}
		}
		boolean[] visited = new boolean[N];
		int[] bfs = new int[N];
		bfs[0] = q.get(N - 1);
		visited[bfs[0]] = true;
		long[] count = new long[N];
		for (int i = 0, qi = 1; i < N; i++) {
			int cur = bfs[i];
			for (int adj : g.get(cur)) {
				if (visited[adj]) continue;
				if (adj == parent[cur]) {
					count[adj] = count[cur] - sum[cur];
				} else {
					count[adj] = count[cur] + sum[adj];
				}
				bfs[qi++] = adj;
				visited[adj] = true;
			}
		}
		long ans = 0;
		long min = 0;
		for (int i = 0; i < N; i++) {
			ans += count[i];
			min = Math.min(min, count[i]);
		}
		ans += -min * N;
		System.out.println(ans);
	}

}



Measured memory_bytes: 121384
#include<stdio.h>
#include<algorithm>
using namespace std;
long long int n,mem[110][5],sum;
long long int F(int n1,int n2)
{
    long long int s1,s2;
    s1 = min(n1,n2);
    s2 = max(n1,n2);
    if(s1 == 0)return s2;
    return F(s2 % s1,s1);
}
long long int min_w(int n_mobile)
{
    long long int n1,n2,lim,longth,s1,s2;
    if(mem[n_mobile][2] == 0)n1 = 1;
    else n1 = min_w(mem[n_mobile][2] - 1);
    if(mem[n_mobile][3] == 0)n2 = 1;
    else n2 = min_w(mem[n_mobile][3] - 1);
    longth = F(mem[n_mobile][0],mem[n_mobile][1]);
    //printf("%d %d %d\n",n_mobile,lim,longth);
    s1 = n1 / F(n1,mem[n_mobile][1] / longth);
    s2 = n2 / F(n2,mem[n_mobile][0] / longth);
    lim = F(min(s1,s2),max(s1,s2));
    return ((s1 * s2) / lim) * ((mem[n_mobile][0] / longth) + (mem[n_mobile][1] / longth));
}
int main()
{
    while(scanf("%d",&n),n)
    {
        sum = 0;
        for(int i = 0; i < n; i++)
        {
            for(int j = 0; j < 4; j++)
            {
                scanf("%d",&mem[i][j]);
            }
            sum += mem[i][2] + mem[i][3];
        }
        printf("%lld\n",min_w((n * (n + 1)) / 2 - sum - 1));
    }
    return 0;
}

Measured memory_bytes: 2600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int A = in.nextInt();
			int B = in.nextInt();
			if(B % A == 0) {
				out.println(A + B);
			}else {
				out.println(B - A);
			}
		}
	}
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

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

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

		public int nextInt() {
			return Integer.parseInt(next());
		}
	}
}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
int cnt = 0;
bool visited[200002]{};
 
void dfs(int n, vector<vector<int>> &ar){
	cnt++;
	visited[n] = 1;
	for(int x : ar[n]){
		if(!visited[x]) dfs(x, ar);
	}
}

main(){
	int n,m; cin>>n>>m;
	
	vector<vector<int>> ar(n+1);
	for(int i=0; i<m; i++){
		int a,b; cin>>a>>b;
		ar[a].push_back(b);
		ar[b].push_back(a);
	}
	int ans = 0;
	for(int i=1; i<=n; i++){
		if(!visited[i]){
			cnt = 0;
			dfs(i, ar);
		}
		ans = max(ans,cnt);
	}
	cout<<ans;
}

Measured memory_bytes: 23536
# coding: utf-8


def solve(*args: str) -> str:
    n, m = map(int, args[0].split())
    H = [0]+list(map(int, args[1].split()))
    AB = [tuple(map(int, ab.split())) for ab in args[2:]]

    G = [True]*(n+1)
    for a, b in AB:
        G[a] &= H[b] < H[a]
        G[b] &= H[a] < H[b]

    return str(sum(G[1:]))


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))


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

int main(){
  long long N;
  cin >> N;
  
  if(N%2==1){
    cout << 0 << endl;
    return 0;
  }
  
  long long ans = 0;
  while(N>0){
    N /= 5;
    ans += N/2;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
k = []
sum = 0
for i in range(N):
    t = input().split()
    sum += int(t[1])
    k.append(t)
X = input()
for i in range(N):
    if k[i][0] == X:
        sum -= int(k[i][1])
        print(sum)
        break
    else:
        sum -= int(k[i][1])

Measured memory_bytes: 3060
//Twitter@KonoLv1 2020年春卒で現在就職活動中！
 
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
 
int main(void){
    int i,j;            //  ループ文に使用
    int x,y,z;
    int count1,count2,count;   //  カウント用に使用
    int box[256] = {};
    char s[200001] = {};        //  文字列
    char s2[200001] = {};        //  文字列
    int a,b,c;
    a = b = c = i = 0;
    int mode = 0;
    int m,d;
    int d1,d2;
    count = count1 = count2 = 0;
    int ans;
    int mm = 0;
 
    //  入力処理
    
    scanf("%d %d",&m ,&d);


    //  計算処理

    for (i = 1; i <= m; i++){
        for (j = 1; j <= d; j++){
            d1 = j % 10;
            d2 = (j - d1) / 10;
           // printf("%d %d %d\n",j,d1,d2);
            if (j > 21 && d1 > 1){
                if (i == (d1 * d2)){
                    count++;
                }
            }
        }
    }

    //  出力処理
    printf("%d",count);

    
  

 
 
 
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef		vector<ll>      vll;
#define		pb              push_back
string intostr(int x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    return str;
}

char Uplowch(char ch)
{
    if(ch >= 'A' &&  ch <= 'Z')
        ch += 32;
    return ch;
}
char Lowupch(char ch)
{
    if(ch >= 'a' &&  ch <= 'z')
        ch -= 32;
    return ch;
}
bool Isalpha(char ch)
{
    if((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z'))
        return true;
    return false;
}
int Strtoint(string str)
{
    stringstream ss(str);
    int x = 0;
    ss >> x ;
    return x ;
}
string Intostr(int x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    return str;
}

#define		PB              pop_back
#define		nn              "\n"
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)

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

int dx[] = {0, 0, -1, 1} ;    // right , left , forward , backward
int dy[] = {1, -1, 0, 0} ;

//bool check(int x , int y) {
//    if(x <= n && y <= m && x >= 1 && y >= 1)
//        return 1 ;
//    return 0 ;
//}

int main()
{
    //freopen("in.txt","r",stdin);

    ios::sync_with_stdio(0);
    cin.tie(0);

    ll a,b,c,d;
    cin>>a>>b>>c>>d;

    ll fl=0;
    for(int i =0;; i++)
    {
        if(i%2==0)
        {
            c-=b;
        }
        else
        {
            a-=d;
        }

        if(a<1)
        {
            fl=0;
            break;
        }
        else if(c<1)
        {
            fl=1;
            break;

        }
       // cout<<a<<ss<<c<<nn;
    }

    if(fl)
        cout<<"Yes"<<nn;
    else
        cout<<"No"<<nn;



}



Measured memory_bytes: 3656
import bisect
def main():
    n=int(input())
    a=sorted(list(map(int,input().split(' '))))
    b=sorted(list(map(int,input().split(' '))))
    c=sorted(list(map(int,input().split(' '))))
    c_len=len(c)
    ans = 0
    for i in b:
        ans_a=bisect.bisect_left(a,i)
        ans_c=c_len-bisect.bisect_right(c,i)
        ans += ans_a*ans_c
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 22720
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    N,W=map(int,input().split())
    w,v=[0]*N,[0]*N
    for i in range(N):
        w[i],v[i]=map(int,input().split())
    dp=[[INF]*(10**5+1) for _ in range(N+1)]
    dp[0][0]=0
    ans=0
    for i in range(N):
        for value in range(10**5+1):
            dp[i+1][value]=min(dp[i+1][value],dp[i][value])
            if value>=v[i]:
                dp[i+1][value]=min(dp[i+1][value],dp[i][value-v[i]]+w[i])
            if dp[i+1][value]<=W:
                ans=max(ans,value)
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 123116
import java.util.Scanner;

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

    int x = sc.nextInt();
    int y = sc.nextInt();
    int ans = 0;

    while(true){
      if(x<y){
        int change = x;
        x = y;
        y = change;
      }

      if(x%y > 0){
        int change = x%y;
        x = y;
        y = change;
      }
      else{
        ans = y;
        System.out.println(ans);
        break;
      }

    }
  }
}



Measured memory_bytes: 26268
N, K, Q = map(int,input().split())

if K > Q:
	for i in range(N):
		print("Yes")
	exit()

T = [0 for i in range(N)]
t = Q - K

for i in range(Q):
    a = int(input())
    T[a-1] += 1

for i in range(N):
    if T[i] > t:
         print("Yes")
    else:
        print("No")


Measured memory_bytes: 10008
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int fi, se;
	scanf("%2d%2d", &fi, &se);
	bool isym = (1<=se&&se<=12);
	bool ismy = (1<=fi&&fi<=12);
	if(isym)
	{
		if(ismy) puts("AMBIGUOUS");
		else puts("YYMM");
	}
	else
	{
		if(ismy) puts("MMYY");
		else puts("NA");
	}
}

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

#define ll long long

using namespace std;

int main(void)
{
	ll a, b; cin>>a>>b;
	ll g = __gcd(a, b);
	ll ans = 1;
	for(ll i=2; i*i<=g; i++){
		if (g%i==0){
			ans++;
			while(g%i==0) g/=i;
		}
	}
	if (g!=1) ans++;
	cout << ans << "\n";
	return 0;
}

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

int
main(int argc, char *argv[])
{
  char o[100] = {}; char e[100] = {};
  scanf("%s%s", o, e);
  
  for(int i = 0; i < strlen(e); i++){
    printf("%c%c", o[i], e[i]);
  }
  if(strlen(o) > strlen(e)) printf("%c\n", o[strlen(o) - 1]);
  else printf("\n");
  
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,x) for(int i=0;i<x;i++)
#define put(ans)    cout << ans << endl;
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}
//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

int main(){
    int a,b;
    cin >> a >> b;
    if(a>b){
        puts("safe");
    }else{
        puts("unsafe");
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

uint64_t gcd(uint64_t a, uint64_t b, int64_t& x, int64_t& y) {
    if(b == 0) {
        x = 1; y = 0;
        return a;
    }

    uint64_t d = gcd(b, a%b, y, x);
    y -= a/b * x;
    
    return d;
}

int main(){
    uint64_t a, b;
    cin >> a >> b;

    int64_t x = 0, y = 0; gcd(a, b, x, y);
    cout << x << " " << y << endl;
    return 0;
}


Measured memory_bytes: 3116
/*
Author Shivam
*/
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define m_p			make_pair
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i =a, i>=b;i--)
#define sz(x)       (int)x.size()
#define F			first
#define S			second
#define debug(x)	for(int i=0;i<x;i++) cout<<"##########"<<endl
#define M			1000000007 
#define int			long long int
#define lMax		LLONG_MAX
#define pii 		pair<int ,int >
#define	all(a)		a.begin(), a.end()
#define vi 			vector<int> 
#define vii 		vector<pii> 
#define ve          vector
#define endl		"\n"
#define double 		long double
#define couts		cout<<setprecision(12)<<fixed					
// queue<int> , prefix_sum(a,a+n) , reverse(a,a+n) , priority_queue <int> max heap , priority_queue <int, vector<int>, greater<int> > min heap;
// == > != precedence gretaer then & , << precedence greater than <= == => , 
//int chk, cnt, fl, pos, in, src, tar, val, res. dummy;  fill (myvector.begin(),myvector.begin()+4,5), freq;					
// can

double dp[3*300+1][2*300+1][301+1];
int n;
double call(int i, int j, int k)
{	
	
	double &res=dp[i][j][k];
	//cout<<i<<" "<<j<<" "<<k<<" "<<n<<" "<<res<<endl;
	if(res!=-1) return res;
	double x1=0, x2=0, x3=0, sum=i+j+k;
	if(sum==0) return 0;
	if(i) x1=call(i-1,j,k);
	if(j) x2=call(i+1,j-1,k);
	if(k) x3=call(i,j+1,k-1);
	res=n*((x1+1)*i/n+(x2+1)*j/n+(x3+1)*k/n+(n-sum)/n)/sum;
	
	return res;

}
void solve()
{
	cin>>n;
	int a[n];
	int mp[4]={0,0,0,0};
	rep(i,0,n)
	{ 
		cin>>a[i];
		mp[a[i]]++;
	}
	int sum=mp[1]+mp[2]+mp[3];
	rep(i,0,mp[3]+mp[2]+mp[1]+1)
	{
		rep(j,0,mp[3]+mp[2]+1)
			rep(k,0,mp[3]+1) dp[i][j][k]=-1;
	}
	couts<<call(mp[1], mp[2], mp[3]);
}
signed main()
{
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		int t;
		t=1;
		while(t--)
		{
			solve();
		}
}	


Measured memory_bytes: 807168
import math

while True:
    n = int(input())  #得点の総数

    if n == 0:
        break

    lst = list(map(int,input().split()))  # 得点のリスト
    m = sum(lst)/n  # 平均得点

    val = 0.0

    for i in range(n):
        val += (lst[i] - m)**2

    print(math.sqrt(val/n))


Measured memory_bytes: 5708
import java.util.Scanner;


public class Main 
{
	public static void main(String[] args) 
	{
		// TODO ツ篠ゥツ督ョツ青カツ青ャツつウツづェツつスツδソツッツドツ・ツスツタツブ

		Scanner sc = new Scanner(System.in);
		System.out.println(new StringBuilder(sc.nextLine()).reverse());
	}
}

Measured memory_bytes: 11000
#include<bits/stdc++.h>
#define maxn 1000010
using namespace std;
int h[maxn];
int main()
{
	int k;
	cin >> k;
	int cur = 7 % k, ans = 1;
	if (cur == 0)
	{
		puts("1");
		return 0;
	}
	while (h[cur] == 0)
	{
		ans++;
		h[cur] = 1;
		cur = (cur * 10 + 7) % k;
		if (cur == 0)
		{
			printf("%d\n", ans);
			return 0;
		}
	}
	puts("-1");
}

Measured memory_bytes: 7648
#include<iostream>
#include<map>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<climits>
#include<cstring>

using namespace std;

int main(void) {
    string s;cin>>s;
    string t=s.substr(5,2);
    int x=stoi(t);
    if(x<=4){cout<<"Heisei"<<endl;}
    else{cout<<"TBD"<<endl;}


    return 0;
}

Measured memory_bytes: 764
#include<iostream>

using namespace std;

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

	int n;
	cin >> n;
	int freq[n+1] = {0};
	for(int i=1; i<=n-1; i++){
		int num; cin >> num;
		freq[num]++;
	}
	for(int i=1; i<=n; i++) cout << freq[i] << endl;
	return 0;
}

Measured memory_bytes: 4392
#include <bits/stdc++.h>
#include <vector>
#include <stack>

using namespace std;


int main(){


 int n;
 cin>>n;

 int ans = n%10;


 if(ans == 2 || ans == 4 || ans == 5 || ans == 7 || ans == 9)
  cout<<"hon"<<endl;
  else if(ans ==  0 || ans == 1 || ans == 6 || ans == 8)
  cout<<"pon"<<endl;
  else if(ans== 3)
    cout<<"bon"<<endl;

return 0;
 }



Measured memory_bytes: 3600
import java.util.*;

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

        int N = sc.nextInt();
        int[][] A = new int[2][N];

        for(int i=0; i<2; i++){
            for(int j=0; j<N; j++){
                A[i][j] = sc.nextInt();
            }
        }

        int sum = 0;
        int max = 0;
        int x = 0;
        for(int i=0; i<N; i++){
            for(int j=0; j<N; j++){
                sum += A[x][j];
                if(j==i && x==0){
                    x += 1;
                    j -= 1;
                }
            }
            max = Math.max(max, sum);
            sum = 0;
            x = 0;
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 23124
N=int(input())
music=[]
T=[]
ans=0
for i in range(N):
    s, t=input().split()
    t=int(t)
    music.append(s)
    T.append(t)
X=input()
num=music.index(X)
for j in range(num+1, N):
    ans+=T[j]
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll x, a = 100;
	cin >> x;
	for(int i = 1; ; i++)
	{
		a += a/100;
		if(a >= x)
		{
			cout << i;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int a;

  std::cin >> a;

  std::set<int> set;

  set.insert(a);

  int i = 2;

  for ( ; ; i ++) {
    if (a & 1) {
      a = 3 * a + 1;
    }
    else {
      a >>= 1;
    }

    if (set.count(a))
      break;

    set.insert(a);
  }

  std::cout << i << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pq              priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


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

int32_t main()
{
	c_p_c();
	string s,t;
	cin>>s>>t;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]!=t[i])
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	
	return 0;
}


Measured memory_bytes: 3660
from sys import setrecursionlimit
setrecursionlimit(10 ** 8)

A = input()
B = input()

A_root = [[-1] * 3 for i in range(1000)]
B_root = [[-1] * 3 for i in range(1000)]

class Source():
  def __init__(self, S):
    self.S = S
    self.pos = 0
   
  
def peek(S):
  return S.S[S.pos] if S.pos < len(S.S) else -1

def next(S):
  S.pos += 1

def tree(S, A, i):
  next(S)
  if peek(S) == ')':
    next(S)
    return -1
  c = i[0]
  i[0] += 1
  l = i[0] 
  left = tree(S, A, i)
  center = root(S, A)
  i[0] += 1
  r = i[0]
  right = tree(S, A, i)
  
  A[c] = [center, l, r]
  next(S)
  
def root(S, A):
  res = 0
  next(S)
  while peek(S) != ']':
    res = res * 10 + int(peek(S))
    next(S)
  next(S)
  
  return res
  
tree(Source('(' + A + ')'), A_root, [0])
tree(Source('(' + B + ')'), B_root, [0])

def f(i, j):
  if A_root[i][0] == -1 or B_root[j][0] == -1:
    return '()'
  center = '[' + str(A_root[i][0] + B_root[j][0]) + ']'
  return '(' + f(A_root[i][1], B_root[j][1]) + center + f(A_root[i][2], B_root[j][2]) + ')'

print(f(0, 0)[1:-1])


Measured memory_bytes: 5900
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000
	

int main(){
	
	int N;
	cin>>N;
	
	string S,T;
	cin>>S>>T;
	
	string ans = "";
	
	for(int i=0;i<N;i++){
		ans += S[i];
		ans += T[i];
	}
	
	cout<<ans<<endl;
	
	
	return 0;
}

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

using namespace std;

int32_t main() {

    ios_base::sync_with_stdio(false);

    cin.tie(0);

    string a;

    cin >> a;

    string b;

    cin >> b;

    b.pop_back();

    if(a==b) {

        cout << "Yes" <<'\n';

    } else {

        cout << "No" <<'\n';

    }

    return 0;

}



Measured memory_bytes: 3656
#include<stdio.h>

int main(){
  int n;
  scanf("%d",&n);
  long int sum=0;
  int i,j=0;
  
  for(i=1;i<=n;i++){
    if(i%3!=0 && i%5!=0)
      sum=sum+i;
  }
  printf("%ld",sum);
}

Measured memory_bytes: 1684
// template version 1.13
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define ceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int a,b;cin>>a>>b;
  cout << max(0LL, a-2*b) << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;

int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	string s,t;
	cin>>s>>t;
	int cnt=0;
	for(int i=0; i<(int)s.length(); i++) {
		cnt+=(s[i]!=t[i]);
	}
	cout<<cnt<<endl;

	return 0;
}


Measured memory_bytes: 3712
import sys
fin = sys.stdin.readline

def calc_sum(replaced_list):
    max_sum = 0
    for i in range(len(replaced_list) - 1):
        left, right = replaced_list[i], replaced_list[i + 1]
        max_sum += abs(left - right) 
    return max_sum


def calc_replaced_even(N, A_list, left_mid, right_mid):
    replaced_list = [None] * N
    replaced_list[0] = A_list[left_mid]
    replaced_list[-1] = A_list[right_mid]
    for i in range(1, N//2):
        replaced_list[2 * i - 1] = A_list[-i]
        replaced_list[2 * i] = A_list[i - 1]
    return replaced_list


def calc_replaced_odd(N, A_list, left_mid, right_mid):
    replaced_list = [None] * N
    replaced_list[0] = A_list[left_mid]
    replaced_list[-1] = A_list[right_mid]
    if left_mid == N // 2 - 1:
        replaced_list[1] = A_list[-1]
        for i in range(1, left_mid + 1):
            replaced_list[2 * i] = A_list[i - 1]
            replaced_list[2 * i + 1] = A_list[-(i + 1)]
    else:
        replaced_list[-2] = A_list[0]
        for i in range(1, left_mid):
            replaced_list[2 * i - 1] = A_list[i]
            replaced_list[2 * i] = A_list[-i]
    return replaced_list


def calc_max_sum(replaced_list):
    max_sum = calc_sum(replaced_list)
    replaced_list[1:N-1] = replaced_list[1:N-1][::-1]
    return max(max_sum, calc_sum(replaced_list))


N = int(fin())
A_list = [int(fin()) for _ in range(N)]

A_list.sort()
replaced_list = [None] * N
if N % 2 == 0:
    left_mid = N // 2 - 1
    right_mid = N // 2
    replaced_list = calc_replaced_even(N, A_list, left_mid, right_mid)
    max_sum = calc_max_sum(replaced_list)
    print(max_sum)
else:
    # try 2 types
    max_sum = 0
    for left_mid, right_mid in ((N // 2 - 1, N // 2), (N // 2, N // 2 + 1)):
        replaced_list = calc_replaced_odd(N, A_list, left_mid, right_mid)
        max_sum = max(max_sum, calc_max_sum(replaced_list))
    print(max_sum)


Measured memory_bytes: 9352
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int A[n];
	for(int i=0;i<n;i++){
		cin>>A[i];
	}
	sort(A,A+n);
	cout<<A[n/2]-A[(n-1)/2];
	
	return 0;
}


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

using namespace std;

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

    int N, M;
    cin >> N >> M;
    vector<int> S(N), T(M);
    for (int i = 0; i < N; ++i) {
        cin >> S[i];
    }
    for (int i = 0; i < M; ++i) {
        cin >> T[i];
    }
    vector<vector<int>> dp(N + 1, vector<int>(M + 1, 1));
    constexpr int MOD = 1'000'000'007;
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= M; ++j) {
            dp[i][j] = (dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]) % MOD;
            if (S[i-1] == T[j-1]) 
                dp[i][j] = (dp[i][j] + dp[i-1][j-1]) % MOD;
            dp[i][j] = (dp[i][j] + MOD) % MOD;
        }
    }
    cout << dp[N][M] << "\n";

    return 0;
}

Measured memory_bytes: 16000
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;

typedef long long LL;

LL cmb[440][10];
int m, n, L;
vector<vector<int> > pts;
vector<int> hd;

bool empty(const vector<int> &v){
	return v.empty();
}

void check(int k, const vector<int> &v){
	if(k == pts.size()){
		throw 0;
	}
	vector<int> w;
	int sz = (int)v.size() - (int)pts[k].size();
	for(int i = 1; i <= sz; ++i){
		bool ok = true;
		for(size_t j = 0; j < pts[k].size(); ++j){
			if(v[i + j] < pts[k][j]){
				ok = false;
			}
		}
		if(ok){
			w = v;
			for(size_t j = 0; j < pts[k].size(); ++j){
				w[i + j] -= pts[k][j];
			}
			check(k + 1, w);
		}
	}
}

LL dfs1(int rest){
	LL res = 0;
	if(hd.size() > m + 1){ return 0; }
	if(rest == 0){
		try{
			check(0, hd);
		}
		catch(int){
			res = 1;
			int zero = 0;
			for(size_t i = 1; i < hd.size(); ++i){
				if(hd[i] == 0){
					++zero;
				}
				else{
					res *= cmb[n][hd[i]];
				}
			}
			if(zero){
				int t = hd.size() - zero - 1;
				res *= cmb[m - t - 1][zero - 1];
			}
			else if(hd.size() != m + 1){
				res = 0;
			}
		}
	}
	if(rest > 0 || hd.back()){
		for(int i = !hd.back(); i <= rest && i <= n; ++i){
			hd.push_back(i);
			res += dfs1(rest - i);
			hd.pop_back();
		}
	}
	return res;
}

int main(){
	cmb[0][0] = 1;
	for(int i = 1; i < 440; ++i){
		cmb[i][0] = 1;
		for(int j = 1; j < 10; ++j){
			cmb[i][j] = cmb[i - 1][j] + cmb[i - 1][j - 1];
		}
	}
	
	string s;
	while(cin >> n >> m >> L, n){
		pts.assign(3, vector<int>());
		for(int i = 0; i < L; ++i){
			cin >> s;
			if(s[0] != '*'){
				vector<int> &v = pts[s[0] - 'a'];
				if(v.size() < s.size()){
					v.resize(s.size());
				}
				++v[s.size() - 1];
			}
		}

		pts.erase(remove_if(pts.begin(), pts.end(), empty), pts.end());
		bool ok = true;
		for(size_t i = 0; i < pts.size(); ++i){
			if(pts[i].size() > m){
				ok = false;
			}
		}
		LL cnt = 0;
		if(ok){
			hd.assign(1, -1);
			cnt = dfs1(L);
		}
		double ans = cnt / double(cmb[n * m][L]);
		printf("%.15f\n", ans);
	}
}

Measured memory_bytes: 1364
#include <stdio.h>

int main(void)
{
	int n, seq, tmp;
	int num[10];
	int i, j, res;
	
	scanf("%d", &n);
	for (; n > 0; n--){
		scanf("%d", &seq);
		for (i = 0; i < 8; i++){
			num[i] = seq % 10;
			seq /= 10;
		}
		for (i = 0; i < 7; i++){
			for (j = i + 1; j < 8; j++){
				if (num[i] > num[j]){
					tmp = num[i];
					num[i] = num[j];
					num[j] = tmp;
				}
			}
		}
		res = 0;
		for (i = 0; i < 8; i++){
			res *= 10;
			res += (num[7 - i] - num[i]);
		}
		printf("%d\n", res);
	}
	return (0);
}

Measured memory_bytes: 600
#include <iostream>
#define REP(i, a, b) for (auto i = (a); i < (b); ++i)
using namespace std;

const long long mod = 1e9 + 7, inv2 = 500000004;

signed main() {
	long long n, k; cin >> n >> k;
	int a[n];
	REP(i, 0, n) cin >> a[i];
	long long ans = 0;

	REP(i, 0, n) {
		long long x = 0, y = 0;
		REP(j, 0, i) y += (a[i] > a[j]);
		REP(j, i + 1, n) x += (a[i] > a[j]);
		ans += (k * x) % mod + (((k * (k - 1) % mod) * inv2 % mod) * (x + y) % mod);
		ans %= mod;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
main()
{
    int n, m;
    cin >> n;
    int ara[n];
    map<int, int>mp;
    for(int i = 0; i < n; i++)
    {
        cin >> ara[i];
        mp[ara[i]]++;
    }
    int ans = 0;
    for(auto it = mp.begin(); it != mp.end(); it++)
    {
        int x = it->second;
        ans += (x * (x -1)) / 2;
    }
    for(int i = 0; i < n; i++)
    {
        int x = mp[ara[i]];
        cout << ans - (x - 1) << endl;
    }
    //  main();
}


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


bool comp(const pair<int,int> &a , const pair<int,int> &b){

  return (a.second<b.second);
}
int main(){
  int a[5];
  for(int i=0;i<5;i++){
    scanf("%d",&a[i]);
  }
  int rem[5];
  for(int i=0;i<5;i++){
    int x=a[i]%10;
    if(x==0){ rem[i]=0;}
    else { rem[i]= 10-x;}
  }
  vector< pair<int,int> > vect;
  for(int i=0;i<5;i++){
    vect.push_back(make_pair(a[i],rem[i]));
  }

sort(vect.begin(),vect.end(),comp);

/*for(int i=0;i<5;i++){

  cout<<vect[i].first<<" ";
  cout<<vect[i].second;
  cout<<"\n";
}*/

int ans=0;

for(int i=0;i<4;i++){
  if(vect[i].second ==0){
    ans+= vect[i].first;

  }
  else{
    ans+=vect[i].first+vect[i].second;
  }
}
ans+=vect[4].first;
printf("%d\n",ans);

return 0;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

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

    int ans = 0;
    for_(i,0,N) {
        int a;
        cin >> a;
        if (i & 1) continue;
        if (a & 1) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
def main():
    N = int(input())
    A = list(map(int, input().split()))
    cnt = 0
    for i in range(len(A)):
        if (i + 1) % 2 == 1 and A[i] % 2 == 1:
            cnt += 1
    return cnt

if __name__ == '__main__':
    print(main())
    

Measured memory_bytes: 61748
#include <stdio.h>

int main(void)
{
  int n, i, j, al = 0, b = 0;
  int a[100];
  int tmp;

  scanf(" %d", &n);
  for (i = 0; i < n; i++)
    scanf(" %d", &a[i]);
  i = -1;
  while (++i < n)
  {
    j = i + 1;
    while (j < n)
    {
      if (a[i] < a[j])
      {
        tmp = a[i];
        a[i] = a[j];
        a[j] = tmp;
      }
      j++;
    }
  }
  for (i = 0; i < n; i++)
  {
    if (i % 2 == 0)
      al += a[i];
    else
      b += a[i];
  }
  printf("%d\n", al - b);
  return (0);
}

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

#define LL long long
#define VI vector<int>
#define VB vector<bool>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

template<class T> T ceil(T a, T b) { return (a + b - 1) / b; }
template<class T> void print(T x) { std::cout << x << std::endl; }

const std::string YES = "YES", Yes = "Yes", NO = "NO", No = "No";
const std::vector<int> dy = { 0, -1, 0, 1 }, dx = { 1, 0, -1, 0 };    // 4近傍（右, 下, 左, 上）

using namespace std;

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

    int N, target;
    cin >> N;
    vector<int> A(N - 1);
    FOR(i, 0, N - 1) {
        cin >> A[i];
    }
    cin >> target;

    vector<vector<LL>> dp(N, vector<LL>(100, 0));
    dp[1][A[0]] = 1;

    FOR(i, 1, A.size()) {
        int a = A[i];

        FOR(j, 0, dp[0].size()) {

            // +
            if (j + a <= 20) {
                dp[i + 1][j + a] += dp[i][j];
            }

            // -
            if (0 <= j - a) {
                dp[i + 1][j - a] += dp[i][j];
            }
        }
    }

    print(dp[N - 1][target]);
}




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

#define N 10020
#define MAX 100000000000000005ll
// #define MAX 3

using namespace std;

int n;
long long X[N], Y[N];

int first_test() {
	static int f[64][3];
	static int ans[3];
	memset(ans, 0, sizeof(ans));
	for (int t = 1; t <= n; ++t) {
		long long x = X[t], y = Y[t];
		memset(f, 0, sizeof(f));
		f[61][x % 3] = 1;
		for (int k = 60; k >= 0; --k) {
			for (int i = 0; i < 3; ++i) (f[k][i] += f[k + 1][i]) %= 2;
			if (y >> k & 1) {
				for (int i = 0; i < 3; ++i)
					(f[k][(i + (k & 1 ? 2 : 1)) % 3] += f[k + 1][i]) %= 2;
			}
		}
		for (int i = 0; i < 3; ++i) ans[i] = (ans[i] + f[0][i]) % 2;
	}
	for (int i = 0; i < 3; ++i) if (ans[i]) return i;
}

int second_test(long long xx, int r) {
	static int f[64][2][3];
	static int ans[3];
	memset(ans, 0, sizeof(ans));
	for (int t = 1; t <= n; ++t) {
		long long x = xx - X[t], y = Y[t];
		if (x < 0) continue;
		memset(f, 0, sizeof(f));
		f[61][1][X[t] % 3] = 1;
		for (int k = 60; k >= 0; --k) {
			for (int i = 0; i < 3; ++i) 
				(f[k][(x >> k & 1) == 0][i] += f[k + 1][1][i]) %= 2;
			if ((y >> k & 1) && (x >> k & 1)) {
				for (int i = 0; i < 3; ++i) 
					(f[k][1][(i + (k & 1 ? 2 : 1)) % 3] += f[k + 1][1][i]) %= 2;
			}
			for (int i = 0; i < 3; ++i) (f[k][0][i] += f[k + 1][0][i]) %= 2;
			if (y >> k & 1) {
				for (int i = 0; i < 3; ++i) 
					(f[k][0][(i + (k & 1 ? 2 : 1)) % 3] += f[k + 1][0][i]) %= 2;
			}
		}
		for (int i = 0; i < 3; ++i) ans[i] = (ans[i] + f[0][0][i] + f[0][1][i]) % 2;
	}
	return ans[r];
}

int second_test(long long x, long long y, int r) {
	return second_test(y, r) ^ second_test(x - 1, r);
}

int single_test(long long xx) {
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		long long x = xx - X[i], y = Y[i];
		if (x < 0) continue;
		if ((x | y) == y) ans ^= 1;
	}
	return ans;
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) scanf("%lld%lld", &X[i], &Y[i]);
	for (int i = 1; i <= n; ++i) X[i] += MAX, Y[i] += MAX;
	int r = first_test();
	long long w = 0;
	for (int k = 60; k >= 0; --k) {
		int t1 = second_test(w, w + (1ll << k) - 1, r);
		int t2 = second_test(w + (1ll << k), w + (1ll << (k + 1)) - 1, r);
		assert(t1 != t2);
		if (t1 == 0) w += 1ll << k;
	}
	long long x = w, y = w;
	for (int k = 60; k >= 0; --k) {
		if (single_test(x - (1ll << k))) x -= 1ll << k;
		if (single_test(y + (1ll << k))) y += 1ll << k;
	}
	y -= x;
	x -= MAX; y -= MAX;
	printf("%lld %lld\n", x, y);
}


Measured memory_bytes: 384
S = input()
len = len(S)
flag = 0
for num in range((len-1)//2):
    if flag == 0:
        if S[num] != S[len-1-num]:
            print("No")
            flag = 1
        elif S[num] != S[((len-1)//2)-1-num]:
            print("No")
            flag = 1
if flag == 0:
    print("Yes")


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define double long double
using namespace std;
signed main() {
	ll cnt = 0, memo = 0;
	string s;
	cin >> s;
	for (int i = 2; i < s.size() - 1; i++) {
		if (s[i] == 'C')cnt++;
	}
	for (int i = 0; i < s.size(); i++) {
		if (s[i] - 'a' >= 0)memo++;
	}
	if (s[0] != 'A')puts("WA");
	else if (cnt != 1)puts("WA");
	else if (memo != s.size() - 2)puts("WA");
	else puts("AC");
	getchar(); getchar(); return 0;
}


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

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

    int sum = 0;
    int flag = 1;
    int tmp = n;
    while (true) {
        sum += tmp % 10;
        tmp /= 10;
        if (tmp == 0) break;
    }

    if (n % sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
N, X = list(map(int, input().split()))
x = list(map(int, input().split()))

for i in range(N):
	x[i] -= X
if N == 1:
	print(abs(x[0]))
else:
	a = x[0]
	for i in range(N - 1):
		b = x[i + 1]
		a, b = sorted([a, b])
		while True:
			if b % a == 0:
				break
			else:
				a, b = b % a, a
	print(abs(a))

Measured memory_bytes: 14224
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;

#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(int i=m; i<n; i++)
#define FORR(i, m, n) for(int i=m-1; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define REVERSE(v) reverse(v.begin(), v.end());
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"


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

	string S;
	cin >> S;

	bool can = true;
	if (S[0] == S[1] && S[0] == S[2]) can = false;
	if (can) cout << "Yes" << "\n";
	else cout << "No" << "\n";
}


Measured memory_bytes: 256