akhauriyash/Code-Regression huggingface dataset:
# Author: cr4zjh0bp
# Created: Fri Mar  6 03:39:35 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

from collections import Counter

s = ns()
n = len(s)
k = ni()

l = []
for i in range(n):
    st = s[i]
    l.append(st)
    for j in range(1, min(k, n - i)):
        st += s[i + j]
        l.append(st)

c = Counter(l)
uni = list(c)
uni.sort()
print(uni[k - 1])

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

// A

const string YES = "";
const string NO  = "";

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

void solve() {

}

int main() {
  string s;
  cin >> s;
  if( s.back() == 's' ) {
    cout << s << "es" << endl;
  } else {
    cout << s << "s" << endl;
  }

  return 0;
}


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

using namespace std;

typedef long long int64;

int64 N, k;

bool check(int64 val)
{
  for(int i = 0; i < N - 1; i++) {
    val -= val / k + 1;
  }
  return (val < 0);
}

int main()
{
  cin >> N >> k;
  int64 low = 0, high = 1000000000000000000LL;
  while(high - low > 0) {
    int64 mid = (low + high) >> 1;
    if(!check(mid)) high = mid;
    else low = mid + 1;
  }
  cout << low << endl;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
#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 ALL(v) v.begin(), v.end()
#define MAX(a, b, c) max(max(a, b), c)
using namespace std;

int main(){
  int a,p;
  scanf("%d%d", &a, &p);
  cout << (3*a+p)/2 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int X,N;
  int tmp;
  cin >> X >> N;
  
  vector<int> check(101);
  
  REP(i,N){
    cin >> tmp; 
    check.at(tmp)++;
  }
  
  int j,ans;
  REP(i,202){
    if(i % 2 == 0)
      j = i / 2;
    else
      j = -i / 2 - 1;
    if(X + j > 100){
      ans = 101;
      break;
    }
    
    if(check.at(X + j) == 0){
      ans = X + j;
      break;
    }
  }
  cout << ans << endl; 
}

Measured memory_bytes: 3608
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<fstream>

int main() {
	int *N = new int[4];
	int *a = new int[4];
	int error = 0;
	for (int i = 0; i < 4; i++) {
		std::cin >> N[i];
	}

	a[0] = 1;
	a[1] = 7;
	a[2] = 9;
	a[3] = 4;

	for (int i = 0; i < 4; i++) {
		if (N[i] < 0 || N[i] > 9) {
			error = 1;
		}

	}

	if (error == 1) {
		//std::cout << "error" << std::endl;
	}
	else {
		for (int i = 0; i < 4; i++) {
			if (a[i] == N[0] || a[i] == N[1] || a[i] == N[2] || a[i] == N[3]) {
				a[i] = 0;
				continue;
			}
		}

		if (a[0] == 0 && a[1] == 0 && a[2] == 0 && a[2] == 0) {
			std::cout << "YES" << std::endl;
		}
		else {
			std::cout << "NO" << std::endl;
		}
	}




}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pii;

const int N = 1e5 + 10;
int n, x, m, tmp, ans, t;
int a, b, c;
string s, p;
map<string, int> pol;
vector<int> nei[N];
bool mark[N];


int main() 
{
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> a >> b >> c;
	if (b * c < a)
		cout << "No";
	else
		cout << "Yes";
	
	return 0;
}

Measured memory_bytes: 6000
n,a,b=map(int,input().split())
anssumsum=0
for i in range(n):
    num=i+1
    num10000=num//10000
    num1000=(num - num10000*10000)//1000
    num100=(num- num10000*10000-num1000*1000)//100
    num10=(num- num10000*10000-num1000*1000-num100*100)//10
    num1=num- num10000*10000-num1000*1000-num100*100-num10*10
    anssum=num10000+num1000+num100+num10+num1
    if (anssum>=a)&(anssum<=b):
        anssumsum=anssumsum+num
    #print(num1000,num100,num10,num1)
print(anssumsum)

Measured memory_bytes: 3064
def marubatu():
    N=list(input())
    for koma in ["o","x"]:
        for i in range(3):
            if N[i:9:3].count(koma)==3 or N[3*i:3*i+3].count(koma)==3:return koma
        if N[0:9:4].count(koma)==3 or N[2:7:2].count(koma)==3:return koma
    return "d"
while 1:
    try:print(marubatu())
    except:break


Measured memory_bytes: 5556
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    long long int N=0,K=1,a=0,b=0,ans;
    scanf("%lld %lld",&N,&K);
    a = N%K;
    b =abs(a-K);
    ans=min(a,b);
    printf("%lld\n",ans);


}

Measured memory_bytes: 256
// ¬ÊªêèÈÌÅAa{ p.205 Ìû@ÅàÓððÁÅ«é¯ÇA
// »¤·éÆ¬Ê 2+n Ìt[ð¬³È¢Æ¢¯È¢ÌÅ TLE(?)

#include<queue>
#include<cstdio>
#include<cstdlib>
#include<algorithm>

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

using namespace std;

const int CAPA_INF=1<<29;
const int COST_INF=1<<29;

template<class T,class U>
struct Edge{
	int v,rev;
	T capa;
	U cost;
	T flow;
};

template<class T,class U>
struct AdjList:public vector< vector< Edge<T,U> > >{
	AdjList(int n):vector< vector< Edge<T,U> > >(n){}
};

