akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

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

    string ans = "";
    while(n > 0){
        ll m = n / 26;
        ll k = n % 26;
        if(k == 0){
            ans += 'z';
            n /= 26;
            n--;
        }else{
            ans += 'a' + k - 1;
            n /= 26;
        }
    }
    reverse(ans.begin(), ans.end());
    cout<<ans<<endl;
}

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

int main() {
  double n; cin >> n;
  vector<double> a(n);
  rep(i,n) cin >> a[i];
  
  double s = 0;
  rep(i,n) s += 1/a[i];
  cout << fixed << setprecision(6) << 1/s << endl; 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll a,b;
  	ci(a>>b);
  if(a<=8&&b<=8){
    co("Yay!")
  }
  else{
    co(":(")
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second
 

int main() {
	string s;
	cin >> s;
	int cnt = 0;
	forn(i, sz(s)/2) {
		if(s[i] != s[sz(s)-i-1]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}



Measured memory_bytes: 3612
s=str(input())
k=int(input())
ans=0
count=1
c1=0
c2=0

if len(set(s))==1:
    print(len(s)*k//2)
    exit()

if s[0]==s[-1]:
    for i in range(len(s)-1):
        if s[i]==s[i+1]:
            count+=1
        else:
            if 2<=count:
                ans+=count//2
            count=1
    ans+=count//2
    i=0
    while s[i]==s[0]:
        c1+=1
        i+=1
    
    i=len(s)-1
    while s[i]==s[-1]:
        c2+=1
        i-=1
    #print(c1,c2)
    ans*=k
    if c1%2==1 and c2%2==1:
        ans+=k-1

    print(ans)


else:
    for i in range(len(s)-1):
        if s[i]==s[i+1]:
            count+=1
        else:
            if 2<=count:
                ans+=count//2
            count=1
    ans+=count//2
    print(ans*k)

Measured memory_bytes: 3064
import sys

#sys.stdin = open('d_2.txt', 'r')
in_stg = list(raw_input())

for x in range(len(in_stg) - 1):
	cand1, cand2 = min(x+1, len(in_stg)-1), min(x+2, len(in_stg)-1)
	if (in_stg[x] == in_stg[cand1]):
		print str(x + 1) + ' ' + str(cand1 + 1)
		sys.exit()
	elif (in_stg[x] == in_stg[cand2]):
		print  str(x + 1) + ' ' + str(cand2 + 1)
		sys.exit()
	else:
		pass

print '-1 -1'


Measured memory_bytes: 6532
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main()
{
	int a, b, mennseki,nagasa;

	scanf("%d%d", &a, &b);
	mennseki = a*b;
	nagasa = a * 2 + b * 2;
		printf("%d %d\n", mennseki, nagasa);
	return 0;
}



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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}
const int N = 1005;
struct s{
  string name;
  int rating;
  int id;
};
bool cmp(const s &a, const s &b){
  return (a.name < b.name) || (a.name == b.name && a.rating > b.rating);
}
int main(){
  FASTER;
  int n;
  cin >> n;
  vector
ar(n);
  for (int i = 0; i < n; i++){
    cin >> ar[i].name >> ar[i].rating;
    ar[i].id = i + 1;        
  }
  sort(ar.begin(), ar.end(), cmp);
  for (int i = 0; i < n; i++){
    cout << ar[i].id << '\n';
  }
  return 0;
}


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

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

	vector<int> vec(N);
	int d;

	for (int i = 0; i < N; i++) {
		cin >> d;
		vec[i] = d;
	}

	sort(vec.begin(), vec.end());

	cout << vec[N / 2] - vec[N / 2 - 1] << endl;

}

Measured memory_bytes: 640
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    h, w = LI()
    B = [SI() + '.' for _ in range(h)]
    B.append('.' * w)

    for y in range(h):
        for x in range(w):
            if B[y][x] == '.':
                continue
                
            # |# . .
            # |# # #
            # |# . #
            if B[y][x + 1] == '#' and B[y + 1][x] == '#':
                return 'Impossible'
            
            # |. . .
            # |. # .
            # |# # .
            # |. # #
            if min(y, x) != 0:
                if B[y - 1][x] == '.' and B[y][x - 1] == '.':
                    return 'Impossible'

    return 'Possible'


print(main())

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

bool exist[100005]={0};

int main(){
    int n;
    cin >> n;
    int cnt = 0;
    for(int i=0;i<n;++i){
        int a;
        cin >> a;
        if(exist[a])cnt++;
        else exist[a] = true;
    }

    cout << n - (cnt+1) / 2 * 2 << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int a, b, k;
    cin >> a >> b >> k;
    if ( b - a + 1 <= k * 2 ) {
        for ( int i = a; i <= b; i++ ) {
            cout << i << endl;
        }
        return 0;
    } 
    for ( int i = a; i <= a + k - 1; i++ ) {
        cout << i << endl;
    }
    for ( int i = b - k + 1; i <= b; i++ ) {
        cout << i << endl;
    }
    return 0;
}


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

void a()
{
    int k, n;
    cin >> n >> k;
    cout << n - k + 1;
}
void b()
{
    int a, b, c, n;
    cin >> a >> b >> c >> n;
    int am = n / a;
    int bm = n / b;
    int cm = n / c;
    long long int num = 0;

    for (int i = 0; i <= am; i++)
    {
        if (a * i > n)
            break;
        for (int j = 0; j <= bm; j++)
        {
            if (a * i + b * j > n)
                break;
            if ((n - a * i - b * j) % c == 0)
                num++;
        }
    }
    cout << num;
}
int main(void)
{
    b();
    //a();
}

Measured memory_bytes: 256
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    let s = next()
    let cnt = 0
    if(s.includes("RRR")){
        cnt = 3
    } else if(s.includes("RR")){
        cnt = 2
    } else if (s.includes("R")){
        cnt = 1
    } else {
        cnt = 0
    }
    console.log(cnt)

}
Main()



Measured memory_bytes: 29588
#include<iostream>

using namespace std;

int main(){
  int k;
  string s;
  cin>>k;
  cin>>s;
  if(s.size()<=k) cout<<s;
  else{
    for(int i=0;i<k;i++)
      cout<<s[i];
    cout<<"...";
  }
  return 0;
}

Measured memory_bytes: 3628
import math as M
def R(A): return (A[0]**2+A[1]**2)**.5
def I(i): return [map(int,raw_input().split()) for _ in [0]*i]
def C(a,b): return a>b or abs(a-b)<1e-6
def f(e1):
  tx,ty,sx,sy=e1
  x=[]
  for e2 in WP:
    wx,wy,r=e2
    wt=[tx-wx,ty-wy]; rwt=R(wt)
    sw=[wx-sx,wy-sy]; rsw=R(sw)
    st=[tx-sx,ty-sy]; rst=R(st)
    F=[rwt<r,rsw<r]
    if rst==0: c=1
    elif F==[1,1]: c=1
    elif F==[1,0] or F==[0,1]: c=0
    elif F==[0,0]:
      a=M.pi/2-M.acos(r/rsw)
      b=M.acos(round((sw[0]*st[0]+sw[1]*st[1])/rsw/rst,4))
      if C(a,b) and C(rst**2,rsw**2-r**2): c=0
      else: c=1
    x.append(c)
  return all(x)

while 1:
  n=input()
  if n==0: break
  WP=I(n)
  P=I(input())
  for e in P: print ["Safe","Danger"][f(e)]

Measured memory_bytes: 4596
#include <iostream>
using namespace std;
 
int main() {
 
  string key[10] ={
    "00000",
    ".,!? ",
    "abc",
    "def",
    "ghi",
    "jkl",
    "mno",
    "pqrs",
    "tuv",
    "wxyz"
  };
 
 
  int n;
  cin >> n;
  string str;
  for(int j=0;j<n;j++){
    cin >> str;
    int cnt = -1;
    int ima;
    for(int i=0;i<str.size();i++){
      if(cnt == -1 && str[i] == '0') continue;
      if(str[i] == '0'){
    cout <<key[ima][cnt%key[ima].size()];
    cnt = -1;
      }
      else{
    ima = str[i]-'0';
    cnt++;
      }   
    }
    cout << endl;
     
  }
 
    return 0;
}

Measured memory_bytes: 3044
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
int n,k; ll ans=0,f[123][12345];
const ll MOD=1e9+7;
ll qp(ll a,ll b)
{
	ll x=1;
	while(b)
	{
		if(b&1) x=x*a%MOD;
		a=a*a%MOD; b>>=1;
	}
	return x;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=k;++i)
		ans+=i*qp(k+1,n-1)%MOD*n%MOD;
	ans%=MOD;
	f[n+1][0]=1;
	int up=0;
	for(int i=n;i>=1;--i)
	{
		int up_=up;
		for(int j=0;j<=up_;++j) if(f[i+1][j])
		{
			for(int p=0;p<=k;++p)
			{
				if(p>i) (f[i][j]+=f[i+1][j])%=MOD;
				else (f[i][(j+p)/i+j]+=f[i+1][j])%=MOD,
				up=max(up,(j+p)/i+j);
			}
		}
	}
	for(int i=0;i<=up;++i) ans-=f[1][i]*i%MOD;
	ans=(ans%MOD+MOD)%MOD;
	printf("%d\n",int(ans));
}


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

int main(){
	int n;
	cin >> n;
	if(n == 1) cout << fixed << setprecision(9) << 1.00000000 << endl;
	else{
		int odd = (n+1)/2;
		double ans = double(odd)/double(n);
		cout << fixed << setprecision(9) << ans << endl;
	}
}

Measured memory_bytes: 3752
/*
  -------------
  Prateek Celly
  DA-IICT
  -------------
*/
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define MOD 1000000007

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll r,d,x;
  cin>>r>>d>>x;
  for(ll i=0;i<10;i++){
    x=r*x-d;
    cout<<x<<'\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define pb                      push_back
#define MOD                     1000000007
#define inf                     3e18
#define ld                      long double
//#define mp                      make_pair
#define vpll                    vector<pair<ll,ll>>
#define sll                     set<ll>
#define usll                    unordered_set<ll>
#define vll                     vector<ll>
#define vld                     vector<ld>
#define vvll                    vector<vector<ll>>
#define vvld                    vector<vector<ld>>
#define pll                     pair<ll,ll>
#define vvpll                   vector<vector<pair<ll,ll>>>
#define pqll                    priority_queue<ll>
#define mll                     map<ll,ll>
#define mlc                     map<ll,char>
#define um                      unordered_map
#define umll                    um<ll,ll>
#define umlc                    um<ll,char>
#define umcl                    um<char,ll>
#define all(x)                  x.begin(),x.end()
#define fi                      first
#define se                      second
#define test                    ll Testcases;cin>>Testcases;while(Testcases--)
#define fastIO                  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db(...)                 __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << " "<< name << " : " << arg1 <<'\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void inp_out()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
    #endif
}

int main()
{
	fastIO
//	inp_out();
	ll n;
	cin>>n;
	ll ans=0;
	for(ll i=1;i<=n;++i)
	{
		if((i%3!=0)&&(i%5!=0))
			ans+=i;
	}
	cout<<ans;
	return 0;
}



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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    vector<int> chs(n);

    vector<int> nr;
    rep(i,n-1){
        if(s.at(i) == 'R' && s.at(i+1) == 'L') nr.push_back(i);
    }
    
    for(int x : nr){
    // cout << x << endl;

        chs.at(x) = 1;
        chs.at(x+1) = 1;
        for(int i=x-1;i>=0 && s.at(i) == 'R';i--) {
            // cout << "i:" << i << " x:" << x << endl;
            if((x-i)%2==1) chs.at(x+1)++;
            else chs.at(x)++;
        }
        for(int i=x+2;i<n && s.at(i) == 'L';i++) {
            if((i-x)%2==1) chs.at(x+1)++;
            else chs.at(x)++;
        }
    }
    rep(i,n){
        if(i>0) cout << " ";
        cout << chs.at(i);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1280
from bisect import bisect_left
n = int(input())
t = [0]+[int(i) for i in input().split()]+[0]
v = [int(i) for i in input().split()]+[0]
def f(x,v,t1,t2):
	if x<t1: return v+(t1-x)
	elif t1<=x<=t2: return v
	else: return v+(x-t2)
for i in range(1,n+2): t[i]+=t[i-1]
T,ans = t[-1],0
for i in range(2*T+1):
	num = min(i/2,T-i/2)
	for j in range(max(0,bisect_left(t,i/2-100)-1),n+1):
		if i/2<t[j]-100: break
		num = min(num,f(i/2,v[j],t[j],t[j+1]))
	ans+=num/2
print(ans)

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

int main() {
  int N;
  cin >> N;
  
  map<int, int> Students; //出席番号,人数

  for(int i = 1;i <= N; i++){
    int Ai;
    cin >> Ai;
    Students[Ai] = i;
  }

  int cnt = 0;
  for(int i = 1;i <= N; i++){
	cout << Students.at(i) << " ";

  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 5504
ans' l =
  let l1 = dropWhile (/= 'A') l 
      l2 = dropWhile (/= 'Z') l1
  in
    if (l1 == []) || (l2 == [])
    then []
    else "AZ" ++ (ans' $ drop 1 l2)

ans l =
  let a = ans' l
  in
    if a == []
    then "-1"
    else a

main = do
  l <- getLine
  let o = ans l
  putStrLn o



Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000001;
constexpr ll INF= 1e18;
constexpr ll MOD = 998244353;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N,X,Y;
    cin >> N >> X >> Y;
    X--;
    Y--;
    vector<int> ret(N);
    for(int i = 0;i < N - 1;i++) {
        for(int j = i + 1;j < N;j++) {
            if(j <= X || Y <= i) {
                ret.at(j - i)++;
            }
            else if(i <= X && Y <= j) {
                ret.at(j - Y + X - i + 1)++;
            }
            else if(i <= X && j < Y) {
                ret.at(min(Y - j + 1,j - X) + (X - i))++;
            }
            else if(X < i && Y <= j) {
                ret.at(min(Y - i,i - X + 1) + (j - Y))++;
            }
            else {
                ret.at(min(i - X + Y - j + 1,j - i))++;
            }
        }
    }
    for(int i = 1;i < N;i++) {
        cout << ret.at(i) << endl;
    }
}

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

#define ll long long
#define sc(n) long long int n; scanf("%d",&n);
#define mod 10000007
#define N 100001
#define MX 1000000001
#define log(n) (int)log2(n)
#define pb(x) push_back(x);
#define T int t, q=0; scanf("%d", &t); while(q++<t)
#define scArr(n) int n; scanf("%d", &n); int a[n]; for(int i=0; i<n; i++) scanf("%d", &a[i]);

vector<int>primes;
int a[10000001];
void sieve()
{
    primes.push_back(2);
    for(int i=3; i*i<10000001; i+=2)
    {
        if(a[i]==0)
        {
            for(int j=i*i; j<10000001; j+=i+i)
                a[j]=1;
        }
    }
    a[0]=a[1]=1;
    for(int i=3; i<10000001; i+=2)
        if(!a[i])
            primes.push_back(i);
}

int main()
{
    sieve();
    int n;
    cin>>n;
    for(auto it=primes.begin();it!=primes.end();it++)
    {
        if(*it<n)
            continue;
        else cout<<*it;
        break;
    }
}


Measured memory_bytes: 45552
n, m = map(int, input().split())

dic = {}

for i in range(m):
    a, b = map(int, input().split())

    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1
    if b in dic:
        dic[b] += 1
    else:
        dic[b] = 1

ok = 1

for k, v in dic.items():
    if v % 2 != 0:
        ok = 0
        break

print('YES' if ok else 'NO')


Measured memory_bytes: 9064
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int x,a,b; cin >> x >> a >> b;
    if(0<b-a&&b-a<=x) out("safe");
    else if(0>=b-a) out("delicious");
    else out("dangerous");

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static int mp_dp(int[] values) {
		int maxp = values[1]-values[0];
		int minv = min(values[1],values[0]);
		for(int i=2;i<values.length;i++) {
			maxp = max(maxp,values[i]-minv);
			minv=min(minv,values[i]);
		}
		return maxp;
	}
	public static int max(int a,int b) {
		if (a>=b) {
			return a;
		}
		else {
			return b;
		}
	}
	public static int min(int a,int b) {
		if (a>=b) {
			return b;
		}
		else {
			return a;
		}
	}
	public static void main(String[] wjy) {
		Scanner sc = new Scanner(System.in);
		int[] stock = new int[sc.nextInt()];
		for (int i=0;i<stock.length;i++) {
			stock[i]= sc.nextInt();
		}
		sc.close();
		System.out.println(mp_dp(stock));
	}
}



Measured memory_bytes: 101012
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    ll n,r,c=0;
    cin>>n>>r;
    while(n)
    {
        c++;
        n/=r;
    }
    cout<<c<<endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <queue>
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

#define pb push_back
#define mk make_pair
#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define sf(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pf(a) printf("%d\n",a);
#define pfl(a) printf("%lld\n",a);
#define TEST int test; cin >> test;while(test--)
#define ii pair<int,int>
#define iil pair<ll,ll>
#define loop(i,a,b) for(int i = a ; i < b ; i++)
#define INF 2147483647


int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const double pi = acos(-1.0);

map<ll,ll>mp;
void solve()
{
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int f = 0;
    vector<int> v, v1;
    //if(s[0] == '0') v.pb(0);
    if(s[0] == '0') v.pb(1);
    if(s[0] == '0' && s[1] == '1') v1.pb(1);

    for(int i = 1 ; i < n ; i++)
    {

        if(s[i] == '0' && s[i-1] == '1') v.pb(i+1);

        if(s[i] == '0' && s[i+1] == '1') v1.pb(i+1);

    }
//    for(int i = 0 ; i < v.size() ; i++){
//    cout << v[i] << " ";
//    }
//    cout << endl;
    int ans = -1;
    if(v.size() <= k)
    {
        cout << n << endl;
        return;
    }
    else
    {
        v.pb(n+1);
        ans = v[k] - 1;

        //v.insert(v.begin(),0);
        for(int i = k+1 ; i < v.size() ; i++)
        {
                ans = max(ans, v[i] - v1[i - k - 1]  - 1);

        }
    }

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //TEST
    solve();
    //main();
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
	int range, n;
	cin >> range >> n;
	for(int i = n-range+1; i<n+range; i++){
		cout << i << " ";
	}
}

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

typedef long long ll;

int main()
{
	int n, ans = 0;
	ll k, x;
	scanf("%d %lld", &n, &k);
	for(int i = 1; i <= n; ++i)
	{
		scanf("%lld", &x);
		if(x >= k) ++ans;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	int N, A;
	cin >> N >> A;
	cout << N * N - A << endl;
}

Measured memory_bytes: 256
n,k = gets.split.map(&:to_i)
h = []
n.times do
  h << gets.to_i
end
h.sort!
ans = 10 ** 9
(n-k+1).times do |i|
  t = h[i+k-1] - h[i]
  ans = t if t < ans
end
p ans

Measured memory_bytes: 4016
import java.util.*;
import java.lang.*;
import java.io.*;
class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(), b = sc.nextInt();
		System.out.println((a / b) + " " + (a % b) + " " + String.format("%.8f", (double)(a) / b));
	}
}


Measured memory_bytes: 26536
#include<cstring>
#include<iostream>

using namespace std;

int a[100010];

int main()
{
	int a;
	int ans=0;
	cin>>a;
	for(int i=1;i<=a;i++){
		int tmp;
		cin>>tmp;
		ans+=tmp-1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#解説のコードそのもの
import bisect

A, B, Q = map(int, input().split())
INF = 10**11
s = [-INF]+[int(input()) for i in range(A)]+[INF]
t = [-INF]+[int(input()) for i in range(B)]+[INF]

for q in range(Q):
    x = int(input())
    b, d = bisect.bisect_right(s,x), bisect.bisect_right(t,x)
    res = INF
    for S in [s[b-1],s[b]]:
        for T in [t[d-1],t[d]]:
            A,B = abs(S-x)+abs(T-S), abs(T-x)+abs(T-S)
            res = min(res,A,B)
    print(res)
    


Measured memory_bytes: 14252
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
typedef long long int64;
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
struct Edge {
	int to, id;
};

vector<vector<Edge>> g;
vector<int> ans;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}


void dfs(int v, int c=-1, int p=-1) {
	int k = 1;
	rep(i, g[v].size()) {
		int u = g[v][i].to, ei = g[v][i].id;
		if (u == p) continue;
		if (k == c) ++k;
		ans[ei] = k; ++k;
		dfs(u, ans[ei], v);
	}
}

void solve() {
		int n;
		cin >> n;
		g.resize(n);
		ans = vector<int>(n - 1);
		rep(i, n - 1) {
			int a, b;
			cin >> a >> b;
			--a; --b;
			g[a].push_back((Edge){b, i});
			g[b].push_back((Edge){a, i});
		}
		dfs(0);
		int mx = 0;
		rep(i, n) {
			mx = max(mx, int(g[i].size()));
		}
		cout << mx << endl;
		rep(i, n - 1) {
			cout << ans[i] << endl;
		}
    return;
}

int main() {
    solve();
    return 0;
}



Measured memory_bytes: 8320
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

struct Card { char suit, value;};

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

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

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

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

    }
    return true;
}

int main(){
    Card C1[100], C2[100];
    int N;
    char ch;
    cin >> N;
    for(int i=0;i<N;++i){
        cin >> C1[i].suit >> C1[i].value;
    }
    for(int i=0;i < N;++i) C2[i] =C1[i];
    bubble(C1,N);
    selection(C2,N);
    print(C1,N);
    cout << "Stable" << endl;
    print(C2,N);
    if(isStable(C1,C2,N)){
        cout << "Stable" << endl;
    }
    else{
        cout << "Not stable" << endl;
    }
    return 0;
}



Measured memory_bytes: 3088
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
int main()
{
	int N, A[100000], wa1 = 0, wa2 = 0;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	sort(A, A + N);
	wa1 = A[0]; wa2 = A[N - 1];
	for (int i = 1; i < N - 1; i++) {
		if (A[i] <= 0) {
			wa2 -= A[i];
		}
		else {
			wa1 -= A[i];
		}
	}
	printf("%d\n", wa2 - wa1);
	for (int i = 1; i < N - 1; i++) {
		if (A[i] <= 0) {
			printf("%d %d\n", A[N-1], A[i]);
			A[N - 1] -= A[i];
		}
		else {
			printf("%d %d\n", A[0], A[i]);
			A[0] -= A[i];
		}
	}
	printf("%d %d\n", A[N - 1], A[0]);
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
/* clang-format off */
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */


int main() {
  int n;
  bool f = false;
  cin >> n;
  vector<char> s(n);
  REP(i, n) { cin >> s.at(i); }
  REP(i,n){
    if (s.at(i) == 'Y') f = true;
  }
  if(f) cout <<  "Four"<< "\n";
  else cout << "Three" << "\n";
  return 0;
}


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

int N = 10;
int H, W;

vector<int> dijkstra(int s, vector<vector<pair<int, int>>> adj) {
    vector<bool> visit(N);
    vector<int> dist(N, 1e9), par(N);
    priority_queue<pair<int, int>> q;
    dist[s] = 0; q.push(make_pair(0, s)); visit[s] = true;
    while (!q.empty()) {
        pair<int, int> tmp = q.top(); q.pop();
        int t = tmp.second; visit[t] = true;
        if (dist[t] < tmp.first * (-1) ) continue;  //別のルートでdist[t]が更新されていれば無視
        for (int i = 0; i < adj[t].size(); i++) {
            int next = adj[t][i].first;
            if (visit[next]) continue;
            if (dist[next] > dist[t] + adj[t][i].second) {
                dist[next] = dist[t] + adj[t][i].second;
                par[next] = t;
                q.push(make_pair(dist[next] * (-1), next));
            }
        }
    }
    return dist;
}

int main() {
    cin >> H >> W;
    vector<vector<pair<int, int>>> adj(N, vector<pair<int, int>>(N));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            int d;
            cin >> d;
            adj[j][i] = make_pair(i, d);
        }
    }
    vector<int> dist = dijkstra(1, adj);
    long long ans = 0;
    for (int i = 0; i < H * W; i++) {
        int a; cin >> a;
        ans += dist[a];
    }
    cout << ans << endl;
}




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

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

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

