akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fin cin
#define fout cout
using namespace std;
//ifstream fin("data.in");
//ofstream fout("data.out");
int main()
{
    //ios_base::sync_with_stdio(false);
    //fin.tie(NULL), fout.tie(NULL);
    string s;
    fin >> s;
    if (s == "ABC")
        fout << "ARC";
    else fout << "ABC";
    //fin.close(), fout.close();
    return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        double xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2;
        if(!(cin >> xa1 >> ya1 >> xa2 >> ya2 >> xb1 >> yb1 >> xb2 >> yb2))
            return 0;

        if(ya1 <= yb2 && yb1 <= ya2 && xa1 <= xb2 && xb1 <= xa2)
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
}

Measured memory_bytes: 0
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

{
    fast
    string s,t;
    cin>>s>>t;
    t.pop_back();
    if(s==t)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;

}





































Measured memory_bytes: 3624
l,r=map(int,input().split())
ans=2018
d=r-l
if d>2019:
    d=2019

for i in range(l%2019,l%2019+d):
    for j in range(i+1,l%2019+d+1):
        a=(i*j)%2019
        if a<ans:
            ans=a
print(ans)


Measured memory_bytes: 2940
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

# 最小公倍数
def gcd(a, b):
	if a < b:
		a, b = b, a
	while a % b != 0:
		a, b = b, a % b
	return b
 
# 最大公約数 
def lcm(a, b):
	y = a*b / gcd(a, b)
	return int(y)

a, b, k = MAP()

if a <= k:
	k = k - a
	a = 0
	if b <= k:
		b = 0
	elif b > k:
		b = b - k
elif a > k:
	a = a - k
	
print(a, b)




# while k > 0:
#   if a >= 1:
#     a = a - 1
#   elif b >= 1:
#     b = b - 1
#   k = k - 1


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

using namespace std;

#define ll long long
#define ld long double

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

	int nx = 1;
	for (int i = 0; i < n; ++i)
		if (a[i] == nx)
			++nx;

	if (nx == 1) cout << -1 << endl;
	else cout << (n - nx + 1) << endl;

	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=20+10;

int n,p[maxn];
int kq=0;

int main(){
  cin>>n;
  for(int i=1;i<=n;i++) cin>>p[i];
  for(int i=2;i<=n-1;i++){
    if (p[i-1]<p[i] && p[i]<p[i+1]) kq++;
    if (p[i-1]>p[i] && p[i]>p[i+1]) kq++;
  }
  cout<<kq;
}


Measured memory_bytes: 256
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    static Scanner sc = null;
    static PrintWriter pw = null;

    static {

        try {
            sc = new Scanner(System.in);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private static final long MOD = 1_000_000_007;

    public static void main(String[] args) {
        String x = sc.nextLine();
        int a = sc.nextInt();
        switch (a) {
            case 1:
                System.out.println(p1(x));
                break;
            case 2:
                System.out.println(p2(x));
                break;
            case 3:
                System.out.println(p3(x));
                break;
        }

    }

    private static final String r0(String s) {
        if (s.length() == 0) return s;
        if (s.charAt(0) == '0') return r0(s.substring(1));
        return s;
    }

    private static long p1(String a) {
        a = r0(a);
        if (a.length() < 1) return 0;

        return 9 * (a.length() - 1) + (a.charAt(0) - '0');
    }

    private static long p2(String a) {
        a = r0(a);
        if (a.length() < 2) return 0;

        int rr = a.length() - 1;


        return 9 * 9 * rr * (rr - 1) / 2 + p1(a.substring(1)) + (a.charAt(0) - '1') * 9 * rr;
    }

    private static long p3(String a) {
        a = r0(a);
        if (a.length() < 3) return 0;

        int rr = a.length() - 1;

        return 9 * 9 * 9 * rr * (rr - 1) * (rr - 2) / 6 + p2(a.substring(1)) + (a.charAt(0) - '1') * 9 * 9 * rr * (rr - 1) / 2;
    }
}


Measured memory_bytes: 23636
from math import ceil

def solve(n, h, AB):
    max_attack_index = 0
    for i in range(1, n):
        if AB[max_attack_index][0] < AB[i][0]:
            max_attack_index = i
    throw_damages = []
    for _, b in AB:
        if AB[max_attack_index][0] < b:
             throw_damages.append(b)
    throw_damages.sort(reverse=True)
    count = 0
    for damage in throw_damages:
        h -= damage
        count += 1
        if h <= 0:
            return count
    return ceil(h / AB[max_attack_index][0]) + count

_n, _h = map(int, input().split())
_AB = [list(map(int, input().split())) for _ in range(_n)]
print(solve(_n, _h, _AB))


Measured memory_bytes: 28588
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(string[] args)
    {
        var n = Int32.Parse(Console.ReadLine());
        var l = Console.ReadLine().Split(' ').Select(x => x.ToCharArray()).ToArray();
        var s = l[0]; var t = l[1];
        for (var i = 0; n > i; i++)
        {
            Console.Write($"{s[i]}{t[i]}");
        }
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <utility>
#include <iomanip>
#include <cmath>
#include <set>
#include <functional>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr ll MOD = 1e4 + 7;
 
int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N;
    string s,t;cin>>N>>s>>t;
    int ans = s.size() + t.size();
    int cnt=0;
    while(!s.empty()){
        bool ok = true;
        REP(i,s.size()){
            if(s[i]!=t[i]) ok = false;
        }
        if(ok) { cnt = s.size(); break;}
        s.erase(0,1);
    }
    cout << ans - cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import itertools
import math
n = int(input())
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))

