akhauriyash/Code-Regression huggingface dataset:
// I need some holiday
// But I don't wish that everyday is holiday
// Because I didn't bear the pain
// Because it wasn't a true freedom
//         ——『イヤホンと蝉時雨』·Orangestar

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define MP make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }
template<typename T> inline T sqr(const T &val) { return val * val; }

namespace fastIO
{
	const int MAX_BUFFER_SIZE = 1 << 16;

	char buffer[MAX_BUFFER_SIZE], *cur = buffer, *ed = buffer;

	inline char getc() { return cur == ed && (ed = (cur = buffer) + fread(buffer, 1, MAX_BUFFER_SIZE, stdin), cur == ed) ? EOF : *cur++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

inline char *read_str(char *s)
{
	register char ch(getc());
	while(!isgraph(ch)) ch = getc();
	for(; isgraph(ch); ch = getc()) *s++ = ch;
	*s = '\0';
	return s;
}

// END tpl.

const int MAXN = (int) 1e5;

int n, m;

vector<int> adj[MAXN + 5];

inline void input()
{
	n = read<int>(), m = read<int>();
	for(int i = 1; i <= m; ++i)
	{
		int u = read<int>(), v = read<int>();
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
}

int vis[MAXN + 5], col[MAXN + 5];
vector<int> V;

inline void dfs(int u, int T)
{
	vis[u] = 1, col[u] = T, V.push_back(u);
	for(auto v : adj[u]) if(!vis[v]) dfs(v, !T);
}

inline int chk_type()
{
	if(SZ(V) == 1) return 0;
	for(auto u : V) for(auto v : adj[u]) if(col[u] == col[v]) return 1;
	return 2;
}

inline void solve()
{
	int cnt[3] = {0, 0, 0};
	for(int i = 1; i <= n; ++i) if(!vis[i])
	{
		V.clear(), dfs(i, 0);
		++cnt[chk_type()];
	}

	LL ans = (LL) cnt[0] * cnt[0] + (LL) cnt[0] * (n - cnt[0]) * 2 + (LL) cnt[1] * cnt[1] + (LL) cnt[1] * cnt[2] * 2 + (LL) cnt[2] * cnt[2] * 2;
	printf("%lld\n", ans);
}

int main()
{
#ifdef K_ON
	freopen("C.in", "r", stdin);
	freopen("C.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}




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

using namespace std;

int K;
queue<string> que;

int main(){
    cin>>K;
    for(int i=1;i<=9;++i){ 
        string tmp="";
        tmp.push_back('0'+i);
        que.push(tmp);
    }
    int cnt=0;
    string  lnum;
    while(cnt<K){
        lnum=que.front();
        que.pop();
        int dig=lnum[lnum.size()-1]-'0';
        for(int i=max(dig-1,0);i<=min(dig+1,9);++i){
            string lnum_n=lnum;
            lnum_n.push_back(i+'0');
            que.push(lnum_n);
        }
        cnt++;
    }
    cout<<lnum<<endl;
}

Measured memory_bytes: 13696
from collections import defaultdict

def main():
    q = int(input())
    d = defaultdict(int)

    for _ in range(q):
        para = input().split()

        if para[0] == "0":
            d[para[1]] = int(para[2])

        elif para[0] == "1":
            print(d[para[1]])
main()



Measured memory_bytes: 37908
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int x = in.nextInt();
        final int n = in.nextInt();
        in.nextLine();
        final Set<Integer> set = IntStream.rangeClosed(-100, 200).boxed().collect(Collectors.toSet());
        for (int i = 0; i < n; i++) {
            set.remove(in.nextInt());
        }
        int diff = Integer.MAX_VALUE;
        int res = Integer.MAX_VALUE;
        for (int item : set) {
            if (Math.abs(item - x) < diff) {
                diff = Math.abs(item - x);
                res = item;
            } else if (Math.abs(item - x) == diff) {
                res = Math.min(res, item);
            }
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 36548
n = int(input())
nlist = list(map(int, input().split()))
for i in range(n):
    j = i-1
    v = nlist[i]
    while (j >= 0 and nlist[j] > v):
        nlist[j+1] = nlist[j]
        j -= 1
    nlist[j+1] = v
    for k in range(n):
        if (k == n-1):
            print(nlist[k], end = '')
        else:
            print(nlist[k], end = ' ')
    print()


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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

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

const llong inf = 1100100100100100ll;
const llong mod = 1e9+7;

int main() {
	string s;
	cin >> s;
	s += "d";

	llong ans = 0;
	llong bc = 0;
	for (int i = (int)s.size()-3; i >= 0; i--) {
		if (s[i] == 'A') {
			if (s[i+1] == 'B' && s[i+2] == 'C') {
				ans += bc;
				s[i] = 'B';
				s[i+1] = 'C';
			} else {
				bc = 0;
			}
		}else if (s[i] == 'B') {
			if (s[i+1] == 'C') {
				bc++;
			} else {
				bc = 0;
			}
		} else if (s[i] == 'C') {
			if (s[i+1] == 'B') {
				continue;
			} else {
				bc = 0;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int n;
vector<vector<int>> M;
vector<int> dp;
//dp[mask] -> quantos pareamentos eu posso fazer com aquela mask dali pra frente
int mod = 1e9+7;
int biggestMask;
int solve(int i, int mask){
    if(i == n){
        //cout << n << "????????????" << endl;
        if(mask == biggestMask)return 1;
        return 0;
        //cout << "whatthefuckinghell" << endl;
    }
    //cout << "oooooooooof" << endl;
    if(dp[mask] != -1) return dp[mask];
    int ret = 0;
    bool check = true;
    for(int j = 0 ; j < n ; j++){
       // cout << "oof" << endl;
        if(M[i][j] && !(mask & (1 << j))){
            //cout << mask << endl;
            check = false;
            mask = mask | (1<<j);
            ret += solve(i+1,mask);
            //ret %= mod;
            if(ret >= mod) ret -= mod;
            mask = mask - (1<<j);
        } 
    }
    if(check) return 0;
    dp[mask] = ret;
    return ret;
}

int main(){
    cin >> n;
    M.resize(n);
    biggestMask = (1<<n) - 1;
    dp.resize((1<<n),-1);
    for(int i = 0 ; i < n ; i++){
        M[i].resize(n);
        for(int j = 0 ; j < n ; j++){
            cin >> M[i][j];
        }
    }
    cout << solve(0,0);
    return 0;
}

Measured memory_bytes: 8448
N, M = map(int, input().split())
X = sorted([int(x) for x in input().split()])

#print(X)

if N >= M:
    print(0)
    exit()

diff = []
for i, x in enumerate(X):
    if i == 0:
        diff.append((0, 0))
        continue
    diff.append((i, X[i] - X[i - 1]))

#print(diff)

diff.sort(key=lambda x: x[1], reverse=True)

#print(diff)

indices = sorted([e[0] for e in diff[:N-1]])
start = 0
step = 0

#print(indices)

for end in indices:
    step += X[end - 1] - X[start]
    start = end
step += X[-1] - X[start]
print(step)


Measured memory_bytes: 19148
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b; cin >> a >> b;
    if(b == 1) {
        cout << 0 << endl;
        return 0;
    }
    b = max(b - a, 0);
    cout << b / (a - 1) + 1 + (b % (a - 1) != 0) << endl;        
    return 0;
}

Measured memory_bytes: 256
using System;

class Prog{
    static void Main(){
        int x = int.Parse(Console.ReadLine());
        string y = x.ToString();
        double a = 0;
        if(y.Length % 2 != 0){
            a += x - Math.Pow(10,y.Length-1) + 1;
        }
        for(int i = 0;i < y.Length-1;i = i + 2){
            a += 9*Math.Pow(10,i);
        }
        Console.WriteLine(a);
    }
}

Measured memory_bytes: 27664
nums = input()
intNums = []

def saidaiKouYaku(a, b):
    if a < b:
        tmp = a
        a = b
        b = tmp

    r = a % b
    while(r != 0):
        a = b
        b = r
        r = a % b
    return b


for n in nums.split():
    intNums.append(int(n))
    
if len(intNums) == 4 and intNums[0] <= intNums[1] \
    and (intNums[0] >= 1 and intNums[0] <= 10**18) \
    and (intNums[1] >= 1 and intNums[1] <= 10**18) \
    and (intNums[2] >= 1 and intNums[2] <= 10**9) \
    and (intNums[3] >= 1 and intNums[3] <= 10**9):

    # 逆にどちらかで割り切れる数を調べる
    # C,D の最大公約数
    saidaiKouYaku = saidaiKouYaku(intNums[2], intNums[3])
    
    # C,Dの最小公倍数は　積 / 最大公約数
    saisyoKoubai = (intNums[2] * intNums[3]) // saidaiKouYaku
#     print('saidaiKouYaku = ',saidaiKouYaku)
#     print('saisyoKoubai = ',saisyoKoubai)
    c1 = intNums[1] // intNums[2] - (intNums[0]-1) // intNums[2]
    c2 = intNums[1] // intNums[3] - (intNums[0]-1) // intNums[3]
    c3 = intNums[1] // saisyoKoubai - (intNums[0]-1) // saisyoKoubai
#     print(c1)
#     print(c2)
#     print(c3)
    c4 = c1 + c2 - c3
    result = (intNums[1] - (intNums[0]-1)) - c4
    print(result)

Measured memory_bytes: 3064
import java.util.*;
public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		long a=sc.nextLong();
		long b=sc.nextLong();
		long c=sc.nextLong();
		long d=sc.nextLong();
		long ans=Math.max(a*c,Math.max(a*d,Math.max(b*d,b*c)));
		System.out.println(ans);

	}
}

Measured memory_bytes: 35688
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n, m;
    cin >> n >> m;
    ll a[n], b[m];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < m; i++) cin >> b[i];

    ll dp[n][m];
    memset(dp, 0, sizeof dp);
    dp[0][0] = (a[0] == b[0]);
    for (int i = 1; i < n; i++) {
        dp[i][0] = (a[i] == b[0]) + dp[i - 1][0];
    }

    for (int j = 1; j < m; j++) {
        dp[0][j] = (a[0] == b[j]) + dp[0][j - 1];
    }


    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];
            if (a[i] == b[j]) {
                dp[i][j] += dp[i - 1][j - 1] + 1;
            }

            dp[i][j] = (dp[i][j] + mod) % mod;

        }
    }

    cout << dp[n - 1][m - 1] + 1;



//    for (int i = 1; i < n; i++) {
//        for (int j = 1; j < m; j++) {
//            cout << dp[i][j] << ' ' ;
//
//        }
//        cout << '\n';
//    }


}

Measured memory_bytes: 31488
#include <iostream>
#include <vector>
#include <set>
#include <stack>

#define INF 0x3fffffff

using namespace std;

int main(){
	int n;
	while(cin>>n, n){
		int to[900], ds[900], to_num[900]={0}, ds_sum=0, ans=0;
		int w[900][900];
		set<int> sg;
		vector<int> tosg[900], dssg[900];
		fill( w[0], w[0]+900*900, INF );
		for(int i=1; i<n; i++){
			cin >> to[i];
			to[i]--;
			to_num[ to[i] ]++;
			to_num[ i ]++;
		}
		for(int i=1; i<n; i++){
			cin >> ds[i];
			ds_sum += ds[i];
			if( to[i] == 0 ){
				to[0] = i;
				ds[0] = ds[i];
			}
			w[ i ][ to[i] ] = ds[i];
			w[ to[i] ][ i ] = ds[i];
		}

		int ds_ha = 0;
		for(int i=0; i<n; i++){
			if( to_num[i] == 1 ){
				ds_ha += ds[i]; 
				sg.insert( to[i] );
			}else{
				tosg[i].push_back( to[i] );
				dssg[i].push_back( ds[i] );
				tosg[to[i]].push_back( i );
				dssg[to[i]].push_back( ds[i] );
			}
		}

/*		for(int i=0; i<n; i++){
			if( !sg.count(i) ) break;
			stack< pair<int,int> > st;
			st.push( make_pair(i, 0) );
			st.push( make_pair(i, 0) );
			while( st.size() > 1 ){
				pair<int,int> p = st.top(); st.pop();
				pair<int,int> bp = st.top();
				for(int k=0; k<tosg[p.first].size(); k++){
					int j = tosg[p.first][k];
					if( j != bp.first ){
						int sum = p.second + dssg[p.first][k];
						if( sg.count( j ) ){
							w[i][j] = min( w[i][j], sum);
							w[j][i] = min( w[j][i], sum);
						}
						st.push( make_pair(tosg[p.first][k], sum) );
					}
				}
			}
		}*/
		
		for(int i=1; i<n; i++){
			int j = to[i], sum = ds[i];
			if( sg.count(i) )
			while(1){
	//			if( sg.count(j) || j == 0 ){
					w[i][j] = min( w[i][j], sum);
					w[j][i] = min( w[j][i], sum);
					for(int k=0; k<tosg[j].size(); k++){
						w[i][ tosg[j][k] ] = min(w[i][ tosg[j][k] ], sum + dssg[j][k]);
						w[ tosg[j][k] ][i] = min(w[i][ tosg[j][k] ], sum + dssg[j][k]);
					}
					tosg[j].push_back( i );
					dssg[j].push_back( sum );
	//			}
				if( j == 0 ){
					break;
				}
				else {
					sum += ds[j];
					j = to[j];
				}
			}
		}
		//for(int k=0; k<n; k++){
		//	for(int i=0; i<n; i++){
		//		for(int j=0; j<n; j++){
		//			w[i][j] = min(w[i][j], w[i][k] + w[k][j]);
		//		}
		//	}
		//}
		int maxlen=0;
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				if( sg.count(i) && sg.count(j) && i != j && w[i][j] < INF ){
					maxlen = max( maxlen, w[i][j] );
				}
			}
		}
		ans = (3 * ds_sum) - (2 * ds_ha) - maxlen;
	//	cout << ds_sum << " " << ds_ha << " " << maxlen << endl;
		cout << ans << endl;
	}
	return 0;
}

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