struct Node{
  int key;
  Node *prev, *next; //address
};

Node *nil; // nilという名のポインタ

Node* listSearch(int key) {
  Node *cur = nil->next; // 番兵の次の要素から辿る
  while ( cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
  cout << cur << endl;
}

void init() {
  nil = (Node *)malloc(sizeof(Node)); // mallocは指定したサイズだけメモリを動的に確保する関数
  nil->next = nil; // ->ポインタ変数からメンバにアクセスするための演算子で、アロー演算子という
  nil->prev = nil;
}

void printList() {
  Node *cur = nil->next;
  int isf = 0;
  while( true ) {
    if ( cur == nil ) break;
    if ( isf++ > 0 ) printf(" ");
    printf("%d", cur->key); // decimal整数を10進数で表示
    cur = cur->next; // 次に移動
  }
  printf("\n");
}

void deleteNode(Node *t) {
  if ( t == nil ) return; // tが番兵の場合は処理しない
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t); // メモリを開放するSTL関数
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

void deleteKey(int key) {
  // 検索したノードを削除
  // cout << "deleteKey!" << endl;
  deleteNode(listSearch(key));
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  // 番兵の直後に要素を追加
  x->next = nil->next;
  nil->next->prev = x; // 次の要素の前がxになるようにする
  nil->next = x; // 前の要素の次がxになるようにする。
  x->prev = nil; // x自身の前はnil(左端)になるようにする
}

int main() {
  int key, n;
  int size = 0;
  // char com[20]; // command
  char com[30];
  int np = 0, nd = 0; // plus and delete counter;
  scanf("%d", &n); // nのアドレスにinput
  init();
  for ( int i = 0; i < n; i++ ) {
    scanf("%s%d", com, &key); // より高速な入力関数を使用
    // printf("%s%d", com[0], key); // %s is wrong maybe
    // cout << com[0] << endl;
    if ( com[0] == 'i' ) { // insertの初めの文字iで振り分け
      insert(key);
      np++;
      size++;
    } else if( com[0] == 'd' ) { // deleteの初めの文字dで振り分け
      if ( strlen(com) > 6 ) {
        if ( com[6] == 'F' ) deleteFirst(); // deleteFirst
        else if ( com[6] == 'L' ) deleteLast(); // deleteLast
      } else {
        deleteKey(key);
        nd++;
      }
      size--;
    }
  }

  printList();

  return 0;
}



Measured memory_bytes: 34448
#include <bits/stdc++.h>
using namespace std;
 
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
 
#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second
 
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
 
#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
using namespace std;

int main()
{
    fastIO;
    ll ans, n, i, j, k;
    cin>>n;
    ans = n-1;
    Fo(i,1,1000001) {
        if(n%i==0) {
            ans = min(ans, (i-1ll) + (n/i-1ll));
        }
    }
    cout<<ans<<endl;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " : " << x << '\n'

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll Mod = 1000000007LL;
const int Maxn = 1e5 + 10;
const ll Inf = 2242545357980376863LL;
const ll Log = 30;

vector<ll> G[Maxn];

ll g[Maxn];
void DFS(ll u, ll p){
	for(auto adj : G[u]){
		if(adj != p){
			DFS(adj, u);
			g[u] ^= g[adj];
		}
	}
	if(u == 1){
		if(g[u]) cout << "Alice\n";
		else cout << "Bob\n";
	}
	g[u] ++;
}

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);	
	ll n;
	cin >> n;
	ll u, v;
	for(int i = 1; i < n; i++){
		cin >> u >> v;
		G[u].pb(v);
		G[v].pb(u);
	}
	DFS(1, -1);
	return 0;
}





