akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define sz(a) int(a.size())
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
signed main()
{
	int a,b,c;
	cin>>a>>b>>c;
	cout<<( a+b+c - max(a , max(b , c)) );
	re 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

string s5[2];
string s[5];
string bar;

const int FIVE = 0, N = 5;

int main()
{
    int n, k;
    bool sec = false;
    bar = "=====";

    while(cin >> n)
    {
        REP(5) s[i] = "*****";
        REP(2) s5[i] = "*****";
        REP(5)
        {
            k = n % 10;
            if(k >= 5) { s5[FIVE][N - i - 1] = ' '; k -= 5;}
            else {s5[!FIVE][N - i - 1] = ' ';}

            s[k][N - i - 1] = ' ';
            
            n = n / 10;
        }
        if(sec) cout << endl;

        REP(2) cout << s5[i] << endl;
        cout << bar << endl;
        REP(5) cout << s[i] << endl;
        sec = true;

    }
    return 0;
}

Measured memory_bytes: 904
//https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_d
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
    ll N; cin>>N;
    string S; cin>>S;
    vector<ll> tbl;
    for(auto& s:S){
        tbl.push_back(s-'0');
    }
    ll ans=0;
    set<ll> v0;
    for(ll l=0; l<N-2;++l){
        auto lval=tbl.at(l);
        if(v0.count(lval)!=0) continue;

        set<ll> v2;
        for(ll r=N-1;l+1<r;--r){
            auto rval=tbl.at(r);
            if(v2.count(rval)!=0) continue;

            set<ll> v1;
            for(ll mid=l+1;mid<r;++mid){
                auto mval=tbl.at(mid);
                if(v1.count(mval)==0) ++ans;
                v1.insert(tbl.at(mid));
            }
            v2.insert(tbl.at(r));
        }
        v0.insert(tbl.at(l));
    }
    cout<<ans<<endl;
    return 0;
}

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

#define MOD 1000000007

typedef long long int ll;

using namespace std;

vector<ll> INV;
vector<ll> FACT;
vector<ll> FACT_INV;


ll inv_mod(ll x, int mod){
  return mod - (mod / x) * INV[mod%x] % mod;
}

ll sub_mod(ll x, ll y, int mod){
  return (x - y + MOD) % MOD;
}

ll mul_mod(ll x, ll y, int mod){
  return x * y % mod;
}

int comb_mod(int n, int k, int mod){
  if(n < k){
    return 0;
  }else{
    return mul_mod(mul_mod(FACT[n], FACT_INV[k], mod), FACT_INV[n-k], mod);
  }
}


int main(void){

  int n;
  cin >> n;

  vector<int> a(n+1);
  vector<int> i_first(n, -1);
  int l;
  for(int i = 0; i < n + 1; ++i){
    cin >> a[i];
    if(i_first[a[i]-1] < 0){
      i_first[a[i]-1] = i;
    }else{
      l = i_first[a[i]-1] + n - i;
    }
  }

  INV = vector<ll>(n+2, 1);
  for(int i = 2; i < n + 2; ++i){
    INV[i] = inv_mod(i, MOD);
  }

  FACT = vector<ll>(n+2, 1);
  FACT_INV = vector<ll>(n+2, 1);
  for(int i = 1; i < n + 2; ++i){
    FACT[i] = mul_mod(FACT[i-1], i, MOD);
    FACT_INV[i] = mul_mod(FACT_INV[i-1], INV[i], MOD);
  }

  for(int k = 1; k <= n + 1; ++k){
    int answer = sub_mod(comb_mod(n+1, k, MOD), comb_mod(l, k-1, MOD), MOD);
    cout << answer << endl;
  }
  
  return 0;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,T;
    cin >> n >> T;
    ll ans = 0;
    ll pre = 0;
    ll saki = 0;
    rep(i,n){
        ll t;
        cin >> t;
        if(t <= saki) saki = t + T;
        else{
            ans += saki - pre;
            pre = t;
            saki = t + T;
        }
    }
    ans += saki - pre;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3500
# -*- coding: utf-8 -*-

def solve(l1):

    l = [int(e) for e in l1.split(" ")]
    a = l[0]
    b = l[1]

    result = 0
    if b % a == 0:
        result = a + b
    else:
        result = b - a


    return str(result)

def main():
    # 出力
    params = []
    for i in range(0, 1):
        params.append(input())   
    print(solve(*params))

if __name__ == '__main__':

    main()


Measured memory_bytes: 3060
//
#include <vector>
#include <set>
#include <map>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <numeric>
#include <bitset>
#include <iomanip>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);++i)
#define outD(fpv) cout << setprecision(20) << fpv << endl;
inline void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
inline void YES(bool cond) { cond ? puts("YES") : puts("NO"); }
template<typename Type> inline void chmin(Type& a, Type b) { if (a > b) a = b; }
template<typename Type> inline void chmax(Type& a, Type b) { if (a < b) a = b; }
template<typename Arr, typename Type> inline void fill(Arr& arr, Type v) { std::fill(arr.begin(), arr.end(), v); }
template<typename Type> inline void sort(Type& arr) { std::sort(arr.begin(), arr.end()); }
template<typename Type> inline void reverse(Type& arr) { reverse(arr.begin(), arr.end()); }
template<typename Type> inline Type nth(vector<Type>& arr, size_t pos) { std::nth_element(arr.begin(), arr.begin() + pos, arr.end()); return arr[pos]; }
template<typename Type> inline void unique(Type& arr) { sort(arr); arr.erase(unique(arr.begin(), arr.end()), arr.end()); }
constexpr ll INF_I = std::numeric_limits<ll>::max();
constexpr ll BIGP = 1e9 + 7;
constexpr double INF_F = std::numeric_limits<float>::infinity();
constexpr double PI = 3.14159265358979323846L;
using P = pair<ll, ll>;
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    cout << ((e - a > k) ? ":(" : "Yay!");
    return 0;
}

