akhauriyash/Code-Regression huggingface dataset:
import copy

n, m = map(int, input().split())
h = list(map(int, input().split()))
l = []
for i in range(m):
    a, b = map(int, input().split())
    l.append([a, b])

ll = [0]*n

for j in l:
    if h[j[0] - 1] > h[j[1] - 1]:
        ll[j[1] - 1] += 1
    elif h[j[0] - 1] == h[j[1] - 1]:
        ll[j[1] - 1] += 1
        ll[j[0] - 1] += 1
    else:
        ll[j[0] - 1] += 1

ans = 0

for k in ll:
    if k == 0:
        ans += 1
    else:
        ans += 0
    
print(ans)

Measured memory_bytes: 28996
#include<iostream>
#include"stdio.h"
using namespace std;

int main(){
	double a,b,c,d,e,f;
	double x,y;
	
	while(cin >> a >> b >> c >> d >> e >> f ){

		y = (f - d*c/a )/(e - b*d/a );
		x = (c - b*y)/a;

		//	cout << x << endl << y << endl;
		printf("%.3f ",x);
		printf("%.3f\n",y);
	}	
}

Measured memory_bytes: 0
h,w=map(int,input().split())
c=[list(map(int,input().split())) for i in range(h)]
ans=[]
for i in range(h):
  for j in range(w):
    if c[i][j]%2==1:
      if i<h-1:
        ans.append((i+1,j+1,i+2,j+1))
        c[i+1][j]+=1
      elif j<w-1:
        ans.append((i+1,j+1,i+1,j+2))
        c[i][j+1]+=1
print(len(ans))
for a in ans:
  print(' '.join(map(str,a)))

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