Measured memory_bytes: 11264
#include<algorithm>
#include<cmath>
#include<climits>
#include<cstdio>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<string>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,s,e) for(int i=s;i<e;i++)
#define reple(i,s,e) for(int i=s;i<=e;i++)
#define revrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

	deque<char> q(all(s));

	int count = 0;

	while (!q.empty())
	{
		if (q.size() == 1) break;

		if (q.front() == q.back())
		{
			q.pop_front();
			q.pop_back();
			continue;
		}

		if (q.front() == 'x')
		{
			count++;
			q.pop_front();
			continue;
		}

		if (q.back() == 'x')
		{
			count++;
			q.pop_back();
			continue;
		}

		count = -1;
		break;
	}

	cout << count << endl;

	return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
typedef pair<ll, int> Edge; // 辺，辺の先の点
typedef pair<ll, int> P; // 最短距離，点
using Graph = vector<vector<Edge>>;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int N;
    cin >> N;
    Graph G(N);
    for (int i = 0; i < N - 1; i++) {
        int u, v;
        ll w;
        cin >> u >> v >> w;
        u--, v--;
        G[u].push_back(Edge(w, v));
        G[v].push_back(Edge(w, u));
    }
    vector<ll> d(N, INF_64);
    vector<int> ans(N);
    priority_queue<P> que;
    que.push(P(0, 0));
    ans[0] = 0;

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[v] < p.first)
            continue;
        d[v] = p.first;
        if (d[v] % 2 == 0) {
            ans[v] = 0;
        } else {
            ans[v] = 1;
        }
        for (auto e : G[v]) {
            int nv = e.second;
            if (d[nv] < d[v] + e.first)
                continue;
            que.push(P(d[v] + e.first, nv));
        }
    }

    for (int i = 0; i < N; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 11848
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;

int main(){
	char alphabet[26];
	int time[26] = { };
	for(int i = 0; i < 26; i++){
		alphabet[i] = (char)('a' + i);
	}
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i++){
		time[s[i] - 'a']++;
	}
	int ans = 1000;
	for(int i = 0; i < 26; i++){
		if(time[i] == 0 && ans > i) ans = i;
	}
	if(ans == 1000) cout << "None" << endl;
	else cout << (char)('a' + ans) << endl;
	return 0;
}

