akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
clock_t t=clock();
namespace IO
{
	using namespace std;
	char buf[1<<22],Out[1<<22],*p1=buf,*p2=buf;
	int p3=-1,f=0;
	inline void file()
	{
		#ifdef NTFOrz
		freopen("file.in","r",stdin);
		#endif
	}
	inline char getchar()
	{
		return (p1==p2)&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;
	}
	inline void flush(){fwrite(Out,1,p3+1,stdout),p3=-1;}
	inline void check(){if (p3>(1<<21)) flush();}
	inline void putchar(char a){Out[++p3]=a;check();}
	inline void putline(string s)
	{
		int tmp=p3;
		while (p3-tmp<s.size()) putchar(s[p3-tmp]);
		putchar('\n');
	}
	inline char gc()
	{
		char c=getchar();
		while (!c||c=='\n'||c==' ') c=getchar();
		return c;
	}
	inline void chktime()
	{
		#ifdef NTFOrz
		printf("%dms\n",clock()-t);
		#endif
	}
}
namespace my_std
{
	using namespace std;
//	#define getchar IO::getchar
//	#define putchar IO::putchar
    #define Re register
    #define rep(i,a,b) for (Re int i=(a);i<=(b);i++)
    #define drep(i,a,b) for (Re int i=(a);i>=(b);i--)
    #define repv(i,v) for (Re int i=0;i<v.size();i++)
    #define go(u) for (Re int i=head[(u)];i;i=e[i].nxt)
    #define writesp(x) write(x),putchar(' '),IO::check()
    #define writeln(x) write(x),putchar('\n'),IO::check()
    #define mem(x,v) memset(x,v,sizeof(x))
    #define pb push_back
    #define fir first
    #define sec second
    #define MP make_pair
    typedef long long ll;
    typedef unsigned long long ull;
    typedef pair<int,int> pii;
    const int INF=0x7fffffff;
    inline int read()
    {
        ll sum=0,f=0;char c=getchar();
        while (!isdigit(c)) f|=(c=='-'),c=getchar();
        while (isdigit(c)) sum=(sum<<1)+(sum<<3)+(c^48),c=getchar();
        return f?-sum:sum;
    }
    void write(int k)
    {
        if (k<0) putchar('-'),k=-k;
        if (k>=10) write(k/10);
        putchar(k%10+48);
    }
	#define templ template<typename T>
    templ inline void chkmax(T &x,T y){if (x<y) x=y;}
    templ inline void chkmin(T &x,T y){if (x>y) x=y;}
}
using namespace my_std;
char c[114514];
int ___[114514];
stack<int>s;
inline int query(int x,int y)
{
	printf("? %d %d\n",x,y);fflush(stdout);
	scanf("%s",c+1);
	return c[1]=='Y';
}

int main()
{
	IO::file();
	int a=read(),b=read(),n=a+b;
	if (a<=b) return printf("Impossible\n"),0;
	rep(i,0,n-1)
	{
		if (!s.size()) s.push(i);
		else
		{
			if (query(s.top(),i)) s.push(i);
			else s.pop();
		}
	}
	rep(i,0,n-1) ___[i]=query(s.top(),i);
	printf("! ");
	rep(i,0,n-1) write(___[i]);
	IO::flush();
	IO::chktime();
	return 0;
}

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

using namespace std;

int main(){
  int n;
  cin >> n;
  priority_queue<pair<int,int>> p;
  for(int i=0;i<n;i++){
    int a,b;
    cin >> a >> b;
    p.emplace(b,a);
  }
  int t=1000000000;
  while(!p.empty()){
    pair<int,int> s=p.top();
    p.pop();
    t=min(t,s.first);
    t-=s.second;
  }
  if(t>=0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 2420
import numpy as np
N,X=map(int,input().split())
L=list(map(int,input().split()))
       
L=np.array(L)
D=np.zeros(N+1)
s=1
for i in range (1,N+1):
    D[i]=D[i-1]+L[i-1]

    if D[i]<=X:
        s+=1
    else:
        break
       
print (s)
       

Measured memory_bytes: 12388
from sys import stdin

N = int(stdin.readline())
A = list((int(wd) for wd in stdin.readline().split()))
B = list((int(wd) for wd in stdin.readline().split()))
C = list((int(wd) for wd in stdin.readline().split()))

ret = sum(B)
#print(ret)
for i in range(N-1):
    if A[i] + 1 == A[i+1]:
        #print(A[i], C[A[i]-1])
        ret += C[A[i]-1]
    pass
print(ret)


Measured memory_bytes: 3064
package main

import (
    "fmt"
    "sort"
)

func main() {
    var p, q, r int
    fmt.Scanf("%d %d %d", &p, &q, &r)
    candidates := []int{p + q, q + r, p + r, q + r, p + r, q + p}
    sort.Sort(sort.IntSlice(candidates))
    fmt.Printf("%d", candidates[0])
}

Measured memory_bytes: 512
N = int(input())
H = list(map(int,input().split()))
cnt = 0
while True:
    flag = 0
    for i in range(N):
        if H[i]>0:
            cur = i
            flag = 1
            break
    if flag==0:break
    cmin = H[cur]
    flag = 1
    for i in range(cur,N):
        if H[i]>0 and flag==1:
            cmin = min(cmin,H[i])
        elif H[i]>0 and flag==0:
            cur = i
            cmin = H[i]
            flag = 1
        else:
            cnt += cmin
            for k in range(cur,i):
                H[k] -= cmin
            cur = i
            cmin = 0
            flag = 0
    cnt += cmin
    for k in range(cur,N):
        H[k] -= cmin
print(cnt)

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

int main()
{
	int x, a, b;
	cin >> x >> a >> b;

	if( abs( x - a ) < abs( x - b ) ) {
		cout << "A" << endl;
	}
	else {
		cout << "B" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
    //static List<string> str = new List<string>();
    static void Main(string[] args)
    {
        // 入力
        //string[] input = Console.ReadLine().Split(' ');
        int N = int.Parse(Console.ReadLine());

        // しりとりリスト
        List<string> shiritori = new List<string>();
        bool ret = true;
        string post = ""; // 前回のワード
        for (int i = 0; i < N; i++)
        {
            string word = Console.ReadLine();
            if (!ret) continue;

            // 同じワードは1回のみ
            if(shiritori.Contains(word))
            {
                ret = false;
            }
            else
            {
                shiritori.Add(word);
            }

            if(post != "" && post[post.Length - 1].CompareTo(word[0]) != 0)
            {
                ret = false;
            }
            post = word;

        }

        //Console.WriteLine(ret);
        if (ret)
            Console.WriteLine("Yes");
        else
            Console.WriteLine("No");
    }

}

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

const long long int m = 40000;
int p[20005] = {0};

int main(){
    int n;
    cin >> n;
    for(int i=0;i<n;++i){
        int tmp;
        cin >> tmp;
        p[tmp] = i + 1;
    }
    vector<long long int> a, b;
    for(int i=0;i<n;++i){
        a.push_back(m*i + 1 + p[i+1]);
        b.push_back(m*(n-i) + p[i+1]);
    }
    for(int i=0;i<n;++i){
        cout << a[i];
        if(i == n-1)cout << endl;
        else cout << ' ';
    }

    for(int i=0;i<n;++i){
        cout << b[i];
        if(i == n-1)cout << endl;
        else cout << ' ';
    }

    return 0;
}


Measured memory_bytes: 1276
//start of jonathanirvings' template v3.0.3 (BETA)

#include <bits/stdc++.h>
using namespace std;

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)

inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}

inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}

inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  #ifndef TESTING
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
  #endif
}

//end of jonathanirvings' template v3.0.3 (BETA)

LL n,a,b;

int main()
{
  scanf("%lld %lld %lld",&n,&a,&b);
  LL ada = (n-1)*b+a-((n-1)*a+b);
  printf("%lld\n",max(0LL,ada+1));
  return 0;
}










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

vector<pair<int,int> > v[1<<18];

int a[1<<18],tmp;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	int m=(1<<n);
	for(int i=0;i<m;i++)
		cin>>a[i];
	
	for(int i=0;i<m;i++){
		v[i].push_back(make_pair(0,-1));
		v[i].push_back(make_pair(a[i],i));
		if(i!=0){
			for(int j=0;j<n;j++)
				if((1<<j)&i){
					v[i].push_back(v[i^(1<<j)][0]);
					v[i].push_back(v[i^(1<<j)][1]);
				}
			sort(v[i].begin(),v[i].end(),greater<pair<int,int> >());
			v[i].resize(unique(v[i].begin(),v[i].end())-v[i].begin());
			tmp=max(tmp,v[i][0].first+v[i][1].first);
			cout<<tmp<<'\n';
		}
	}
}


Measured memory_bytes: 72064
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
  // input
  int N, M;
  cin >> N >> M;
  vector<int> X(M);
  for (int i = 0; i < M; i++) {
      cin >> X[i];
  }

  if(N >= M){
    cout << 0 << endl;
    return 0;
  }

  // sort X
  sort(X.begin(), X.end());

  // Diff X
  vector<int> X_diff(M-1);
  for (int i = 0; i < M-1; i++){
    X_diff[i] = X[i+1] - X[i];
  }

  sort(X_diff.begin(), X_diff.end(),std::greater<int>());
  int L = 0;
  for(int i = 0; i < N-1; i++){
    L += X_diff[i];
  }
  cout << X[M-1] - X[0] - L << endl;

  // Output
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)                                                         

using namespace std;
#define ll long long

int main(){
  int N, D, X;
  cin >> N >> D >> X;
  for(int i=0; i<N; i++){
    int in;
    cin >> in;
    X += (D - 1) / in + 1;
  }
  cout << X << endl;
  return 0;
}


Measured memory_bytes: 256
def print_rectangle(H, W):
    
    for i in range(H):
        for j in range(W):
            print("#",end="")
        print()
    print()



if __name__ == "__main__":

    while(1):

        param = input().split(" ")
        h = int(param[0])
        w = int(param[1])

        if h != 0 and w != 0:
            print_rectangle(h, w)
        else:
            break



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

using namespace std;

int main()
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if (abs(a - c) <= d or (abs(a - b) <= d and abs(b - c) <= d))
        cout << "Yes\n";
    else
        cout << "No\n";

    return 0;
}


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

#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))
#define MOD 1000000007

using namespace std;

using ll = long long;
const ll MAX = LLONG_MAX;
const ll MIN = LLONG_MIN;

typedef stack<ll> llStack;
typedef queue<ll> llQueue;
typedef vector<ll> llVector;
typedef list<ll> llList;

typedef struct S{
  int a;
  int b;
} Object;