const int MAX_N = 55;
vector<pair<int,int>> edges[MAX_N];

vector<int> path, found;
void dfs(int a, int goal, int parent) {
	if(a == goal) {
		found = path;
		return;
	}
	for(pair<int,int> e : edges[a]) {
		int b = e.first;
		if(b == parent) {
			continue;
		}
		path.push_back(e.second); // edge id
		dfs(b, goal, a);
		path.pop_back();
	}
}

int main() {
	int n;
	cin >> n;
	for(int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		edges[a].emplace_back(b, i);
		edges[b].emplace_back(a, i);
	}
	int m;
	cin >> m;
	vector<pair<int,int>> paths;
	vector<int> containMe(n - 1);
	// containMe[e] is a mask that represents which paths
	// 								contain edge e
	for(int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		found = {-1};
		dfs(a, b, -1);
		assert(found != vector<int>{-1});
		assert(path.empty());
		for(int e : found) {
			containMe[e] |= 1 << i;
		}
	}
	vector<long long> dp(1 << m);
	// dp[mask] - number of ways to paint already-considered edges
	// so that 'mask' would represent satisfied paths
	dp[0] = 1;
	for(int e = 0; e < n - 1; e++) {
		// cout << containMe[e] << endl;
		vector<long long> new_dp(1 << m);
		for(int mask = 0; mask < (1 << m); mask++) {
			new_dp[mask] += dp[mask];
			new_dp[mask | containMe[e]] += dp[mask];
			// dp[mask] -> new_dp[mask]
			// dp[mask] -> new_dp[mask|pathSatisfiedByThisEdge]
		}
		dp = new_dp;
	}
	cout << dp[(1<<m)-1];
}


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

