akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#define MOD 1000000007
using namespace std;

int main(){
	int n,k;
	long long int ans = 0;
	int a[100];
	long long int po[101] = {0,1};
	int dp[101][101][256] = {};//i番目まででj個使ってXORがkになる組み合わせの数
	cin >> n >> k;
	for(int i = 0;i < n;i++) {
		cin >> a[i];
		if(i >= 2) po[i] = po[i - 1] * i % MOD;
		dp[i][0][0] = 1;
	}
	po[n] = po[n - 1] * n % MOD;
	dp[n][0][0] = 1;
	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= i;j++){
			for(int l = 0;l <= 255;l++){
				dp[i][j][l] = (dp[i - 1][j][l] + dp[i - 1][j - 1][l ^ a[i - 1]]) % MOD;
			}
		}
	}
	for(int i = 1;i <= n;i++){
		ans = (ans + (dp[n][i][k] * po[i] % MOD)) % MOD;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 10496
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <unordered_set>

using namespace std;

int main()
{
	int n, val;
	cin >> n;
	vector<int> f(n + 1, 0);
	for (int i = 1; i < n; i++)
	{
		cin >> val;
		f[val]++;
	}
	for (int i = 1; i <= n; i++)
	{
		cout << f[i] << '\n';
	}
	return 0;
}

Measured memory_bytes: 4048
#include <iostream>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <sstream>
#include <cmath>

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)

using namespace std;


