akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>

using namespace std;

typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF=1LL<<60;

vector<string> split(const string& input, char delimiter)
{
    stringstream stream(input);
    
    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}

//#define DEBUG

ll A, B, C, D, E, M, N, K, Q, W, H, T, X, Y;

int main()
{
    cin >> N >> M;
    cout << ( (N-1)*(M-1) ) << endl;

    return 0;
}

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

using namespace std;

vector<int> Z_algorithm(string s) {
	vector<int> ret(s.size(), 0);
	int c = 0;
	for (int i = 1; i < s.size(); ++i) {
		if (i + ret[i-c] < c + ret[c]) {
			ret[i] = ret[i-c];
		} else {
			int j = max(0, c + ret[c] - i);
			while (i + j < s.size() && s[j] == s[i+j]) { ++j; }
			ret[i] = j;
			c = i;
		}
	}
	ret[0] = s.size();
	return ret;
}

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

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		string t = s.substr(i, N);
		auto vec = Z_algorithm(t);
		for (int j = 0; j < vec.size(); ++j) {
			if (vec[j] <= j) { ans = max(ans, vec[j]); }
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import numpy as np

N = int(input())
A = [np.array(list(map(int, input().split()))).nonzero()[0] for _ in range(N)]

MOD = 10 ** 9 + 7
dp = np.zeros(1 << N, dtype=np.int64)
dp[0] = 1
for a in A:
    new_dp = np.zeros_like(dp)
    for i in a:
        x = (1 << i)
        new_dp[x:] += dp[:-x]
    dp = new_dp
    dp %= MOD
print(dp[-1])


Measured memory_bytes: 47156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7

#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

#define MAX_N 401
#define INF 10000000000001
long long d[MAX_N][MAX_N];
long long N;

void warshall_floyd() {
	for (int k = 0; k < N; k++) 
		for (int i = 0; i < N; i++) 
			for (int j = 0; j < N; j++) d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
}




int main(){	
	long long H;
	long long W;
	scanf("%lld",&H);
	vector<string> S(H-1+1);
	scanf("%lld",&W);
	for(int i = 0 ; i <= H-1 ; i++){
		cin >> S[i];
	}

	for(int i = 0 ; i <= MAX_N-1 ; i++){
		for(int j = 0 ; j <= MAX_N-1 ; j++){
			if (i == j) d[i][j] = 0; else d[i][j] = INF;
		}
	}
	rep(i, H) {
		rep(j, W) {
			if (i > 0 && S[i][j] == '.' && S[i-1][j] == '.') {
				ll f = i*W+j, t = (i-1)*W+j;
				d[f][t] = 1;
				d[t][f] = 1;
			}
			if (j > 0 && S[i][j] == '.' && S[i][j-1] == '.') {
				ll f = i*W+j, t = i*W+j-1;
				d[f][t] = 1;
				d[t][f] = 1;
			}
			if (i < H-1 && S[i][j] == '.' && S[i+1][j] == '.') {
				ll f = i*W+j, t = (i+1)*W+j;
				d[f][t] = 1;
				d[t][f] = 1;
			}
			if (j < W-1 && S[i][j] == '.' && S[i][j+1] == '.') {
				ll f = i*W+j, t = i*W+j+1;
				d[f][t] = 1;
				d[t][f] = 1;
			}
		}
	}
	N = H*W;
	warshall_floyd();
	ll res = 0;
	rep(i, H*W) {
		rep(j, H*W) {
			// cout << i/W << " " << i%W << "  " << j/W << " " << j%W << "  " << d[i][j] << endl;
			if (d[i][j] < INF) res = max(res, d[i][j]);
		}
	}
	cout << res << endl;
	return 0;
}



Measured memory_bytes: 1536
#include <iostream>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    int64_t H, W, h, w;
    std::cin >> H >> W >> h >> w;

    std::cout << (H-h) * (W-w) << std::endl;

    return 0;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a = int(readline())
    b = int(readline())
    c = int(readline())
    x = int(readline())
    ans = 0
    for i in range(a + 1):
        for j in range(b + 1):
            for k in range(c + 1):
                cur = 500 * i + 100 * j + 50 * k
                if cur == x:
                    ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 65044
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int N;
    int A[20];
    int B[20];
    int C[20];
    int result = 0;
    scanf("%d", &N);
    for (int i = 1; i <= N; i++) {
        scanf("%d", &A[i]);
    }
    for (int i = 1; i <= N; i++) {
        scanf("%d", &B[i]);
    }
    for (int i = 1; i <= N - 1; i++) {
        scanf("%d", &C[i]);
    }
    for (int i = 1; i <= N - 1; i++) {
        result += B[A[i]];
        if ((A[i] + 1) == A[i + 1]) {
            result += C[A[i]];
        }
    }
    result += B[(A[N])];
    printf("%d", result);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
const int N = 100000 + 10;
typedef long long LL;
const LL MOD = 998244353;
int n, d[N], mx;
int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i ++) {
        int x; scanf("%d", &x);
        if (i == 1 && x != 0) return !printf("0\n");
        d[x] ++; mx = max(mx, x);
    }
    if (d[0] > 1 || d[0] == 0) return !printf("0\n");
    LL ans = d[0];
    for (int i = 1; i <= mx; i ++) {
        if (d[i] == 0) return !printf("0\n");
        for (int j = 1; j <= d[i]; j ++) {
            ans = ans * d[i-1] % MOD;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D,E;
  cin >> A >> B>> C >> D >>E;
  if(A==0){
    cout << 1 <<endl;
  }
    if(B==0){
    cout << 2 <<endl;
  }
    if(C==0){
    cout << 3 <<endl;
  }
    if(D==0){
    cout << 4 <<endl;
  }
    if(E==0){
    cout << 5 <<endl;
  }
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define ll  long long

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, "\e[31;1m"); fprintf(stderr, __VA_ARGS__); fprintf(stderr, "\e[0m")
#else
    #define eprintf(...) 42
#endif

std::string solve(const std::vector<std::string>& S)
{
    std::string s;
    for (auto itr = S.begin(); itr != S.end(); ++itr)
    {
        s += (*itr)[0];
    }
    return s;
}

int main(void)
{
    std::vector<std::string> S(3);
    for (int i = 0; i < 3; i++)
    {
        std::cin >> S[i];
    }
    std::cout << solve(S) << std::endl;

    return 0;
}

Measured memory_bytes: 256
s=input()
n=len(s)
 
res=0
for i in range(n):
  for j in range(i,n):
    sub=s[i:j+1]
    flg=True
    for k in sub:
      if(k not in ['A','G','C','T']):
        flg=False
    if(flg):
      res=max(res,len(sub))
      
print(res)

Measured memory_bytes: 3064
use std::io;

fn read_line()-> String {
    let mut s = String::new();
    let _ = io::stdin().read_line(&mut s).unwrap();
    s
}

fn count(s: &str,s_cnt: String) -> i64 {
	let mut c = 0;
	let s_iter = s.trim().split("").collect::<Vec<&str>>();
	for i in s_iter.iter() {
		if i.to_string() == s_cnt {
			c+=1;
		}
	}
	c
}

fn main() {
	let s = read_line();
	let five = count(&s,"5".to_string());
	let seven = count(&s,"7".to_string());
	if five == 2 && seven == 1 {
		println!("YES");
	}else {
		println!("NO")
	}
}


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

int main(){
    string s, t;
    bool flag = true;
    cin >> s >> t;
     for(int i = 0; i < s.length(); i++){
         if(s[i] != t[i]){
             flag = false;
         }
     }
     if(flag == true)cout << "Yes" << endl;
     else cout << "No" << endl;
}

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


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

    string s;
    cin >> s;
    cout << s.substr(0, len(s)-8) << endl;

}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
int a , b , c ,d ,e ,k,m;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
scanf("%d",&d);
scanf("%d",&e);
scanf("%d",&k);
m=e-a;
if(m>k){
    printf(":(");}
    else { printf("Yay!");}
    
    return 0;
}