ans = list(itertools.permutations(range(1,n+1)))         

a = 0
b = 0
for i in range(len(ans)) :
  if ans[i] == p:
    a = i+1
  if ans[i]== q:
    b = i+1
      
print(abs(a-b))
      

Measured memory_bytes: 7972
#include <bits/stdc++.h>
using namespace std;
struct _I { _I() {cin.tie(0);ios::sync_with_stdio(false);}} __I;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class F, class S> istream& operator >> (istream& s, pair<F, S>& p)
{ cin >> p.first >> p.second; return s;}
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

template<class T> class XY {
public:
    T x, y;   
    XY(T _x=0, T _y=0) : x(_x), y(_y) {}
    XY(const XY& p) { *this=p; }
    XY& operator=(const XY& p) { x=p.x; y=p.y; return *this; }
};
template<class T> inline XY<T> operator-(const XY<T>& p1, const XY<T>& p2) { return XY<T>(p1.x-p2.x,p1.y-p2.y); }
template<class T> inline XY<T> operator+(const XY<T>& p1, const XY<T>& p2) { return XY<T>(p1.x+p2.x,p1.y+p2.y); }
template<class T> inline istream& operator >> (istream& s, XY<T>& p) { s >> p.x >> p.y; return s;}
double distance_squared(const XY<double>& p1, const XY<double>& p2)
{ XY<double> d = p1 - p2; return d.x*d.x+d.y*d.y; }

int N;
vector<XY<double>> xy;

double f(const XY<double>& o)
{
    double res = 0.0;
    rep(i, N) {
        double d = distance_squared(xy[i], o);
        if (d > res) res = d;
    }
    return res;
}

double g(double x)
{
    double l = 0, r = 1000; // 円の中心のy座標    
    rep(i, 100) {
        double c1 = l  + (r-l)/3.0;
        double c2 = c1 + (r-l)/3.0;
        if (f(XY<double>(x, c1)) > f(XY<double>(x, c2))) {
            l = c1;
        } else {
            r = c2;
        }
    }
    return f(XY<double>(x, l));
}

