akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	//for team
	public static final int ID = 0;
	public static final int AC = 1;
	public static final int PE = 2;
	public static int[][] team;
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		doIt();
	}
	
	public static void doIt(){
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		int p = sc.nextInt();
		int r = sc.nextInt();
		while(t + p + r != 0){
			team = new int[t][3];
			int[][] problem = new int[t][p];
			//initialize
			for(int i = 0; i < t; i++){
				team[i][ID] = i + 1;
				team[i][AC] = 0;
				team[i][PE] = 0;
				for(int j = 0; j < p; j++){
					problem[i][j] = 0;
				}
			}
			//start.
			for(int i = 0; i < r; i++){
				int tID = sc.nextInt() - 1;
				int pID = sc.nextInt() - 1;
				int time = sc.nextInt();
				String message = sc.next();
				//System.out.println("tID = " + tID + ", pID = " + pID + ", time = " + time + ", message = " + message);
				if(message.equals("CORRECT")){
					team[tID][AC] += 1;
					team[tID][PE] += time + problem[tID][pID] * 1200;
					//System.out.println("correct : team " + tID + ", pID = " + pID);
				}
				else{
					problem[tID][pID] += 1;
				}
			}
			//teamデータを使ってチームの順位を決める
			int[] rank = new int[t];
			for(int i = 0; i < t; i++){
				rank[i] = i;
			}
			for(int i = 0; i < t; i++){
				for(int j = t - 1; j >= i + 1; j--){
					if(compare(rank[j - 1],rank[j])){
						//ひっくり返す
						int tmp = rank[j];
						rank[j] = rank[j - 1];
						rank[j - 1] = tmp;
					}
				}
			}
			for(int i = 0; i < t; i++){
				int tmp = rank[i];
				System.out.println(team[tmp][ID] + " " + team[tmp][AC] + " " + team[tmp][PE]);
			}
			t = sc.nextInt();
			p = sc.nextInt();
			r = sc.nextInt();
		}
	}
	//id1の成績 < id2の成績ならtrue
	public static boolean compare(int id1, int id2){
		boolean bRet = false;
		if(team[id1][AC] < team[id2][AC]){
			bRet = true;
		}
		else if(team[id1][AC] == team[id2][AC]){
			if(team[id1][PE] > team[id2][PE]){
				bRet = true;
			}
			else if(team[id1][PE] == team[id2][PE]){
				if(team[id1][ID] > team[id2][ID]){
					bRet = true;
				}
			}	
		}
		return bRet;
	}
}

Measured memory_bytes: 13000
# -*- coding: utf-8 -*-
"""
C - Christmas Eve
https://atcoder.jp/contests/abc115/tasks/abc115_c

"""
import sys


def solve(heights, K):
    return min([r - l for l, r in zip(heights, heights[K - 1:])])


def main(args):
    N, K = map(int, input().split())
    heights = sorted([int(input()) for _ in range(N)])
    ans = solve(heights, K)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


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

