akhauriyash/Code-Regression huggingface dataset:
import math
N = int(input())
A = list(map(int, input().split()))
M = math.ceil(N / 2)
L = [0 for i in range(M)]

for a in A:
    if (N % 2 == 0 and a % 2 == 0) or (N % 2 != 0 and a % 2 != 0):
        print(0)
        exit()
    L[M - a // 2 - 1] += 1

if N % 2 == 0:
    for m in range(M):
        if L[m] != 2:
            print(0)
            exit()
else:
    for m in range(M):
        if m != M - 1:
            if L[m] != 2:
                print(0)
                exit()
        else:
            if L[m] != 1:
                print(0)
                exit()

ans = 1
MOD = int(1e9) + 7
for m in range(N // 2):
    ans *= 2
    ans %= MOD
print(ans)


Measured memory_bytes: 13940
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	LL s;
	cin>>s;
	LL ans[3][2]={};
	if(s==1000000LL*1000000*1000000){
		cout<<0<<" "<<0<<" "<<1000000000<<" "<<0<<" "<<0<<" "<<1000000000<<endl;
		return 0;
	}
	LL sq=sqrt(s);
	FOR(i,-2,3){
		if((sq+i+1)*(sq+i+1)>=s){
			sq+=i;
			break;
		}
	}
	//cerr<<"sq:"<<sq<<endl;
	if(sq*sq==s){
		ans[1][0]=sq;
		ans[1][1]=0;
		ans[2][0]=0;
		ans[2][1]=sq;
	}else if(sq*(sq+1)>=s){
		LL rest=sq*(sq+1)-s;
		//cerr<<"rest1:"<<rest<<endl;
		ans[1][0]=sq;
		ans[1][1]=1;
		ans[2][0]=rest;
		ans[2][1]=sq+1;
	}else{
		LL rest=(sq+1)*(sq+1)-s;
		//cerr<<"rest2:"<<rest<<endl;
		ans[1][0]=sq+1;
		ans[1][1]=1;
		ans[2][0]=rest;
		ans[2][1]=sq+1;
	}


	FOR(i,0,3){
		cout<<ans[i][0]<<" "<<ans[i][1]<<" ";
	}
	return 0;
}


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

const int d = 365;
int main() {
  vector<int> c(26);
  int mn = 1000, mnv;
  for (int i = 0; i < 26; i++) {
    cin >> c[i];
    if (mn > c[i]) {
      mn = c[i];
      mnv = i + 1;
    }
  }
  vector<vector<int>> s(d, vector<int>(26));
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s[i][j];
    }
  }

  vector<int> t(26);
  for (int i = 0; i < 26; i++) {
    t[i] = i + 1;
  }

  for (int i = 0; i < d; i++) {
    cout << mnv << endl;
  }

  return 0;
}


Measured memory_bytes: 3688
def create_card():
    return [str(i) for i in range(1,14)]
Card = {
        'S':create_card(),
        'H':create_card(),
        "C":create_card(),
        "D":create_card(),
        }
for i in range(int(input())):
    in_str = input().split()
    Card[in_str[0]].remove(in_str[1])

for s in ['S','H','C','D']:
    while(Card[s]):
        print(s,Card[s].pop(0))

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

int main(){
	int q, x;
	char com[20];
	//使用标准库中的list
	list<int> v;
	scanf("%d",&q);
	for(int i =0; i<q; i++){
		scanf("%s",&com);
		if( com[0] == 'i'){//insert
		scanf("%d",&x);
		v.push_front(x);
		}else if(com[6] == 'L'){//deletelast
		v.pop_back();
		}else if (com[6] == 'F'){//deletefirst
		v.pop_front();
		}else if (com[0] == 'd'){//delete
			scanf("%d",&x);
			for (list<int>::iterator it = v.begin(); it != v.end(); it++){
				if(*it == x){
					v.erase(it);
					break;
				}
			}
		}
	} 
	int i= 0;
	for( list<int>::iterator it = v.begin(); it != v.end(); it++){
		if( i++ )printf(" ");
		printf("%d", *it);
	}
	printf("\n");
	
	return 0;
} 


Measured memory_bytes: 34024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF 20000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
#define MOD 1000000007
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 1
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

int pow(int mul,int times){
  int s=1;
  while(times){
    s*=mul;
    times--;
  }
  return s;
}

signed main(){
  string s; cin>>s;
  int n=s.size()-1;
  
  int ans=0;
  for(int i=0; i<(1<<n); i++){
    vector<int> num[13];
    for(int j=0; j<=12; j++) num[j].clear();
    int cnt=0;
    num[cnt].push_back(s[0]-'0');
    for(int j=0; j<n; j++){
      if(i&(1<<j)){
        cnt++;
      }
      num[cnt].push_back(s[j+1]-'0');
    }
    for(int j=0; j<=cnt; j++){
      for(int k=0; k<num[j].size(); k++){
        ans+=num[j][k]*pow(10, num[j].size()-k-1);
      }
    }
  }
  cout<<ans<<en;
}



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