int main(){
  ll X;
  cin >> X;
  
  ll a = 100;
  ll count = 0;
  while(1){
    if(a >= X){
      break;
    }
    count++;
    a = (ll)floor((a*1.01));
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3744
from math import gcd
A, B = map(int,input().split())
max_cmn_div = gcd(A, B)

# 約数列挙関数
def make_divisor(n):
    divisor = []
    for i in range(1, int(n**(1/2))+1):
        if n % i == 0:
            divisor.append(i)
            if i != n//i:
                divisor.append(n//i)
    return divisor

def check_prime(n):
    for i in range(2, int(n**(1/2))+1):
        if n % i == 0:
            return 0
    return 1

cmn_div = make_divisor(max_cmn_div)
ans = 0
for i in cmn_div:
    if check_prime(i):
        ans += 1
print(ans)

Measured memory_bytes: 70680
import math


def distance(s, t):
    assert len(s) == len(t)

    cnt = 0
    for i in range(len(s)):
        if s[i] != t[i]:
            cnt += 1

    return cnt


def main():
    S = input()
    T = input()

    dist = float('inf')
    
    for i in range(len(S) - len(T) + 1):
        dist = min(dist, distance(S[i:i+len(T)], T))

    print(dist)


if __name__ == '__main__':
    main()


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

int main() {
  int N;
  cin >> N;
  vector<vector<int>> V(N, vector<int>(26));
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    for (int j = 0; j < S.size(); j++) V.at(i).at(S.at(j) - 'a')++;
  }
  for (int i = 0; i < 26; i++) {
    int cnt = 1e9;
    for (int j = 0; j < N; j++) cnt = min(cnt, V.at(j).at(i));
    while (cnt--) cout << char('a' + i);
  }
  cout << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
using namespace std;

using int64 = long long;
using int128 = __int128;

#define repeat(i, n) for (auto i = decltype(n)(); (i) < (n); (i)++)

template<typename T>
vector<T> MakeVector(size_t a){return vector<T>(a);}

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

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
FillVector(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
FillVector(T &t,const V &v){
  for(auto &e:t) FillVector(e,v);
}

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

  int W, H, N;
  cin >> W >> H >> N;

  auto area = MakeVector<int>(W, H);
  FillVector(area, 1);

  repeat (i, N) {
    int X, Y, A;
    cin >> X >> Y >> A;
    repeat (x, W) {
      repeat (y, H) {
        if (A == 1 and x < X) area[x][y] = 0;
        if (A == 2 and x >= X) area[x][y] = 0;
        if (A == 3 and y < Y) area[x][y] = 0;
        if (A == 4 and y >= Y) area[x][y] = 0;
      }
    }
  }

  int ans = 0;
  repeat (x, W) {
    repeat (y, H) {
      ans += area[x][y];
    }
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
const int M = 100010;
int n,x,ans,a[M];
int main()
{
    scanf("%d",&n);
    ans = n;
    for (int i = 0; i < n; i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    for (int i = 0; i < n; i++)
        if(a[i] == a[i+1] && a[i] != 0 && a[i+1] != 0)
        {
            ans-=2;
            a[i] = a[i+1] = 0;
        }
    printf("%d\n",ans);
    return 0;
}

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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll)1e9 + 7;
constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n;
    cin >> n;
    Array a(n);
    REP(i, n)
    cin >> a[i];
    Array b;
    ll sum = 0;
    for(int i = 0; i < n; i += 2) {
        ll bb = a[i] ^ a[i + 1];
        b.push_back(bb);
        sum ^= bb;
    }

    Array ans(n);
    for(int i = 0; i < n; i += 2) {
        int j = i / 2;
        ll tmp = sum ^ b[j];
        ans[i] = a[i + 1] ^ tmp;
        ans[i + 1] = a[i] ^ tmp;
    }
    REP(i, n)
    cout << ans[i] << " ";
    cout << en;
}

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

    solve();
    // ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 7128
#include <cstdio>
#include <map>
#include <algorithm>
using namespace std;
int main(){
    int A = 1, B = 0, C = 0;
    map<char, int> m;
    m.insert({'A', 1}); m.insert({'B', 0}); m.insert({'C', 0});
    char x[2], y[2];
    while (scanf("%1s,%1s", x, y) != EOF) {
        swap(m[x[0]], m[y[0]]);
    }
    for (map<char, int>::iterator it = m.begin(); it != m.end(); it++) {
        if (it->second) { printf("%c\n", it -> first); break; }
    }
    return 0;
}



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

#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"

#define ll long long
#define ff first
#define ss second
#define null NULL
#define all(c) (c).begin(),(c).end()
#define nl "\n"

#define ld long double
#define eb emplace_back
#define pb push_back
#define pf push_front
#define mod 1000000007

typedef vector<ll> vl;
typedef vector< vl > vvl;
typedef pair< ll,ll> pll;
typedef map< ll,ll> mll;


int main() {

	// Use ctrl+shift+b ( second option )
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

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

	string s;
	cin>>s;


	ll n = s.length();

	if(s[n-1]=='s'){
		s = s+"es";
	}else{
		s =s+"s";
	}

	cout<<s<<nl;


	return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include<algorithm>

#define endl '\n'
#define ll long long
#define ull unsigned ll
#define x first
#define y second

using namespace std;

bool a[200005];
int b[200005];

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

    for(int i=1;i<=n;i++){
        cin>>a[i];
        b[i]=-1;
    }

    int c;
    for(int i=n;i>=1;i--){
        c=0;
        for(int j=(n/i)*i;j>0;j-=i){
            if(b[j]==-1){
                b[j]=(c+a[j])%2;
            }
            else c+=b[j];
        }

    }
    int m=0;
    for(int i=1;i<=n;i++){
        if(b[i])m++;
    }
    cout<<m<<endl;
    for(int i=1;i<=n;i++){
        if(b[i])cout<<i<<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 1920
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
 
using namespace std;
 
int main()
{
    ll A, B, x, y, ans;   cin >> A >> B;
    ll C = B%A;
    while(C > 0){
        B = A;
        A = C;
        C = B%A;
    }

    queue<ll> que, d, p, q;
    for(int i=2; i<ll(sqrt(A))+3; i++){
        if(A%i == 0){
            if(d.empty())   d.push(i);
            else{
                while(!que.empty()){
                    x = que.front();
                    que.pop();
                    if(i%x == 0)    break;
                    if(que.empty()) d.push(i);
                }
            }
            q.push(i);
        }
        que = d;
    }
    p = q;
    for(int i=0; i<q.size(); i++){
        x = p.front();
        p.pop();
        C = A/x;
        while(!que.empty()){
            y = que.front();
            que.pop();
            if(C%y == 0)    break;
            if(que.empty()) d.push(C);
        }
        que = d;
    }
    if(A == 2 or A == 3)    ans = 2;
    else if(d.empty()){
        if(A > 1)   ans = 2;
        else    ans = 1;
    }else{
        ans = d.size() + 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3760
#68 B - 3人でカードゲームイージー
from collections import deque
Sa = deque(input())
Sb = deque(input())
Sc = deque(input())

turn = 0
while True:
    if turn == 0:
        if len(Sa) == 0:
            ans = 'A'
            break
        tgt = Sa.popleft()
        if tgt == 'b':
            turn = 1
        elif tgt == 'c':
            turn = 2
    if turn == 1:
        if len(Sb) == 0:
            ans = 'B'
            break
        tgt = Sb.popleft()
        if tgt == 'a':
            turn = 0
        elif tgt == 'c':
            turn = 2
    if turn == 2:
        if len(Sc) == 0:
            ans = 'C'
            break
        tgt = Sc.popleft()
        if tgt == 'a':
            turn = 0
        elif tgt == 'b':
            turn = 1
print(ans)

Measured memory_bytes: 9332
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <limits>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
#define reps(i, S, E) for (ll i = (S); i <= (E); i++)
#define rep(i, N) reps(i, 0, N-1)
#define deps(i, E, S) for (ll i = (E); i >= (S); i--)
#define dep(i, N) deps(i, N-1, 0)
const ll MOD = 1000000007;
const ll INF = 1LL << 60;


//C
struct LLPair {
	ll a = 0;
	ll b = 0;
	LLPair() {}
	LLPair(ll a, ll b) {
		this->a = a;
		this->b = b;
	}
};

ll LLpow(ll x, ll n) {
	ll ret = 1;
	while (n > 0) {
		if (n & 1) {
			ret *= x;
		}
		x *= x;
		n >>= 1;
	}
	return ret;
}

int main() {
	ll N;
	scanf("%lld", &N);
	vector<vector<LLPair>> A(N, vector<LLPair>());
	rep(i, N) {
		ll a;
		scanf("%lld", &a);
		rep(j, a) {
			ll x;
			scanf("%lld", &x);
			ll y;
			scanf("%lld", &y);
			A[i].push_back(LLPair(x - 1, y));
		}
	}

	ll result = INF;

	vll liar(N, 0);
	rep(i, LLpow(2, N)) {
		ll liar_gt = 0;
		rep(j, N) {
			if (liar[j] > 0) {
				liar_gt++;
			}
		}

		//�������Ȃ������ׂ�
		bool ok = true;
		rep(j, N) {
			bool flag_liar = false;

			for (auto item : A[j]) {
				//�������Ă���H
				if (liar[item.a] > 0) {
					//����͂�����
					if (item.b == 0) {
						//ok
					}
					else {
						flag_liar = true;
						break;
					}
				}
				else {
					//����͐���
					if (item.b > 0) {
						//ok
					}
					else {
						flag_liar = true;
						break;
					}
				}
			}

			//j����̖����`�F�b�N
			if (flag_liar == true && liar[j] == 1) {
				//ok
			}
			else if (flag_liar == false && liar[j] == 0) {

			}
			else {
				ok = false;
				break;
			}
		}

		//�����Ȃ�
		if (ok) {
			result = min(result, liar_gt);
		}

		//���̏�Ԃ�
		liar[0]++;
		rep(k, N - 1) {
			if (liar[k] > 1) {
				liar[k + 1]++;
				liar[k] = 0;
			}
		}
	}

	if (result == INF) {
		printf("0\n");
	}
	else {
		printf("%lld\n", N - result);
	}
}


//B
/*
int main() {
	char s[101010];
	scanf("%s", s);
	ll len = strlen(s);

	ll result = 0;

	rep(i, len / 2) {
		if (s[i] != s[len - 1 - i]) {
			result++;
		}
	}

	printf("%lld\n", result);
}
*/

//A
/*
int main() {
	ll a;
	scanf("%lld", &a);
	ll b;
	scanf("%lld", &b);
	ll c;
	scanf("%lld", &c);

	if (a + b + c >= 22) {
		printf("bust\n");
	}
	else {
		printf("win \n");
	}
}
*/

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	float x1,y1,x2,y2,xq,yq;
	float L,xp,yp,x,y;
	while(~scanf("%f,%f,%f,%f,%f,%f",&x1,&y1,&x2,&y2,&xq,&yq)){
		x2-=x1, y2-=y1;
		xq-=x1, yq-=y1;
		L=(x2*xq+y2*yq)/(x2*x2+y2*y2);
		xp=L*x2, yp=L*y2;
		x=x1+2*xp-xq, y=y1+2*yp-yq;
		printf("%f %f\n",x,y);
	}
	return 0;
}

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

int count_div(int n)
{
  int cnt=0;
  map<int,int>mp;
  for(int i=2;i*i<=n;i++)
  {
      if(n%i==0)
      {
          while(n%i==0)
          {
              cnt++;
              n=n/i;
          }
          mp[i]=cnt;
          cnt=0;
      }
  }
  if(n>1)
    mp[n]++;
  int ans=1;

  for(auto x:mp)
  {
      ans*=(x.second+1);
  }
   return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    ll n;
    cin>>n;

    ll ans=0;
    for(ll i=1;i<n;i++)
    {
        ans+=count_div(n-i);
    }
    cout<<ans<<"\n";
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;

template<typename A,typename B> inline void chmin(A &a,B b){if(a>b) a=b;}
template<typename A,typename B> inline void chmax(A &a,B b){if(a<b) a=b;}
//-----------------------------------------------------------------------

const int SZ=2005;
bitset<SZ> bset;

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

    int n; cin>>n;
    bset[0]=true;
    while(n--){
        int a; cin>>a;
        bset|=(bset<<a);
    }
    int q; cin>>q;
    while(q--){
        int m; cin>>m;
        if(bset[m]) cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
}

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

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef long double ld;

const ll mod = (ll)1e9 + 7;
const ll mxN = 200200;

bool f(vll a, vll b){
	ll ans =0;
	for(int i=0;i<a.size();i++)
		ans+=(a[i]-b[i])*(a[i]-b[i]);
	ll t=sqrtl(ans);
	return t*t==ans;
}

void solve(){
	ll n,d,ans=0;
	cin>>n>>d;
	vector<vector<ll>> A(n,vector<ll>(d,0));
	for(int i=0;i<n;i++)
		for(int j=0;j<d;j++)
			cin>>A[i][j];
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
			ans+=(ll)f(A[i],A[j]);
	cout<<ans<<'\n';


}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(20);
	cout << fixed;

	//ll t;cin>>t;while(t--)
	solve();

}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#define SQR(X) ( (X) * (X) )

int main()
{
   static long i,j,k,l;
   long double a,b,c,C;
   long double ans;
   cin >> a >> b >> C;

   C = C / 180 * 3.14159265;
   c = sqrtl(a*a+b*b-2*a*b*cosl(C));

   printf("%llf\n",a*b*sinl(C)/2);
   printf("%llf\n",a+b+c);
   printf("%llf\n",b*sinl(C));
   return 0;
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)


int main() {
  ll x;
  cin >> x;
  //vector<ll> a(N);
  //vector<vector<int>> data(3, vector<int>(4));
  if (x >= 30){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;

  return 0;
}


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

int main() {
	int N, A=0;
	cin >> N;
	vector<int> ar(N);
	for (int i = 0; i < N; i++)
		cin >> ar.at(i);

	sort(ar.begin(), ar.end());
	reverse(ar.begin(), ar.end());
	for (int i = 0; i < N; i++) {
		if (i % 2 == 0)
			A += ar.at(i);
		else
			A -= ar.at(i);
	}
	cout << A << endl;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n;
  cin >> n;
  vector<int> g[n + 1];
  for (int i = 1, u, v; i < n; i++) {
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  vector<int> a(n);
  int tot = 0;
  rep(i, n) cin >> a[i], tot += a[i];

  sort(a.rbegin(), a.rend());
  tot -= a[0];

  int ans[n + 1] = {0};
  int l = 0;
  function<void(int, int)> dfs = [&](int u, int p) {
    ans[u] = a[l++];
    for (int v : g[u]) {
      if (v == p) continue;
      dfs(v, u);
    }
  };

  dfs(1, 0);
  cout << tot << endl;
  for (int i = 1; i <= n; i++) cout << ans[i] << " ";
}


Measured memory_bytes: 4768
#include <bits/stdc++.h>
#define N 100007
using namespace std;
int n,m,deg[N],d[N],f[N];
vector <int> to[N];
bool vis[N],conn[N];
stack <int> s;
set <int> del[N];
int dfs(int x,int p){
    vis[x]=1,s.push(x);
    for(int y:to[x]){
        if(y==p)continue;
        if(vis[y])return y;
        return dfs(y,x);
    }
}
void rm(int x,int y){
    del[x].insert(y);
    del[y].insert(x);
    --d[x],--d[y];
}
int find(int x){return f[x]==x ? x:f[x]=find(f[x]);}
bool check(int rt){
    for(int i=1;i<=n;++i)vis[i]=0;
    while(!s.empty())s.pop();
    int a=dfs(rt,0);
    int b=s.top();
    for(int i=1;i<=n;++i)d[i]=deg[i],del[i].clear();
    rm(a,b);
    while(!s.empty()){
        int x=s.top();
        s.pop();
        if(x==a)break;
        int y=s.top();
        rm(x,y);
    }
    int k=0;
    for(int i=1;i<=n;++i)
        if(d[i])k+=d[i]/2-1;
    if(k)return 1;
    for(int i=1;i<=n;++i)f[i]=i,conn[i]=0;;
    for(int i=1;i<=n;++i)
        for(int j:to[i]){
            if(del[i].find(j)!=del[i].end())continue;
            f[find(j)]=find(i);
            conn[i]=1;
        }
    k=0;
    for(int i=1;i<=n;++i)
        if(conn[i] && f[i]==i)++k;
    if(k>1)return 1;
    return 0;
}
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1,x,y;i<=m;++i){
        scanf("%d%d",&x,&y);
        to[x].push_back(y);
        to[y].push_back(x);
        ++deg[x],++deg[y];
    }
    int k=0;
    for(int i=1;i<=n;++i)
        if(deg[i]&1){puts("No");return 0;}
        else k+=deg[i]/2-1;
    if(k<2){puts("No");return 0;}
    for(int i=1;i<=min(n,10);++i)
        if(check(i)){puts("Yes");return 0;}
    puts("No");
}
/*
6 9
1 2
1 4
2 3
2 4
2 5
3 4
3 5
3 6
4 6
*/


Measured memory_bytes: 16820
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
const int N=100000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u],v=sq[i].to;i;i=sq[i].nxt,v=sq[i].to)
#define fir first
#define sec second
#define mkp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

namespace My_Math{
	#define N 100000

	int fac[N+100],invfac[N+100];

	int add(int x,int y) {return x+y>=maxd?x+y-maxd:x+y;}
	int dec(int x,int y) {return x<y?x-y+maxd:x-y;}
	int mul(int x,int y) {return 1ll*x*y%maxd;}
	ll qpow(ll x,int y)
	{
		ll ans=1;
		while (y)
		{
			if (y&1) ans=mul(ans,x);
			x=mul(x,x);y>>=1;
		}
		return ans;
	}
	int getinv(int x) {return qpow(x,maxd-2);}

	int C(int n,int m)
	{
		if ((n<m) || (n<0) || (m<0)) return 0;
		return mul(mul(fac[n],invfac[m]),invfac[n-m]);
	}

	void math_init()
	{
		fac[0]=invfac[0]=1;
		rep(i,1,N) fac[i]=mul(fac[i-1],i);
		invfac[N]=getinv(fac[N]);
		per(i,N-1,1) invfac[i]=mul(invfac[i+1],i+1);
	}
	#undef N
}
using namespace My_Math;

struct node{int u,v,w;};
vector<node> edge;
int n,m,L;

int main()
{
	L=read();
	int lim=1;
	while (lim<=L)
	{
		lim<<=1;n++;
		//cout << lim << " " << n << endl;
	}
	rep(i,1,n-1)
	{
		edge.pb((node){i,i+1,1<<(n-i-1)});
		edge.pb((node){i,i+1,0});
	}
	int pre=1<<(n-1);
	//cout << pre << endl;
	per(i,n-1,1)
	{
		if ((L>>(i-1))&1)
		{
			edge.pb((node){1,n-i+1,pre});
			pre+=(1<<(i-1));
		}
	}
	m=edge.size();
	printf("%d %d\n",n,m);
	rep(i,0,m-1)
		printf("%d %d %d\n",edge[i].u,edge[i].v,edge[i].w);
	return 0;
}
	
	



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define rt return 0
#define endln "\n"
#define all(v) v.begin(), v.end()
#define for1(i, a, b) for (long long int i = a; i < b; i++)
#define for2(i, a, b) for (long long int i = a; i > b; i--)
//  cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;typedef long long int i;
typedef long long int lli;
typedef pair<lli, lli> pll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    lli n;
    cin >> n;
    vector<lli> v;
    vector<lli> p;
    lli f = 1;
    for1(i, 0, n)
    {
        lli a;
        cin >> a;
        v.pb(a);
    }
    for1(i, 0, n)
    {
        while (i < n - 1 && v[i] >= v[i + 1])
        {
            i += 1;
        }
        if (i < n - 1)
        {
            p.push_back(v[i]);
            i += 1;
            while (i < n - 1 && v[i + 1] >= v[i])
            {
                i += 1;
            }
            p.push_back(v[i]);
        }
        else
        {
            break;
        }
    }
    lli ans = 1000, s = 0;
    for1(i, 0, p.size())
    {
        if (i % 2 == 0)
        {
            s = ans / p[i];
            ans -= (s * p[i]);
        }
        else
        {
            ans += s * p[i];
            s = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <deque>
#include <map>
#include <set>

#define ll long long
#define inf 0x3f3f3f3f
#define il inline

namespace io {

#define in(a) a = read()
#define out(a) write(a)
#define outn(a) out(a), putchar('\n')

#define I_int ll
inline I_int read() {
    I_int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') {
        if (c == '-') f = -1;
        c = getchar();
    }
    while (c >= '0' && c <= '9') {
        x = x * 10 + c - '0';
        c = getchar();
    }
    return x * f;
}
char F[200];
inline void write(I_int x) {
    if (x == 0) return (void) (putchar('0'));
    I_int tmp = x > 0 ? x : -x;
    if (x < 0) putchar('-');
    int cnt = 0;
    while (tmp > 0) {
        F[cnt++] = tmp % 10 + '0';
        tmp /= 10;
    }
    while (cnt > 0) putchar(F[--cnt]);
}
#undef I_int

}
using namespace io;

using namespace std;

#define N 100010

int n, m;
int a[N], b[N], f[N];
ll siz[N];
ll ans = 0, sum = 0, res[N];
int find(int x) {
	if(f[x] == x) return x; 
	else return f[x] = find(f[x]);
}
int main() {
	in(n), in(m);
	sum = (ll)(n * (n - 1ll) / 2ll);
	for(int i = 1; i <= m; ++i) in(a[i]), in(b[i]);
	for(int i = 1; i <= n; ++i) f[i] = i, siz[i] = 1ll;
	for(int i = m; i; --i) {
		res[i] = sum - ans;
		int x = find(a[i]), y = find(b[i]);
		if(x != y) {
			ans += (ll)siz[x] * siz[y];
			siz[x] += siz[y];
			f[y] = x; 
		}
	}
	for(int i = 1; i <= m; ++i) printf("%lld\n", res[i]);
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int n,a[10000],b[100000],c[100000],sum=0;
  cin>>n;
  for(int i=0;i<n;i++){
	cin>>a[i]>>b[i];
    sum+=b[i]-a[i]+1;
  }
  cout<<sum<<"\n";
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && a != c) cout << "Yes";
  else if(b == c && b != a) cout << "Yes";
  else if(c == a && c != b) cout << "Yes";
  else cout << "No";

}



Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <string>
#include <sstream>
#include <queue>
using namespace std;

#define x first
#define y second
#define ll long long
#define ld long double
#define pii pair<int,int>
#define wh(x) (x).begin(),(x).end()
#define ri(x) int x;cin>>x;
#define rii(x,y) int x,y;cin>>x>>y;
#define rl(x) ll x;cin>>x;
#define rv(v) for(auto&_cinv:v) cin>>_cinv;
#define wv(v) for(auto&_coutv:v) cout << _coutv << ' '; cout << endl;
#define ev(v) for(auto&_cerrv:v) cerr << _cerrv << ' '; cerr << endl;
#define MOD 1000000007

namespace std { 
template<typename T,typename U>struct hash<pair<T,U>>{hash<T>t;hash<U>u;size_t operator()(const pair<T,U>&p)const{return t(p.x)^(u(p.y)<<7);}};
}
template<typename T,typename F>T bsh(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){l=m+1;r=m;}else{h=m-1;}}return r;}
template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }

int main(int,char**) {
    ios_base::sync_with_stdio(false);

    int N; cin >> N;
    vector<int> P(N); 
    for (int i = 0; i < N; i++) {
        int c; cin >> c;
        P[c-1] = i;
    }

    for (int i = 0; i < N; i++) {
        cout << i*N + 1 << ' ';
    } cout << endl;

    for (int i = 0; i < N; i++) {
        cout << (N-i)*N + 1 + P[i] << ' ';
    } cout << endl;
}


Measured memory_bytes: 768
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long a = scanner.nextLong();
        long b = scanner.nextLong();
        long c = scanner.nextLong();
        long d = scanner.nextLong();
        long all = b - a + 1;
        long canDivC=b/ c - a/ c ;
        long canDivD=b/ d - a/ d ;
        long canDivCD= b/ lcm(c,d) - a/ lcm(c,d);
        if (a % c == 0) {
            canDivC++;
        }
        if (a % d == 0) {
            canDivD++;
        }
        if (a % (c * d) == 0) {
            canDivCD++;
        }
        System.out.println(all - canDivC - canDivD + canDivCD);
    }

    private static long lcm(long a, long b) {
            long temp;
            long c = a;
            c *= b;
            while((temp = a%b)!=0) {
                a = b;
                b = temp;
            }
            return (long)(c/b);

        }
}

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