int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    long int N;
    cin >> N;
    long int sum = 0;
    int ans,num = N;

    for(int i = 9; i > -1; i--){
        ans = N/(int)pow(10,i);
        sum += ans;
        N = N-(ans*pow(10,i));
    }
    if(num%sum == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define abs(x) (((x)>0)?(x):-(x))

int main()
{
  int i, j, k, n;
  scanf("%d %d", &n, &k);
  
  int h[n+k];
  int cost[n+k];
  for (i=0; i<n; i++)  scanf("%d", &h[i]);
  for (; i<n+k; i++) {
    h[i] = h[n-1];
    cost[i] = 0;
  }

  for (i=n-1; i>=0; i--) {
    for (j=k; j>0; j--) {
      if (j==k || cost[i] > abs(h[i]-h[i+j])+cost[i+j])
	cost[i] = abs(h[i]-h[i+j])+cost[i+j];
    }
  }
  
  printf("%d\n", cost[0]);

  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int n; cin >> n;
    vector<vector<ll>> d(3, vector<ll>(n));
    rep(i, n) cin >> d[0][i]; sort(d[0].begin(), d[0].end());
    rep(i, n) cin >> d[1][i]; sort(d[1].begin(), d[1].end());
    rep(i, n) cin >> d[2][i]; sort(d[2].begin(), d[2].end());
    ll ans = 0;
    vector<vector<ll>> x(2, vector<ll>(n));
    rep(i, 2) {
        rep(j, n) {
            x[i][j] = d[i+1].end() - lower_bound(d[i+1].begin(), d[i+1].end(), d[i][j]+1);
        }
    }
    /*rep(i, 2) {
        rep(j, n) {
            printf("%2d ",x[i][j]);
        }puts("");
    }*/
    vector<ll> ruisekiwa(n+1);
    rep(i, n) ruisekiwa[i+1] = ruisekiwa[i] + x[1][i];
    rep(i, n) {
        ll y = x[0][i];
        ans += ruisekiwa[n] - ruisekiwa[n-y];
    }
    cout << ans;
}


Measured memory_bytes: 5744
if __name__ == '__main__':
    from sys import stdin
    # from collections import defaultdict
    # from collections import deque
    # from collections import Counter
    import numpy as np
    # import math
    # import random
    input = stdin.readline


    n, k = map(int, input().split())
    aa = [0]+list(map(int, input().split()))
    arrive = [1]
    next = aa[1]
    visited = set([1])
    if next == 1:
        print(1)
        exit()
    while not (next in visited):
        arrive.append(next)
        visited.add(next)
        next = aa[next]
    num_town = len(arrive)
    start_index = arrive.index(next)
    if k < num_town:
        print(arrive[k])
        exit()
    print(arrive[start_index+(k-start_index)%(num_town-start_index)])



Measured memory_bytes: 51132
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1 << 21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// 0115c
int main(){
    int n;
    cin >> n;
    int h[n+1];
    rep(i, n) cin >> h[i];
    int pre = 0;
    int ans = 0;
    rep(i, n){
        if (pre < h[i]){
            ans += h[i] - pre;
        }
        pre = h[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#青木を根で深さ決定
#先回りできる点のうち子の深さが最大の点
from collections import deque
n,u,v = map(int, input().split( ))

u -= 1
v -= 1
Tr =[[]for i in range(n)]

Dep = [-1]*n
Deg = [0]*n
for i in range(n-1):
    ai,bi = map(int, input().split( ))
    ai -=1
    bi -=1
    Tr[ai].append(bi)
    Tr[bi].append(ai)
    Deg[ai] += 1
    Deg[bi] += 1

Q = deque()
Dep[v] = 0
Leaf = []
Q.append(v)
while Q:
    x = Q.popleft()
    leaf = True
    for y in Tr[x]:
        if Dep[y] == -1:
            Dep[y] = Dep[x] + 1
            Q.append(y)
            leaf = False
    if leaf:
        Leaf.append(x)
Parent = [-1]*n
Parent[v] = v
for i in range(n):
    for j in Tr[i]:
        if Dep[j]<Dep[i]:
            Parent[i] = j

Path= []
tmp = u
while tmp !=v:
    Path.append(tmp)
    tmp = Parent[tmp]
Q = deque()
Dep_max = [-1]*n
for l in Leaf:
    Q.append(l)
    Dep_max[l] = Dep[l]

while Q:
    x = Q.popleft()
    y = Parent[x]
    if y!=v:
        Deg[y] -= 1
    Dep_max[y] = max(Dep_max[y],Dep_max[x])
    if Deg[y]-1 == 0 and y!=v:
        Q.append(y)
        Deg[y]-=1
D_m_path = []
lp = len(Path)
for i in range(lp):
    D_m_path.append(Dep_max[Path[i]])
ans = max(D_m_path[:(lp+1)//2])
print(ans-1)


Measured memory_bytes: 70176
#! env/bin/local python3
# -*- coding: utf-8 -*-

from itertools import combinations


def is_tri(_a, _b, _c):
    if (_a + _b > _c) and (_b + _c > _a) and (_c + _a > _b):
        return True
    else:
        return False


n = int(input())
sticks = list(map(int, input().split()))

h = combinations(sticks, 3)

counter = 0
for a, b, c in h:
    if is_tri(a, b, c):
        a, b, c = sorted([a, b, c])
        if (a != b) and (b != c):
            counter += 1

print(counter)


Measured memory_bytes: 9156
#include<stdio.h>
	int main(void){
	int w,h,x,y,r;
	
	scanf("%d %d %d %d %d", &w,&h,&x,&y,&r);

		if(x+r>w || x-r<0 || y+r>h || y-r<0){
			
			printf("No\n");
		}
		else{
			printf("Yes\n");
		}

return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

int dfs(vector<int> &v, vector<int> t, int index) {
  if (index == 13) {
    vector<int> x;
    rep(i, 0, t.size()) {
      rep(j, 0, t[i]) { x.push_back(i); }
    }
    rep(i, 0, t.size()) {
      rep(j, 0, t[i]) { x.push_back(i); }
    }
    int ret(INF);
    rep(i, 0, x.size() - 1) {
      chmin(ret, min(abs(x[i] - x[i + 1]), 24 - abs(x[i] - x[i + 1])));
    }
    return ret;
  }

  if (v[index] == 0) {
    return dfs(v, t, index + 1);
  } else if (v[index] == 1) {
    t[index]++;
    int a = dfs(v, t, index + 1);
    t[index]--;
    t[(24 - index) % 24]++;
    int b = dfs(v, t, index + 1);
    return max(a, b);
  }
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  vector<int> D(N);
  rep(i, 0, N) cin >> D[i];
  vector<int> t(25, 0);
  t[0] = 1;

  vector<int> v(13, 0);
  rep(i, 0, D.size()) { v[D[i]]++; }
  rep(i, 0, v.size()) {
    if (v[i] >= 3) {
      cout << 0 << endl;
      return 0;
    }
  }
  rep(i, 0, v.size()) {
    if (v[i] == 2) {
      t[i]++;
      t[(24 - i) % 24]++;
      v[i] = 0;
    }
  }
  cout << dfs(v, t, 0) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> p_i;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repext(i, a, b) for (int i = a; i < b; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (int i = b - 1; i >= a; i--)

#define repv(values) for (auto v : values)

#define vec_all(vec) vec.begin(), vec.end()
#define sum(vec) accumulate(vec_all(vec), 0)
#define srt(vec) sort(vec_all(vec))

// vectorデバッグ
template <typename T>
void dump_vec(vector<T> vec)
{
    rep(i, vec.size())
    {
        cout << i << ": " << vec[i] << endl;
    }
}

// --- notice ---
// intの和はllにしろ

int main()
{
    int n;
    cin >> n;
    vector<p_i> a;
    int tmp;
    rep(i, n) {
        cin >> tmp;
        a.push_back(p_i(i + 1, tmp));
    }

    sort(vec_all(a), [](p_i p1, p_i p2) {
        return p1.second < p2.second;
    });

    rep(i, n) {
        cout << a[i].first << " ";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 1780
import java.util.*;

public class Main {
//======
// main
//
	public static void main(String[] args) throws Exception {
		Main m = new Main();
		m.exec();
	}
//===========
// variables
//
	Scanner sc;
	String S;
	int[][] solCnt; // solCnt[i][x] : ≡ x となる解の個数(i 文字まで)
	
	private static final int MOD = 1000000007;
	
	// 10a + x ≡ b (mod 13) (x=0,1,..,9, b=0,1,...,12)
	// の解の個数を計算する。
	// 変形して x ≡ b-10a が 0～9 の場合 x は 1 つ定まり、そうでないとき
	// 解はない。
	
//=============
// constructor
//
	public Main() {
		sc = new Scanner(System.in);
	}
	
//==================
// instance methods
//
	void out(Object o) {
		System.out.println(o);
		System.out.flush();
	}
	
	public void exec() throws Exception {
		S = sc.next();
		
		solCnt = new int[S.length()][13];
		
		for (int i = 0; i < S.length(); i++) {
			// 解の個数を求めていく
			char digit = S.charAt(i);
			if (digit == '?') {
				for (int b = 0; b < 13; b++) {
					for (int a = 0; a < 13; a++) {
						if (i == 0 && a > 0) continue; // 最初は a=0 だけ処理
						// 解があるかをチェック
						int a10 = (a * 10)%13; // 0-12
						int x = (b - a10 + 13)%13;
						if ( (0 <= x) && (x <= 9) ) {
							// 解がある
							solCnt[i][b] += (i>0)? solCnt[i-1][a]:1;
							solCnt[i][b] = solCnt[i][b] % MOD;
						}
					}
				}
			} else {
				// 定数(m)の場合
				// 10a + m ≡ b となるかをチェック
				for (int b = 0; b < 13; b++) {
					for (int a = 0; a < 13; a++) {
						if (i == 0 && a > 0) continue; // 最初は a=0 だけ処理
						// 解があるかをチェック
						int a10 = (a * 10)%13; // 0-12
						int m = (b - a10 + 13)%13;
						if ( m == (int)(digit - '0')) {
							// 解がある
							solCnt[i][b] += (i>0)? solCnt[i-1][a]:1;
							solCnt[i][b] = solCnt[i][b] % MOD;
						}
					}
				}
			}
		}
		
		//
		out(solCnt[S.length()-1][5]);
	}
//=================

	/**
	 * 拡張ユークリッド互除法
	 * ax+by=gcd(a,b) となる gcd,x,y を求める。
	 */
	public static final int[] extgcd(int a, int b) {
		int x0 = 1, x1 = 0;
		int y0 = 0, y1 = 1;
	
		while (b != 0) {
			int q = a / b;
			int r = a % b;
			int x2 = x0 - q * x1;
			int y2 = y0 - q * y1;
	
			a = b; b = r;
			x0 = x1; x1 = x2;
			y0 = y1; y1 = y2;
		}
	
	    return new int[]{a, x0, y0};
	}

}


Measured memory_bytes: 32960
local ior = io.input()
local n, x = ior:read("*n", "*n")
local sum = n
local a, b = x, n - x
if(a < b) then a, b = b, a end
while(true) do
  if(a % b == 0) then
    sum = sum + b * (2 * (a // b) - 1)
    break
  else
    local rem = a % b
    sum = sum + 2 * (a - rem)
    a, b = b, rem
  end
end
print(sum)


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

using namespace std;

int dist[20][20];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
string *s;
int h, w;

int func(int sx, int sy, int gx, int gy) {
    queue<pair<int,int> > q;
    dist[sx][sy] = 0;
    q.push(pair<int,int>(sx, sy));
    
    while (!q.empty()) {
        pair<int,int> u = q.front();
        int x = u.first, y = u.second;

        for (int i = 0; i < 4; i++) {
            int a = x + dx[i], b = y + dy[i];
            if (a < 0 || h <= a || b < 0 || w <= b || s[a][b] == '#' || dist[a][b] != -1)
                continue;
            
            dist[a][b] = dist[x][y] + 1;
            q.push(pair<int,int>(a, b));
        }
        q.pop();
    }

    return dist[gx][gy];
}

int main() {
    cin >> h >> w;
    s = new string[h];
    for (int i = 0; i < h; i++)
        cin >> s[i];

    int ans = 0;
    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            for (int k = 0; k < h; k++) {
                for (int l = 0; l < w; l++) {
                
                    for (int m = 0; m < h; m++) {
                        for (int n = 0; n < w; n++)
                            dist[m][n] = -1;
                    }
                if (s[i][j] == '.' && s[k][l] == '.')
                    ans = max(ans, func(i, j, k, l));
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long int ll;
typedef vector<int> vi;     typedef vector<ll> vl;
typedef vector<vi> vvi;     typedef vector<vl> vvl;
typedef pair<int, int>  pii;  typedef pair<ll, ll> pll;
typedef vector<pii> vii;    typedef vector<pll> vll;
typedef map<int,int> mii;
typedef vector<char> vc;
typedef vector<bool> vb;
#define endl '\n'
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (ll)x.size()
#define MOD 1000000007
#define F first
#define S second
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define in insert
#define mp make_pair
#define fill(a,x) memset(a,x,sizeof a);
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
const ll INFL = 1e18;
const int INFI = 1e9;
#ifdef EVIL
	#include "../../trace.h"
#else
	#define trace(args...)
#endif

ll div_floor(const ll &a,const ll &b) { return a / b - (((a ^ b) < 0) and a % b);}
ll div_ceil(const ll &a,const ll &b) { return a / b + (((a ^ b) >= 0) and a % b);}
ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; 
	while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}
// void graph(vvi &adj, int m) {int x, y; forn(i, m){cin>>x>>y; adj[--x].pb(--y); adj[y].pb(x);}}



void solve(){
	int a,b;
	cin>>a>>b;
	cout<<a*b;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	#ifdef EVIL
		freopen("inp.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
		freopen("err.txt", "w", stderr);
	#endif
	int t=1;
	// cin>>t;
	rep(q,0,t-1){
		solve();
	}
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
string s;
int k, n;
vector<int> nums;

void solve() {
	cin >> s >> k;
	n = s.size();

	for (int i = 0, cnt = 0; i < n; ++i) {
		if (i != n - 1 && s[i] == s[i + 1]) {
			++cnt;
		}
		else {
			nums.push_back(cnt + 1);
			cnt = 0;
		}
	}

	if (nums.size() == 1) {
		printf("%lld\n", (long long)k * nums[0] / 2);
	}
	else if (s[0] != s[n - 1]) {
		long long sum = 0;
		for (int i = 0; i < nums.size(); ++i) {
			sum = sum + 1ll * nums[i] / 2 * k;
		}
		printf("%lld\n", sum);
	}
	else {
		long long sum = 0;
		for (int i = 1; i < nums.size() - 1; ++i) {
			sum = sum + 1ll * nums[i] / 2 * k;
		}
		sum += nums[0] / 2 + nums[nums.size() - 1] / 2;
		sum += 1ll * (nums[0] + nums[nums.size() - 1]) / 2 * (k - 1);
		printf("%lld\n", sum);
	}
}
int main() {
	solve();

	return 0;
}

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

    public static void main(String[] args) {
        int max = 0;
        int small =1000;
        int sum=0;
        int average=0;
        Scanner sc = new Scanner(System.in);
        while (true) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
            int[] values = new int[n];
            for (int i = 0; i < values.length; i++) {
                values[i] = sc.nextInt();
            }
            for (int j = 0; j < values.length; j++) {
                if (max < values[j]) {
                    max = values[j];
                }
                if (small > values[j]) {
                    small = values[j];
                }
            }
            for(int j=0;j<values.length;j++){
                sum=sum+values[j];
            }
            average=(sum-max-small)/(n-2);
            System.out.println(average);
            sum=0;
            small=1000;
            max=0;
            }

    }
}



Measured memory_bytes: 29264
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n;
ll t[105];

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

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n;
	ll l = 1;
	FOR(i, n) {
		cin >> t[i];
		if (t[i] % l) l = lcm(l, t[i]);
		else l = t[i];
	}
	cout << l << endl;
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    int N,M,X,Y;
    cin >> N >> M >> X >> Y;
    int x[100],y[100];
    for(int i=0;i<N;i++) cin >> x[i];
    for(int i=0;i<M;i++) cin >> y[i];
    sort(x,x+N);
    sort(y,y+M);
    if(max(x[N-1],X)<min(y[0],Y)) cout << "No War" << endl;
    else cout << "War" << endl;
    
    return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(ReadLine());
        var A = ReadLine().Split(' ').Select(s => int.Parse(s)).OrderByDescending(x => x).ToArray();

        var ans = 0L;

        for (int i = 0; i < N - 1; i++)
        {
            ans += A[(i + 1) / 2];
        }

        WriteLine(ans);
    }
}


Measured memory_bytes: 49292
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int n,m,xx[10005],yy[10005],ff[10005];
double ans;
struct pt
{
	int a,b;
	double ds;	
}c;
bool cmp(pt r,pt s)
{
	return r.ds>s.ds;
}
int ft(int x)
{
	if(ff[x]==x) return x;
	return ff[x]=ft(ff[x]);
}
vector<pt>p;
int main()
{
	int i;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++) { scanf("%d%d",&xx[i],&yy[i]);ff[i]=i;}
	for(i=1;i<=m;i++)
	{
		scanf("%d%d",&c.a,&c.b);
		c.ds=sqrt((xx[c.a]-xx[c.b])*(xx[c.a]-xx[c.b])+(yy[c.a]-yy[c.b])*(yy[c.a]-yy[c.b])+0.0);
		p.push_back(c);
	}
	sort(p.begin(),p.end(),cmp);
	for(i=0;i<m;i++)
		if(ft(p[i].a)!=ft(p[i].b)) ff[ft(p[i].b)]=ft(p[i].a);
		else ans+=p[i].ds;
	printf("%.3f\n",ans);
}

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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

int main(){

    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    int x = 0;
    for(int i = 0; i < n; i++){
        if(s[i] == 'I'){
            x++;
        }
        else if(s[i] == 'D'){
            x--;
        }
        if(ans < x) ans = x;
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3648
# -*- coding: utf-8 -*-

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

cnt = 0
for i in range(N):
    tmp = aN[i]
    while True:
        if tmp % 2 == 0:
            cnt += 1
            tmp //= 2
        else:
            break
print(cnt)

Measured memory_bytes: 4148
#include <bits/stdc++.h>
using namespace std;
int main() {
    
  int n=0;
  cin>>n;
  
  int64_t L[100];
  L[0]=2;
  L[1]=1;
  
  for(int i=2;i<=n;i++)
  {
     L[i]=L[i-2]+L[i-1];
  }
  
  cout<<L[n]<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <ctime>
using namespace std;
 
#define rep(i,a,n) for(int i=a; i<n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 999999999
 
#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
 
typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;
 
typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;
 
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;
 
namespace std {
    bool operator<(const P a, const P b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

// 2???????????????????????????????±???????
double dot(P a, P b) {
    return (a.X * b.X + a.Y * b.Y);
}
 
// 2???????????????????????????????±???????
double cross(P a, P b) {
    return (a.X * b.Y - a.Y * b.X);
}
 
int main() {
 	P a, b, c, d;
 	while(cin >> a.X >> a.Y >> b.X >> b.Y >> c.X >> c.Y >> d.X >> d.Y) {
 		if(a.X > d.X || a.Y > d.Y || b.X < c.X || b.Y < c.Y) cout << "NO" << endl;
 		else cout << "YES" << endl;
 	}
    return 0;
}

Measured memory_bytes: 1216
a,b=map(int,input().split())
cnt=0
for i in range(a,b+1):  
  ii=str(i)
  if ii[-1]!="0":
    flg=True
    for i in range(2):
      if ii[i] != ii[-i-1]:
        flg=False
    if flg:
      cnt+=1
print(cnt)      

Measured memory_bytes: 3060
my $min = 0;

MAIN : {
	my $s1 = <STDIN>;
	chomp $s1;
	my ($a1, $b1) = split(" ", $s1);

	my $s2 = <STDIN>;
	chomp $s2;
	my ($a2, $b2) = split(" ", $s2);

	my $s3 = <STDIN>;
	chomp $s3;
	my ($a3, $b3) = split(" ", $s3);

	
	
	my %a;
	$a[1] = $a1;
	$a[2] = $a2;
	$a[3] = $a3;
	
	my %b;
	$b[1] = $b1;
	$b[2] = $b2;
	$b[3] = $b3;


	my %c;
	$c{1} = 0;
	$c{2} = 0;
	$c{3} = 0;
	
	$c{$a1} += 1;
	$c{$a2} += 1;
	$c{$a3} += 1;
	
	$c{$b1} += 1;
	$c{$b2} += 1;
	$c{$b3} += 1;

	# a1が繋がっている箇所を探す
	
	my $yes = 1;
	foreach my $hoge (values(%c)) {
		if ($hoge eq 0) {
			$yes = 0;
			break;
		}
		if ($hoge eq 3) {
			$yes = 0;
			break;
		}
	}
	


	if ($yes eq 1) {
		print STDOUT "YES\n";
	}
	else {
		print STDOUT "NO\n";
	}
}




__END__

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

#ifdef DEBUG
#define DBG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)
#else
#define DBG(fmt, ...)
#endif

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll A,B,C,X,Y;

    cin >> A >> B >> C >> X >> Y;

    ll a,b,c;
    a = X;
    b = Y;
    c = 0;

    ll ans = INF;
    ll cost;
    while(true){
        cost = a*A + b*B + c*C;
        ans = min(ans, cost);
        if( a == 0 && b == 0 ){
            break;
        }

        a = max((ll)0, a-1);
        b = max((ll)0, b-1);
        c += 2;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3624
#include<stdio.h>

int main(){
	int a, b, d, r;
	double f;
	scanf("%d %d", &a, &b);
	d = a/b;
	r = a%b;
	f = (double)a/(double)b;
	printf("%d %d %lf\n", d, r, f);
	return 0;
}

Measured memory_bytes: 636
#include <iostream>

using namespace std;

int main()
{
    int n;
    cin >> n;
    for(int i=1; i<=9; i++){
        for(int j=1; j<=9; j++){
            if(i*j == n){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define ALL(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;

string func(ll N) {
    string ans = "";
    while (N > 0) {
        N = N - 1;
        int tmp = N % 26;
        ans = (char)('a' + tmp) + ans;
        N /= 26;
    }
    return ans;
}
int main() {
    ll N;
    cin >> N;
    cout << func(N) << endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int size=1e5;
const long inf=1e9;
int main(){
	string s;long K; cin>>s>>K;
	int i = 0;
	while(s[i] == '1' && i < s.size()) i++;
	if(K <= i) cout<<1<<endl;
	else cout<<s[i]<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<tgmath.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define miin(a, b, c) min((a), min((b), (c)))
#define maax(a, b, c) max((a), max((b), (c)))
#define mod 1000000007
#define MAX_NYAA 100000000

int n, m, x, c[15], a[15][15], b[15], d[15]={}, nyaa = MAX_NYAA;

main(){
    scanf("%d%d%d", &n, &m, &x);
    for(int i=0; i<n; i++){
        scanf("%d", &c[i]);
        for(int j=0; j<m; j++){
            scanf("%d", &a[i][j]);
        }
    }
    for(int i=0; i<(1<<n); i++){
        int tmp1 = 0, tmp2 = 1;
        for(int j=0; j<m; j++){
            b[j] = 0;
        }
        if(i){
            int j=0;
            for(;d[j];j++)d[j]=0;
            d[j]=1;
        }
        for(int j=0; j<n; j++){
            if(d[j] == 1){
                tmp1 += c[j];
                for(int k=0; k<m; k++){
                    b[k] += a[j][k];
                }
            }
        }
        for(int j=0; j<m; j++){
            if(b[j] < x)tmp2 = 0;
        }
        if(tmp2){
            nyaa = min(nyaa, tmp1);
        }
    }
    printf("%d\n", nyaa==MAX_NYAA?-1:nyaa);
    return 0;
}

Measured memory_bytes: 1732
def f(ks, d):
    md = 10 ** 9 + 7
    dp = [0] * d
    just = 0

    for k in ks:
        ndp = [0] * d

        ndp[0] = s = sum(dp[i % d] for i in range(-9, 1))
        for i in range(1, d):
            ndp[i] = s = (s + dp[i % d] - dp[(i - 10) % d]) % md

        for ndi in range(just, just + k):
            ndp[ndi % d] += 1

        just = (just + k) % d
        dp = ndp

    print((dp[0] + (just == 0) - 1) % md)


ks = list(map(int, list(input())))
d = int(input())
f(ks, d)


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}



int main()
{
    fastio();
    int a,b;
    cin>>a>>b;
    if(a<=5) cout<<0<<endl;
    else if(6<=a && a<=12) cout<<b/2<<endl;
    else cout<<b<<endl;
    return 0;
}


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

int top = -1;
int S[100];

void push(int);
void operate(char);
int pop(void);

int main(){
  char n[100];

 
   while(1){
    if(scanf("%s ", n) == EOF) break;

    if(n[0] == '+' || n[0] == '-' || n[0] == '*'){
      operate(n[0]);
    }else {
      push(atoi(n));
    }
  }

  printf("%d\n", S[top]);

  return 0;

}

void push(int n){
  top++;
  S[top] = n;
}

int pop(){
  int n;

  n = S[top];

  top--;

  return n;

}

void operate(char o){
  int n;
  int a, b;

  switch(o){
  case '+':
    n = pop() + pop();
    break;
  case '-':
    // n = -1 * (pop() - pop()); 
    a = pop();
    b = pop();
    n = -1 * (a - b);
    break;
  case '*':
    n = pop() * pop();
    break;
  }
    push(n);
}

Measured memory_bytes: 552
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
using namespace std;

/*----------macros----------*/

//output================
#define endl '\n'
#define fcout cout << fixed << setprecision(15)

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF9   = (ll)1e9 + 1;
constexpr ll INF18  = (ll)1e18 + 1;
constexpr ll MOD    = 1000000007;
constexpr ld PI     = 3.141592653589793L;

//member================
#define pb push_back
#define eb emplace_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second

//others================
#define all(x)          (x).begin(), (x).end()
#define rall(x)         (x).rbegin(), (x).rend()
#define rep(i, n)       for(int i = 0; (i) < (n); ++(i))
#define rrep(i, n)      for(int i = n - 1; (i) >= 0 ; --(i))
#define For(i, a, b)    for(int i = (a); (i) < (b) ; ++(i))
#define CtoI(c)         int((c)) - int('0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
//vector<int> dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
/*----------fastio----------*/
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
/*----------solve-----------*/

    int n; cin >> n;
    
    ll ans = 1;
    For(i, 1, n+1){
        ans = (ans * (i % MOD)) % MOD;
    }

    cout << ans << endl;

return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

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

signed main(){
    int h,w;
    cin >> h >> w;
    char s[h][w];
    REP(i,h){
        REP(j,w){
            cin >> s[i][j];
        }
    }
    ll ans = 0;
    bool used[h][w] = {};
    REP(i,h){
        REP(j,w){
            if(used[i][j] == true){
                continue;
            }
            ll black = 0, white = 0;
            if(s[i][j] == '#'){
                black++;
            }else{
                white++;
            }
            queue<P> que;
	        que.push(P(i, j));
            used[i][j] = true;
	        while(que.size()){
                P p = que.front();
                que.pop();
                REP(k,4){
                    int ny = p.first + dy[k], nx = p.second + dx[k];
                    if(0 <= ny && ny < h && 0 <= nx && nx < w && used[ny][nx] == false && s[p.first][p.second] != s[ny][nx]){
                        if(s[ny][nx] == '#'){
                            black++;
                        }else{
                            white++;
                        }
                        que.push(P(ny, nx));
                        used[ny][nx] = true;
                    }
                }
            }
            ans += black * white;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 512
#define ONLINE_JUDGE
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(n);++i)
#define _repe3(i,a,b) for(ll i=(a);i<=(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(b)-1;i>=(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
template<class T>
bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>
bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<class T>
using pq=priority_queue<T,vector<T>,greater<T>>;

ll X;

void solve();

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin >> X;
    solve();
}

// 101 < X < 10^{18}
// 入力はすべて整数

// ll X
// 高橋くんの預金額が初めて X 円以上になるのは何年後かを出力せよ。
void solve(){
    ll m=100;
    ll ans=0;
    while(1){
        ++ans;
        m=m+m/100;
        if(m>=X){
            cout<<ans<<endl;
            return;
        }
    }
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(c)              c.begin(), c.end()
#define FastRead ios_base::sync_with_stdio(false);cin.tie(NULL);
#define EPS 1e-9
using namespace std;

int main()
{
    FastRead
    ll x,y,z,a=0,b=0;
    cin >> x;
    int flag=0;
    while(1)
    {
        ll c=0;
        for(int i=2;i<=sqrt(x);i++)
        {
            if(x%i==0)
               c++;
        }
        if(c==0)
            break;
        x++;
    }
    cout <<x<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int K;
    cin >> K;
    string S;
    cin >> S;

    if (S.length() <= K) {
        cout << S << endl;
    } else {
        cout << S.substr(0, K) << "..." << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define N 100010
#define M 1010

using namespace std;
ll a;

void dfs(ll x) {
	if (x == 0) return;
	ll a = x % 26;
	if (x % 26 == 0)
		dfs(x / 26 - 1);
	else dfs(x / 26);
	if (a == 0) cout << 'z';
	else cout << char(a + 'a' - 1);
}

int main() {
	cin >> a;
	dfs(a);
}

Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
ll solve(vector<vector<ll>> vec,ll K,ll w){
  ll res=0;
  ll h=vec[1].size();
  vector<ll> sum(vec[1].size(),0);
  for(int i=1;i<=w;i++){
    bool f=false;
    for(int j=0;j<h;j++){
      if(vec[i][j]>K){
        return 17441744174417;
      }
      else if(sum[j]+vec[i][j]>K){
        f=true;
      }
    }
    if(f){
      for(int j=0;j<h;j++){
        sum[j]=0;
      }
      res++;
    }
    for(int j=0;j<h;j++){
      sum[j]+=vec[i][j];
    }
  }
  return res;
}
ll field[15][1005]={0};
int main(){
  ll h,w,K;
  cin>>h>>w>>K;
  for(int i=0;i<h;i++){
    for(int j=1;j<=w;j++){
      char c;
      cin>>c;
      field[i][j]=(int)(c-'0');
    }
  }
  ll ans=17441744174417;
  for(int i=0;i<(1<<(h-1));i++){
    vector<vector<ll>> vec(w+5);
    ll cnt=0;
    for(int k=0;k+1<h;k++){
      if(((i>>k)&1)==1) cnt++;
    }
    for(int j=1;j<=w;j++){
      vec[j].push_back(field[0][j]);
      for(int k=0;k+1<h;k++){
        if(((i>>k)&1)==1){
          //cut
          vec[j].push_back(field[k+1][j]);
        }
        else vec[j][vec[j].size()-1]+=field[k+1][j];
      }
    }
  //  cout<<i<<" "<<solve(vec,K,w)<<endl;
    ans=min(ans,solve(vec,K,w)+cnt);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 660
from itertools import combinations
n = int(input())
counter = {"M": 0, "A": 0, "R": 0, "C": 0, "H": 0}
for i in range(n):
  s = input()[0]
  if s in "MARCH":
    counter[s] += 1
ans = 0
for c in combinations("MARCH", 3):
  ans += counter[c[0]] * counter[c[1]] * counter[c[2]]
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    int a[n];
    for(int i = 0; i < n; i++)
        scanf("%d",&a[i]);
    long long ans = 0;
    for(int i = 1; i < n; i++){
        if(a[i] > a[i - 1])
            continue;
        int d = a[i - 1] - a[i];
        ans += d;
        a[i] = a[i - 1];
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 2484
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include<iomanip>

using namespace std;
#define ff(ii,nn,mm) for(int ii=nn;ii<mm;ii++)
#define i64 int64_t
#define tos(x) to_string(x)

int main() {
	int a, b;
	cin >> a >> b;
	if ((a + b )% 3 == 0 || a % 3 == 0 || b % 3 == 0) {
		cout << "Possible" << endl;
		return 0;
	}
	cout << "Impossible" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<string>
using namespace std;
int main(){
  string a,b;
  cin>>a>>b;
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  if(a<b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
    }

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

#define N_MAX 100

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

    double ans = 0;
    for (long i = 0; i < n; i++) {
        double x;
        string u;
        cin >> x >> u;

        if (u == "JPY") {
            ans += x;
        }
        else if (u == "BTC") {
            ans += (x * 380000);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int w, h;
    while(cin >> w >> h, w) {
        int n;
        cin >> n;
        vector<int> x1(n), y1(n), x2(n), y2(n), xs, ys;
        for(int i=0; i<n; ++i) {
            cin >> x1[i] >> y1[i] >> x2[i] >> y2[i];
            int d[3] = {-1, 0, 1};
            for(int j=0; j<3; ++j) {
                if(0 <= x1[i] + d[j] && x1[i] + d[j] < w) {
                    xs.push_back(x1[i] + d[j]);
                }
                if(0 <= x2[i] + d[j] && x2[i] + d[j] < w) {
                    xs.push_back(x2[i] + d[j]);
                }
                if(0 <= y1[i] + d[j] && y1[i] + d[j] < h) {
                    ys.push_back(y1[i] + d[j]);
                }
                if(0 <= y2[i] + d[j] && y2[i] + d[j] < h) {
                    ys.push_back(y2[i] + d[j]);
                }
            }
        }
        sort(xs.begin(), xs.end());
        sort(ys.begin(), ys.end());
        xs.erase(unique(xs.begin(), xs.end()), xs.end());
        ys.erase(unique(ys.begin(), ys.end()), ys.end());
        for(int i=0; i<n; ++i) {
            x1[i] = lower_bound(xs.begin(), xs.end(), x1[i]) - xs.begin();
            y1[i] = lower_bound(ys.begin(), ys.end(), y1[i]) - ys.begin();
            x2[i] = lower_bound(xs.begin(), xs.end(), x2[i]) - xs.begin();
            y2[i] = lower_bound(ys.begin(), ys.end(), y2[i]) - ys.begin();
        }
        w = xs.size();
        h = ys.size();
        vector<vector<bool>> field(w, vector<bool>(h));
        for(int i=0; i<n; ++i) {
            for(int j=x1[i]; j<x2[i]; ++j) {
                for(int k=y1[i]; k<y2[i]; ++k) {
                    field[j][k] = true;
                }
            }
        }
        int res = 0;
        for(int i=0; i<w; ++i) {
            for(int j=0; j<h; ++j) {
                if(!field[i][j]) {
                    res++;
                    queue<P> que;
                    que.push(P{i, j});
                    while(!que.empty()) {
                        P p = que.front();
                        que.pop();
                        int dx[4] = {0, 1, 0, -1},
                            dy[4] = {1, 0, -1, 0};
                        for(int k=0; k<4; ++k) {
                            int nx = p.first + dx[k],
                                ny = p.second + dy[k];
                            if(nx < 0 || w <= nx || ny < 0 || h <= ny || field[nx][ny]) {
                                continue;
                            }
                            field[nx][ny] = true;
                            que.push(P{nx, ny});
                        }
                    }
                }
            }
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 3196
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output


def chkprint(*args):
    names = {id(v): k for k, v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg), '???')+' = '+repr(arg) for arg in args))

# Binary converter


def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]

# --------------------------------------------


dp = None


def main():
    t = 0
    A = li_input()

    while max(A) - min(A) > 1:
        t += 1
        A[A.index(min(A))] += 2

    if A.count(max(A)) == 2:
        t += 2
    elif A.count(max(A)) == 1:
        t += 1

    print(t)


main()


Measured memory_bytes: 4628
while True:
    n = int(input())
    if n == 0:
        break
    Scr = list(map(int, input().split()))
    ScrSq = []

    for i in Scr:
        ScrSq.append(i**2)

    print((sum(ScrSq)/n - (sum(Scr)/n)**2)**(1/2.0))


Measured memory_bytes: 5676
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define ALL(x) (x).begin(),(x).end()
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
using P=pair<int,int>;

signed _main(){
  int N; cin >> N;
  v<P> xy(N);
  rep(i,N){
    cin >> xy[i].first >> xy[i].second;
  }
  sort(ALL(xy));
  map<P,int> mp;
  int ans=0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
        int x=xy[i].first-xy[j].first;
        int y=xy[i].second-xy[j].second;
        mp[P(x,y)]++;
        //cout << "xy " << x << " " << y <<  " " << mp[P(x,y)] << endl;
        chmax(ans,mp[P(x,y)]);
    }
  }
  cout << N-ans << endl;
  return 0;
}


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

int main(){
    vector<int> isprime;
    int n;
    while (cin >> n){
	for (int i = 0; i <= n; i++) isprime.push_back(1);
	
	int prime = 0;
	for (int i = 2; i <= n; i++){
	    if (isprime[i]){
		prime++;
		for (int j = 2; i * j <= n; j++) isprime[i*j] = 0;
	    }
	}
	cout << prime << endl;
	isprime.clear();
    }
    return 0;
}

Measured memory_bytes: 4940
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(a>b && a>c) {
        	if(a==(b+c)) {
        		System.out.println("Yes");
        		System.exit(0);
        	}
        	else {
        		System.out.println("No");
        		System.exit(0);
        	}
        }
        else if(b>a && b>c) {
        	if(b==(a+c)) {
        		System.out.println("Yes");
        		System.exit(0);
        	}
        	else {
        		System.out.println("No");
        		System.exit(0);
        	}
        }
        else {
        	if(c==(a+b)) {
        		System.out.println("Yes");
        		System.exit(0);
        	}
        	else {
        		System.out.println("No");
        		System.exit(0);
        	}
        }
    }
}



Measured memory_bytes: 23764
/*
    Those who cannot remember the past are condemned to repeat it.
                                            - Dynamic Programming
    
    I never lose, I either win or I learn.
                - Competitive Programming

*/

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st;
        PrintWriter pw = new PrintWriter(System.out);
        
        st = new StringTokenizer(br.readLine());
        String s1 = st.nextToken();
        String s2 = st.nextToken();
        st = new StringTokenizer(br.readLine());
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        String u = br.readLine();
        if(u.equals(s1)) {
            a--;
        }
        else {
            b--;
        }

        pw.println(a + " " + b);
        
        
        
        
        
        pw.flush();
        pw.close();
    }
}


Measured memory_bytes: 21204
import math

def main():

    mp = {
        "AC": 0,
        "WA": 0,
        "TLE": 0,
        "RE": 0
    }

    n = int(input())
    for _ in range(n):
        s = input()
        mp[s]+=1

    for key in mp.keys():
        print(key, "x", mp[key])
main()

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

int main(){
  int n; cin>>n;
  vector<int> b(n-1,0);
  for(int i=0;i<n-1;i++)cin>>b[i];
  
  int ans=0;
  for(int i=0;i<n;i++){
    if(i==0){
      ans+=b[0];
    }else if(i==n-1){
      ans+=b[n-2];
    }else{
      ans+=min(b[i],b[i-1]);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256