Measured memory_bytes: 128
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()

hand = {'r':p, 's':r, 'p':s}
win = {'r':'p', 's':'r', 'p':'s'}

ans = 0
u = []
for i,tt in enumerate(t):
    if i >= k and tt == t[i-k] and u[i-k] == win[tt]:
            u.append(tt)
    else:
        u.append(win[tt])
        ans += hand[tt]
print(ans)


Measured memory_bytes: 4212
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;


/*
*/

ll n;
double ans=0;

int main(void){
	cin>>n;
	rep(i,n){
		string u;
		double x;
		cin>>x>>u;
		if(u=="BTC"){
			ans+=x*380000.0;
		}else{
			ans+=x;
		}
	}
	cout<<fixed<<setprecision(15)<<ans<<endl;
	return 0;
}

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

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define DOUBLE fixed << setprecision(10)
#define fi first
#define se second
const double pi = acos(-1.0);
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };
template <typename T>
bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
};
template <typename T>
bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
};
void Pvll(vll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) cout << v[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}
void Pvvll(vvll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Ps(string s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) cout << s[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}

void Pvs(vs s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) {
		rep(j, s[i].size()) {
			cout << s[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}

void Yay(bool x) {
	if (x) cout << "Yay!\n";
	else cout << ":(\n";
}

//最大公約数
ll gcd(ll m, ll n) {
	if ((0 == m) || (0 == n))
		return 0;

	// ユークリッドの方法
	while (m != n)
	{
		if (m > n) m = m - n;
		else         n = n - m;
	}
	return m;
}
//最小公倍数
ll lcm(ll m, ll n) {
	if ((0 == m) || (0 == n))
		return 0;

	return (m * n / gcd(m, n));
}

ll  n, m, r, l, k, h, ans = 0, ret = M;
bool flag = false, flag2 = false, flag3 = false;
string s,t;

void INIT() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << DOUBLE;
}

int main() {
	INIT();
	cin >> n;
	vs v(n);
	rep(i, n) {
		cin >> v[i];
		sort(all(v[i]));
	}
	sort(all(v));
	ll sum = 0;
	rep(i, n-1) {
		if (v[i] == v[i + 1]) ans += ++sum;
		else sum = 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 5760
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int [][][] array = new int[4][3][10];
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        for(int i = 0; i < a; i++) {
            int b = sc.nextInt();
            int c = sc.nextInt();
            int d = sc.nextInt();
            int e = sc.nextInt();
            array[b-1][c-1][d-1] += e;
        }
        for(int i = 0; i < 4; i++) {
            for(int j = 0; j < 3; j++) {
                for(int k = 0; k < 10; k++) {
                    System.out.print(" " + array[i][j][k]);
                }
                System.out.println();
            }
            if(i < 3) {
                System.out.println("####################");
            }
        }
    }
}



Measured memory_bytes: 30128
N,M=map(int,input().split())
Ks=[list(map(int,input().split())) for _ in range(M)]
P=list(map(int,input().split()))

x=2**N
ans=0
for i in range(x):
    A=list(format(i,'b').zfill(N))
    flag=1
    for j in range(M):
        buf=0
        for k in range(Ks[j][0]):
            buf+=int(A[Ks[j][k+1]-1])
        if buf%2!=P[j]:
            flag=0
            break
    ans+=flag
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int K,X;cin>>K>>X;
    if(500*K>=X) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc *bufio.Scanner

func nextString() string {
	sc.Scan()
	i := sc.Text()
	return i
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

type Dice struct {
	nums []int
}

//  /1
// 4/2/3/5
//  /6
func (d *Dice) rotate(direction string) {
	if direction == "W" {
		d.nums[0], d.nums[2], d.nums[5], d.nums[3] = d.nums[2], d.nums[5], d.nums[3], d.nums[0]
	}
	if direction == "E" {
		d.nums[0], d.nums[2], d.nums[5], d.nums[3] = d.nums[3], d.nums[0], d.nums[2], d.nums[5]
	}
	if direction == "N" {
		d.nums[0], d.nums[4], d.nums[5], d.nums[1] = d.nums[1], d.nums[0], d.nums[4], d.nums[5]
	}
	if direction == "S" {
		d.nums[0], d.nums[1], d.nums[5], d.nums[4] = d.nums[4], d.nums[0], d.nums[1], d.nums[5]
	}

}

func (d *Dice) lr(direction string) {
	if direction == "L" {
		d.nums[3], d.nums[1], d.nums[2], d.nums[4] = d.nums[1], d.nums[2], d.nums[4], d.nums[3]
	}
	if direction == "R" {
		d.nums[3], d.nums[1], d.nums[2], d.nums[4] = d.nums[4], d.nums[3], d.nums[1], d.nums[2]
	}
}

func (d *Dice) getindex(value int) (index int) {
	for i, v := range d.nums {
		if v == value {
			index = i
			break
		}
	}
	return index
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	dice := Dice{
		make([]int, 6),
	}
	for i := 0; i < 6; i++ {
		dice.nums[i] = nextInt()
	}
	q := nextInt()
	for i := 0; i < q; i++ {
		up, front := nextInt(), nextInt()
		index := dice.getindex(up)
		if index == 1 {
			dice.rotate("N")
		}
		if index == 2 {
			dice.rotate("W")
		}
		if index == 3 {
			dice.rotate("E")
		}
		if index == 4 {
			dice.rotate("S")
		}
		if index == 5 {
			dice.rotate("N")
			dice.rotate("N")
		}
		for {
			if dice.nums[1] == front {
				break
			}
			dice.lr("L")
		}
		fmt.Println(dice.nums[2])
	}
}



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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
	ll N;
	cin >> N;
	vector<pair<ll, ll>> ab(N);
	REP(i, N)cin >> ab[i].second >> ab[i].first;
	sort(ab.begin(), ab.end());

	ll now = 0;
	for (auto p : ab) {
		now += p.second;
		if (now > p.first) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3328
# Author: cr4zjh0bp
# Created: Thu Mar 12 20:02:15 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

S = ns()

print("2018" + S[4:])

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

#define ll long long

#ifdef sarthak
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#else
#define trace(...)
#endif

#ifndef sarthak
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif

#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fort(i,v) for(auto i:v)
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) rep(i,sizeof(ar)/sizeof(ll)) ar[i]=val
#define fill2(ar,val) rep(i,sizeof(ar)/sizeof(ar[0])) rep(j,sizeof(ar[0])/sizeof(ll)) ar[i][j]=val
#define fill0(ar) memset(ar,0,sizeof(ar))
#define debug(x) cout<<#x<<": "<<x<<endl

#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define sd2(x,y) scanf("%d %d",&x,&y)
#define slld2(x,y) scanf("%lld %lld",&x,&y)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pd2(x,y) printf("%d %d\n",x,y)
#define plld2(x,y) printf("%lld %lld\n",x,y)
#define all(ar) ar.begin(), ar.end()
#define endl '\n'
#define sz(x) (int)x.size()
#define len(x) (int)x.length()

typedef pair<ll, ll> ii;
typedef pair<ii, ll> iii;
typedef vector<ii> vii;
typedef vector<ll> vi;

#define INF 1000000000000000000
#define PI 3.14159265358979323846L

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rngb(chrono::steady_clock::now().time_since_epoch().count()); // can give negative values too

void solve()
{
    ll a,b,c;
    cin >> a >> b >> c;
    ll xx1 = 4*a*b;
    ll xx2 = c-a-b;
    if(xx2<0)
    {
        cout << "No" << endl;
        return;
    }
    xx2 = xx2*xx2;

    if(xx1<xx2)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed;
    cout << setprecision(10);
    #ifdef sarthak
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ll t = 1;
    // cin >> t;
    while(t--)
    {
        solve();
    }

    #ifdef sarthak
    cerr << "Time elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
    #endif
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;
const string YES = "Yes";
const string NO = "No";

int main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<long long> a(N);
  map<ll, ll> mp;
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &a[i]);
    mp[a[i]]++;
  }
  sort(a.begin(), a.end());
  if (mp.size() == 1)
  {
    if (mp[0] > 0)
      cout << YES << endl;
    else
      cout << NO << endl;
  }
  else if (mp.size() == 2 && N % 3 == 0)
  {
    if (a[0] == 0 && mp[a[0]] == N / 3 && mp[a[N / 3]] == 2 * N / 3)
      cout << YES << endl;
    else
      cout << NO << endl;
  }
  else if (mp.size() == 3 && N % 3 == 0)
  {
    bool flag = true;
    ll t = -1;
    ll s = 0;
    for (auto &e : mp)
    {
      s ^= e.first;
      if (t < 0)
        t = e.second;
      if (t != e.second)
        flag = false;
    }
    if (flag && s == 0)
      cout << YES << endl;
    else
      cout << NO << endl;
  }
  else
    cout << NO << endl;

  return 0;
}


Measured memory_bytes: 5632
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N, K;
  cin>>N>>K;
  map<int, int> amap;
  vector<int> arr;
  int tmp;
  for(int i=0;i<N;++i) {
    cin>>tmp;
    if(amap[tmp]==0) arr.push_back(tmp);
    amap[tmp]++;
  }
  vector<int> arr1;
  for(int i=0;i<arr.size();++i) {
    arr1.push_back(amap[arr[i]]);
  }
  sort(arr1.begin(), arr1.end(), greater<int>());
  int ans = 0;
  for(int i=K;i<arr.size();++i) ans += arr1[i];
  cout<<ans<<endl;
}



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