typedef long long ll;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
signed main(){
    
    int  n,m,x,y;
    cin >> n >> m >> x >> y; 
    int MOD = 1000000007;
    
    int a[n];
    int b[m];
    REP(i,n) cin >> a[i];
    REP(i,m) cin >> b[i];

    sort(a,a+n);
    sort(b,b+m);

    if(a[n-1] < b[0] && x < b[0] && y > a[n-1]){
        cout << "No War";
    }else cout << "War";  
    //cout << ans << endl;
  

    
    return 0;
}
//g++ -std=c++14 code1.cpp



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, k;
    cin >> n >> k;
    vector<int> A(n);
    for(int i = 0; i < n; i++)
        cin >> A[i];
    int ans = 0;
    for(int i = 0; i < n; i++){
        if(A[i] <= (k / 2)){
            int typeA = A[i] * 2;
            ans += typeA;
        }
        else if(A[i] > (k/2)){
            int typeB = (k - A[i]) * 2;
            ans += typeB;
        }
    }
    cout<<ans;
    return 0;    
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
 
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int> > VVI;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<bool> VB;
 
int main() {
    string s;
    cin >> s;
    if(s != "AAA" && s != "BBB")  {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
}

Measured memory_bytes: 256
"use strict";
const main = arg => {
  let NumAmount = arg.split("\n")[0]*1;
  let row1 = arg.split("\n")[1].split(" ").map(n => n*1);
  let row2 = arg.split("\n")[2].split(" ").map(n => n*1);
  let ansArr = [];
  let a_sum = 0;
  let b_sum = 0;
  // 全部網羅して最大値をとればいい
  // aのそれぞれのところまでの足し合わせ
  for(let a_i = 0; a_i < NumAmount; a_i++){
  	a_sum += row1[a_i];
    ansArr[a_i] = a_sum;
  }
  // bをお尻の方からそれぞれのところまでの足し合わせ
  for(let b_i = NumAmount - 1; b_i >= 0; b_i--){
  	b_sum += row2[b_i];
    ansArr[b_i] += b_sum;
  }
  // 最大値を表示
  console.log(Math.max(...ansArr));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,sum=0,m=10;
  for(int i=0;i<5;i++){
    cin>>a;
    sum+=a+(a%10 ? 10-a%10 : 0 );
    m=(a%10 ? min(m,a%10) : m );
    cerr<<sum<<' '<<m<<endl;
  }
  cout<<sum-10+m;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int c[5][5];
  reps(i, 3){
    reps(j, 3){
      cin >> c[i][j];
    }
  }

  int a[5], b[5];
  rep(i, c[1][1] + 1){
    rep(j, c[2][2] + 1){
      rep(z, c[3][3] + 1){
	a[1] = i;
	a[2] = j;
	a[3] = z;
	b[1] = c[1][1] - i;
	b[2] = c[2][2] - j;
	b[3] = c[3][3] - z;
	bool out = false;
	reps(na, 3){
	  reps(su, 3){
	    if(c[na][su] != a[na] + b[su])
	      out = true;
	  }
	}
	if(!out){
	  cout << "Yes\n";
	  return 0;
	}
      }
    }
  }
  cout << "No\n";
  return 0;
}


Measured memory_bytes: 3652
#include<cstdio>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int a,b,c,mn,mx;
	scanf("%d %d %d",&a,&b,&c);
	mn=a;	mx=a;
	mn=min(mn,b);
	mx=max(mx,b);
	mn=min(mn,c);
	mx=max(mx,c);
	printf("%d %d\n",mn,mx);
	return 0;
}