int main() {
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n, vector<int>(d));
  for (int i=0; i < n; i++) {
    for (int j = 0; j < d; j++) {
      cin >> x.at(i).at(j);
    }
  }

  int count = 0;
  for (int i = 0; i < n -1; i++) {
    for (int j = i + 1; j < n; j++) {
      int distance2 = 0;
      for (int k = 0; k< d;k++) {
        int m_s_distance1 = x.at(j).at(k) - x.at(i).at(k);
        distance2 += m_s_distance1 * m_s_distance1;
      }
      for(int k = 1; k*k <= distance2; k++){
        if(k*k == distance2){
          count++;
        }
      }
    }
  }
  cout << count << endl;
}


Measured memory_bytes: 256
import sys

import re
import math
import collections
import decimal
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 10
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    def fast_pow(num, kata, mod):
        if kata == 0:
            return 0

        res = 1
        while kata > 0:
            if kata & 1 == 1:
                res = res * num % mod
            num = num * num % mod

            kata >>= 1
        return res

    n, a, b = ns()

    total = fast_pow(2, n, MOD) - 1

    def choose(n, r):
        res = 1
        fac = 1
        for i in range(r):
            res *= n - i
            res %= MOD
            fac *= i + 1
            fac %= MOD
        return res * fast_pow(fac, MOD - 2, MOD) % MOD

    tmp_a = choose(n, a)
    tmp_b = choose(n, b)

    ans = total - tmp_a - tmp_b
    ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5168
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using P = pair<int,bool>;
using ll = long long;
const int MX = 300005, MOD = 1e9+7;