int main() {
	int n, tt;
	cin >> n >> tt;
	int ans = 10000000;
	while (n --) {
		int c, t;
		cin >> c >> t;
		if (tt >= t) {
			ans = min(ans, c);
		}
	}
	if (ans == 10000000) {
		cout << "TLE" << endl;
	} else {
		cout << ans << endl;
	}
        return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int k = sc.nextInt();
        int n = sc.nextInt();

        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int max = a[0] + k - a[n-1];
        for(int i=0; i<n-1; i++) {
            max = Math.max(max, a[i+1]-a[i]);
        }
        System.out.println(k-max);
    }
}

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

int main() {
    int n, ans;
    cin >> n;
    if(n%1000==0) cout << "0" << endl;
    else{
        ans = 1000 - n%1000;
        cout << ans << endl;
    }
}


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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
inline ll powll(ll x,ll y) {ll p=1; while(y--) p*=x; return p;}


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

    int N; cin >>N;

    int A;
    int even = 0;
    rep(i, N) {
        cin >> A;
        if (A%2==0) even++;
    }
    
    cout << powll(3, N) - powll(2, even) << endl;
}


Measured memory_bytes: 256
//c++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
#include <fstream>
#include <random>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);
#define len(x) ((int)(x).size())

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const int INF = 1 << 30;//10^9
const ll MOD = 1000000007;
//const ll MOD = 998244353;
double EPS = 1e-10;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.9lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


//コンビネーション
const int MAXcomb = 2000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; 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;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}



ll disit(ll s, ll base = 10){
  ll res = 0;
  while(s){
    res++;
    s /= base;
  }
  return res;
}

void solve(){
  ll x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  ll dec = min(x / d, k);
  x -= d * dec;
  k -= dec;
  if(k % 2){
    cout << abs(x - d) << endl;
  }else{
    cout << x << endl;
  }
}

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


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll mod = 1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  vector<bool> island(n);
  rep(i,n) island[i] = true;
  
  rep(i,m) {
      int a, b;
      cin >> a >> b;
      a--; b--;
      if (h[a] > h[b]) {
          island[b] = false;
      } else if (h[a] < h[b]) {
          island[a] = false;
      } else {
          island[a] = false;
          island[b] = false;
      }
  }

  int ans = 0;
  rep(i,n) {
      if (island[i]) ans++;
  }
  cout << ans << endl;
} 


Measured memory_bytes: 3784
list_1 = list(map(int, input().split()))
list_2 = list(map(int, input().split()))
list_3 = list(map(int, input().split()))
list_bingo = list_1 + list_2 + list_3
list_check =[]
n = int(input())
for i in range(n):
    b = int(input())
    if b in list_bingo:
        list_check.append(list_bingo.index(b))
if 0 in list_check and 1 in list_check and 2 in list_check or 3 in list_check and 4 in list_check and 5 in list_check or 6 in list_check and 7 in list_check and 8 in list_check:
    print("Yes")
elif 0 in list_check and 3 in list_check and 6 in list_check or 1 in list_check and 4 in list_check and 7 in list_check or 2 in list_check and 5 in list_check and 8 in list_check:
    print("Yes")
elif 0 in list_check and 4 in list_check and 8 in list_check or 2 in list_check and 4 in list_check and 6 in list_check:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

