akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


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

int D;
cin >> D;
vi c(26);
rep(i,26) cin >> c[i];
vvi s(D,vi(26));
rep(d,D) rep(i,26) cin >> s[d][i];

int cur = 0;
vi last(26);
rep(d,D) {
    int res = -INF;
    int p = 0;
    rep(i,26) {
        int up = s[d][i];
        int old = last[i];
        last[i] = d+1;
        int down = 0;
        rep(j,26) {
            down += c[i] * (d+1-last[i]);
        }
        last[i] = old;
        if(chmax(res,up-down)) p = i;
    }
    last[p] = d+1;
    cout << p+1 << endl;
}

return 0;
}

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

using namespace std;

const int Maxn = 10010;
int main()
{
    string s;
    cin>>s;
    int sz = s.length();
    int f = 0;
    for(int i = 0;i < sz;i ++) {
        if(s[i] == 'C')
            f = 1;
        if(s[i] == 'F')
        {
            if(f == 1)
            {
                cout<<"Yes"<<endl;
                f = 2;
                break;
            }
        }
    }
    if(f != 2)
    cout<<"No"<<endl;
    return 0;
}


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

#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
#define DEBUG(x) cerr << #x << " = " << x << endl

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> inline T tabs(T a) { return (a > 0) ? a : -a; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

void pos() {
	cout << "Positive" << endl;
}

void neg() {
	cout << "Negative" << endl;
}

void zero() {
	cout << "Zero" << endl;
}

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);
	
	int a, b;

	cin >> a >> b;
	if (a > 0) pos();
	else if (b < 0) {
		if ((b - a + 1) & 1) neg();
		else pos();
	}
	else zero();
	
	return 0;
}

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,j,N) for(int i = (N-1);i >= (j);i--)
#define ALL(x) x.begin(),x.end()
#define PB push_back

typedef pair<int,int> pi;
typedef long long LL;

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

string s;


