akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#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 rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

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

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

int main()
{
    ll n,ans=999999999;
    cin >> n;
    ll v[n];
    rep(i,n) cin >> v[i];
    rep(i,n-1){
        ll sum=0,tmp=0;
        rep(j,n){
            if(j<=i) sum+=v[j];
            else tmp+=v[j];
        }
        ans=min(ans,abs(sum-tmp));
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()


count = 0
r_count = []
for i in range(N):
    if S[i] == "R":
        count += 1
    r_count.append(count)

count = 0
g_count = []
for i in range(N):
    if S[i] == "G":
        count += 1
    g_count.append(count)

count = 0
b_count = []
for i in range(N):
    if S[i] == "B":
        count += 1
    b_count.append(count)

ans = 0
for i in range(N):
    if S[i] == "R":
        ans += g_count[i] * (b_count[-1] - b_count[i]) + b_count[i] * (
            g_count[-1] - g_count[i]
        )
    elif S[i] == "G":
        ans += r_count[i] * (b_count[-1] - b_count[i]) + b_count[i] * (
            r_count[-1] - r_count[i]
        )
    else:
        ans += r_count[i] * (g_count[-1] - g_count[i]) + g_count[i] * (
            r_count[-1] - r_count[i]
        )

rgbs = set(("RGB", "RBG", "BRG", "BGR", "GRB", "GBR"))

for i in range(N):
    for j in range(i + 2, N, 2):
        s = S[i : j + 1 : (j - i) // 2]
        if s in rgbs:
            ans -= 1

print(ans)


Measured memory_bytes: 9340
import sys
import copy
import string
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

sx, sy, tx, ty = na()
ans = ""
dx = tx - sx
dy = ty - sy

ans += dy * "U"
ans += dx * "R"

ans += dy * 'D'
ans += dx * "L"

ans += "L"
ans += "U" * (dy + 1)
ans += 'R' * (dx + 1)
ans += "D"

ans += "R"
ans += 'D' * (dy + 1)
ans += "L" * (dx + 1)
ans += "U"

print(ans)










Measured memory_bytes: 3900
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
using namespace std;
#define ll long long
const int maxn = 1e5 + 5;
int a[maxn];
long long T, n, m, k, x;
void init()
{

}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> n >> m;
	if (m & 1) { cout << "No" << endl; return 0; }
	if (m >= 2 * n && m <= 4 * n)cout << "Yes" << endl;
	else cout << "No" << endl;

}

Measured memory_bytes: 3644
#include<iostream>
#include<queue>
using namespace std;
const int MAXN = 105;
const int INF = 1<<21;
int a[105][105];
int d[MAXN];
int n;


void bfs(int s)
{
	for(int i = 0; i < n; i++)
	{
		d[i] = INF;
	}
	queue<int> q;
	q.push(s);
	d[s] = 0;
	
	int u;
	while(!q.empty())
	{
		u = q.front(); q.pop();
		for(int v = 0; v < n; v++)
		{
			if(d[v] != INF)
				continue;
			if(a[u][v] == 0)
				continue;
			d[v] = d[u] + 1;
			q.push(v);
		}
	}
	
	for(int i = 0; i < n; i++)
	{
		if(d[i] != INF)
			cout << i+1 << " " << d[i] << endl;
		else
			cout << i+1 << " " << -1 << endl;
	}
}

int main ()
{
	int u, v, k;
	cin >> n;
	for(int i = 0; i < n; i++)
	{
		cin >> u >> k;
		u--;
		for(int j = 0; j < k; j++)
		{
			cin >> v;
			v--;
			a[u][v] = 1;
		}
	}
	bfs(0);
	return 0;
}


Measured memory_bytes: 3152
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
 
#define N 600000
#define NIL -1
 
//array
int key[N];
int parent[N];
int leftc[N];
int rightc[N];
//root
int root=NIL;
 
//function insert
void insert(int z){
  int x,y;
   
  y=NIL;
  x=root;
 
  while(x!=NIL){
    y=x;
    if(key[z]<key[x]) x=leftc[x];
    else x=rightc[x];
  }  
   
  parent[z]=y;
 
  if(y==NIL) root=z;
     
  else if(key[z]<key[y]) leftc[y]=z;
 
  else rightc[y]=z;
   
   
}
 
//function search
int find(int now,int data){
  if(now==NIL ||data==key[now]) return now;
   
  if(data<key[now]) return find(leftc[now],data);
  else return find(rightc[now],data);
}
 
//function minimum
int treeminimum(int x){
  while(leftc[x]!=NIL){
    x=leftc[x];
  }
  return x;
}
 
//function successor
int treesuccessor(int x){
  int y; 
  if(rightc[x]!=NIL) return treeminimum(rightc[x]);
  y=parent[x];
  while(y!=NIL &&x==rightc[x]){
    x=y;
    y=parent[y];
  }
  return y;
}
 
 
//function delete
void treedelete(int z){
  int x,y;
  if(leftc[z]==NIL ||rightc[z]==NIL) y=z;
  else y=treesuccessor(z);
 
  if(leftc[y]!=NIL) x=leftc[y];
  else x=rightc[y];
 
  if(x!=NIL) parent[x]=parent[y];
  if(parent[y]==NIL) root=x;
  else if(y==leftc[parent[y]]) leftc[parent[y]]=x;
  else rightc[parent[y]]=x;
 
  if(y!=z) key[z]=key[y];
 
}
 
//print
void inorderprint(int now){
  if(now!=NIL){
    inorderprint(leftc[now]);
    printf(" %d",key[now]);
    inorderprint(rightc[now]);
  }
}
 
void preorderprint(int now){
  if(now!=NIL){
    printf(" %d",key[now]);
    preorderprint(leftc[now]);
    preorderprint(rightc[now]);
  }
}
 
 
 
int main(){
 
  int n,i,j,data;
  int z=0;
  int del;
  char str[10];
  //initialize array
  for(i=0;i<N;i++){
    parent[i]=NIL;
    key[i]=NIL;
    rightc[i]=NIL;
    leftc[i]=NIL;
  }
  //load n
  scanf("%d",&n);
  //load commnad and key
  for(i=0;i<n;i++){
    scanf("%s",str);
    if(strcmp(str,"insert")==0) {
      scanf("%d",&data);
      key[z]=data;
      insert(z);
      z++;
    }
    else if(strcmp(str,"find")==0){
      scanf("%d",&data);
      if(find(root,data)!=NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(strcmp(str,"delete")==0){
      scanf("%d",&data);
      del=find(root,data);
      treedelete(del);
    }
    else if(strcmp(str,"print")==0){
      inorderprint(root);
      cout <<endl;
      preorderprint(root);
      cout <<endl;
    }
  }
 
  return 0;
}

Measured memory_bytes: 10000
#include<stdio.h>
int main(){
  long int a,b,c,d;
  scanf("%ld%ld%ld",&a,&b,&c);
  d=c-b-a;
  if(4*a*b<d*d && d>0)
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


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

int path[9][9];
int ind[9];
int vis[9];
int ans,n,m;

void DFS(int num,int ind){
	if(num==n){
		ans++;
		return;
	}
	for(int i = 1;i <= n;i++){
		if(path[ind][i]&&!vis[i]){
			vis[i] = 1;
			DFS(num+1,i);
			vis[i] = 0;
		}
	}
}

int main(){
	int a,b;
	
	cin >> n >> m;
	while(m--){
		cin >> a >> b;
		path[a][b] = 1;
		path[b][a] = 1;
	}
	ans = 0;
	vis[1] = 1;
	DFS(1,1);
	cout << ans;
}

Measured memory_bytes: 256
#8:47
MOD=10**9+7
INT_MAX=10**18+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
def power(a,x):
    res=1
    while(x>0):
        if x&1:
            res=(res*a)%MOD
        a=(a*a)%MOD
        x//=2
    return res%MOD
def NCR_MOD(n,r):
    num=1
    for i in range(n,n-r,-1):num=(num*i)%MOD
    for j in range(1,r+1):num=(num*power(j,MOD-2))%MOD
    return num
#################################################################################
import math as M
a,b,h,m=INPUT()
thetha=abs(30*h-6*m+0.5*m)
if thetha>180:
    thetha=360-thetha
#print(M.cos(thetha*M.pi/180)
#print(M.sqrt(a**2+b**2))
c=M.sqrt(b**2+a**2-2*a*b*M.cos(thetha*M.pi/180))
print(c)


Measured memory_bytes: 62496
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;

const int maxn=1e2+5;
int n,m,dp[2][maxn][maxn][maxn],ex,ey,sum[maxn][maxn],l,r,u,d,ans;
char s[maxn][maxn];

inline int max_(int a,int b){
	return a>=b?a:b;
}
inline int min_(int a,int b){
	return a<=b?a:b;
}
inline void chkmax(int&a,int b){
	if(a<b)a=b;
}
inline int calc(int a,int b,int c,int d){
	return sum[c][d]-sum[c][b-1]-sum[a-1][d]+sum[a-1][b-1];
}

int main(){
	cin>>n>>m;
	for(int i=1;i<=n;++i)
		cin>>(s[i]+1);
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			if(s[i][j]=='o')
				sum[i][j]=1;
			else if(s[i][j]=='E')
				ex=i,ey=j;
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			sum[i][j]=sum[i][j]+sum[i-1][j]+sum[i][j-1]-sum[i-1][j-1];
	u=ex-1;d=n-ex;l=ey-1;r=m-ey;
	for(int i=ex;i;--i){
		memset(dp[i&1^1],0,sizeof(dp[i&1^1]));
		for(int j=ex;j<=n;++j)
			for(int x=ey;x;--x)
				for(int y=ey;y<=m;++y){
					if(i>1&&j-i<u)
						chkmax(dp[i&1^1][j][x][y],dp[i&1][j][x][y]+calc(i-1,max_(x,y-ey+1),i-1,min_(y,m-ey+x)));
					if(j<n&&j-i<d)
						chkmax(dp[i&1][j+1][x][y],dp[i&1][j][x][y]+calc(j+1,max_(x,y-ey+1),j+1,min_(y,m-ey+x)));
					if(x>1&&y-x<l)
						chkmax(dp[i&1][j][x-1][y],dp[i&1][j][x][y]+calc(max_(i,j-ex+1),x-1,min_(j,n-ex+i),x-1));
					if(y<m&&y-x<r)
						chkmax(dp[i&1][j][x][y+1],dp[i&1][j][x][y]+calc(max_(i,j-ex+1),y+1,min_(j,n-ex+i),y+1));
					chkmax(ans,dp[i&1][j][x][y]);
				}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 9472
#include<stdio.h>
int main(void){
	int a,x=0,i;
	char b[5];
	scanf("%s",b);
	if(b[0]=='A'){printf("T\n");}
	else if(b[0]=='T'){printf("A\n");}
	else if(b[0]=='G'){printf("C\n");}
	else if(b[0]=='C'){printf("G\n");}

	return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using CompLib.Util;

public class Program
{
    private long N;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextLong();
        var hs = new HashSet<long>();
        int ans = 0;
        for (long i = 1; i * i <= N; i++)
        {
            if (N % i == 0)
            {
                if (i != 1)
                    if (C(N, i))
                        ans++;
                if (N / i != i)
                    if (C(N, N / i))
                        ans++;
            }
        }

        for (long i = 1; i * i <= (N - 1); i++)
        {
            if ((N - 1) % i == 0)
            {
                if (i != 1)
                    if (C(N, i))
                        ans++;
                if ((N - 1) / i != i)
                    if (C(N, (N - 1) / i))
                        ans++;
            }
        }

        Console.WriteLine(ans);
    }

    bool C(long n, long k)
    {
        while (n % k == 0)
        {
            n /= k;
        }

        return n % k == 1;
    }


    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13396
#include<iostream>
#include<string>
#include<math.h>
#include<iomanip>
using namespace std;
int main(){
	int x,h;
	while(true){
		cin>>x>>h;
		if(x==0&&h==0)
			break;
		double s=x*x;
		s+=x*2*(double)sqrt((double)x*x/4+h*h);
		cout<<fixed<<setprecision(10)<<s<<endl;
	}
    return 0;
}
 

Measured memory_bytes: 1232
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

const int M=1005;
const int ME=M*M;

vector<int> g[ME];

inline int id(int u,int v)
{
	if(u>v) swap(u,v);
	return u*M+v;
}

int d[ME];
int col[ME];
int dfs(int u)
{
	if(col[u])
	{
		if(col[u]==2) return d[u];
		return -1;
	}
	col[u]=1;
	int &ans=d[u];
	for(int v:g[u])
	{
		int nans=dfs(v);
		if(nans==-1) return -1;
		ans=max(ans,nans);
	}
	col[u]=2;
	// not super source
	if(u) ans++;
	return ans;
}

int main()
{
	int n; scanf("%d",&n);
	int pre,v;
	for(int u=1;u<=n;u++)
	{
		pre=0;
		for(int i=1;i<n;i++)
		{
			scanf("%d",&v);
			int now=id(u,v);
			g[pre].push_back(now);
			pre=now;
		}
	}
	printf("%d\n",dfs(0));
	return 0;
}

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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(0)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;

const int MAXN = 1000100, MAXK = 30;
const ll MOD = 1e9+7;
const ll INF = 1e18;
const ld PI = asin(1) * 2;



int main()
{
    FAST_IO;

    int h, a; cin >> h >> a;
    cout << (h+a-1)/a << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

int main() {
    int a,b,c,d; cin >> a >> b >> c >> d;
    int s = min(a,c);
    int g = max(b,d);
    int ans = 0;
    for(int i = s;i < g;i++){
        if(i >= a && i < b && i >= c && i < d){
            ans++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD (ll)(998244353)
#define MAX (ll)(1e5 + 4)
#define INF (ll)(1e17)
using namespace std;
using ll =  long long;
using ld = long double;

int main () {
	ll n;
	ll ce = -INF;
	cin >> n;
	set<ll> rem;
	set <pair<ll, ll>> le, lb;
	vector<pair<ll, ll>> pp;
	for (ll i = 0; i < n; i++) {
		ll x, l;
		cin >> x >> l;
		pp.push_back (make_pair (x + l, x - l));
	}
	sort (pp.begin (), pp.end ());
	int cc = 0;
	for (int i = 0; i < n; i++) {
		if (pp[i].second >= ce) {
			cc++;
			ce = pp[i].first;
		}
	}
	cout << cc << "\n";
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
bool dp[100505];
int n;
void qaq(int qwq) {
	for(int i=100;i<=105;i++) dp[qwq+i]=1;
}
int main() {
	cin>>n;
	qaq(0);
	for(int i=1;i<=100000;i++) 
		if(dp[i]) qaq(i);
	if(dp[n]) cout<<1;
	else cout<<0;
	return 0;
}

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

const int INF = 10000009;
int main(){
  int N;
  cin >> N;
  vector<int> P(N);
  for(int i = 0; i < N; i++)cin >> P.at(i);
  int tmpmin = INF;
  int res = 0;
  for(int i = 0; i < N; i++){
    tmpmin = min(P.at(i),tmpmin);
    if(tmpmin==P.at(i))res++;
  }
  cout << res << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cassert>
#include <random>
#include <tuple>

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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1e9 + 7;
const int MAX = 110000;
ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

ll COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

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


int main() {
    int n;
    cin >> n;
    vector<ll> x(n);
    rep(i, n) cin >> x[i];

    COMinit();

    int used = 0;
    ll ans = 1;
    rep(i, n) {
        if (x[i] < 2*(i-used)+1) {
            ans *= (i+1-used);
            ans %= MOD;
            used++;
        }
    }

    ans *= fac[n-used];
    ans %= MOD;

    cout << ans << endl;


    return 0;

}


Measured memory_bytes: 3584
function Main(input){
  
  var str = input.trim();
  var len = str.length;
  var kekka = 0;
  var tmp = 0;

 for(i=0;i<len;i++){ 
 //var head = str.substr(0,1);
              // console.log(head);
            //console.log(str.match(/^[ACGT]/));
    //console.log(str);
   if(str.match(/^[ACGT]/) !== null){
     var str = str.substr(1);
     tmp++;
       //console.log("tmp:"+tmp);
     if(tmp>kekka){
       kekka = tmp;
              //console.log("kekka:"+kekka);
     }
   }//if true end
     else{
       var str = str.substr(1);
       tmp = 0;
       
     }
  
 }
  console.log(kekka);
}//function end
 
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<iostream>
#define MAX_NUM 8
using namespace std;

int H, W;
char grid[MAX_NUM][MAX_NUM];

void dfs(int h, int w) {
    grid[h][w] = '.';
    if (w + 1 < W && grid[h][w + 1] == '#') dfs(h, w + 1);
    else if (h + 1 < H && grid[h + 1][w] == '#') dfs(h + 1, w);
    return;
}

int main() {
    cin >> H >> W;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) cin >> grid[i][j];
    }
    dfs(0, 0);
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (grid[i][j] == '#') {
                cout << "Impossible" << endl;
                return 0;
            }
        }
    }
    cout << "Possible" << endl;
    return 0;
}

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

int main(){
    int x[3000],y[3000];
    int i = 0;
    int z;
    while(true){
        cin >> x[i] >> y[i];
        if((x[i] == 0)&&(y[i] == 0))
            break;
        i++;
    }
    for(int j = 0; j < i; j++){
        if(x[j]> y[j]){
            z = x[j];
            x[j] = y[j];
            y[j] = z;
        }
        cout << x[j] << " " << y[j] << endl;
    }
} 


Measured memory_bytes: 3016
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


fn main() {
    input! {
        n: i32
    }
    println!("{}", n * n * n);
}

Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;
vector<int> vec;

int main(int argc, char const* argv[])
{
	int n;
	cin >> n;
	int tmp = n;
	if(n == 0){
			cout << 0 << endl;
			return 0;
	}
	while(tmp != 0){
			int ttmp = tmp % 2;
			if(ttmp < 0)ttmp = ttmp + 2;
			vec.pb(ttmp);
			tmp = (tmp - ttmp) / (-2);
	}
	for(auto itr = vec.rbegin(); itr != vec.rend(); ++itr){
			cout << *itr;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <stack>

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

void dfsutil(vvi & al, vi & ht, vi & par, vi & subtree_sz, ll src, vector<bool> & vis) {
	vis[src] = true;
	ll sz = 0;
	for(ll i=0; i<al[src].size(); i++) {
		if(!vis[al[src][i]]) {
			par[al[src][i]] = src;
			ht[al[src][i]] = ht[src]+1;
			dfsutil(al, ht, par, subtree_sz, al[src][i], vis);
			sz += subtree_sz[al[src][i]];
		}
	}
	subtree_sz[src] = 1+sz;
}

void DFS(vvi & al, vi & ht, vi & par, vi & subtree_sz) {
	ll src = 0;
	ht[0] = 0;
	par[0] = -1;
	ll n = al.size();
	vector<bool> vis(n);
	dfsutil(al, ht, par, subtree_sz, src, vis);
}

int main(int argc, char ** argv) {
	ll n;
	cin >> n;
	vvi al(n);
	for(ll i=0; i<(n-1); i++) {
		ll a, b;
		cin >> a >> b;
		a--;
		b--;
		al[a].push_back(b);
		al[b].push_back(a);
	}
	vi ht(n,0);
	vi par(n,0);
	vi subtree_sz(n,0);
	DFS(al, ht, par, subtree_sz);
	ll ht_nm1, ht_0;
	if((ht[n-1]+1) % 2 == 0) {
		ht_nm1 = (ht[n-1]+1)/2;
		ht_0 = (ht[n-1]+1)/2;
	} else {
		ht_0 = (ht[n-1]+1)/2 + 1;
		ht_nm1 = (ht[n-1]+1)/2;
	}
	ll cur = n-1;
	ht_nm1 --;
	while(ht_nm1 != 0) {
		cur = par[cur];
		ht_nm1 --;
	}
	ll snuke = subtree_sz[cur]-1;
	ll fennec = subtree_sz[0] - subtree_sz[cur] - 1;
	bool fennec_wins = (fennec > snuke);
	if(fennec_wins) cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
	return 0;
}


Measured memory_bytes: 19072
import sys
input = sys.stdin.readline
from collections import Counter
n = int(input())
S = []
for _ in range(n):
    S.append(list(input().rstrip()))
c = Counter(S[0])
for i in range(1, n):
    c_2 = Counter(S[i])
    for j in c.keys():
        c[j] = min(c[j], c_2[j])
cha = sorted(list(c.items()))
ans = []
for k in cha:
    ans.append(k[0] * k[1])
print("".join(ans))

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

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }	//最大公約数(Greatest Common Divisor)
ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }			//最小公倍数(Least Common Multiple)

long long comb(long long m) {
	return (m * (m - 1)) / 2;
}


int main() {
	int n,k;
	cin >> n >> k;
	vector<int> p(n);
	rep(i, n)	cin >> p[i];

	list<int> pp(0);
	rep(i, n)	pp.push_back(p[i]);
	pp.sort();

	int ans = 0;
	list<int>::iterator itr;
	itr = pp.begin();
	rep(i, k) {
		ans += *itr;
		itr++;
	}

	cout << ans << endl;


}

Measured memory_bytes: 3628
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <map>
#define for1(x,y) for(long long x = 1; x<ll(y); x++)
#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
#define PII pair<int,int>
#define FF first
#define SS second
#define PB push_back
#define all(x) x.begin(), x.end()

#define forn(x,y,z) for(long long x = y; x< ll(z); x++)
#define for0(x,y,z) for(long long x = y; x< ll(z); x++)
using namespace std;
typedef long long ll;
typedef long double ld;	
#define vi vector<int> 
#define vl vector<ll> 
#define vvi vector<vector<int>>
#define vvl vector<vector<ll>>
#define maxn 1000015
const double EPS = (1e-7), EPSm= (1e7);
const ll linf = (ll)1e17 + 5;
long double PI = 3.14159265359;
int dir[8][2]={{1,0},{-1,0},{0,1},{0,-1},{-1,-1},{1,1},{-1,1},{1,-1}};
	
const int MAXN = 3*1e5+10;
const int NINF = -1e5;
const int INF = 20000000;
const ll mod=1e9+7;


void solve()
{
	ll n;
	cin>>n;
	vector<pair<ll,ll>> points(n), pre(n);
	for(auto &[x,y] : points){
        cin>>x>>y;
  }
	ll ans1=-1e11,ans2=1e11,ans3=-1e11,ans4=1e11;
	for(auto &[x,y] : points){
		ans1=max(x+y,ans1);
		ans2=min(x+y,ans2);
		ans3=max(x-y,ans3);
		ans4=min(x-y,ans4);
	}
	//cout<<ans1<<" "<<ans2<<" "<<ans3<<" "<<ans4<<endl;
	cout<<max((ans1-ans2),(ans3-ans4))<<endl;
	return;
}


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int test;
	//cin >> test;
	//while(test--)
		solve();
	return 0;
}


Measured memory_bytes: 9480
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

char buf[100000+10];
int n;

ll mypow(ll x, ll n) {
  if(n == 0) return 1;
  if(n % 2 == 0) return mypow(x*x%MOD, n/2);
  return mypow(x*x%MOD, n/2) * x % MOD;
}

int cs[100000+10];

int main(void) {
  scanf("%s", buf);
  n = strlen(buf);
  REP(i, n) {
    cs[i+1] = cs[i] + (buf[i] == '?');
  }

  ll c = 0;
  ll bc = 0;
  ll abc = 0;
  for(int i = n-1; i >= 0; --i) {
    if(buf[i] == 'A') {
      abc = (abc + bc) % MOD;
    } else if(buf[i] == 'B') {
      bc = (bc + c) % MOD;
    } else if(buf[i] == 'C') {
      // cerr << "> " << cs[n] - cs[i+1] << " " << c << " " << mypow(3, cs[n]-cs[i+1]) << endl;
      c = (c + mypow(3, cs[n]-cs[i+1])) % MOD;
    } else if(buf[i] == '?') {
      ll nc = (c + c + (c+mypow(3, cs[n]-cs[i+1]))) % MOD;
      ll nbc = (bc + (bc+c) + bc) % MOD;
      ll nabc = ((abc + bc) + abc + abc) % MOD;
      c = nc;
      bc = nbc;
      abc = nabc;
    } else {
      assert(false);
    }
    // cerr << c << " " << bc << " " << abc << endl;
  }
  cout << abc << endl;
  
  return 0;
}


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

using ps = pair<string,string>;

bool is_palindrome(const string &s)
{
    int S = s.size();
    rep(i,S)if(s[i]!=s[S-1-i]) return false;
    return true;
}

bool is_rev(const string &a, const string &b)
{
    int S = a.size();
    rep(i,S)if(a[i]!=b[S-i]) return false;
    return true;
}

string rev(const string &s)
{
    string t(s);
    reverse(t.begin(),t.end());
    return t;
}

int main()
{
    int n,L;
    cin >>n >>L;
    vector<string> s(n);
    rep(i,n) cin >>s[i];

    map<string,int> ct;
    rep(i,n) ++ct[s[i]];

    priority_queue<ps,vector<ps>,greater<ps>> pq;
    rep(i,n)
    {
        if(is_palindrome(s[i]))
        {
            while(ct[s[i]]>1)
            {
                pq.push({s[i],s[i]});
                ct[s[i]]-=2;
            }
        }
        else
        {
            string r = rev(s[i]);
            while(ct[s[i]]>0 && ct[r]>0)
            {
                string a = min(s[i],r), b = max(s[i],r);
                pq.push({a,b});

                --ct[s[i]];
                --ct[r];
            }
        }
    }

    string f = "", b = "";
    while(!pq.empty())
    {
        ps p = pq.top();
        pq.pop();
        f += p.first;
        b = p.second + b;
    }

    string center = "";
    rep(i,n)if(is_palindrome(s[i]) && ct[s[i]]>0)
    {
        if(center=="") center = s[i];
        else center = min(center,s[i]);
    }

    string ans = f+center+b;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3412
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	x=0;char c=getchar();bool f=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return  x;
}
template<class t> inline void write(t x){
	if(x<0){putchar('-'),write(-x);}
	else{if(x>9)write(x/10);putchar('0'+x%10);}
}

const int N=2005;
int n,m,q,a[N][N],s[N][N],sx[N][N],sy[N][N];

void doit(){
	int x,y,xx,yy;
	read(x);read(y);read(xx);read(yy);
	int n=s[xx][yy]-s[xx][y-1]-s[x-1][yy]+s[x-1][y-1];
	int m=(sx[xx][yy-1]-sx[xx][y-1]-sx[x-1][yy-1]+sx[x-1][y-1])+(sy[xx-1][yy]-sy[x-1][yy]-sy[xx-1][y-1]+sy[x-1][y-1]);
	write(n-m);
	//printf("\n$%d %d %d\n",n,sx[xx][yy-1]-sx[xx][y-1]-sx[x-1][yy]+sx[x-1][y-1],sy[xx-1][yy]-sy[x-1][yy]-sy[xx][y-1]+sy[x-1][y-1]);
	puts("");
}

signed main(){
	read(n);read(m);read(q);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			scanf("%1d",&a[i][j]);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+a[i][j];
			sx[i][j]=sx[i-1][j]+sx[i][j-1]-sx[i-1][j-1]+(a[i][j]+a[i][j+1]==2);
			sy[i][j]=sy[i-1][j]+sy[i][j-1]-sy[i-1][j-1]+(a[i][j]+a[i+1][j]==2);
		}
	//for(int i=1;i<=n;i++,puts("")) for(int j=1;j<=m;j++) printf("%d ",sy[i][j]);puts("");
	while(q--) doit();
}

Measured memory_bytes: 64640
import time
from collections import deque
N, M, K = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(M)]
CD = [list(map(int, input().split())) for _ in range(K)]

F = [set() for _ in range(N)]
B = [set() for _ in range(N)]

for i, j in AB:
    F[i - 1].add(j - 1)
    F[j - 1].add(i - 1)
for i, j in CD:
    B[i - 1].add(j - 1)
    B[j - 1].add(i - 1)

Q = deque()
S = [0] * N
d = [0] * N

for i in range(N):
    if d[i] != 0:
        continue
    L = {i}
    d[i] = 1
    Q.append(i)
    while len(Q) > 0:
        q = Q.pop()
        for j in F[q]:
            if d[j] == 0:
                d[j] = 1
                Q.append(j)
                L.add(j)
    for k in L:
        S[k] = len(L) - len(L & F[k]) - len(L & B[k]) - 1

print(*S)


Measured memory_bytes: 129544
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
int mod=1000000007;
int read()
{
	char ch=getchar();int f=0;
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9')
	{f=(f<<1)+(f<<3)+ch-'0';
	ch=getchar();}
	return f;
}
int ksm(long long a1,long long b)  
{  
    LL ans = 1;  
    a1 %= mod;  
    while(b)  
    {  
        if(b & 1)  
        {  
            ans = ans * a1 % mod;  
            b--;  
        }  
        b >>= 1;  
        a1 = a1 * a1 % mod;  //cout<<"ans:"<<ans<<" ";
    }  
    
    return ans;  
}  
LL a[100003],v[100003],f,l,r,q[100005],s[100005];
long long c(int m,int n)
{
	if(m>n)
	return 0;
	return ((s[n]*q[m])%mod)*q[n-m]%mod;
}
int main()
{
	int n=read();
	for(int i=1;i<=n+1;i++)
	a[i]=read();
	for(int i=1;i<=n+1;i++)
	v[a[i]]++;
	for(int i=1;i<=n;i++)
	{
		if(v[a[i]]==2)
		{
			f=a[i];
			break;
		}
	}
	for(int i=1;i<=n+1;i++)
	{
		if(a[i]==f)
		{
			if(l==0)
			l=i;
			else
			{
				r=i;
				break;
			}
		}
	}
	printf("%lld\n",n);
	q[0]=1;s[0]=1;
	for(int i=1;i<=n+1;i++)
	{
		q[i]=(q[i-1]*ksm(i,mod-2))%mod;
		s[i]=(s[i-1]*i)%mod;
		//cout<<i<<" "<<q[i]<<" "<<s[i]<<endl;
	}
	for(int i=2;i<=n+1;i++)
	{
		printf("%lld\n",(((c(i,n+1)-c(i-1,n-r+l))%mod)+mod)%mod);
		//cout<<c(i,n+1)<<" "<<c(i-1,n-r+2)<<endl;
	//	cout<<i-1<<" "<<n-r+1;
	}
}


Measured memory_bytes: 4352
fn zalgo<T>(s: &[T]) -> Vec<usize>
where
    T: PartialEq,
{
    let mut a = vec![0; s.len()];
    a[0] = s.len();

    let mut i = 1;
    let mut j = 0;
    while i < s.len() {
        while i + j < s.len() && s[j] == s[i + j] {
            j += 1;
        }
        a[i] = j;
        if j == 0 {
            i += 1;
            continue;
        }
        let mut k = 1;
        while (i + k < s.len() && k + a[k] < j) {
            a[i + k] = a[k];
            k += 1;
        }
        i += k;
        j -= k;
    }

    a
}

#[test]
fn zalgo_test() {
    assert_eq!(
        zalgo("aaabaaaab".as_bytes()),
        vec![9, 2, 1, 0, 3, 4, 2, 1, 0]
    );
}

fn solve(s: &str) -> usize {
    use std::cmp::min;

    let n = s.len();

    let mut r = 0;

    for i in 0..n {
        let v = zalgo(s[i..].as_bytes());
        for j in (i + 1)..n {
            let m = min(j - i, v[j - i]);
            if r < m {
                r = m;
            }
        }
    }

    r
}

#[test]
fn solve_test() {
    assert_eq!(solve("ababa"), 2);
    assert_eq!(solve("xy"), 0);
    assert_eq!(solve("strangeorange"), 5);
}

#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        line.pop();
        line
    }};
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => {{
        let mut line = String::new();
        ::std::io::stdin().read_line(&mut line).unwrap();
        let iter = line.split_whitespace();
        iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
    }};
}

fn main() {
    let _n = parse_line!(usize);
    let s = read_line!();

    println!("{}", solve(&s));
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n;
  cin >> n;
  vll a(n);
  for (ll i = 0; i < n; i++) cin >> a[i];
  ll cnt = 0;
  for (ll i = 0; i < n; i++) {
    if (a[i] % 2 == 1) cnt++;
  }
  if (cnt % 2) NO();
  else YES();
}

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

vector<int> z_algorithm(const string &s) {
  vector<int> prefix(s.size(), 0);
  for (int i = 1, j = 0; i < s.size(); i++) {
    if (i + prefix[i - j] < j + prefix[j]) {
      prefix[i] = prefix[i - j];
    } else {
      int k = max(0, j + prefix[j] - i);
      while (i + k < s.size() && s[k] == s[i + k]) ++k;
      prefix[i] = k;
      j = i;
    }
  }
  for (int i = 0; i < s.size(); i++) {
    prefix[i] = min(i, prefix[i]);
  }
  return prefix;
}

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    auto t = s.substr(i, n - i);
    auto z = z_algorithm(t);
    ans = max(ans, *max_element(begin(z), end(z)));
  }
  cout << ans << endl;
}


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

int main(int argc, char const *argv[])
{
    int i = 0;
    int n = 0;
    char *btc = "BTC";
    double total = 0;

    scanf("%d", &n);

    double a = 0;
    char u[2];

    while (i != n)
    {
        scanf("%lf %s", &a, u);
        if (strcmp(btc, u) == 0)
        {
            a *= 380000.0;
        }
        total += a;
        i++;
    }

    printf("%lf\n", total);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
#define SZ(v) int((v).size())
#define ALL(vec) (vec).begin(),(vec).end()
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string>) {}
template<typename T1,typename T2> ostream& operator<<(ostream& os, pair<T1,T2> buf) {
  return os << "(" << buf.first << ": " << buf.second << ")"; }
#define DefOut(Con) template<typename T>ostream&operator<<(ostream&os,Con<T>&A){ bool f = false; os << "{"; \
  for (const auto e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
#define DefOut2(Con) template<typename K,typename V>ostream&operator<<(ostream&os,Con<K,V>&A) \
{ bool f = false; os << "{"; for (auto &e: A) { if (f) os << ", "; os << e; f = true; } return os << "}"; }
template<typename T>ostream &operator << (ostream &os,vector<vector<T>>& A) {
  for (auto &B: A) os << '\n' << B; return os; }
DefOut(vector) DefOut(set) DefOut(multiset) DefOut2(map) 
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << a << endl; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1000000007;
long long const INF = 1e18;
#define PI 3.14159265358979323846
/***********************************************************************/

int32_t main() {

  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int x, a;
  cin >> x >> a;
  kek(x < a ? 0 : 10);
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int a[n],i,j,m;
    long s=0;
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++)
    {
        for(j=i+1;j<n;j++)
        {
            if(a[i]>a[j])
            {
                m=a[i];
                a[i]=a[j];
                a[j]=m;
            }
        }
    }
    for(i=0;i<n;i++)
    {
        s=s+a[i];
    }
    printf("%d %d %ld\n",a[0],a[n-1],s);
    return 0;
}


Measured memory_bytes: 2136
import java.util.*;
import java.io.*;
import java.util.Scanner;
import java.util.HashMap;

public class Main{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		long sum = 0;
		HashMap<Integer, Integer> map= new HashMap<>();
		for(int i=0;i<n;i++)
		{
			arr[i] = sc.nextInt();
			if(map.containsKey(arr[i]))
			{
				int a = map.get(arr[i]);
				a++;
				map.replace(arr[i],a);
			}
			else
			{
				map.put(arr[i],1);
			}
			sum = sum + (long)arr[i];
		}
		int q = sc.nextInt();
		int[] b = new int[q];
		int[] c = new int[q];
		for(int i=0;i<q;i++)
		{
			b[i] = sc.nextInt();
			c[i] = sc.nextInt();
			if(map.containsKey(b[i]))
			{
			int s = map.get(b[i]);
			sum = sum+(long)(s*(c[i]-b[i]));
			System.out.println(sum);
			if(map.containsKey(c[i]))
			{
				int a = map.get(c[i]);
				a = a+s;
				map.replace(c[i],a);
			}
			else
			{
				map.put(c[i],s);
			}
			map.remove(b[i]);
		}
		else
		{
			System.out.println(sum);
		}
		}
	}
}

Measured memory_bytes: 87452
#include <iostream>
#include<algorithm>
#include <vector>
#include<string>
#include<cmath>
#include<cstdio>

using namespace std;
int s(int);
int main() {
	int n;
	cin >> n;
	int ans = s(n);
	if ((n%ans )== 0) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}
int s(int n) {
	int ans = 0;
	while (1)
	{
		ans += n % 10;
		if (n < 10) {
			break;
		}
		n /= 10;
	}
	return ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using ll = long long;
using ull = unsigned long long;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> v;
    int a; cin >> a;
    v.emplace_back(a);    
    REP(i,n-1) {
        int x; cin >> x;
        if (v.back() >= x ) {
            v.emplace_back(x);
        } else {
            auto it = lower_bound(RALL(v),x);
            auto d = distance(v.rbegin(),it);
            //cerr << d << endl;
            v[v.size()-d] = x;
        }
    }
    
    cout << v.size() << endl;

    return 0;
}

Measured memory_bytes: 892
#include <cmath>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	string str, ans;
	int m[256] = {0};
	for(int j=1; j<256; ++j)
		m[j] = 999999999;
	
	for(int i=0; i<n; ++i)
	{
		int mm[256] = {0};
		cin >> str;
		for(int j=0; j<str.size(); ++j)
			mm[str[j]]++;
		for(int j=1; j<256; ++j)
			m[j] = min(mm[j], m[j]);
	}
	for(int j=1; j<256; ++j)
		for(int i=0; i<m[j]; ++i)
			ans += (char)j;

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	String fileName = "erase";

	public void solve() throws IOException {
		int a = nextInt();
		int b = nextInt();
		if (b >= 10 && b != 100) {
			a = a * 100 + b;
		} else if (b == 100) {
			a = a * 1000 + b;
		} else if (b < 10) {
			a = a * 10 + b;
		}
		if (Math.sqrt(a) == (int) Math.sqrt(a)) {
			out.print("Yes");
		} else
			out.print("No");
	}

	public void run() {
		try {
			InputStreamReader isr = new InputStreamReader(System.in);
			br = new BufferedReader(isr);
			out = new PrintWriter(System.out, true);
			// out = new PrintWriter(fileName + ".out");
			// br = new BufferedReader(new FileReader(fileName + ".in"));
			solve();
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

	BufferedReader br;
	StringTokenizer in;
	static PrintWriter out;

	public String nextToken() throws IOException {
		while (in == null || !in.hasMoreTokens()) {
			in = new StringTokenizer(br.readLine());
		}
		return in.nextToken();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	public double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	public long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

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

}

Measured memory_bytes: 20820
m, d = map(int, input().split())

ans = 0
for i in range(22, d+1):
    d10 = i // 10
    d1 = i - d10 * 10
    if d10 > 1 and d1 > 1 and d10 * d1 <= m:
        ans += 1
print(ans)


Measured memory_bytes: 2940
import java.util.*;


public class Main {
	static int j =0;
	public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
		 int x = sc.nextInt();
		 if(x>=30) {
			 System.out.println("Yes");
		 }else {
			 System.out.println("No");
		 }

	}


}


Measured memory_bytes: 35688
import std.stdio;
import std.ascii;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

class Matrix {
    int Y, X;
    int[][] F;
    this(int Y, int X) {
        this.Y = Y;
        this.X = X;
        F = new int[][](Y, X);
    }
    void set(int y, int x, int v) { 
        F[y][x] = v; 
    }
    int get(int y, int x) { return F[y][x]; }
    int[] get(int y) { return F[y]; }
    // 繧ャ繧ヲ繧ケ縺ョ豸亥悉豕? 遐エ螢顔噪. 陦悟?縺ィ諡。蠑オ陦悟?縺ョrank縺御ク??縺吶ｋ縺九←縺?°繧定ソ斐☆
    bool GaussianElimination() {
        int rank0 = 0, rank1 = 0;
        int ny = 0;
        int pivot(int x) {
            foreach (y; ny .. Y) {
                if (F[y][x] != 0) return y;
            }
            return -1;
        }
        foreach (int px; 0 .. X) {
            int py = pivot(px);
            if (py < 0) continue;
            if (px < X - 1) rank0++;
            rank1++;
            swap(F[py], F[ny]);
            py = ny;
            ny++;
            foreach (int y; ny .. Y) {
                if (y == py) continue;
                int d = F[y][px];
                if (d == 0) continue;
                foreach (int x; 0 .. X) {
                    F[y][x] = (F[py][x] + F[y][x]) % 2;
                }
            }
        }
        return rank0 == rank1;
    }
}


const dy = [-1, 0, 1, 0],
      dx = [0, 1, 0, -1];

void main() {
    int X, Y, D;
    int[][] F;
    bool input() {
        scanf("%d %d %d\n", &X, &Y, &D);
        if (X == 0 && Y == 0 && D == 0) return false;
        F = new int[][Y];
        foreach (i; 0 .. Y) F[i] = readln.chomp.split(" ").map!(to!int).array;
        return true;
    }
    void solve() {
        Matrix m = new Matrix(Y * X, Y * X + 1);
        foreach (y; 0 .. Y) {
            foreach (x; 0 .. X) {
                m.set(X * y + x, Y * X, F[y][x]);
            }
        }
        foreach (y1; 0 .. Y) {
            foreach (x1; 0 .. X) {
                m.set(X * y1 + x1, X * y1 + x1, 1);
                foreach (y2; 0 .. Y) {
                    foreach (x2; 0 .. X) {
                        if (abs(y1 - y2) + abs(x1 - x2) == D) {
                            m.set(X * y1 + x1, X * y2 + x2, 1);
                        }
                    }
                }
            }
        }
        writeln( m.GaussianElimination.to!int );
    }
    while (input) solve;
}

Measured memory_bytes: 8392
#include <bits/stdc++.h>
using namespace std;
int main() 
{
    //ifstream cin("input.in");
    //ofstream cout("output.out");
    ios::sync_with_stdio(0);cin.tie(0);
    long n,x;
    map<long,long> m;
    cin>>n;
    while(n--)
    {
        cin>>x;
        m[x-1]++;
        m[x+1]++;
        m[x]++;
    }
    long h=0;
    for(auto i:m)
        h=max(h,i.second);
    cout<<h;
    return 0;
}   


Measured memory_bytes: 6144
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+999;
vector<int>v[maxn];
int n,deg[maxn],dis[maxn],pos1,pos2,mx;
void dfs1(int x,int fa){
	dis[x]=dis[fa]+1;
	if(dis[x]>mx)mx=dis[x],pos1=x;
	for(auto y:v[x]){
		if(y==fa)continue;
		dfs1(y,x);
	}
}
void dfs2(int x,int fa){
	dis[x]=dis[fa]+1;
	if(dis[x]>mx)mx=dis[x],pos2=x;
	for(auto y:v[x]){
		if(y==fa)continue;
		dfs2(y,x);
	}
}
int tot,ans1[maxn],now,ans2[maxn],fl;
void dfs(int x,int fa){
	int cnt=0;
	for(auto y:v[x]){
		if(deg[y]==1&&y!=pos1&&y!=pos2)++cnt;
	}
	if(!fl){
		int t=now+1;++now;
		for(int i=1;i<=cnt;++i)ans1[++tot]=now+1,++now;
		ans1[++tot]=t;
	}else{
		int t=now+1;++now;
		for(int i=1;i<=cnt;++i)ans2[++tot]=now+1,++now;
		ans2[++tot]=t;
	}
	for(auto y:v[x]){
		if(y==fa)continue;
		if(deg[y]>1||y==pos1||y==pos2){
			dfs(y,x);
		}
	}
}
int vis[maxn],stac[maxn],top,flag;
void dfs3(int x){
	stac[++top]=x;vis[x]=1;
	if(x==pos2){flag=1;return;}
	for(auto y:v[x]){
		if(vis[y])continue;
		dfs3(y);
		if(flag)return;
	}
	--top;
}
int main(){
	cin>>n;
	for(int i=1,x,y;i<n;++i){
		cin>>x>>y;v[x].push_back(y);v[y].push_back(x);++deg[x];++deg[y];
	}
	dfs1(1,0);
	mx=0;
	memset(dis,0,sizeof(dis));
	dfs2(pos1,0);
	
	
	dfs3(pos1);
	memset(vis,0,sizeof(vis));
	for(int i=1;i<=top;++i)vis[stac[i]]=1;
	for(int i=1;i<=n;++i){
		if(!vis[i]&&deg[i]>1){
			cout<<-1;exit(0);	
		}
	}
	
	
	fl=0;
	dfs(pos1,0);
	fl=1;tot=0,now=0;
	dfs(pos2,0);
	for(int i=1;i<=n;++i){
		if(ans1[i]!=ans2[i]){
			if(ans1[i]<ans2[i]){
				for(int j=1;j<=n;++j)cout<<ans1[j]<<" ";
				exit(0);
			}else{
				for(int j=1;j<=n;++j)cout<<ans2[j]<<" ";
				exit(0);
			}
		}
	}
	for(int i=1;i<=n;++i)cout<<ans1[i]<<" ";
} 

Measured memory_bytes: 13312