template<class T,class U>
void add_edge(AdjList<T,U> &adj,int u,int v,T capa,U cost){
	adj[u].push_back((Edge<T,U>){v,adj[v].size()  ,capa, cost});
	adj[v].push_back((Edge<T,U>){u,adj[u].size()-1,   0,-cost});
}

template<class T,class U>
pair<T,U> augment(AdjList<T,U> &adj,int s,int t,vector<U> &pot,bool first){
	int n=adj.size();
	static int pre[6006];
	static U d[6006];
	rep(u,n) d[u]=COST_INF; d[s]=0;

	// ÅÌêñÍÓª éÌÅ Dijkstra Å«È¢
	// K¢AÅÍOtª DAG ÈÌÅÅZpXª DP ÅÜé
	if(first){
		rep(u,n) rep(i,adj[u].size()) {
			Edge<T,U> &e=adj[u][i];
			U cost2=d[u]+e.cost;
			if(e.capa-e.flow>0 && cost2<d[e.v]){
				d[e.v]=cost2;
				pre[e.v]=e.rev;
			}
		}
	}
	// 2 ñÚÈ~
	else{
		bool ok=false;
		static bool vis[6006];
		rep(u,n) vis[u]=false;
		rep(_,n){
			int u=-1;
			rep(v,n) if(!vis[v] && (u==-1 || d[v]<d[u])) u=v;
			vis[u]=true;

			if(u==t) ok=true;

			rep(i,adj[u].size()){
				Edge<T,U> &e=adj[u][i];
				U cost2=d[u]+e.cost+pot[u]-pot[e.v];
				if(e.capa-e.flow>0 && cost2<d[e.v]){
					d[e.v]=cost2;
					pre[e.v]=e.rev;
				}
			}
		}

		if(!ok) return make_pair(0,0);
	}

	T water=CAPA_INF;
	for(int v=t;v!=s;){
		Edge<T,U> &e1=adj[v][pre[v]];
		Edge<T,U> &e2=adj[e1.v][e1.rev];
		water=min(water,e2.capa-e2.flow);
		v=e1.v;
	}

	U cost=0;
	for(int v=t;v!=s;){
		Edge<T,U> &e1=adj[v][pre[v]];
		Edge<T,U> &e2=adj[e1.v][e1.rev];
		e1.flow-=water;
		e2.flow+=water;
		cost+=water*e2.cost;
		v=e1.v;
	}

	rep(u,n) pot[u]+=d[u];

	return make_pair(water,cost);
}

template<class T,class U>
pair<T,U> primal_dual(AdjList<T,U> &adj,int s,int t){
	T ans1=0;
	U ans2=0;
	vector<U> pot(adj.size());
	rep(i,2){
		pair<T,U> tmp=augment(adj,s,t,pot,i==0);
		ans1+=tmp.first;
		ans2+=tmp.second;
	}
	return make_pair(ans1,ans2);
}

struct mogu{
	int x,t,p;
	bool operator<(const mogu &mg)const{ return t<mg.t; }
};

int main(){
	int n,v,xl,xr; scanf("%d%d%d%d",&n,&v,&xl,&xr);
	mogu mg[3002];
	rep(i,n) scanf("%d%d%d",&mg[i].x,&mg[i].t,&mg[i].p);
	mg[n++]=(mogu){xl,0,0}; // èÌúÊuÍRXg 0 Ìà®çÆl¦é
	mg[n++]=(mogu){xr,0,0};

	sort(mg,mg+n);

	AdjList<int,int> adj(2*n+2);

	int s=0,t=2*n+1; // \[X, VN
	// \[X©ç¼èÌúÊuÖÌÓ
	add_edge(adj,s,1,1,0);
	add_edge(adj,s,3,1,0);
	rep(i,n){
		add_edge(adj,2*i+2,t,1,0);

		// à®ç i ð@­
		add_edge(adj,2*i+1,2*i+2,1,-mg[i].p);

		// à®ç i ð@¢½ãà®ç j ð_¤
		rep(j,n) if(i!=j && abs(mg[i].x-mg[j].x)<=v*(mg[j].t-mg[i].t)) {
			add_edge(adj,2*i+2,2*j+1,1,0);
		}
	}

	printf("%d\n",-primal_dual(adj,s,t).second);

	return 0;
}

Measured memory_bytes: 209000
use std::cmp;
use std::io::{self, Read};

fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock());

    let a: u32 = sc.read().unwrap();
    let b: u32 = sc.read().unwrap();

    if a >= 13 {
        println!("{}", b);
    } else if a <= 5 {
        println!("{}", 0);
    } else {
        println!("{}", b / 2);
    }
}

struct Scanner<R: Read> {
    reader: R,
}

impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn read<T: std::str::FromStr>(&mut self) -> Option<T> {
        self.reader
            .by_ref()
            .bytes()
            .map(|b| b.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse()
            .ok()
    }

    fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Option<Vec<T>> {
        (0..n).map(|_| self.read()).collect()
    }

    fn read_vec2d<T: std::str::FromStr>(&mut self, m: usize, n: usize) -> Option<Vec<Vec<T>>> {
        (0..m).map(|_| self.read_vec(n)).collect()
    }
}


