akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  ll w, h; cin >> w >> h;
  V<P<ll, ll> > pq(w+h);
  REP(i, w) {
    ll p; cin >> p;
    pq[i] = make_pair(p, 0);
  }
  REP(i, h) {
    ll q; cin >> q;
    pq[i+w] = make_pair(q, 1);
  }
  sort(pq.begin(), pq.end());
  ll a=w+1, b=h+1;
  ll ans = 0;
  REP(i, w+h) {
    if (pq[i].second == 0) {
      ans += b*pq[i].first; a--;
    } else {
      ans += a*pq[i].first; b--;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    if(N[0] == N[2]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    
    return 0;
}

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

int a_pos(char c){
  // if('a' <= c && c <= 'z'+1)
  return (c-'a');
  // return -1;x
}

int main() {
  int n;
  cin >> n;
  vector <string> sv(n);
  rep(i,n) cin >> sv[i];
  rep(i,n) sort(sv[i].begin(), sv[i].end());
  int64_t ans = 0;
  sort(sv.begin(), sv.end());
  // cout << endl;
  ll counter = 0;
  for (int i =1; i<n; i++) {
    // cout << sv[i] << endl;
    if(sv[i-1] == sv[i])
      if (counter == 0)
	counter += 2;
      else
	counter ++;
    else{
      ans += counter * (counter -1) / 2;
      counter =0;
    }
  }
  ans += counter * (counter - 1)/ 2;
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7296
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,w,z;
    char ca,cb,cc;
    cin>>a>>b;
    if(a>8||b>8) cout<<":("<<endl;
    else cout<<"Yay!"<<endl;
    return 0;
}


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

using namespace std;

const double r = 1.0;
const double PI = acos(-1.0);

struct Point {
    double x, y;
    Point() {}
    Point(double x, double y) : x(x), y(y) {}
};
Point operator+(const Point &a, const Point &b) {
    return Point(a.x + b.x, a.y + b.y);
}
Point operator-(const Point &a, const Point &b) {
    return Point(a.x - b.x, a.y - b.y);
}
inline double Distance2(const Point &a, const Point &b) {
    return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}
Point Circle(const Point &p1, const Point &p2, double theta) {
    Point p12 = p2 - p1;
    Point rp(p12.x * cos(theta) - p12.y * sin(theta), p12.x * sin(theta) + p12.y * cos(theta));
    double len = sqrt(p12.x * p12.x + p12.y * p12.y);

    rp.x /= len;
    rp.y /= len;

    return rp + p1;
}

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

    int n;

    while (cin >> n, n) {
        // Input
        vector<Point> p(n);
        for (int i = 0; i < n; ++i)
            cin >> p[i].x >> p[i].y;

        // Solve
        int ans = 1;
        for (int i = 0; i < n; ++i)
            for (int j = i + 1; j < n; ++j) {
                double d = Distance2(p[i], p[j]);

                if (d <= 4.0 * r * r) {
                    double theta = (PI - acos((2.0 - d) * 0.5)) * 0.5;

                    for (int s = -1; s <= 1; s += 2) {
                        Point c = Circle(p[i], p[j], s * theta);

                        int num = 2;
                        for (int k = 0; k < n; ++k) {
                            if (k != i && k != j && Distance2(c, p[k]) <= 1.0)
                                ++num;
                        }

                        ans = max(ans, num);
                    }
                }
            }

        // Output
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3560
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

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

	cin >> N;
	if (N == 2) {
		cout << 1 << endl;
		return 0;
	}
	long long int lft = (N - 1) / 2;
	long long int rht = N / 2 - 1;
	vector<long long int>by(1000001);
	by[0] = 1;
	by[1] = 1;
	for (int i = 2; i < 1000001; i++) {
		by[i] = by[i - 1] * i;
		by[i] %= MOD;
	}
	long long int box = 1;
	if (rht != lft) {
		box = lft;
	}
	long long int kazu = (N + 1) / 2;
	long long int ans = 0;
	long long int used = 0;
	while (rht >= 0) {
		//cout << lft << " " << rht << " " << box << endl;
		//cout << kazu << endl;
		long long int bag = by[kazu] * by[N - 1 - kazu];
		bag %= MOD;
		bag *= box;
		bag %= MOD;
		bag -= used;
		used += bag;
		bag += MOD;
		bag %= MOD;
		ans += bag*kazu;
		ans %= MOD;
		lft++;
		rht--;
		box *= rht + 1;
		box %= MOD;
		box *= lft;
		box %= MOD;
		box *= power(lft - rht, MOD - 2, MOD);
		box %= MOD;
		box *= power(lft - rht - 1, MOD - 2, MOD);
		box %= MOD;
		kazu++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 8064
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
 
using namespace std;
typedef long long ll;
 
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
long long int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<ll> G[100005];
vector<P> tree[100010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
//↓,→,↑,←
 
#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
	//aのb乗を計算する
	if(bed==0){return 1;}
	else{
		ll ced = rui(abc,bed/2);
		ced *= ced;
		ced %= mod;
		if(bed%2==1){ced*=abc; ced%=mod;}
		return ced;
	}
} 

ll i,j,k,ii,jj;
ll n,m,num,sumxor,sum;
ll ans;
ll a,b,c,d,e,f,g,h,w,v;
char s[500][500];
ll x[800005],y[800005],z[900005];

int main(){	
	cin>>x[0]>>x[1]>>x[2];		
	ans = INF;
	for(i=-10;i<=70;i++){
		y[0] = x[0];
		y[1] = x[1];
		y[2] = x[2];
		num = 0;
		for(j=0;j<3;j++){
			while(y[j]<i){
				y[j] += 2;
				num++;
			}
			num += y[j]-i;
		}
		ans = min(num,ans);
	}
	p(ans);
	return 0;
}

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

struct Card {char suit, value;};

void bubble(struct Card A[], int N) {
	for (int i = 0; i < N; i++) {
		for (int j = N - 1; j >= i + 1; j--) {
			if (A[j].value < A[j - 1].value) {
				Card t = A[j];
				A[j] = A[j - 1];
				A[j - 1] = t;
			}
		}
	}
}

void selection(struct Card A[], int N) {
	for (int i = 0; i < N; i++) {
		int minj = i;
		for (int j = i; j < N; j++) {
			if (A[j].value < A[minj].value) minj = j;
		}
		Card t = A[i];
		A[i] = A[minj];
		A[minj] = t;
	}
}

void print(struct Card A[], int N) {
	for (int i = 0; i < N; i++) {
		if (i > 0) cout << " ";
		cout << A[i].suit << A[i].value;
	}
	cout << endl;
}

bool isStable(struct Card C1[], struct Card C2[], int N) {
	for (int i = 0; i < N; i++) {
		if (C1[i].suit != C2[i].suit) return false;
	}
	return true;
}

int main() {
	Card C1[100], C2[100];
	int N;
	char ch;

	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> C1[i].suit >> C1[i].value;
	}

	for (int i = 0; i < N; i++) C2[i] = C1[i];

	bubble(C1, N);
	selection(C2, N);

	print(C1, N);
	cout << "Stable" << endl;
	print(C2, N);
	if (isStable(C1, C2, N)) cout << "Stable" << endl;
	else cout << "Not stable" << endl;

	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;
#define INF 1000000007
#define MOD 1000000007
#define SEP " "

ll gcd(ll num1, ll num2)
{
	if (num1 < num2)
		swap(num1, num2);
	if (num2 == 0)
		return num1;
	return (gcd(num2, num1 % num2));
}

ll lcm(ll num1, ll num2)
{
	return (num1 / gcd(num1, num2) * num2);
}

int		main(void)
{
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	a--;
	ll bc = b / c;
	ll bd = b / d;
	ll bcd = b / lcm(c, d);
	ll ac = a / c;
	ll ad = a / d;
	ll acd = a / lcm(c, d);
	ll range = b - a;
	ll cdiv = (bc + bd - bcd) - (ac + ad - acd);
	ll ans = range - cdiv;
	cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python
from math import *

N=int(input())
tonaris = [[] for i in range(N)]
for _ in range(1,N):
    u,v,w = tuple(map(int,input().split()))
    u -= 1
    v -= 1
    w = w%2
    tonaris[u].append((v,w))
    tonaris[v].append((u,w))


colors = [None for i in range(N)]

q = [0]
colors[0]=0
while len(q)!=0:
    u = q.pop()
    for v,w in tonaris[u]:
        tonaris[v].remove((u,w))
        colors[v] = colors[u] ^ w
        q.append(v)

for color in colors:
    print(color)


Measured memory_bytes: 35756
import java.io.*;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while (true) {
			String sz_input = br.readLine();
			String[] sz_num = sz_input.split(" ");
			int H = Integer.parseInt(sz_num[0]);
			int W = Integer.parseInt(sz_num[1]);
			
			if (H == 0 && W == 0) break;
			
			for (int y = 0; y < H; y++) {
				for (int x = 0; x < W; x++) {
					System.out.print("#");
					x++;
					if (x < W) System.out.print(".");
				}
				System.out.println();
				y++;
				
				if (y >= H) break;
				for (int x = 0; x < W; x++) {
					System.out.print(".");
					x++;
					if (x < W) System.out.print("#");
				}
				System.out.println();
			}
			
			System.out.println();
		}
	}
}

Measured memory_bytes: 31668
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <iomanip>
#include <cmath>
#include <ctgmath>
#include <math.h>
#include <cassert>
#include <chrono>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define io ios_base::sync_with_stdio(false), cin.tie(NULL)
#define GFOR(i,a,n) for (i=a;i<n;i++)
#define FOR(i,a,n) for (int i=a;i<n;i++)
#define RFOR(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<long long int> vll;
typedef vector<pair<int, int> > vpi;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

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

    int i = 0, j = n-1, c = 0;
    while (i < j) {
        while (j >= 0 and s[j] == 'W')
            j--;
        while (i < n and s[i] == 'R')
            i++;
        if (i >= j)
            break;

        swap (s[i], s[j]);
        c++;
    }

    cout << c << "\n";
}

int main() {
    #ifdef LOCAL
    auto t1 = std::chrono::high_resolution_clock::now();
    #endif

    io;
    solve();

    #ifdef LOCAL
    auto t2 = std::chrono::high_resolution_clock::now();
    auto duration = std::chrono::duration_cast<std::chrono::milliseconds>( t2 - t1 ).count();

    std::cout << "Time Taken: " << duration << "\n";
    #endif

}
// check for edge cases in limits
// printing double may print 1.223232e9 like values, beware of that
// carefully observe simulation of test cases


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


def main():
    s = input()
    n = len(s)
    ans = 0

    for i in range(1, n + 1):
        for j in range(n - i + 1):
            t = s[j:j + i]

            if len(t.replace('A', '').replace('C', '').replace('G', '').replace('T', '')) == 0:
                ans = max(ans, i)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000010
using namespace std;
struct dy
{
    ll y,nxt;
}A[maxn];
ll n,num,cnt,tot,ans;
ll head[maxn],a[1010][1010],vis[1010][1010] ;
ll in[maxn],t[maxn],day[maxn];
void add(ll u,ll v)
{
    A[++cnt].y=v;
    A[cnt].nxt=head[u] ;
    head[u]=cnt;
    return;
}
void topsort()
{
    for(ll i=1;i<=tot;i++){
        ll u=t[i];
        for(ll j=head[u];j;j=A[j].nxt){
            ll v=A[j].y;
            day[v]=day[u]+1;
            in[v]--;
            if(!in[v]) t[++tot]=v;
        }
    }
    for(ll i=1;i<=num;i++) ans=max(ans,day[i]);
    return;
}
int main()
{
    scanf("%d",&n);
    for(ll i=1;i<=n;i++){
        for(ll j=1;j<n;j++){
            scanf("%d",&a[i][j]);
            if(!vis[i][j] && !vis[j][i]) vis[i][j]=vis[j][i]=(++num);
        }
    }
    for(ll i=1;i<=n;i++){
        for(ll j=2;j<n;j++){
            add(vis[i][a[i][j-1]],vis[i][a[i][j]]);
            in[vis[i][a[i][j]]]++;
        }
    }
    for(ll i=1;i<=num;i++){
        if(!in[i]){
            t[++tot]=i;
            day[i]=1;
        }
    }
    topsort() ;
    if(tot!=num) puts("-1");
    else printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 54784
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    int N, M;
    cin >> N >> M;
    cout << N*(N-1)/2+M*(M-1)/2 << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;

#define MAX_LENGTH 100

// minとswap関数はalgorithmライブラリ

int selection_sort(int array[], int size) {
  int swap_count = 0;

  for(int i = 0; i < size - 1; i++) {
    int min_index = i;

    for(int j = i + 1; j < size; j++) {
      if (array[min_index] > array[j]) {
        min_index = j;
      }
    }

    if (i != min_index) {
      swap(array[i], array[min_index]);
      swap_count++;
    }
  }

  return swap_count;
}

int main() {
  int size, list[MAX_LENGTH];
  int swap_count;

  scanf("%d", &size);
  for(int i = 0; i < size; i++) {
    scanf("%d", &list[i]);
  }

  swap_count = selection_sort(list, size);

  for(int i = 0; i < size; i++) {
    printf("%d", list[i]);
    if (i != size - 1) {
      printf(" ");
    }
  }
  printf("\n");
  printf("%d\n", swap_count);
}



Measured memory_bytes: 2752
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())
c1 = T1*A1-T1*B1
c2 = T2*A2-T2*B2
if c1 > 0:
    c1 *= -1
    c2 *= -1
power = c1+c2
if power == 0:
    print('infinity')
elif power < 0:
    print(0)
else:
    ans = 2*(-c1//power)+(c1%power > 0)
    print(ans)

Measured memory_bytes: 9036
def main():
    n, x, m = map(int, input().split())
    mflg = [-1] * m
    mflg[x] = 0
    ltot = [x]

    tot = x
    a = x
    for i in range(1, n):
        a = a ** 2 % m

        if mflg[a] >= 0:
            b = mflg[a]
            z = (n - i) // (i - b)
            y = (n - i) % (i - b)
            if b == 0 and y == 0:
                tot += ltot[i - 1] * z
            elif b == 0:
                tot += ltot[b - 1 + y] + ltot[i - 1] * z
            else:
                tot += (ltot[b - 1 + y] - ltot[b - 1]) + (ltot[i - 1] - ltot[b - 1]) * z
            break

        mflg[a] = i
        tot += a
        ltot.append(tot)

    print(tot)


main()



Measured memory_bytes: 13496
n=int(input())
f=[list(map(int,input().split())) for i in range(n)]
p=[list(map(int,input().split())) for i in range(n)]
l=[0]*1024
for i in range(1024):
    I=format(i,'b').zfill(10)
    for k in range(n):
        c=0
        for j in range(10):
            if I[j]=='1' and f[k][j]==1:
                c+=1
        l[i]+=p[k][c]    
print(max(l[1:]))

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

struct UF
{
	vector<int> par; // 親のインデックスを記憶する配列
	vector<int> sz; // サイズを記憶する。
	vector<int> rank;
	// 初期化
	UF(int n):par(n),sz(n),rank(n){
		for(int i = 0; i < n; i++){
			par[i] = i;sz[i] = 1;rank[i] = 0;
		}
	}
	// 親を求める
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	// xとyの属する集合を併合
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		if(rank[x] < rank[y]){
			par[x] = y;
			sz[y] += sz[x];
		}
		else{
			par[y] = x;
			sz[x] += sz[y];
			if(rank[x] == rank[y])rank[x]++;
		}
	}
	// xとyが同じ集合ならtrue
	bool same(int x, int y) { return find(x) == find(y); }
	// 素の集合のサイズを求める
	int size(int n){return sz[find(n)];}
};

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

	ll n;cin >> n;
	vector<P> a(n);
	UF uf(n);
	REP(i, n){
		cin >> a[i].FI;
		a[i].SE = i;
	}
	vector<P> b(n);
	REP(i, n){
		cin >> b[i].FI;
		b[i].SE = i;
	}

	sort(ALL(a));
	sort(ALL(b));

	REP(i, n){
		if(a[i].FI > b[i].FI){
			cout << "No" << endl;
			return 0;
		}
		uf.unite(a[i].SE, b[i].SE);
	}

	if(uf.size(0) != n){
		cout << "Yes" << endl;
		return 0;
	}

	REP(i, n - 1){
		if(a[i+1].FI <= b[i].FI){
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 4608
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;


//      DEEP

using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;
typedef set<int> si;


/*
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
*/
/*
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
*/

const ll mod = 1e9 + 7;
const ll modl=998244353;
const double pie=3.1415926535;
                                                    //power
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}

                        //                    Modular Exponentiation

ll mod_power(ll x, ll y, ll m)
{
    ll r = 1;     // Initialize result

    x = x % m; // Update x if it is more than or equal to m

    if (x == 0) return 0; // In case x is divisible by m;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            r = (r*x) % m;

        // y must be even now
        y = y/2;
        x = (x*x) % m;
    }
    return r;
}

                                                      //GCD
ll gcd(ll x,ll y){
   if(y==0)return x;
   return gcd(y,x%y);
}
                                              // SIEVE

/*
bool isPrime[100001];
void sieve(int N) {

        for(int i = 0; i <= N;++i) {
            isPrime[i]=true;
        }
        isPrime[0]=false;
        isPrime[1]=false;

        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
*/

int main(){
    boost;
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
       int n;
       cin>>n;
       vll v;
       map<int,int>M;
       int i=2;
       v.pb(n);
       int j=0;
       M[n]++;
       while(true){
          if(v[j]%2==0){
            int x=v[j]/2;
            v.pb(x);
            M[x]++;
            if(M[x]>=2){
              cout<<j+2<<endl;
              break;
            }
          }else{
            int x=3*v[j]+1;
            v.pb(x);
            M[x]++;
            if(M[x]>=2){
              cout<<j+2<<endl;
              break;
            }
          }
          j++;
       }

   }
}












Measured memory_bytes: 3548
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn = 2005;
const int mod = 1e9 + 7;
LL a[maxn], n, x, b[maxn], ans;
int main() {
    cin>>n>>x;
    for (int i=0; i<n; i++) cin>>a[i];
    ans = 1LL * maxn * 1e9;
    memset(b, 0x3f, sizeof(b));
    for (int i=0; i<n; i++) {
        LL tmp = 0;
        for (int j=0; j<n; j++)
            b[j] = min(b[j], a[(j-i+n)%n]);
        for (int j=0; j<n; j++)
            tmp += b[j];
        ans = min(ans, i * x + tmp);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(void) {
    long long a, b, k;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a >> b >> k;
    a -= k;
    if (a < 0) {
        b += a;
        if (b < 0) {
            b = 0;
        }
        a = 0;
    }

    cout << a << " " << b << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pb push_back
#define mp make_pair
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(),x.end()
#define mem0(s) memset(s,0,sizeof(s))
#define meminf(s) memset(s,0x3f,sizeof(s))
#define mp_insert(a,b,c) mp.insert(map<pair<int,int>,int>::value_type(make_pair(a,b),c))
double pi=acos(-1);
typedef long long ll;
typedef unsigned long long ull;
inline ll lowbit(ll x){return x&(-x);}
inline ll min(ll a,ll b){return a<b?a:b;}
inline ll max(ll a,ll b){return a>b?a:b;}
const int INF=0x3f3f3f3f,max_n=200005,mod=998244353;
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
inline ll pow(ll a,ll b,ll mod){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll ji[max_n];
ll inv(ll a)
{
	return pow(a,mod-2,mod);//逆元
}
ll C(ll n,ll m)
{
	return 1ll*ji[n]*inv(1ll*ji[m]*ji[n-m]%mod)%mod;//阶乘地求组合数
}
void jiecheng(int n)//预处理阶乘
{
	ji[0]=1;
	for(int i=1;i<=n;i++)
	{
		ji[i]=1LL*ji[i-1]*i%mod;
	}
}
ll ans=0;
int main()
{
	int n,m,k;cin>>n>>m>>k;
	jiecheng(n);
	for(int i=0;i<=k;i++)
	{
		ans+=(1LL*m*C(n-1,i))%mod*pow(m-1,n-i-1,mod)%mod;
	}
	cout<<(ans%mod+mod)%mod;
}

Measured memory_bytes: 5132
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

void solve(){
	int n;
	ll a, b;
	cin>>n>>a>>b;
	vector<ll> x(n);
	for(int i=0;i<n;i++){
		cin>>x[i];
	}
	ll ans = 0;
	for(int i=0;i<n-1;i++){
		ll d = x[i+1]-x[i];
		ans += min(d*a,b);
	}
	cout<<ans<<endl;
}

int main(){
	fastread;
	int t = 1;
	// cin>>t;
	for(int i=1;i<=t;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}


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

template <class T>
inline void read(T &x) {
    x = 0;
    char c = getchar();
    bool f = 0;
    for (; !isdigit(c); c = getchar()) f ^= c == '-';
    for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
    x = f ? -x : x;
}

template <class T>
inline void write(T x) {
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    T y = 1;
	int len = 1;
    for (; y <= x / 10; y *= 10) ++len;
    for (; len; --len, x %= y, y /= 10) putchar(x / y + 48);
}

const int MAXN = 200;
int n, ans, col[MAXN + 5], dis[MAXN + 5][MAXN + 5];

bool dfs(int u, bool f) {
	col[u] = f;
	for (int v = 1; v <= n; ++v)
		if (dis[u][v] == 1) {
			if (col[v] == f) return 0;
			if (col[v] == -1 && !dfs(v, f ^ 1)) return 0;
		}
	return 1;
}

inline void floyd() {
	for (int i = 1; i <= n; ++i) dis[i][i] = 0;
	for (int k = 1; k <= n; ++k)
		for (int i = 1; i <= n; ++i)
			for (int j = 1; j <= n; ++j)
				dis[i][j] = min(dis[i][j], dis[i][k] + dis[k][j]);
}

int main() {
	read(n);
	memset(dis, 0x3f, sizeof (dis));
	for (int i = 1; i <= n; ++i)
		for (int d, j = 1; j <= n; ++j) {
			scanf("%1d", &d);
			if (d) dis[i][j] = 1;
		}
	memset(col, -1, sizeof (col));
	if (!dfs(1, 0)) {
		puts("-1");
		return 0;
	}
	floyd();
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j)
			ans = max(ans, dis[i][j]);
	++ans;
	write(ans);
	putchar('\n');
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
public class Main
{
	public static void main(String aeg[])
	{
		Scanner in = new Scanner(System.in);
		int a[]= new int[3];
		while(in.hasNext())
		{
			a[0]=in.nextInt();
			a[1]=in.nextInt();
			a[2]=in.nextInt();
			if((a[0]|a[1]|a[2])==-1)
				return;
			int re=7200-a[0]*3600-a[1]*60-a[2];
			a[0]=re/3600;
			a[1]=(re%3600)/60;
			a[2]=(re%3600)%60;
			System.out.printf("%02d:%02d:%02d",a[0],a[1],a[2]);
			System.out.println();
			re*=3;
			a[0]=re/3600;
			a[1]=(re%3600)/60;
			a[2]=(re%3600)%60;
			System.out.printf("%02d:%02d:%02d",a[0],a[1],a[2]);
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
def main():

    A, B = map(int, input().split())
    v_A = int(A / 0.08)
    if (100*A) % (100*0.08) != 0:
        v_A += 1
    v_B = int(B / 0.1)
    if (100*B) % (100*0.1) != 0:
        v_B += 1
    v_A2 = int((A+1) / 0.08)
    v_B2 = int((B+1) / 0.1)

    A_cand = [i for i in range(v_A, v_A2)]
    B_cand = [i for i in range(v_B, v_B2)]

    # print(A_cand)
    # print(B_cand)
    ab_cand = set(A_cand) & set(B_cand)
    if len(ab_cand) == 0:
        print(-1)
    else:
        print(min(ab_cand))
    # print(ab_cand)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int x;
    cin >> x;
    int a[2] = {0};
    for(long i=-118; i<=119; i++) {
        for(long j=-118; j<=119; j++) {
            if(i*i*i*i*i - j*j*j*j*j == x) {cout << i << " " << j << endl; return 0;}
        }
    }
    
    return 0;
}


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

double z[200000][2];

int main() {

  int n;
  int cnt = 0;
  double d;

  cin >> n >> d;
  for(int i=0; i<n; ++i) cin >> z[i][0] >> z[i][1];

  for(int i=0; i<n; ++i) {
    double res = sqrt(z[i][0]*z[i][0]+z[i][1]*z[i][1]);
    if(res<=d) ++cnt;
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 6908
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        if (cin.nextint + cin.nextint >= cin.nextint)
        {
            WriteLine("Yes");
        }
        else
        {
            WriteLine("No");
        }
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

ll d[1000010];
bool used[1000010];

ll s;
ll f(int i) {
    if(used[i]) return d[i];
    used[i] = true;
    if(i == 1) return d[i] = s;
    ll a = f(i-1);
    if(a&1) return d[i] = 3*a+1;
    else return d[i] = a / 2;
}

int main(){
    cin >> s;
    f(1000005);
    set<ll> st;
    REP(i, 1, 1000005) {
        if(st.count(d[i])) {
            cout << i << endl;
            return 0;
        }
        st.insert(d[i]);
    }
    return 0;
}

Measured memory_bytes: 24704
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long ll;
int main() {
	int n; cin >> n;
	int ai;
	ll a = 1, b = 1;
	for (int i = 0; i < n; i++) {
		cin >> ai;
		a *= 3;
		b *= (ai % 2) ? 1 : 2;
	}
	cout << a - b << endl;
	char c; cin >> c;
}

Measured memory_bytes: 888
N = int(input())
A = list(map(int, input().split()))

res = True
maxvar = max(A)

x = 0
y = 0

for i in range(N):
    if A[i] == maxvar:
        x += 1
    elif A[i] == maxvar - 1:
        y += 1
    else:
        res = False
        break
else:
    if (maxvar - y) * 2 + y > N or (maxvar - y) * 2 <= 0 or y >= maxvar:
        res = False

    if maxvar == N - 1 and y == 0:
        res = True

print('Yes' if res else 'No')

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

#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define eb emplace_back
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)
#define mmst(v) memset(v, 0, sizeof(v))

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;

const long kMAX = 1000000000;

using namespace std;
using ll = long long;

inline int readInt() {
  char c = getchar();
  while(!isdigit(c) && c != '-') c = getchar();
  int sigma = 1;
  if (c == '-') {
    sigma = -1;
    c = getchar();
  }
  int x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * sigma;
}

long d[kMax5][13];

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

  int n;
  cin >> n;

  int hi;
  cin >> hi;
  rep(i, 2, n) {
    int hj;
    cin >> hj;
    if (hj < hi) { cout << "No\n"; return 0; }
    else if (hj > hi) { --hj; }
    hi = hj;
  }
  cout << "Yes\n";

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
	ll n;
	vector<ll> arr(5);
	cin >> n;
	for(int i = 0; i < 5; i++) {
		cin >> arr[i];
	}
	ll mx = 0;
	for(int i = 0; i < 5; i++) {
		if(n%arr[i]==0LL) mx = max(mx,n/arr[i]);
		else mx = max(mx,n/arr[i]+1);
	}
	cout << (mx+4LL) << endl;
	return 0;
}


Measured memory_bytes: 256
while true do
   h, w = gets.split.map(&:to_i)
   if h == 0 && w == 0
      break
   end
   h.times do |i|
      if i == 0 || i == h - 1
         puts "#{"#" * w}"
      else
         puts "##{"." * (w - 2)}#"
      end
   end
   puts ""
end

Measured memory_bytes: 8792
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <set>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N,0);

    map<ll, deque<ll>> s;
    ll ans=0;
    for(int i=0; i<N; i++){
        ll a;
        cin >> a;
        a--;
        a%=K;
        if(i>0){
            A[i]=a+A[i-1];
            A[i]%=K;
        }else{
            A[i]=a;
        }
    }

    s[0].push_back(-1);
    for(int i=0; i<N; i++){
        ll a=A[i];
        if(s.count(a)){
            while((int)s[a].size()>0 && i-s[a].front()>=K){
                s[a].pop_front();
            }
            ans+=(ll) s[a].size();
        }
        s[a].push_back(i);
      	//cout << i << ' ' << A[i] << ' ' << ans <<  endl;
    }

    cout << ans << endl;
}

Measured memory_bytes: 145536
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  ll sum = a;
  for (int i = 0; i < 1000; i++) {
    if (sum % b == c) {
      cout << "YES" << endl;
      return 0;
    }
    sum += a;
  }
  cout << "NO" << endl;
  return 0;
}

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

const ll LINF=1e18;

int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll> A(n),F(n);
    for(ll i=0;i<n;i++) cin >> A[i];
    for(ll i=0;i<n;i++) cin >> F[i];

    sort(A.begin(),A.end());
    sort(F.rbegin(),F.rend());
    // 2分探索
    ll l=-1,r=LINF;
    while(r-l>1){ // 探索区間幅が1になるまで
        ll m=(r+l)>>1; //1bit 右シフト
        ll cnt=0;
        for(ll i=0;i<n;i++){
            if(A[i]*F[i]>m){
                cnt+=(A[i]*F[i]-m)/F[i]; // A[i]について必要な修行回数
                if((A[i]*F[i]-m)%F[i]) cnt++;
            }
        }
        if(cnt>k) l=m; // kより改善する必要があれば基準を大きく
        else r=m; // kより改善する必要が無ければ基準を小さく
    }
    cout << r << endl;
    return 0;
}

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

int main(){
    int a,b,c,d,e,f;
    cin >> a >> b >> c >> d >> e >> f;
    
    int num;
    int g,h;
    cin >> num;
    for(int i=0; i<num; i++){
        cin >> g >> h;
        for(int i=0; !(a==g && b==h); i++){
            if(d==h || c==h){
                int tmp = a;
                a = d;
                d = f;
                f = c;
                c = tmp;
            }
            for(int i=0; b!=h; i++){
                int tmp=a;
                a = b;
                b = f;
                f = e;
                e = tmp;
            }
            for(int i=0; a!=g; i++){
                int tmp=a;
                a = d;
                d = f;
                f = c;
                c = tmp;
            }
        }
        cout << c << endl;
    }
}

Measured memory_bytes: 3084
#include<stdio.h>
#include<ctype.h>
 
int main(void){
 
    char str[1200];
    int i;
    for(i=0;i<1200;i++)str[i]='\n';
    scanf("%[^\n]",str);
    i=0;
    while(1){
        if(str[i]=='\n'){break;}
        if(islower(str[i])){str[i]=toupper(str[i]);}
        else if(isupper(str[i])){str[i]=tolower(str[i]);}
        i++;
 
    }printf("%s\n",str);
 
 
    return 0;
}

Measured memory_bytes: 524
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

h,w=MI()
lis=[[0 for i in range(w+2)] for j in range(h+2)]
for i in range(h):
    u=list(input().rstrip())
    #print(u)
    for j in range(w):
        if u[j]=="#":
            lis[i+1][j+1]=1
step=[[1,0],[-1,0],[0,1],[0,-1]]
#print(lis)
for i in range(1,h+1):
    for j in range(1,w+1):
        if lis[i][j]==1:
            count=0
            for x,y in step:
                if lis[i+x][j+y]==1:
                    count+=1
            if count==0:
                print("No")
                sys.exit()
print("Yes")

Measured memory_bytes: 3440
#include <iostream>

using namespace std;

int main()
{
	for(int e;cin>>e,e;){
		int res=1000000;
		for(int z=0;z*z*z<=e;z++)
			for(int y=0;y*y+z*z*z<=e;y++){
				int x=e-(y*y+z*z*z);
				res=min(res,x+y+z);
			}
		cout<<res<<endl;
	}
	
	return 0;
}

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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define data asd09123jdf02i3h

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 1e9+7;

int n,m,a[maxn];

int main() {
    read(n),read(m);
    for(int i=1,x,y;i<=m;i++) read(x),read(y),a[x]++,a[y]++;
    for(int i=1;i<=n;i++) if(a[i]&1) return puts("NO"),0;
    puts("YES");
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> cmin(26, 1e9+7);
int main() {
    cin >> n;
    for(int i = 0; i < n; ++i) {
        string s;
        vector<int> c(26, 0);
        cin >> s;
        int slen = s.length();
        for(int i = 0; i < slen; ++i) {
            c.at(s.at(i) - 97)++;
        }
        for(int i = 0; i < 26; ++i) {
            cmin.at(i) = min(cmin.at(i), c.at(i));
        }
    }

    char cnow = 'a';
    for(int i = 0; i < 26; ++i) {
        int clen = cmin.at(i);
        for(int j = 0; j < clen; ++j) {
            cout << cnow;
        }
        cnow++;
    }
}

Measured memory_bytes: 256
n,m=map(int,input().split())
u,v=[],[]
path=[[] for i in range(n)]
for i in range(m):
    ui,vi=[int(x)-1 for x in input().split()]
    path[ui].append(vi)
    # path[vi].append(ui)
s,t=[int(x)-1 for x in input().split()]
from collections import deque
q=deque()
q.append((s,0))
# print(path)
check=[[False]*n for x in [0,1,2]]
while q:
    # print(q)
    p,num=q.popleft()
    if check[num%3][p]==True:
        continue
    if num%3!=0:
        for i in path[p]:
            q.append((i,num+1))
        check[num%3][p]=True
        continue
    elif p==t:
        print(num//3)
        import sys
        sys.exit()
    else:
        for i in path[p]:
            q.append((i,num+1))
        check[0][p]=True
print(-1)

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

using namespace std;
typedef unsigned long long ll;

ll solve(ll a , ll b){
    ll count = 1;
    while(a * 2 <= b){
        a *= 2;
        count++;
    }
    return count;
}

int main(){
    ll x,y; cin >> x >> y;
    ll ans = solve(x, y);
    
    cout << ans << endl;
}


Measured memory_bytes: 256
ast = input()
bst = input()
cst = input()

turn = "a"
while(1):
  if turn == "a":
    if len(ast) == 0:
      print("A")
      break
    else:
      turn = ast[0]
      ast = ast[1:]
  elif turn == "b":
    if len(bst) == 0:
      print("B")
      break
    else:
      turn = bst[0]
      bst = bst[1:]
  else:
    if len(cst) == 0:
      print("C")
      break
    else:
      turn = cst[0]
      cst = cst[1:]

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstdio>
#define INF 99999999
using namespace std;
typedef pair <int,int> P;
int sx,sy; 
int H,W,N;
int ans=0,g=0;
char S[1010][1010];
int gx,gy;
int d[1010][1010];
int dx[4] = {0,1,0,-1},dy[4] = {1,0,-1,0};
int bfs();
int main(){
  cin >> H >> W >> N;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> S[i][j];
      if(S[i][j] == 'S'){
	sx = i;
	sy = j;
      }
    }
  }
  for(int i=0;i<N;i++){
    int res = bfs();
    ans += res;
    g++;
  }
  cout << ans <<  endl;
}
int bfs(){
  queue <P> qu;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      d[i][j] = INF;
      if(S[i][j] == '1' + g){
	gx = i;
	gy = j;
      }
    }
  }
  qu.push(P(sx,sy));
  d[sx][sy] = 0;
  while(!qu.empty()){
    P p = qu.front();
    qu.pop();
    if(p.first == gx && p.second == gy)break;
    for(int i=0;i<4;i++){
      int nx = p.first + dx[i];
      int ny = p.second + dy[i];
      if(0 <= nx && nx < H && 0 <= ny && ny < W && S[nx][ny] != 'X' && d[nx][ny] == INF){
	qu.push(P(nx,ny));
	d[nx][ny] = d[p.first][p.second] + 1;
      }
    }
  }
  sx = gx;
  sy = gy;
  return d[gx][gy];
}

Measured memory_bytes: 6188
// https://atcoder.jp/contests/abc053/tasks/arc068_a
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll x;
    cin >> x;
    ll ans = (x / 11) * 2;
    ll t = x % 11;
    if (t > 0 && t <= 6)
        ans++;
    else if (t >= 7)
        ans += 2;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lol long long
#define inf 1000000000000000000
using namespace std;
int main(){
  int a;
  for(int i=0;i<5;i++){
    cin>>a;
    if(a==0) cout<<i+1<<"\n";
  }
  return(0);
}


Measured memory_bytes: 3532
/**
*    created: 21.06.2020 21:10:37
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcount(bit)
#define mod 1000000007
#define pi acos(-1.0)
using namespace std;

signed main() {

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

    int n;
    cin >> n;
    map<int,int> mp;
    int sum = 0;
    rep(i,n) {
        int a;
        cin >> a;
        mp[a]++;
        sum += a;
    }
    int q;
    cin >> q;
    int b, c;
    rep(i,q) {
        cin >> b >> c;
        if (mp[b] > 0) {
            sum +=  (c - b) * mp[b];
            cout << sum << endl;
            int t = mp[b];
            mp.erase(b);
            mp[c] += t;
        }
        else cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 7604
//2013/07/15(月) パソコン甲子園２０１０ー４　人気のアイスクリーム店

#include <iostream>
using namespace std;

int main()
{

	int n;
	int x;
	
	while(true){
		int k[10] = {0};

		cin >> n;
		if(n==0)
			break;

		for(int i=0; i<n; i++){
			cin >> x;
			k[x]++;
		}
		for(int i=0; i<10; i++){
			if(k[i] == 0)
				cout << '-' << endl;
			else{
				for(int j=0; j<k[i]; j++)
					cout << '*' ;
				cout << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1152
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	ll n; cin >> n;
	ll ans = LLINF;
	rep(i, n){
		ll a; cin >> a;
		ll k = 0;
		while(a % 2 == 0){
			a /= 2;
			k++;
		}
		chmin(ans, k);
	}

	cout << ans << endl;

	return 0;
}


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

int main() {
    int N, L; cin >> N >> L;
    int taste = 0;
    for (int i = 0; i < N; i++) {
        taste += (L+i);
    }
    if (L <= 0 && L+N > 0) cout << taste << endl; 
    else if (L+N <= 0) cout << taste-(L+N-1) << endl;
    else cout << taste-L << endl;
}

Measured memory_bytes: 256