int n;
ll a[MX], c[65], b[65] = {1},ans;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i,60) b[i+1] = b[i] * 2 % MOD;
    rep(i,n){
        cin >> a[i];
        rep(j,60) if(a[i]>>j&1) c[j]++;
    }
    rep(i,60) ans += b[i] * c[i] % MOD * (n - c[i]) % MOD;
    cout << ans % MOD << '\n';
}

Measured memory_bytes: 2560
N = int(input())
h = list(map(int, input().split()))
import math
dp = [0] * N
dp[0] = 0
dp[1] = abs(h[1] -h[0])
if N >= 3:
    for i in range(2, N):
        dp[i] = min(dp[i - 1] + abs(h[i] -h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
print(dp[N - 1])

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

int main() {
	
	int x, y; cin >> x >> y;
	string ans = "No";
	for (int i = 0; i <= x; i++) {
		int j = x - i;
		if (i * 2 + j * 4 == y) {
			ans = "Yes";
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3624
# ABC157 D Friend Suggestions
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1]*n
        
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
        
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x,y = y,x
            
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        
    def size(self, x):
        return -self.parents[self.find(x)]
    
    def same(self, x, y):
        return self.find(x) == self.find(y)

n,m,k = map(int,input().split())
g = [[] for _ in range(n)]
uf = UnionFind(n)

for i in range(m):
    a,b = map(int,input().split())
    g[a-1].append(b-1)
    g[b-1].append(a-1)
    uf.union(a-1,b-1)
    
for i in range(k):
    c,d = map(int,input().split())
    if uf.same(c-1,d-1):
        g[c-1].append(d-1)
        g[d-1].append(c-1)
        
ans = [0]*n
for i in range(n):
    ans[i] = uf.size(i) - len(g[i]) - 1
print(*ans)

Measured memory_bytes: 41776
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var N, M int
	con.Scan(&N, &M)
	E := make([][]int, N)
	for i := 0; i < M; i++ {
		var a, b int
		con.Scan(&a, &b)
		E[a-1] = append(E[a-1], b-1)
		E[b-1] = append(E[b-1], a-1)
	}
	for _, e := range E {
		con.Println(len(e))
	}
	return nil
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
	static int n,k;
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		n=scan.nextInt();
		k=scan.nextInt();
		a=new int[n];
		for(int i=0;i<n;i++) a[i]=scan.nextInt();
		dp=new int[n];
		Arrays.fill(dp,-1);
		System.out.println(go(0));
	}
	static int[] dp;
	static int[] a;
	
	public static int go(int at) {
		if(at==a.length-1) return 0;
		if(dp[at]!=-1) return dp[at];
		int res=Integer.MAX_VALUE/2-5;
		for(int nxt=at+1;nxt<a.length&&nxt<=at+k;nxt++) {
			res=Math.min(res,Math.abs(a[at]-a[nxt])+go(nxt));
		}
		return dp[at]=res;
	}
}

Measured memory_bytes: 62040
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cstring>
#include<cmath>
#include <numeric>
#include<queue>
#include<climits>
#include<cstdio>
#include<map>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
//#define INF ((LLONG_MAX) / (2))
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef long long int ll;
typedef pair<ll,int> LL_IP;
typedef pair<ll,ll> LL_LLP;
#define INF 1000000007
#define MAX_H 20000
#define ARRAY_MAX 200005

typedef struct union_find{

    int pa[ARRAY_MAX];
    int ra[ARRAY_MAX];  
    //vector<int> pa(ARRAY_MAX);//親
    //vector<int> ra(ARRAY_MAX);//木の深さ
    //n要素で初期化
    void init(int n){
        for(int i = 0;i < n;i++){
            pa[i] = i;/*各ノードに番号を振る,この時par[x]=xとなる時は木の根となる*/
            ra[i] = 0;/*各ノード自体の高さは0*/
        }
    }
    //木の根を求める
    int find(int x){
        if(pa[x] == x){
            return x;/*根ならそのノードの番号を返す*/
        }else{
            return pa[x] = find(pa[x]);/*根でないならさらにノードの根を探す*/
        }
    }

    //xとyの属する集合を併合する
    void unite(int x,int y){
        x = find(x);//xの根の番号を探す
        y = find(y);//yの根の番号を探す
        if(x == y){//一致すればつながっている
            return;
        }
        if(ra[x] < ra[y]){//xの高さが低いなら高いほうにつなぐ、そして高さは大きい方(y)になる
            pa[x] = y;
        }else{
            pa[y] = x;//yの高さが低いなら高いほうにつなぐ、そして高さは大きいほう(x)になる
            if(ra[x] == ra[y]){//高さが一致しているなら併合の高さは1増える
                ra[x]++;
            }
        }
    }

    //xとyが同じ集合に属するか判定
    bool same(int x,int y){
        return find(x) == find(y);//同じ集合なら1、違うなら0が返る
    }
}UF;


UF road,rail;

int main(){

    int n,k,l;
    cin >> n >> k >> l;
    road.init(n+2);
    rail.init(n+2);
    REP(i,k){
        /*道路*/
        int p,q;
        cin >> p >> q;
        
        p--;q--;/*配列の添え字に合わせる*/
        road.unite(p,q);
    }

    REP(i,l){
        /*鉄道*/
        int r,s;
        cin >> r >> s;
        r--;s--;/*配列の添え字に合わせる*/
        rail.unite(r,s);
    }

    map<P,int> mp;
    REP(i,n){
        /*i番目の都市の親のペアをカウント、一致するペアがあればi番目の都市と道路でも鉄道でも連結している*/
        mp[P(road.find(i),rail.find(i))]++;
    }
   
    map<P,int>::iterator itr;
    REP(i,n){
        if(i == 0){
            cout <<  mp[P(road.find(i),rail.find(i))];
        }else{
            cout << " " << mp[P(road.find(i),rail.find(i))];
        }
    }
    cout << endl;

   
   
}


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

int main() {
  int A,B,K;
  cin >> A >> B >> K;
  for(int i = 0;i < K;i++) {
    if(i % 2 == 0) {
      if(A % 2 == 0) {
        B = B + A / 2;
        A = A / 2;
      }
      else {
        A = A - 1;
        B = B + A / 2;
        A = A / 2;
      }
    }
    else {
      if(B % 2 == 0) {
        A = A + B / 2;
        B = B / 2;
      }
      else {
        B = B - 1;
        A = A + B / 2;
        B = B / 2;
      }
    }
  }
  cout << A << " " << B << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque
import marshal


class Graph:
    def __init__(self, n, directed=False, decrement=True, destroy=False, edges=[]):
        self.n = n
        self.directed = directed
        self.decrement = decrement
        self.destroy = destroy
        self.edges = [set() for _ in range(self.n)]
        self.parent = [-1]*self.n
        self.info = [-1]*self.n
        for x, y in edges:
            self.add_edge(x,y)

    def add_edge(self, x, y):
        if self.decrement:
            x -= 1
            y -= 1
        self.edges[x].add(y)
        if self.directed == False:
            self.edges[y].add(x)

    def add_adjacent_list(self, i, adjacent_list):
        if self.decrement:
            self.edges[i] = set(map(lambda x: x - 1, adjacent_list))
        else:
            self.edges[i] = set(adjacent_list)

    def bfs(self, start=1, goal=-1, time=0, save=False):
        """
        :param start: スタート地点
        :param goal: ゴール地点
        :param save: True = 前回の探索結果を保持する
        :return: （ループがあっても）最短距離。存在しなければ -1
        """
        if self.decrement:
            start -= 1
            goal -= 1
        if not save:
            self.parent = [-1] * self.n
        p, t = start, time
        self.parent[p] = -2
        next_set = deque([(p, t)])

        while next_set:
            p, t = next_set.popleft()
            for q in self.edges[p]:
                if self.parent[q] != -1:
                    continue
                if q == goal:
                    return t + 1
                self.parent[q] = p
                next_set.append((q, t + 1))
        return -1

    def connection_counter(self):
        """
        :return: 連結成分の個数。有効グラフではあまり意味がない。
        """
        cnt = 0
        self.parent = [-1] * self.n
        for start in range(self.n):
            if self.parent[start] == -1:
                cnt += 1
                self.bfs(start + self.decrement, save=True)
        return cnt

    def distance_list(self, start=1, save=False):
        """
        :param start: スタート地点
        :return: スタート地点から各点への距離のリスト
        """
        dist = [-1]*self.n
        if self.decrement:
            start -= 1
        if not save:
            self.parent = [-1] * self.n
        p, t = start, 0
        self.parent[p] = -2
        dist[p] = 0
        next_set = deque([(p, t)])

        while next_set:
            p, t = next_set.popleft()
            for q in self.edges[p]:
                if self.parent[q] != -1:
                    continue
                dist[q] = t + 1
                self.parent[q] = p
                next_set.append((q, t + 1))
        return dist

##################################################################################################

N, M = map(int, input().split())
graph = Graph(N, directed=False, decrement=True, destroy=False)
for _ in range(M):
    x, y = map(int, input().split())
    graph.add_edge(x, y)

if -1 in graph.distance_list():
    print("No")
else:
    print("Yes")
    print(*list(p+1 for p in graph.parent[1:]), sep="\n")


Measured memory_bytes: 69640
n, m = map(int, input().split())
abc = {}
ac_cnt = 0
wa_cnt = 0
for i in range(m):
    p, s = map(str, input().split())
    abc.setdefault(p, []).append(s)
for key in abc.keys():
    if "AC" in abc[key]:
        idx = abc[key].index("AC")
        ac_cnt += 1
        wa_cnt += idx
    else:
        ac_cnt += 0
        wa_cnt += 0
print(ac_cnt, wa_cnt)

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

/*
dp[i][j] after i share j
dp[i][j]= sum_{k=0}^{min(ai,j)} (dp[i-1][j-k])
*/

const int MN=105;
const int MK=1e5+5;
const int MO=1e9+7;

int add(int x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
	return x;
}
int sub(int x,int y)
{
	x-=y;
	if(x<0) x+=MO;
	return x;
}

int a[MN];
int dp[MK];

int main()
{
	int n,k; scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	dp[0]=1;
	for(int i=1;i<=n;i++)
	{
		int psum=0;
		//cout<<"!!! "<<a[i]<<endl;
		for(int l=0,j=k;l<a[i]&&j>=0;l++,j--)
			psum=add(psum,dp[j]);
		for(int j=k;j>=1;j--)
		{
			if(j-a[i]>=0)
				psum=add(psum,dp[j-a[i]]);
			//cout<<" "<<psum<<endl;
			int tmp=psum;
			psum=sub(psum,dp[j]);
			dp[j]=tmp;
		}
	}
	printf("%d\n",dp[k]);
	return 0;
}

Measured memory_bytes: 640
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    s = str(input().rstrip('\n'))
    m_cnt = 0
    for i in range(1, n):
        t1 = s[:i]
        t2 = s[i:]
        t1 = collections.Counter(t1)
        t2 = collections.Counter(t2)
        cnt = 0
        for k, v in t1.items():
            cnt += min(1, t2[k])
        m_cnt = max(m_cnt, cnt)
    print(m_cnt)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 44652
num = int(input())
num_list = input().split(" ")

nums = []

for n in num_list:
    nums.append(int(n))
    
for m in range(num):
    i = nums[m]
    j = m - 1
    while j >= 0 and nums[j] > i:
        nums[j+1] = nums[j]
        j -= 1
    nums[j+1] = i
    
    for n in range(num):
        if n == len(nums)-1:
            print(int(nums[n]), end = "")
            print("")
        else:
            print(int(nums[n]), end = " ")


Measured memory_bytes: 5988
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fi first
#define sec second 
#define MOD 1000000007
#define pb push_back
#define endl "\n"
#define test cout<<"debuged\n";
const long long INF = 1e13;
#define si 1000000
#define pi pair<ll,ll>

ll v[405];
ll dp[405][405];
ll sum(ll i,ll j)
{
    ll s=0;
    for(ll k=i;k<=j;k++)
        s+=v[k];
    return s;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    for(ll i=0;i<n;i++)
        {
            cin>>v[i];
        }
    for(ll i=n-1;i>=0;i--)
        for(ll j=i;j<n;j++)
        {   
            if(i==j)
            {
                dp[i][j]=0;
                continue;
            }
            else
            {
                dp[i][j]=INF;
                for(ll k=i;k<=j-1;k++)
                {
                            
                    dp[i][j]=min(dp[i][j],(dp[i][k]+dp[k+1][j]+sum(i,j)));
                }
        }
        }
        cout<<dp[0][n-1];
}


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

using namespace std;



int main(){
int n;
do{

    cin>>n;
}while(n<0||n>999);
int a=n%10;
{
    if(a==2||a==4||a==5||a==7||a==9)
    {
        cout<<"hon";
    }
    if(a==0||a==1||a==6||a==8)
    {
        cout<<"pon";
    }
    if(a==3)
    cout<<"bon";
}
return 0;
}


Measured memory_bytes: 3652
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		long[][] senryaku = new long[8][N];
		for(int i=0;i<N;++i){
			long x = sc.nextLong();
			long y = sc.nextLong();
			long z = sc.nextLong();
			senryaku[0][i] = x+y+z;
			senryaku[1][i] = x+y-z;
			senryaku[2][i] = x-y+z;
			senryaku[3][i] = x-y-z;
			senryaku[4][i] = -1*x+y+z;
			senryaku[5][i] = -1*x+y-z;
			senryaku[6][i] = -1*x-y+z;
			senryaku[7][i] = -1*x-y-z;
		}
		for(int i=0;i<8;++i) Arrays.sort(senryaku[i]);
		
		long[] ans = new long[8];
		for(int i=0;i<8;++i) ans[i] = 0;
		for(int i=N-1;i>=N-M;--i){
			for(int j=0;j<8;++j) ans[j] += senryaku[j][i];
		}
		Arrays.sort(ans);
		System.out.println(ans[7]);
		return;
	}
}

Measured memory_bytes: 29156
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <limits.h>
#include <math.h>
int acs(const void *a, const void *b) { return *(int *)a - *(int *)b; } /* 1,2,3,4.. */
int des(const void *a, const void *b) { return *(int *)b - *(int *)a; } /* 8,7,6,5.. */
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)