Measured memory_bytes: 2764
#include<iostream>
using namespace std;
int N_MAX = 100001;
typedef pair<int,int> P;
int main()
{
  int n,m,z;
  cin >> n >> m;
  P b[N_MAX]; // 枝データ
  int c[N_MAX]; // 頂点iの属する集合番号
  int nc[N_MAX]; // 集合jの要素数
  int pc[N_MAX]; // 集合jの先頭の要素番号
  int pi[N_MAX]; // 頂点iと同じ集合の要素へのポインタ
  int res=n;
  int i1,i2,s1,s2,p,pt;
  int c1,c2;
  for(int i=0;i<m;i++)
    cin >> b[i].first >> b[i].second >> z;
  for(int i=1;i<=n;i++){
    c[i]=i;
    nc[i]=1;
    pc[i]=i;
    pi[i]=0;
  }
  for(int i=0;i<m;i++){
    i1=b[i].first;
    i2=b[i].second;
    if(c[i1]!=c[i2]){
// 集合のマージここから
      s1=c[i1]; s2=c[i2];
      if(nc[s1]<nc[s2]){// 小さい方を潰す【重要】
        s1=c[i2]; s2=c[i1];
      }
      res--;
      pt=pc[s1];
      p=pc[s2];
      pc[s1]=p;
      nc[s1]+=nc[s2];
      pc[s2]=0;
      nc[s2]=0;
      while(true){
        c[p]=s1;
        if(pi[p]==0) break;
        p=pi[p];
      }
      pi[p]=pt;
// 集合のマージここまで
    }
  }
  cout << res << endl;
  return 0;
}

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

