akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

typedef pair<int,int> pi;

typedef unsigned long long int lli;

int main(void){
    // Here your code !
    lli h,w,n;
    cin >> h >> w >> n;
    
    vector<pi> all;
    map<pi,int> m;
    vector<int> ans(9,0);
    
    for(int i = 0; i < n; i++){
        int a,b;
        cin >> a >> b;
        
        m[pi(a,b)] = 1;
        
        for(int x = -1; x < 2; x++){
            for(int y = -1; y < 2; y++){
                if(a+y <= 1 || a+y >= h || b+x <= 1 || b+x >= w ){
                    continue;
                }
                
                all.push_back(pi(a+y,b+x));
            }
        }
        
    }
    
    std::sort(all.begin(), all.end());
    all.erase(std::unique(all.begin(), all.end()), all.end());
    
    for(int i = 0; i < all.size(); i++){
        int tmp = 0;
        
        for(int x = -1; x < 2; x++){
            for(int y = -1; y < 2; y++){
                //cout << m[pi(all[i].first + y,all[i].second+x)] << " ";
                if(m[pi(all[i].first + y,all[i].second+x)] == 1){
                    tmp++;
                }
            }
            //cout << endl;
        }
        //cout << "t" << tmp  << " " << all[i].first << " " << all[i].second << endl;
        
        if(tmp)ans[tmp-1]++;
        
    }
    
    
    lli add = 0;
    for(int i = 0; i < 9; i++)
        add += ans[i];
    
    cout << (h-2)*(w-2)-add << endl;
    
    
    for(int i = 0; i < 9; i++)
        cout << ans[i] << endl;
        
    
    
}


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

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    int num = 0;
    int search = 1;
    bool check = false;
    rep(i, n){
        if(a[i] == search){
            search++;
            check = true;
        }else{
            num++;
        }
    }
    cout << (!check? -1: num) << endl;

}

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

#define MAX_LEN 3

int compare(const void *a, const void *b)
{
	if (*(int *)a > *(int *)b)
		return 1;
	else if (*(int *)a < *(int *)b)
		return -1;
	else
		return 0;
}