Measured memory_bytes: 512
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

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

	int t;
	cin >> t;
	while(t--){
		int a, b, c;
		cin >> a >> b >> c;
		int can_1 = b * b + c * c - a * a;
		int can_2 = a * a + b * b - c * c;
		int can_3 = c * c + a * a - b * b;
		if(can_1 == 0 || can_2 == 0 || can_3 == 0)puts("YES");
		else puts("NO");
	}
	return 0;
}
// Write Here



Measured memory_bytes: 3084
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
from collections import deque

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

S = i_s()
d = deque()

for s in S:
    if not d:
        d.append(s)
        continue
    tmp = d.popleft()
    if tmp == s:
        d.append(tmp)
        d.append(s)

print(len(S)-len(d))

Measured memory_bytes: 4204
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 25, M = 1e6 + 25, oo = 1e9+7, mxmsk = 1 << 16;
const long long OO = 1e18+25;
    
#define par pair<pair<int,int>, int>
#define f first
#define s second

int c,d, a[N],b,n, t, e,mx;

int main() {
	scanf("%d",&n);
    for(int i=0; i<n; i++) scanf("%d",a+i);
    for(int i=1; i<n; i++)
    {
        if(a[i] <= a[i-1]) c++;
        else c = 0;
        mx = max(c, mx);
    }
    printf("%d\n",mx);
	return 0;
}