int main (){
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  A = A + B;
  C = C + D;
  if (A == C) {
    cout << "Balanced" << endl;
  }else if (A > C){
    cout << "Left" << endl;
  }else if (A < C){
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
/* BISMILLAHIR RAHMANIR RAHIM */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MXN = 200005;
const ll mod  = 1e9 + 7;
ll fct[MXN], inv[MXN];

int main( int argc, char const *argv[] ) {
  fct[0] = inv[0] = 1LL;
  function< ll( ll, ll, ll ) > big_mod = [&]( ll b, ll p, ll m ) {
    ll x = 1LL;
    for(; p > 0; b = (b * b) % mod, p /= 2) {
      if( p & 1 ) x = (x * b) % mod;
    }
    return x;
  };
  for(ll i = 1; i < MXN; i++) {
    fct[i] = (i * fct[i - 1]) % mod;
    inv[i] = big_mod( fct[i], mod - 2, mod );
  }  
  ios_base :: sync_with_stdio(0); 
  cin.tie(0);
  ll n, m, k;
  cin >> n >> m >> k;
  vector< pair<ll, ll> > P(k + 1);
  bool flg  = false;
  for(int i = 0; i < k; i++) {
    cin >> P[i].first >> P[i].second;
    flg |= ((P[i].first == 1 and P[i].second == 1) or (P[i].first == n and P[i].second == m));
  }
  if( flg ) {
    cout << "0\n";
    return 0;
  }
  if( n == 1 or m == 1 ) {
    cout << (!k ? "1\n" : "0\n");
    return 0;
  }
  P[k] = {n, m};
  sort(P.begin(), P.end());
  vector<ll> dp(k + 5, 0);
  for(int i = 0; i <= k; i++) {
    function< ll( ll, ll ) > nCr = [&]( ll x, ll r ) {
      if( x <= 0 or r < 0 or r > x ) return 0LL;  // nC0 = 1// 
      ll ret = (fct[x] * inv[x - r]) % mod;
      ret = (ret * inv[r]) % mod;
      return ret;
    };
    dp[i] = nCr( P[i].first + P[i].second - 2, P[i].second - 1 );
    for(int j = i - 1; j >= 0; j--) {
      if( P[j].second > P[i].second ) continue;
      ll bad = (dp[j] * nCr( P[i].first + P[i].second - P[j].first - P[j].second, P[i].second - P[j].second )) % mod;
      dp[i] = (dp[i] - bad + mod) % mod;
    }
  }
  cout << dp[k] << "\n";
  return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        int[] ND = ReadLineParseIntArray();
        int N = ND[0];
        int D = ND[1];

        int[,] Xs = new int[N, D];
        for(int i = 0; i < N; i++)
        {
            int[] X = ReadLineParseIntArray();
            for (int j = 0; j < D; j++)
            {
                Xs[i, j] = X[j];
            }
        }
        int ans = 0;
        for(int i = 0; i < N - 1; i++)
        {
            for(int j = i + 1; j < N; j++)
            {
                int dist = 0;
                for(int d = 0; d < D; d++)
                {
                    dist += (Xs[i, d] - Xs[j, d]) * (Xs[i, d] - Xs[j, d]);
                }
                if (Sqrt((double)dist) % 1 == 0) ans++;
            }
        }
        WriteLine(ans);
    }
    static int ReadLineParseInt() => int.Parse(ReadLine());
    static int[] ReadLineParseIntArray() => ReadLine().Split(' ').Select(int.Parse).ToArray();
}

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

int main()
{
    int N;
    int t[110000], x[110000], y[110000];
    cin >> N;

    t[0] = x[0] = y[0] = 0;

    for (int i = 0; i < N; i++) cin >> t[i+1] >> x[i+1] >> y[i+1];

    bool can = true;
    for (int i = 0; i < N; i++) {
        int dt = t[i+1] - t[i];
        int dist = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
        if (dt < dist) can = false;
        if (dt % 2 != dist % 2) can = false;
    }

    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 4240
<?php
while(true){
$input = trim(fgets(STDIN));
list($H,$W) = explode(" ",$input);
if($H == 0 and $W ==0){
break;
}
for($i = 1;$i <= $H; $i++){
    for($j = 1;$j <= $W; $j++){
if($i%2 == 0 and $j%2 ==0 or $i%2 == !0 and $j%2 == !0){
echo "#";
}
elseif($i%2 == 0 and $j%2 == !0 or $i%2 == !0 and $j%2 ==0){
echo ".";
}
}
echo "\n";
}
echo "\n";
}
?>


Measured memory_bytes: 9248
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long 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;}

int main() {
    ll a,b;
    cin >> a >> b;
    ll x = b/4;
    ll y = b%4;
    ll xorsum_b=0;
    rep(i,y+1) {
        xorsum_b ^= 4*x+i;
    }
    ll xorsum_a = 0;
    x = (a-1)/4;
    y = (a-1)%4;
    rep(i,y+1) {
        xorsum_a ^= 4*x+i;
    }
    ll ans = xorsum_a ^ xorsum_b;
    cout << ans << endl;
}

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

int main() {
	int d, n;
    cin >> d >> n;
    if (n == 100)n++;
    if (d == 0) {
        cout << n << endl;
    }
    if (d == 1) {
        cout << 100 * n << endl;
    }
    if (d == 2) {
        cout << 10000 * n << endl;
    }
}

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

const int maxn = 2e5+5;
int n, c[maxn];

const int M = 1e9+7;
void madd(int& a, int b) {
    a += b;
    if (a >= M) a -= M;
}
int mult(int a, int b) {
    return (1LL*a*b) % M;
}
int modexp(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b&1) res = mult(res,a);
        a = mult(a,a);
        b >>= 1;
    }
    return res;
}
int inverse(int x) {
    return modexp(x,M-2);
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    sort(c,c+n,greater<int>());
    int ans = 0;
    for (int i = 0; i < n; i++) {
        madd(ans,mult(c[i],i+2));
    }
    ans = mult(ans,modexp(4,n-1));
    cout << ans << '\n';
}



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