typedef long long LL;
typedef unsigned long long ULL;
#define int long long
#define debug printf("fuck %d\n", __LINE__);

inline LL read() {
	LL res = 0, bo = 1;
	char ch = getchar();
	while (ch < '0' || ch > '9') {
		if (ch == '-') bo = -1;
		ch = getchar();
	}
	while (ch >= '0' && ch <= '9') {
		res = (res << 1) + (res << 3) + ch - '0';
		ch = getchar();
	}
	return bo * res;
}

template <typename T>
void read(T &x) {
	x = read();
}

template <typename T, typename... Argv>
void read(T &a, Argv &... argv) {
	read(a);
	read(argv...);
}

const int N = 1e5 + 10;
int x[N], p[N], s, n;

LL Calc(int l, int r, int t) {
	if (s < x[l]) return x[r] - s;
	if (s > x[r]) return s - x[l];
	if (p[l] >= p[r]) return p[l] += p[r], Calc(l, r - 1, l) + (t == r ? x[r] - x[l] : 0);
	else return p[r] += p[l], Calc(l + 1, r, r) + (t == l ? x[r] - x[l] : 0);
}

signed main() {
	read(n, s);
	for (int i = 1; i <= n; ++ i) read(x[i], p[i]);
	std::cout << Calc(1, n, p[n] > p[1] ? 1 : n) << std::endl;
	return 0;
}