int main() {
    int n;
    std::cin >> n;
    std::vector<int> vec(n+1, 0);
    vec[0] = 1;
    vec[1] = 1;
    for (int i = 2; i <= n; i++) {
        vec[i] = vec[i-1] + vec[i-2];
    }
    std::cout << vec[n] << std::endl;
}



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll MAX = 510000;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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 main()
{
    int x;
    cin >> x;
    if(x>=30){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3632
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int i = sc.nextInt();
		String h = String.valueOf(i / 60 / 60);
		String m = String.valueOf((i / 60) % 60);
		String s = String.valueOf(i % 60);
		System.out.println(h + ":" + m + ":" + s);

	}
}


Measured memory_bytes: 26140
/*
    問題をよく読もう！
    論理的に考えよう！
    サンプルを確認しよう!
    絶対に諦めるな！
    工夫をしろ！
    配列は少し多めにとっておく

    Twitterは終わるまでログアウト！
    （間違えて解法をツイートしてはいけないから）

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//繰り返し
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//イテレータ
#define all_range(C) begin(C), end(C)
//簡略化
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//最大最小
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//関数

//最大公約数を求める
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//最小公約数を求める
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//xのy乗を求める ※参考：10^18乗まで
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
  }

  return sum;
}

//main.cpp----------------------------


void solve();

ll n, k;

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

  solve();

  return 0;
}

void solve() {

  for(int i=1; i<=n; i+=2) --k;

  if(k<=0) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#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 DEBBY
~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__) << "] "

#define ll long long
#define rep(i,a,b) for(int i=int(a); i<=int(b); i++)
#define sz(v)  (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
#define fs first
#define sd second
#define pb push_back

void solve(){
      /////////////// A
      // string s, t;
      // cin >> s >> t;
      // for(int i=0; i<(int)s.size(); i++){
      //       if(s[i]!=t[i]){
      //             cout << "No\n";
      //             return;
      //       }
      // }
      // cout << "Yes\n";

      /////////////// B
      int a,b,c,k; cin >> a >> b >> c >> k;
      if(k<a){
            cout << k;
      } else if(k<a+b){
            cout << a;
      } else{
            cout << a - (k-a-b);
      }
} 

int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      solve();
      return 0;
}
      





Measured memory_bytes: 3612
n,*l=map(int,open(0).read().split())
cnt=0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      a,b,c=l[i],l[j],l[k]
      if a==b or b==c or c==a:
        continue
      if abs(b-c)<a<b+c:
        cnt+=1
print(cnt)

Measured memory_bytes: 68460
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int x;
  cin >> x;
  if(x < 1200)
    cout << "ABC" << endl;
  else
    cout << "ARC" << endl;
  return 0;
}



Measured memory_bytes: 256
N, K = map(int, input().split())

ans = 0
for i in range(K + 1, N + 1):
    # print(i, N // i, N // i * (i - K))
    # print(i)
    tmp = N // i
    ans += tmp * (i - K)
    # print("a", tmp * (i - K))
    if(N % i >= K):
        ans += N % i - K + int(K > 0)
        # print("b", N % i - K + 1)

print(ans)

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

using namespace std;

typedef long long ll;
#define fi first
#define se second
#define pb push_back

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int k;
	string s;
	cin >> k >> s;
	int n = s.size();
	if (n <= k) cout << s;
	else {
		for (int i = 0; i < k; i++) {
			cout << s[i];
		}
		cout << "...";
	}
	return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
int n;

void CountingSort(int *,int *,int );
int main(){

  int i,j;
  int C[2000000];
  int newC[2000000];
  scanf("%d",&n);
  for(i = 0;i <n ; i++){
    scanf("%d",&C[i]);
  }
  
  CountingSort(C,newC,n);
  return 0;
}

void CountingSort(int *A,int *B,int k){
  int i,j;
  int C[1000000];
  for(i=0;i<=100000;i++){
    C[i] = 0;
  }
  
  for(j = 1; j<=n;j++){
    C[A[j-1]]++;
  }
  
  for(i = 1; i<=1000000; i++){
    C[i] = C[i] + C[i-1];
  }
  /*
  printf("A[i]: ");
  for(i=0;i<n;i++){
    printf("%2d ",A[i]);
  }

  
  printf("\n");
 printf("C[i]: ");
  for(i=0;i<n;i++){
    printf("%2d ",C[i]);
  }
    printf("\n");
 printf("A[j-1]: ");
  for(j = n; j>=1; j--){
    printf("%2d ",A[j-1]);
  }
    printf("\n");
     printf("C[A[j-1]]: ");
  for(j = n; j>=1; j--){
    printf("%2d ",C[A[j-1]]);
  }
  printf("\n");
  */
  for(j = n; j>=1; j--){
    B[C[A[j-1]]] = A[j-1];
    C[A[j-1]]--;
  }
  
  for(i=1;i<n;i++){
    printf("%d ",B[i]);
  }
  printf("%d",B[i]);
  printf("\n");
}