Measured memory_bytes: 3020
#include<stdio.h>


int main(void){

  int i, j, n;
  long long int max, sum;
  int x[5000];

  while(1){
    scanf("%d", &n);
    if(n==0) break;

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

    for(i=0; i<n; i++){
      if(max<x[i]) max=x[i];
      sum=x[i];
      for(j=i+1; j<n; j++){
	sum+=x[j];
	if(max<sum) max=sum;
      }
    }
    printf("%lld\n", max);
  }

  return(0);
}



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

int main() {
				    // *constraint*
  int N,l,r;    	// 1<=N<=1000
         		    // 1<=li<=ri<=100000
  				    // 同じ席に複数の人が座ることはなく，入力はすべて整数
  int sum = 0;
  cin  >> N;
  bool hasY = false;
  int i = 1;
  while (i <= N) {
    cin >> l >> r;
    sum += (r - l + 1);
    i ++;
  }
  
  cout << sum << endl;
}


Measured memory_bytes: 3628
#include <string>
#include <iostream>
#include <stdio.h>
#include <list>

using namespace std;

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

  int len_array;
  cin >> len_array;

  list<int> lst;

  int tmp;
  for (int i = 0; i < len_array; i++) {
    cin >> tmp;
    lst.push_back(tmp);
  }

  int num_query;
  cin >> num_query;

  int b, m, e;
  for (int i = 0; i < num_query; i++) {
    cin >> b >> m >> e;
    if (b == m || m == e) {
      continue;
    }

    auto head = next(lst.begin(), m);
    auto tail = next(lst.begin(), e);

    lst.splice(next(lst.begin(), b), lst, head, tail);
  }

  auto itr = lst.begin();
  cout << *itr++;
  for (int i = 1; i < len_array; i++, itr++) {
    cout << " " << *itr;
  }

  cout << endl;
  return 0;
}



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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

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

    double sum = 0;
    rep(i, n-1){
        REP(j, i+1, n){
            sum += sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
        }
    }
    double avg = sum / (n*(n-1)/2) * (n-1);
    cout << setprecision(20) << avg << endl;
}


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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


signed main(){
    int N;
    double x[10];
    string u[10];
    cin >> N;
    REP(i, N) cin >> x[i] >> u[i];
    double ans = 0;
    REP(i, N){
        if(u[i] == "JPY"){
            ans += x[i];
        }else{
            ans += x[i] * 380000;
        }
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
using namespace std;
char s[100002],s1[2][200002];
int n,q,x,y,t,tmp,cnt[2];
char c;
int main(){
scanf("%s",s+1);
scanf("%d",&q);
while(q--){
	scanf("%d",&t);
	if(t==1){
		tmp^=1;
	}
	else{
		scanf("%d %c",&x,&c);
		s1[(x-1)^tmp][++cnt[(x-1)^tmp]]=c;
	}
}
reverse(s1[tmp]+1,s1[tmp]+cnt[tmp]+1);
if(tmp)reverse(s+1,s+strlen(s+1)+1);
printf("%s%s%s",s1[tmp]+1,s+1,s1[tmp^1]+1);
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y);
const int INF = 1001001001;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    ll x = 0;
    rep(i,n) {
        if (i%2) x -= a[i];
        else x += a[i];
    }
    vector<ll> ans(n);
    ans[0] = x/2;
    for (int i = 1; i <= n-1; i++) {
        ans[i] = a[i-1] - ans[i-1];
    }
    rep(i,n) ans[i] *= 2;
    rep(i,n) printf("%d%c", ans[i], i==n-1?'\n':' ');
    return 0;
}

Measured memory_bytes: 4604
/*
				   _ooOoo_
				  o8888888o
				  88" . "88
				  (| -_- |)
				  O\  =  /O
			   ____/`---'\____
			 .'  \\|     |//  `.
			/  \\|||  :  |||//  \
		   /  _||||| -:- |||||-  \
		   |   | \\\  -  /// |   |
		   | \_|  ''\---/''  |   |
		   \  .-\__  `-`  ___/-. /
		 ___`. .'  /--.--\  `. . __
	  ."" '<  `.___\_<|>_/___.'  >'"".
	 | | :  `- \`.;`\ _ /`;.`/ - ` : | |
	 \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
				   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
		fozubaoyou    pass System Test!
		quoted from "https://codeforces.com/contest/472/submission/7996840"
*/
 
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#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 fin(ans) cout<<(ans)<<endl
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define Sort(a) sort(a.begin(),a.end())
#define Rort(a) sort(a.rbegin(),a.rend())
#define PI acos(-1)
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);};};
const int MOD = 1000000007;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

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 main(void){

	int n,m;
	string s,t;
	cin>>n>>m>>s>>t;
	ll x=lcm(n,m);


	int snum=0,tnum=0;

	bool ch=1;

	while(1){
		// cout<<snum<<" "<<tnum<<endl;
		if(s[snum]!=t[tnum]){
			ch=0;
			fin(-1);
			return 0;
		}
		snum+=x/m;
		tnum+=x/n;
		if(snum>=n||tnum>=m){
			break;
		}
	}
	fin(x);
}