int main(void)
{
	int A[MAX_LEN] = {0};
	int i, res = 0;
	size_t array_size = sizeof(A) / sizeof(A[0]);

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

	qsort((void *)A, array_size, sizeof(A[0]), compare);

	for (i = 1; i < (int)array_size; i++)
		res += abs(A[i] - A[i - 1]);

	printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;

public static partial class Program
{
    public static void Main()
    {
        var str = CRL();
        for (int rmCnt = 2; rmCnt < str.Length; rmCnt++)
        {
            var s = str.Substring(0, str.Length - rmCnt);
            if (s.Length.IsEven() == false)
            {
                continue;
            }
            
            if (s.Substring(0, s.Length / 2) == s.Substring(s.Length / 2))
            {
                CWL(s.Length);
                return;
            }
        }
    }
}

public static partial class Program
{
    //テンプレここから
    public static int Sigma(int n, int next = 1, int val = 0) => next > n ? val : Sigma(n, next + 1, val + next);
    public static long GCD(long a, long b) => b == 0 ? a : GCD(b, a % b);
    public static int GCD(int a, int b) => b == 0 ? a : GCD(b, a % b);
    public static long LCM(long a, long b) => a * b / GCD(a, b);
    public static int LCM(int a, int b) => a * b / GCD(a, b);
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static int ToInt(this double d) => (int) d;
    public static long ToLong(this double d) => (long) d;
    public static int ToInt(this string str) => int.Parse(str);
    public static long ToLong(this string str) => long.Parse(str);
    public static long[] ToLong(this IEnumerable<string> strs) => strs.Select(x => x.ToLong()).ToArray();
    public static int[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToLong();
    public static int[] ArrayInts(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static int Diff(int a, int b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static readonly int[] Dx = new[] {0, -1, 0, 1};
    public static readonly int[] Dy = new[] {-1, 0, 1, 0};
    public const int Mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    public static long[] Sort(this long[] array) => array.OrderBy(x => x).ToArray();
    public static int[] Sort(this int[] array) => array.OrderBy(x => x).ToArray();
    public static long[] DSort(this long[] array) => array.OrderByDescending(x => x).ToArray();
    public static int[] DSort(this int[] array) => array.OrderByDescending(x => x).ToArray();
    public static string Join(this IEnumerable<string> array, string sep = "") => string.Join(sep, array);
    public static string Join(this IEnumerable<char> array, string sep = "") => string.Join(sep, array);

    public static string JoinToStr(this IEnumerable<int> array, string sep = "")
        => array.Select(x => x.ToString()).Join(sep);

    //テンプレここまで
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

// ref : https://drken1215.hatenablog.com/entry/2018/09/02/020500

int main(){
    ll l;
    cin >> l;
    ll n = 0, p = 1;
    while(p <= l) {
        p *= 2;
        n++;
    }
    ll m = (n - 1) * 2 + __builtin_popcount(l) - 1;

    cout << n << " " << m << endl;
    rep(i, n-1) {
        cout << i+1 << " " << i+2 << " " << 0 << endl;
        cout << i+1 << " " << i+2 << " " << (1ll<<i) << endl;
    }
    
    ll now = 1<<(n-1);

    rrep(i, n-1){
        if (l & (1<<i)) {
            cout << i+1 << " " << n << " " << now << endl;
            now += (1ll<<i);
        }
    }
    return 0;
}


Measured memory_bytes: 3632
/*
Çé¿ö1
   1
  110
 01100
0011000
  ^^
Çé¿ö2
   0
  001
 10011
1100111
  ^^
Çé¿ö3
   1
  011
 00111
0010111
    ^^
Çé¿ö4
   0
  001
 00011
0001011
 ^^
Çé¿ö5 
   1
  101
 10101
1010101
^
Çé¿ö6
   0
  010
 01010
0101010
^
*/
#include<iostream>
using namespace std;

int n,a[20000010];
int l,r;

bool judge1(int k,int g,int h)
{return (a[g]>k)&&(a[h]>k);}
bool judge2(int k,int g,int h)
{return (a[g]<=k)&&(a[h]<=k);}
bool check(int x)
{
	for(int i=0;i<=n-2;i++)
	{
		if(judge1(x,n+i,n+i+1)||judge1(x,n-i,n-i-1))//1 3
			return 0;
		if(judge2(x,n+i,n+i+1)||judge2(x,n-i,n-i-1))//2 4
			return 1;
	}
	return judge2(x,1,1);//5 6
}

int main()
{
//	freopen("4.in","r",stdin);
	cin>>n;
	for(int i=1;i<=2*n-1;i++)
		cin>>a[i],r=max(r,a[i]);
	l=1;//r=2*n-1;
	while(l<r)
	{
//		cout<<l<<" "<<r<<endl;
		int mid=(l+r)/2;
		if(check(mid)) r=mid;
		else l=mid+1;
	}
	cout<<r<<endl;
//	for(int i=1;i<=n*2-1;i++)cout<<check(i);
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <vector>
using namespace std;

int main() {
    int n;
    cin>>n;
    string s;
    cin>>s;
    
    int mx = 0;
    for (int i=0; i<s.size(); i++) {
        set<char> st1, st2;
        for (int j = 0; j<=i; j++) {
            st1.insert(s[j]);
        }
        
        for (int j = i+1; j<s.size(); j++) {
            if(st1.find(s[j])!=st1.end()) {
                st2.insert(s[j]);
            }
        }
        mx = max(mx, (int)st2.size());
    }
    
    cout << mx;
    return 0;
}


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

int main(void){
	char **input;
	int i, j;
	
	input = (char **)malloc(sizeof(char *) * 50000);
	for (j = 0; j <= 49999; j++){
		input[j] = (char *)malloc(sizeof(char) * 6);
	}
	
	for (j = 0; j <= 49999; j++){
		fgets(input[j], sizeof(char) * 7, stdin);
		if ((atoi(input[j]) == 0)){
			break ;
		}
	}
	
	for (i = 0; i <= (j - 1); i++)
	printf("Case %d: %s", i + 1, input[i]);
	
	return 0;
}

Measured memory_bytes: 2508
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int zc = 0,oc = 0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i] == '0')zc++;
		if(s[i] == '1')oc++;
	 } 
	int k = min(zc,oc);
	cout<<k*2<<endl;
 } 

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<utility>
#include<map>
#include<algorithm>

using namespace std;
using ll = long long;

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

	map<string, int>ma;

	string tmp;
	for (int i = 0; i < N; i++) {
		cin >> tmp;
		ma[tmp]++;
	}

	int M;
	cin >> M;

	for (int i = 0; i < M; i++) {
		cin >> tmp;
		ma[tmp]--;
	}

	int ans = 0;

	for (auto itr : ma) {
		ans = max(itr.second, ans);
	}

	cout << ans << endl;
}

Measured memory_bytes: 3404
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; ha=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end
def bs(ar,eq,n) en=(eq==1 ? :>= : :>); ar.bsearch_index{|x|x.send(en,n)} end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n, k = gsmi
h = desc n.times.map{gi}

min = 10**9
l = 0
r = k-1
while r<n do
  diff = h[l] - h[r]
  min = diff if min>diff
  l+=1
  r+=1
end

puts min

Measured memory_bytes: 3704
#include<stdio.h>
int main() {
	int x, i = 0;
	while (1) {
		i++;
		if (i == 10001) break;
		scanf("%d", &x);
		if (x == 0 ) {
			break;
		}
		printf("Case %d: %d\n", i, x);
	}
	return 0;
}

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

import re

def main():
    sp = input().replace("?", ".")
    t = input()
    ns = len(sp)
    nt = len(t)
    if ns < nt:
        return False
    se = set()
    for i in range(len(sp) - len(t) + 1):
        if re.match(sp[i:i + nt], t):
            res = sp[:i] + t + sp[i + nt:]
            assert len(res) == ns
            se.add(res.replace(".", "a"))
    if len(se) == 0:
        return False
    return sorted(list(se))[0]

res = main()
print(res if res else "UNRESTORABLE")


Measured memory_bytes: 3188
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A, ll x = 10){cout << fixed << setprecision(x) << A << endl;}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}