Measured memory_bytes: 640
/*
  最大流問題
  時間計算量：O(|E||V|^2)
  アルゴリズム：Dinic法
 */
#include <bits/stdc++.h>

using namespace std;

template<typename Weight>
class Dinic {
public:
    Dinic(const int n) : n(n), g(n), INF(numeric_limits<Weight>::max()) {}

    void add_edge(const int src, const int dst, const Weight cap) {
        g[src].emplace_back(Edge(src, dst, cap, g[dst].size()));
        g[dst].emplace_back(Edge(dst, src, 0, g[src].size() - 1));
    }

    Weight MaximumFlow(const int s, const int t) {
        Weight flow = 0;

        while(true) {
            vector<int> level(n, -1), iter(n);
            Bfs(s, level);

            if(level[t] == -1) break;
            for (Weight f = 0; (f = Dfs(level, iter, s, t, INF)) > 0; )
                flow += f;
        }

        return flow;
    }

private:
    struct Edge {
        int src, dst, rev;
        Weight weight;
        Edge(int f, int t, Weight cap, int rev = 0) :
            src(f), dst(t), rev(rev), weight(cap) {}
    };

    int n;
    vector<vector<Edge>> g;
    const Weight INF;

    void Bfs(const int s, vector<int> &level){
        queue<int> que;
        for (level[s] = 0, que.push(s); !que.empty(); ) {
            const int v = que.front(); que.pop();
            for (auto &e : g[v]) {
                if(e.weight > 0 && level[e.dst] == -1){
                    level[e.dst] = level[v] + 1;
                    que.push(e.dst);
                }
            }
        }
    }