int main(){
  int n; cin>>n;
  string s; cin>>s;
  int e=s.size();
  int left=0, right=e-1;
  int ans=0;
  while(true){
    if(s[left]=='W' && s[right]=='R'){
      ans++; left++; right--;
    }
    if(s[left]=='R' && s[right]=='W'){
      left++; right--;
    }
    if(s[left]=='R' && s[right]=='R'){
      left++;
    }
    if(s[left]=='W' && s[right]=='W'){
      right--;
    }
    if(left>=right)break;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3680
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
using namespace std;
char A[4];
int main()
{
    int jiage=700;
    scanf("%s",A);
    if(A[0]=='o')
        jiage=jiage+100;
    if(A[1]=='o')
        jiage=jiage+100;
    if(A[2]=='o')
        jiage=jiage+100;
        printf("%d\n",jiage);
    return 0;
}


Measured memory_bytes: 256
import sys

*a, = map(int, sys.stdin.readline().split())

def main():
    a.sort()
    res = a[2] * 2 - a[0] - a[1]
    return (res + 3) // 2 if res & 1 else res // 2
    
if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

#define MOD 1000000007

int main()
{
    int N, K; cin >> N >> K;
    vector<int> A(N); cin >> A;
    sort(A.begin(), A.end());

    vector<int> fact(N);
    vector<int> finv(fact.size());
    vector<int> inv(fact.size());
    
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    inv[0] = 0; inv[1] = 1;
    for (int i = 2; i < fact.size(); i++) {
        fact[i] = (ll)fact[i-1] * i % MOD;
        inv[i] = (ll)MOD - (ll)inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = (ll)finv[i - 1] * inv[i] % MOD;
    }

    auto C = [&](int n, int r) {
        return (ll)fact[n] * finv[n-r] % MOD * finv[r] % MOD;
    };

    ll ans = 0;
    for (int i = 0; i < N-K+1; i++) {
        ll c = C(N-i-1, K-1);
        ans += c * A[N-1-i] % MOD;
        ans %= MOD;
        ans -= c * A[i] % MOD;
        ans %= MOD;
    }
    while (ans < 0) ans += MOD;
    cout << ans << endl;
}


Measured memory_bytes: 1920
n=int(input())
v_list=list(map(int,input().split()))
even=1
e_dict={}
o_dict={}
for i in v_list:
    if even==1:
        if i in e_dict:
            e_dict[i]=e_dict[i]+1
        else:
            e_dict[i]=1
        even=0
    else:
        if i in o_dict:
            o_dict[i]=o_dict[i]+1
        else:
            o_dict[i]=1
        even=1
max_e=max(e_dict,key=e_dict.get)
max_o=max(o_dict,key=o_dict.get)
if max_e==max_o:
    max1e=max(e_dict.values())
    max1o=max(o_dict.values())
    e_dict.pop(max_e)
    o_dict.pop(max_o)
    if e_dict=={}:
        max2e=0
    else:
        max2e=max(e_dict.values())
    if o_dict=={}:
        max2o=0
    else:
        max2o=max(o_dict.values())
    answer=min(n-max1e-max2o,n-max1o-max2e)
    print(answer)
else:
    answer=n-max(e_dict.values())-max(o_dict.values())
    print(answer)
        
    


Measured memory_bytes: 59628
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
//#pragme GCC target("avx2");
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#define int long long
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define f first
#define se second
#define pll pair<ll, ll>
#define pii pair<int, int>

using namespace std;
//using namespace __gnu_pbds;

/*
	st.insert(k);
	st.find_by_order(k); iterator on k-th from 0
	st.order_of_key(k); strictly more than k
*/

//typedef
//tree<
//  ll,
//  null_type,
//  less_equal<ll>,
//  rb_tree_tag,
//  tree_order_statistics_node_update>
//ordered_set;


const int N = 4e5 + 19;
const int M = 2e6 + 19;
const ll mod = 998244353;
const int inf = 2e9;
const int blocksz = 300;
const ll INF = 1e18;


inline int modulo(int x) {x %= mod; return (x + mod) % mod; }
inline ll mult(ll x, ll y) { ll x1 = modulo(x), y1 = modulo(y); return (x1 * y1) % mod; }
inline void add(int &x, int y) { x = modulo(x + y); }
inline void Max(int &x, int y) { x = max(x, y); }
inline void Min(int &x, int y) { x = min(x, y); }

ll n;
string s;

//int pw(int x, int y) {
//	if (y == 0)
//		return 1;
//	int res;
//	if (y % 2) {
//		res = pw(x, y - 1);
//		return mult(res, x);
//	} else {
//		res = pw(x, y / 2);
//		return mult(res, res);
//	}
//}
//
//
//int C(int n, int k) {
//	if (n > k)
//		return 0;
//	int t1, t2, t3;
//	t1 = fact[n];
//	t2 = pw(fact[k], mod - 2);
//	t3 = pw(fact[n - k], mod - 2);
//	return mult(t1, mult(t2, t3));
//}


main() {
	ios_base::sync_with_stdio(NULL); cin.tie(NULL); cout.tie(NULL);
	//freopen("input.txt", "r", stdin);
	ll R, G, B, RG, RB, GB, ost, ans = 1;
	R = G = B = RG = RB = GB = 0;
	cin >> n;
	cin >> s;
	ost = n;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'R') {
			if (GB) {
				ans = mult(ans, GB);
				GB--;
			} else if (B) {
				ans = mult(ans, B);
				B--;
				RB++;
			} else if (G) {
				ans = mult(ans, G);
				G--;
				RG++;
			} else {
				ans = mult(ans, ost);
				R++;
				ost--;
			}
		} else if (s[i] == 'G') {
			if (RB) {
				ans = mult(ans, RB);
				RB--;
			} else if (R) {
				ans = mult(ans, R);
				R--;
				RG++;
			} else if (B) {
				ans = mult(ans, B);
				B--;
				GB++;
			} else {
				ans = mult(ans, ost);
				G++;
				ost--;
			}
		} else {			
			if (RG) {
				ans = mult(ans, RG);
				RG--;
			} else if (R) {
				ans = mult(ans, R);
				R--;
				RB++;
			} else if (G) {
				ans = mult(ans, G);
				G--;
				GB++;
			} else {
				ans = mult(ans, ost);
				B++;
				ost--;
			}
		}
	}
	cout << ans;	
	return 0;
}
/*
3 5
1 3 2 1 3
10 5 7
3
4 2 4
1 3 1
3 5 2
*/



Measured memory_bytes: 720
#include <iostream>
#include <stdio.h>
#include<cmath>
#include<cctype>
#include<cstdio>
#include <algorithm>
#include <string.h>
#include<math.h>
#include<map>
#include<bits/stdc++.h>
#include<unordered_map>
#define Maxn 100005
#define ll long long
using namespace std;

ll sum;
int num[Maxn];
int a[Maxn];
int main(){
	int n,q,b,c;
	scanf("%d",&n);
	sum=0;
	for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
        num[a[i]]++;//a[i]出现的次数
	}
    scanf("%d",&q);
	for(int i=1;i<=q;i++){
        scanf("%d%d",&b,&c);
        sum+=(c-b)*num[b];
        num[c]+=num[b];
        num[b]=0;
        printf("%lld\n",sum);
	}
	return 0;
}


Measured memory_bytes: 4584
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define INF 2e9
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vint a(n);
	int count=1,count2=0;
    rep(i,n){
        cin>>a[i];
      	if(a[i]==count){
          count++;
        }
		else{
          count2++;
        }
    }
  	if(count==1){
      	cout<<-1<<'\n';
    }
	else{
      cout<<count2<<'\n';
    }
    return(0);
}

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