Measured memory_bytes: 21240
n = int(input())
cards = list(map(int, input().split()))
remains = cards.copy()
alice, bob = [], []
while remains:
    a = max(remains)
    alice.append(a)
    remains.remove(a)
    if not remains:
        break
    b = max(remains)
    bob.append(b)
    remains.remove(b)
print(abs(sum(alice) - sum(bob)))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
/*メモ 
*/
int main(){
    int d,n;
    std::cin >> d>>n;
    if(n==100)n++;
    std::cout << int(pow(100,d)*n) << std::endl;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using  namespace std;
#define ll long long
#define sc second
#define fr first
#define mp make_pair
const int N = 500 + 10,MOD = 1e9 + 7;
const int OO = 1e9 + 5000;
int n , k;
ll sum;
vector<ll> g;
ll a[N] , dp[N];
vector<int> v;
ll need;
bool check(ll cc) {
	v.clear();
	for (int i = 1; i <= n; ++i) {
		v.push_back(a[i] % cc);
	}
	sort(v.begin(), v.end());
	ll sofar = 0;
	for (int i = 0; i < v.size(); ++i) {
		sofar += (cc - v[i]);
	}
	ll get = 0;
	for (int i = 0; i < v.size(); ++i) {
		sofar -= (cc - v[i]);
		get += v[i];
		if (get == sofar && get <= k)
			return true;
	}
	return false;
}
int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; ++i) {
		int x;
		cin >> x;
		sum += x;
		a[i] = x;
	}
	sort(a + 1, a + 1 + n);
	for (ll i = 1; i*i <= sum; ++i) {
		if (i*i == sum) {
			g.push_back(i);
			break;
		}
		if (sum%i == 0) {
			g.push_back(i);
			g.push_back(sum / i);
		}
	}
	sort(g.rbegin(), g.rend());
	for (auto c : g) {
		if (check(c))cout << c << endl, exit(0);
	}
	assert(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++) cin >> b[i];
    for(int i=0;i<n;i++) cin >> c[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());
    ll cnt[3][MAX_N]{};
    for(int i=0;i<n;i++){
        cnt[2][n-i-1] = i+1;
    }
    for(int i=n-1;i>=0;i--){
        cnt[1][i] = cnt[2][upper_bound(c.begin(), c.end(), b[i]) - c.begin()];
        cnt[1][i] += cnt[1][i+1];
    }
    for(int i=n-1;i>=0;i--){
        cnt[0][i] = cnt[1][upper_bound(b.begin(), b.end(), a[i]) - b.begin()];
        cnt[0][i] += cnt[0][i+1];
    }
    cout << cnt[0][0] << endl;
    return 0;
}