    Weight Dfs(vector<int> &level, vector<int> &iter, int v, int t, Weight flow) {
        if(v == t) return flow;
        for (int &i = iter[v], N = g[v].size(); i < N; ++i) {
            Edge &e = g[v][i];

            if(e.weight > 0 && level[v] < level[e.dst]){
                Weight d = Dfs(level, iter, e.dst, t, min(flow, e.weight));
                if(d > 0){
                    e.weight -= d;
                    g[e.dst][e.rev].weight += d;
                    return d;
                }
            }
        }
        return 0;
    }
};

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

    int n, m, u, v, c;

    cin >> n >> m;
    Dinic<int> flow(n);
    for (int i = 0; i < m; ++i) {
        cin >> u >> v >> c;
        flow.add_edge(u, v, c);
    }

    cout << flow.MaximumFlow(0, n - 1) << endl;

    return 0;
}



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

int main()
{

    int m, f, r;
    while (true)
    {
        cin >> m >> f >> r;
        if ((m == -1) && (f == -1) && (r == -1))
            break;
        if ((m == -1) || (f == -1))
        {
            cout << 'F' << endl;
            continue;
        }
        if (m + f >= 80)
        {
            cout << 'A' << endl;
        }
        else if (m + f >= 65)
        {
            cout << 'B' << endl;
        }
        else if (m + f >= 50)
        {
            cout << 'C' << endl;
        }
        else if (m + f >= 30)
        {
            if (r >= 50)
            {
                cout << 'C' << endl;
            }
            else
            {
                cout << 'D' << endl;
            }
        }
        else
        {
            cout << 'F' << endl;
        }
    }
}


Measured memory_bytes: 3016