int main()
{
    cin >> s;
    int sz = s.size();
    if(s[sz-1] == '1') {printf("-1\n");return 0;}
    if(s[0] != '1' || s[sz-2] != '1') {printf("-1\n");return 0;}
    //cout << mid << endl;
    bool ok = true;

    queue<int> que;
    for(int i = 0;i < sz-1;i++){
        if(s[i] != s[sz-i-2]) ok = false;
        if(s[i] == '1'){
            que.push(i);
        }
    }
    que.push(sz-1);

    if(!ok) printf("-1\n");
    else{
        _for(i,0,sz-1){
            if(i == que.front()) que.pop();
            printf("%d %d\n",i+1,que.front()+1);
        }
    }

    return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
    ll ans=1;
    for(int i=1; i<=n; i++)
        ans*=a;
    return ans;
}

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

    string s,t;
    cin>>s>>t;
    ll len=t.size(),ans=999999999999999999;
    for(int i=0; i<=s.size()-len; i++)
    {
        ll cnt=0;
        for(int j=0; j<t.size(); j++)
        {
            if(t[j]!=s[i+j])
                cnt++;
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 3660
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

h,w = inpl()
a = [inpl() for i in range(h)]
res = []
for y in range(h-1):
    for x in range(w):
        if a[y][x] % 2:
            res.append([y+1,x+1,y+2,x+1])
            a[y][x] -= 1
            a[y+1][x] += 1
for x in range(w-1):
    if a[h-1][x] % 2:
        a[h-1][x] -= 1
        a[h-1][x+1] += 1
        res.append([h,x+1,h,x+2])
print(len(res))
for i in res:
    print(*i)

Measured memory_bytes: 69596
n=int(input())
b=list(map(int,input().split()))
a=[]
f=0
for _ in range(n):
  for i in range(len(b)-1,-1,-1):
    if b[i]==i+1:
      a.append(b.pop(i))
      break
    if i==0:
      f=1
if f==0:
  for i in range(n-1,-1,-1):
    print(a[i])
else:
  print(-1)

Measured memory_bytes: 3064
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	string str;
	cin >> str;
	int ans = 0;
	for (int i = 1; i < n; i++)
	{
		string s1 = str.substr(0, i);
		string s2 = str.substr(i);
		int cnt = 0;
		for (int c = 'a'; c <= 'z'; c++)
		{
			if (count(s1.begin(), s1.end(), c) && count(s2.begin(), s2.end(), c))
				cnt++;
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=2e5+20;

#define pii pair<int,int>

int nxt[maxn],lst[maxn];

int val[maxn],lf[maxn],rf[maxn],vis[maxn],L,tag[maxn];
int n;

priority_queue<pii,vector<pii>,greater<pii> >q;

inline void init()
{
	n=read();L=read();
	REP(i,1,n)val[i]=read();
	REP(i,1,n+1)lst[i]=i-1,nxt[i-1]=i,lf[i]=rf[i]=1;
	REP(i,1,n)q.push(mkr(val[i],i));
}

ll ans;

inline void doing()
{
	while(!q.empty())
	{
		static int st[maxn],top; top=0;
		static int Lf[maxn],Rf[maxn];
		int u=q.top().se,VAL=val[u];
		for(int i=u;i<=n && val[i]==val[u];i=nxt[i])
			st[++top]=i,tag[i]=1;
		while(!q.empty() && tag[q.top().se])q.pop();
		ll sumlf=0;
		int j=1,Lst=0;
		REP(i,1,top)if(!vis[st[i]])ans++;
		REP(i,1,top)
		{
			if(!vis[st[i]])Lst=i;
			while(j<=Lst && j<=i-L+1)
				sumlf+=lf[st[j++]];
			ans+=sumlf*rf[st[i]];
		}
		int num=top/L;
		if(num)
		{
			REP(i,1,num)
			{
				Rf[i]=0;
				REP(j,L*i,min(L*i+L-1,top))Rf[i]+=rf[st[j]];
			}
			REP(i,1,num)
			{
				Lf[num-i+1]=0;
				DREP(j,top-L*i+1,max(top-L*i-L+2,1))Lf[num-i+1]+=lf[st[j]];
			}
			nxt[st[num]]=nxt[st[top]];
			lst[nxt[st[top]]]=st[num];
			REP(j,1,num)tag[st[j]]=0,vis[st[j]]=1,val[st[j]]=VAL+1,lf[st[j]]=Lf[j],rf[st[j]]=Rf[j],q.push(mkr(VAL+1,st[j]));
		}else nxt[lst[st[1]]]=n+1;
	}
	printf("%lld\n",ans);
}

int main()
{
	init();
	doing();
	return 0;
}


Measured memory_bytes: 8560
/*
    AUTHOR:hruday pabbisetty
    NIT ROURKElA
*/
#include <bits/stdc++.h>
#include <tr1/unordered_map>
using namespace std;
using namespace std::tr1;
#define opt ios_base::sync_with_stdio(0)
#define lli long long int
#define ulli unsigned long long int
#define I int
#define S string
#define D double
#define rep(i,a,b) for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define in(n) scanf("%lld",&n)
#define in2(a,b) scanf("%lld %lld",&a,&b)
#define in3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define out(n) printf("%lld\n",n)
#define inu(a) scanf("%lld",&a)
#define outu(a) printf("%llu",a)
#define ins(s) scanf("%s",&s)
#define outs(s) printf("%s",s)
#define mod 1000000007
#define inf 100000000000000
typedef long long       ll;
typedef pair<lli,lli>  plli;
typedef vector<lli>     vlli;
typedef vector<ulli>    vulli;
typedef vector<ll>      vll;
typedef vector<string>  vs;
typedef vector<plli>     vplli;
#define MM(a,x)  memset(a,x,sizeof(a));
#define ALL(x)   (x).begin(), (x).end()
#define P(x)       cerr<<"{"#x<<" = "<<(x)<<"}"<<endl;
#define P2(x,y)       cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<"}"<<endl;
#define P3(x,y,z)  cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<"}"<<endl;
#define P4(x,y,z,w)cerr<<"{"#x" = "<<(x)<<", "#y" = "<<(y)<<", "#z" = "<<(z)<<", "#w" = "<<(w)<<"}"<<endl;
#define PP(x,i)     cerr<<"{"#x"["<<i<<"] = "<<x[i]<<"}"<<endl;
#define TM(a,b)     cerr<<"{"#a" -> "#b": "<<1000*(b-a)/CLOCKS_PER_SEC<<"ms}\n";
#define UN(v)    sort(ALL(v)), v.resize(unique(ALL(v))-v.begin())
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define sz() size()
#define nl cout<<"\n"
#define MX1 100005
#define MX2 1000005
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
lli dx[]={0,0,-1,1,-1,-1,1,1};
lli dy[]={1,-1,0,0,1,-1,-1,1};
lli power(lli a,lli b)
    {
    lli value;
    if(b==0)
        {
        return 1;
    }
    else if(b%2==0)
        {
        value=power(a,b/2)%mod;
        return(value*value)%mod;
    }
    else
        {
        value=power(a,b/2)%mod;
        return ((a*value)%mod*(value))%mod;
    }
}
int main()
{
      /*  #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
        #endif*/
    opt;
    lli a[26]={0},b[26]={0},i;
    string s,t;
    cin>>s>>t;
    sort(ALL(s));
    sort(ALL(t));
    reverse(ALL(t));
    if(s<t)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}


Measured memory_bytes: 256
N = int(input())
num = [0]*N
for i in range(1,10**2 + 1):
    for j in range(1,10**2 + 1):
        for k in range(1,10**2 + 1):
            ans = i**2 + j**2 + k**2 + i*j + j*k + k*i
            if ans <= N:
                num[ans - 1] += 1
for i in range(N):
    print(num[i])


Measured memory_bytes: 9372
n = gets.to_i
as = gets.split.map(&:to_i).sort

nums = Hash.new(0)
ans = Array.new(as.last + 1, 0)
res = 0

as.each do |a|
  nums[a] += 1
  ans[a] = 1
end

as.each do |a|
  next if ans[a] == 0
 
  res += 1 if nums[a] == 1
 
  a.step(as.last, a) do |i|
    ans[i] = 0
  end
end
p res

Measured memory_bytes: 46376
using System;

class Program
{
    static void Main(string[] args)
    {
        var nm = Console.ReadLine().Split(' ');
        var n = int.Parse(nm[0]);
        var m = int.Parse(nm[1]);

        var a = new int[n];
        var b = new int[n];
        for (int i = 0; i < n; i++)
        {
            var ab = Console.ReadLine().Split(' ');
            a[i] = int.Parse(ab[0]);
            b[i] = int.Parse(ab[1]);
        }

        var min = int.MaxValue;

        for (int i = 0; i < n; i++)
        {
            if (b[i] <= m)
            {
                min = Math.Min(min, a[i]);
            }
        }

        if (min != int.MaxValue) Console.WriteLine(min);
        else Console.WriteLine("TLE");
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  ll n,k;
  cin >> n >> k;
  if(n<=k){cout<<0<<endl;return 0;}
  vector<ll> a(n);
  rep(i,n){ cin>>a[i]; }
  sort(a.begin(),a.end());
  ll sum=accumulate(a.begin(),a.end()-k,0LL);
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
class Program {
    
    static Scanner cin = new Scanner();
    static void Main() {
        int x = cin.Int();
        int y = cin.Int();

        if(Math.Abs(x) < Math.Abs(y)) {
            if(y > 0) {
                if (x >= 0) Console.WriteLine(y - x);
                else Console.WriteLine(1 + y - (-x));
            }
            else {
                if (x >= 0) Console.WriteLine(1 + (-y) - x);
                else Console.WriteLine(1 + (-y) - (-x) + 1);
            }
        }
        else {
            if(y > 0) {
                if (x >= 0) Console.WriteLine(1 + (-y) - (-x) + 1);
                else Console.WriteLine((-y) - x + 1);
            }
            else if(y == 0) {
                if (x >= 0) Console.WriteLine(1 + x);
                else Console.WriteLine(-x);
            }
            else {
                if (x >= 0) Console.WriteLine(1 + y - (-x));
                else Console.WriteLine(y - x);
            }
        }
        Console.ReadLine();
    }
}

Measured memory_bytes: 11220
n = int(input())
l = [[] for i in range(n)]

for i in range(n):
    a = int(input())
    for j in range(a):
        x, y = map(int, input().split())
        l[i].append([x, y])

ans = 0

for b in range(1 << n): # 正直者か不親切か全ての設定パターンを作る。
    cnt = bin(b).count("1")
    judge = True
    for j in range(n):
        if judge == False: #矛盾があれば、ループを止める。
            break
        if b & (1 << j) != 0: # j番目の人が正直者設定なら進む。
            for x, y in l[j]:
                if y == 1 and b & (1 << x - 1) == 0: # 証言:正直者、設定:不親切の場合
                    judge = False
                if y == 0 and b & (1 << x - 1) != 0: # 証言:不親切、設定:正直者の場合
                    judge = False
    if judge == True:
        ans = max(cnt, ans)
print(ans)

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main(){
	int a[3][3];
	for(int i=0 ;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>a[i][j];
		}
	}
	int n;
	cin>>n;
	int b[n];
	for(int i=0 ;i<n;i++){
		cin>>b[i];
	}
	bool c[3][3];
	for(int i=0 ;i<n ;i++){
		for(int j=0 ;j<n ;j++){
			c[i][j] = false;
			for(int k=0 ;k<n;k++){
				if(a[i][j]==b[k]){
					c[i][j]=true;
				}
			}
		}
	}
	string res = "No";
	for(int i=0 ;i<n;i++){
		if(c[i][0] && c[i][1] && c[i][2])
			res = "Yes";
	}
	for(int i=0 ;i<n;i++){
		if(c[0][i] && c[1][i] && c[2][i])
			res = "Yes";
	}
	if(c[0][0] && c[1][1] && c[2][2])
		res = "Yes";
	if(c[0][2] && c[1][1] && c[2][0])
		res = "Yes";
	cout<<res;
	return 0;

}

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

int main() {
  int n;
  cin >> n;
  vector<int> c(n), v(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> c.at(i);
  }
  int sum=0;
  for (int i = 0; i < n; i++) {
    if (v.at(i) > c.at(i)) {
      sum += v.at(i) - c.at(i);
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  
  int s,x,sum=0;
  scanf("%d",&s);
  x = s;
  while(x>=1){
    sum+=x%10;
    x/=10;
  }
  if(s%sum==0){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return(0);
}

Measured memory_bytes: 128
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll MOD=(ll)1e9+7;
//}}}

int main(){
  ll N, K;
  cin >> N >> K;
  ll ans;
  if(K % 2){
    ans = N / K;
    ans = ans * ans * ans;
  }else{
    ans = N / K;
    ans = ans * ans * ans;
    ll ans2 = (N + K / 2) / K;
    ans2 = ans2 * ans2 * ans2;
    ans += ans2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N, M, X = map(int, input().split())
L = list()
INF = float('INF')
ans = INF
for i in range(N):
  L.append(list(map(int, input().split())))
for i in range(1<<N):
  a = [0]*M
  flag = 1
  check = list()
  cost = 0
  for j in range(N):
    if i&(1<<j):
      check.append(j)
  for j in check:
    cost += L[j][0]
    for m in range(M):
      a[m] += L[j][m+1]
  for i in range(M):
    if(a[i] < X):
      flag = 0
  if(flag == 1):
    ans = min(ans, cost)
if(ans == INF):
  print(-1)
else:
  print(ans)

Measured memory_bytes: 68488
#include<string>
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<chrono>
#include<functional>
#include<random>
#include<unordered_set>
using namespace std;
typedef long long int llint;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
const llint mod=1000000007;
const llint big=1e9+10;
const long double pai=3.141592653589793238462643383279;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(b==0){return a;}return gcd(b,a%b);}//a>b
llint lcm(llint a,llint b){return (a/gcd(max(a,b),min(a,b)))*b;}
int main(void){
	string s;cin>>s;
	int i,n,k;cin>>k;
	for(i=0;i<s.size();i++){
		int it;if(s[i]=='a'){it=0;}
		else{it=26-s[i]+'a';}
		if(it<=k){k-=it;s[i]='a';}
	}
	s.back()+=k%26;
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    int N,a,b;
    scanf("%d",&N);
    for(a=1;a<=9;a++)
    {
        if(N%a==0)
        {
            b=N/a;
        }
    }
    if(b>=1&&b<=9)
    {
        printf("Yes");
    }
    else
    printf("No");
    return 0;
}

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const ll INF = 1e18;

int main() {


    int D;
    cin >> D;

    if(D==22){
        cout << "Christmas Eve Eve Eve" << endl;
    }else if(D==23){
        cout << "Christmas Eve Eve" << endl;
    }else if(D==24){
        cout << "Christmas Eve" << endl;
    }else{
        cout << "Christmas" << endl;
    }


}
/*
みんな、くるくるぱーにな〜れ
　∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/



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

int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    while(true){
        if (A == C && B == D){
            cout << "Yes" << endl;
            break;
        }
        C -= B;
        if (C <= 0){
            cout << "Yes" << endl;
            break;
        }
        A -= D;
        if (A <= 0){
            cout << "No" << endl;
            break;
        }
    }
}

Measured memory_bytes: 3628
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <cstdio>
//#include <iomanip>//"cout<<fixed<<setprecision(n)<<sth<<endl;"
//#include <string>//"reverse(s's it,s's it)"
//#include <functional>//"greater<T>" "sort(a,a+n,greater<int>());""
//#include <cmath>//"abs" "sqrt"
//#include <numeric>//"accumulate(inputit,inputit,init,(optional) object)"
//#include <algorithm>//"lower_bound(it,it,v)" "next_permutation(a,a+n)"
//"reverse(v's it,v's it)"(v: vector)
using namespace std;
#define pb push_back
#define fi first
#define sc second
#define mp make_pair
#define is insert
#define ps push//TMP//stack,(priority) queue,
#define fr front//TMP//queue//for priority, use top().

struct seg{
	int l,r,id;
};

const int inf=1000000001;

void solve(int q){
	list<seg> l;
	l.pb((seg){0,inf,-1});
	while((q--)>0){
		char C;
		cin>>C;
		if(C=='W'){
			int i,s;
			cin>>i>>s;
			for(list<seg>::iterator it=l.begin();it!=l.end();++it) if((*it).id==-1){
				(*it).id=i;
				if((*it).r-(*it).l>=s){
					if((*it).r-(*it).l>s){
						list<seg>::iterator nit=it;
						++nit;
						l.is(nit,(seg){(*it).l+s,(*it).r,-1});
						(*it).r=(*it).l+s;
					}
					break;
				}else s-=((*it).r-(*it).l);
			}
		}else if(C=='D'){
			int i;
			cin>>i;
			for(list<seg>::iterator it=l.begin();it!=l.end();++it) if((*it).id==i) (*it).id=-1;			
		}else{//if(C=='R')
			int p;
			cin>>p;
//			for(list<seg>::iterator it=l.begin();it!=l.end();++it){
//				cout<<"segment: from "<<(*it).l<<" to "<<(*it).r<<", id: "<<(*it).id<<endl;
//			}
			for(list<seg>::iterator it=l.begin();it!=l.end();++it) if((*it).r>p){
				cout<<(*it).id<<endl;
				break;
			}
		}
	}
	cout<<endl;
}

int main(){
	while(true){
		int q;
		cin>>q;
		if(q>0) solve(q);
		else break;
	}		
}

Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
int main() {

        int n;
        cin >> n;
        double arr[n];
        double ans = 0.0D;
        for(int i = 0;i < n;++i){
            cin >> arr[i];
            ans += (1.0D/arr[i]);
        }
        sort(arr,arr+n);
        cout << (1.0/ans) << endl;
}


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

namespace AtCoder.Abc
{
    class QuestionC
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            long a = inputLongArray[0];
            long b = inputLongArray[1];

            for (long x = 0; x < 15000; x++)
            {
                var y10 = (int)(x * 0.1);
                var y8 = (int)(x * 0.08);
                if (y8 == a && y10 == b)
                {
                    Console.WriteLine(x);
                    Console.Out.Flush();
                    return;
                }
            }

            Console.WriteLine(-1);
            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13396
def main():
    import sys
    import bisect

    read = sys.stdin.buffer.read
    bisect_right = bisect.bisect_right

    N, *A = map(int, read().split())

    dp = [A[-1]]
    for a in reversed(A[:-1]):
        if a >= dp[-1]:
            dp.append(a)
        else:
            dp[bisect_right(dp, a)] = a

    print(len(dp))
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 12528
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

int d[100];
vector<int> adj[100];

void bfs(int n, int start) {
	queue<int> que;

	for (int i = 0; i < n; i++)
		d[i] = (i == start ? 0 : -1);

	que.push(start);
	while(!que.empty()) {
		int from = que.front();
		que.pop();

		for (int i = 0; i < adj[from].size(); i++) {
			int to = adj[from][i];
			if (d[to] == -1) {
				d[to] = d[from] + 1;
				que.push(to);
			}
		}
	}
}

int main() {
	int n;

	cin >> n;

	for (int i = 0; i < n; i++) {
		int u, k;
		cin >> u >> k;
		while (k--) {
			int v;
			cin >> v;
			adj[u - 1].push_back(v - 1);
		}
	}

	bfs(n, 0);

	for (int i = 0; i < n; i++)
		cout << i + 1 << " " << d[i] << endl;

	return 0;
}

Measured memory_bytes: 1228
a, b, c, d = gets.split.map(&:to_i)

divc = (b - a + 1) / c
if a <= (divc + 1 + (a-1) / c) * c && (divc + 1 + (a-1) / c) * c <= b
  divc += 1
end

divd = (b - a + 1) / d
if a <= (divd + 1 + (a-1) / d) * d && (divd + 1 + (a-1) / d) * d <= b
  divd += 1
end

lcmcd = c.lcm(d)
divcd = (b - a + 1) / lcmcd
if a <= (divcd + 1 + (a-1) / lcmcd) * lcmcd && (divcd + 1 + (a-1) / lcmcd) * lcmcd <= b
  divcd += 1
end

puts (b - a + 1) - divc - divd + divcd

Measured memory_bytes: 1788
/*input
async layered coding
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
string s[]={"Even","Odd"};
int main()
{
	IOS;
	int a,b;
	cin>>a>>b;
	cout<<s[a*b%2];
	return 0;
}


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

typedef long long ll;
#define pb push_back
#define ii pair<int ,int >
#define vi vector<int >
#define vii vector < pair<int ,int > >
#define IO ios::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define IOfiles freopen("input.txt","r+",stdin) ; freopen("output.txt","w+",stdout)
#define PI 3.14159265
const double eps = 1e-9;


int main()
{
	IO;
	ll n,k;
	cin>>n>>k;
	ll ans;
	if(n>k){
		ans=min(n%k,k-n%k);
	}
	else ans=min(n,k-n);
	cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <stdio.h>
int gcd(int x, int y) {
	int r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
}
int main() {
	int n, a[100000], ans;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	ans = a[0];
	for (int i = 1; i < n; i++) {
		ans = gcd(ans, a[i]);
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;
  cin>>n;
  vector<tuple<int,int>> vt;
  REP(i,n) {
    int a;
    cin>>a;
    int sft = 0;
    while (a < (1 << 29)) {
      a <<= 1;
      --sft;
    }
    vt.emplace_back(sft, a);
  }
  vecll neg(n+1), pos(n+1);
  ll sum = 1;
  stack<int> pending;
  REP(i,n*30) pending.push(-1);
  REP(i,n-1) {
    neg[i+1] = sum;
    int li,lx,ri,rx;
    tie(li,lx) = vt[i];
    tie(ri,rx) = vt[i+1];
    int sft2 = 0;
    while (tie(li,lx) < tie(ri,rx)) {
      li += 2;
      ++sft2;
    }
    while (sft2) {
      sum += 2 * (i - pending.top());
      pending.pop();
      --sft2;
    }
    while (make_pair(li,lx) >= make_pair(ri+2,rx)) {
      ri += 2;
      pending.push(i);
    }
    ++sum;
  }
  neg[n] = sum;
  sum = 0;
  while (!pending.empty()) pending.pop();
  REP(i,n*30) pending.push(n);
  pos[n-1] = sum;
  for (int i = n-1; i > 0; --i) {
    int li,lx,ri,rx;
    tie(li,lx) = vt[i-1];
    tie(ri,rx) = vt[i];
    int sft2 = 0;
    while (tie(li,lx) > tie(ri,rx)) {
      ri += 2;
      ++sft2;
    }
    while (sft2) {
      sum += 2 * (pending.top() - i);
      pending.pop();
      --sft2;
    }
    while (make_pair(li+2,lx) <= make_pair(ri,rx)) {
      li += 2;
      pending.push(i);
    }
    pos[i-1] = sum;
  }
  ll ans = 2*n*n;
  REP(i,n+1) {
    ans = min(ans, neg[i] + pos[i]);
  }
  cout<<ans<<"\n";
  return 0;
}


Measured memory_bytes: 29552
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define gc getchar()
#define pc(x) putchar(x)
template<typename T> void scan(T &x){x = 0;bool _=0;T c=gc;_=c==45;c=_?gc:c;while(c<48||c>57)c=gc;for(;c<48||c>57;c=gc);for(;c>47&&c<58;c=gc)x=(x<<3)+(x<<1)+(c&15);x=_?-x:x;}
template<typename T> void printn(T n){bool _=0;_=n<0;n=_?-n:n;char snum[65];int i=0;do{snum[i++]=char(n%10+48);n/= 10;}while(n);--i;if (_)pc(45);while(i>=0)pc(snum[i--]);}
template<typename First, typename ... Ints> void scan(First &arg, Ints&... rest){scan(arg);scan(rest...);}
template<typename T> void print(T n){printn(n);pc(10);}
template<typename First, typename ... Ints> void print(First arg, Ints... rest){printn(arg);pc(32);print(rest...);}

#define lc (rt<<1)
#define rc (rt<<1|1)
#define nm ((nl+nr)>>1)

using namespace std;
using T = pair<int, int>;
using L = int;
const int MM = 2e5+5;

int n, m, a[MM], b[MM];

const T DEF = {-1e8, 1e8};
const L DEFL = 1e8;

struct node{
	T val; L lp;
	inline void apply(L v, int nl, int nr){
		if(v == DEFL) return;
		val.first = v; //starting
		val.second = nl-v; //dis to travel
		lp = v;
	}
};

struct segtree{
	node tree[MM*4];
	int LS, RS;
	
	inline T merge(T va, T vb){
		return {max(va.first, vb.first), min(va.second, vb.second)};
	}
	inline void pull(int rt){
		tree[rt].val = merge(tree[lc].val, tree[rc].val);
	}
	inline void push(int rt, int nl, int nr){ // node with lazy val means yet to push to children (but updated itself)
		if(nl == nr) return;
		L &val = tree[rt].lp; tree[lc].apply(val, nl, nm); tree[rc].apply(val, nm+1, nr); val = DEFL;
	}
	
	void build(int _LS, int _RS){ build(LS = _LS, RS = _RS, 1);} void build(int nl, int nr, int rt){
		tree[rt].val = DEF;
		tree[rt].lp = DEFL;
		if(nl == nr){
			tree[rt].val = {nl, 0};
			return;
		}
		build(nl, nm, lc); build(nm+1, nr, rc); pull(rt);
	}
	
	void update(int l, int r, L val){ update(l, r, val, LS, RS, 1);} void update(int l, int r, L val, int nl, int nr, int rt){
		if(r < nl || l > nr) return;
		if(l <= nl && r >= nr){
			tree[rt].apply(val, nl, nr);
			return;
		}
		push(rt, nl, nr); update(l, r, val, nl, nm, lc); update(l, r, val, nm+1, nr, rc); pull(rt);
	}
	
	T query(int l, int r){ return query(l, r, LS, RS, 1);} T query(int l, int r, int nl, int nr, int rt){
		if(r < nl || l > nr) return DEF;
		if(l <= nl && r >= nr) return tree[rt].val;
		push(rt, nl, nr); return merge(query(l, r, nl, nm, lc), query(l, r, nm+1, nr, rc));
	}
} ST;

int main(){
	scan(n, m);
	ST.build(0, m-1);

	for(int i = 1; i <= n; i++){
		scan(a[i], b[i]);
		a[i]--, b[i]--;

		auto res = ST.query(0, a[i]-1);
		//latest starting possible, but force to be <= res.first
		ST.update(a[i], b[i], res.first);
		// print(res.first);

		res = ST.query(0, m-1);

		if(res.second <= m)
			print(res.second+i);
		else
			print(-1);
	}
}

Measured memory_bytes: 14484
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int q = sc.nextInt();
		String s = sc.next();
		String[] t = new String[q];
		String[] d = new String[q];
		for (int i = 0; i < q; i++) {
			t[i] = sc.next();
			d[i] = sc.next();
		}
		sc.close();

		int left = binarySearchLeft(s, t, d);
		int right = binarySearchRight(s, t, d);
		System.out.println(right - left - 1);
	}

	static int binarySearchLeft(String s, String[] t, String[] d) {
		int start = -1;
		int end = s.length();

		while (Math.abs(end - start) > 1) {
			int mid = (end + start) / 2;
			if (isDeadLeft(s, mid, t, d)) {
				start = mid;
			} else {
				end = mid;
			}
		}
		return start;
	}

	static int binarySearchRight(String s, String[] t, String[] d) {
		int start = -1;
		int end = s.length();

		while (Math.abs(end - start) > 1) {
			int mid = (end + start) / 2;
			if (isDeadRight(s, mid, t, d)) {
				end = mid;
			} else {
				start = mid;
			}
		}
		return end;
	}

	static boolean isDeadLeft(String s, int idx, String[] t, String[] d) {
		for (int i = 0; i < t.length; i++) {
			if (t[i].equals(s.substring(idx, idx + 1))) {
				if ("L".equals(d[i])) {
					idx--;
				} else {
					idx++;
				}
			}
			if (idx < 0) {
				return true;
			}
			if (s.length() <= idx) {
				return false;
			}
		}
		return false;
	}

	static boolean isDeadRight(String s, int idx, String[] t, String[] d) {
		for (int i = 0; i < t.length; i++) {
			if (t[i].equals(s.substring(idx, idx + 1))) {
				if ("L".equals(d[i])) {
					idx--;
				} else {
					idx++;
				}
			}
			if (idx < 0) {
				return false;
			}
			if (s.length() <= idx) {
				return true;
			}
		}
		return false;
	}
}


Measured memory_bytes: 184868
#include <bits/stdc++.h>
#define int long long
using namespace std;

int n, m, black = 0, white = 0, color[100001];
bool visited[100001];
vector <int> adj[100001];
bool haichieu = 1;

void dfs(int v, int c) {
    for(auto u : adj[v]) {
        if(color[u] != -1) {
            if(color[u] != c) {
                haichieu = 0;
            }
        } 
        color[u] = c;
    }
    for(auto u : adj[v]) {
        if(!visited[u]) {
            visited[u] = 1;
            dfs(u, 1 - c);
        }
    }
}

signed main() {
    cin >> n >> m;
    for(int i = 1, u, v; i <= m; i++) {
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    memset(color, -1, sizeof color);
    color[1] = 0;
    visited[1] = 1;
    dfs(1, 1);
    if(!haichieu) {
        return cout << (n * (n - 1)) / 2 - m << '\n', 0;
    }
    for(int i = 1; i <= n; i++) {
        if(color[i] == 1) {
            black++;
        } else if(color[i] == 0) {
            white++;
        }
    }
    cout << black * white - m << '\n';
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

int p[N], sz[N];

int find(int x) {
  if (x == p[x]) {
    return x;
  }
  return p[x] = find(p[x]);
}

void unite(int a, int b) {
  a = find(a);
  b = find(b);
  if (a != b) {
    p[b] = a;
    sz[a] += sz[b];
  }
}

void solve(int) {
  cin >> n >> m >> k;
  for (int i = 0; i < n; ++i) {
    p[i] = i;
    sz[i] = 1;
  }
  vector<int> ans(n);
  for (int i = 0; i < m; ++i) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    unite(x, y);
    --ans[x];
    --ans[y];
  }
  for (int i = 0; i < k; ++i) {
    int x, y;
    cin >> x >> y;
    --x; --y;
    if (find(x) == find(y)) {
      --ans[x];
      --ans[y];
    }
  }
  for (int i = 0; i < n; ++i) {
    cout << ans[i] + sz[find(i)] - 1 << ' ';
  }
  cout << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}



Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define lli long long int
using namespace std;

int main() 
{
	lli n;
	cin >> n;
	unordered_map<lli, lli> mp;
	lli a[n], sum = 0;
	for(lli i=0;i<n;i++)
	{
		cin >> a[i];
		mp[a[i]] += 1;
		sum += a[i];
	}
	lli q, l, r;
	cin >> q;
	while(q--)
	{
		cin >> l >> r;
		if(mp[l]>0)
		{
			lli cnt = mp[l];
			mp[l] = 0;
			if(cnt>0)
				mp[r] += cnt;
			sum = sum - l*cnt + r*cnt;
		}
			cout << sum << endl;
	}
	return 0;
}
   








Measured memory_bytes: 7648
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N; cin >> N;
  vector<pair<int, int>> dist(N);
  for(int i = 0; i < N; i++) cin >> dist.at(i).first >> dist.at(i).second;
  cout << setprecision(16);
  vector<int> town(N);
  for(int i = 0; i < N; i++) town.at(i) = i;
  double d = 0;
  sort(town.begin(), town.end());
  do {
    for(int i = 1; i < N; i++) {
      long x = pow(abs(dist.at(town.at(i - 1)).first - dist.at(town.at(i)).first), 2);
      long y = pow(abs(dist.at(town.at(i - 1)).second - dist.at(town.at(i)).second), 2);
      double z = sqrt(x + y);
      d += z;
    }
  } while(next_permutation(town.begin(), town.end()));
  int kai = 1;
  for(int i = 1; i <= N; i++) kai *= i;
  d /= kai;
  cout << d << endl;
}

Measured memory_bytes: 256
from itertools import permutations

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
i = j = -1
cur = 0
for c in permutations(range(1, n + 1)):
    c = list(c)
    if c == b: j = cur
    if c == a: i = cur
    cur += 1
print(abs(j - i))

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

using namespace std ;

int arr[3210] ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	int n ;
	cin>>n ;
	int cnt = 0 ;
	for(int i = 0 ; i < n ; ++i)
	{
		int x ;
		cin>>x ;
		if(x >= 3200)
			cnt++ ;
		else
		{
			int prv = x - (x % 400) ;
			if(prv < 400)
				prv = 1 ;
			arr[prv]++ ; 
		}
	}
	int ans1 = 0 , ans2 = 0 ;
	int now = 1-400 ;
	if(cnt == n)
		ans1 = 1 ;
	for(int i = 1 ; ; ++i)
	{
		now += 400 ;
		if(now % 400 != 0 && now != 1)
			now-- ;
		if(now == 3200)
			break ;
		if(arr[now])
			ans1++ , ans2++ ;
	}
	return cout<<ans1<<" "<<ans2+cnt<<"\n" , 0 ;
}

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

int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> p(n);
  vector<pair<pair<string,int>,int>> t(n);
  for(int i=0;i<n;i++){
    cin >> s[i] >> p[i];
  }
  for(int i=0;i<n;i++){
    t[i]=make_pair(make_pair(s[i],p[i]*(-1)),i);
  }
  sort(t.begin(),t.end());
  for(int i=0;i<n;i++){
    cout << t[i].second+1 << endl;
  }
  
}

Measured memory_bytes: 256
#include <iostream>

int main()
{
  int c[3][3];
  for ( int i = 0; i < 3; i++ ) {
    for ( int j = 0; j < 3; j++ ) {
      std::cin >> c[i][j];
    }
  }

  bool can = true;
  for ( int i = 0; i < 2; i++ ) {
    for ( int j = 0; j < 2; j++ ) {
      if (c[j+1][i+1] - c[j][i+1] != c[j+1][i] - c[j][i]) {
        can = false;
      }
    }
  }
  for ( int i = 0; i < 2; i++ ) {
    for ( int j = 0; j < 2; j++ ) {
      if (c[j+1][i+1] - c[j+1][i] != c[j+1][i+1] - c[j+1][i]) {
        can = false;
      }
    }
  }

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


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a, b;
	scanf("%d %d", &a, &b);
	if (a > b) {
		printf("a > b\n");
	}
	if (a < b) {
		printf("a < b\n");
	}
	
	if (a == b) {
		printf("a == b\n");
	}
	return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,W;
    cin >> N >> W;
    vec<int> v(N),w(N),m(N);
    for(int i=0;i<N;i++) cin >> v[i] >> w[i] >> m[i];

    vec<int> dp(W+1,0);
    for(int i=0;i<N;i++){
        int res = m[i];
        for(int k=1;res>0;k<<=1){
            int now = min(res,k);
            for(int j=W;j>=0;j--){
                if(j-now*w[i]>=0) dp[j] = max(dp[j],dp[j-now*w[i]]+now*v[i]);
            }
            res -= now;
        }
    }
    int ans = 0;
    for(int j=0;j<=W;j++) ans = max(ans,dp[j]);
    cout << ans << endl;
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define SANKOU(n, a, b) cout << ((n) ? (#a) : (#b)) << endl
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
int N, K;
int u, d;
void solve()
{
    int t[20] = {1};
    for (int i = 1; i < 20; i++) {
        t[i] = 2 * t[i - 1];
    }
    int w = 0;
    for (int i = 1; i < K; i *= 2) {
        w++;
    }

    d = N * t[w];

    for (int i = 1; i <= N; i++) {
        for (int j = 0; j < 20; j++) {
            if (t[j] * i >= K) {
                u += t[w - j];
                break;
            }
        }
    }


    cout << fixed << setprecision(13) << u / (double)d << endl;
}

signed main()
{
    cin >> N >> K;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	int n, k; scanf("%d%d", &n, &k);
	std::vector<int> cnt(n, 0);
	for(int i = 0; i < k; i++) {
		int d; scanf("%d", &d);
		
		while(d--) {
			int p; scanf("%d", &p);

			cnt[p - 1] |= 1;
		}
	}

	printf("%d\n", n - std::accumulate(begin(cnt), end(cnt), 0));
	return 0;
}


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

int gcd(int x,int y){
    if(x == 0 || y == 0) return x+y;
    else return gcd(y,x%y);
}

int main(){
    ll A,B; cin >> A >> B;
    ll ans = A*B/gcd(A,B);
    cout << ans << endl;
}

Measured memory_bytes: 256