#define mod 2019

int main(void)
{
	int n, a[100000];
	scanf("%d", &n);

	int i;
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);

	int p = 0;
	for (i = 0; i < n; i++)
	{
		if (i % 2 == 0)
			p += a[i];
		else
			p -= a[i];
	}
	printf("%d", p);
	for (i = 0; i < n - 1; i++)
	{
		p = 2 * a[i] - p;
		printf(" %d", p);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N,M;
    cin >> N >> M;
    vector<ll> a(M), b(M);
    vector<Pll> c(M);
    rep(i,M){
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
        c[i] = Pll(b[i], a[i]);
    }
    sort(c.begin(), c.end());
    ll prev = -1;
    ll ans = 0;
    rep(i,M){
        ll bb = c[i].fi;
        ll aa = c[i].se;
        if(aa <= prev){
            continue;
        }else{
            prev = bb-1;
            ans++;
        }
    }
    cout << ans << endl;
}

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

long long fact(int n){
	long long res=1,i;
	for(i=1;i<=n;i++){
		res*=i;
	}
	return res;
}

int main(){
	int n;
	scanf("%d",&n);
	printf("%lld\n",fact(n));
	return 0;
}

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


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

    ll total = 0;
    for(int i = N - 1; i >= 0; i--){
        A[i] += total;
        if(A[i] % B[i] != 0) {
            total += B[i] - (A[i] % B[i]);
        }
    }
    cout << total << endl;
    return 0;
}


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