Measured memory_bytes: 3712
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define PI 3.14159265358979323

//int calc1(float a,float b,float c,float d,float e,float f,float *x,float *y);
//void quick(int *,long long,long long);
//int comp(char *a,char *b);

int main(){
	
	int a[101],max,n,i;
	max=0;
	for(i=1;i<=100;i++)
		a[i]=0;
	while(scanf("%d",&n)!=EOF){
		a[n]++;
		if(a[n]>max)
			max=a[n];
	}
	for(i=1;i<=100;i++)
		if(a[i]==max)
			printf("%d\n",i);
	return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
#define MAX 100000
#define MIN -1

struct Node{
  int parent, left, right;
};

struct Node T[MAX];
int D[MAX], H[MAX];

int Depth(int);
int Sibling(int);
void print(int);


int main(){
  int i,n, x,y,z,a,b;
  
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    T[i].parent=MIN;
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d%d%d",&x,&y,&z);
    T[x].left=y;
    T[x].right=z;
    if (y!=MIN) T[y].parent=x;
    if (z!=MIN) T[z].parent=x;
  }

  for ( i = 0; i < n; i++ ){
    D[i]=Depth(i);
    H[i]=0;
  }

  for ( i = 0; i < n; i++ ){
    if ( T[i].left==MIN&&T[i].right==MIN) { 
      H[i]=0;
       a = T[i].parent;
       b = 1;
      while(1){
	if (a==MIN) break;
	if ( H[a] < b ) H[a]=b;
	b++;
	a = T[a].parent;
      }
    }
  }

  for ( i = 0; i < n; i++ ){
    print(i);
  }
  return 0;
}