int main(){
  int a, b, ch=-1;
  int i;
  cin >> a >> b;
  for(i=1; i<=1000; i++){
    int c = i*0.08;
    int d = i*0.1;
    if(c==a && b == d){
      ch=i;
      break;
    }
    else if(d>b) break;
    
  }
  cout << ch << endl;
  
  
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.math.abs
import kotlin.math.min

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (w, h, x, y) = readLongList()
    val area = (h * w) / 2.0

    val check = if (w % 2 == 0L && h % 2 == 0L && w / 2 == x && h / 2 == y) {
        1
    } else {
        0
    }

    out.println("$area $check")
}

fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


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

using namespace std;

const int max_n = 200222, inf = 1000111222;
const int max_x = 33;

int n;
long long a[max_n], ans, cnt[max_x][max_x];

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        int pw = 10;
        bool f = 0;
        for (char c : s) {
            if (c == '.') {
                f = 1;
            } else {
                a[i] = a[i] * 10 + c - '0';
                pw -= f;
            }
        }
        for (int j = 0; j < pw; ++j) {
            a[i] *= 10;
        }
        int c2 = 0, c5 = 0;
        while (a[i] % 2 == 0) {
            ++c2;
            a[i] /= 2;
        }
        while (a[i] % 5 == 0) {
            ++c5;
            a[i] /= 5;
        }
        c2 = min(c2, 20);
        c5 = min(c5, 20);
        ++cnt[c2][c5];
    }
    for (int a = 0; a < max_x; ++a) {
        for (int b = 0; b < max_x; ++b) {
            for (int c = 0; c < max_x; ++c) {
                for (int d = 0; d < max_x; ++d) {
                    if (a + c >= 20 && b + d >= 20) {
                        if (a == c && b == d) {
                            ans += 1LL * cnt[a][b] * (cnt[a][b] - 1);
                        } else {
                            ans += 1LL * cnt[a][b] * cnt[c][d];
                        }
                    }
                }
            }
        }
    }
    assert(ans % 2 == 0);
    cout << ans / 2 << endl;
    return 0;
}


Measured memory_bytes: 5272
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

auto make_tables()
{
	boost::multi_array<std::tuple<std::int64_t, std::int64_t, int>, 2> start(boost::extents[10][10]);
	boost::multi_array<std::pair<std::int64_t, std::int64_t>, 2> loop(boost::extents[10][10]);
	for (auto i : boost::irange(1, 10))
	{
		for (auto p : boost::irange(0, 10))
		{
			boost::optional<std::pair<std::int64_t, std::int64_t>> flag[10];
			auto v = p;
			std::int64_t discard = 0, count = 0;
			while (true)
			{
				v += i;
				++discard;
				++count;
				if (10 <= v)
				{
					v = v / 10 + v % 10;
					++count;
				}
				if (flag[v])
				{
					std::int64_t d, c;
					std::tie(d, c) = *flag[v];
					start[i][p] = std::make_tuple(d, c, v);
					loop[i][v] = std::make_pair(discard - d, count - c);
					break;
				}
				else
				{
					flag[v] = std::make_pair(discard, count);
				}
			}
		}
	}
	return std::make_pair(start, loop);
}