void solve(){
  ll N, M;
  cin >> N >> M;
  vector<ll> A[N];
  rep(i, M){
    ll a; cin >> a; a--;
    string S;
    cin >> S;
    if(S == "AC") A[a].pb(1);
    else A[a].pb(-1);
  }
  ll ans = 0;
  ll Ans = 0, B = 0;
  rep(i, N){
    ll plus = 0;
    bool ac = 0;
    rep(j, A[i].size()){
      if(A[i][j] == -1) plus++;
      else{
        ac = 1;
        break;
      }
    }
    if(ac){
      Ans++;
      B += plus;
    }
  }
  cout << Ans << " " << B << endl;
}


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


Measured memory_bytes: 5760
#include<iostream>
#include<string>
#include<algorithm>
#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;
    int A[210000];
    REP(i, N) cin >> A[i];
    int num[210000];
    REP(i, N) num[i] = 0;
    REP(i, N) num[A[i] - 1] += 1;
    sort(num, num + N);
    int ans = 0;
    REP(i, N - K){
        ans += num[i];
    } 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		int x = scanner.nextInt();
		int y = scanner.nextInt();
		int min = y;
		int minxy = b;
		int max = x;
		int maxxy = a;
		if (x < y) {
			min = x;
			minxy = a;
			max = y;
			maxxy = b;  
		}
		
		int ans = (a * x) + (b * y);
		int ans2 = (min * 2) * c + ((max - min) * maxxy);
		int ans3 = (max * 2) * c;
		ans = Math.min(ans, ans2);
		ans = Math.min(ans, ans3);
		System.out.println(ans);
		
		scanner.close();
	}

}


Measured memory_bytes: 21972
#include <stdio.h>

enum {
	B = 4,
	F = 3,
	R = 10,
};