Measured memory_bytes: 4352
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
    
    string s;
    cin>>s;
    int sum=700;
    
    for(int i=0;i<3;i++){
        if(s[i]=='o'){
            sum+=100;
        }
    }
    cout<<sum<<endl;
    
    return 0;
   
}






Measured memory_bytes: 256
#include <stdio.h>

typedef long long ll;

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

int main(){
	int n, c=0, cnt=0;

	scanf("%d", &n);

	if (n >= 195)		cnt = 5;
	else if (n >= 189)	cnt = 4;
	else if (n >= 165)	cnt = 3;
	else if (n >= 135)	cnt = 2;
	else if (n >= 105)	cnt = 1;

	printf("%d\n", cnt);

	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void){

int n, T, c[101], t[101], i, j, mink, mint;
 
scanf("%d %d", &n, &T);
for(i=0; i<n; i++){
scanf("%d %d", &c[i], &t[i]);
}

mink=1001;
mint=1001;
for(i=0; i<n; i++){
 if(T>=t[i]){
  if(mink>c[i]){
   mink=c[i];
   mint=t[i];
}
}
}
if(mink==1001)
 printf("TLE\n");
else
printf("%d\n", mink);

return 0;
}

Measured memory_bytes: 128
import sys

sys.setrecursionlimit(500*500)