const int mod = 1'000'000'007;  //'

struct ModInt {
    int x;

    ModInt() : x(0) {}
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

    ModInt &operator+=(const ModInt &p) {
        if ((x += p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p) {
        if ((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p) {
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p) {
        *this *= p.inverse();
        return *this;
    }

    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }

    ModInt inverse() const {
        int a = x, b = mod, u = 1, v = 0, t;
        while (b > 0) {
            t = a / b;
            std::swap(a -= t * b, b);
            std::swap(u -= t * v, v);
        }
        return ModInt(u);
    }

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

    friend std::ostream &operator<<(std::ostream &os, const ModInt &p) {
        return os << p.x;
    }
    friend std::istream &operator>>(std::istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt(t);
        return (is);
    }

    static int get_mod() { return mod; }
};

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

    // inputs
    int64_t N;  // n <= 1e6
    cin >> N;

    // solve
    // 10^N - 8 ^N
    ModInt ten = 10, nine = 9, eight = 8;
    ten        = ten.pow(N);
    nine       = nine.pow(N);
    eight      = eight.pow(N);
    ModInt ans = ten - nine - nine + eight;

    // output
    cout << ans << "\n";

    return 0;
}


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

int main(void){
    string s;
    cin >> s;
    if(s[0]==s[1] && s[0]==s[2] ||
       s[3]==s[2] && s[3]==s[1]){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    
    return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

int n;

void dfs(string s, char mx) {
	if (s.length() == n) {
		out(s);
	}
	else {
		for (char c = 'a'; c <= mx; c++) {
			dfs(s + c, ((c == mx)) ? (char)(mx + 1) : mx);
		}
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	cin >> n;
	dfs("", 'a');

	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
// #define PI 3.141592653589793238L
#define INF 1000000011
#define INFLL 100000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pii a, pii b)//true for a before b
{
	if(a.S < b.S)
		return 1;
	if(a.S > b.S)
		return 0;
	if(a.F <= b.F)
		return 1;
	return 0;
}

const int N = (50) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 900;

pll pt[N];
map < pll, int > cnt;

void solve()
{
	int n, i, j, ans;
	cin >> n;
	fo(i,1,n+1)
		cin >> pt[i].F >> pt[i].S;
	fo(i,1,n+1)
		fo(j,1,n+1)
			if(i != j)
				cnt[{pt[i].F-pt[j].F,pt[i].S-pt[j].S}]++;
	ans = 0;
	for(auto x : cnt)
		ans = max(ans, x.S);
	cout << (n-ans) << '\n';
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand(clock());

	//Code here
	int t = 1, cs;
	cout << fixed << setprecision(6);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 384
N, Y = map(int, input().split())

for x in range(N + 1):
    for y in range(N + 1 - x):
        z = N - x - y
        if 10000 * x + 5000 * y + 1000 * z == Y:
            print(x, y, z)
            exit()

print("-1 -1 -1")


Measured memory_bytes: 40684
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    s: Chars
    }
    let n = s.len();
    for i in 0..n {
        print!("{}", s[i]);
    }
    if s[n - 1] == 's' {
        print!("es");
    } else {
        print!("s");
    }
}


Measured memory_bytes: 2200
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	int n,a[101],tot=0;
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",a+i);
	for (int i=2;i<=n;i++) if (a[i]==a[i-1]) a[i]=0,tot++;
	printf("%d\n",tot);
}

Measured memory_bytes: 256
n = input()
d = {}
for i in range(n):
    a, b = raw_input().split()
    if a in d: d[a] += int(b)
    else: d[a] = int(b)
for ans in sorted(sorted(d.items()), key = lambda x: len(x[0])):
     print " ".join(map(str,ans))

Measured memory_bytes: 6564
#include<bits/stdc++.h>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int main(){
	int m1,d1,m2,d2;
	cin>>m1>>d1>>m2>>d2;
	if(d2==1)
	cout<<1;
	else
	cout<<0;
	re 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<long> X(N+1,0),Y(N+1,0);
  for(int i=1; i<=N; i++){
    cin >> X.at(i);
    Y.at(i)=X.at(i);
  }
  sort(X.begin(),X.end());
  
  for(int i=1; i<=N; i++){
    if(Y.at(i)<=X.at(N/2)){
      cout << X.at(N/2+1) << endl;
    }
    else{
      cout << X.at(N/2) << endl;
    }
  }
}

Measured memory_bytes: 5376
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        String S = sc.next();

        System.out.println(solve(S));
    }

    private static String solve(String S) {
        return S.equals("ABC") ? "ARC" : "ABC";
    }
}

Measured memory_bytes: 35696
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
from collections import Counter

def f(s):
    n = len(s)
    c = 0
    ans = 0
    for i in range(n-1):
        if s[i] == s[i+1]:
            c += 1
            if i == n-2:
                ans += (c+1) // 2
        else:
            ans += (c+1) // 2
            c = 0
    return ans

def main():
    s = input().strip()
    k = int(input().strip())
    n = len(s)
    if len(Counter(s)) == 1:
        print(n * k // 2)
        return
    ini = f(s)
    dif = f(s*2) - ini
    print(ini + dif * (k-1))

if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <iostream>
using namespace std;
const int MAXn=100;
const int INFTY=1<<21;

int n,M[MAXn][MAXn],col[MAXn],d[MAXn],p[MAXn];

void prim()
{
	for(int i=0;i<n;i++)
	{
		col[i]=0;
		d[i]=INFTY;
	}
	d[0]=0;
	p[0]=-1;
	
	while(1)
	{
		int mincost=INFTY;
		int u;
		for(int i=0;i<n;i++)
		{
			if(col[i]!=2&&d[i]<mincost)
			{
				mincost=d[i];
				u=i;
			}
		}
		if(mincost==INFTY)break;
		col[u]=2;
		for(int v=0;v<n;v++)
		{
			if(col[v]!=2&&M[u][v]!=INFTY)
			{
				if(M[u][v]<d[v])
				{
					d[v]=M[u][v];
					p[v]=u;
					col[v]=1;
				}
			}
		}
	}
	return;
}

int sum()
{
	int sum=0;
	for(int i=0;i<n;i++)if(p[i]!=-1)sum+=M[i][p[i]];
	return sum;
}

int main() {
	cin>>n;
	for(int i=0;i<n;i++)for(int j=0;j<n;j++)
	{
		cin>>M[i][j];
		if(M[i][j]==-1)M[i][j]=INFTY;
	}
	prim();cout<<sum()<<endl;
	return 0;
}

Measured memory_bytes: 3096
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i,n){
        cin >> a[i];
    }
    bool flag = (a[0]==0);
    REP(i,n-1){
        if(a[i+1]>a[i]+1){
            flag = false;
        }
    }
    if(flag){
        ll res = 0;
        REP(i,n-1){
            if(a[i+1]!=a[i]+1){
                res+=a[i];
            }
        }
        res+=a.back();
        put(res);
    }else{
        put(-1);
    }
    return 0;
}