int Depth(int u){
  int d=0;
  while(T[u].parent!=MIN){
    u=T[u].parent;
    d++;
  }
  return d;
}

int Sibling(int u){
  if ( T[u].parent==MIN) return MIN;
  if ( T[T[u].parent].left!=u&&T[T[u].parent].left!=MIN) return T[T[u].parent].left;
  if ( T[T[u].parent].right!=u&&T[T[u].parent].right!=MIN) return T[T[u].parent].right;
  return MIN;
}

void print(int u){
  int count=0;
  printf("node %d: ", u);

  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", Sibling(u));
  if ( T[u].left!=MIN) {
    count++;
  }
  if ( T[u].right!=MIN){
    count++;
  }
  printf("degree = %d, ", count);
  printf("depth = %d, ", D[u]);
  printf("height = %d, ", H[u]);

  if ( T[u].parent==MIN){
    printf("root\n");
  } else if ( T[u].left==MIN&&T[u].right==MIN){
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}



Measured memory_bytes: 2140
answer = []


def point_check(num):
    for i in A_dic.keys():
        A_dic[i] -= num


N, K, Q = map(int, input().split())
A_dic = {i: K for i in range(1, N + 1)}

for j in range(Q):
    answer.append(int(input()))

point_check(Q)

for l in answer:
    A_dic[l] += 1

for k in A_dic.values():
    if k <= 0:
        print("No")
    else:
        print("Yes")


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

int N,M,f[1000005]={0,1},i,r;

int main()
{
	for(i=2;i<1000005;i++)
	{
		if((i%2==0&&f[i/2])||(i%3==0&&f[i/3])||(i%5==0&&f[i/5]))
			f[i]=1;
	}

	for(;scanf("%d%d",&M,&N),M;)
	{
		for(i=0;M<=N;M++)
			if(f[M])i++;
		printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 4504
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = (int)(n)-1; 0 <= i; i--)
#define rrep1(i, n) for (int i = (int)(n); 1 <= i; i--)

#define each(it, c) \
    for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define all(obj) (obj).begin(), (obj).end()

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x) cerr << #x << " = " << (x) << endl;

#define endl "\n"

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

typedef long long lint;

using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    lint ans = 0;
    cin >> n;
    map<lint, lint> m;
    rep(i, n) {
        int tmp;
        cin >> tmp;
        ans += tmp;
        m[tmp]++;
    }
    int q;
    cin >> q;
    rep(i, q) {
        lint b, c;
        cin >> b >> c;
        ans -= b * m[b];
        ans += c * m[b];
        m[c] += m[b];
        m[b] = 0;
        // for (const auto &e : m) {
        //     ans += e.first * e.second;
        // }
        cout << ans << endl;
    }
}