int main(){
    int A,B,K;
    cin >> A >> B >> K;
    int cnt=0;
    for(int i=100;i>0;i--){
        if(A%i == 0 && B%i == 0){
            cnt++;
        }
        if(cnt==K){
            cout << i << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
	int H,W,i=0,j=0,k=0;
	while(cin>>H>>W){
		if(H==0&&W==0) break;
		for(i=1;i<=H;i++){
			for(j=1;j<W;j++){
				if(i%2==1){
					if(j%2==1)cout<<"#";
					else cout<<".";
					}
				else{
					if(j%2==1)cout<<".";
					else cout<<"#";
				}
			}
			if (W%2==0){
				if(i%2==1) cout<<"."<<endl;
				else cout<<"#"<<endl;
				}
			else{
				if(i%2==1) cout<<"#"<<endl;
				else cout<<"."<<endl;
			}
		}
	cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
int main()
{
  int n,score[1000];
  int i;
  int max,min;
  int sum;
  while(1)
    {
      scanf("%d",&n);
      if(n==0) break;
      sum=0;
      for(i=0;i<n;i++)
	{
	  scanf("%d",&score[i]);
	  sum+=score[i];
	}
      max=score[0];
      for(i=1;i<n;i++)
	{
	  if(max<score[i]) max=score[i];
	}
      min=max;
      for(i=0;i<n;i++)
	{
	  if(min>score[i]) min=score[i];
	}
      printf("%d\n",(sum-max-min)/(n-2));
    }
  return 0;
}

Measured memory_bytes: 604
//Author:Nirmit Shah
//201701044
//Daiict,Gandhinagar
 
#include<bits/stdc++.h>
using namespace std;
 
//Macros
#define Fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define error std::cerr
#define INF LONG_LONG_MAX
//#define MINF=LONG_LONG_MIN
#define MOD 1000000007
#define pii pair<int,int>
#define forn(i,j,n) for(ll i=j;i<n;i++)
#define mp make_pair
#define pb push_back
#define ull unsigned long long
 
//Debugging
#define deb1(x) cout<<#x<<" : "<<x<<endl;
#define deb2(x,y) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<endl;
#define deb3(x,y,z) cout<<#x<<" : "<<x<<"\t"<<#y<<" : "<<y<<"\t"<<#z<<" : "<<z<<endl;
 
#define all(c) c.begin(),c.end()
 
ll min(ll x,ll y)
{
    if(x>y)
        return y;
    return x;
}
 
ll max(ll x,ll y)
{
    if(x>y)
        return x;
    return y;
}
 
ll gcd(ll x,ll y)
{
    if(!x)
        return y;
    return gcd(y%x,x);
}
 
ll calcpower(ll x, ll y)
{
    ll ans = 1;
    x = x % MOD;
    while (y > 0)
    {
        if (y & 1)
            ans = (ans*x) % MOD;
 
            y = y>>1;
            x = (x*x) % MOD;
    }
    return ans;
}
 
/*bool prime[1000005];
void Sieve(ll n)
{
    for(int i=0; i<1000005; i++)
        prime[i] = true;
    prime[1] = false;
    prime[0] = false;
 
    for (ll p=2; p*p<=n; p++)
    {
        if (prime[p])
        {
            for (ll i=p*2; i<=n; i += p)
                prime[i] = false;
        }
    }
}*/
 
int main()
{
    Fast;
    ll n,m,x,y;
    cin>>n>>m>>x>>y;
    
    ll a[n];
    ll b[m];
    forn(i,0,n)
        cin>>a[i];
    forn(i,0,m)
        cin>>b[i];
    sort(a,a+n);
    sort(b,b+m);
    ll maxi=a[n-1];
    ll mini=b[0];
    
    if(x<a[n-1] && a[n-1]<=y && x<mini && mini<=y)
    {
        if(b[0]>a[n-1])
            cout<<"No War\n";
        else
            cout<<"War\n";
    }
    else
        cout<<"War\n";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
const int N=15;
inline bool Check(char*s,char*t){
    if(strlen(s)!=strlen(t)) return 0;
    for(register int i=0;s[i];i++)
        if(s[i]!=t[i]) return 0;
    return 1;
}
char S[N],T[N],U[N];
int a,b;
int main(){
    scanf("%s %s",S,T);
    scanf("%d %d",&a,&b);
    scanf("%s",U);
    if(Check(U,S)) a--;
    else b--;
    printf("%d %d\n",a,b);
    return 0;
}

Measured memory_bytes: 128
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    token.parse().ok().unwrap()
}

fn main() {
    let a1 = input::<i64>();
    let a2 = input::<i64>();
    let a3 = input::<i64>();

    let mut ans = i64::max_value();
    ans = std::cmp::min(ans, (a1 - a2).abs() + (a2 - a3).abs());
    ans = std::cmp::min(ans, (a1 - a3).abs() + (a3 - a2).abs());
    ans = std::cmp::min(ans, (a2 - a1).abs() + (a1 - a3).abs());
    ans = std::cmp::min(ans, (a2 - a3).abs() + (a3 - a1).abs());
    ans = std::cmp::min(ans, (a3 - a1).abs() + (a1 - a2).abs());
    ans = std::cmp::min(ans, (a3 - a2).abs() + (a2 - a1).abs());
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
    
int main(){
  int k,s;
  cin >> k >> s;
  int ans = 0;
  rep(x,k+1){
    rep(y,k+1){
      int z = s - x - y;
      if(0 <= z && z <= k) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (void)
{
  int n,i,j,num;
  char card[5][14]={0},mark;
  //s=1,h=2,c=3,d=4
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf(" %c %d",&mark,&num);
    if(mark=='S')card[1][num]=1;
    if(mark=='H')card[2][num]=1;
    if(mark=='C')card[3][num]=1;
    if(mark=='D')card[4][num]=1;
  }
  for(i=1;i<=4;i++){
    for(j=1;j<=13;j++){
      if(card[i][j]==0){
    if(i==1)printf("S %d\n",j);
    if(i==2)printf("H %d\n",j);
    if(i==3)printf("C %d\n",j);
    if(i==4)printf("D %d\n",j);
      }
    }
  }
  return 0;
}
    


Measured memory_bytes: 2040
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<vector>
struct P{int x,y;P(int x,int y):x(x),y(y){}};

int num[10][10];
bool visited[10][10];
std::vector<P>v;

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

bool BackTrack(int x,int y,int index,int rest)
{
	if(rest==0)
	{
		if(index==v.size()-1)
			return true;
		++index;
		x=v[index].x;
		y=v[index].y;
		rest = -num[y][x];
		return BackTrack(x,y,index,rest);
	}
	bool res = false;
	for(int i=0; i<4; ++i)
	{
		int nx = x+dx[i];
		int ny = y+dy[i];
		if(visited[ny][nx])continue;
		visited[ny][nx] = true;

		res = res || BackTrack(nx,ny,index,rest-num[ny][nx]);

		visited[ny][nx] = false;
	}
	return res;
}

int main()
{
	int n,i,j,t;
	while(scanf("%d",&n),n)
	{
		v.clear();
		memset(visited,1,sizeof(visited));

		int check = 0;
		for(i=1; i<=n; ++i)
		{
			for(j=1; j<=n; ++j)
			{
				scanf("%d",&t);
				num[i][j]=t;
				if(t<0)
				{
					v.push_back(P(j,i));
					visited[i][j]=true;
				}
				else
				{
					visited[i][j]=false;
				}
				check += t;
			}
		}

		int x=v[0].x;
		int y=v[0].y;
		puts(check==0&&BackTrack(x,y,0,-num[y][x]) ? "YES" : "NO");
	}
	return 0;
}

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

int main() {
 
  int n;
  cin >> n;
  
  map<string,int> s;
  
  string name;
  
  int saidai = 0;
  
  for ( int i = 0; i < n; i++){
    cin >> name;
    s[name]++;
    saidai = max(saidai,s[name]);
  }
  
  for ( auto t : s ){
    auto key = t.first;
    auto value = t.second;
    if ( value == saidai ){
      cout << key << endl;
    }
  } 
  
}

Measured memory_bytes: 19176
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cmath>
#include <limits>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
int N, A[3][3], b[10];
bool appear[3][3];
int main() {
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) cin >> A[i][j];

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

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			appear[i][j] = false;
			for (int k = 0; k < N; k++) {
				if (A[i][j] == b[k]) appear[i][j] = true;
			}

		}

	}
	string ANS = "No";
	for (int i = 0; i < 3; i++) {
		if (appear[i][0] and appear[i][1] and appear[i][2]) ANS = "Yes";
	}
	for (int i = 0; i < 3; i++) {
		if (appear[0][i] and appear[1][i] and appear[2][i]) ANS = "Yes";
	}
	if (appear[0][0] and appear[1][1] and appear[2][2]) ANS = "Yes";
	if (appear[0][2] and appear[1][1] and appear[2][0]) ANS = "Yes";
	cout << ANS << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
 
#define REDIRECT(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)
#define CLOSEALL() fclose(stdin), fclose(stdout)
 
using namespace std;
 
const int MAXN = 1e5 + 10;
 
int N;
bool vist[MAXN], noSolution;
vector <int> Adj[MAXN];
 
inline void addEdge(int u, int v)
{
	Adj[u].push_back(v), Adj[v].push_back(u);
}
 
void DFS(int cur, int pre)
{
	if(noSolution)
		return;
 
	// If it's a leaf, match it with its parent
	if(Adj[cur].size() == 1)
	{
		if(vist[pre])
			noSolution = true;
		vist[cur] = true;
		vist[pre] = true;
		return;
	}
 
	for(vector<int>::iterator itr = Adj[cur].begin(); itr != Adj[cur].end(); ++itr)
	{
		if(*itr == pre)
			continue;
		DFS(*itr, cur);
	}
 
	// If it's not matched
	if(!vist[cur])
	{
		// It's parent is used or its the root
		if(vist[pre] || pre == 0)
			noSolution = true;
		vist[cur] = true;
		vist[pre] = true;
		return;
	}
}
 
int main()
{
	//REDIRECT("blackwhite");
 
	int u, v;
	scanf("%d", &N);
	for(int i = 1; i < N; i++)
		scanf("%d%d", &u, &v),
		addEdge(u, v);
 
	for(int i = 1; i <= N; i++)
		if(Adj[i].size() > 1)
		{
			DFS(i, 0);
			break;
		}
 
	puts(noSolution ? "First" : "Second");
 
	CLOSEALL();
	return 0;
}

Measured memory_bytes: 5888
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <bitset>
using namespace std;

int n;
const int maxn = 2005;
int a[maxn];

bitset<4000005> dp;
int main(){
	cin >> n;
	int sum = 0;
	for(int i = 1;i <= n;i++){
		scanf("%d",&a[i]);
		sum += a[i];
	}
	dp.set(0);
	for(int i = 1;i <= n;i++){
		dp |= (dp << a[i]);
	}
	int ans = sum;
	for(int i = 0;i <= sum;i++){
		if(dp.test(i) == 1){
			if(i * 2 >= sum){
				ans = min(ans,i);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1664
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>
#include <iterator>

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ldouble = long double;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s) cout << fixed << setprecision(10) << s << endl;


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

	string a0 = a;
	string b0 = b;

	ll m = max(a.length(), b.length());
	for (ll i = 0; i < m - a.length(); i++)
	{
		a0 = "0" + a0;
	}

	for (ll i = 0; i < m - b.length(); i++)
	{
		b0 = "0" + b0;
	}

	string res = "EQUAL";
	if (a0 > b0)
	{
		res = "GREATER";
	}
	else if (a0 < b0)
	{
		res = "LESS";
	}

	println(res);
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <sstream>

#define DEBUG 0
#define fi first
#define se second
#define pb push_back
#define fore(i, a, b) for (int i = (a), _b = (b); i < (_b); ++i)
#define fort(i, a, b) for (int i = (a), _b = (b); i <= (_b); ++i)
#define ford(i, a, b) for (int i = (a), _b = (b); i >= (_b); --i)

using namespace std;

typedef long long LL;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;

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

int main() {
    if (DEBUG) {
        freopen("CP.inp", "r", stdin);
        //freopen("CP.out", "w", stdout);
    }
    ios_base::sync_with_stdio(false); cin.tie(0);
    string s; cin >> s;
    int n = (int)s.size();
    vvi f(n + 1, vi(13));
    f[0][0] = 1;
    fore(i, 0, n) fore(j, 0, 13) {
        if (s[i] != '?') f[i + 1][(j * 10 + s[i] - '0') % 13] = (f[i + 1][(j * 10 + s[i] - '0') % 13] + f[i][j]) % MOD;
        else {
            fore(k, 0, 10) f[i + 1][(j * 10 + k) % 13] = (f[i + 1][(j * 10 + k) % 13] + f[i][j]) % MOD;
        }
    }
    cout << f[n][5] << '\n';
    return 0;
}


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

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

int main(){
	ll A,B,C,D;
	cin >> A >> B >> C >> D;
	
	ll temp = B/C - (A+C-1)/C + 1;
	
	ll temp2 = B/D - (A+D-1)/D + 1;
	
	ll val = C*D/gcd(C,D) ;
	
	ll temp3 = B/val - (A+val-1)/val + 1;
	
	cout << B-A + 1 - temp - temp2 + temp3 << endl;
}

Measured memory_bytes: 256
s = input()
q = int(input())

S = []

for i in range(q) :
  x = list(map(str, input().split()))
  a = int(x[1])
  b = int(x[2]) + 1

  if(x[0] == "print") :
    S.append(s[a:b])
  elif(x[0] == "reverse") :
    rv = s[a:b]
    srv = rv[::-1]  #[::-1]で逆転
    s = s[:a] + srv + s[b:]
  else :
    rp = x[3]
    s = s[:a] + rp + s[b:]

for j in S :
  print(j)


Measured memory_bytes: 5616
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


typedef pair<ll,int> P;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout<<setprecision(10);
  int n,m,s,t;
  cin>>n>>m>>s>>t;
  vector<vector<P>> sun(n+1),yen(n+1);
  rep(i,m)
  {
    int u,v,a,b;
    cin>>u>>v>>a>>b;
    sun[u].push_back({v,b});
    sun[v].push_back({u,b});
    yen[u].push_back({v,a});
    yen[v].push_back({u,a});

  }
  priority_queue<P,vector<P>,greater<P>> sq,yq;
  vector<ll> sm(n+1,-1),ym(n+1,-1);
  yq.push({0,s});
  sq.push({0,t});
  while(!yq.empty())
  {
    P tp=yq.top();yq.pop();
    if(ym[tp.second]>-1)continue;
    ym[tp.second]=tp.first;
    for(P nn:yen[tp.second])
    {
      if(ym[nn.first]>-1)continue;
      yq.push({tp.first+nn.second,nn.first});
    }
  }
  while(!sq.empty())
  {
    P tp=sq.top();sq.pop();
    if(sm[tp.second]>-1)continue;
    sm[tp.second]=tp.first;
    for(P nn :sun[tp.second])
    {
      if(sm[nn.first]>-1)continue;
      sq.push({tp.first+nn.second,nn.first});
    }
  }
  vector<ll> ans(n+1);
  ll res=1e15;
  for(int i=n;i>0;i--)
  {
    ll tmp=sm[i]+ym[i];
    chmin(res,tmp);
    ans[i]=1e15-res;
  }
  rep(i,n)cout<<ans[i+1]<<"\n";
  cout<<flush;
  return 0;

}


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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)
#define PI 3.14159265358979

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

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int n, a[101010];
map<int,int> mp;
void solve(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
		mp[a[i]]++;
	}
	
	int cnt = 0;
	for(int i = 0; i < n; i++){
		if(mp[a[i]] % 2){
			cnt++;
			mp[a[i]] = 0;
		}
	}
	cout << cnt << endl;
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  int north = -1;
  int south = -1;
  int west = -1;
  int east = -1;

  for(int i=0;i<s.size();i++) {
    if(s[i] == 'N') north = 1;
    else if(s[i] == 'S') south = 1;
    else if(s[i] == 'W') west = 1;
    else if(s[i] == 'E') east = 1;
  }

  if(north * south == 1 && west * east == 1) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
  string S;
  cin >> S;
  
  int K;
  cin >> K;
  
  for (int i = 0; i < S.size(); i++) {
    if (K < 26 - (S[i] - 'a')) {
      if (i < S.size()-1) {
        continue;
      } else {
        // 最後の文字を出来る限り回す
        // aに戻らないことが確定しているので単に足すだけでオッケー
        S[i] = S[i] + K;
        K = 0;
        break;
      }
    } else {
      
      if (S[i] == 'a') continue;
      
      // その文字を'a'になるまで動かす
      K -= 26 - (S[i] - 'a');
      S[i] = 'a';
    }
    
  }
  
  if (K > 0) {
    K %= 26;
    
    
    S[S.size()-1] = S[S.size()-1] + K;
  }
  
  
  cout << S << endl;

}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define scan(n) scanf("%d",&n)
#define ls(n) scanf("%lld",&n)
#define print(n) printf("%d",n)
#define pln(n) printf("%d\n",n)
#define lpln(n) printf("%lld\n",n)
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rev(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define tc           ll t1; cin>>t1; while(t1--)
#define inp         ll n; cin>>n; ll arr[n]; rep(i,0,n) cin>>arr[i];
#define vect vector<ll>
#define sortv(v)       sort(v.begin(),v.end())
#define lower(v,n)    lower_bound(v.begin(),v.end(),n)-v.begin()
#define upper(v,n)    upper_bound(v.begin(),v.end(),n)-v.begin()
#define all(v)        v.begin(),v.end()
#define bitcount(n) __builtin_popcount(n)
#define ln <<endl
#define inf          1e12+5
#define ninf         LONG_MIN
#define fast()         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
const   ll mod=1e9+7;
const ll N=1e5+5;




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

          string s;
          cin >> s;
          int c=0;
          
          if(s[0]=='R' && s[1]=='R' && s[2]=='R')
            c=3;
         else if(s[0]=='R' && s[1]=='R')
            c=2;
        else  if(s[2]=='R' && s[1]=='R')
            c=2;
        else  if(s[2]=='R')
            c=1;
         else if(s[1]=='R')
            c=1;
         else if(s[0]=='R')
            c=1;
          cout<<c;
          
 
           return 0; 

} 

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

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

  for( auto &c : S ){
    int c_code = (int)c;
    if (N + c_code <= 90 )
    {
      c = (char)( N + c_code );
    }else{
      c = (char)( N + c_code - 26 );
    }
  }

  cout << S << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <bitset>
#include <limits.h>
#define REP(i, n) for(LL i = 0;i < n;i++)
#define REPR(i, n) for(LL i = n;i >= 0;i--)
#define FOR(i, m, n) for(LL i = m;i < n;i++)
#define FORR(i, m, n) for(LL i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define INF (LL)1e15
#define MOD 1000000007
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;
typedef pair<int, P> PP;
typedef pair<LL, LP> LPP;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

//#define int long long

/*************** using variables ***************/
/**********************************************/

signed main(){
    map<vector<int>, int> mp;
    int n;
    cin >> n;
    vector<int> amida = {0, 1, 2};
    mp[{0, 1, 2}] = 0;
    mp[{0, 2, 1}] = 0;
    mp[{1, 0, 2}] = 0;
    mp[{1, 2, 0}] = 0;
    mp[{2, 1, 0}] = 0;
    mp[{2, 0, 1}] = 0;
    REP(i, n){
        int w;
        cin >> w;
        vector<int> amida = {0, 1, 2};
        REP(i, w){
            int a;
            cin >> a;
            if(a == 0){
                swap(amida[0], amida[1]);
            }else if(a == 1){
                swap(amida[1], amida[2]);
            }
        }
        mp[amida]++;
    }

    bool flag = false;
    if(mp[{0, 1, 2}] >= 1) flag = true;
    else if(mp[{0, 2, 1}] >= 2 || mp[{1, 0, 2}] >= 2 || mp[{1, 2, 0}] >= 3 || mp[{2, 0, 1}] >= 3 || mp[{2, 1, 0}] >= 2) flag = true;

    if(!flag){
        if(mp[{1, 2, 0}] >= 1 && mp[{2, 0, 1}] >= 1) flag = true;
        else if(mp[{1, 2, 0}] == 0 && mp[{2, 0, 1}] == 0){
            cout << "no" << endl;
            return 0;
        }
        else{
            if(mp[{0, 2, 1}] + mp[{1, 0, 2}] + mp[{2, 1, 0}] >= 2){
                flag = true;
            }
        }

    } 
    if(flag) cout << "yes" << endl;
    else cout << "no" << endl;
    // デバッグ用
    /*
    cout << "{0, 1, 2}: " << mp[{0, 1, 2}] << endl;
    cout << "{0, 2, 1}: " << mp[{0, 2, 1}] << endl;
    cout << "{1, 0, 2}: " << mp[{1, 0, 2}] << endl;
    cout << "{1, 2, 0}: " << mp[{1, 2, 0}] << endl;
    cout << "{2, 1, 0}: " << mp[{2, 1, 0}] << endl;
    cout << "{2, 0, 1}: " << mp[{2, 0, 1}] << endl;
    */
}



Measured memory_bytes: 3156
from collections import deque

def to_char(n):
    base = ord('a')
    return chr(base + n)

def main():
    N = int(input())
    q = deque([])
    # print(q)
    while N > 0:
        N -= 1
        v = N % 26
        q.appendleft(v)
        N //= 26

    # print(q)
    print(''.join(map(to_char, q)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 9460
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


int main() {
	ll n, k;
	const ll INF = 10001000100;
	std::cin >> n >> k;
	vll h(n),cost(n,INF);
	cost[0] = 0;
	rep(i, 0, n) {
		std::cin >> h[i];
		rep(j, max(i - k, 0LL), i) {
			cost[i] = min(cost[j] + abs(h[i] - h[j]), cost[i]);
		}
	}

	std::cout << cost[n - 1] << endl;
	return 0;
}

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

int main(){
    ll n, k;
    cin>>n>>k;
    ll ans=0;
    for(ll i=0;i<1e9;++i){
        if(pow(k, i) <= n){
            ans=i+1;
        }else{
            break;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
/**************************************************
 * Atcoder problems
 * Contest No :081
 * Problem No :A
 * File Name  :program_copy.cs
 * Create date:2020/06/07
 *
 * Copyright 2020 Shunichi Sato,All Rights Reserved.
**************************************************/
//memo terinal command
//compile:mcs program.cs
//excute :mono program.exe
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
        // 整数の入力
        string input = Console.ReadLine();
		// 個数の判定
		int output = 0;
        if (input[0] == '1')
        {
            output++;
        }
        if (input[1] == '1')
        {
            output++;
        }
        if (input[2] == '1')
        {
            output++;
        }
		//出力
		Console.WriteLine(output);
	}
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define len(x) ((int)(x).size())

using namespace std;

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

  int N, D;
  cin >> N >> D;
  int a, b;

  int count = 0;
  while (N) {
    cin >> a >> b;
    if (pow(a, 2) + pow(b, 2) <= pow(D, 2)) count++;
    --N;
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
int main() {
    long int N,K,Q;
    cin >> N >> K >> Q;
    int A[Q];
    for (int i=0;i<Q;i++) cin >> A[i];
  
    int B[N];
    for (int i=0;i<N;i++)  B[i] =0;
    for (int i=0;i<Q;i++) B[A[i]-1]++;
    for (int i=0;i<N;i++){
        if (B[i]>Q-K) cout << "Yes\n";
        else cout << "No\n";
    }

}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int T;
  R T;
  while(T--) {
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a<b||b>d) {
      pr("No");
      continue;
    } else if(b<=c) {
      pr("Yes");
      continue;
    }
    a%=b;
    ll x=a;
    a+=d;
    a%=b;
    ll y=a;
    a+=d;
    if(c<x||c<y) {
      pr("No");
      continue;
    }
    ll z=abs(x-y);
    ll r=__gcd(z,b);
    if(b-c>r) {
      pr("No");
      continue;
    }
    pr("Yes");
  }
}

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


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int main(){
    ll a, b , c;
    cin >> a >> b >> c;
    if(a%2 || b%2 || c%2){
        cout << 0 << endl;
        return 0;
    }
    if(a==b && b==c){
        cout << -1 << endl;
        return 0;
    }
    ll ta = a, tb = b, tc = c;
    FOR(i,0,500000000){
        if(a%2 || b%2 || c%2){
            cout << i << endl;
            return 0;
        }
        a = (tb+tc)/2;
        b = (ta+tc)/2;
        c = (tb+ta)/2;
        ta = a, tb = b, tc = c;
    }
    cout << -1 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s, n) for(int i = s; i < (int)(n); i++)
#define co(x) cout<<x<<endl
#define SQvec(i,j) vector<vector<int>> data(i, vector<int>(j))
#define mod 1000000000+7
typedef long long int lint;

int main() {
  int N,K,d,A;
  cin >> N >> K;
  vector<int> ans(0);
  
  rep(i,0,K){
    cin >> d;
    rep(j,0,d){
      cin >> A;
      ans.push_back(A);
    }
  }
  sort(ans.begin(), ans.end());
  ans.erase(unique(ans.begin(), ans.end()), ans.end());  
  co(N - ans.size());
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
const int N = 1003, m = 10004;
struct ban
{
    int w, s;
    int g;
};
bool operator<(const ban& a, const ban& b)
{
    return a.w + a.s < b.w + b.s;
}

int n;
ban a[N];

long long dp[m];
int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        scanf("%d%d%d", &a[i].w, &a[i].s, &a[i].g);
    sort(a, a + n);
    long long ans = 0;
    for (int i = 0; i < n; ++i)
    {
        for (int j = a[i].s; j >= 0; --j)
        {
            ans = max(ans, dp[j] + a[i].g);
            if (j + a[i].w < m)
                dp[j + a[i].w] = max(dp[j + a[i].w], dp[j] + a[i].g);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
table = [0 for i in range(2*10**5+5)]
for i in range(2*10**5+5):
    table[i] = "{:0b}".format(i).count("1")


def main():
    """
    a % d + c % d = (a + c) % dだよね
    整数の余りを取るのと，整数の各桁の余りを取るのが同じこともあった　→　Digits Parade
    """
    N = int(input())
    X = input()
    t = X.count("1")
    x1, x2 = int(X, 2) % (t+1), int(X, 2) % (t-1) if t != 1 else 0
    for i in range(N):
        ans = 1
        x = 0
        if X[i] == "0":
            # 反転してt+1
            p = pow(2, N-i-1, t+1)
            x = x1 + p
            x %= t+1
        elif t != 1 and X[i] == "1":
            p = pow(2, N-i-1, t-1)
            x = x2 - p
            x %= (t-1)
        else:
            # t == 1 かつ その"1"を反転するとき
            # 当然X_iは0になる，答えも0
            ans = 0
        while x > 0:
            x %= table[x]
            ans += 1
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 86580
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n, k);
    Cins(int, n, p);
    Sort(p);
    ll ans = 0;
    For(i, k){
        ans += p[i];
    }
    Cout(ans);
}


Measured memory_bytes: 3624
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    H, W = Scanner.map_int()
    S = Scanner.string_list(H)
    white = 0
    for s in S:
        white += s.count(".")
    q = []
    q.append((0, 0))
    memo = [[-1 for _ in range(W)] for _ in range(H)]
    memo[0][0] = 0
    while q != []:
        cur = q.pop(0)
        DIR = [(-1, 0), (1, 0), (0, 1), (0, -1)]
        for i in range(4):
            next = (cur[0] + DIR[i][0], cur[1] + DIR[i][1])
            if not 0 <= next[1] < H:
                continue
            if not 0 <= next[0] < W:
                continue
            if S[next[1]][next[0]] == "#":
                continue
            if memo[next[1]][next[0]] != -1:
                continue
            memo[next[1]][next[0]] = memo[cur[1]][cur[0]] + 1
            q.append(next)
    if memo[H-1][W-1] == -1:
        print("-1")
    else:
        print(white - memo[H-1][W-1] - 1)


if __name__ == "__main__":
    main()


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

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

int MOD = 1e9 + 7;
ll INF = 1e18;

int main() {
    int n; cin>>n;
    ll sum=0;
    for(int i=0; i<n; i++) {
        int a; cin>>a;
        sum += (a-1);
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
d = int(input())
c = list(map(int, input().split()))
x = [0] * 26
y = [0] * 26
for _ in range(d):
    s = list(map(int, input().split()))
    for i in range(26):
        x[i] += c[i]
        y[i] = s[i] - x[i]
    ans = y.index(max(y)) + 1
    print(ans)
    x[ans - 1] = 0

Measured memory_bytes: 68604