Measured memory_bytes: 4352
#include <iostream>

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

	int nw = 0, old = 2147483647;
	int counter = -1, max = -1;
	while (n--)
	{
		std::cin >> nw;

		if (nw <= old) counter++;
		else counter = 0;

		if (counter > max)max = counter;

		old = nw;
	}

	std::cout << max << std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, char *argv[]){
    unsigned long n,k,r;
    scanf("%lu %lu", &n,&k);
  
    if(n>k){
        r = n % k;
    }else{
        r = n;
    }

    if(r>k-r){
        printf("%lu",k-r);
    }else{
        printf("%lu",r);
    }
        


    return 0;
}

Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};



void solve(){
    string s;
    cin>>s;
    s[0]='2';
    s[1]='0';
    s[2]='1';
    s[3]='8';
    cout<<s<<endl;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    solve();

    return 0;
}


Measured memory_bytes: 256
n = int(input())
data = [0 for i in range(100)]
ans = 0
for now in range(1,n+1):
    s = int(str(now)[0])
    t = int(str(now)[-1])
    q = 10*t + s
    p = 10*s + t
    data[p] += 1
    ans += 2*data[q]
    if s == t:ans -= 1

print(ans)

Measured memory_bytes: 41964
#include <stdio.h>
#include <string.h>

int main(){
  int Ans=2000,m;
  char S[2000],T[2000];
  int LS,LT;
  scanf("%s\n%s",S,T);
  LS=strlen(S);
  LT=strlen(T);
  for(int i=0;i<=LS-LT;i++){
    m=0;
    for(int j=0;j<LT;j++){
      if(S[i+j]!=T[j]) m++;
    }
    if(m<Ans) Ans=m;
  }
  printf("%d\n",Ans);
  return 0;
}

Measured memory_bytes: 1740
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

const ll max_n=100005;
vi fac(max_n),finv(max_n),inv(max_n);
// テーブルを作る前処理 O(max_n)
void init(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  REP(i,2,max_n){
    fac[i]=fac[i-1]*i%mod;
    inv[i]=mod-inv[mod%i]*(mod/i)%mod;
    finv[i]=finv[i-1]*inv[i]%mod;
  }
}
// 二項係数計算 O(1)
ll 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;
}
//init(); を忘れない！
void solve(){
  init();
  ll n; cin>>n;
  out(fac[n]);
}

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


Measured memory_bytes: 2560
//Rating 1-399 : gray
//Rating 400-799 : brown
//Rating 800-1199 : green
//Rating 1200-1599 : cyan
//Rating 1600-1999 : blue
//Rating 2000-2399 : yellow
//Rating 2400-2799 : orange
//Rating 2800-3199 : red
#include<iostream>
#include<cstdio>
using namespace std;
int main() {
	int n;
	int a[105];
	scanf("%d",&n);
	for(int i=0; i<n; i++) {
		scanf("%d",&a[i]);
	}
	int cnt=0;
	for(int i=0; i<n; i++) {
		if(a[i]>=1&&a[i]<=399) {
			cnt+=1;
			break;
		}
	}
	for(int i=0; i<n; i++) {
		if(a[i]>=400&&a[i]<=799) {
			cnt+=1;
			break;
		}
	}
	for(int i=0; i<n; i++) {
		if(a[i]>=800&&a[i]<=1199) {
			cnt+=1;
			break;
		}
	}
	for(int i=0; i<n; i++) {
		if(a[i]>=1200&&a[i]<=1599) {
			cnt+=1;
			break;
		}
	}
	for(int i=0; i<n; i++) {
		if(a[i]>=1600&&a[i]<=1999) {
			cnt+=1;
			break;
		}
	}
	for(int i=0; i<n; i++) {
		if(a[i]>=2000&&a[i]<=2399) {
			cnt+=1;
			break;
		}
	}
	for(int i=0; i<n; i++) {
		if(a[i]>=2400&&a[i]<=2799) {
			cnt+=1;
			break;
		}
	}
	for(int i=0; i<n; i++) {
		if(a[i]>=2800&&a[i]<=3199) {
			cnt+=1;
			break;
		}
	}
	int ctt=0;
	for(int i=0; i<n; i++) {
		if(a[i]>=3200) {
			ctt+=1;
		}
	}
	if(cnt==0) {
		printf("1 ");
	} else {
		printf("%d ",cnt);
	}
	printf("%d",cnt+ctt);
	return 0;
}

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

using namespace std;