int main()
{
    cout<<std::fixed<<std::setprecision(10);

    cin >>N;
    xy.resize(N); cin >> xy;

    double l = 0, r = 1000; // 円の中心のx座標

    rep(i, 100) {
        double c1 = l  + (r-l)/3.0;
        double c2 = c1 + (r-l)/3.0;
        if (g(c1) > g(c2)) {
            l = c1;
        } else {
            r = c2;
        }
    }
    double ans = sqrt(g(l));
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;

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

int main() {
  int n, k;
  cin >> n >> k;

  int ans = 0;
  while (n > 0) {
    ++ans;
    n /= k;
  }

  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;

class Dijkstra
{
    int V;
    double inf;
    vector<double> distance;
    double eps;
public:
    vector<vector<double> > e;
    Dijkstra(int V, double inf) : V(V), inf(inf), eps(1E-5)
    {
        e = vector<vector<double> >(V, vector<double>(V, inf));
        for (int i=0; i<V; i++) e[i][i] = 0;
    }
    void update_edge(int v1, int v2, double d)
    {
        e[v1][v2] = e[v2][v1] = min(e[v1][v2], d);
    }

    double dijkstra(int from, int to)
    {
        distance = vector<double>(V, inf);
        using Pque = pair<double, int>;
        priority_queue<Pque, vector<Pque>, greater<Pque> > que;
        que.push(make_pair(0.0, from));
        while (true)
        {
            int now = que.top().second;
            double dist_tmp = que.top().first;
            if (now == to) return dist_tmp;
            que.pop();

            if (distance[now] > dist_tmp + eps)
            {
                distance[now] = dist_tmp;
                for (int i=0; i<V; i++)
                {
                    if (i == now) continue;
                    if (distance[i] > distance[now] + e[now][i] + eps)
                    {
                        que.push(make_pair(distance[now] + e[now][i], i));
                    }
                }
            }
        }
    }
};

int N;
lint xs, ys, xt, yt;
vector<int> r;
vector<P> x;

double d(P p1, P p2)
{
    return sqrt((double)((p1.first - p2.first) * (p1.first - p2.first) + (p1.second - p2.second) * (p1.second - p2.second)));
}

int main()
{
    cin >> xs >> ys >> xt >> yt >> N;
    r.resize(N);
    x.resize(N);
    for (int i=0; i<N; i++) cin >> x[i].first >> x[i].second >> r[i];

    Dijkstra dij(N+2, 1E10);
    for (int i=0; i<N; i++)
    {
        dij.update_edge(i+1, 0, max(d(make_pair(xs, ys), x[i]) - r[i], 0.0));
        dij.update_edge(i+1, N+1, max(d(make_pair(xt, yt), x[i]) - r[i], 0.0));
        for (int j=0; j<i; j++)
        {
            dij.update_edge(i+1, j+1, max(0.0, d(x[i], x[j]) - r[i] - r[j]));
        }
    }
    dij.update_edge(0, N+1, d(make_pair(xs, ys), make_pair(xt, yt)));

    cout << setprecision(11) << dij.dijkstra(0, N+1) << endl;
}


Measured memory_bytes: 18412
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>

using namespace std;


/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back


/*---  Type ---*/
typedef long long ll;


/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;


// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)


// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------

int main() {
  ll h, w;
  cin >> h >> w;

  ll ans = INF<ll>;
  // 縦に2本入れるパターン
  ans = min(ans, h*((w+2)/3) - h*(w/3));

  // 横に2本入れるパターン
  ans = min(ans, ((h+2)/3)*w - (h/3)*w);

  // 縦に1本入れ、右側を真っ二つにするパターン
  rep1(i, w/2+1) {
    ll c1=h*i, c2=((h+1)/2)*(w-i), c3=(h/2)*(w-i);
    ll max_c = max(c1, c2, c3);
    ll min_c = min(c1, c2, c3);
    ans = min(ans, max_c - min_c);
  }

  // 横に1本入れ、下側を真っ二つにするパターン
  rep1(i, h/2+1) {
    ll c1=i*w, c2=(h-i)*((w+1)/2), c3=(h-i)*(w/2);
    ll max_c = max(c1, c2, c3);
    ll min_c = min(c1, c2, c3);
    ans = min(ans, max_c - min_c);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;


  int parent[N];
  int sz[N];

  void make_set(int n)
  {
  	for(int i = 0; i <= n; i++)
  	{
  		parent[i] = i;
  		sz[i] = 1;
  	}
  }

  int getParent(int s)
  {
  	if(s == parent[s])return s;
  	else return parent[s] = getParent(parent[s]);
  }

  void join(int a,int b)
  {
  	a = getParent(a);
  	b = getParent(b);
  	if(a != b)
  	{
  		parent[b] = a;
  		sz[a] += sz[b];
  		sz[b] = 0;
  	}
  }

int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS



    int n,m;
    cin >> n >> m;

    make_set(n);

    for(int i = 1; i <= m; i++)
    {
    	int x,y;
    	cin >> x >> y;
    	join(x,y);

    }

    int ans = 0;

    for(int i = 1; i <= n; i++)
    {
    	int p = getParent(i);
    	ans = max(sz[p],ans);
    }

    cout << ans;



    return 0;
}


Measured memory_bytes: 6856
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <limits.h>
#include <math.h>

using namespace std;

int main(){
    int n;
    cin >> n;
    map<int,int> da;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        if(da.count(x)){
            da[x]++;
        }
        else{
            da[x]=0;
        }
    }
    int ans1=0,ans2=0;
    for(auto i:da){
        if(i.second>0){
            int x=i.first;
            if(ans1<x){
                ans2=ans1;
                ans1=x;
                continue;
            }
            if(ans2<x){
                ans2=x;
            }
        }
    }
    if(da[ans1]>2){
        cout << (long long)ans1*ans1 << endl;
    }
    else{
        cout << (long long)ans2*ans1 << endl;
    }
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define si(x)    scanf("%d",&x)
#define sl(x)    scanf("%lld",&x)
#define ss(s)    scanf("%s",s)
#define pi(x)    printf("%d\n",x)
#define pl(x)    printf("%lld\n",x)
#define ps(s)    printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define in insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>    pii;
typedef pair<ll, ll>      pl;
typedef vector<int>       vi;
typedef vector<ll>        vl;
typedef vector<pii>       vpii;
typedef vector<pl>        vpl;
typedef vector<vi>        vvi;
typedef vector<vl>        vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
#define MAXN   20000001 
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}

int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;



void solve(){
    char a;
    cin>>a;
    if(a>=65 && a<=91)
    {
        cout<<"A"<<endl;
    }
    else
    {
        cout<<"a"<<endl;
    }
}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t = 1;
   // cin >> t;
    while(t--) {
      solve();
    }

    return 0;
}

vl g[N];


int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m){
    int i, u, v;
    while(m--){
        cin>>u>>v;
    u--, v--;
        g[u].pb(v);
        g[v].pb(u);
    }
}

