akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"
#define fcout cout << fixed << setprecision(18)

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926535
/*
3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679
*/
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1
#define LINF 1000000000000000001 // 1e18+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  string s;cin>>s;
  int c=0;
  for(int i=0;i<4;i++){
    if(s[i]=='+'){
      c++;
    }else{
      c--;
    }
  }
  P(c);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  ll n, a_list[200050];
  ll sum = 0;
  unordered_map<ll, ll> a_map;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> a_list[i];
  }

  for (int i = 0; i < n; i++) a_map[a_list[i]]++;
  for (auto itr = a_map.begin(); itr != a_map.end(); ++itr) sum += itr -> second * (itr -> second - 1) / 2;

  for (int i = 0; i < n; i++)
  {
    cout << sum - a_map[a_list[i]] * (a_map[a_list[i]] - 1) / 2 + (a_map[a_list[i]] - 1) * (a_map[a_list[i]] - 2) / 2 << endl;
  }

  return 0;
}


Measured memory_bytes: 9160
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <stack>
#include <queue>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using ld = long double;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, i, a[10001], b[10001], c[10001], sum1=0, sum2=0;

    cin >> N;
    for(i=1; i<=N; i++){
        cin >> a[i];
    }
    for(i=1; i<=N; i++){
        cin >> b[i];
        c[i] = b[i]-a[i];
    }

    for(i=1; i<=N; i++){
        if(c[i]>0) sum1 += c[i]/2;
        else sum2 += c[i];
    }

    if(sum1+sum2>=0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

int main(void){
	int a,b;
	char tmp;

	int sum = 0, sum2 = 0;
	int n = 0;

	while(cin>>a>>tmp>>b){
		n++;
		sum2 += b;
		sum += a * b;
	}
	cout<<sum<<endl<<(int)((double)sum2/n+0.5)<<endl;

	return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;

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

int main() {
    int A, B, K;
    cin >> A >> B >> K;
    set<int> S;
    for (int i = 0; i < K; i++) {
        if (A + i <= B) S.insert(A + i);
        if (B - i >= A) S.insert(B - i);
    }
    for(auto x : S) {
        cout << x << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
vector<int>p;
int main(){
    unsigned long long int a;
    cin>>a;

    while(a!=0){
        a-=1;
        p.push_back(a%26);
        a/=26;
    }
    for(int i=p.size()-1;i>=0;i--){
        char c=p[i]+97;
        cout<<c;
    }


}


Measured memory_bytes: 3132
#include <cstdio>
#include <cstring>
using namespace std;

char s[200], t[200];

int main() {
    scanf("%s%s", s, t);
    for (int i = 0 ; s[i] ; i++) {
        if (s[i] != t[i]) {
            printf("No");
            return 0;
        }
    }
    printf("Yes");
}


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

using namespace std;

bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; 

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}
	return true;
}

int main()
{
	int n;
	vector<int> a;
	a.push_back(2);
	
	cin >> n;

	while (a.size() < n) {
		for (int i = a[a.size()-1]+1; i < 55554; i++) {
			if (IsPrime(i) && i%5 == 1) {
				a.push_back(i);
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << a[i] << ' ';
	}
	char qq;
	cin >> qq;
	return 0;
}

Measured memory_bytes: 256
<?php
$n = fgets(STDIN);
$a = explode(' ', fgets(STDIN));

foreach($a as $k => $v){
  $t = 1/$v;
  $arr[$k] = round($t,10);
}

$tmp = array_sum($arr);
$res = 1/$tmp;
echo(round($res,6));

Measured memory_bytes: 4604
import itertools
from collections import Counter 

n = int(input())
l = list(map(int,input().split()))
w = set(l)
r = Counter(l)
cnt = 0

for i,j,k in itertools.combinations(w,3):
    if i+j>k and j+k>i and k+i>j:
        cnt += (r[i]*r[j]*r[k])
    
print(cnt)

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
#define popb pop_back
using namespace std;

int main(){
  int x, y;
  cin >> x >> y;

  cout << (x + (y / 2)) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,ans=1,M=1e9+7;
vector<int>v[100050];
void dfs(int x,int p,int c)
{
	ans=1ll*ans*max(k-c,0)%M;
	int cnt=1+!!p;
	for(int i=0;i<v[x].size();i++)
		if(v[x][i]!=p)dfs(v[x][i],x,cnt++);
}
int main()
{
	cin>>n>>k;
	for(int i=1,x,y;i<n;i++)
	{
		cin>>x>>y;
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(1,0,0);
	cout<<ans;
}

Measured memory_bytes: 10368
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    cout << c <<" " <<  a <<" "<< b << endl; 

    return 0;
}

Measured memory_bytes: 256
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long x = sc.nextLong();
        long nen = 0;
        long yen = 100;
        for (int i = 1; i <= x; i++) {
            yen = (long)(yen * 1.01);
            if (yen >= x) {
                nen = i;
                break;
            }
        }
        System.out.println(nen);
    }
}



Measured memory_bytes: 27036
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
#define ld long double
#define tc() ll t;cin>>t;while(t--)
#define inp(n) ll n;cin>>(n)
#define inp2(n,m) ll n,m;cin>>(n);cin>>(m)
#define inp3(n,m,g) ll n,m,g;cin>>(n);cin>>(m);cin>>(g)
#define inps(s) string s;cin>>(s)
#define fr(i,n) for(ll i=0;i<n;i++)
#define rf(n,i) for(ll i=n-1;i>=0;i--)
#define vi vector<int >
#define vl vector<ll>
#define vd vector<ld>
#define vs vector<string >
#define pii pair<int,int>
#define pci pair<char ,int>
#define pic pair<int ,char>
#define psi pair<string ,int>
#define mii map<int ,int >
#define mci map<char ,int>
#define msi map<string ,int>
#define si set<int >
#define ss set<string>
#define pb push_back
#define mp make_pair
#define ft first
#define sd second
#define mem(a,b) memset(a,b,sizeof(a))
#define mod 1000000007

int main() {
    fast
    
		int n,m;
		cin >> n>>m;
		cout<<n*m;
		
	
	
	return 0;
}


Measured memory_bytes: 3596
import java.util.Scanner;
public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(s.equals("Sunny")){
			System.out.print("Cloudy");
		}else if(s.equals("Cloudy")){
			System.out.print("Rainy");
		}else if(s.equals("Rainy")){
			System.out.print("Sunny");
		}
	}
}


Measured memory_bytes: 21076
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vii = vector<ii>;
const int oo = 1e8+7;


int main() {
    
    int A, B;
    cin >> A >> B;
    
    int ans = max(A+A-1, max(B+B-1, A+B));
    
    cout << ans << endl;
    
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mst(a,b) memset(a,b,sizeof(a))
#define ALL(x) x.begin(),x.end()
#define pii pair<int,int>
#define eps 1e-3
inline int lowbit(int x){ return x & -x; }
const int N = 1e5 + 10;
const int mod = (int) 998244353;
const int INF = 0x3f3f3f3f;
const long long LINF = (1LL << 62);
typedef long long LL;
typedef unsigned long long ULL;
const double PI = acos(-1.0);
using namespace std;

//char buf[100000],*p1=buf,*p2=buf;
//inline char nc(){
//  return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
//inline bool read(int & x){
//  char c=nc();x=0;
//  if(c==EOF) return false;
//  bool flag = false;
//  for(;!isdigit(c);c=nc()) flag = true;
//  for(;isdigit(c);x=x*10+c-'0',c=nc());
//  if(flag) x *= -1;
//  return true;
//}
//inline bool readL(LL & x){
//  char c=nc();x=0;
//  if(c==EOF) return false;
//  bool flag = false;
//  for(;!isdigit(c);c=nc()) flag = true;
//  for(;isdigit(c);x=x*10+c-'0',c=nc());
//  if(flag) x *= -1;
//  return true;
//}
//LL q_pow(LL base, LL b){LL res=1;for(base%=mod;b;b>>=1,base=base*base%mod)if(b&1){res=res*base%mod;}return res;}

int odd[N], even[N], v[N];
vector<pii> vecOdd, vecEven;
int n;

int main(){
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
//    freopen("out.txt","w",stdout);
#endif
  scanf("%d", &n);
  for(int i = 1; i <= n; i++) scanf("%d", &v[i]);
  for(int i = 1; i <= n; i += 2) odd[v[i]]++;
  for(int i = 2; i <= n; i += 2) even[v[i]]++;

  vecOdd.clear();
  vecEven.clear();
  for(int i = 1; i < N; i++) if(odd[i]) vecOdd.push_back(make_pair(odd[i], i));
  for(int i = 1; i < N; i++) if(even[i]) vecEven.push_back(make_pair(even[i], i));
  sort(ALL(vecOdd));
  reverse(ALL(vecOdd));
  sort(ALL(vecEven));
  reverse(ALL(vecEven));
//  for(int i = 0; i < vecEven.size(); i++) printf("%d %d   ", vecEven[i].first, vecEven[i].second);
//  printf("\n");
  int ans = 0;
  for(int i = 0; i < vecEven.size(); i++) if(vecOdd[0].second != vecEven[i].second) {
    ans = vecOdd[0].first + vecEven[i].first;
    break;
  }
  for(int i = 0; i < vecOdd.size(); i++) if(vecEven[0].second != vecOdd[i].second) {
    ans = max(ans, vecOdd[i].first + vecEven[0].first);
    break;
  }
  if(ans == 0) ans = max(vecOdd[0].first, vecEven[0].first);
  printf("%d\n", n - ans);
  return 0;
}

Measured memory_bytes: 2552
import numpy as np
n, wt = map(int, input().split())
 
d = np.full(n*1000+1,wt+1, 'i8')
d[0] = 0
for _ in range(n):
  w, v = map(int, input().split())
  d[v:] = np.minimum(d[v:], d[:-v]+w)
print(np.max(np.where(d<=wt)))

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

int main() {
    
    while (true) {
        string s; cin >> s;
        if (s == "-")
            break;

        int n;cin >> n;
        vector<int> h(n);
        rep(i, n) cin >> h.at(i);

        string ans;
        ans = s;
        rep(i, n) {
            string first;
            first = ans.substr(0, h.at(i));
            string second;
            //cout << first << endl;
            second = ans.substr(h.at(i), ans.size());
            //cout << second << endl;
            ans = second + first;
        }
        cout << ans <<endl;
    }
}


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

double distance(vector<double> v1,vector<double> v2) {
    double s=0;
    for(int i=0;i<v1.size();i++) {
        int d=v1[i]-v2[i];
        s+=d*d;
    }
    return sqrt(s);
}

int main() {
    ios::sync_with_stdio(false);
    int n,d;
    cin>>n>>d;
    vector<double> x[n];
    for(int i=0;i<n;i++) {
        for(int j=0;j<d;j++) {
            int k;
            cin>>k;
            x[i].push_back(k);
        }
    }
    int count=0;
    for(int i=0;i<n-1;i++) {
        for(int j=i+1;j<n;j++) {
            double dist=distance(x[i],x[j]);
            if(int(dist)==dist) {
                count++;
            }
        }
    }
    cout<<count;
    return 0;
}

Measured memory_bytes: 256
# 3 3   n: node, m: link
# 1 2   a_1   b_1
# 1 3
# 2 3   a_m   b_m

$n, $m = gets.split.map(&:to_i)
array_a_temp, array_b_temp = $m.times.map{ gets.split.map(&:to_i) }.transpose
$array_a = array_a_temp + array_b_temp
$array_b = array_b_temp + array_a_temp

reached_node = Array.new($n, false)
used_link = []
$ans = 0

# $binding = 0

def move(to, reached_node, used_link)
  # $binding += 1
  # puts "binding: #{$binding}"
  # p reached_node
  # p used_link
  if reached_node.count(true) == $n
    $ans += 1
    return true
  end
  if used_link.length == $m
    return false
  end

  indexes_to_a = []
  $array_a.each_with_index do |a, i|
    indexes_to_a << i if a == to && !(used_link.include?(i))
  end

  indexes_to_a.each do |i|
    reached_node_temp = []
    reached_node.each do |j|
      reached_node_temp << j
    end
    # used_link_temp = []
    # used_link.each do |j|
    #   used_link_temp << j
    # end
    to = $array_b[i]
    next if reached_node[to-1]
    reached_node_temp[to-1] = true
    used_link_temp = used_link + [i]
    move(to, reached_node_temp, used_link_temp)
  end
end

indexes_1_a = []
$array_a.each_with_index do |a, i|
  indexes_1_a << i if a == 1
end

indexes_1_a.each do |i|
  reached_node = Array.new($n, false)
  from = $array_a[i]
  to = $array_b[i]
  reached_node[from-1] = true
  reached_node[to-1] = true
  used_link = [i]
  move(to, reached_node, used_link)
end

puts $ans


Measured memory_bytes: 14712
#include<cstdio>
#include<cstring>
#include<cmath>
#include<bitset>
#include<iostream>
#include<algorithm>
#include<string>
#include<utility>
#include<tuple>
#include<vector>
#include<list>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<numeric>
#include<functional>
#include<iomanip>
#include<random>

#define IOS ios::sync_with_stdio(false),cin.tie(0)
#define REP(i,n) for(int i = 0;i < n;i++)
#define FOR(i,a,b) for(int i = a;i < b;i++)
#define MEM(a,b) memset(a,b,sizeof(a))
#define ALL(x) (x).begin(),(x).end()
#define LMAX 9223372036854775807
#define LMIN -9223372036854775808

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ull, ull> UP;
typedef tuple<int, int, int> T;

struct UnionFind {
	vector<int> data;
	UnionFind(int size) : data(size, -1) {}
	void unionSet(int x, int y) {
		x = root(x), y = root(y);
		if (x != y) {
			if (data[y] < data[x])swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int gcd(int a, int b) {
	if (a < b)swap(a, b);
	int k = a % b;
	if (k == 1)return 1;
	if (k == 0)return b;
	int ans = gcd(b, k);
	return ans;
}
int digisum(ll a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}

int a[114514][3];

int main() {
	int n;
	cin >> n;
	REP(i, 3)a[0][i] = 0;
	bool ans = true;

	FOR(i, 1, n + 1) {
		REP(j, 3)cin >> a[i][j];
		ll tmp = abs(a[i][1] - a[i - 1][1]) + abs(a[i][2] - a[i - 1][2]);
		ll t = a[i][0] - a[i - 1][0];
		if (tmp > t || t % 2 != tmp % 2)ans = false;
	}
	cout << (ans ? "Yes" : "No") << endl;
}



Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int cnt=0;
int k;

bool solve(int i,int sz,string s){
    if(i==sz){
        ++cnt;
        if(cnt==k){
            cout<<s<<endl;
            return true;
        }
        return false;
    }
    s+='0';
    for(char c='0';c<='9';++c){
        if(i==0&&c=='0')continue;
        if(i!=0&&abs(s[i-1]-c)>1)continue;
        s[i]=c;
        if(solve(i+1,sz,s)){
            return true;
        }
    }
    return false;
}

int main(){
    cin>>k;
    for(int sz=1;sz<=k;++sz){
        string s={};
        if(solve(0,sz,s))return 0;
    }
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, n) for (int i = 1; i <= (n); ++i)
// using namespace atcoder;
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
//マクロ
// forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())       // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))    //最大値を求める
#define MIN(x) *min_element(ALL(x))    //最小値を求める
//定数
#define INF 1000000000000  // 10^12:極めて大きい値,∞
#define inf 2147483647     // int値の最大値
#define MOD 1000000007     // 10^9+7:合同式の法
#define MAXR 100000        // 10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back                             // vectorヘの挿入
#define MP make_pair                             // pairのコンストラクタ
#define F first                                  // pairの一つ目の要素
#define S second                                 // pairの二つ目の要素
#define CST(x) cout << fixed << setprecision(x)  //小数点以下の桁数指定
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int gcd(int a, int b) {
    if (b == 0)
        return a;
    else
        return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
//各桁の和
int sumDight(int x) {
    int sum = 0;
    while (x > 0) {
        sum += (x % 10);
        x /= 10;
    }
    return sum;
}
//回文数
int divideReverse(int x) {
    int reverse = 0;
    int r;
    while (x > 0) {
        r = x % 10;
        reverse = reverse * 10 + r;
        x /= 10;
    }
    return reverse;
}

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

    int n,m;
    cin >> n >> m;
    vector<int> a(55);
    vector<int> b(55);
    rep(i, m) cin >> a[i] >> b[i];
    vector<int> sum(55,0);
    rep(i, m) { 
        sum[a[i]]++;
        sum[b[i]]++;
    }
    rep(i, n) cout << sum[i] << endl;
}


Measured memory_bytes: 3624
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>

using namespace std;
#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

using ll = long long;
using Graph = vector<vector<int> >;

const int Mod = static_cast<int>(1e9 + 7);
const int INF = INT_MAX;


int main()
{
	int n, m;
	cin >> n >> m;
	int k, v;

	vector<vector<int>> s(n);
	vector<int> p(m);

	rep(i, m) {
		cin >> k;
		rep(j, k) {
			cin >> v;
			v--;
			s[v].push_back(i);
		}
	}
	rep(i, m)  cin >> p[i];

	int ans = 0;
	for (int bit = 0; bit < (1 << n); bit++) {
		vector<int> e(m, 0);
		for (int i = 0; i < n; i++) {
			if (bit & (1 << i)) {
				for (auto t : s[i]){
					e[t]++;
				}
			}
		}
		bool f = true;
		rep(j, m) {
			if (p[j] != e[j] % 2) {
				f = false;
				break;
			}
		}
		if (f)  ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
D = int(input())
c = list(map(int, input().split()))
S = [list(map(int, input().split())) for i in range(D)]
#T = [int(input()) for i in range(D)]
SUM = 0
last = [0] * 28
for d in range(1, D + 1):
    i = S[d - 1].index(max(S[d - 1]))
    print(i + 1)

Measured memory_bytes: 9512
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

ll n, k, ans;
vector<pair<ll, ll>> p;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n >> k;
    rep(i, 0, n) {
        ll a, b;
        cin >> a >> b;
        p.pb(mp(a, b));
    }
    sort(p.begin(), p.end());
    rep(i, 0, n) {
        k -= p[i].second;
        if (k <= 0) {
            ans = p[i].first;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2420
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <iostream>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

ll n;
ll a,b;

int main(void){
	scanf("%lld%lld%lld",&n,&a,&b);
	if(a>b || n==1){
		if(n==1 && a==b){
			printf("1\n");
			return 0;
		}
		printf("0\n");
		return 0;
	}
	printf("%lld\n",(b-a)*(n-2)+1LL);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n,x,cnt=0,i,a,b;
    cin>>n>>x;
    int arr[n];
    for(i=0;i<n;i++)cin>>arr[i];
    for(i=1;i<n;i++)
    {
        if(arr[i]+arr[i-1]>x)
        {
            a=arr[i]+arr[i-1]-x;
            cnt+=a;
            if(a<=arr[i])
                arr[i]-=a;
            else
            {
                b=a-arr[i];
                arr[i]=0;
                arr[i-1]-=b;
            }
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3996
import sys
sys.setrecursionlimit(10 ** 6)


def main():
    N = int(input())

    abc = []
    for _ in range(N-1):
        a, b, c = map(int, input().split())
        abc.append((a, b, c))

    Q, K = map(int, input().split())
    xy = []
    for _ in range(Q):
        x, y = map(int, input().split())
        xy.append((x, y))

    ans = ref_pypy(N, abc, Q, K, xy)
    print(*ans, sep="\n")


def ref_pypy(N, abc, Q, K, xy):
    """https://atcoder.jp/contests/abc070/submissions/5331379"""
    L = [-1 for i in range(N+1)]
    L[K] = 0
    n = [[] for i in range(N+1)]
    for a, b, c in abc:
        n[a].append([b, c])
        n[b].append([a, c])

    def dfs(x):
        for i in n[x]:
            if L[i[0]] == -1:
                L[i[0]] = L[x]+i[1]
                dfs(i[0])

    dfs(K)

    ans = []
    for x, y in xy:
        ans.append(L[x] + L[y])

    return ans


if __name__ == "__main__":
    main()


Measured memory_bytes: 225924
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	vector<int> food(5, 0);
	for (int i = 0; i < food.size(); i++) {
		cin >> food[i];
	}

	sort(food.begin(), food.end());

	int ans = 1e9;
	do {
		int tmp = 0;
		for (int i = 0; i < 5; i++) {
			if (i == 4) {
				tmp += food[i];
			} else {
				tmp += (food[i] + 9) / 10 * 10;
			}
		}
		ans = min(ans, tmp);
	} while (next_permutation(food.begin(), food.end()));

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        if (x == 3 || x == 5 || x == 7) {
            System.out.print("YES");
        } else {
            System.out.print("NO");
        }
    }
}

Measured memory_bytes: 21972
//Daniel Grzegorzewski
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second

using namespace std;

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

void init_ios() {
     ios_base::sync_with_stdio(0);
     cin.tie(0);
}

const int N = (int)1e5 + 10;

int n, k, h[N], dp[N];

int main() {
  init_ios();
  cin >> n >> k;
  for (int i = 1; i <= n; ++i)
    cin >> h[i];
  for (int i = 2; i <= n; ++i)
    dp[i] = (int)2e9;
  for (int i = 2; i <= n; ++i)
    for (int j = 1; j <= min(k, i-1); ++j)
      dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
  cout<<dp[n]<<"\n";
}

Measured memory_bytes: 1024
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
//#include <bits/stdc++.h>

#define all(v) v.begin(), v.end()
typedef long long ll;
#define rep(i, z, n) for(int i = z; i < n; i++)
//const int INF = 1<<29;
//const ll MOD = 1000000007;
using namespace std;

int main(){
    int N, K;
    cin >> N >> K;
    vector<char> S(N);
    int count = 0;
    cin >> S.at(0);
    char left = S.at(0);
    rep(i, 1, N){
        cin >> S.at(i);
        if(S.at(i) != left){
            count++;
            left = S.at(i);
        }
    }
    int n = 0, ans = N - count - 1;
    while(n < K){
        if(count >= 2){
            ans += 2;
            count--;
        }
        else if (count == 1){
            ans++;
        }
        else{
            break;
        }
        count--;
        n++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
static const int N = 1000;

int lcs(string X, string Y) {
	int c[N + 1][N + 1];
	int m = X.size();
	int n = Y.size();
	int maxl = 0;
	X = ' ' + X;
	Y = ' ' + Y;
	for (int i = 0; i <= m; i++) c[i][0] = 0;
	for (int j = 1; j <= n; j++) c[0][j] = 0;

	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++) {
			if (X[i] == Y[j]) {
				c[i][j] = c[i - 1][j - 1] + 1;
			}
			else {
				c[i][j] = max(c[i - 1][j], c[i][j - 1]);
			}
			maxl = max(maxl, c[i][j]);
		}
	}
	return maxl;
}

int main() {
	string s1, s2;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s1;
		cin >> s2;
		cout << lcs(s1, s2) << endl;
	}
	return 0;
}


Measured memory_bytes: 7064
#include <stdio.h>
int main(void)
{
    int n, h[100], i, ans=0, p, cnt=0;

    scanf("%d", &n);
    for(i=0;i<n;i++){
        scanf("%d", &h[i]);
    }

    while(1){
        p=0;cnt=0;
        for(i=0;i<n;i++){
            if(h[i] != 0){
                p=1;
                h[i]=h[i]-1;
            }
            else if(h[i]==0 && p==1){
                break;
            }
        }
        if(p==1) ans++;
        for(i=0;i<n;i++){
            if(h[i]==0) cnt++;
        }
        if(cnt==n) break;
    }
            
                
    printf("%d\n", ans);          

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define inf 1000000000
#define md 1000000007
#define pb push_back
#define li 100005
#define lo long long
using namespace std;
int n,a,b;
int main(){
	scanf("%d %d %d",&n,&a,&b);
	printf("%d\n",min(n*a,b));
	return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <functional>
using namespace std;
template<class T>
bool equal(T x, T y) { return x==y;}

template<>
bool equal(const char* x, const char* y) {return std::strcmp(x, y);}

template<class Iterator, class Compare>
void selection_sort(Iterator first, Iterator last, Compare comp)
{
    for(Iterator p = first; p != last; ++p)
    {
        Iterator min_position = p;
        for(Iterator q = p; q != last; ++q)
        {
            if(comp(*q, *min_position))
                min_position = q;
        }
        auto tmp = *min_position;
        *min_position = *p;
        *p = tmp;
    }
}

int main()
{
    int a, b; cin >> a >> b;
    if(a<=0 && b >=0){
        cout << "Zero" << endl;
    }else if(a > 0){
        cout << "Positive" << endl;
    }else if(a<0 && b<0){
        if((b-a)%2==0){
            cout << "Negative" << endl;
        }else{
            cout << "Positive" << endl;
        }
    }
        
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <deque>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <map>
#include <stack>
#include <set>
#include <sstream>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define mod 1000000007
#define eps 1e-6
#define ll long long
#define INF 0x3f3f3f3f
#define MEM(x,y) memset(x,y,sizeof(x))
using namespace std;
int dt[][2]= {{1,0},{-1,0},{0,1},{0,-1},{0,0}};
//typedef pair<int, int> P;
//priority_queue<int, vector<int>, greater<int> > q;

int x[110];
int f(int i,int p){
    return (i-p)*(i-p);
}
int main(){
    IOS;
    int n;
    cin>>n;
    int minn=INF,maxx=-INF;
    for(int i=1;i<=n;i++){
        cin>>x[i];
        minn=min(minn,x[i]);
        maxx=max(maxx,x[i]);
    }
    int ans=INF;
    for(int i=minn;i<=maxx;i++){
        int temp=0;
        for(int j=1;j<=n;j++){
            temp+=f(x[j],i);
        }
        ans=min(ans,temp);
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define gcakioi
#define gcakioi
#define gcakioi
#define gcakioi
#define gcakioi
#define gcakioi
using namespace std;
int main(){
    string a;
    cin>>a;
    string b=a;
    reverse(a.begin(),a.end());
    for(int i=0;i<a.size();++i)
    {
        if(a[i]=='b') a[i]='d';
        else if(a[i]=='d') a[i]='b';
        else if(a[i]=='p') a[i]='q';
        else if(a[i]=='q') a[i]='p';
    }
    if(a==b) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
const int maxn = 1e6 + 5;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    map<int,int>mp[2];
    f(n) {
        int x;
        cin >> x;
        mp[i%2][x]++;
    }
    mp[0][74751];
    mp[1][74751];
    vector<pair<int,int>>v[2];
    
    f(2) {
        for(auto j:mp[i]) {
            v[i].pb({j.S,j.F});
        }
    }
    sort(all(v[0]));
    reverse(all(v[0]));
    sort(all(v[1]));
    reverse(all(v[1]));
    if (v[0][0].S != v[1][0].S) {
        cout << n - v[0][0].F - v[1][0].F <<'\n';
    }
    else {
        cout << n - max(v[0][1].F + v[1][0].F,v[0][0].F + v[1][1].F) << '\n';
    }
}

Measured memory_bytes: 6140
using System;
using System.Linq;

namespace atcoder.abc171.c
{
    class Program
    {
        static void Main(string[] args)
        {
            long N = getLongParam();

            string ret = "";
            while (N > 0)
            {
                N--;

                ret += (char)('a' + N % 26);

                N /= 26;
            }
            Console.WriteLine(new String(ret.Reverse().ToArray()));
        }


        //↓↓↓ shared function ↓↓↓
        static int getIntParam()
        {
            return int.Parse(Console.ReadLine());
        }
        static int[] getIntParams()
        {
            return Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
        }
        static long getLongParam()
        {
            return long.Parse(Console.ReadLine());
        }
        static long[] getLongParams()
        {
            return Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
        }
        static string getStringParam()
        {
            return Console.ReadLine();
        }
        static string[] getStringParams()
        {
            return Console.ReadLine().Split(' ');
        }
    }
}


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

int main(){
    long long ans = 0;
    long long x, k, d;
    cin >> x >> k >> d;
    if (x < 0) x *= -1;
    
    long long buf;
    buf = x / d;
    if (buf >= k) {
        ans = x - k * d;
        cout << ans << endl;
        return 0;
    }
    
    long long bufk = k - buf;
    if (bufk % 2 == 0) {
        ans = x % d;
    } else {
        ans = (x % d - d) * -1;
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define reps(i, n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define repi(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> h(100010);
    rep(i,n) cin>>h.at(i);
    
    vector<int> dp(100010);
    rep(i,n){
        if(i==0) dp.at(i)=0;
        else if(i==1) dp.at(i)=dp.at(i-1)+abs(h.at(i)-h.at(i-1));
        else dp.at(i)=min(dp.at(i-1)+abs(h.at(i)-h.at(i-1)), dp.at(i-2)+abs(h.at(i)-h.at(i-2)));
    }
    
    cout<<dp.at(n-1)<<endl;
}


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

int main() {
  int n;
  cin >> n;
  int t1=0,x1=0,y1=0,t2,x2,y2;
  for (int i=0; i<n; i++) {
    cin >> t2 >> x2 >> y2;
    if (abs((abs(x2-x1)+abs(y2-y1)-(t2-t1))) % 2 == 1
	|| abs(x2-x1)+abs(y2-y1) > t2-t1) {
      cout << "No" << endl;
      return 0;
    }
    t1=t2;
    x1=x2;
    y1=y2;
  }

  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <atcoder/all>
#define endl "\n"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

const long long INF = 1e18;
//const ll mod = 1000000007;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;
    cin >> k;
    while(k--) cout << "ACL";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3580
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		long X = scan.nextLong();
		long sum = 0;
		sum += (X/500)*1000;
		sum += ((X%500)/5)*5;
		System.out.println(sum);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, x;
    cin >> n >> x;
    vector<ll> l(n);
    rep(i, n) cin >> l[i];
    ll sum = 0, ans = 1;
    rep(i, n) {
        sum += l[i];
        if (sum > x) break;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
use std::cmp::min;
use std::collections::HashMap;
use std::collections::VecDeque;

fn main() {
    input! {
        N: usize,
        A: i64,
        B: i64,
        Xs: [i64; N],
    }

    let mut ans: i64 = 0;

    // 次の町に最短のコストで進むことを繰り返す
    for i in 0..N - 1 {
        let cost = min(B, (Xs[i + 1] - Xs[i]) * A);
        ans += cost;
    }

    println!("{}", ans);
}


Measured memory_bytes: 3740
#include <bits/stdc++.h>
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define vll vector< ll >
//#define M 100000
#define MD 1000000007
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= b; ++i)
#define fo(i,a,b) for(int i = a; i<= b; ++i)
#define pii pair<int,int>
#define vec(a) vector<a >
#define all(a) a.begin(),a.end()
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//#define int unsigned long long
//#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long  
#define int long long
using namespace std;
//using ll = unsigned long long;
ll md=MD;
//ll M=1073741824;
ll M=998244353;
//ll exp(ll a,ll b){ll r=1;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b>>=1;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll Min(int a,int b){if(a<b)return a; return b;}
ll Max(int a,int b){if(a>b)return a; return b;}
ll power(ll a,ll b){ll ans=1;while(b>0){if(b&1)ans=(ans*a)%M;a=(a*a)%M;b=b>>1;}return ans;}
const int INF=1000000000000000000;


int32_t main()
{
	IOS;
	int t;
//	cin>>t;
	t=1;
	while(t--)
	{
		 int n;
		 cin>>n;
		 int sum=0;
		 vector<int> chk(100001,0);
		 for(int i=0;i<n;++i)
		 {
		 	int x;
		 	cin>>x;
		 	sum+=x;
		 	++chk[x];
		 }
		 int q;
		 cin>>q;
		 while(q--)
		 {
		 	int x,y;
		 	cin>>x>>y;
		 	sum+=(chk[x]*(y-x));
		 	chk[y]+=chk[x];
		 	chk[x]=0;
		 	cout<<sum<<"\n";
		 }
	}
	return 0;
}

Measured memory_bytes: 3980
#include <stdio.h>
#include <math.h>

int main(void)
{
	int i;
	double n, s[1000] = { 0 }, a = 0, m = 0;
	
	while (1)
	{
		scanf("%lf", &n);

		if (n==0)
		{
			break;
		}
		for (i = 0; i < n; i++)
		{
			scanf("%lf", &s[i]);

			m = m + s[i];

		}

		m = m / n;

		for (i = 0; i < n; i++)
		{
			a = a + (s[i] - m)*(s[i] - m);

			s[i] = 0;
		}

		printf("%lf\n", sqrt(a / n));

		a = 0;
		m = 0;
		
	}
	return 0;
}


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

using namespace std;
typedef long long int ll;

vector<ll> s_tree;

void update(int tpos, int l, int r, int pos, ll val){
	if(l > r) return;
	if(l==r && l==pos){
		s_tree[tpos] = val;
		return;
	}
	int m = (l+r) >> 1;
	if(pos<=m)
		update(tpos*2,l,m,pos,val);
	else
		update(tpos*2+1,m+1,r,pos,val);	
	s_tree[tpos] = max(s_tree[tpos*2],s_tree[tpos*2+1]);
}
ll get_max(int tpos, int tl, int tr,int l, int r){
	if(tl > tr) return 0;
	if(tr < l || tl > r) return 0;
	if(tr <= r && tl >= l) return s_tree[tpos];
	int m = (tl+tr) >> 1;
	return max(get_max(tpos*2,tl,m,l,r),get_max(tpos*2+1,m+1,tr,l,r));
}


int main(){
	int n;
	cin >> n;
	vector<ll> h(n),a(n);
	s_tree.resize(4*n+2);
	for(int i = 0; i < n; i++) cin >> h[i];
	for(int i = 0; i < n; i++) cin >> a[i];
	ll best = 0;
	for(int i = 0; i < n; i++){
		ll cur_best = get_max(1,1,n,1,h[i]);
		best = max(best,cur_best+a[i]);
	//	cout << cur_best << "\n";
		update(1,1,n,h[i],cur_best+a[i]);
	}
	cout << best << "\n";
	return 0;
}


Measured memory_bytes: 9600
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) begin(a),end(a)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
ll gcd(ll a, ll b){
  if (b==0) return a;
  else return gcd(b,a%b);
}
int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

template <typename T> bool next_combination(const T first, const T last, int k) {
    const T subset = first + k;
    // empty container | k = 0 | k == n 
    if (first == last || first == subset || last == subset) {
        return false;
    }
    T src = subset;
    while (first != src) {
        src--;
        if (*src < *(last - 1)) {
            T dest = subset;
            while (*src >= *dest) {
                dest++;
            }
            iter_swap(src, dest);
            rotate(src + 1, dest + 1, last);
            rotate(subset, subset + (last - dest) - 1, last);
            return true;
        }
    }
    // restore
    rotate(first, subset, last);
    return false;
}

int a[5];
vector<int> v{0,1,2,3,4};
int main(){
  int N;
  cin >> N;
  rep(i,N){
    string s;
    cin >> s;
    if(s[0] == 'M') a[0]++;
    if(s[0] == 'A') a[1]++;
    if(s[0] == 'R') a[2]++;
    if(s[0] == 'C') a[3]++;
    if(s[0] == 'H') a[4]++;    
  }
  ll ans = 0;
  do {
    ll tmp = 1;
    rep(i,3){
      tmp *= a[v[i]];
      
    }
    ans += tmp;
  }while(next_combination(all(v),3));
  cout << ans << endl;

      
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	/*if (n == 1) {
		dunk(1);
		return 0;
	}*/
	vector<P> res;
	int cnt = 1;
	rrep(i, n) {
		if (s[i] == s[i - 1]) cnt++;
		else {
			if (s[i] == '1') res.emplace_back(P(0, cnt));
			else res.emplace_back(P(1, cnt));
			cnt = 1;
		}
	}
	if (s.back() == '0') res.emplace_back(P(0, cnt));
	else res.emplace_back(P(1, cnt));
	int p = res.size();
	//rep(i, p) cout << res[i].first << ' ' << res[i].second << endl;
	res.emplace_back(P(0, 0));
	res.emplace_back(P(0, 0));
	vector<int> ans(p + 1);
	ans[0] = 0;
	rep(i, p) ans[i + 1] = ans[i] + res[i].second;
	int j_ans = 0;
	if (2 * k >= p) {
		dunk(n);
		return 0;
	}
	for (int i = 0; i < p + 1; ++i) {
		if (!res[i + 1].first) {
			j_ans = max(j_ans, ans[min(p,i + 2 * k + 1)] - ans[i]);
		}
		else {
			if (i + 2 * k >= p + 1) continue;
			j_ans = max(j_ans, ans[min(p,i + 2 * k)] - ans[i]);
		}
	}
	dunk(j_ans);
	return 0;
}

Measured memory_bytes: 1528
import numpy as np
from collections import deque

H, W = map(int, input().split())
maze = [input() for _ in range(H)]

# 方針
# まずはスタート地点を固定し、移動回数を最小にして歩いたときの最大移動回数をbfs関数で求める
# ついでスタート地点を動かして、当の最大移動回数の最大値をとる
def bfs(maze, visited, sy, sx):

    visited[sy][sx] = 0
    # queueの要素について、そこから周囲4方向を模索する
    # queueには、これから周囲4方向を模索すべき地点が格納されている
    queue = deque([[sy, sx]])

    while queue:
        y, x = queue.popleft()
        for dy, dx in ([1, 0], [0, 1], [-1, 0], [0, -1]):
            ny, nx = y + dy, x + dx
            if 0 <= ny < H and 0 <= nx < W and \
                    maze[ny][nx] == "." and visited[ny][nx] == -1:
                visited[ny][nx] = visited[y][x] + 1
                queue.append([ny, nx])

    return np.amax(visited)

ans = -1
for i in range(H):
    for j in range(W):
        sy, sx = i, j
        # (i,j)地点に到達するのにかかった歩数を(i,j)成分に記録する用のリストvisited
        visited = [[-1] * W for _ in range(H)]
        if maze[sy][sx] == '.':
            ans = max(ans, bfs(maze, visited, sy, sx))

print(ans)


Measured memory_bytes: 21704
#include<stdio.h>
#include<string.h>
#define LEN 100005
#define MAX 100000
typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n,m;

void enqueue(P x){
  if (isFull() == 1) printf("??¨?????????????????????????????????\n");
  Q[tail] = x;
	 
  if (tail + 1 == MAX) tail = 0;
  else tail++;
 
}

P dequeue(){
  P x;
  if (isEmpty()==1) printf("??¨???????????¢?????????????????????\n");
  x = Q[head];
  
  if (head + 1 == MAX) head = 0;
  else head++;
  return x;
}

void initialize(){
  head = tail = 0;
      }
int isEmpty(){
  if(head == tail) return 1;
  else return 0;
      }
int isFull(){
  if(head == (tail + 1) % MAX) return 1;
  else return 0;
      }

int main(){
  int elaps = 0, c=0;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
  m = n;
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1;
  tail = n+1;
  while(n != 0){
    u =Q[head];
    u.t = Q[head].t - q;
    if(u.t > 0){
      elaps = elaps + q;
      enqueue(u);
      Q[head] = dequeue();
    }
    else {
      elaps = elaps + Q[head].t;
      printf("%s",Q[head].name);
      printf(" %d\n",elaps);
      Q[head] = dequeue();
      n--;
    }
  }
      
    

  
  return 0;
}

Measured memory_bytes: 10756
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <cmath>
#include <queue>
typedef long long ll;
using namespace std;

int main(void){
    string S;
    cin >> S;
    string ans = "";
    for(int i = 0; i < S.length(); i++) ans+="x";
    cout << ans << endl;
}


Measured memory_bytes: 256