typedef long long ll;
const int MN = 1e5+5;
ll N, M, i, x, y, f, val[MN], c1, c2, ans, sz;
vector<ll> adj[MN];
void dfs(int n){
    for(auto v : adj[n]){
        if(val[v]==-1) val[v]=!val[n], dfs(v);
        else if(val[v]==val[n]) f=1;
    }
}
int main(){
    for(scanf("%lld%lld",&N,&M),i=1;i<=M;i++){
        scanf("%lld%lld",&x,&y);
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    memset(val,-1,sizeof(val));
    for(i=1;i<=N;i++){
        if(adj[i].size()) sz++;
        if(val[i]!=-1||adj[i].empty()) continue;
        f=0; val[i]=0; dfs(i);
        if(!f) ans+=2*(c1+2*c2)+2, c2++;
        else ans+=2*(c1+c2)+1, c1++;
    }
    ans += N*N-sz*sz;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 11392
#include<bits/stdc++.h>
#define int long long
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define re return 
#define MP make_pair
#define pb push_back
#define pii pair<int,int>
#define se second
#define fi first
using namespace std;

signed main(){
	ios_base::sync_with_stdio(0);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b<c+d) cout<<"Right";
	else if(a+b>c+d) cout<<"Left";
	else cout<<"Balanced";
	re 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define ts cout<<"ok"<<endl
#define int long long
#define hh puts("")
#define pc putchar
#define ite vector<int>::iterator
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
using namespace std;
int n,m,use,now;
char a[100005],b[100005];
vector<int> v[1005];
inline int read(){
    int ret=0,ff=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') ff=-ff;ch=getchar();}
    while(isdigit(ch)){ret=(ret<<3)+(ret<<1)+ch-'0';ch=getchar();}
    return ret*ff;
}
void write(int x){
    if(x<0){x=-x;putchar('-');}
    if(x>9) write(x/10);
    putchar(x%10+48);
}
signed main(){
	scanf("%s",a+1);
	scanf("%s",b+1);
	n=strlen(a+1);
	m=strlen(b+1);
	for(int i=1;i<=n;i++) v[a[i]-'a'].push_back(i);
	for(int i=1;i<=m;i++){
		if(!v[b[i]-'a'].size()){
			printf("-1");
			return 0;
		}
	}
	now=v[b[1]-'a'][0];
	for(int i=2;i<=m;i++){
		ite it=upper_bound(v[b[i]-'a'].begin(),v[b[i]-'a'].end(),now);
		if(it==v[b[i]-'a'].end()){
			use++;
			now=v[b[i]-'a'][0];
		}
		else now=*it;
	}
	printf("%lld",use*n+now);
    return 0;
}

Measured memory_bytes: 1656
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')


def solve(A: int, B: int):
    def lcm(x, y):
        return (x * y) // math.gcd(x, y)
    return lcm(A, B)


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    print(f'{solve(A, B)}')


if __name__ == '__main__':
    main()


Measured memory_bytes: 75340
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

S = input()

n = S.count("N")
w = S.count("W")
s = S.count("S")
e = S.count("E")

if n+s == 0 and 0 < w*e:
	print("Yes")
elif 0 < n*s and w+e == 0:
	print("Yes")
elif 0 < n*s and 0< w*e:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int N; cin >> N;
    vector<int> X(N); for (auto &x : X) cin >> x;
    int L; cin >> L;
    // dp[a][i] := a から 2^i 日で移動できる最大位置
    vector<vector<int>> dp(N, vector<int>(17));
    for (int a = 0; a < N; a++) {
        auto it = upper_bound(begin(X), end(X), X[a]+L) - 1;
        dp[a][0] = it - begin(X);
    }
    for (int i = 1; i <= 16; i++) {
        for (int a = 0; a < N; a++) {
            dp[a][i] = dp[dp[a][i-1]][i-1];
        }
    }
    int Q; cin >> Q;
    for (int i = 0; i < Q; i++) {
        int a, b; cin >> a >> b; a--, b--;
        if (a > b) swap(a, b);
        int ans = 0;
        for (int j = 16; j >= 0; j--) {
            if (dp[a][j] < b) {
                ans += 1 << j;
                a = dp[a][j];
            }
        }
        ans++;
        cout << ans << '\n';
    }
    return 0;
}

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

using namespace std;

#define forn(i, x, n) for (int i = int(x); i <= int(n); ++i)
#define for1(i, n, x) for (int i = int(n); i >= int(x); --i)
#define F first
#define S second
#define pb push_back

typedef long long ll;
typedef pair <int, ll> pii;
typedef long double ld;
typedef vector <ll> vi;

const int N = 2e3 + 1;
const int INF = 1e9 + 9;
const int B = 1e9 + 7;

int n, a[N], b[N];
vi sel;

bool ok(int k) {
    forn(it, 1, n) {
        vector <bool> u(a[it] + 1, 0);
        u[a[it]] = 1;
        for (auto i : sel)
            forn(j, 0, a[it])
                if (u[j]) u[j % i] = 1;
        for1(i, k, 1)
            forn(j, 0, a[it])
                if (u[j]) u[j % i] = 1;
        if (!u[b[it]]) return 0;
    }
    return 1;
}

int main() {
    #ifdef black
    freopen("in", "r", stdin);
    #endif // black
    ios_base :: sync_with_stdio(0);
    cin.tie(0);

    cin >> n;
    forn(i, 1, n)
        cin >> a[i];
    forn(i, 1, n)
        cin >> b[i];

    if (!ok(50)) {
        cout << "-1\n";
        return 0;
    }
    ll ans = 0;
    for1(i, 50, 1) {
        if (!ok(i - 1)) {
            sel.pb(i);
            ans += (1ll << i);
        }
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define ll long long

using namespace std;
int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
    ll n; cin>>n;
    // vector<ll> a(n);
   if(n>=30)  cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3636
// C - Half and Half
#include <bits/stdc++.h>
using namespace std;

int main(){
	int A,B,C,X,Y; cin>>A>>B>>C>>X>>Y;
	int ans;
	if(A+B > C*2){
		int min_n = min(X, Y);
		ans = C*2 * min_n;
		int rest_n = abs(X - Y);
		if(X > Y){//rest X -> A
			if(A > C*2) ans += C*2 * rest_n;
			else ans += A * rest_n;
		}
		else if(X < Y){//rest Y -> B
			if(B > C*2) ans += C*2 * rest_n;
			else ans += B * rest_n;
		}
	}
	else ans = A*X + B*Y;
	cout<< ans <<endl;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
const ll mod = 1e9+7;
const ll inf = 1e17;
const int INF = 1e9;
const double PI = acos(-1);
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  int n;
  cin >> n;
  vi a(n), b(n), c(n-1);
  re(i, n) cin >> a[i];
  re(i, n) cin >> b[i];
  re(i, n-1) cin >> c[i];

  int sum = 0;
  sum += b[a[0]-1];
  fo(i, 1, n) {
    sum += b[a[i]-1];
    if(a[i] - a[i-1] == 1) sum += c[a[i-1]-1];
  }
  cout << sum << endl;

  return 0;
}


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

namespace ConsoleApp28 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            int X = st[0];
            int a = st[1];
            int b = st[2];

            int dist_a = Math.Abs(X - a);
            int dist_b = Math.Abs(X - b);

            if (dist_a > dist_b) {
                Console.WriteLine("B");
            } else {
                Console.WriteLine("A");
            }

        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using 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 RREP(i,m,n) for(int i=(int)(m);i>=(int)(n);--i)
#define debug(x) cout << #x << "=" << (x) << endl;

template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> void fail(T v){cout << v << endl;exit(0);}
//template end

void solve(){
  int a,b,c;
  cin>>a>>b>>c;
  int l=0,r=a;
  while(true){
    int v=l/60*60;
    if(v+c>(a+b)*60){cout << -1 << endl;return;}
    if(l<=v+c&&v+c<=r)
    {cout << v+c << endl;return;}
    l=r+b;
    r=l+a;
  }
}

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



Measured memory_bytes: 3208
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int DP[(1 << 16)];

int main(){
    while(true){
        int N, M;
        cin >> N >> M;
        if(N == 0){
            break;
        }
        long long int s[20], d[110];
        long long int S = 0, off = 0;
        for(int i = 0; i < N; i++){
            cin >> s[i];
            S += s[i];
        }
        for(int i = 0; i < M; i++){
            cin >> d[i];
            if(S < d[i]){
                off += d[i] - S;
            }
        }
        for(int i = 0; i < (1 << N); i++){
            DP[i] = INF;
        }
        DP[0] = 0;
        for(int i = 0; i < (1 << N); i++){
            long long int S2 = 0;
            for(int j = 0; j < N; j++){
                if(i & (1 << j)){
                    S2 += s[j];
                }
            }
            for(int j = 0; j < N; j++){
                if(i & (1 << j)){
                    long long int num = DP[i - (1 << j)];
                    long long int S1 = S2 - s[j];
                    for(int k = 0; k < M; k++){
                        if(S1 < d[k] && d[k] < S2){
                            num += min(S2 - d[k], d[k] - S1);
                        }
                    }
                    DP[i] = min(DP[i], num);
                }
            }
        }
        cout << DP[(1 << N) - 1] + off << endl;
    }
    return 0;
}


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

int main(void)
{
	char s[100000];
	int i,cnt[2]={0},n;
	scanf("%s",s);
	n=strlen(s);
	for(i=0;i<n;i++){
		cnt[s[i] - '0']++;
	}
	printf("%d\n",(int)fmin(cnt[0],cnt[1])*2);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include<stdio.h>
#include <functional>
#include<algorithm>
#define PI 3.14159265
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define SZ(x) ((int)(x).size())

using namespace std;



int main() {
	int h, w;
	cin >> h >> w;
	int hw[100][100];
	string s;
	REP(i, h) {
		cin >> s;
		REP(j, w) {
			
			if (s[j] == '.') {
				hw[i][j] = 0;
			}
			else {
				hw[i][j] = 1;
			}
		}
	}
	//while (1) {
		REP(i, h) {
			REP(j, w) {
				if (hw[i][j] == 1) break;
				if (j == w - 1) {
					REP(k, w) {
						hw[i][k] = -1;
					}
				}
			}

		}
		REP(i, w) {
			REP(j, h) {
				if (hw[j][i] == 1) break;
				if (j == h - 1) {
					REP(k, h) {
						hw[k][i] = -1;
					}
				}
			}

		}
	//}
		int flag;
	REP(i, h) {
		flag = 0;
		REP(j, w) {
			
				if (hw[i][j]==1) {
					cout << "#";
					flag = 1;
				}
				else if (hw[i][j] == 0) {
					cout << ".";
					flag = 1;
				}
				
			
		}
		if (flag == 1) {
			cout << endl;
		}
		
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main()
{
    int r, d, x;
    cin >> r >> d >> x;
    int ans = x;
    for (int i = 0; i < 10; i++) {
        ans = r * ans - d;
        cout << ans << endl;
    }
    return 0;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  int n, m;
  cin >> n >> m;

  vector<vector<int>> g(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  vector<int> ans(n, -1);
  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    auto idx = q.front();
    q.pop();

    for (int i = 0; i < g[idx].size(); ++i) {
      if (ans[g[idx][i]] != -1 || g[idx][i] == 0) {
        continue;
      }

      ans[g[idx][i]] = idx;
      q.push(g[idx][i]);
    }
  }

  cout << "Yes" << '\n';
  for (int i = 1; i < n; ++i) {
    cout << ans[i] + 1 << '\n';
  }

  return 0;
}

Measured memory_bytes: 10100
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long

signed main() {
    string s;
    int k;
    cin >> s>> k;
    int n = s.length();
    int ans =0;
    if(n==1) {
        cout << k/2 << endl;
        return 0;
    }
    FOR(i,1,s.length()) {
        if(s[i]==s[i-1]) {
                ans++;
        }
    }
    if(ans==n-1) {
        cout << n*k/2 << endl;
    }
    else if(s[0]!=s[n-1]) {
        ans =0;
        FOR(i,1,s.length()) {
            if(s[i]==s[i-1]) {
                ans++;
                s[i]='.';
            }
        }
        //cout << ans << endl;
        cout << ans*k<< endl;
    }else {
        char ss = s[0];
        char ee = s[n-1];
        int sc = 0;
        int ec = 0;
        rep(i,n) {
            if(ee==s[i])sc++;
            else break;
        }
        rrep(i,n) {
            if(ss==s[i])ec++;
            else break;
        }
        ans =0;
        FOR(i,1,s.length()) {
            if(s[i]==s[i-1]) {
                ans++;
                i++;
            }
        }
        cout << ans*k-(sc/2+ec/2-(sc+ec)/2)*(k-1) << endl;
    }
    return 0;
}



Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
int main(){
	int n,m;
	cin>>n>>m;
	vvi in(10);
	while(n--){
		int a,b;
		cin>>a>>b;
		b--;
		in[b].pb(-a);
	}
	rep(i,10)sort(all(in[i]));
	vi dp(m+1);
	rep(i,10)for(int j=m;j>=0;j--){
		int sum=0;
		rep(k,in[i].size()){
			sum-=in[i][k];
			int J=j+1+k;
			if(J>m)continue;
			dp[J]=max(dp[J],dp[j]+sum+(k+1)*k);
		}
	}
	cout<<dp[m]<<endl;
}

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

#define MAXN 100010
#define ll long long
#define mod 1000000007

using namespace std;

int n;
ll ans = MAXN * 100;
int a[MAXN];

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	
	for (int i = 1; i <= 100; i++) {
		ll sum = 0;
		for (int j = 1; j <= n; j++) {
			sum += pow(a[j] - i, 2);
		}
		ans = min(ans, sum);
	}
	cout << ans << endl;
	return 0;
} 

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

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll x=c-a,y=d-b;
    cout<<c-y<<" "<<d+x<<" "<<a-y<<" "<<b+x<<endl;
    return 0;
}

Measured memory_bytes: 3552
#include <stdio.h>
#define int64 long long int
int64 F[100005];
const int md = 1000000007;
int n, m;

int abs (int x) { return x < 0 ? -x : x; }

int main ()
{
	F[0] = 1;
	for (int i = 1; i < 100005; i++) F[i] = F[i - 1] * i, F[i] %= md;
	scanf ("%d %d", &n, &m);
	if (abs (n - m) >= 2) {
		puts ("0");
		return 0;
	}
	int64 ans = 1;
	ans = (ans * 1ll * F[n]) % md;
	ans = (ans * 1ll * F[m]) % md;
	if (n == m) ans *= 2;
	printf ("%lld\n", ans % md);
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
using ll = long long;
constexpr long long INF = 1LL << 62;

int grid[3][30];
int color[30][30];

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n, c; cin >> n >> c;
    REP(i,c) REP(j,c) cin >> color[i][j];
    REP(i,n) REP(j,n) {
        int t;
        cin >> t;
        ++grid[(i+j)%3][t-1];
    }

    ll ans = INF;

    REP(i,c) REP(j,c) {
        if(i==j) continue;
        REP(k,c) {
            if(i==k || j==k) continue;
            ll tmp = 0;
            // (n+m)%3==0 : x->i
            // (n+m)%3==1 : x->j
            // (n+m)%3==2 : x->k
            REP(x,c) tmp += grid[0][x] * color[x][i];
            REP(x,c) tmp += grid[1][x] * color[x][j];
            REP(x,c) tmp += grid[2][x] * color[x][k];
            if(ans > tmp) ans = tmp;
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
import * as fs from 'fs';

namespace AtCoder {
    export interface Paramable {
        readonly args: string[][];
    }

    export interface Task {
        main(this: Task): void;
    }
}

namespace AtCoder.abc078 {
    export class TaskA implements AtCoder.Task, AtCoder.Paramable {

        public constructor(public readonly args: string[][]) {

        }

        public main(this: TaskA): void {
            const [x, y]: string[] = this.args[0];

            if (x>y) {
                console.log('>');
            } else if (x<y) {
                console.log('<');
            } else {
                console.log('=');
            }

        }
    }

    const args: string[][] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n').map(x => x.split(' '));
    const task: AtCoder.Task = new TaskA(args);
    task.main();
}

Measured memory_bytes: 7372
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    ll n;
    cin >> n;
    ll a[n];
    rep(i, n)cin >> a[i];
    if(a[0] != 0){
        cout << -1 << endl; 
        return 0;
    }
    ll  ans = 0;
    for(ll i = n-1; i > 0; --i){
        if(a[i]-a[i-1]>1){
            cout << -1;
            return 0;
        }
        if(i!=n-1&&a[i]<a[i+1])continue;
        ans+=a[i];
        // cout << ans << "&" << a[i] <<  endl;
    }
    cout << ans << endl;
}

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

int n;
string A[100000];
string B[100000];

string iso="Isono-kun";
string naka="Nakajima-kun";
string hiki="Hikiwake-kun";

string solve(){
  int ca=0,cb=0;
  for(int i=0;i<n;i++){

    if(ca>5)ca=5;
    if(cb>5)cb=5;

    if(A[i]=="tameru"&&B[i]=="tameru"){
      ca++;
      cb++;
    }
    if(A[i]=="tameru"&&B[i]=="kougekida"){
      ca++;
      if(cb==0)return iso;
      else return naka;
    }
    if(A[i]=="tameru"&&B[i]=="mamoru"){
      ca++;
    }

    if(A[i]=="kougekida"&&B[i]=="tameru"){
      cb++;
      if(ca==0)return naka;
      else return iso;
      ca=0;
    }
    if(A[i]=="kougekida"&&B[i]=="kougekida"){
      if(ca>cb)return iso;
      if(ca<cb)return naka;
      ca=cb=0;
    }
    if(A[i]=="kougekida"&&B[i]=="mamoru"){
      if(ca==0)return naka;
      if(ca==5)return iso;
      ca=0;
    }


    if(A[i]=="mamoru"&&B[i]=="tameru"){
      cb++;
    }

    if(A[i]=="mamoru"&&B[i]=="kougekida"){
      if(cb==0)return iso;
      if(cb==5)return naka;
      cb=0;
    }

    if(A[i]=="mamoru"&&B[i]=="mamoru"){
      
    }
  }
  return hiki;
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  for(int i=0;i<n;i++){
    cin>>B[i];
  }
  cout<<solve()<<endl;
  return 0;
}

Measured memory_bytes: 2784
n=input()
l=len(n)-1
s=[n[0]]
for i in range(2**l):
    x=['-']*l
    for j in range(l):
          if ((i >> j) & 1):
              x[l - 1 - j]='+'
    for i in range(l):
        s.append(x[i])
        s.append(n[i+1])
    if eval(''.join(s))==7:
        s+='=7'
        print(''.join(s))
        exit()
    s=[n[0]]

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

using namespace std;

int main(void) {
  int N; cin >> N;
  map<int, int> A;
  int MX = 0;

  for (int i = 0; i < N; i++) {
    int a; cin >> a;
    auto t = A.try_emplace(a, 1);
    if (!t.second) {
      t.first->second++;
    }
    MX = max(a, MX);
  }

  //sort(A.begin(), A.end());
  
  bool B[MX+1];
  memset(B, false, sizeof(B));

  int ans = 0;
  for (auto it = A.begin(); it != A.end(); ++it) {
    if (!B[it->first]) {
      if (it->second == 1) {
        ans++;
      }
      for (int i = 1; i*it->first <= MX; i++) {
        B[i*it->first] = true;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

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

int main(){
    string s,t;
    cin>>s>>t;
    int p=0,len=s.length();
    rep(i,len){
        if(s[i]!=t[i]){
            p++;
        }
    }
    cout<<p<<endl;
    return 0;
}

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

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

    string s;
    cin >> s;
    REP(i, s.size()){
        if(i == 4) cout << " " << s[i];
        else cout << s[i];
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}


//#########################################



int main() {

    long long n=LLD(),h=LLD();
    long long a[n];
    long long b[n];
    long long mx=-1;
    long long cnt=0;
    for(int i=0;i<n;i++){

        scanf("%lld%lld",&a[i],&b[i]);
        if(a[i]>mx)
            mx=a[i];
    }
    sort(b,b+n);
    for(int i=n-1;i>=0;i--) {

        if(b[i]>mx) {
            h -= b[i];
            cnt++;
        }
        if(h<=0){
            cout<<cnt;
            return  0;

        }



    }
    if(h%mx==0){
        cnt+=h/mx;

    } else {
        cnt += h / mx;
        cnt++;
    }

    cout<<cnt;

}


Measured memory_bytes: 1792
package main
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

var sc = bufio.NewScanner(os.Stdin)
const MAX_A = 20;
const MAX_B = 50;
const MAX_C = 50;

func nextInt() int {
    sc.Scan()
    i, err := strconv.Atoi(sc.Text())
    if err != nil {
        panic(err)
    }
    return i
}

func main(){
    sc.Split(bufio.ScanWords)
    n := nextInt()
    var a [MAX_A]int
    var b [MAX_B]int
    var c [MAX_C]int
    for i := 0; i < n; i++ {
        a[i] = nextInt() -1
    }
    for i := 0; i < n; i++ {
        b[i] = nextInt()
    }
    for i := 0; i < n-1; i++ {
        c[i] = nextInt()
    }

    sum := 0
    for i := 0; i < n-1; i++ {
        sum += b[a[i]]
        if a[i+1] == a[i]+1 {
            sum += c[a[i]]
        }
    }
    sum += b[a[n-1]]
    fmt.Println(sum)
}


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

using namespace std;
using ll = long long;


int main()
{
	ll n; cin >> n;
	ll sum = 0;

	ll i = 1;
	for(; i * i < n; i++) {
		if(n / i == n % i)sum += i;
	}

	for(; i >= 1; i--) {
		ll tmp = (n - i);
		if(tmp == 0)continue;
		ll m = tmp / i;
		if(tmp % i)continue;
		if(n / m == n % m)sum += m;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.concurrent.atomic.AtomicInteger;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    long n = Long.parseLong(sc.next());
    if (n == 1) {
      pw.println(0);
      return;
    }
    SortedMap<Long, AtomicInteger> soinus = primeFactorization(n);
    SortedMap<Integer, AtomicInteger> eCountMap = new TreeMap<>();
    for (AtomicInteger v : soinus.values()) {
      eCountMap
        .computeIfAbsent(v.intValue(), k -> new AtomicInteger(0))
        .incrementAndGet();
    }
    long ans = 0;
    int totalE = 0;
    for (int i = 1; totalE <= eCountMap.lastKey(); i++) {
      totalE += i;
      long nextTotalE = totalE + i + 1;
      for (int j = totalE; j < nextTotalE; j++) {
        if (eCountMap.containsKey(j)) {
          ans += eCountMap.get(j).intValue() * i;
        }
      }
    }
    pw.println(ans);
  }

  static SortedMap<Long, AtomicInteger> primeFactorization(long n) {
    if (n == 1) {
      return new TreeMap<>();
    }
    SortedMap<Long, AtomicInteger> ans = new TreeMap<>();
    while (n % 2 == 0) {
      ans.computeIfAbsent(
        2l,
        k -> new AtomicInteger(0)
      ).incrementAndGet();
      n /= 2;
    }
    for (long i = 3; i * i < n; i = i + 2) {
      while (n % i == 0) {
        ans.computeIfAbsent(
          i,
          k -> new AtomicInteger(0)
        ).incrementAndGet();
        n /= i;
      }
    }
    if (n != 1) {
      ans.put(n, new AtomicInteger(1));
    }
    return ans;
  }
}


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

namespace C_test_For_Atcorder
{

    public static class Extensions
    {
        public static string Reverse(this string sourse){
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }


        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var Ai = new long[N + 2];
            Ai[0] = 0;
            for (int i = 1; i < N + 1;i++){
                Ai[i] = cin.ReadLong;
            }
            Ai[N + 1] = 0;
            long AllCost = 0;
            var costlist = new long[N+1];

            for (int i = 0; i < N+1;i++){
                costlist[i] = Abs(Abs(Ai[i + 1] - Ai[i]));
                AllCost += costlist[i];
            }

            for (int i = 1; i <= N;i++){
                if (Ai[i-1] < Ai[i] && Ai[i] < Ai[i+1])
				{
					Console.WriteLine(AllCost);
				}
				else if (Ai[i - 1] > Ai[i] && Ai[i] > Ai[i + 1])
				{
					Console.WriteLine(AllCost);
				}
				else
				{
                    Console.WriteLine(AllCost-costlist[i-1]-costlist[i]+Abs(costlist[i-1]-costlist[i]));
                    //Console.WriteLine(AllCost-Abs(Ai[i]));
				}   
            }
            return;

            //Console.WriteLine(AllCost);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue inputStream;

        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return (string)inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return (string)inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }

}


Measured memory_bytes: 28132
import sys, collections
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    while True:
        w, h = LI()
        if w==0 and h==0:
            break
        else:
            # 縦と横の壁を別の配列に入れる
            wall_h = []
            wall_v = []
            for i in range(h-1):
                wall_v.append(LI())
                wall_h.append(LI())
            wall_v.append(LI())
            # print('wall_v')
            # for i in wall_v:
            #     print(i)
            # print('wall_h')
            # for i in wall_h:
            #     print(i)

            que = collections.deque()
            que.append((0, 0))
            dist = [[INF]*w for _ in range(h)]
            dist[0][0] = 1
            while que:
                cy, cx = que.popleft()
                # 右
                ny = cy
                nx = cx+1
                if 0<=ny<h and 0<=nx<w and wall_v[cy][cx]==0 and dist[ny][nx]>=INF:
                    que.append((ny, nx))
                    dist[ny][nx] = dist[cy][cx]+1
                # 下
                ny = cy+1
                nx = cx
                if 0<=ny<h and 0<=nx<w and wall_h[cy][cx]==0 and dist[ny][nx]>=INF:
                    que.append((ny, nx))
                    dist[ny][nx] = dist[cy][cx]+1
                # 左
                ny = cy
                nx = cx-1
                if 0<=ny<h and 0<=nx<w and wall_v[cy][cx-1]==0 and dist[ny][nx]>=INF:
                    que.append((ny, nx))
                    dist[ny][nx] = dist[cy][cx]+1
                # 上
                ny = cy-1
                nx = cx
                if 0<=ny<h and 0<=nx<w and wall_h[cy-1][cx]==0 and dist[ny][nx]>=INF:
                    que.append((ny, nx))
                    dist[ny][nx] = dist[cy][cx]+1

        # print(w, h, 'dist')
        # for i in dist:
        #     print(i)
        if dist[-1][-1]<INF:
            print(dist[-1][-1])
        else:
            print(0)
        


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 6024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N, K;
vector<ll> A, B;
map<ll, int> C;

const int M = 200010;
int bit[M+1];
ll count_le(ll n) {
	ll r = 0;
	for (int x = C[n]; x > 0; x -= x & -x) r += bit[x];
	return r;
}
void add(ll n) {
	for (int x = C[n]; x <= M; x += x & -x) bit[x] += 1;
}
int main() {
	cin >> N >> K;
	A.resize(N);
	for (auto& x : A) cin >> x;
	B.resize(N+1);
	for (int i = 0; i < N; ++ i) {
		B[i+1] = B[i] + A[i] - K;
	}

	set<ll> b;
	for (auto x : B) b.insert(x);
	int idx = 1;
	for (auto x : b) C[x] = idx++;

	ll r = 0;
	for (int i = 0; i <= N; ++ i) {
		r += count_le(B[i]);
		add(B[i]);
	}
	cout << r << endl;
}


Measured memory_bytes: 25984
import math
n,k = map(int,input().split())
als = list(map(int,input().split()))
als.sort()
# n = 10**5
# k = 5*(10**4) 
mod = 10**9+7
ans = 0
# def nCr(n,r):
#     mod = (10**9)+7
#     fac = [1,1]+[0]*n
#     finv = [1,1]+[0]*n
#     inv = [1,1]+[0]*n
#     for i in range(2,n+1):
#         fac[i] = fac[i-1] * i % mod
#         inv[i] = mod - inv[mod%i] * (mod//i) % mod
#         finv[i] = finv[i-1] * inv[i] % mod
#     ans = fac[n] * (finv[r] * finv[n-r] % mod) % mod
    
#     return ans

fac = [1,1]+[0]*n
finv = [1,1]+[0]*n
inv = [1,1]+[0]*n
for i in range(2,n+1):
    fac[i] = fac[i-1] * i % mod
    inv[i] = mod - inv[mod%i] * (mod//i) % mod
    finv[i] = finv[i-1] * inv[i] % mod

for i in range(n):
    if i >= k-1:
        ans += als[i] * fac[i] * (finv[(k-1)] * finv[i-(k-1)] % mod) % mod
        ans = ans % mod
    if i <= n-k:
        ans -= als[i] * fac[(n-i-1)] * (finv[(k-1)] * finv[(n-i-1)-(k-1)] % mod) % mod
        ans = ans % mod

print(ans)
        

Measured memory_bytes: 19784
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//String tmp = sc.next();
		//int tmp = sc.nextInt();
		//Long tmp = sc.nextLong();
      int A = sc.nextInt();
      int B = sc.nextInt();
      int C = sc.nextInt();
      if(A == Math.min(A,Math.min(B,C))){
        System.out.println((B > C) ? "Yes" : "No");
      }else if(B == Math.min(A,Math.min(B,C))){
        System.out.println((A > C) ? "Yes" : "No");
      }else{
        System.out.println("No");
      }
	}
}


Measured memory_bytes: 21588
#include<iostream>
using namespace std;
long mod=998244353,dp[301][90001],dp2[301][90001];
long ans=1;
int N,a[300],SUM;
main()
{
	cin>>N;
	dp[0][0]=dp2[0][0]=1;
	for(int i=0;i<N;i++)
	{
		cin>>a[i];
		SUM+=a[i];
		for(int k=0;k<=SUM-a[i];k++)
		{
			(dp[i+1][k+a[i]]+=dp[i][k])%=mod,(dp[i+1][k]+=dp[i][k]*2)%=mod;
			(dp2[i+1][k+a[i]]+=dp2[i][k])%=mod,(dp2[i+1][k]+=dp2[i][k])%=mod;
		}
		ans=ans*3%mod;
	}
	for(int i=(SUM+1)/2;i<=SUM;i++)
	{
		ans=(ans-dp[N][i]*3%mod+mod)%mod;
	}
	if(SUM%2==0)
	{
		ans=(ans+dp2[N][SUM/2]*3%mod)%mod;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 419968
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;

int main() {
    ll a,b,c,d; cin >> a >> b >> c >> d;
    if (a<0 && b<0){
        if (c<0 && d<0) cout << a*c << "\n";
        else if(0>c && 0<=d) cout << a*c << "\n";
        else cout << b*c << "\n";
    }
    if (a<0 && b>=0){
        if (c<0 && d<0) cout << a*c << "\n";
        else if(0>c && 0<=d) cout << max(a*c,b*d) << "\n";
        else cout << b*d << "\n";
    }
    if (a>=0 && b>=0){
        if (c<0 && d<0) cout << a*d << "\n";
        else if(0>c && 0<=d) cout << b*d << "\n";
        else cout << b*d << "\n";
    }
}















Measured memory_bytes: 3564
import sys 
import collections

N, K = map(int, input().split())
A = list(map(int, input().split()))

if len(set(A)) <= K :
    print(0)
    sys.exit()

A_Counter = collections.Counter(A)
A_Counterlist = sorted(list(A_Counter.values()))

#set(A)の個数に一致するまでcountを足していく。
count_num = 0
count_set = len(set(A))

for i in range(len(A_Counterlist)):
    count_set = count_set - 1
    count_num = count_num + A_Counterlist[i]

    if count_set == K:
        print(count_num)
        sys.exit()

Measured memory_bytes: 47796
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

#define llint long long int

#define mod 2019

int main(void){

  llint l, r;
  std::cin >> l >> r;

  llint diff = (l/mod)*mod;
  l -= diff;
  r -= diff;

  if(r-l >= mod+1){
    std::cout << 0 << std::endl;
    return 0;
  }

  int min_mod = mod; // max number
  for(int i=l; i<=r; i++){
    for(int j=i+1; j<=r; j++){
      min_mod = (i*j)%mod < min_mod ? (i*j)%mod : min_mod;

    }
  }
  std::cout << min_mod << std::endl;

  return 0;
}


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

using namespace std;

namespace {

    typedef double real;
    typedef long long ll;

    template<class T> ostream& operator<<(ostream& os, const vector<T>& vs) {
        if (vs.empty()) return os << "[]";
        auto i = vs.begin();
        os << "[" << *i;
        for (++i; i != vs.end(); ++i) os << " " << *i;
        return os << "]";
    }
    template<class T> istream& operator>>(istream& is, vector<T>& vs) {
        for (auto it = vs.begin(); it != vs.end(); it++) is >> *it;
        return is;
    }

    const real EPS = 1e-5;
    bool EQ(real a, real b) { return abs(a - b) < EPS; }
    struct Matrix : public vector< vector<real> > {
        int H, W;
        Matrix(int H, int W) : H(H), W(W) {
            clear(); resize(H, vector<real>(W, 0));
        }
    };
    void eliminate(Matrix& M) {
        // ???????¶????
        int H = M.H, W = M.W;
        for (int i = 0; i < H; i++) {
            int p = i;
            for (int j = i; j < H; j++) {
                if (M[j][i] > M[p][i]) {
                    p = j;
                }
            }
            if (EQ(M[p][i], 0)) continue;
            swap(M[i], M[p]);
            real x = M[i][i];
            for (int j = i; j < W; j++) M[i][j] /= x;
            for (int k = i + 1; k < H; k++) {
                real y = M[k][i];
                for (int l = i; l < W; l++) {
                    M[k][l] -= y * M[i][l];
                }
            }
        }
        // ????????£??\
        for (int i = H - 1; i >= 0; i--) {
            for (int j = i - 1; j >= 0; j--) {
                real x = M[j][i];
                for (int k = i; k < W; k++) {
                    M[j][k] -= x * M[i][k];
                }
            }
        }
    }

    int D;
    vector<real> V;
    bool input() {
        cin >> D;
        if (D == 0) return false;
        V.resize(D + 3);
        cin >> V;
        return true;
    }

    void solve() {
        for (int d = 0; d < D + 3; d++) {
            // assume f(d) is the outlier;
            Matrix M(D + 2, D + 2);
            for (int i = 0, p = 0; i < D + 3; i++) {
                if (i == d) continue;
                for (int j = 0; j < D + 1; j++) {
                    M[p][j] = pow(i, j);
                }
                M[p][D + 1] = V[i];
                p++;
            }
            eliminate(M);
            if (EQ(M[D + 1][D + 1], 0)) {
                cout << d << endl;
                return;
            }
        }
        assert(false);
    }
}

int main() {
    while (input()) solve();
    return 0;
}

Measured memory_bytes: 3280
import numpy as np

a = int(input())
h = list(map(int,input().split()))
count = int(0)
max_count = int(0)

for index in range(1,len(h)):
  if h[index-1]>=h[index]:
    count += 1
    if max_count<count:
      max_count = count
  else:
    count = 0

print(max_count)

Measured memory_bytes: 23384
#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 ff                  first
#define ss                  second
#define endl                "\n"
#define loop(i,s,e)         for(int i=s;i<e;i++)
#define int                 long long
#define vi                  vector<int> 
#define S(v)                sort(v.begin(),v.end())
#define RS(v)               sort(v.rbegin(),v.rend())
#define R(v)                reverse(v.begin(),v.end())
#define mxpq(T)             priority_queue <T>
#define mnpq(T)             priority_queue<T,vector<T>,greater<T>>
#define prv(v)              for(auto &x : v)cout << x << " ";
#define piirv(v)            for(auto &x : v)cout << x.ff << " " << x.ss << endl;
#define prvv(v)             for(auto &x : v)for(auto &y : x.ss)cout << y << " ";
#define mp                  make_pair
#define pii                 pair<int,int>
#define mset(a,f)           memset(a , f , sizeof(a))
#define pb                  push_back
#define inf                 INT_MAX
#define INF                 LLONG_MAX
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;
 
const int N = 2e6 + 6;
const int M = 1e9+7;
int A[N];
int n , m;

void solve()
{
	 int n;
	 cin >> n;

	 int sum = 0;

	 map<int,int> m;

	 loop(i,0,n)
	 {
	 	cin >> A[i];
	 	sum += A[i];
	 	m[A[i]]++;
	 }

	 int q;
	 cin >> q;

	 loop(i,0,q)
	 {
	 	int a , b;
	 	cin >> a >> b;
	 	int x = m[a];
	 	m.erase(a);
	 	m[b] += x;
	 	sum -= a*x , sum += b*x;
	 	cout << sum << endl;
	 }
}			
 
int32_t main()
{
 
cout<<fixed<<setprecision(16);
 
ios_base:: sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
 	
 
 	int t = 1;
 	// cin >> t;
 	while(t--)solve();
  
}

Measured memory_bytes: 8348
#include <iostream>
#include <algorithm>

using namespace std;


int main() {
    long long int i,j,k,N,M,K,Q,d;
  //  long long int A[100][100];
    long long S[101];
    long long sol,A;

    sol = 0;

   cin >> N >> K;
   for (i=1;i<=N;i++)
      S[i]=0;
   for (i=0;i<K;i++) {
     cin >> d;
     for (j=0;j<d;j++) {
       cin >> A;
       S[A]++;
     }
   }
   for (i=1;i<=N;i++)
    if (S[i]==0)
      sol++;


    cout << sol << endl;


  return 0;
}


Measured memory_bytes: 3636
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import numpy as np

A1 = LIST()
A2 = LIST()
A3 = LIST()
N = INT()
B = np.ones(N)
for i in range(N):
  B[i] = INT()
  
B = list(B)

def bingo_array(A, B):
  for i in range(3):
    for x in B:
      if A[i] == x:
        A[i] *= 0
       
bingo_array(A1, B)
bingo_array(A2, B)
bingo_array(A3, B)

if sum(A1) == 0 or sum(A2) == 0 or sum(A3) == 0:
  print("Yes")
elif A1[0]+A2[0]+A3[0] == 0 or A1[1]+A2[1]+A3[1] == 0 or A1[2]+A2[2]+A3[2] == 0:
  print("Yes")
elif A1[0]+A2[1]+A3[2] == 0 or A1[2]+A2[1]+A3[0] == 0:
  print("Yes")
else:
  print("No")

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

typedef long long ll;

int main (void) {
  int K; std::cin >> K;
  std::cout << (K / 2) * (K-K/2) << std::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);
		String s = sc.nextLine();
		int hoge = 0;
		for(int i = 0; i < s.length();++i) {
			hoge += s.charAt(i) - 48;
		}
		System.out.println(Integer.valueOf(s) % hoge == 0 ? "Yes" : "No");
	}
}


Measured memory_bytes: 22868
import itertools
l = []
p_num = 0
q_num = 0
n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))
for i in range(1,n+1):
    l.append(i)
cnt = 0
for i in itertools.permutations(l,n):
    cnt += 1
    if i == p:
        p_num = cnt
    if i == q:
        q_num = cnt
        
print(abs(p_num - q_num))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = ll(1e9 + 7);
ll dp[70][2][2];
int a[70];

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

	ll N;
	cin >> N;

	for(int i = 0; i < 64; i++) {
		a[i] = N >> i & 1;
	}

	ll ans = 0;
	dp[0][0][0] = 1;
	for(int i = 0; i < 64; i++) {
		for(int j = 0; j < 2; j++) {
			for(int k = 0; k < 2; k++) {
				if(dp[i][j][k] == 0) continue;
				int u[4] = { 0, 1, 0, 1 }, v[4] = { 0, 0, 1, 1 };
				for(int l = 0; l < 4; l++) {
					if(u[l] == 0 && v[l] == 1) continue;
					int sum = j + u[l] + v[l];
					int nk = (sum % 2) > a[i] || k && (sum % 2) >= a[i];
					int nj = sum / 2;
					dp[i + 1][nj][nk] += dp[i][j][k];
					dp[i + 1][nj][nk] %= MOD;
				}
			}
		}
	}

	cout << dp[64][0][0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define max_v(v) *max_element(all(v));
#define min_v(v) *min_element(all(v));
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl
template <typename T> istream& operator >> (istream& is, vector<T>& vec) {
    for(T& x : vec) is >> x;
    return is;
}
template<typename T> ostream& operator << (ostream& os, vector<T>& vec) {
    for(int i = 0; i < vec.size(); i++) {
        os << vec.at(i) << (i + 1 == vec.size() ? "" : " ");
    }
    return os;
}

int main() {
    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    cin >> P >> Q;

    vector<int> V(N);
    repi(i, 1, N + 1) {
        V.at(i - 1) = i; 
    }

    int Pk = 0, Qk = 0, cnt = 0;
    do {
        cnt++;
        if(V == P) {
            Pk = cnt;
        }
        if(V == Q) {
            Qk = cnt;
        }
    } while(next_permutation(all(V)));

    cout << abs(Pk - Qk) << endl;
}

Measured memory_bytes: 256