Measured memory_bytes: 512
#include<stdio.h>
int main(void)
{
    int a,b,i,z=0,n=0;
	scanf("%d %d",&a,&b);
	for(i=a;i<=b;i++){
	    if(i==0){
			n=1;
		}
	    if(a<0&&z==1){
		    z=0;
		}
		else if(a<0){
		    z=1;
		}
	}
	if(n==1){
	    printf("Zero\n");
	}
	else if(z==0){
	    printf("Positive\n");
	}
	else if(z==1){
	    printf("Negative\n");
	}
	return 0;
}

Measured memory_bytes: 128
// VSCF.cpp : Defines the entry point for the console application.
//
#include <cmath>
#include <list>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <string>
#include <vector>
#include <set>
#include <deque>
#include <map>
#include <iomanip>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define FOR(v,p,k) for(int v=p;v<=k;++v)
#define FORD(v,p,k) for(int v=p;v>=k;--v)
#define REP(i,n) for(int i=0;i<(n);++i)
#define VAR(v,i) __typeof(i) v=(i)
#define FOREACH(i,c) for(VAR(i,(c).begin());i!=(c).end();++i)
#define PB push_back
#define ST first
#define ND second
#define SIZE(x) (int)x.size()
#define ALL(c) c.begin(),c.end()
#define int long long
#define MAXN 1000010
typedef long double LD;

#undef int
int main() {
#define int long long
	string s;
	cin >> s;
	string s2 = "CODEFESTIVAL2016";
	int res = 0;
	REP(i, 16) {
		if (s[i] != s2[i]) {
			res++;
		}
	}
	cout << res << endl;
	return 0;
}



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

using ll = long long;

const ll MOD = 1e9+7;

template <typename T>
T modMinus(T a, T b, T mod) {
  a %= mod;
  b %= mod;
  return (a>b)? (a-b)%mod: (mod+a-b)%mod;
}

template <typename T>
T modPow(T base, T e, T mod) {
  if(e==0) return 1;
  if(e==1) return base%mod;
  if(e%(T)2==1) return (base * modPow(base, e-(T)1, mod)) %mod;
  
  T tmp = modPow(base, e/(T)2, mod);
  return (tmp * tmp) % mod;
}

template <typename T>
T primeModDiv(T num, T den, T primeMod){
  return ( num*modPow(den, primeMod-(T)2, primeMod) )%primeMod;
}

template <typename T>
T modComb(T n, T k, T mod) {
  T num = (T)1; //numerator
  T den = (T)1; //denominator
  for (T i = 1; i <= k; i++) {
    num *= (n-i+(T)1);
    num %= mod;
    den *= i;
    den %= mod;
  }
  return primeModDiv(num, den, mod);
}