Measured memory_bytes: 9524
#include<stdio.h>
int partition(int*,int,int);
int A[100000];
int main(){
    int n,i,p,r,k;
    scanf("%d",&n);
    for(i=0;i<n;i++) scanf("%d",&A[i]);
    p=0;
    r=n-1;
    k=partition(A,p,r);
    for(i=0;i<n;i++){
        if(i==n-1) printf("%d",A[i]);
        else if(i==k) printf("[%d] ",A[i]);
        else printf("%d ",A[i]);
    }
    printf("\n");
    return 0;
}

int partition(int *A,int p,int r){
    int i=0,j=0,x,y;
    x=A[r];
    i=p-1;
    for(j=p;j<=r-1;j++){
        if(A[j]<=x){
            i=i+1;
            y=A[i];
            A[i]=A[j];
            A[j]=y;
        }
    }
    y=A[i+1];
    A[i+1]=A[r];
    A[r]=y;
    return i+1;
}


Measured memory_bytes: 2180
s = '0'
l = []
ans = 0
temp = -1
n = int(raw_input())
for i in range(0, n):
    s = raw_input()
    if (s != ''):
        l += [int(s)]
l.sort()
for i in range(0, len(l)):
    if(l[i] != temp):
        ans += 1
        temp = l[i]

print(ans)

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

ll r, g, b, ng;