int main() {
	int r, d, x[11];
	cin >> r >> d >> x[0];
	for (int i = 1; i <= 10; i++) {
		x[i] = (r*x[i - 1]) - d;
		cout << x[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if((0 < c-a-b) && (4ll*a*b < (c-a-b)*(c-a-b))) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<set>
using namespace std;
int main(){
	int n;
	set<string> S;
	cin>>n;
	for(int i=0;i<n;i++){
		string s1,s2;
		cin>>s1>>s2;
		if(s1[0]=='i'){
			S.insert(s2);
		}
		else if(s1[0]=='f'){
			if(S.find(s2)!=S.end())cout<<"yes"<<endl;
			else cout<<"no"<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 32180
#include<stdio.h>
int main(){
  int n,i;
  int data[100];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&data[i]);
  }
  for(i=n-1;i>=0;i--){
    printf("%d",data[i]);
    if(i!=0)printf(" ");
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 2692
import sys
import math
from collections import deque
input = lambda: sys.stdin.readline().rstrip()
Yes = lambda boolean: print('Yes') if boolean else print('No')
YES = lambda boolean: print('YES') if boolean else print('NO')
aint = lambda: int(input())
ints = lambda: list(map(int, input().split()))
is_even = lambda x: True if x%2==0 else False

n = aint()
get = []
for i in range(n):
    s = input()
    get.append(s)
ss = set(get)
print(len(ss))

Measured memory_bytes: 36060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  rep(i,N){
    cout << S[i] << T[i];
  }
  cout << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <set>

using namespace std;

int f[101][101];
int chk[101][101];

int main(){
    int n;
    
    while(cin >> n && n){
        int x,y,ret=0,tmp;
        set<int> s;

        memset(chk, -1, sizeof(chk));

        for(int j=0;j<n;j++){
            for(int i=0;i<n;i++){
                cin >> x >> y;
                f[i][j] = x * 1000 + y;
            }
        }
        
        for(int j=0;j<n;j++){
            for(int i=0;i<n;i++){
                x = i;
                y = j;
                while(chk[x][y] == -1){
                    s.insert(x*1000+y);
                    chk[x][y] = f[x][y];
                    tmp = f[x][y];
                    x = tmp / 1000;
                    y = tmp % 1000;
                }
                if(s.find(x*1000+y) != s.end()){
                    ret++;
                }
                s.clear();
            }
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>

using namespace std;

int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    string s;
    unordered_map<string, int> map;
    for (int i = 0; i < n; i++)
    {
        cin >> s;
        sort(s.begin(), s.end());
        map[s]++;
    }
    long int ans = 0;
    for (auto it = map.begin(); it != map.end(); it++)
    {
        if (it->second > 1)
        {
            ans += (long int)it->second * (it->second - 1) / 2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 10660
h,k,w=map(int,input().split())
cc = 1
nn=1
r = ""
lr = ""
for _ in range(h):
    rrr = 0
    sss = input()
    if "#" in sss:
        lr = ""
        for c in sss:
            if c == "#":
                if rrr:
                    cc += 1
                else:
                    rrr = 1
            lr += " " + str(cc)
        r += (lr.strip() +"\n")*nn
        cc += 1
        nn=1
    else:
        if lr == "":
            nn += 1
        else:
            r += lr +"\n"
            nn=1
        continue
print(r.strip())


Measured memory_bytes: 118952
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5+10;
int sum[maxn];
int main(){
    int n,m;
    cin>>n>>m;
    for (int i=1;i<=m;i++){
        int l,r;
        cin>>l>>r;
        sum[l]++;
        sum[r+1]--;
    }
    int ans = 0;
    for (int i=1;i<=n;i++){
        sum[i] += sum[i-1];
        if (sum[i] == m) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

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

  int q;
  cin >> q;

  int t;
  bool reverse = false;

  deque<char> d;
  for(int i = 0; i < s.length(); ++i)
  {
    d.push_back(s[i]);
  }

  for(int i = 0; i < q; ++i)
  {
    cin >> t;
    if (t == 1)
    {
      reverse = !reverse;
    }
    else if (t == 2)
    {
      int f;
      char c;
      cin >> f >> c;
      if ((f - 1) == (int)reverse)
      {
        d.push_front(c);
      }
      else
      {
        d.push_back(c);
      }
    }
  }

  string ans = "";
  while(!d.empty())
  {
    ans += d.front();
    d.pop_front();
  }
  if (reverse)
  {
    std::reverse(ans.begin(), ans.end());
  }
  cout << ans;
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

int main() {
  int n;
  string s;
  bool flg = true;

  cin >> n >> s;

  if (n % 2 != 0) {
    flg = false;
  }
  else {
    for (int i = 0; i < n / 2; i++) {
      if (s.at(i) != s.at(i + n/2)) flg = false;
    }
  }
  if (flg) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
def resolve():
    N = int(input())
    A = input()
    B = input()
    C = input()
    ans = 0
    for i in range(N):
        if A[i] != B[i] != C[i] != A[i]:
            ans += 2
        elif A[i] == B[i] == C[i]:
            ans += 0
        else:
            ans += 1
    print(ans)
resolve()

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

void solve(){
    int n;
    cin>>n;
    int arr[n],u,v;
    for(int i=0;i<n;i++){
        cin>>u>>v;
        if(u==v) arr[i]=1;
        else arr[i]=0;
    }
    for(int i=0;i<n-2;i++){
        if(arr[i]==1 && arr[i+1]==1 && arr[i+2]==1){
            cout<<"Yes";
            return;
        }
    }
    cout<<"No";
}

int main(void){
    int t=1;//cin>>t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 3632
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
import math

#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入g
#
# インデックス系
# int min_y = max(0, i - 2), max_y = min(h - 1, i + 2);
# int min_x = max(0, j - 2), max_x = min(w - 1, j + 2);
#
#
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
#mod = 998244353
from sys import stdin
readline = stdin.readline
def readInts():
  return list(map(int,readline().split()))
def readTuples():
    return tuple(map(int,readline().split()))
def I():
  return int(readline())
s = input()
ans = 0
for bit in range(1 << len(s)-1):
    st = s[0]
    wa = 0
    for i in range(len(s)-1):
        if bit & (1 << i):
            wa += int(st)
            st = s[i+1]
        else:
            st += s[i+1]
    ans += wa + int(st)
print(ans)


Measured memory_bytes: 10348
#include<iostream>
  
  
using namespace std;
  
int cnt;
  
#define MAX 1000000
  
void insertionSort(int A[],int n,int g){
    int v,j;
    for(int i=g;i<n;i++){
        v=A[i];
        j=i-g;
        while(j>=0&&A[j]>v){
            A[j+g]=A[j];
            j=j-g;
            cnt++;
        }
        A[j+g]=v;
    }
}
  
void shellSort(int A[],int n){
    cnt=0;
    int G[MAX];
    int m=0;
    int h;
  
    for(h=1;h<n;h=3*h+1);
    h=(h-1)/3;
  
    while(h>1){
        G[m]=h;
        m++;
        h=(h-1)/3;
    }
    G[m]=1;
    m++;
  
    cout<<m<<endl;
    for(int i=0;i<m-1;i++){
        cout<<G[i]<<" ";
    }
    cout<<G[m-1]<<endl;
  
    for(int i=0;i<m;i++){
        insertionSort(A,n,G[i]);
    }
}
  
int main(){
 
    std::ios_base::sync_with_stdio(false);
 
    int n;
    int A[MAX];
  
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A[i];
    }
  
    shellSort(A,n);
    cout<<cnt<<endl;
  
    for(int i=0;i<n;i++){
        cout<<A[i]<<endl;
    }
  
    return 0;
}

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

using namespace std;

const int N = 1e6;

vector<int> e(N), o(N), x(N);

void complete(int n) {
  sort(e.rbegin(), e.rend());
  sort(o.rbegin(), o.rend());
  cout << min(n/2-o[1]+(n+1)/2-e[0], n/2-o[0]+(n+1)/2-e[1]) << endl;
}

int main(int argc, char *argv[])
{
  int n; cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
  }
  for (int i = 0; i < n; i++) {
    i % 2 == 0 ? e[x[i]]++ : o[x[i]]++;
  }
  int me = *max_element(e.begin(), e.end());
  int mo = *max_element(o.begin(), o.end());
  int fe = 0, fo = 0;
  for (int i = 0; i < N; ++i) {
    if (e[i] == me) {
      fe++;
    }
    if (o[i] == mo) {
      fo++;
    }
  }
  if (fe > 1 || fo > 1) {
    cout << (n / 2 - mo) + ((n+1)/2 - me) << endl;
  }
  else {
    for (int i = 0; i < N; ++i) {
      if (e[i] == me && o[i] == mo) {
        complete(n);
        return 0;
      }
    }
    cout << (n / 2 - mo) + ((n+1)/2 - me) << endl;
  }
  
  return 0;
}




Measured memory_bytes: 12032
#include <bits/stdc++.h>
 
#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(x) (ll) __builtin_popcount(x)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define mp make_pair  
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ller ios::sync_with_stdio(false);cin.tsie(nullptr);cout.tie(nullptr)
 #define watch(x) cout<<(#x)<<" is " <<x<<"\n"

#define PI 3.1415926535
using namespace std;
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;
const ll mod = 1e9 + 7;
const ll MAX = 1e5+7;
const ll inf = 1e18+1;


int main(){
 fastio;
 ll n;
 cin>>n;
 string s;
 cin>>s;
 bool go =true;
 if(n&1) {cout<<"No\n";return 0;}
 f(i,0,n/2){
    if(s[i]!=s[i+n/2]) go = false;
 }
 if(go) cout<<"Yes\n";
 else cout<<"No\n";
 return 0; 
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using lint = long long;
const lint mod = 1e9 + 7;
using P = pair<int,int>;


int main(){
    int N,K; cin >> N >> K;
    int p[N];
    rep(i,N) cin >> p[i];
    sort(p,p+N);
    int m = 0;
    rep(i,K){
        m += p[i];
    }
    cout << m << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<list>
#include<map>
#include<numeric>
#include<iomanip>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define ll long long

using namespace std;

/*小数点以下の長さを指定
cout << fixed << setprecision(15) << y << endl;
*/

//最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) {
		return a;
	}
	return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}


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

	vector<ll>h(n);
	rep(i, n)cin >> h[i];
	vector<bool>state(n, true);

	ll a, b;

	rep(i, m) {
		cin >> a >> b;
		if (h[a-1] < h[b-1]) {
			state[a - 1] = false;
		}
		else if (h[a - 1] > h[b - 1]) {
			state[b - 1] = false;
		}
		else if (h[a - 1] == h[b - 1]) {
			state[a - 1] = false;
			state[b - 1] = false;
		}
	}

	ll ans = 0;
	rep(i, state.size()) {
		if (state[i] == true)ans++;
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4052
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
#include<numeric>
#include<limits>
#include<iterator>
#include<iterator>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i,n) for(int i=0; i<n; i++)
#define INF (1<<20)

using namespace std;
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ll, char> plc;

queue<ll> q;

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

	rep(i, 1 << n) {
		ll a; cin >> a;
		q.push(a);
	}
	
	while(q.size() != 1){
		ll num1 = q.front(); q.pop();
		ll num2 = q.front(); q.pop();
		if (num1 > num2)q.push(num1 - num2);
		else if (num1 < num2)q.push(num2 - num1);
		else if (num1 == num2)q.push(num1);
	}
	cout << q.front() << endl;
	return 0;
}

Measured memory_bytes: 2432
N, Q = [int(i) for i in input().split()]
S = input()

t = [0] * (N+1)

for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)
    
for i in range(Q):
    l, r = [int(i) for i in input().split()]
    print(t[r-1] - t[l-1])

Measured memory_bytes: 7748
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

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

int main() {
    int A[3][3];
    rep(i, 3) rep(j, 3) cin >> A[i][j];

    int N;
    cin >> N;

    int B[N];
    rep(i, N) cin >> B[i];

    bool bingo[3][3];
    bool flg = false;


    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            bingo[i][j] = false;

            for (int k = 0; k < N; k++) {
                if (B[k] == A[i][j]) {
                    bingo[i][j] = true;
                    break;
                }
            }
        }
    }

    for (int i = 0; i < 3; i++) {
        if (bingo[i][0] + bingo[i][1] + bingo[i][2] == 3)
            flg = true;

        if (bingo[0][i] + bingo[1][i] + bingo[2][i] == 3)
            flg = true;
    }

    if (bingo[0][0] + bingo[1][1] + bingo[2][2] == 3)
        flg = true;

    if (bingo[2][0] + bingo[1][1] + bingo[0][2] == 3)
        flg = true;

    if (flg)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

   return 0;
}

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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> v(10);
  for(int i=0; i<10; ++i) v[i] = i;
  for(int i=0; i<k; ++i){
    int d;
    cin >> d;
    v.erase(lower_bound(v.begin(),v.end(),d));
  }
  queue<int> que;
  for(int i=0; i<10-k; ++i){
    if(v[i] == 0) continue;
    que.push(v[i]);
  }
  int ans;
  while(1){
    int x = que.front();
    if(x >= n){
      ans = x;
      break;
    }
    que.pop();
    for(int i=0; i<10-k; ++i) que.push(x*10+v[i]);
  }
  cout << ans << endl;
}

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

int main() {
  int W, a, b;
  scanf("%d %d %d", &W, &a, &b);

  if(a+W <= b){
    printf("%d\n", b-(a+W));
  } else if(b+W <= a){
    printf("%d\n", a-(b+W));
  } else{
    printf("0\n");
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define sd(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define pl(n) printf("%lld",n)
#define sf(n) scanf("%f",&n)
#define pf(n) printf("%.12f",n)
#define psp printf(" ")
#define endc printf("\n")

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;

const int maxn = 2e5 + 7; 
//const int md = 1e9 + 7;

bool pr[maxn];
bool ok[maxn];
int a[maxn];

int main() {
	IOS;	
	fill(pr, pr + maxn, true); pr[1] = false;
	    
	for (int i = 2; i < maxn; i++) {
	    if (!pr[i]) continue;
	    for (int j = i + i; j < maxn; j += i) {
	        pr[j] = false;
	    }
    }
	    
    for (int i = 1; i < maxn; i++) {
        if (i % 2 == 0) { ok[i] = false; continue; }
        ok[i] = pr[i] && (pr[(i + 1)/2]);	    
    }
    a[0] = 0;   
    for (int i = 1; i < maxn; i++) {
        a[i] = a[i - 1]; a[i] += ok[i];
    }   
    
    int q; cin>>q;
    while(q--) {
        int l, r; cin>>l>>r;
        cout<<(a[r] - a[l - 1])<<endl;
    }
}

Measured memory_bytes: 1920
/*
 * main.c
 *
 *  Created on: 2019/07/21
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

char S[200001] = {0};

int check_ptn(int i)
{
	int ptn = 0;
	if (S[i] == S[i+1]) {
		ptn = 2;
	} else {
		if (S[i+1] == S[i+2]) {
			ptn = 2;
		} else {
			ptn = 3;
		}
	}
	return ptn;
}


int main()
{
	int ans = 0;
	int len = 0, i = 0;
	scanf("%s", S);
	len = strlen(S);
	while(len != 0) {
		if (3 <= len) {
			if (S[i] != S[i+1]) {
				len -= 1;
				i += 1;
				ans += 1;
			} else {
				ans += check_ptn(i);
				len -= 3;
				i += 3;
			}
		} else if (len == 2) {
			if (S[i] == S[i+1]) {
				ans++;
			} else {
				ans += 2;
			}
			len -= 2;
		} else {
			ans++;
			len -= 1;
		}
	}
	printf("%d\n",ans);
    return 0;
}


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

int main() {
  ll a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  cout << (v > w && t * (v - w) >= abs(a - b) ? "YES" : "NO") << endl;
}


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


int main() {
    int a,b;
    cin>>a>>b;
    if(a==b)
        cout<<a+b;
    else{
        int mx=max(a,b);
        int k=(mx-1)+mx;
        cout<<k;
    }
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000007
using Graph = vector<vector<int>>;
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
vector<int> seen(200010);
void dfs(const Graph &G, int v ,int count) {
    seen[v] = count;
    for (int next_v : G[v]) { 
        if (seen[next_v]) continue;
        dfs(G, next_v ,count); // 再帰的に探索
    }
}

int main (){
  int N,M;
  cin>>N>>M;
  Graph friends(N);
  rep(i,M){
    int x,y,z=0;
    cin>>x>>y;
 /*   rep(j,friends[x-1].size()){
      if(friends[x-1][j]==y-1)z=1;
    }
    if(z==0){*/
    friends[x-1].push_back(y-1);
    friends[y-1].push_back(x-1);
    //}
  }
    int count = 1;
  //  seen.assign(N, 0);
    for (int v = 0; v < N; ++v) {
        if (seen[v]) continue; // v が探索済みだったらスルー
        dfs(friends, v ,count); // v が未探索なら v を始点とした DFS を行う
        ++count;
    }
  int ans=0;
  vector<int>aaa(count,0);
  rep(i,N){
    aaa[seen[i]]++;
  }
  rep(i,count){
    ans=max(ans,aaa[i]);
  }
  cout<<ans;
}


Measured memory_bytes: 24264
#include<cmath>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define fori(i,k,n) for(int i=k;i<n;i++)
using namespace std;
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
const int dX[8] = { 0, 1, 1, 1, 0, -1, -1, -1 }, dY[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };



int main()
{
	int n;
	cin >> n;
	while (n)
	{
		int a[25][25] = {};
		int x = 10, y = 10;

		for (int i = 0; i < n; i++)
		{
			int X, Y;
			cin >> X >> Y;
			a[X][Y] = 1;
		}
		int m;
		cin >> m;
		char v;
		int s;
		for (int i = 0; i < m; i++)
		{
			cin >> v >> s;
			switch (v)
			{
			case'N':
				for (int z = 0; z < s; z++)
				{
					y++;
					if (a[x][y] == 1)
					{
						a[x][y] = 0;
						n--;
					}
				}
				break;
			case'E':
				for (int z = 0; z < s; z++)
				{
					x++;
					if (a[x][y] == 1)
					{
						a[x][y] = 0;
						n--;
					}
				}
				break;
			case'S':
				for (int z = 0; z < s; z++)
				{
					y--;
					if (a[x][y] == 1)
					{
						a[x][y] = 0;
						n--;
					}
				}
				break;
			case'W':
				for (int z = 0; z < s; z++)
				{
					x--;
					if (a[x][y] == 1)
					{
						a[x][y] = 0;
						n--;
					}
				}
				break;
			}

		}




		if (n)cout << "No" << endl; else cout << "Yes" << endl;
		cin >> n;
	}


	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, m;
  cin >> n >> m;
  vl a(n), b(n), c(m), d(m);
  rep(i, n) cin >> a[i] >> b[i];
  rep(i, m) cin >> c[i] >> d[i];
  rep(i, n) {
    ll ans, mn = 1e18;
    rep(j, m) {
      ll now = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      if(mn <= now) continue;
      mn = now;
      ans = j + 1;
    }
    cout << ans << '\n';
  }
}

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

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

using namespace std;

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

 public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

using mint = modint<1000000007>;

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

  mint minimum = 0;
  mint maximum = 0;
  REP(i, K) {
    minimum += i;
    maximum += N - i;
  }

  mint ans = 0;
  for (int i = K; i <= N + 1; ++i) {
    ans += maximum - minimum + 1;
    minimum += i;
    maximum += N - i;
  }
  cout << ans.value() << endl;
}


Measured memory_bytes: 3576
def re(k1,l,s):
    r=0
    for i in range(0,n):
        if s==1:
            s=0
            k1+=l[i]
            if k1>=0:
                r+=k1+1
                k1=-1
            continue
        if s==0:
            s=1
            k1+=l[i]
            if k1<=0:
                r+=abs(k1)+1
                k1=1
    return r

n=int(input())
l=list(map(int,input().split()))
ans=0

k1=0

ans=min(re(k1,l,1),re(k1,l,0))



print(ans)

Measured memory_bytes: 14468
#include <stdio.h>
#include <stdlib.h>

int cmp(void *x, void *y)
{
        return *(int*)y - *(int*)x;
}

int main(void)
{
        int i;
        int heights[10];

        for (i = 0; i < 10; i++)
                scanf("%d", heights + i);

        qsort(heights, 10, sizeof(int), cmp);

        for (i = 0; i < 3; i++)
                printf("%d\n", heights[i]);

        return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
#define int long long 
const int mod=1e9+7;
int ans,a[21][21][5],m[21],n,res[21],b[21];
int check(){
	memset(b,-1,sizeof(b));
	for (int i=1;i<=n;i++){
		if (res[i]&&b[i]==0) return -1;
		if (res[i]==0&&b[i]==1) return -1;
		if (!res[i]) continue;
		for (int j=1;j<=m[i];j++) if (b[a[i][j][1]]!=-1&&b[a[i][j][1]]!=a[i][j][2]) return -1;else b[a[i][j][1]]=a[i][j][2];
	}
	for (int i=1;i<=n;i++){
		if (res[i]&&b[i]==0) return -1;
		if (res[i]==0&&b[i]==1) return -1;
	}
	int ans1=0;
	for (int i=1;i<=n;i++) ans1+=res[i];
	return ans1;
}
void dfs(int dep){
	if (dep>n){
		ans=max(ans,check());
		return ;
	}
	res[dep]=0;
	dfs(dep+1);
	res[dep]=1;
	dfs(dep+1);
}
signed main()
{
    cin>>n;
    for (int i=1;i<=n;i++){
    	cin>>m[i];
    	for (int j=1;j<=m[i];j++) cin>>a[i][j][1]>>a[i][j][2];
	}
	dfs(1);
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  ll n;
  cin >> n;
  vector<ll> v(5);
  rep(i, 0, 5) cin >> v[i];
  ll min_val = *min_element(v.begin(), v.end());
  cout << 5 + (n - 1) / min_val << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
using namespace std;



int main(){
	int n;
	cin>>n;
	vi v;
	pan(i,n){
		int a;
		cin>>a;
		if(a%2==0){
			v.pb(a);
		}
	}
	int flag=0;
	
	pan(i,v.size()){
		if(v[i]%3==0 || v[i]%5==0){
			flag++;
		}
	}
	if(flag==v.size()) cout<<"APPROVED";
	else cout<<"DENIED";
}

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

signed main() {
  int N;
  cin >> N;
  vector<int> P(N), Q(N);
  for (int i = 0; i < N; i++) {
    cin >> P[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> Q[i];
  }

  vector<int> v;
  for (int i = 1; i <= N; i++) {
    v.push_back(i);
  }

  int ans_p, ans_q;
  int cnt = 1;
  do {
    bool flag = true;
    for (int i = 0; i < N; i++) {
      if (v[i] != P[i]) {
        flag = false;
        break;
      }
    }

    if (flag) {
      ans_p = cnt;
      break;
    }
    cnt++;
  } while (std::next_permutation(v.begin(), v.end()));

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

  cnt = 1;
  do {
    bool flag = true;
    for (int i = 0; i < N; i++) {
      if (v[i] != Q[i]) {
        flag = false;
        break;
      }
    }

    if (flag) {
      ans_q = cnt;
      break;
    }
    cnt++;
  } while (std::next_permutation(v.begin(), v.end()));

  cout << abs(ans_p - ans_q) << endl;
  return 0;
}

Measured memory_bytes: 256
S = input()

def kaibun(x):
    N = len(x)
    flag = True
    for i in range(N // 2):
        if x[i] != x[-i - 1]:
            flag = False
    return flag

tmp1 = kaibun(S)
tmp2 = kaibun(S[:(len(S) - 1) // 2])
tmp3 = kaibun(S[(len(S) + 3) // 2 - 1:])


if tmp1 and tmp2 and tmp3:
    print('Yes')
else:
    print('No')


        


Measured memory_bytes: 9112
#include <bits/stdc++.h>
#define N 200005
#define ll long long
using namespace std;
ifstream in("in.txt");
ll f[N];
int main(){
    ll n, x, y;
    cin>>n>>x>>y;
    for(ll i=1; i<=n; ++i){
        for(ll j=i+1; j<=n; ++j){
            f[min(j-i, abs(y-j)+1+abs(x-i))]++;
        }
    }
    for(ll i=1; i<=n-1; ++i){
        cout<<f[i]<<"\n";
    }
    return 0;
}


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

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;

/*
    if you have any question about any part of my code,
    please don't shy to ask anytime :)
*/

void solve()
{
    ll n, m;
    cin >> n >> m;
    for (int i = 0, j = n; i <= n; i++, j--)
    {
        if (((i * 2) + (j * 4)) == m)
        {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
}

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

    // ll t;
    // cin >> t;

    // while (t--)
    // {
    //     solve();
    // }
    solve();
    return 0;
}

Measured memory_bytes: 3656
import bisect
N, K = map(int, input().split())
a=list(map(int, input().split()))
nlis=[0]*200001
s=0
for i in range(N):
    if nlis[a[i]]==0:
        s+=1
    nlis[a[i]]+=1
nlis.sort()
l=bisect.bisect_left(nlis, 1)

print(sum(nlis[l:l+s-K]))

Measured memory_bytes: 25860
first=input()
shuffle=[]
while first!="-":
    timse=int(input())
    order=[]
    cards=[]
    for i in range(timse):
        h=int(input())
        order.append(h)

    for j in first:
        cards.append(j)
    maisu=len(cards)
    
    for k in range(timse):
        offset=order[k]
        cards1=[cards[l] for l in range(offset)]
        cards2=[cards[l] for l in range(offset,maisu)]
        cards=cards2+cards1
    shuffle.append(cards)

    first=input()

for m in range(len(shuffle)):
    for n in range(len(shuffle[m])):
        print(str(shuffle[m][n]),end="")
    print()



Measured memory_bytes: 5624
N = int(input())
Cx = [[0, 0] for i in range(N)]
Cy = [[0, 0] for i in range(N)]
for i in range(N):
  x, y = map(int, input().split())
  Cx[i] = [x, i]
  Cy[i] = [y, i]
Cx.sort()
Cy.sort()
Qx = sorted([[Cx[i + 1][0] - Cx[i][0], Cx[i][1], Cx[i + 1][1]] for i in range(N - 1)])
Qy = sorted([[Cy[i + 1][0] - Cy[i][0], Cy[i][1], Cy[i + 1][1]] for i in range(N - 1)])
R = [i for i in range(N)]
def root(n):
  if R[n] == n:
    return n
  else:
    R[n] = root(R[n])
    return R[n]
cnt = 0
cost = 0
x = 0
y = 0
while cnt < N - 1:
  if Qx[x][0] <= Qy[y][0]:
    q = Qx[x]
    x += 1
  else:
    q = Qy[y]
    y += 1
  r1 = root(q[1])
  r2 = root(q[2])
  if r1 != r2:
    R[r2] = q[1]
    cost += q[0]
    cnt += 1
print(cost)

Measured memory_bytes: 66184
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

int digi(int n) {
    int res = 0;
    while(n/10>0) {
        res++;
        n /= 10;
    }
    if(n%10) res++;
    return res;
}

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

    int res = 1e10;
    for(int i=1; i*i<=N; i++) {
        if(N%i==0) res = min(res, max(digi(i), digi(N/i)));
    }

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

Measured memory_bytes: 256