void dfs(int u, int par){
    for(int v:g[u]){
        if (v == par) continue;
        dfs(v, u);
    }
}


Measured memory_bytes: 10644
N, M = map(int,input().split())
L = 0
R = 0
Lmax = 0
Rmin = 100000
for i in range(0,M):
  L, R = map(int,input().split())
  if L > Lmax:
    Lmax = L
  if R < Rmin:
    Rmin = R

result = Rmin - Lmax + 1
if result < 0:
    result = 0
print(result)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N; cin >> N;
  vector<vector<pair<int,int>>> axy(N);
  rep(i,N){
    int A; cin >> A;
    rep(a,A){
      int x, y; cin >> x >> y;
      axy[i].pb({x-1, y});
    }
  }
  int ans = 0;
  rep(i,pow(2,N)){
    int state = i;
    int preans = 0;
    bool flag = true;
    vector<int> tf(N);
    rep(j,N){
      tf[j] = state%2;
      state/=2;
    }
    vector<int> st(N, 0);
    rep(j,N){
      if(tf[j] == 1){
        st[j] = 1;
        preans++;
      }
    }
    rep(j,N){
      if(st[j] == 0) continue;
      rep(k, (int)axy[j].size()){
        if(st[axy[j][k].first] != axy[j][k].second){
          flag = false;
        }
      }
    }
    if (flag)ans = max(ans, preans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"Yes"<<'\n'
#define no cout<<"No"<<'\n'
using namespace std;

int main()
{
    godspeed
    ll  i,j,k,l,n,x,ans=INT_MAX;
    string s;
    cin>>n;
    for(i=0;i<n;i++){
    ll opt=0;
    cin>>x;
    while(x%2==0)
    {
        opt++;
        x/=2;
    }
    ans=min(ans,opt);

    }
    cout<<ans<<endl;
    return 0;
}





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

#define FOR(i,l,r) for(int i = int(l);i < int(r);i++)
template<typename T> bool chmax(T& a,const T& b){ return a < b ? (a = b,true) : false; }
template<typename T> bool chmin(T& a,const T& b){ return b < a ? (a = b,true) : false; }
typedef long long ll;

int N;
vector<int> A;

int main()
{
	scanf("%d",&N);
	A.assign(N,0);
	map<int,int> mp;
	FOR(i,0,N){
		scanf("%d",&A [i]);
		mp [A [i]]++;
	}

	int ans = 0;
	FOR(i,-10,100010){
		chmax(ans,mp [i - 1] + mp [i] + mp [i + 1]);
	}
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 5376
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    s = f.read_str()
    x, y = f.read_int_list()

    l = s.split('T')
    x0 = len(l[0])

    ys = {0}
    for i in l[1::2]:
        ys2 = set()
        yi = len(i)
        for item in ys:
            ys2.add(item+yi)
            ys2.add(item-yi)
        ys = ys2

    if y not in ys: return 'No'

    xs = {x0}
    for i in l[2::2]:
        xs2 = set()
        xi = len(i)
        for item in xs:
            xs2.add(item+xi)
            xs2.add(item-xi)
        xs = xs2

    if x not in xs: return 'No'

    return 'Yes'


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


Measured memory_bytes: 5084
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <map>
#include <numeric>
#include <iomanip>

int main(void) {
	std::string s;

	std::cin >> s;

	int upper = 0, upper0;
	char last_upper;

	for (size_t i = 0; i < s.length(); i++) {
		if (isupper(s[i])) {
			upper++;
			last_upper = s[i];
			upper0 = i;
		}
	}

	if (upper != 2 || s[0] != 'A' || last_upper != 'C') {
		std::cout << "WA" << std::endl;
		return 0;
	}

	if (2 <= upper0 && upper0 <= s.length() - 2) {
		std::cout << "AC" << std::endl;
		return 0;
	}

	std::cout << "WA" << std::endl;

	return 0;
}

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

using ll = long long;
const ll amari = 1e9+7;
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)

int main(){
	int n;
	cin >> n;
	int a[100];
	double ave = 0.0;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		ave += a[i];
	}
	ave /= 1.0 * n;
	int ans = 0;
	double ok = 99999999;
	for(int i = 0; i < n; i++){
		if(abs(a[i] - ave) < ok){
			ok = abs(a[i] - ave);
			ans = i;
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main (){
  vector<ll>v(5,0);
  for(ll i=0;i<5;i++){
    cin>>v[i];
  }
  ll ans=0;
  ll f=10;
  for(ll i=0;i<5;i++){
    if(v[i]%10!=0){
      f=min(f,v[i]%10);
    }
  }
  if(f==10){
    for(ll i=0;i<5;i++){
      ans+=v[i];
    }
    cout<<ans<<endl;
  }
  else{
    for(ll i=0;i<5;i++){
      if(v[i]%10!=0){
        ans+=(v[i]-v[i]%10+10);
      }
      else{
        ans+=v[i];
      }
    }
    ans-=(10-f);
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//---------------------------------------------------------------------------
bool color[200001];
//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int a,b,c;cin>>a>>b>>c;
    if(c>=a&&c<=b)cout<<"Yes"<<Endl;
    else if(c>=b&&c<=a)cout<<"Yes"<<Endl;
    else cout<<"No"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------

/*
ll n;cin>>n;
vector<ll>a(n);
for(ll i=0;i<n;i++)
    cin>>a[i];
 
ll n;cin>>s;
string s;cin>>s;

ll n,m;cin>>n>>m;
vector<ll>a(n),b(m);
for(ll i=0;i<n;i++){
    cin>>a[i];
}
for(ll i=0;i<m;i++){
    cin>>b[i];
}

ll n;cin>>n;
vector<Pll>xy;
for(ll i=0;i<n;i++){
    ll x,y;cin>>x>>y;
    xy.pb({x,y});
}
*/


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

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;}

const ll mod=1e9+7;

int main(){
    ll n;
    cin >> n;
    ll ans=0;
    for(ll i=1;i<=100000;i++){
        if(i*i<=n){
            ans=i*i;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
// ------------------------------------
// Date:2018/ 2/18
// Problem:ABC 088 _ a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto&& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)

int main()
{
  int N,A,x;
  cin >> N >> A;
  x = N%500;
  if (x<=A) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define ll long long

using namespace std;

int main() {
	ll t, x, ans = 1;
	cin >> t;
	while (t--) {
		cin >> x;
		if (!x) {
			ans = 0;
			break;
		}
		if (1000000000000000000ll / ans < x)
			ans = -1;
		else
			ans *= x;
	}
	cout << ans;
}

Measured memory_bytes: 3632
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <tuple>
#include <string>
using namespace std;
#define ll int64_t
const long MOD = 1e9 + 7;
const long LINF = 1e13;
const long LLINF = 1e18;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}



int main() {

  long n, m;
  cin >> n >> m;
  vector<long>p(m);
  vector<long>y(m);
  vector<tuple<long, long, long>> npy(m);//前からイテレータ,所属市、年

  for (long i = 0; i < m; ++i){
    cin >> p[i] >> y[i];
    npy[i] = make_tuple(i , p[i], y[i]);
  }


  sort(npy.begin(), npy.end(), [](tuple<long, long, long> &l, tuple<long, long, long>&r) {
    return get<2>(l) < get<2>(r);
  });

  vector<long> ken(n+1,0);
  // long ken[1000001];
  // for (long i = 0; i < n+1; ++i){
  //   ken[i] = 1;
  // }
  vector<string> ans(m);



  for (long i = 0; i < m; ++i) {
    // cerr << get<0>(npy[i]) << " : " << get<1>(npy[i]) << " : " <<  get<2>(npy[i]) << endl;

    ostringstream sout;
    sout << setfill('0') << setw(6) << get<1>(npy[i]);
    string pref = sout.str();

    ostringstream sout2;
    sout2 << setfill('0') << setw(6) << (ken[ get<1>(npy[i]) ] + 1 );
    string num = sout2.str();

    ans[ get<0>(npy[i]) ] =  pref + num;

    ken[ get<1>(npy[i]) ]+=1;
  }



  for (long i = 0; i < m; ++i) {
    cout << ans[i] << endl;
  }

}




























Measured memory_bytes: 11648
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define INF 1e9
typedef long long llong;
using namespace std;

int main(){
	int n,k;
	cin>>n>>k;
	
	vector<int> h(n);
	REP(i,n) cin>>h[i];
	
	vector<int> dp(n,INF);
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for(int i=2;i<n;++i){
		for(int j=1;j<=min(i,k);++j){
			dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]),dp[i]);
		}
	}
	
	cout<<dp[n-1]<<endl;
	return 0;
}//解答参考.

Measured memory_bytes: 1024
n,m = map(int,input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

cnt = 0
flg = 'No'

for i in range(n-m+1):
    for j in range(n-m+1):
        for k in range(m):
            for l in range(m):
                if a[i+k][j+l] == b[k][l]:
                    cnt += 1
        if cnt == m ** 2:
            flg = 'Yes'
        else:
            cnt = 0
print(flg)
    

Measured memory_bytes: 40560
using static System.Math;
using System;

public class Hello
{
	public static void Main()
	{
		string[] line = Console.ReadLine().Trim().Split(' ');
		var a = int.Parse(line[0]);
		var b = int.Parse(line[1]);
		Console.WriteLine(Max(a + b, Max(a - b, a * b)));
	}
}

Measured memory_bytes: 11092
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int main () {

    int a,b,c,d; cin >>a>>b>>c>>d;

    int res = min(a+c, a+d);
    res = min(b+c, res);
    res = min(b+d, res);

    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  long long a, b, n;
  cin>>a>>b>>n;
  long long ans;
  if(n >= b){
    ans = (a * (b - 1)) / b;
  }else{
    ans = (a * n) / b;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>
#include <limits>
#include <map>
#include <set>
#include <functional>

using namespace std;

int main()
{
  string S;

  cin >> S;

  for (int i = 0; i < 3; i++) {
    cout << S[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,n) for(int i=1;i<=n;i++)
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)
#define ll int64_t
#define all(v) v.begin(), v.end()

const int MOD = 1000000007;

int main() {

ll N; cin >> N ;

vector<string> s(N);

rep(i,N) cin>>s[i];

rep(i,N) sort(all(s[i]));

map<string,ll> A;

rep(i,N){
  if(A[s[i]]==0) A[s[i]]=1;
  else A[s[i]]++;
}

ll ans=0;

for(auto p:A){
  string key=p.first;
  ll value=p.second;

  ans+=value*(value-1)/2;
}

cout << ans << endl;


return 0;
}

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

using namespace std; 

#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mmp make_pair
#define st first
#define nd second
#define rd third
#define ll long long
#define pii pair <int, int>
#define tri pair <pii, int>
#define itr pair <int, pii>
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define Rep(i, n) for (int (i) = 0; (i) <= (int)(n); i++)
#define For(i, a, n) for (int (i) = (a); (i) <= (int)(n); i++)
#define Forn(i, a, n) for (int (i) = (a); (i) >= (int)(n); i--)
#define rep(i, n) for (int (i) = 1; (i) <= (int)(n); i++)
#define pi 3.1415926535897932384626433832795028841971
//#define LOCAL

const int INF = 1e9; 
const int Maxn = 1005; 
const int dx[] = {-1, 0, 1, 0}; 
const int dy[] = {0, 1, 0, -1}; 

struct pos { int first, second, third; }; 

int a, b; 

int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin); 
		freopen("output.txt", "w", stdout); 
	#endif
	
	scanf("%d%d", &a, &b); 
	
	printf("%d\n", (a - 1) * (b - 1)); 
	
	return 0; 
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
r=0
for i in range(n):
	r+=min(a[i],b[i])
	b[i]=max(b[i]-a[i],0)
	r+=min(a[i+1],b[i])
	a[i+1]=max(0,a[i+1]-b[i])
print(r)

Measured memory_bytes: 18624
#include<bits/stdc++.h>
    #define vll vector<ll>
    #define vi vector<int>
    #define vpll vector<pair<ll,ll>>
    #define pii pair<int,int>
    #define REP(i,a) for(int (i)=0; (i)<(a); (i)++)
    #define RREP(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
    #define REP2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
    #define MOD 1000000007
    #define ALL(v) v.begin(), v.end()
    #define m0(x) memset(x,0,sizeof(x))
    typedef long long ll;
     
    using namespace std;
     
    int main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int A,B,C;
      cin >> A >> B >> C;
      cout << max(0,C-(A-B));
     
      return 0;
    }

Measured memory_bytes: 256
def solve(n, m):
    if n == 2 or m == 2:
        return 0
    if min(n, m) == 1:
        if max(n, m) == 1:
            return 1
        else:
            return n * m - 2
    return n * m - 2 * (n + m) + 4


n, m = map(int, input().split())
print(solve(n, m))


Measured memory_bytes: 2940
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(){
	double xa, ya, ra, xb, yb, rb;
	double d;
	int n, i;

	scanf("%d", &n);
	for( i=0; i<n; i++ ){
		scanf("%lf %lf %lf %lf %lf %lf",
				&xa, &ya, &ra, &xb, &yb, &rb);
		d = sqrt( (xb-xa)*(xb-xa) + (yb-ya)*(yb-ya) );
		if( ra+rb < d )
			printf("0\n");
		else if( fabs(ra-rb) <= d )
			printf("1\n");
		else if( ra-rb > d )
			printf("2\n");
		else
			printf("-2\n");
	}

	return 0;
}

Measured memory_bytes: 620
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N, M;
  std::cin >> N >> M;
  std::vector<i64> operations(N, 0);
  for (i64 i = 0; i < M; ++i) {
    i64 a_i, b_i;
    std::cin >> a_i >> b_i;
    --a_i, --b_i;
    ++operations[a_i];
    ++operations[b_i];
  }

  std::cout << (std::all_of(operations.begin(), operations.end(), [](const i64& operation) { return operation % 2 == 0; }) ? "YES" : "NO") << std::endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

ll rec(ll s, ll x, map<pair<ll, ll>, ll>& memo)
{
  if (s == 0) { return 1; }
  else if (s == 1) { return 2; }

  pair<ll, ll> p = make_pair(s, x);
  if (memo.count(p) > 0) { return memo[p]; }
  ll ret = rec(s / 2, x / 2, memo) + rec((s - 1) / 2, (x - 1) / 2, memo);
  ret %= MOD;
  ret = (ret + rec((s - 2) / 2, x / 2, memo)) % MOD;
  return memo[p] = ret;
}

int main()
{
  ll N; scanf("%lld", &N);
  map<pair<ll, ll>, ll> memo;
  ll ans = rec(N, N, memo);
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 256
/*
      author : Nishikawa
      created: 09.08.2020 17:02:11
*/

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


int main(){
    string s,t;
    cin >> s >> t;
    for(int i=0; i<(int)s.size(); i++){
        if(s[i]!=t[i]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

#define INF 1e9

struct P
{
	int stage, cost, state;

	bool operator >(const P& p) const{
		return cost > p.cost;
	}
};

int main() {
	int n;
	while(cin >> n, n){
		vvi stage_times(n, vi(n + 1));
		REP(i, n){
			REP(j, n + 1){
				cin >> stage_times[i][j];
			}
		}

		vvi G(n, vi(1 << n, INF));

		priority_queue<P, vector<P>, greater<P>> que;
		que.push({-1, 0, (1 << n) -1});

		int res = -1;
		while(!que.empty()){
			P p = que.top(); que.pop();
			if(p.state == 0){
				res = p.cost;
				break;
			}
			 // LOG("stage %d cost %d state %d\n", p.stage,p.cost, p.state);

			REP(i, n){
				if(p.state & (1 << i)){//そのステージへ行ったことがない
					priority_queue<pii, vector<pii>, greater<pii>> costs;
					//装備を使わない
					costs.push({stage_times[i][0], 0});

					//なにか装備を使う
					REP(j, n){
						if (p.state & (1 << j)) continue; //そのステージをクリアしてないなら装備は使えない
						// LOG("can use %d\n", j);
						costs.push({stage_times[i][j + 1], j + 1});
					}

					int next_state = p.state & ~(1 << i);
					int next_cost = p.cost + costs.top().first;
					// LOG("cost %d use %d to %d\n",costs.top().first, costs.top().second, i);
					if (G[i*0][next_state] > next_cost){
						G[i*0][next_state] = next_cost;
						que.push({i, next_cost, next_state});
					}
				}
			}
		}

		cout << res << endl;
	}
}

Measured memory_bytes: 6480
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
from Queue import Queue


def main():
    num = int(stdin.readline())

    L = []
    for _ in xrange(num):
        L.append([int(s) for s in stdin.readline().split()[2:]])

    d = [-1] * num
    d[0] = 0
    q = Queue(100)
    q.put(0)
    while not q.empty():
        u = q.get()
        for v in L[u]:
            if d[v-1] < 0:
                d[v-1] = d[u] + 1
                q.put(v-1)

    for i, v in enumerate(d):
        print(i+1, v)


main()

Measured memory_bytes: 4872
from sys import stdin
input=stdin.readline

#S=input()
N = int(input())

N-=1

base=ord('a')

print_string=""

while (N >= 26):
  print_string=chr(base+N%26)+print_string
  N //= 26
  N-=1

#print(N)
print_string=chr(base+N%26)+print_string

#print(N)
print(print_string)
#N,K=list(map(int,input().split()))
#P=list(map(int,input().split()))

#P.sort()
#print(sum(P[:K]))

#print(A)

Measured memory_bytes: 9116
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <utility>
#include <cmath>
#include <queue>
#include <stack>

using namespace std;

#define mp make_pair
#define pb push_back
#define st first
#define nd second

typedef long long ll;
typedef vector<ll> vl;
typedef pair<int, int> ii;
typedef pair<ll,ll> pll;

int main() {
  //sieve

  vector<ll> prime;
  bool vis[1000100];
  for(int i = 0; i < 1000100; ++i) vis[i] = true;
  vis[0] = false;
  vis[1] = false;
  for(int i = 2; i * i < 1000100; ++i) {
    if(vis[i]) {
      for(int j = 2; i * j < 1000100; ++j) {
        vis[i * j] = false;
      }
    }
  }
  for(int i = 2; i < 1000100; ++i) {
    if(vis[i]) {
      prime.pb(i);
      //cout << i << endl;
    }
  }

  ll n, p;
  scanf("%lld %lld", &n, &p);
  ll ans = 1;
  if(n == 1) ans = p;
  else {
    int sz = prime.size();
    ll temp = p;
    for(int i = 0; i < sz; ++i) {
      if(prime[i] > temp) break;
      ll check = 0;
      while(temp % prime[i] == 0) {
        //cout << temp << endl;
        temp /= prime[i];
        ++check;
      }
      if(check >= n) {
        for(ll j = 0; j < check / n; ++j) {
          ans *= prime[i];
        }
      }
    }
  }
  printf("%lld\n", ans);
  return 0;
}


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

int main(){
int n,m,k,A;
cin >> n >> m;
bitset<31> b("1111111111111111111111111111111");
for (int i = 0;i < n;i++){
  bitset<31> a;
  cin >> k;
  for (int j = 0;j < k;j++){
    cin >> A;
    a.set(A,1);
  }
  b = b & a;
}
cout << b.count() << endl;
}

Measured memory_bytes: 256
# ABC061C - Big Array
import sys
input = sys.stdin.readline

def main():
    n, k = list(map(int, input().rstrip().split()))
    arr = sorted([list(map(int, input().rstrip().split())) for _ in range(n)])
    cur, cnt, ans = 0, 0, 0
    for i, j in arr:
        ans = i
        cnt += j
        if cnt >= k:
            break
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 28640