int main() {
  ll N, K;
  cin >> N >> K;

  for (ll i = 1; i <= K; i++) {
    ll cmb = modComb((N-K)+1, i, MOD);
    cout << cmb*modComb(K-1, i-1, MOD)%MOD << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
ll INF = 1000000007;
using Graph = vector<vector<ll>>;

// 0 false, 1 true 


int main() {
    ll m1, m2, d1, d2;
    cin >> m1 >> d1;
    cin >> m2 >> d2;

    if(m1 == m2){
        cout << 0 << endl;
    }else{
        cout << 1 << endl;
    }


}


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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> d(n);    
    rep(i, k){
        int m;
        cin >> m;
        rep(j,m){
            int a;
            cin >> a;
            d[a- 1] = 1;
        }
    }
    int ans = 0;
    rep(i, n) if(d[i] == 0) ++ans;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3628
n, k = map(int, input().split())
arr = []
for i in range(n):
    a, b = map(int, input().split())
    arr.append([a,b])
arr.sort()
s = 0
for i in range(n):
    s+=arr[i][1]
    if s >= k:
        print(arr[i][0])
        exit()
print(arr[-1][0])


Measured memory_bytes: 24420
package main

import "fmt"

func main() {
	var w, h, x, y int
	fmt.Scan(&w, &h, &x, &y)
	ans := 0
	if x*2 == w && y*2 == h {
		ans = 1
	}

  fmt.Printf("%.10f %d\n", float64(w*h)/2.0, ans)
}


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

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str; 
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define STDIO
#define MP make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define PF push_front 
#define PB push_back
#define PP push
#define lb lower_bound 
#define ub upper_bound

inline void checkmin(int &x, int y){x = min(x, y);}
inline void checkmax(int &x, int y){x = max(x, y);}

int L;

int main() 
{
	#ifndef STDIO
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    cin>>L;
    double a=(double)L/3.0;
	printf("%0.9f\n",a*a*a);
    /* end code */
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define vec(x) vector<x>
#define pb push_back
#define pii pair<ll,ll>
#define vi vector<ll>
#define vii vector<pair<ll,ll>>
#define matrix(x) vector<vector<x>>
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a, b, sizeof a)
#define ff first
#define ss second
#define mp make_pair
const int INF = 1e9;
const int MOD = 1e9 + 7;
int main()
{
ll n,k,x,y;
cin>>n;
cin>>k;
cin>>x;
cin>>y;
ll res=n-k;
ll total;
if(res>=0)
{
    total=k*x;
    total=total+res*y;

}
else
    total=n*x;
    cout<<total<<endl;

}


Measured memory_bytes: 3612
#include<iostream>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<map>
#include<vector>
using namespace std;
const pair<int,int> no=make_pair(-1,2333333);
#define N 50050
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,m,T,x[N<<1],y[N<<1],col[N<<1];
void Output(){
	for(int i=1;i<=m;++i){
		putchar(col[i]?'^':'v');
	}
	putchar('\n');
}
namespace Task_1{
	bitset<N> to[N];
	int ok[N];
	void Find(int k){
		ok[x[k]]=ok[y[k]]=1;
		for(int i=k-1;i>=1;--i){
			if(!ok[x[i]]&&!ok[y[i]])continue;
			if(ok[x[i]])col[i]=1;
			ok[x[i]]=ok[y[i]]=1;
		}
	}
	void Solve(){
		for(int i=1;i<=n;++i){
			to[i][i]=1;
		}
		for(int i=1;i<=m;++i){
			to[x[i]]=to[y[i]]=to[x[i]]|to[y[i]];
			if((int)to[x[i]].count()==n){
				Find(i);
				Output();
				return;
			}
		}
		printf("-1\n");
	}
}
namespace Task_2{
	map<int,vector<pair<int,int> > > mp; 
	void Solve(){
		if(n==2){
			puts("-1");
			return;
		}
		for(int i=m;i>=1;--i){
			mp[x[i]].emplace_back(y[i],i);
			mp[y[i]].emplace_back(x[i],i);
		}
		int A=x[1],B=y[1]+1;
		if(B>n)A=x[1]-1,B=y[1];
		if(A<1)A=x[1]+1,B=y[1];
		for(int i=1;i<=m;++i){
			while(!mp[A].empty()&&mp[A].back().second<=i)mp[A].pop_back();
			while(!mp[B].empty()&&mp[B].back().second<=i)mp[B].pop_back();
			if(x[i]==A||y[i]==A){
				auto tA=mp[A].empty()?no:mp[A].back();
				auto tB=mp[B].empty()?no:mp[B].back();
				bool rev=false;
				if(tA.second<tB.second){
					if(tA.first==B)rev=true;
				}
				else{
					if(tB.first==A)rev=true;
				}
				col[i]=rev^(x[i]==A);
				if(rev)A=(x[i]==A)?y[i]:x[i];
			}
			else if(x[i]==B||y[i]==B){
				auto tA=mp[A].empty()?no:mp[A].back();
				auto tB=mp[B].empty()?no:mp[B].back();
				bool rev=false;
				if(tA.second<tB.second){
					if(tA.first==B)rev=true;
				}
				else{
					if(tB.first==A)rev=true;
				}
				col[i]=rev^(x[i]==B);
				if(rev)B=(x[i]==B)?y[i]:x[i];
				
			}
		}
		Output();
	}
}
int main(){
	n=read(),m=read(),T=read();
	for(int i=1;i<=m;++i){
		x[i]=read(),y[i]=read();
	}
	if(T==1){
		Task_1::Solve();
	}
	else{
		Task_2::Solve();
	}
	return 0;
}


Measured memory_bytes: 310720
{-# LANGUAGE BangPatterns #-}

module Main
  ( main
  )
where

import           Control.Applicative
import           Control.Monad
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import           Control.Monad.ST
import           Data.Ord

parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine

main = do
  s <- getLine
  putStrLn $ ['x' | i <- [1..(length s)]]


Measured memory_bytes: 508
#include <atcoder/all>
#include <iostream>
#include <algorithm>

int op(int a, int b)
{
    return (a > b) ? a : b;
}

int e() { return 0; }

int main(int argc, char **argv)
{
    int n, k;

    std::cin >> n >> k;

    atcoder::segtree<int, op, e> seg(600001);

    for (int i = 0; i < n; i++) {
        int a; 
        std::cin >> a;
        int l = std::max(0, a - k);
        int r = std::min(6000000, a + k + 1);
        int v = seg.prod(l, r);
        seg.set(a, v + 1);
    }
    std::cout << seg.all_prod () << std::endl;
    return 0;
}

Measured memory_bytes: 13360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;



signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
 
    ll n;
    cin>>n;
    ll a[n];

    for(int i=0;i<n;i++){
        cin>>a[i];

    }
    int cnt=0;
    for(int i=0;i<n;i++){
        if(a[i]!=(i+1)) cnt++;
        
    }
    if(cnt<=2){
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
    
    
}

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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int64_t a,int64_t b){return a/gcd(a, b)*b;}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int64_t a){if(a<=1)return false;for(int64_t i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
// }



int main()
{
	int n, k;
	double ans, temp = 0;

	cin >> n >> k;
	vector<int64_t> p(n);
	vector<double> a(n);
	for (int i = 0; i < n; i++)
	{
		cin >> p[i];
		a[i] = (double)sigma(1, p[i]) / p[i];
	}
	for (int i = 0; i < k; i++)
		temp += a[i];
	ans = temp;
	for (int i = k; i < n; i++)
	{
		temp += a[i] - a[i - k];
		ans = max(ans, temp);
	}
	cout << fixed << setprecision(6) << ans << endl;
}



Measured memory_bytes: 6428
#include<iostream>
#include<queue>
#include<map>
#include<algorithm>

#define fs first
#define sc second
using namespace std;

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

int main(){
  int w,h;
  string room[2][50];
  int ry,rx,ly,lx;

  while(cin >> w >> h && (w||h)){
    int ay[2],ax[2];

    for(int i=0;i<h;i++){
      for(int k=0;k<2;k++){
	cin >> room[k][i];
	for(int j=0;j<w;j++){
	  if(room[k][i][j] == 'L'){
	    ly = i; lx = j;
	    room[k][i][j] == '.';
	  }
	  if(room[k][i][j] == 'R'){
	    ry = i; rx = j;
	    room[k][i][j] = '.';
	  }
	  if(room[k][i][j] == '%'){
	    ay[k] = i; ax[k] = j;
	  }
	}
      }
    }

    bool visit[50][50][50][50];
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++)
	for(int k=0;k<h;k++)
	  for(int l=0;l<w;l++)visit[i][j][k][l] = false;

    visit[ly][lx][ry][rx] = true;
    queue<P2> q;
    q.push(P2(P(ly,lx),P(ry,rx)));

    while(q.size()){
      P2 p = q.front();q.pop();
      ly = p.fs.fs; lx = p.fs.sc; ry = p.sc.fs; rx = p.sc.sc;

      if(room[0][ly][lx] == '%' && room[1][ry][rx] == '%')break;

      int ldy[] = {-1,0,1,0}, ldx[] = {0,-1,0,1};
      int rdy[] = {-1,0,1,0}, rdx[] = {0,1,0,-1};

      for(int i=0;i<4;i++){
	int lsy = ly + ldy[i], lsx = lx + ldx[i];
	int rsy = ry + rdy[i], rsx = rx + rdx[i];
	if(lsy < 0 || h-1 < lsy)lsy = ly;
	if(lsx < 0 || w-1 < lsx)lsx = lx;
	if(room[0][lsy][lsx] == '#'){
	  lsy = ly;
	  lsx = lx;
	}
	if(rsy < 0 || h-1 < rsy)rsy = ry;
	if(rsx < 0 || w-1 < rsx)rsx = rx;
	if(room[1][rsy][rsx] == '#'){
	  rsy = ry;
	  rsx = rx;
	}

	if( (room[0][lsy][lsx] == '%') != (room[1][rsy][rsx] == '%') )continue;
	if(visit[lsy][lsx][rsy][rsx])continue;
	visit[lsy][lsx][rsy][rsx] = true;

	q.push(P2(P(lsy,lsx),P(rsy,rsx)));
      }
    }

    if(visit[ay[0]][ax[0]][ay[1]][ax[1]])cout << "Yes\n";
    else cout << "No\n";
  }
}

Measured memory_bytes: 7924
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <numeric>
#include <string>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
	int n, a, b;
	cin >> n >> a >> b;
	string s;
	cin >> s;

	int kaigai = 0;
	int gakusei = 0;

	for (int i = 0; i < n; i++) {
		if (s[i] == 'b') kaigai++;

		if (s[i] == 'a' and gakusei < a + b) {
			cout << "Yes" << endl;
			gakusei++;
		}
		else if (s[i] == 'b' and gakusei < a + b and kaigai <= b) {
			cout << "Yes" << endl;
			gakusei++;
		}
		else {
			cout << "No" << endl;
		}

		//if (s[i] == 'c')cout << "No" << endl;
	}
	return 0;
}


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

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

using ll = long long;
using P = pair<int,int>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

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

int main(){
    ll N,H;
    cin>>N>>H;
    int ans = 0;
    vector<P> v(2*N);
    rep(i,N){
        ll x,y;
        cin>>x>>y;
        v[2*i] = make_pair(x,0);
        v[2*i+1] = make_pair(y,1);
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    int p = 0;
    while(H>0){
        if(v[p].second==1){
            H-=v[p].first;
            p++;
            ans++;
        }
        else{
            ans+=((H-1)/v[p].first)+1;
            H=0;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4840
N, K = map(int, input().split())
A = list(map(int, input().split()))
ok = 10**9
ng = 0
while ng+1 < ok:
    tmp = (ok+ng)//2
    k = 0
    for a in A:
        if a%tmp == 0:
            k += a//tmp -1
        else:
            k += a//tmp
    if k <= K:
        ok = tmp
    else:
        ng = tmp
print(ok)

Measured memory_bytes: 30920
function Main(input) {
	var str = input;
	str = str.split("\n");
	var ans = [];
	str = str[0].split(" ");
 	ans[0]= str[2];
 	ans[1] = str[0];
 	ans[2]= str[1];
	 console.log(ans[0]+" "+ans[1]+" "+ ans[2]);
}
 //*おまじない
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(long long int i=a; i<n; i++)
#define rloop(i,a,n) for(long long int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcount(a)
#define mod 1000000007
#define ll long long int
#define ull unsigned long long int 
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define stkll stack<ll>
#define qll queue<ll>
#define pqll priority_queue<ll>
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power)
{
    ll ans=1;
    while(power>0)
    {
        if(power%2==1)
        {
            ans=(ans*B)%mod;
        }
        B=(B*B)%mod;
        power/=2;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1)
    { 
        return false; 
    }
    if(n<=3)
    { 
        return true;
    } 
    if(n%2==0 || n%3==0) 
    {
        return false; 
    }
    for(ll i=5; i*i<=n; i+=6) 
    {
        if(n%i==0 || n%(i+2)==0) 
        {
            return false; 
        }
    }
    return true; 
}
using namespace std;
int main() 
{
    FAST
    FO
    FI
    ll n;
    IN n;
    ll ans=n-1;
    loop(i,2,sqrt(n)+1)
    {
        ll temp=-2;
        if(n%i==0)
        {
            temp+=(n/i);
            temp+=i;
            ans= min(ans,temp);
        }
    }
    OUT ans;
    return 0;
}

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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    vector<ll> acc(N + 1);
    for (int i = 0; i < N; i++) {
        acc[i + 1] = acc[i] + A[i];
    }

    map<ll, ll> cnt;
    ll ans = 0;
    for (int i = 0; i < N + 1; i++) {
        ans += cnt[acc[i]];
        cnt[acc[i]]++;
    }
    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main()
{
    ll s;
    scanf("%lld",&s);
        ll x=sqrt(s+1);
        x+=1;
        if(x>1e9)
            x=1e9;
        ll t=x;
        x=x*x-s;
        printf("0 0 1 %lld %lld %lld",t,t,x);
    return 0;
}

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


public class Main {
	private final static int MAX_QUEENS = 8;
	private static boolean[] row = new boolean[MAX_QUEENS];
	private static boolean[] col = new boolean[MAX_QUEENS];
	private static boolean[] dpos = new boolean[MAX_QUEENS*2 - 1];
	private static boolean[] dneg = new boolean[MAX_QUEENS*2 - 1];
	private static boolean[][] PieceBoard = new boolean[MAX_QUEENS][MAX_QUEENS];
	private static boolean[][] Fixed = new boolean[MAX_QUEENS][MAX_QUEENS];
	private static boolean done;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		
		int b, c;
		for(int i = 0;i< a;i++) {
			b = sc.nextInt();
			c = sc.nextInt();
			
			Queen(b,c);
		}
		
		if(has_fixed(0))
			printBoard();
		
	}
	private static boolean has_fixed(int i) {
		// TODO Auto-generated method stub'
		
		if(i == MAX_QUEENS)
			return done=true;
		
		for(int j = 0; j< MAX_QUEENS;j++) {
			if(col[j] || dpos[i+j] || dneg[i-j+MAX_QUEENS-1])
				if(!if_Queen(i,j))
					continue;
			
			if(!if_fixed(i,j))
				putQ(i,j);
			
			if(has_fixed(i+1))
				return done;
			
			if(!if_fixed(i,j))
				take_queen(i,j);
		}
		
		return false;
	}
	private static void take_queen(int i, int j) {
		// TODO Auto-generated method stub
		if(if_Queen(i,j)) {
			PieceBoard[i][j] = false;
			row[i] = col[j] = dpos[i+j] = dneg[i -j +MAX_QUEENS -1] = false;
		}
		
	}
	private static boolean if_fixed(int i, int j) {
		// TODO Auto-generated method stub
		return Fixed[i][j];
	}
	private static void printBoard() {
		// TODO Auto-generated method stub
		StringBuilder build = new StringBuilder();
		
		for(int i=0; i< MAX_QUEENS; i++) {
			for(int j = 0; j< MAX_QUEENS; j++) {
				build.append(if_Queen(i,j)?"Q":".");
			}
			build.append("\n");
		}
		System.out.print(build);
	}
	private static void Queen(int b, int c) {
		// TODO Auto-generated method stub
		putQ(b,c);
		Fixed[b][c] = true;
	}
	private static boolean putQ(int r, int c) {
		// TODO Auto-generated method stub
		if(if_Queen(r,c))
			return false;
		if(row[r] || col[c] || dpos[r+c] || dneg[r-c+MAX_QUEENS - 1])
			return false;
		
		PieceBoard[r][c] = true;
		row[r] = col[c] = dpos[r+c] = dneg[r-c+MAX_QUEENS-1] = true;
		
		return true;
		
	}
	private static boolean if_Queen(int b, int c) {
		// TODO Auto-generated method stub
		
		return PieceBoard[b][c];
	}

}



Measured memory_bytes: 26220
#include<stdio.h>
#include<stdlib.h>
#define ll long long
#define max(p,q)((p)>(q)?(p):(q))

//*
//プラキュー（二分ヒープ）（最低限バージョン）
//int PQhikaku(int i,int j);//jの方が優先度が高いならtrueを返す
int PQhikaku(ll*heap,int i,int j){return heap[i]>heap[j];}
void heap_utod(ll*heap,int n){
	if(2*n>heap[0])return;
	int rflag=(2*n+1<=heap[0])&&(PQhikaku(heap,2*n,2*n+1));
	if(PQhikaku(heap,n,2*n+rflag)){
		ll temp=heap[2*n+rflag];
		heap[2*n+rflag]=heap[n];
		heap[n]=temp;
		heap_utod(heap,2*n+rflag);
	}
}
void heap_dtou(ll*heap,int n){
	if(n==1||PQhikaku(heap,n,n/2))return;
	ll temp=heap[n];
	heap[n]=heap[n/2];
	heap[n/2]=temp;
	heap_dtou(heap,n/2);
}
ll PQpop(ll*heap){
	ll rr=heap[1];
	heap[1]=heap[heap[0]--];
	heap_utod(heap,1);
	return rr;
}
void PQpush(ll*heap,ll n){
	heap[++heap[0]]=n;
	heap_dtou(heap,heap[0]);
}
//*/

int netacnt[100010];
int neta[100010],v[100010],idx[100010];
ll h[100010];
int cmp(const void*p,const void*q){
	if(v[*(int*)p]<v[*(int*)q])return 1;
	return -1;
}
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++){
		scanf("%d%d",neta+i,v+i);
		idx[i]=i;
	}
	qsort(idx,n,sizeof(int),cmp);
	ll crr=0,cnt=0;
	for(int i=0;i<k;i++){
		crr+=v[idx[i]];
		if(netacnt[neta[idx[i]]]++)PQpush(h,v[idx[i]]);
		else cnt++;
	}
	ll ans=crr+cnt*cnt;
	for(int i=k;i<n&&h[0];i++){
		if(netacnt[neta[idx[i]]]==0){
			crr-=PQpop(h);
			netacnt[neta[idx[i]]]++;
			crr+=v[idx[i]];
			cnt++;
			ans=max(ans,crr+cnt*cnt);
		}
	}
	printf("%lld",ans);
}

Measured memory_bytes: 2036
use std::io::stdin;

fn count<'a>(r: usize, n: &'a str) -> usize {
    if r == 0 { return 1; }
    let mut d = 0u16;
    let mut sum = 0;
    for (i, c) in n.chars().enumerate() {
        let index = c as usize - '0' as usize;
        if d >> index & 1 == 1 {
            continue;
        }
        d = d | 1 << index;
        sum += count(r-1, &n[i+1..]);
    }
    sum
}