Measured memory_bytes: 1024
#include <stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    for (int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    int store;
    for (int i=n-1;i>0;i--){
        for (int j=0;j<i;j++){
            if (a[j]<a[j+1]){
                store=a[j];
                a[j]=a[j+1];
                a[j+1]=store;
            }
        }
    }
    int sum=0;
    for (int i=0;i<n;i+=2){
        sum+=a[i];
    }
    for (int i=1;i<n;i+=2){
        sum-=a[i];
    }
    printf("%d",sum);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <unistd.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<ll,ll> P;
 
long long int INF = 3e18;
double Pi = 3.1415926535897932384626;
 
vector<ll> G[550010];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←
 
 
#define p(x) cout<<x<<"\n";
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define CLEAR(a) a = decltype(a)(); 
 
 
ll mod = 998244353;
 
ll rui(ll number1,ll number2){
 
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
 
    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){
 
    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){
 
    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}
 
/*
ll fact[800005],rfact[800005];
 
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
    rfact[800000] = rui(fact[800000],mod - 2);
    for(ll i=800000; i>=1; i--){
       rfact[i-1] = rfact[i] * i;
       rfact[i-1] %= mod;
    }
    return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod ) * rfact[n-r]) % mod;}
*/
 
ll n,m,num,sum,a,b,c,d,e,g,h,w,i,j,q,r,l;
ll k,ans;
ll x[500005],y[500005],z[500005];
bool used[500005];
char s[500005];

int main(){
    cin >> n;
    for(int i=0;i<n;i++){
    	cin >> x[i];
    }
    for(int i=0;i<n;i++){
    	for(int j=0;j<i;j++){
    		ans += x[i] * x[j];
    	}
    }
    p(ans);
    return 0;
}











Measured memory_bytes: 15616