void Main()
{
	auto table = make_tables();
	auto const& start = table.first;
	auto const& loop = table.second;
	int M;
	std::cin >> M;
	int prev = 0;
	std::int64_t count = 0;
	auto greedy = [&](int d, std::int64_t c)
	{
		for (auto _ : boost::irange<std::int64_t>(0, c))
		{
			prev += d;
			++count;
			if (10 <= prev)
			{
				prev = prev / 10 + prev % 10;
				++count;
			}
		}
	};
	for (auto i : boost::irange(0, M))
	{
		int d;
		std::int64_t c;
		std::cin >> d >> c;
		if (d == 0)
		{
			count += c;
			continue;
		}
		if (c < std::get<0>(start[d][prev]))
		{
			greedy(d, c);
			continue;
		}
		c -= std::get<0>(start[d][prev]);
		count += std::get<1>(start[d][prev]);
		prev = std::get<2>(start[d][prev]);
		if (loop[d][prev].first < c)
		{
			count += (c / loop[d][prev].first) * loop[d][prev].second;
			c -= (c / loop[d][prev].first) * loop[d][prev].first;
		}
		greedy(d, c);
	}
	std::cout << count - 1 << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

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

using namespace std;

const long long mod = 1e9 + 7;

int main(){
  int N, K;
  cin >> N >> K;
  
  vector<long long> pos, neg;
  for(int i = 0; i < N; i++){
    long long A;
    cin >> A;
    if(A >= 0) pos.push_back(A);
    else neg.push_back(-A);
  }
  
  int n_pos = int(pos.size()), n_neg = int(neg.size());
  
  long long ans = 1;
  
  if(K == N){
    for(int i = 0; i < n_pos; i++){
      ans *= pos[i];
      ans %= mod;
    }
    
    for(int i = 0; i < n_neg; i++){
      ans *= -neg[i];
      ans %= mod;
    }
  }else if(n_neg == N && (K & 1)){
    sort(neg.begin(), neg.end());
    
    ans = -1ll;
    for(int i = 0; i < K; i++){
      ans *= neg[i];
      ans %= mod;
    }
  }else{  
    sort(pos.begin(), pos.end(), greater<long long>());
    sort(neg.begin(), neg.end(), greater<long long>());
    
    int idx_pos = 0, idx_neg = 0;
    
    if(K & 1){
      --K;
      ans = pos[idx_pos++];
    }
    
    for(int i = 0; i < K; i += 2){
      if(idx_pos + 1 < n_pos && idx_neg + 1 < n_neg){
        if(pos[idx_pos] * pos[idx_pos + 1] < neg[idx_neg] * neg[idx_neg + 1]){
          ans *= neg[idx_neg] * neg[idx_neg + 1] % mod;
          idx_neg += 2;
        }else{
          ans *= pos[idx_pos] * pos[idx_pos + 1] % mod;
          idx_pos += 2;
        }
      }else if(idx_pos + 1 < n_pos){
        ans *= pos[idx_pos] * pos[idx_pos + 1] % mod;
        idx_pos += 2;
      }else{
        ans *= neg[idx_neg] * neg[idx_neg + 1] % mod;
        idx_neg += 2;
      }
      
      ans %= mod;
    }
  }
  
  cout << (ans + mod) % mod << endl;
  
  return 0;
}


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

#define V vector
typedef long long ll;
typedef unsigned long long ull;

typedef V<int> vi;
typedef V<ll> vll;
typedef V<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define f(i,a) for(int i = 0 ; i < a ; i++)
#define fll(i,a) for(ll i = 0 ; i < a ;i++)
#define forab(i,a,b) for(int i = a ; i < b ; i++)
#define prec(x) cout<<fixed<<setprecision(x)
#define ff first
#define ss second
#define mod 1073741824

#define pb push_back
#define mp make_pair
#define numberofdigits(x) floor(log10(x)) + 1

void solve()
{
	string s, t;
	cin >> s;
	cin >> t;

	int n = s.size() , cnt = 0;

	f(i, n)
	{
		if (s[i] != t[i]) cnt++;
	}

	cout << cnt << "\n";
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int t = 1;
	//cin >> t;

	while (t--)
	{
		solve();
	}

	return 0;
}





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

int* d;
int n=1;

void initRSQ(int n) {
    for(int i=0; i<2*n-1; i++) d[i] = 0;
}

void add(int k, int a) {
    k += n-1;
    d[k] = d[k]+a;
    while(k > 0) {
        k = (k-1)/2;
        d[k] = d[k*2+1]+d[k*2+2];
    }
}

int query(int a, int b, int k, int l, int r) {
    if(r <= a || b <= l) return 0;
    if(a <= l && r <= b) return d[k];

    return query(a,b,k*2+1,l,(l+r)/2)+query(a,b,k*2+2,(l+r)/2,r);
}

int findSum(int a, int b) {
    return query(a, b, 0, 0, n);
}

int main() {
    int q, com, x, y, n_;
    cin >> n_ >> q;
    while(n < n_) n *= 2;
    d = new int[2*n-1];
    initRSQ(n);

    for(int i=0; i<q; i++) {
        cin >> com >> x >> y;
        if(com) cout << findSum(x-1,y) << endl;
        else add(x-1,y);
    }

    delete[] d;
    return 0;
}



Measured memory_bytes: 3880
#include <cstdio>

int main(){
    int H,W;
    while(1){
        scanf("%d %d",&H,&W);
    if(H == 0 && W ==0){break;}
    for(int x = 0; x < H;x++){
        for(int y = 0;y < W;y++){
            if(x % 2 == 1){
                if(y % 2 == 1){printf("#");}
                else{printf(".");}
                }
            else{
                if(y % 2 == 1){printf(".");}
                else{printf("#");}
                }
            }
        printf("\n");}
    printf("\n");}
    return 0;
    }


Measured memory_bytes: 2676
import numpy as np

N,M = map(int, input().split())
C = np.array([list(map(int, input().split())) for i in range(N)])
A = C.T[0]
B = C.T[1]

B = B[np.argsort(A)]
A = np.sort(A)

s = 0
m = M
i = 0
while(m > 0):
    if B[i] <= m:
        s += A[i] * B[i]
        m -= B[i]
        i += 1
    else:
        s += A[i] * m
        m = 0
print(s)






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

int main() {
	int a,b;
	cin >> a >> b;
	string kai = "No";
	int cnt = 0,bc = b;
	while(bc > 0)
	{
		cnt++;
		bc /= 10;
	}
	a = a * pow(10,cnt) + b;
	int aa = floor(pow(a,0.5));
	if(a == pow(aa,2))
	{
		kai = "Yes";
	}
    cout << kai << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e15;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int h,w; cin>>h>>w;
    int a,b; cin>>a>>b;

    cout<<h*w-h*b-w*a+a*b<<endl;
}

Measured memory_bytes: 3644
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace paiza2
{
    class Program
    {
        static int Main(string[] args)
        {
            var read = Console.ReadLine();
            var split = read.Split(' ');
            string a = split[0];
            string b = split[1];
            string c = split[2];
            if (a == "5" || a == "7")
                if (b == "5" || b == "7")
                    if (c == "5" || c == "7")
                        if (Int32.Parse(a) + Int32.Parse(b) + Int32.Parse(c) == 17)
                        {
                            Console.WriteLine("YES");
                            return 0;
                        }
            Console.WriteLine("NO");
            return 0;
         
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {

  int N; std::cin >> N;
  std::vector<ll> A(N);
  for(int i=0; i<N; i++) {
    std::cin >> A[i];
    A[i] -= i+1;
  }

  std::sort(A.begin(), A.end());

  int b = 0;
  if (N % 2 == 1) b = A[(N-1)/2];
  else b = (A[(N/2)-1] + A[N/2])/2;

  ll ans = 0;
  for(int i=0; i<N; i++) ans += std::abs(A[i]-b);
  std::cout << ans << std::endl;
  
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define F first
#define S second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
int a[100010];
int main()
{
	cin >>n;
	for (int i=0;i<n;i++) cin >>a[i];
	sort(a,a+n);
	int x=a[n/2-1],y=a[n/2];
	cout <<y-x;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i , n) for (int i = 0; i < (int)(n); i++)
const int INF = 1<<29;
using namespace std;
using ll = long long;
int main() {
    int h , w , n;
    cin >> h >> w >> n;
    vector<int> a(h), b(w);
    set<pair<int , int>> s;
    rep(i,n) {
        int c , d;
        cin >> c >> d;
        --c;
        --d;
        a[c]++;
        b[d]++;
        s.emplace(c , d);
    }
    int e = 0, f = 0;
    for(int i = 0; i < h; i++){
        e = max(e, a[i]);
    }
    for(int i = 0; i < w; i++){
        f = max(f, b[i]);
    }
    vector<int> g, k;
    for(int i = 0; i < h; i++){
        if (e == a[i]){
            g.push_back(i);
        }
    }
    for(int i = 0; i < w; i++){
        if (f == b[i]){
            k.push_back(i);
        }
    }
    int ans = e + f;
    for(int i : g) for (int j : k) {
        if(s.count(pair<int , int>(i , j))){
            continue;
        }
        cout << ans << endl;
        return 0;
    }
    --ans;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 23784
#include <iostream>
using namespace std;
int main(){
	int N;
	double D;
	cin>>N>>D;
	D = D*D;
	int ans = 0;
	for(int i=1;i<=N;i++){
		double xi,yi;
		cin>>xi>>yi;
		double d = (xi*xi)+(yi*yi);
		if(d<=D) ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 3736
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<=n;i++)
#define all(c) c.begin(), c.end()
#define MOD 1000000007
#define MAX 1000000001
#define INF 1410065408
 
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{int from, to; ll cost;};

signed main(){
	ll n, s;
	scanf("%lld\n%lld", &n, &s);
	
	int m = (int)sqrt((double)n);
	reppp(b, 2, m){
		ll nn = n;
		ll sum = 0;
		while(nn >= b){
			ll surplus = nn % b;
			sum += surplus;
			nn = (nn - surplus) / b;
		}
		sum += nn;
		if(sum == s){
			printf("%lld", (ll)b);
			return 0;
		}
	}
	
	vector<ll> bb;
	reppp(p, 1, m){
		//n = p * b + q
		//b = (n - q) / p = (n - s + p) / p
		ll b = (ll)((double)(n - s + p) / p);
		if(b > m && b <= n && n / b + n % b == s){
			bb.push_back(b);
		}
	}
	
	if(!bb.empty()){
		printf("%lld", *min_element(all(bb)));
		return 0;
	}
	
	if(s == 1 && n >= 2){
		printf("%lld", n);
		return 0;
	}else if(s == n){
		printf("%lld", n+1);
		return 0;
	}
	
	printf("-1");
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    std::string str = "Christmas";
    for(int i=0; i<25-n; i++){
      str += std::string(" Eve");
    }
  
    std::cout << str << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  int n;cin>>n;
  vector<string> s(n);
  rep(i,n){
    cin>>s[i];
    sort(all(s[i]));
  }
  sort(all(s));

  ll ans = 0;
  ll tmp = 0;
  rep(i,n-1){
    if(s[i] == s[i+1])tmp++;
    else{
      ans += (tmp*(tmp+1))/2;
      tmp = 0;
    }
  }
  ans += (tmp*(tmp+1))/2;
  print(ans);
  return 0;
}



Measured memory_bytes: 7296
#include <iostream>
#include <stack>
#include <set>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

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

int n;
int m;

struct edge
{
	int from;
	int to;
	i64 cost;
};

vector<edge> edges;




void input()
{
	cin >> n >> m;
	for(int i = 0;i < m;i++)
	{
		int a,b;
		i64 c;
		cin >> a >> b >> c;

		c *= -1;

		edges.push_back({a,b,c});

	}
}

i64 score[1010];
i64 INF = (1LL << 60);

bool solve()
{
	vector<bool> nega(n + 1,false);
	fill(score,score + 1010,INF);
	score[1] = 0;
	for(int i = 1;i <= n - 1;i++)
	{
		for(edge& e : edges)
		{
			if(INF != score[e.from] && score[e.to] > score[e.from] + e.cost)
			{
				//cout << e.to << "=" << score[e.to] << endl;
				score[e.to] = score[e.from] + e.cost;

			}
		}
	}
	for(int i = 1;i <= n - 1;i++)
	{
		for(edge& e : edges)
		{
			if(INF != score[e.from] && score[e.to] > score[e.from] + e.cost)
			{
				//cout << e.to << "=" << score[e.to] << endl;
				score[e.to] = score[e.from] + e.cost;
				nega[e.to] = true;
			}
			if(nega[e.from])
			{
				nega[e.to] = true;
			}
		}
	}
	return nega[n];

}

int main()
{
	input();


	if(solve())
	{
		cout << "inf" << endl;
		return 0;
	}

	cout << -score[n] << endl;
	return 0;

}


		


Measured memory_bytes: 256
n, k = map(int, input().split())
MOD = 1000000007
cnt = [0] * (k + 1)
for i in range(1, k + 1):
    cnt[i] = pow(k // i, n, MOD)

for i in range(k, 0, -1):
    j = i * 2
    while j <= k:
        cnt[i] = (MOD + cnt[i] - cnt[j]) % MOD
        j += i
ans = 0
for i in range(1, k + 1):
    ans = (ans + cnt[i] * i) % MOD
print(ans)



Measured memory_bytes: 11176
#include<bits/stdc++.h>
#define int long long
#define rep(i, l, r) for(register int i = l; i <= r; ++ i)
using namespace std;
const int N = 100010, mod = 2147483647;
inline int read()
{
    register char cc = getchar(); register int cn(0), flus(1);
    while(cc < '0' || cc > '9') {if(cc == '-') flus = - flus; cc = getchar();}
    while(cc >= '0' && cc <= '9') {cn = cn * 10 + cc - '0'; cc = getchar();}
    return cn * flus;
}
//int a[N]; 
signed main()
{
	int n, m, tmp(0);
	m = read();
	n = read();
	rep(i, 1, n)
	{
		tmp += read(); 
	}
	if(tmp > m) printf("-1\n");
	else printf("%d",m - tmp);
	return 0;
} 

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

int main()
{
  int64_t N, K, ans = 0;
  cin >> N >> K;
  map<int, int> mp;
  vector<pair<int64_t, int64_t>> vp(N);
  vector<int64_t> v1, v2, s1(N + 1, 0), s2(N + 1, 0);
  for (int i = 0; i < N; i++)
  {
    cin >> vp[i].second >> vp[i].first;
  }
  sort(vp.begin(), vp.end());
  reverse(vp.begin(), vp.end());
  for (auto p : vp)
  {
    if (mp.count(p.second))
      v2.push_back(p.first);
    else
      v1.push_back(p.first);
    mp[p.second]++;
  }
  s1[0] = 0, s2[0] = 0;
  for (int i = 1; i <= v1.size(); i++)
  {
    s1[i] = s1[i - 1] + v1[i - 1];
  }
  for (int i = 1; i <= v2.size(); i++)
  {
    s2[i] = s2[i - 1] + v2[i - 1];
  }
  for (int64_t n = 1; n <= K; n++)
  {
    if (n > v1.size() || K - n > v2.size())
      continue;
    int64_t tmp = s1[n] + s2[K - n] + n * n;
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for (int i = 0; i < 1000; i++) {
    vector<int> a = {i/100, (i/10)%10, i%10};
    int c = 0;
    for (int j = 0; j < s.size(); j++) {
      if (s[j] == (char)('0' + a[c])) c++;
      if (c == 3) {
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cmath>

using namespace std;

bool isPrime(int num){
    if(num==1)return false;
    if(num==2)return true;
    if(num%2==0)return false;
    for(int i=3;i<=sqrt(num);i+=2){
        bool flag=false;
        for(int j=i;j<=sqrt(i);j+=2){
            if(i%j==0){
                flag=true;
                break;
            }
        }
        if(flag)continue;
        if(num%i==0){
            return false;
        }
        
    }
    return true;
}

int main(){
    int n;
    cin >> n;
    int count=0;
    for(int i=0;i<n;i++){
        int a=0;
        cin >> a;
        if (isPrime(a)){
            count++;
//            cout << a << endl;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3060
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}

main :: IO ()
main = do
  s <- getLine
  print $ solve s

solve :: String -> Int
solve s = minimum . map (abs . (subtract 753) . read) $ windows 3 s

windows :: Int -> [a] -> [[a]]
windows n xs = go [] xs
  where
    go acc xs
      | length ys /= n = acc
      | otherwise      = go (ys:acc) (tail xs)
      where
        ys = take n xs


Measured memory_bytes: 508
# li = list(map(int, input().split()))
n, m = map(int, input().split())
matr = []
for i in range(n):
	matr.append(list(input().split()))
for i in range(n):
	for j in range(m):
		if matr[i][j] == "snuke":
			print(chr(ord('A')+j)+str(i+1))
			break
# print(chr(ord('A')+ind[1])+str(ind[0]))

Measured memory_bytes: 61912
#include <bits/stdc++.h>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;
const ll Lmax=ll(1e18);
const int Nmax=2e5+1;
const int Nd=61;
const int INF=1e5;

struct UnionFind {
    //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
    //そうでなければ親のid
    vector<int> r;

    UnionFind(int N) {
        r = vector<int>(N, -1);
    }

    int root(int x) {
        if (r[x] < 0) return x;
        return r[x] = root(r[x]);
    }

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (r[x] > r[y]) swap(x, y);
        r[x] += r[y];
        r[y] = x;
        return true;
    }

    int size(int x) {
        return -r[root(x)];
    }
};




int main(){
  int n,m;
  cin>>n>>m;
  UnionFind UF(n);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--; b--;
    UF.unite(a,b);
  }

    int ans=0;
    rep(i,n){
      ans=max(ans,UF.size(i));

    }


  cout<<ans<<endl;




}


Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ‘ ‘
const ll mei = (ll)1e9 + 7;

int main(){
  ll n;
  cin >> n;
  cout << n * n * n;
  memi;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>

#include<queue>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
 
#define INF (1e9)
typedef long long unsigned int ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
 

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int gcd(int a,int b){
	if(b>0){
		return gcd(b, a % b);
	}else{
		return a;
	}
}

int N;


int main()
{
	cin >> N;
	int A[N+2];
	A[0] = 0;
	A[N + 1] = 0;
	int sum = 0;
	REP(i, N)
	{
		cin >> A[i+1];
		sum += abs(A[i + 1] - A[i]);
	}
	sum += abs(A[N + 1] - A[N]);

	for(int i=1;i<=N;i++){
		int s = sum + abs(A[i - 1] - A[i + 1]) - abs(A[i] - A[i - 1]) - abs(A[i + 1] - A[i]);
		cout << s << endl;
	}

	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>

using namespace std;

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

int main(){
    string inp;
    cin >> inp;

    cout << count(inp.begin(), inp.end(), '1') << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.TreeSet;

// Java8
public class Main
{
	Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception
	{
		new Main().run();
	}

	void run()
	{
		int n = nint();
		int[] b = new int[n+1];
		for(int i=1; i<=n; i++)
		{
			int a = nint();
			b[a] = i;
		}
		TreeSet<Integer> set = new TreeSet<>();
		set.add(0);
		set.add(n+1);
		long sum = 0;
		for(int i=1; i<=n; i++)
		{
			int c = b[i];
			int lower = set.lower(c);
			int higher = set.higher(c);
			sum += ((long)i) * (c - lower) * (higher - c);
			set.add(c);
		}
		System.out.println(sum);

	}

	int nint()
	{
		return Integer.parseInt(sc.next());
	}

}

Measured memory_bytes: 54100
package main

import (
	"fmt"
)

func main() {
	var s []byte
	fmt.Scan(&s)
	var cnt int
	for i := range s {
		if s[i] == '1' {
			cnt++
		}
	}
	fmt.Println(cnt)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


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

typedef long long int llint;

int main(){
	llint Q,H,S,D;
	llint N;
	cin >> Q >> H >> S >> D;
	cin >> N;

	llint cost=0;
	{
		llint Ql=Q*8;
		llint Hl=H*4;
		llint Sl=S*2;
		llint Dl=D;
		vector<llint> V={Ql,Hl,Sl,Dl};
		cost += *min_element(V.begin(),V.end())*(N/2);
	}
	{
		llint Ql=Q*4;
		llint Hl=H*2;
		llint Sl=S;
		vector<llint> V={Ql,Hl,Sl};
		cost += *min_element(V.begin(),V.end())*(N%2);
	}
	cout << cost << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<pair<string, int>> sp(n);
    map<pair<string, int>, int> bangou;
    for (int i = 0; i < n; i++)
    {
        string s;
        int t;
        cin >> s >> t;
        sp[i] = make_pair(s, -t);
        bangou[sp[i]] = i + 1;
    }
    sort(ALL(sp));

    for (int i = 0; i < n; i++)
    {
        cout << bangou[sp[i]] << endl;
    }
}

Measured memory_bytes: 256
from collections import deque
n,q=map(int,input().split())
arr=[[] for _ in range(n)]
ans=[0]*n
for i in range(n-1):
    a,b=map(int,input().split())
    arr[a-1].append(b-1)
    arr[b-1].append(a-1)

for i in range(q):
    p,x=map(int,input().split())
    ans[p-1]+=x

que=deque([0])

visited=[0]*n
while que:
    x=que.popleft()
    visited[x]=-1
    for i in arr[x]:
        if visited[i]>-1:
            ans[i]+=ans[x]
            que.append(i)

print(*ans)

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intll int long long
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
  string s ; 
  int k ; 
  cin >> k >> s ;
    
  if(s.size() <= k) cout << s ;
  else {
    rep(i,k){
      cout << s.at(i) ;
    }
    cout << "..." ;
  }
  
  
  
}


Measured memory_bytes: 3628
n = int(input())
s = input()
rr = 0
gg = 0
bb = 0
for i in range(n):
    if s[i] == "R":
        rr += 1
    if s[i] == "G":
        gg += 1
    if s[i] == "B":
        bb += 1

ans = rr * gg * bb

for j in range(n):
    for i in range(min(j+1, n-j)):
        if s[j - i] != s[j] and s[j] != s[j + i] and s[j + i] != s[j - i]:
            ans -= 1
print(ans)


Measured memory_bytes: 9212
n,h=map(int,input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
a, b = [list(i) for i in zip(*ab)]
ab.sort(reverse=True)

bm=ab[0][1]
b.remove(bm)
b.sort()

c=0
while h>0:
  if h<=bm:
    c+=1
    break
  if len(b)>0:
    if b[-1]>ab[0][0]:
      h-=b.pop()
      c+=1
      continue
  c+=(h-bm-1)//ab[0][0]+2
  h=0

print(c)

Measured memory_bytes: 35656
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    string s, t;
    cin >> s >> t;
    vector<int> app[26];
    for(int i = 0; i < s.length(); i++){
        app[s[i]-'a'].push_back(i);
    }
    ll cur = 0, lap = 0;
    for(int i = 0; i < t.length(); i++){
        int tmp = t[i]-'a';
        int ind = lower_bound(app[tmp].begin(), app[tmp].end(), cur) - app[tmp].begin();
        if(ind == app[tmp].size()){
            lap++;
            cur = 0;
            ind = lower_bound(app[tmp].begin(), app[tmp].end(), cur) - app[tmp].begin();
            if(ind == app[tmp].size()){
                cout << -1 << endl;
                return 0;
            }
        }
        cur = app[tmp][ind]+1;
        if(cur >= s.length())   lap++, cur = 0;
    }
    cout << lap*(ll)(s.length()) + cur << endl;
    return 0;
}

Measured memory_bytes: 1216