fn main() {
    let mut v = String::new();
    stdin().read_line(&mut v).unwrap();
    let mut c = String::new();
    stdin().read_line(&mut c).unwrap();
    println!("{}", count(3, &c.trim()));
}

Measured memory_bytes: 4352
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ

int main(){
	int a,b;scanf("%d%d",&a,&b);
	if(a<=9&&b<=9)printf("%d\n",a*b);else printf("-1\n");
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void)
{
	int x;
	scanf("%d", &x);
	if (x == 3) {
		printf("YES");
	}
	else if (x == 5) {
		printf("YES");
	}
	else if (x == 7) {
		printf("YES");
	}
	else {
		printf("NO");
	}
	return 0;
}

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

using namespace std;

typedef long long ll;

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

int main() {
  vector<int> alp1(26, 0), alp2(26, 0);
  string S, T;
  cin >> S >> T;
  for (int i = 0; i < S.size(); ++i) {
    alp1[S[i] - 'a']++;
    alp2[T[i] - 'a']++;
  }
  sort(alp1.begin(), alp1.end());
  sort(alp2.begin(), alp2.end());
  if (alp1 == alp2) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 776
#include<bits/stdc++.h>
#define ll long long int
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define test(t) int t; cin >> t; while(t--)
#define endl "\n"
#define debug(x) cout << x << "\n"
#define pb push_back
#define mp make_pair
#define MEMS(x,t) memset(x, t, sizeof(x))
#define mod 1000000007
#define forn(i,n) for (ll i = 0; i < n; i++)
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define rrep(i,a,b) for( int i = a; i >= b; i--)
#define map map<ll,ll>
#define fi first
#define se second
#define set set<ll>
#define pp pair<ll,ll>
using namespace std;
bool sortbysec(const pp &a,
              const pp &b)
{
    return (a.second < b.second);
}
int main()
{
    string s;
    cin >> s;
    ll sum = 0;
    forn(i, s.length())
    {
        sum += s[i] - '0';
        sum = sum%9;
    }
    if ( sum == 0) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 3716
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
Q = int(input())
ans = sum(A)
cnt = Counter(A)
for i in range(Q):
    B, C = map(int,input().split())
    ans += cnt[B] * (C - B)
    print(ans)
    cnt[C] += cnt[B]
    cnt[B] = 0


Measured memory_bytes: 87816
def almost0(m,K):
    M=str(m)
    s=len(M)
    if s<K:
        return 0
    elif m==0:
        return 0
    elif K==0:
        return 0
    elif K==1:
        return int(M[0])+almost0((10**(len(M)-1))-1,K)
    elif K==2:
        return (int(M[0])-1)*9*(len(M)-1)+almost0(m%(10**(len(M)-1)),K-1)+almost0((10**(len(M)-1))-1,K)
    else:
        return  (int(M[0])-1)*81*(s-1)*(s-2)//2+almost0(m%(10**(s-1)),K-1)+almost0((10**(s-1))-1,K)

N=int(input())
K=int(input())

print(almost0(N,K))

Measured memory_bytes: 3064
/*
csc -debug B.cs && mono --debug B.exe <<< "oxoxoxoxoxoxox"
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Reflection;

public class HelloWorld {
    public static void SolveCodeForces() {
        var S = Console.ReadLine();
        var cnt = S.Count(c => c == 'x');
        System.Console.WriteLine(cnt >= 8 ? "NO" : "YES");
    }

    static Scanner cin = new Scanner();
    static StringBuilder cout = new StringBuilder();

    static public void Main () {
        SolveCodeForces();
        // IncreaseStack(SolveCodeForces);
        // System.Console.Write(cout.ToString());
    }

    public static void IncreaseStack(ThreadStart action, int stackSize = 128000000)
    {
        var thread = new Thread(action, stackSize);
        thread.Start();
        thread.Join();
    }
}

public static class Helpers {
    public static T[] CreateArray<T>(int length, Func<int, T> itemCreate) {
        var result = new T[length];
        for (var i = 0; i < result.Length; i++)
            result[i] = itemCreate(i);
        return result;
    }
}

public class Scanner
{
    private string[] line = new string[0];
    private int index = 0;

    public string Next() {
        if (line.Length <= index) {
            line = Console.ReadLine().Split(' ');
            index = 0;
        }
        var res = line[index];
        index++;
        return res;
    }

    public int NextInt() {
        return int.Parse(Next());
    }

    public long NextLong() {
        return long.Parse(Next());
    }

    public ulong NextUlong() {
        return ulong.Parse(Next());
    }

    public string[] Array() {
        line = Console.ReadLine().Split(' ');
        index = line.Length;
        return line;
    }

    public int[] IntArray(int emptyPrefixLen = 0) {
        var array = Array();
        var result = new int[emptyPrefixLen + array.Length];
        for (int i = 0; i < array.Length; i++)
            result[emptyPrefixLen + i] = int.Parse(array[i]);
        return result;
    }

    public long[] LongArray() {
        var array = Array();
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = long.Parse(array[i]);
        return result;
    }

    public ulong[] UlongArray() {
        var array = Array();
        var result = new ulong[array.Length];
        for (int i = 0; i < array.Length; i++)
            result[i] = ulong.Parse(array[i]);
        return result;
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    cout << a + b + c + (max({a, b, c}) * ((1LL << k) - 1)) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cctype>

#include<cmath>
#include<iostream>
#include<fstream>

#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
#include<set>
#include<sstream>
#include<stack>

using namespace std;

int main()
{
    double x1,x2,x3,x4,y1,y2,y3,y4,ansx,ansy;
    int q;
    scanf("%d",&q);
 
    for(int i=0;i<q;i++){
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
        ansx = ((x2-x1)*(y3*(x4-x3)+x3*(y3-y4))-(x4-x3)*(y1*(x2-x1)+x1*(y1-y2)))/((y2-y1)*(x4-x3)-(y4-y3)*(x2-x1));
        if(x1 != x2){
            ansy = ((y2-y1)*ansx+y1*(x2-x1)+x1*(y1-y2))/(x2-x1);
        }else{
            ansy = ((y4-y3)*ansx+y3*(x4-x3)+x3*(y3-y4))/(x4-x3);
        }
        printf("%.10lf %.10lf\n",ansx,ansy);
    }
}



Measured memory_bytes: 3244
#include<iostream>
 
using namespace std;
 
int main(){
  int a=0;
  int temp;
  for(int i=0;i<4;i++){
    cin >> temp;
    a+=temp;
  }
  //int b=0;
  int ab=a;
  for(int i=0;i<4;i++){
    cin >> temp;
    ab-=temp;
  }
  if(ab<0){
    cout <<(a-ab)<<endl;
  }else{
      cout << a<< endl;
    }
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
//const int MODINF = 1000000007;
//const int64_t INF = 998244353;
using namespace std;

bool prime_number(int x){
    if (x < 2) return false;
    else if (x == 2) return true;
    else if (x % 2 == 0) return false;
    
    double sqrtN = sqrt(x);
    for (int i = 3; i <= sqrtN; i += 2){
        if (x % i == 0) return false;
    }
    return true;
}

int main(){
    int X;
    cin >> X;
    while(true){
        if(prime_number(X)){
            cout << X << endl;
            return 0;
        }
        else X++;
    }
}



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

int main(){
  int n;
  cin >> n;
  int c0,c1,c2,c3;
  c0 = c1 = c2 = c3 = 0;
  for (int i = 0; i < n; i++){
    string s;
    cin >> s;
    if (s == "AC") c0++;
    else if (s == "WA") c1++;
    else if (s == "TLE") c2++;
    else if (s == "RE") c3++;
  }
  cout << "AC x " << c0 << endl;
  cout << "WA x " << c1 << endl;
  cout << "TLE x " << c2 << endl;
  cout << "RE x " << c3 << endl;
}

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

#define For(i, j, k) for (int i = j; i <= k; i++)
#define Forr(i, j, k) for (int i = j; i >= k; i--)

using namespace std;

const int N = 710;

bool G[N][N];
int n, m;
int a, b;
int col[N];
bool dp[N];

bool DFS(int o) {
	if (col[o] == 1) ++a; else ++b;
	For(j, 1, n) if (!G[o][j]) {
		if (!col[j]) {
			col[j] = 3 - col[o];
			if (!DFS(j)) return false;
		}
		if (col[j] == col[o]) return false;
	}
	return true;
}

int main() {

	scanf("%d%d", &n, &m);
	For(i, 1, n) G[i][i] = true;
	For(i, 1, m) {
		int u, v;
		scanf("%d%d", &u, &v);
		G[u][v] = G[v][u] = true;
	}

	dp[0] = true;
	For(i, 1, n) if (!col[i]) {
		a = b = 0;
		col[i] = 1;
		if (!DFS(i)) {
			puts("-1");
			return 0;
		}
		Forr(j, n, 0) if (dp[j]) {
			dp[j] = 0;
			dp[j + a] = dp[j + b] = true;
		}
	}

	int ans = m;
	For(i, 0, n) if (dp[i]) ans = min(ans, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 896