N, M = map(int, input().split())
UF = [-1] * (N+1)
def find(x):
    global UF
    if UF[x] == -1:
        return x
    else:
        UF[x] = find(UF[x])
        return UF[x]
def union(x,y):
    global UF
    xx = find(x)
    yy = find(y)
    if UF[x] == UF[y] == -1:
        UF[y] = xx
        return
    elif xx == yy:
        return 
    else:
        UF[yy] = xx
        return 
    
for _ in range(M):
    a, b = map(int, input().split())
    union(a,b)

ans = set()
for i in range(1,N+1):
    ans.add(find(i))
    
print(len(ans)-1)


Measured memory_bytes: 18076
/**
 * @author Video Vocabulary
 * @date 2020-07-11 18:00:43
 */
#include <bits/stdc++.h>

using namespace std;

void solve() {

}

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

    int n;
    cin >> n;
    int ans = 0;
    for (int i=1; i<=n; i++) {
        int num;
        cin >> num;
        if (i%2!=0 && num%2!=0) ans++;
    }
    cout << ans << endl;
}


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

int main() {
  	string T;
  	cin	>> T;
  	/*int dp[T.size()][2];
  	if (T[0] == 'P'){
      	dp[0][0] = -100;
      	dp[0][1] = 0;
    }
  	if (T[0] == 'D'){
      	dp[0][0] = 0;
      	dp[0][1] = -100;
    }
  	if (T[0] == '?'){
      	dp[0][0] = 0;
      	dp[0][1] = 0;
    }
  	for (int i = 1; i < T.size(); i++){
      	if (T[i] == 'P'){
          	dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]);
          	dp[i][1] = -100;
        }
      	if (T[i] == 'D'){
          	dp[i][0] = -100;
          	dp[i][1] = max(dp[i - 1][0] + 2, dp[i - 1][1] + 1);
        }
      	if (T[i] == '?'){
          	dp[i][0] = max(dp[i - 1][0], dp[i - 1][1]);
          	dp[i][1] = max(dp[i - 1][0] + 2, dp[i - 1][1] + 1);
        }
    }
  
  	cout << max(dp[T.size() - 1][0], dp[T.size() - 1][1]) << endl;*/
  	for (int i = 0; i < T.size(); i++){
      	if (T[i] == '?') T[i] = 'D';
    }
  
  	cout << T << endl;
}

Measured memory_bytes: 3724