int
main()
{
	int rooms[B][F][R] = {0};
	int b, f, r, v;

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

	int i;
	for (i = 0; i < n; i++)
	{
		scanf("%d %d %d %d", &b, &f, &r, &v);
		rooms[b-1][f-1][r-1] += v;
		if (rooms[b-1][f-1][r-1] < 0)
			rooms[b-1][f-1][r-1] = 0;
	}

	for (b = 0; b < B; b++)
	{
		if (b != 0)
		{
			printf("####################\n");
		}

		for (f = 0; f < F; f++)
		{
			for (r = 0; r < R; r++)
			{
				printf(" %d", rooms[b][f][r]);
			}
			printf("\n");
		}
	}
	
	return 0;
}

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

    public static long Combination(long n, long r){
        long A = 1;
        long B = 1;
        for(long i = 0; i < r; i++){
            A = A*(n-i);
            B = B*(r-i);
        }
        if(A == 0) return 0;
        return A/B;
    }

    public static long solve(int i, int j, boolean check, int N, String S){
        if(i == N){
            if(j == 0){
                return 1;
            }else{
                return 0;
            }
        }

        if(j == 0) return 1;

        if(check){
            return Combination(N-i, j)*(long)Math.pow(9, j);
        }else{
            if(S.charAt(i) == '0') return solve(i+1, j, false, N, S);
            long Z = solve(i+1, j, true, N, S);
            long A = solve(i+1, j-1, true, N, S)*(S.charAt(i)-'1');
            long P = solve(i+1, j-1, false, N, S);
            return Z+A+P;
        }


    }
 
	public static void main(String[] $){
		Scanner s = new Scanner(System.in);
        int H = s.nextInt();
        int A = s.nextInt();
        int i = 0;
        while(H > 0){
            H = H - A;
            i++;
        }
        System.out.println(i);
	}
} 

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)  
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (int (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
#define pp printf("Case %d: \n",t)
const unsigned int mod = 1e9+7;
const int mx=1000005;
const int maxInt = 2147483647;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n,a,b;
    cin >> n >> a >>b;
    cout << min(n*a,b) << endl;
    return 0;
}


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

const int MAXN = 2e5;

int N;
int A[MAXN + 10];

int cc[25];

bool bad() {
   return *max_element(cc, cc + 20) > 1;
}

void add(int k, int x) {
   for(int i = 0; i < 20; i++) {
      if(A[k] & (1 << i)) cc[i] += x;
   }
}

int main() {
   scanf("%d", &N);
   for(int i = 0; i < N; i++) {
      scanf("%d", &A[i]);
   }
   long long res = 0;
   int l = 0, r = 0; add(r, +1);
   while(r < N) {
      while(l < r && bad()) {
         add(l, -1);
         l++;
      }
      res += r - l + 1;
      r++;
      if(r < N) add(r, +1);
   }
   printf("%lld\n", res);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(auto i = (N) - 1; i >= 0; i -= 1)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define rand mtrand
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cout << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,...) do { cout << #v << " = "; array_out(v , ##__VA_ARGS__);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
#endif
using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = 0x1FFFFFFFFFFFFFFFLL;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}

random_device seed_gen; mt19937_64 mtrand(seed_gen());
constexpr int MOD = 1000000007;
//////////////////////////////////////////

int main(){
  ini(H,W);
  vector<string> v(H);
  rep(i,H) in(v[i]);
  auto ok = [&](int a,int b){
    return 0<=a&&a<H&&0<=b&&b<W;
  };
  const int dx[] = {1,0};
  const int dy[] = {0,1};
  int h = 0 , w = 0;
  while(h!=H-1||w!=W-1){
    int dh ,dw;
    int cnt = 0;
    rep(k,2){
      dh = h + dx[k] , dw = w + dy[k];
      if(ok(dh,dw) && v[dh][dw] == '#') cnt++;
    }
    if(cnt != 1) die("Impossible");
    rep(k,2){
      dh = h + dx[k] , dw = w + dy[k];
      if(ok(dh,dw) && v[dh][dw] == '#'){
        v[h][w] = '.'; h = dh,w = dw; break;
      }
    }
  }
  v[h][w] = '.';
  rep(i,H) rep(j,W){
    if(v[i][j] == '#') die("Impossible");
  }
  out("Possible");

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int unsigned ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}

signed main(void) {
    int a,b;
    cin >> a >> b;
    double ans = 4.0/3 * M_PI * b*b*b;
    cout << shosu(10) << ans << endl;
}



Measured memory_bytes: 3288
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
#include <typeinfo>
#include <tuple>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define INF_LONG 1e18
#define rep(i, n) for(int i=0; i<n; ++i)
#define rep1(i, n) for(int i=1; i<=n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
#define countof(array) (sizeof(array) / sizeof(array[0]))
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

string ab = {"ABCDEFGHIJKLMNOPQRSTUVWXYZ"};
string as = {"abcdefghijklmnopqrstuvwxyz"};

ll gcd(ll x, ll y) {
  if(y==0) return x;
  else return gcd(y, x%y);
}

ll lcm(ll x, ll y) {
  return (x*y)/gcd(x, y);
}

void yes() {
  cout << "Yes" << endl;
}

void no() {
  cout << "No" << endl;
}

void print_array(int array[], int len) {

  for(int i=0; i<len; ++i) {
    cout << array[i] << endl;
  }

}

ll absolute(ll x) {
  return (x<0)? (-1)*x : x;
}

//g++ AtCoder.cpp -o AtCoder
//AtCoder

//--------------------------

ll a[MAX_N+1];
ll b[MAX_N];

int main() {

  ll n;
  cin >> n;
  rep(i, n+1) cin >> a[i];
  rep(i, n) cin >> b[i];

  ll res = 0;
  rep(i, n) {
    if(b[i]<=a[i]) {
      res += b[i];
    }else  {
      res += a[i];
      b[i] -= a[i];
      if(b[i]<=a[i+1]) {
        res += b[i];
        a[i+1] -= b[i];
      }else {
        res += a[i+1];
        a[i+1] = 0;
      }
    }
  }

  cout << res << endl;

  return 0;
}


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

int main(){
    
    int n;
    cin >> n;
    string s;
    cin >> s;
    int res = n;
    
    for(int i=0;i<n;i++){
        if(s[i]==s[i+1])    --res;
    }
    
    cout << res;
    
    
    
}

Measured memory_bytes: 512
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <bitset>
#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;

int main(int argc, char *argv[]) {
	int a, b, m;
	cin >> a >> b >> m;
	vector<int> va, vb;
	for (int i = 0; i < a; i++) {
		int t;
		cin >> t;
		va.push_back(t);
	}
	for (int i = 0; i < b; i++) {
		int t;
		cin >> t;
		vb.push_back(t);
	}
	int res = *min_element(va.begin(), va.end()) + *min_element(vb.begin(), vb.end());
	for (int i = 0; i < m; i++) {
		int x, y, c;
		cin >> x >> y >> c;
		res = min(res, va[x - 1] + vb[y - 1] - c);
	}
	cout << res << endl;
}









Measured memory_bytes: 1400
// unolight {{{
#include <bits/stdc++.h>
#include <unistd.h>
#define SZ(x) ((int)(x).size())
#define ALL(c) begin(c),end(c)
#define REP(i,n) for ( int i=0; i<(int)(n); i++ )
#define REP1(i,a,b) for ( int i=(int)(a); i<=(int)(b); i++ )
#define FOR(it,c) for ( auto it=(c).begin(); it!=(c).end(); it++ )
#define MP make_pair
#define PB push_back
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef long long LL;

void RI() {}

template<typename... T>
void RI( int& head, T&... tail ) {
    scanf("%d",&head);
    RI(tail...);
}

template<typename T>
void _dump( const char* s, T&& head ) { cerr<<s<<"="<<head<<endl; }

template<typename T, typename... Args>
void _dump( const char* s, T&& head, Args&&... tail ) {
    int c=0;
    while ( *s!=',' || c!=0 ) {
        if ( *s=='(' || *s=='[' || *s=='{' ) c++;
        if ( *s==')' || *s==']' || *s=='}' ) c--;
        cerr<<*s++;
    }
    cerr<<"="<<head<<", ";
    _dump(s+1,tail...);
}

#define dump(...) _dump(#__VA_ARGS__, __VA_ARGS__);

template<typename A, typename B>
ostream& operator <<( ostream &s, const pair<A,B> &p ) { return s<<"("<<p.first<<","<<p.second<<")"; }

template<typename Iter>
ostream& _out( ostream &s, Iter b, Iter e ) {
    s<<"[";
    for ( auto it=b; it!=e; it++ ) s<<(it==b?"":" ")<<*it;
    s<<"]";
    return s;
}
template<typename T>
ostream& operator <<( ostream &s, const vector<T> &c ) { return _out(s,ALL(c)); }
template<typename T>
ostream& operator <<( ostream &s, const set<T> &c ) { return _out(s,ALL(c)); }
template<typename A, typename B>
ostream& operator <<( ostream &s, const map<A,B> &c ) { return _out(s,ALL(c)); }

template<class T>
void chmax(T &a, T b) {
	if(a<b) a=b;
}

template<class T>
void chmin(T &a, T b) {
	if(a>b) a=b;
}
// }}}

const int MAX_N = 605;
int n, m;
vector<int> adj[MAX_N];
double ans=1e9, dp[MAX_N];


void input() {
    RI(n, m);
    REP(i, m) {
    	int u, v;
    	RI(u, v);
    	--u; --v;
    	adj[u].push_back(v);
    }
}
void solve() {
	dp[n-1] = 0;
	REP(k, n) {
		for(int i=n-2; i>=0; i--) {
			double maxi = 0;
			double cnt = 0;
			int n = adj[i].size();
			for(int j:adj[i]) {
				cnt += dp[j];
				chmax(maxi, dp[j]);
			}
			if(i == k && adj[i].size()>1) {
				cnt -= maxi;
				n--;
			}
			dp[i]=cnt/n + 1;
		}
		chmin(ans, dp[0]);
	}
	printf("%.10lf\n", ans);
}

int main( int argc, char *argv[] ) {
	input();
	solve();
    return 0;
}

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

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

// ref. https://drken1215.hatenablog.com/entry/2018/09/08/195000
int main(void) {
    int Q;
    cin >> Q;

    for (int i = 0; i < Q; i++) {
        ll a, b;
        cin >> a >> b;

        if (a > b) {
            swap(a, b);
        }

        if (a == b) {
            cout << 2 * (a - 1) << endl;
            continue;
        }

        ll left = 1, right = 1LL << 31, mid;
        while (right - left > 1) {
            mid = left + (right - left) / 2;

            // this condition is simpler
            if (((mid + 1) / 2) * ((mid + 1) - (mid + 1) / 2) < a * b) {

            // this conditon is complicated, but understandable.
            // ll m = (mid + 1) - a + 1;
            // ll n = (mid + 1) - b + 1;
            // if (((mid + 1) / 2) * ((mid + 1) - (mid + 1) / 2) < a * b
            //         && (m * n < a * b || (n == a && m == b))) {
                left = mid;
            } else {
                right = mid;
            }
        }

        // why -1?
        cout << left - 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<algorithm>
typedef unsigned long long ull;
using namespace std;
int main(){
	string target = "abcdefghijklmnopqrstuvwxyz";
	string str,str1,str2;
	int n;
	cin >> n >> str;
	int max = 0;
	for(int i=1;i<n;i++){
		str1 = str.substr(0,i);
		str2 = str.substr(i,n-i);
		//cout << str1 << "," << str2 << endl;
		int sum = 0;
		for(int j=0;j<target.length();j++){
			//cout << target[j] <<endl;
			//cout << str1.find(target[j]) << "," << str2.find(target[j]) << endl;
			if(str1.find(target[j])!=-1&&str2.find(target[j])!=-1){
				sum++;
			}
		}
		sum>max?(max=sum):max;
	}
	cout << max << endl;
}

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

int main()
{
	int n;
	int max_no = 0;
	int sum = 0;

	scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		int tmp;
		scanf("%d", &tmp);
		sum += tmp;
		max_no = max(max_no, tmp);
	}

	if (max_no < sum - max_no)
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;
#define n_max 1000

int main()
{
    int N;
    int T, A;
    int H[n_max];
    int distance;
    int min, ans;
    
    cin >> N;
    cin >> T >> A;
    
    for(int i = 0; i < N; i++) {
        cin >> H[i];
    }
        
    min = abs(1000 * A - 1000 * T + H[0] * 6);
    ans = 0;
    //cout << "min" << min << endl;

    for(int i = 1; i < N; i++) {
        distance = abs(1000 * A - 1000 * T + H[i] * 6);

        if(min > distance) {
            min = distance;
            ans = i;
        }
    }

    cout << ans + 1<< endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n;cin>>n;
  vector<int> l(n), r(n);
  for(int i=0;i<n;i++){cin>>l.at(i)>>r.at(i);}
  int ans=n;
  for(int i=0;i<n;i++){
    ans+=r.at(i)-l.at(i);
  }
  cout << ans << endl;
}

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

int main() {
	string s;
	cin >> s;
	if (s == "SUN") {
		cout << 7 << endl;
	}
	else if (s == "MON") {
		cout << 6 << endl;
	}
	else if (s == "TUE") {
		cout << 5 << endl;
	}
	else if (s == "WED") {
		cout << 4 << endl;
	}
	else if (s == "THU") {
		cout << 3 << endl;
	}
	else if (s == "FRI") {
		cout << 2 << endl;
	}
	else cout << 1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string st;
    cin>>st;
    if(st[0]=='a'||st[0]=='e'||st[0]=='i'||st[0]=='o'||st[0]=='u')cout<<"vowel"<<endl;
    else cout<<"consonant"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
  int n, limit, min = 1001;
  int t[1000], c[1000];
  std::cin >> n >> limit;
  for(int i = 0; i < n; i++){
    std::cin >> c[i] >> t[i];
  }

  for(int i = 0; i < n; i++){
    if(t[i] <= limit){
      if(c[i] < min) min = c[i];
    }
  }
  if(min == 1001) std::cout << "TLE" << std::endl;
  else std::cout << min << std::endl;
}

Measured memory_bytes: 256
/*  AtCoder Beginner Contest 133 B - Good Distance
    2019.07.25 by meyon  */

#include <stdio.h>
#include <stdlib.h>

void err()
{
  printf("Error!\n");
  exit(1);
}

int main()
{
  // input N:point and D:dimension
  int N, D;
  scanf("%d %d", &N, &D);
  if(N<2 || N>10 || D<1 || D>10) {
    err();
  }

  // input X:coordinates
  int X[N][D];
  for(int i=0; i<N; i++) {
    for(int j=0; j<D; j++) {
      scanf("%d", &X[i][j]);
      if(X[i][j] < -20 || X[i][j] > 20) {
        err();
      }
    }
  }

  // calculate norm
  int ans=0;
  for(int i=0; i<N-1; i++) {
    for(int j=i+1; j<N; j++) {
      int norm=0;
      for(int k=0; k<D; k++) {
        int diff = X[i][k] - X[j][k];
        norm += diff * diff;
      }

      // check norm whether integer
      int flag=0;
      for(int k=0; k*k <= norm; k++) {
        if(k*k == norm) {
          flag=1;
        }
      }
      if(flag) {
        ans++;
      }
    }
  }

  // display answer
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#define CID(a) (a-'a')

int main(void){
    int str=1;
    int ary[26]={},n=0,i,f=0;

    while((str=getchar())!=EOF){
        if (str >= 'a' && str <= 'z') ary[CID(str)]++;
        else if (str >= 'A' && str <= 'Z') ary[CID(str)+('a'-'A')]++;
    }
    for(i=0;i<26;i++) printf("%c : %d\n",'a'+i,ary[i]);
    return 0;
}


Measured memory_bytes: 2104
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int n,m;
  cin >> n >> m;
  
  int b,c = 0;
  
  REP(i,m){
    cin >> b;
    c += b;
  }

  if(n >= c) cout << n-c << endl;
  else cout << -1 << endl;
  
  
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=(0);(i)<(int)(n);++(i))
using ll = long long;
using P = pair<ll, ll>;
template<class T> inline bool chmax(T& a, T b) {if (a < b){a = b;return 1;}return 0;}
template<class T> inline bool chmin(T& a, T b) {if (a > b){a = b;return 1;}return 0;}
const long long LLINF = 1LL << 60;
using namespace std;

ll mod = 1e9 + 7;
string S[] = { "A", "G", "C", "T" };

// dp[i][s3][s2][s1]
// s3: 3文字前, s2: 2文字前, s1: 1文字前
ll dp[101][4][4][4];

bool ng(int s3, int s2, int s1) {
    string tmp = S[s3] + S[s2] + S[s1];
    return tmp == "AGC";
}

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

    dp[0][3][3][3] = 1LL;
    rep(i, N) {
        rep(s3, 4) rep(s2, 4) rep(s1, 4) rep(s, 4) {
            if (ng(s2, s1, s) or ng(s1, s2, s) or ng(s2, s, s1)) continue;
            if (ng(s3, s1, s) or ng(s3, s2, s)) continue;
            dp[i+1][s2][s1][s] += dp[i][s3][s2][s1];
            dp[i+1][s2][s1][s] %= mod;
        }
    }

    ll ans = 0;
    rep(s3, 4) rep(s2, 4) rep(s1, 4) {
        ans += dp[N][s3][s2][s1];
        ans %= mod;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int cnt;
vector<string> board(8);
const int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dy[8] = {1, 1, 0, -1, -1, -1, 0, 1};

bool search(vector<string>& brd, int x, int y, int d, char stone) {
	if(x < 0 || y < 0 || x >= 8 || y >= 8)
		return false;

	if(brd[y][x] == '.')
		return false;

	if(brd[y][x] == stone)
		return true;

	if(search(brd, x + dx[d], y + dy[d], d, stone)) {
		++cnt;
		brd[y][x] = stone;
		return true;
	}

	else
		return false;
}

int simulate(int x, int y, char stone) {
	vector<string> tmp(board);
	cnt = 0;
	for(int d = 0; d < 8; ++d)
		search(tmp, x + dx[d], y + dy[d], d, stone);

	return cnt;
}

void put(int x, int y, char stone) {
	board[y][x] = stone;
	for(int d = 0; d < 8; ++d)
		search(board, x + dx[d], y + dy[d], d, stone);		
}

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

	for(int i = 0; i < 8; ++i)
		cin >> board[i];

	while(true) {
		bool pass = false;
		int mx = 0, x, y;
		for(int i = 0; i < 8; ++i) {
			for(int j = 0; j < 8; ++j) {
				if(board[i][j] != '.')
					continue;

				const int num = simulate(j, i, 'o');
				if(mx < num) {
					mx = num;
					x = j;
					y = i;
				}
			}
		}

		if(mx)
			put(x, y, 'o');
		else
			pass = true;

		mx = 0;
		for(int i = 7; i >= 0; --i) {
			for(int j = 7; j >= 0; --j) {
				if(board[i][j] != '.')
					continue;

				const int num = simulate(j, i, 'x');
				if(mx < num) {
					mx = num;
					x = j;
					y = i;
				}
			}
		}

		if(mx)
			put(x, y, 'x');
		else if(pass)
			break;
	}

	for(int i = 0; i < 8; ++i)
		cout << board[i] << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1188
import collections
N = int(input())
A = list(map(int,input().split()))
C = collections.Counter(A)
count = []
ans = 0
pt = [0 for i in range(N)]
for k,v in C.items():
    count.append([k,v])
    if v > 1:
        ans += v*(v-1)//2
        pt[k-1] = v-1
for i in A:
    print(ans - pt[i-1])

Measured memory_bytes: 102604
//#pragma GCC target ("avx2,sse2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree <pair <ll, int>, null_type, less <pair <ll, int> >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long
#define ull unsigned long long
#define db double
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define fi first
#define se second
#define mp make_pair
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define endl "\n"

#define left fsdsdfoisf
#define sum dpsdfioppsf
#define assign xcvjlkdjfio
#define trie fksdfkjkfnjuiv
#define next sidlfjsfkl
#define merge sdfksdkfsldf

#define int long long

using namespace std;

void dout() {
    cerr << endl;
}
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;

const int N = 107, K = 1e5 + 7, MOD = 1e9 + 7;
int n, k, a[N], dp[N][K], p[N][K];

void solve(int tc) {
    // check for (int i = 0; i < n; j++)
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    dp[0][0] = 1;
    for (int i = 0; i <= k; i++) {
        p[0][i] = 1;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= k; j++) {
            int tmp = 0;
            if (j - a[i] - 1 >= 0) {
                tmp = p[i - 1][j - a[i] - 1];
            }
            dp[i][j] = (p[i - 1][j] - tmp + MOD);
            if (dp[i][j] >= MOD) {
                dp[i][j] -= MOD;
            }
            p[i][j] = dp[i][j];
            if (j > 0) {
                p[i][j] += p[i][j - 1];
                if (p[i][j] >= MOD) {
                    p[i][j] -= MOD;
                }
            }
        }
    }
    cout << dp[n][k];
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int tc = 1;
//    cin >> tc;
    for (int i = 0; i < tc; i++) {
        solve(i);
//        cleanup();
    }
}


Measured memory_bytes: 162048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws IOException {
//        long[] emp = new long[4001];
            

//        BufferedReader bReader =
//                new BufferedReader(new InputStreamReader(System.in));
        Scanner s = new Scanner(System.in); 

//        aryClear(emp);
        int empValue;
        while ((empValue = s.nextInt()) != 0) {
        	int overCount = 0, empID, n;
        	long price, quantitiy;
        	long total;

        	HashMap<Integer,Long> emp = new HashMap<Integer,Long>();
        	Queue<Integer> iQueue = new LinkedList<Integer>();

            n = 0;
            while (n < empValue) {
//                String str = bReader.readLine();
//                String[] editedstr = str.split(" ");
                empID = s.nextInt(); //Integer.parseInt(editedstr[0]);         //社員番号
                price = s.nextLong(); //Integer.parseInt(editedstr[1]);         //単価
                quantitiy = s.nextLong(); //Integer.parseInt(editedstr[2]);     //販売個数
                total = price * quantitiy;                      //実績

                if (!emp.containsKey(empID)) {                         //初めての入力
                    emp.put(empID, total);
                    iQueue.offer(empID);
                } else if (emp.get(empID) <= 1000000) {   //2回目以降の入力かつ100万を超えない値の場合
                    emp.put(empID, emp.get(empID) + total);
                    
                } else {
                }
                n++;
            }

//            for (int a : iQueue) {
            Integer a;
            while ((a = iQueue.poll()) != null) {
                //System.out.println(a);        //debug
                if (emp.get(a) >= 1000000) {
                    System.out.println(a);
                    overCount++;
                }
            }
            if (overCount == 0) {
                System.out.println("NA");
            }
            overCount = 0;
            iQueue.clear();
//            emp = new long[4001];
//            aryClear(emp);
            emp.clear();
        }
    }

    public static void aryClear(long[] ary) {
        for (int i = 0; i <= 4000; i++) {
            ary[i] = -1;
        }
    }
}

Measured memory_bytes: 13000
#include<stdio.h>

int main(void) {
  int n, x, y, sum = 0;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    scanf("%d %d", &x, &y);
    sum += y - x + 1;
  }

  printf("%d", sum);

  return 0;
}


Measured memory_bytes: 128
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=100000+19;

struct Edge{
	int y,nxt;
} E[N*2];
int las[N];
int n,cnt;

void Link(int x,int y){
	E[cnt]=(Edge){y,las[x]};las[x]=cnt++;
	E[cnt]=(Edge){x,las[y]};las[y]=cnt++;
}
int dfs(int x,int fa){
	int res=0;
	for (int i=las[x],y;~i;i=E[i].nxt)
		if ((y=E[i].y)!=fa){
			res^=dfs(y,x)+1;
		}
	return res;
}

int main(){
	memset(las,-1,sizeof(las));
	n=IN();
	For(i,1,n) Link(IN(),IN());
	puts(dfs(1,-1)?"Alice":"Bob");
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int a,b;
  cin>>a>>b;
  if(a+b == 15){
    cout<<'+'<<endl;
  }else if(a*b == 15){
    cout<<'*'<<endl;
  }else{
    cout<<'x'<<endl;
  }
  return 0;
}


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

int minim(int a, int b)
{
    if (a < b)
    {
        return a;
    }
    else
    {
        return b;
    }
}
int main()
{
    int n;
    int v[100001];
    cin >> n;
    for (int i = 0; i < n - 1; i++)
    {
        cin >> v[i];
    }
    int sum = v[0];
    int a1 = v[0];
    int a2 = v[1];
    for (int i = 1; i < n - 1; i++)
    {
        sum += minim(v[i-1], v[i]);
    }
    cout << sum + v[n-2];
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
	
def main():
	X = input().split(" ")
	X = [int(s) for s in X]
	
	dx = X[2] - X[0]
	dy = X[3] - X[1]
	
	ans = "{} {} {} {}".format(X[2]-dy, X[3]+dx, X[0]-dy, X[1]+dx)
	print(ans)
	
if __name__ == "__main__":
	main()


Measured memory_bytes: 3572
def Recursion(S):
    list = []
    list.append(int(S))
    for i in range(len(S)-1):
        left = S[:i+1]
        right = S[i+1:]
        x = int(left)
        for y in Recursion(right):
            list.append(x + y)
    return list

S = input()
print(sum(Recursion(S)))


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

using namespace std;



int main(int argc, char* argv[])
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int N;
  cin >> N;
  if (N == 1) cout << "Hello World\n";
  else { int A, B; cin >> A >> B;  cout << A + B << "\n"; }

  return 0;
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define For(i, l, r) for (int i = (l); i <= (r); ++i)

typedef long long LL;
typedef pair<int, int> Pii;

const int inf = 0x3f3f3f3f;
const LL infLL = 0x3f3f3f3f3f3f3f3fLL;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << max(c - (a - b), 0) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

typedef long long int ll;


int main(void){
	int N;
	ll res;
	std::cin >> N;
	std::vector<ll> A(N, 0);
	for(int i = 0; i < N; i++) std::cin >> A[i];
	std::sort(A.begin(), A.end(), std::greater<ll>());
	
	res = A[0];
	int i = 1, j = 1;
	for(; i < N-1; i += 2, j++){
		if(i == N - 2){
			res += A[j];
			break;
		}
		res += 2 * A[j];
		// std::cout << res << std::endl;
	}

	std::cout << res << std::endl;
	return 0;
}


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


int main()
{
    int n;
    cin >> n;
    vector<int> cards(2 * n);
    for(int i = 0; i < 2 * n; i++)
        cards[i] = i + 1;

    int k, m;
    cin >> m;
    for(int i = 0; i < m; i++) {
        cin >> k;
        if(k == 0) {
            vector<int> c(n);
            for(int i = 0; i < n; i++)
                c[i] = cards[i];
            for(int i = 0; i < n; i++)
                cards[2 * i + 1] = cards[n + i];
            for(int i = 0; i < n; i++)
                cards[2 * i] = c[i];
        } else { 
            vector<int> c(2 * n);
            for(int i = 0; i < 2 * n; i++)
                c[i] = cards[i];
            for(int i = 0; i + k < 2 * n; i++)
                cards[i] = c[i + k];
            for(int i = 0; i < k; i++)
                cards[i + 2 * n - k] = c[i];
        }
    }
    for(int i = 0; i < cards.size(); i++)
        cout << cards[i] << endl;
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
#include<string>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <utility> 

#define rep(i,m,n) for(ll i = m;i < n;i++)
using namespace std;
using ll = long long;
const ll inf = 1LL << 50;




int main(){
	ll N, W;
	ll w1;
	cin >> N >> W;

	vector<ll> s[4];

	rep(i, 0, N) {
		ll w, v;
		cin >> w >> v;
		if (i == 0) w1 = w;
		s[w - w1].push_back(v);
	}

	rep(i, 0, 4) {
		sort(s[i].begin(), s[i].end());
		s[i].push_back(0);
		reverse(s[i].begin(), s[i].end());
		rep (j,1,s[i].size()){
			s[i][j] += s[i][j - 1];
		}
	}




	ll ans = 0;
	rep(i,0,s[0].size()) {
		rep(j, 0, s[1].size()) {
			rep(k, 0, s[2].size()) {
				rep(l, 0, s[3].size()) {
					ll wtotal = i * w1 + j * (w1 + 1) + k * (w1 + 2) + l * (w1 + 3);
					if (wtotal <= W) {
						ll sum = s[0][i] + s[1][j] + s[2][k] + s[3][l];
						ans = max(sum, ans);
					}
				}
			}
		}
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256