int main() {
  int n;
  string s;
  cin >> n;
  cin >> s;


  for(int i=0; i<n; ++i)
		s[i]=='R'? r++: s[i]=='G'? g++: b++;

  ll ans = r*g*b;

  /*
  int cntR = 0, cntG = 0, cntB = 0;
  rep(i, n) {
    if (s[i] == 'R') cntR++;
    else if (s[i] == 'G') cntG++;
    else if (s[i] == 'B') cntB++;
  }

  ll ans = cntR * cntG * cntB;
  */

  rep(i, n) {
    repI(j, i+1, n) {
      int k = 2*j - i;
      if (k >= n) break;
      if (s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) ans--;
    }
  }

  /*
  for(int i=0; i<n-2; ++i){
		for(int d=1; d<=(n-1)/2; ++d){
			int j = i + d, k = j + d;
			if(k >= n) break;
			if(s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) ng++;
		}
	}
  */

  cout << ans - ng << endl;

  return 0;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<set>
#include<string>
using namespace std;
const int N=10+5,dx[]={0,0,1,-1},dy[]={1,-1,0,0},INF=0x3f3f3f3f;
int sz[88][20];
void jj(){
    sz[0][0]=1;
    sz[1][0]=1;
    sz[0][1]=2;
    sz[1][1]=1;
    int ans=2;
    while(ans<=86){
        int last=0;
        for(int i=1;i<=sz[ans-1][0];i++){
            sz[ans][i]=sz[ans-1][i]+sz[ans-2][i]+last;
            last=0;
            while(sz[ans][i]>=10){
                last++;
                sz[ans][i]-=10;
            }
        }
        sz[ans][0]=sz[ans-1][0];
        if(last) {sz[ans][++sz[ans][0]]=last;}
        ans++;
    }


}
int main()
{
    //freopen("out.txt","w",stdout);
    int n;
    jj();
    while(~scanf("%d",&n)){
        for(int i=sz[n][0];i>=1;i--)
            printf("%d",sz[n][i]);
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 256
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
#define int long long int
#define pb push_back
#define mp make_pair
#define loop(i,x,n) for(int i=x;i<=n;i++)
#define rloop(i,x,n) for(int i=x;i>=n;i--)
#define ff first
#define ss second
#define N4RUTO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
// typedef tree<int, null_type, less_equal<int>, rb_tree_tag,  
tree_order_statistics_node_update>
ordered_set;
 
int32_t main(){
    N4RUTO;
    int t;
    t=1;
    // cin>>t;
    while(t--){
        int n;
        cin>>n;
        int ans=0;
        loop(i,1,n){
            int x = (n/i);
            ans+=i*x*(x+1)/2;
        }
        cout<<ans<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3684
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

vec eratosthenes(ll N){
  ll i;
  vec ch(N+1,1),p;
  ch[0]=ch[1]=0;
  rep(i,N+1){
    if(ch[i]){
      p.pb(i);
      for(ll j=2;i*j<=N;j++){
        ch[i*j]=0;
      }
    }
  }
  return ch;
}

int main(){
  ll i,j,N,x,ans=inf,res;
  cin>>N>>x;
  vec v(N*2),ch(N,inf);
  rep(i,N){cin>>v[i];v[i+N]=v[i];}
  rep(i,N+1){
    rep(j,N)ch[j]=min(ch[j],v[i+j]);
    res=i*x;
    rep(j,N){
      res+=ch[j];
    }
    ans=min(res,ans);
  }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

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

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

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

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

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

#define MAXN 1005
#define MAXH 10005

int dp1[MAXN][MAXH];
int dp2[MAXN][MAXH];
int dp[MAXH];
//dp[i][j] := i番目の魔法まで使って体力をj減らしたときの魔力の最小

signed main(void) {
    int h,n;
    cin >> h >> n;
    vi a(n),b(n);
    rep(i,n)cin >> a[i] >> b[i];
    rep(j,MAXH)dp[j] = LINF;
    dp[0] = 0;
    rep(i,n)rep(j,h){
        dp[min(j+a[i],h)] = min(dp[min(j+a[i],h)], dp[j] + b[i]);
    }
    cout << dp[h] << endl;
    return 0;
    rep(i,MAXN)rep(j,MAXH){
        dp1[i][j] = LINF;
        dp2[i][j] = LINF;
    }
    dp1[0][0] = dp2[0][0] = 0;
    rep(i,n)rep(j,h+1){
        int x1 = a[i], x2 = a[n-i-1];
        int y1 = b[i], y2 = b[n-i-1];
        dp1[i+1][j] = min(dp1[i+1][j],dp1[i][j]);//何もしない
        dp2[i+1][j] = min(dp2[i+1][j],dp2[i][j]);//何もしない
        dp1[i+1][j+x1] = min(dp1[i+1][j+x1], dp1[i][j]+y1);
        dp2[i+1][j+x2] = min(dp2[i+1][j+x2], dp2[i][j]+y2);
    }
    int ind = 0;
    rep(i,n)if(a[i]*b[ind] > a[ind]*b[i]){
        if(b[i] < b[ind])ind = i;
    }
    cout << ind << endl;

    //[0,ind)と[ind+1,n)を使った後、モンスターが死ぬまでi番目の魔法を使い続ける
    //dp1[i][*]とdp2[n-i-1][*]
    int ans = LINF;
    rep(i,h+1)if(dp1[ind][i] < LINF)rep(j,h+1)if(dp2[n-ind-1][j] < LINF){
        int sum = dp1[ind][i] + dp2[n-ind-1][j];
        int left = h - i - j;
        //cout << i << " "<<j << " " <<sum << " " << left << endl;
        ans = min(ans, sum + (left + a[ind]-1)/a[ind] * b[ind]);
        //cout << ans << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
inputLine=input()
N = int(inputLine.split(" ")[0])
K = int(inputLine.split(" ")[1])

result = 0
for i in range(K,N+2):
    min_number = (i - 1) * i / 2
    max_number = (N + ( N - i + 1)) * i / 2

    result += max_number - min_number + 1

result = result % (10**9 + 7)
result = int(result)
print(result)










Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	while(true){
		cin>>n;
		if(n==0)	return 0;
		cin>>m;
		string s;	cin>>s;
		long long ans=0;
		for(int i=0;i<m;i++){
			if(s[i]=='I'){
				int cnt=0;
				while(i+2<m&&s[i+1]=='O'&&s[i+2]=='I')	i+=2,cnt++;
				ans+=max(0,cnt-n+1);
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 2104