akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){
  int i,n,m;
  scanf("%d",&n);
  n*=n*n;
  printf("%d.",n/27);
  n%=27;
  for(i=0;i<7;i++){
    n*=10;
    printf("%d",n/27);
    n%=27;
  }
  return(0);
}

Measured memory_bytes: 128
#include<bits/stdc++.h> 
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define int long long
#define swap(x,y) (x^=y^=x^=y)

#define debug1(a) cerr<<#a<<" = "<<(a)<<endl;
#define debug2(a,b) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define debug3(a,b,c) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
#define debug4(a,b,c,d) cerr<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<", "<<#d<<" = "<<(d)<<endl;

using namespace std;
 
#define mod 1000000007
long long modexpo(long long x, long long p){
    int res = 1;x = x%mod;
    while(p){
        if(p%2)res = res * x;
        p >>= 1;
        x = x*x % mod;
        res %= mod;
    }
    return res;
}

struct compare{
    bool operator() (const pair<int,int> a, const pair<int,int> b) const{
        return a.first < b.first;
    }
};

int32_t main(){
    IOS
    double d,t,s;
    cin >> d >> t >> s;
    double taken = d/s;
    if(taken <= t){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
} 

Measured memory_bytes: 3704
# https://atcoder.jp/contests/arc097/tasks/arc097_b
# Pについてp_xとp_yでuniteしていくと、スワップできる集合が獲得できる
# 1,2,3...i...Nにできるかだが, iについてp_iとiがスワップできるかはunion-findで探せばよい


import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


class UnionFind:
    def __init__(self, N):
        self.N = N  # ノード数
        # 親ノードをしめす。負は自身が親ということ。
        self.parent = [-1] * N  # idxが各ノードに対応。

    def root(self, A):
        # print(A)
        # ノード番号を受け取って一番上の親ノードの番号を帰す
        if (self.parent[A] < 0):
            return A
        self.parent[A] = self.root(self.parent[A])  # 経由したノードすべての親を上書き
        return self.parent[A]

    def size(self, A):
        # ノード番号を受け取って、そのノードが含まれている集合のサイズを返す。
        return -self.parent[self.root(A)]

    def unite(self, A, B):
        # ノード番号を2つ受け取って、そのノード同士をつなげる処理を行う。
        # 引数のノードを直接つなぐ代わりに、親同士を連結する処理にする。
        A = self.root(A)
        B = self.root(B)

        # すでにくっついている場合
        if (A == B):
            return False

        # 大きい方に小さい方をくっつけたほうが処理が軽いので大小比較
        if (self.size(A) < self.size(B)):
            A, B = B, A

        # くっつける
        self.parent[A] += self.parent[B]  # sizeの更新
        self.parent[B] = A  # self.rootが呼び出されればBにくっついてるノードもすべて親がAだと上書きされる

        return True

    def is_in_same(self, A, B):
        return self.root(A) == self.root(B)


# default import

N, M = read_ints()
P = [p - 1 for p in read_ints()]
uf = UnionFind(N)
for _ in range(M):
    x, y = read_ints()
    uf.unite(P[x - 1], P[y - 1])

ans = 0
for i in range(N):
    ans += uf.is_in_same(i, P[i])

print(ans)


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

int main(){
    char ca,cb;
    cin >> ca >> cb;
    int ia = (ca=='H') ? 1 : -1;
    int ib = (cb=='H') ? 1 : -1;
    if(ia*ib==1) cout << 'H' << endl;
    else cout << 'D' << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX
int main(){
    string s,t,u;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    cin>>u;
    if (s==u) cout<<a-1<<" "<<b<<endl;
    else cout<<a<<" "<<b-1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<string>
#include<bits/stdc++.h>
#include<algorithm>
#include<stdio.h>
#include<bits/stdc++.h>
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

using namespace std;

/*ll ma=998244353;
ll power(ll v,ll ti){
if(ti==1)
    return v;
ll x=power(v,ti/2);
x=(x*x)%ma;
if(ti%2==1)
    x=(x*v)%ma;
return x;

}
struct t{
int a,b;
};
vector<vector<t > >g;
vector<int> v;


ll n;


void dfs(int i,int sum){
v[i]=1;


for(int j=0;j<go[i].size();j++){
    int x=go[i][j].a;
    int y=go[i][j].b;
    if(v[x]==0){
        dfs(x,min(y,sum));

    }

}

}*/
int x[200001];
bool c(int i,int j){
return x[i]<x[j];
}

 int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n,q;
cin>>n>>q;
vector<int> m;
int s[n],t[n];
for(int i=0;i<n;i++){
    cin>>s[i]>>t[i]>>x[i];

    m.pb(i);


}
sort(m.begin(),m.end(),c);
set<int> si;
map<int,int> f;
for(int i=0;i<q;i++)
{
    int d;
    cin>>d;
    f[d]=i;
    si.insert(d);


}
vector<int> ans(q,-1);
for(int j=0;j<n;j++){
    if(si.size()==0)
    break;
        int i=m[j];
    set<int>::iterator it1,it2,it3;
    it3=it1=si.lower_bound(max(s[i]-x[i],0));
    it2=si.lower_bound(max(t[i]-x[i],0));
    for(;it1!=it2;it1++){
        ans[f[*it1]]=x[i];
    }
    si.erase(it3,it2);

}

  for(int i=0;i<q;i++)
        cout<<int(ans[i])<<endl;






}


Measured memory_bytes: 25588
#include <stdio.h>

int main(void) {
	int x,y;
	for(;;){
		scanf("%d %d",&x,&y);
	if((x==0)&&(y==0)){
		break;
	}else if(x>=y){
			printf("%d %d\n",y,x);
	}else if(x<y){
			printf("%d %d\n",x,y);
	}
	}
	return 0;
}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int x,y,z; cin >> x >> y >> z;

  int ans = 0;
  x-=z;
  do{
    ans++;
    x-=(y+z);
  }while(x>=y+z);
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <vector>
#include <cstring>
#include <queue>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
using namespace std;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
template<class T> inline bool chmax(T &a,T& b){if(a < b){a = b; return true;} else return false;}
template<class T> inline bool chmin(T &a,T& b){if(a > b){a = b; return true;} else return false;}
//function area
void dist(long double x1, long double y1, long double x2, long double y2){
    long double dx = x1 - x2, dy = y1 - y2;
    cout << fixed << setprecision(5) << sqrtl(dx*dx + dy*dy) << endl;
}
//main area
int main(){
    long double x1, x2, y1, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    dist(x1, y1, x2, y2);
}


Measured memory_bytes: 3308
a=int(input())
if a<2:
  print(1)
elif 2<=a<4:
  print(2)
elif 4<=a<8:
  print(4)
elif 8<=a<16:
  print(8)
elif 16<=a<32:
  print(16)
elif 32<=a<64:
  print(32)
elif 64<=a:
  print(64)

Measured memory_bytes: 3064
import math
import copy
temp=input().split()
H=int(temp[0])
W=int(temp[1])
K=int(temp[2])
A=[[i for i in input()] for j in range(H)]
place=[[K+2 for j in range(W)] for i in range(H)]
ans=0

si=0
sj=0
for i in range(H):
	for j in range(W):
		if A[i][j]=="S":
			si=i
			sj=j
			A[i][j]="."
			break
	else:
		continue
	break

now=[[si,sj]]
place[si][sj]=0
next=[]
for i in range(K):
	for room in now:
		if A[room[0]-1][room[1]]=="." and place[room[0]-1][room[1]]==K+2:
			place[room[0]-1][room[1]]=i
			next.append([room[0]-1,room[1]])
			if room[0]-1==0:
				ans=-1
		if A[room[0]+1][room[1]]=="." and place[room[0]+1][room[1]]==K+2:
			place[room[0]+1][room[1]]=i
			next.append([room[0]+1,room[1]])
			if room[0]+1==H-1:
				ans=-1
		if A[room[0]][room[1]-1]=="." and place[room[0]][room[1]-1]==K+2:
			place[room[0]][room[1]-1]=i
			next.append([room[0],room[1]-1])
			if room[1]-1==0:
				ans=-1
		if A[room[0]][room[1]+1]=="." and place[room[0]][room[1]+1]==K+2:
			place[room[0]][room[1]+1]=i
			next.append([room[0],room[1]+1])
			if room[1]+1==W-1:
				ans=-1
	if ans==-1:
		break
	now=copy.deepcopy(next)
	next=[]
		
little=H+W
goodi=-1
goodj=-1
for i in range(H):
	for j in range(W):
		if place[i][j]!=K+2:
			little=min(little,i,j,H-1-i,W-1-j)
			goodi=i
			goodj=j
print(math.ceil(little/K)+1)

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

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

  vector<int> ans(n+1);
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        int s = x*x + y*y + z*z + x*y + y*z + z*x;
        if (s > n) continue;
        ans[s]++;
      }
    }
  }

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

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

using namespace std;


int main()
{
	int n;
	cin >> n;
	long double p[n];
	for(int i=0;i<n;i++)
		cin >> p[i];

	long double dp[n+1][n+1];
	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1 - p[0];
	for(int i=1;i<n;i++)
		dp[0][i] = (1 - p[i])*dp[0][i-1];
	dp[1][0] = p[0];
	for(int i=1;i<n;i++)
	{
		for(int j=1;j<=i+1;j++)
		{
			dp[j][i] = dp[j][i-1]*(1.0 - p[i]) + dp[j-1][i-1]*p[i];
		}
	}
	long double ans = 0;
	for(int i=n/2 + 1;i<=n;i++)
		ans += dp[i][n-1];
	cout.precision(17);
	cout << fixed << ans << "\n";
	
	return 0;
}
	


Measured memory_bytes: 140928
#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int main()
{
    int a,b;
    scanf("%d%d",&a,&b);
    int ans=a*b-a-b+1;
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    int N,K;
    cin >> N >> K;
    if (K==1) cout << 0 << endl;
    else cout << N-K << endl;
}

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

int main()
{
	int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	if (c - e >= 0 && c + e <= a && d - e >= 0 && d + e <= b)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 1160
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

ll N, M, Q, ans = 0;
vl A;
vl a(Q), b(Q), c(Q), d(Q);

void dfs(vl now, ll n, ll m){
    ll tmp = 0;
    if(n == 0){
        rep(i, Q){
            if(now[b[i]]-now[a[i]] == c[i]){
                tmp += d[i];
            }
            ans = max(ans, tmp);
        }
        return;
    }
    FOR(i, now[now.size()-1], m){
        vl next = now;
        next.push_back(i);
        dfs(next, n-1, m);
    }
    
}

int main() {
    A.push_back(0);
    cin >> N >> M >> Q;
    a.resize(Q);
    b.resize(Q);
    c.resize(Q);
    d.resize(Q);
    rep(i, Q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }
    dfs(A, N, M);
    cout << ans;
}

Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cstring>
#define _for(i,a,b) for(int i = (a); i < b; i++)
#define _rep(i,a,b) for(int i = (a); i <= b; i++)
using namespace std;
const int N = 1e5 + 10;

int n;
int ans[N];

int main(){
	cin >> n;
	int a;
	_rep(i,1,n){
		cin >> a;
		ans[a] = i;
	}
	_rep(i,1,n-1){
		cout << ans[i] << " ";
	}
	cout << ans[n] << endl;
} 

Measured memory_bytes: 1152
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    double a;
    cin >> a;

    double resA,resB;
    resA = a * a * M_PI;
    resB = 2.0 * a * M_PI;

    cout << fixed << resA << " " << fixed << resB << endl;

    return 0;
}

Measured memory_bytes: 1288
#include <iostream>
#include <vector>
using namespace std;
struct po{
  int I,U,A,P,sum;
};
 
int main (){
  int n;
 
  while(1) {
  cin >> n;
  if (n == 0) break;
  vector <po> D;
  D.resize(n);
  for(int i=0;i<n;i++) cin >> D[i].I >> D[i].U >> D[i].A >> D[i].P;
 
  po t;
  for(int i=0;i<n;i++) {
    for(int j=n-1;j>i;j--){
      if(D[j].A > D[j-1].A){
    t = D[j];
    D[j] = D[j-1];
    D[j-1] = t;
      }
      if(D[j].A == D[j-1].A) {
    if(D[j].P < D[j-1].P) {
      t = D[j];
      D[j] = D[j-1];
      D[j-1] = t;
    }
    if(D[j].P == D[j-1].P && D[j].U <= D[j-1].U) {
      t  = D[j];
      D[j] = D[j-1];
      D[j-1] = t;
    }
      }
    }
  }
 
  int goukei = 0;
  int flg[1001] = {};
 
  for(int i=0;i<n;i++) {
    if(goukei < 10 && flg[D[i].U] < 3) {
      cout << D[i].I << endl;
      flg[D[i].U]++;
      goukei++;
    }
    else if(goukei < 20 && flg[D[i].U]< 2) {
      cout << D[i].I << endl;
      flg[D[i].U]++;
      goukei++;
    }
    else if(goukei < 26 && flg[D[i].U] == 0) {
      cout << D[i].I << endl;
      flg[D[i].U]++;
      goukei++;
    }
  }
 
  }
 
  return 0;

}

Measured memory_bytes: 1204
#include <iostream>
#include <string>

using namespace std;

int main(void) {
    string S, T;
    cin >> S >> T;
    int ans = 0;
    for(int i=0; i<S.size(); i++) {
        if(S[i] != T[i]) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3784
#include <bits/stdc++.h>
using namespace std;
string str[2];
int n,ima;


int stoi(int &i){
  int res=0;
  while('0'<=str[ima][i]&&str[ima][i]<='9')res=res*10+str[ima][i]-'0',i++;
  return res;
}


int main(){
  while(1){

    cin>>str[1]>>n;
    if(str[1]=="0"&&n==0)break;
    str[0].clear();
    for(int i=0;i<str[1].size();i++) {
      if(str[1][i]=='('&&str[1][i+2]==')') str[0]+=str[1][i+1],i+=2;
      else str[0]+=str[1][i];
    }
    str[1].clear();    

    ima=0;
    int f=1;
    int flg=1;
    while(f){
      f=0;
      str[!ima].clear();
      for(int i=0;i<(int)str[ima].size();i++){
	if(!('0'<=str[ima][i]&&str[ima][i]<='9')) str[!ima]+=str[ima][i];
	else {
	  f=1;
	  int num=stoi(i);
	  string pls;
	  if(str[ima][i]!='(') pls+=str[ima][i];
	  else {
	    int c=1;
	    while(c){
	      i++;
	      if(str[ima][i]=='(')c++;
	      if(str[ima][i]==')')c--;
	      if(c) pls+=str[ima][i];
	    }
	  }
	  while(num--&&(int)str[!ima].size()<=n) str[!ima]+=pls;
	}
      }
      
      ima=!ima;
    }
    //cout <<str[ima]<<endl;
    if((int)str[ima].size()<=n&&flg) cout <<0<<endl;
    else cout << str[ima][n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 4832
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int A,B;
cin >> A >> B;
vector<int> vec(3);
vec.at(0) = A+B;
vec.at(1) = A-B;
vec.at(2) = A*B;
sort(vec.begin(),vec.end());
cout << vec.at(2) << endl;



return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n = int(input())
w = [''] * n
for i in range(n):
    w[i] = input().rstrip('\n')
for i in range(1, n):
    if w[i - 1][-1] != w[i][0]:
        print('No')
        exit()
if len(set(w)) == len(w):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>

using namespace std;

int main()
{
    int a, b, c, d;
    cin>>a>>b>>c>>d;
    if (abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d)) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<int,int> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

string s;
int alp[26]={0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,0,0,0,0,1,0,0,0,1,0};

int main(){
	while(1){
		string s;
		cin>>s;
		if(s=="#")break;
		int cou=0;
		REP(i,s.size()-1){
			if(alp[s[i+1]-'a']!=alp[s[i]-'a'])
				cou++;
		}
		cout<<cou<<endl;
	}
	return 0;
}


Measured memory_bytes: 3048
#include <cstdio>
#include <iostream>
#include <string>
#include<vector>
using namespace std;
int main()
{
	int k,x;
	scanf("%d%d",&k,&x);
	int min_num,max_num;
	min_num = x-k+1;
	if(min_num<-1000000){
		min_num=-1000000;
	}
	max_num = x+k-1;
	if(max_num>1000000){
		max_num=1000000;
	}
	printf("%d",min_num);
	for(int i=min_num+1;i<=max_num;i++){
		printf(" %d",i);
	}

	return 0;
}


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

using namespace std;

int main(){
    int N;
    bool flag = true;
    string S;
    cin >> N;
    cin >> S;
    for(int i=0;i<N/2;i++){
        if(S[i]!=S[N/2+i]){
            flag = false;
        }
    }

    if(flag && N%2!=1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

int main() {
	int n,s;
	char o[6];
	int pos[6]={0,1,2,3,4,5};
	int n_o[6]={4,0,2,3,5,1};
	int e_o[6]={2,1,5,0,4,3};
	int w_o[6]={3,1,0,5,4,2};
	int s_o[6]={1,5,2,3,0,4};
	int r_o[6]={0,3,1,4,2,5};
	int l_o[6]={0,2,4,1,3,5};
	
	while(1){
		int pos[6]={0,1,2,3,4,5};
		s=1;
		cin >> n;
		if(n == 0){return 0;}
		for(int i=0;i<n;i++){
			cin >> o;
			switch( o[0] ){
				case 'N':
				for(int j=0;j<6;j++){
					pos[j]=n_o[pos[j]];
					if(pos[j]==0){s+=1+j;}
				}
				break;
				
				case 'E':
				for(int j=0;j<6;j++){
					pos[j]=e_o[pos[j]];
					if(pos[j]==0){s+=1+j;}
				}
				break;
				
				case 'W':
				for(int j=0;j<6;j++){
					pos[j]=w_o[pos[j]];
					if(pos[j]==0){s+=1+j;}
				}
				break;
				
				case 'S':
				for(int j=0;j<6;j++){
					pos[j]=s_o[pos[j]];
					if(pos[j]==0){s+=1+j;}
				}
				break;
				
				case 'R':
				for(int j=0;j<6;j++){
					pos[j]=r_o[pos[j]];
					if(pos[j]==0){s+=1+j;}
				}
				break;
				
				case 'L':
				for(int j=0;j<6;j++){
					pos[j]=l_o[pos[j]];
					if(pos[j]==0){s+=1+j;}
				}
				break;
			}
		}
		cout << s << endl;
	}
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;

int main(){
    int a,b;
    cin >> a >> b;
    for(int i= 1; i<= 3; i++){
        if(i != a && i!= b){
            cout << i << endl;
            return 0;
        }
    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b=1,c;
  cin>>a;
  for(int i=1;i<=a;i++){
  if(i%3==0){
    cout<<" "<<i;
    b=0;
  }
  if(i%10==3&&b==1){
    cout<<" "<<i;
  }
  else if(i%10!=3&&b==1){
    c=i;
    for(int j=0;j<c;){
    c/=10;
    if(c%10==3&&b==1){
      cout<<" "<<i;
      b=0;
    }
    }
  }
  b=1;
  }
  cout<<"\n";
  return(0);
}
  



Measured memory_bytes: 3104
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::input;
use proconio::marker::{Bytes, Chars};
use std::collections::*;

fn main() {
    input! {
        n:usize,
        mut txy:[(i32,(i32,i32));n],
    }
    txy.insert(0, (0, (0, 0)));
    let mut det = true;
    for i in 0..n {
        let start = txy[i].1;
        let goal = txy[i + 1].1;
        let d = dist(start, goal);
        let interval = txy[i + 1].0 - txy[i].0;
        if interval < d || (interval - d) % 2 != 0 {
            det = false;
        }
    }
    let ans = if det { "Yes" } else { "No" };
    println!("{}", ans);
}

fn dist(p: (i32, i32), q: (i32, i32)) -> i32 {
    (p.0 - q.0).abs() + (p.1 - q.1).abs()
}

Measured memory_bytes: 4600
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<int,int>;
using vv = vector<vector<ll> >;
template <class _t> inline bool chmax (_t& a,_t b){if(a<b){a=b;return true;}return false;} template <class _t> inline bool chmin (_t& a,_t b){if(a>b){a=b;return true;}return false;}

const int INF = 2147483647;
const int max_N = 1000000000;
const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int main(){
    ll x,k,d;cin >> x >> k >> d;
    ll ans = inf;
    if(abs(x)/d>=k){
        cout << abs(x)-k*d << endl;
        return 0;
    }
    if(abs(k-abs(x)/d)%2==0){
         cout << abs(x)%d << endl;
    }else{
        cout << abs(abs(x)%d-d) << endl;     
    }
        return 0;
    return 0;
}


Measured memory_bytes: 3636
/* 
 * File:   main.c
 * Author: s1252006
 *
 * Created on June 15, 2018, 11:02 AM
 */

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


int gcd(int a, int b) {
    int temp = 0;
    
    while (b != 0) {
        if (a > b) {
            temp = a;
            a = b;
            b = temp;
        }
        // here, a <= b
        b = b % a;
    }
    return a;
    
}

/*
 * 
 */
int main(int argc, char** argv) {
    int a,b;
    
    scanf("%d %d", &a, &b);
    
    printf("%d\n", gcd(a,b));
    
    return (EXIT_SUCCESS);
}




Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
typedef struct node
{
    int x,l;
    bool operator <(const node &t)const
    {
        return x<t.x;
    }
}node;
node a[N];
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    for(int i=0;i<n;i++) cin>>a[i].x>>a[i].l;
    sort(a,a+n);
    int ans=0;
    for(int i=1;i<n;i++){
        if(a[i-1].x+a[i-1].l>a[i].x-a[i].l){
            if(a[i-1].x+a[i-1].l<=a[i].x+a[i].l) a[i].x=a[i-1].x,a[i].l=a[i-1].l;
            ans++;
        }
    }
    cout<<n-ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
#define MOD 1000000007
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(int argc,char const* argv[])
{
  string s,t;
  string mak="";
  int cnt=0;
  int ans=1e9;
  cin >> s;
  if(int(s.size())==1)
    {
      cout << 0 << endl;
      return 0;
    }
  bool firstout=true;
  for(int i=0;i<s.size()-1;i++)
    {
      if(s[i]!=s[i+1]) firstout=false;
    }
  if(firstout)
    {
      cout << 0 << endl;
      return 0;
    }
  for(char i='a';i<='z';i++)
    {
      //cout << i << endl;
      cnt=0;
      t=s;
      while(1)
	{
	  mak="";
	  for(int j=0;j<int(t.size()-1);j++)
	    {
	      if(t[j]==i || t[j+1]==i)
		{
		  mak+=i;
		}
	      else
		{
		  mak+=t[j];
		}
	    }
	  cnt++;
	  //cout << t << ' ' << mak << endl;
	  t=mak;
	  if(int(mak.size())==1) break;
	  bool clear=true;
	  for(int j=0;j<mak.size()-1;j++)
	    {
	      if(mak[j]!=mak[j+1]) clear=false;
	    }
	  if(clear) break;
	}
      ans=min(ans,cnt);
    }
  cout << ans << endl;
 
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = a / 1000;
    int ans;
    if (a == b * 1000){
    	ans = b * 1000 - a; 
    } else {
    	ans = (b + 1) * 1000 - a; 
    }
    System.out.println(ans);  
      
    }

}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long a, long long b, long long c){
    long long right = c -a -b;
    if(right <0){
        cout << NO << endl;
        return;
    }
    long long right2digit = right * right;
    // cerr << right2digit << endl;
    if((4*a*b)<right2digit){
        cout << YES <<endl;
    }else{
        cout << NO << endl;
    }

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    solve(a, b, c);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n];
        for (int i = 0; i < w.length; i++) {
            w[i] = sc.nextInt();
        }
        int result = 0;
        for (int i = 0; i < w.length - 1; i++) {
            int s1 = 0, s2 = 0;
            for (int j = 0; j < w.length; j++) {
                if (j <= i) {
                    s1 += w[j];
                } else {
                    s2 += w[j];
                }
            }
            if (i == 0) {
                result = Math.abs(s1 - s2);
            } else {
                result = Math.min(result, Math.abs(s1 - s2));
            }
        }
        System.out.println(result); 
        sc.close();
    }
}

Measured memory_bytes: 22100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
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; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  int T;
  T = 1;
  while (T--) solve();
}

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


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int N,M;

int main() {
  cin>>N>>M;
  if(N>=M){cout<<0<<endl;return 0;}
  vector<int> Xs(M);
  for(int i=0;i<M;i++){cin>>Xs.at(i);}
  sort(Xs.begin(),Xs.end());
  vector<int> Ds(M-1);
  for(int i=0;i<M-1;i++){Ds.at(i)=Xs.at(i+1)-Xs.at(i);}
  sort(Ds.begin(),Ds.end());
  int steps=accumulate(Ds.begin(),Ds.end()-(N-1),0);
  cout<<steps<<endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

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

    while (in.hasNext()) {
      int N = in.nextInt();
      int K = in.nextInt() - 1;
      char[] S = in.next().toCharArray();

      S[K] = Character.toLowerCase(S[K]);

      System.out.println(S);
    }
  }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mp(x,y) make_pair(x,y)

void solve(){
    string s;
    cin>>s;
    if(s=="ABC") cout<<"ARC\n";
    else cout<<"ABC\n";
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int tc;
    tc=1;
    while(tc--){
        solve();
    }
return 0;
}


Measured memory_bytes: 3636
n, A, B = map(int, input().split())
s = input()
tuuka = 0
f_rank = 0
for i in range(n):
  if s[i] == 'a':
    if tuuka < A + B:
      tuuka += 1
      print('Yes')
    else:
      print('No')
  if s[i] == 'b':
    if tuuka < A + B and f_rank < B:
      tuuka += 1
      f_rank += 1
      print('Yes')
    else:
      print('No')
  if s[i] == 'c':
    print('No')

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    vll f(87);
    f[0] = 2;
    f[1] = 1;
    FOR(i,2,n){
        f[i]=f[i-1]+f[i-2];
    }
    cout<<f[n]<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    String[] s=new String[n];
    int count=0,c1=0,c2=0,c3=0;
    
    for(int i=0;i<n;i++){
      s[i]=sc.next();
      int len=s[i].length();
      
      for(int j=0;j<len-1;++j){
        if(s[i].charAt(j)=='A' && s[i].charAt(j+1)=='B') count++;
      }
      if(s[i].charAt(0)=='B' && s[i].charAt(len-1)=='A') c1++;
      if(s[i].charAt(0)=='B' && s[i].charAt(len-1)!='A') c2++;
      if(s[i].charAt(0)!='B' && s[i].charAt(len-1)=='A') c3++;
    }
    if(c1==0){
      count+=Math.min(c2,c3);
    }else{
        count+=(c2+c3==0)?c1-1:c1+Math.min(c2,c3);
    }
    System.out.print(count);
  }
}


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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;i++)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;i++)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

#define int ll

const int inf = 1ll<<62;
const int mod = 1e9+7;

main(){
  int h,w; cin >> h >> w;
  int ans = 0;
  rep(i, h) rep(i, w){
    char c; cin >> c;
    if(c == '#') ans++;
  }
  if(ans == h + w - 1) cout << "Possible\n";
  else cout << "Impossible\n";
}

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

int main() {
    int N, M, Ki, k;
    cin >> N >> M;
    int A[30][30] = {0};
    for (int i = 0; i < N; i++) {
        cin >> Ki;
        for (int j = 0; j < Ki; j++) {
            cin >> k;
            A[i][k - 1] = 1;
        }
    }
    int c = 0;
    bool all = true;
    for (int j = 0; j < M; j++) {
        all = true;
        for (int i = 0; i < N && all; i++) {
            all *= (A[i][j] == 1);
        }
        if (all) c++;
    }

    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

    int a, b, c;

    scanf("%d", &a); scanf("%d", &b); scanf("%d", &c);

    if (a <= b && b <= c) {
       printf("%d %d %d\n", a, b, c);
    } else if (a <= c && c <= b) {
       printf("%d %d %d\n", a, c, b);
    } else if (b <= a && a <= c) {
       printf("%d %d %d\n", b, a, c);
    } else if (b <= c && c <= a) {
       printf("%d %d %d\n", b, c, a);
    } else if (c <= a && a <= b) {
       printf("%d %d %d\n", c, a, b);
    } else {
       printf("%d %d %d\n", c, b, a);
    }

    return 0;

}



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

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

  for(int i=0; i<S.length(); i++) {
    if(S[i]+N>='A' && S[i]+N<='Z') {
      S[i] += N;
    } else {
      S[i] = S[i] - ('Z'-'A') + N - 1; 
    }

  }

  cout << S << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(a,b) for(int i=a;i<=b;i++)
#define FORBACK(a,b) for(int i=b;i>=a;i--)
#define pb push_back
#define mp make_pair
#define sz size
#define fi first
#define se second
typedef pair <int , int> ii;
int r,c,k,ans;
char arr[805][805];
vector<pair<int,int> >v;
bool visited[805][805];
struct State {
	int b, k, byk;
	
	State(){}
	State(int _b, int _k, int z){
		b = _b;
		k = _k;
		byk = z;
	}
};
State s;
queue<State> q;
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};
bool inside(int ro,int co){
	return 1<=ro && ro <=r && 1<=co && co<=c;
}
void bfs(int sr, int sc,int Byk){
	q.push(State(sr,sc,Byk));
	while(!q.empty()){
		State now = q.front();
		q.pop();
		int cb = now.b;
		int ck = now.k;
		int cbyk = now.byk;
		//cout << " :: " << b << " " << k << " " << byk << endl;
		if(cbyk<=k){
			v.pb(mp(cb,ck));
		}
		for(int i=0;i<4;i++){
			if(inside(cb + dx[i],ck + dy[i]) && arr[cb + dx[i]][ck + dy[i]]!='#' && visited[cb + dx[i]][ck + dy[i]]==false){
				visited[cb + dx[i]][ck + dy[i]]=true;
				q.push(State(cb + dx[i], ck + dy[i], cbyk + 1));							
			}			
		}
	}
}

int min3(int a , int b , int c) {
	return min(min(a , b) , c);
}

int min4(int a , int b , int c , int d) {
	return min(min3(a , b , c) , d);
}

int updiv(int a , int b) {
	int tmp = a / b;
	return tmp * b < a ? tmp + 1 : tmp;
}

int main(){
//	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>r>>c>>k;
	for(int i=1;i<=r;i++){
		for(int j=1;j<=c;j++){
			cin>>arr[i][j];
		}
	}
	for(int i=1;i<=r;i++){
		for(int j=1;j<=c;j++){
			if(arr[i][j]=='S'){
				bfs(i,j,0);
				break;
			}
		}
	}
	int sol = INT_MAX;
	for (ii vec : v) {
		int _r = vec.fi, _c = vec.se;
		sol = min(sol , min4(_c - 1 , c - _c , _r - 1 , r - _r));
	}
	printf("%d\n" , updiv(sol , k) + 1);
}

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

#define i64 long long
#define u64 unsigned long long
#define i32 int
#define u32 unsigned int

#define pii pair<int, int>
#define pll pair<long long, long long>

#define ld long double
#define defmod 1000000007

#define mati64(a,b) vector<vector<i64>>(a, vector<i64>(b, 0));
using namespace std;


int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);
	
	int n; cin >> n;
	vector<i64> a(n+2);
	for(int i = 1; i <= n; ++i)
		cin >> a[i];
	i64 ans = 0;
	for(int i = 1; i <= n; ++i){
		ans+=a[i]/2;
		//cout << "lis " << i << " kpl " << a[i]/2 << endl;
		a[i]-=(a[i]/2)*2;
		if(a[i] && a[i+1]){
			ans++;
			a[i+1]--;
			a[i]--;
			//cout << "lis " << i << " " << i+1 << " " << 1 << endl;
		}
	}
	cout << ans << endl;
	return 0;
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const ll INF = 1e18;
const int inf = 1e8;


void solve()
{
  ll X;
  scanf("%lld",&X);
  ll ans=1;
  for (ll i=2; i<=X; i++) {
    for (ll j=2; pow(i,j)<=X; j++) {
      ans = max(ans, (ll)pow(i,j));
    }
  }
  cout << ans << endl;
}

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


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

int main(){
  int n;
  int a[1000];
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  sort(a,a+n);
  cout << a[n-1]-a[0] << endl;

  return 0;
}

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

int prise(int water, int count){
	if(count==0) return water*125;
	if(count==1) return water*140;
	return water*160;
}

int main(){
	int prev=4280, water;
	while(cin >> water){
		if(water<0) break;
		int sum=1150, count=0;
		water-=10;
		while(water >= 0){
			if(water >= 10){
				sum += prise(10,count);
				count++;
			}
			else{
				sum += prise(water,count);
			}
			water-=10;
		}
		cout << prev - sum << endl;
	}
	return 0;
}

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

#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 1e9
int N;
vector<string> ans;

void solve(string s, int v){
  if(s.size() == N){
    ans.push_back(s);
    return;
  }
  REP(i, v+1){
    string a = string(1,'a'+i);
    if(i == v){
      solve(s+a, v+1);
    }
    else{
      solve(s+a, v);  
    }
  }
}
int main(){
  cin >> N;
  solve("a", 1);
  REP(i, ans.size()){
    cout << ans[i] << endl;
  }
  return 0;
}


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

int main() {
    long long N, K; cin >> N >> K;
    vector<long long>A(N);
    long long ans = 1000000007;
    for (long long i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    sort(A.begin(), A.end(), greater<long long>());
    for (long long i = 0; i <= N - K; i++) {
        ans = min(ans, A.at(i) - A.at(i + K - 1));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
N, M = map(int, input().split())
lst = sorted([int(x) for x in input().split()])
lst2 = []
for x in range(1, len(lst)):
    lst2.append(lst[x] - lst[x - 1])

lst2.sort()
if N >= M:
    print(0)
else:
    print(sum(lst2[:M-N]))


Measured memory_bytes: 13196
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int N,K;
  int x,y,m;
  cin>>N>>K;
  while(K-->0){
    cin>>x>>y;
    m=min(min(x-1,y-1),min(N-x,N-y));
    cout<<m%3+1<<endl;
  }
}

Measured memory_bytes: 0
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  int t, x;
  readf("%s %s\n", &t, &x);
  writefln("%.12f", t.to!double/x);
}


Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
    
    int N = sc.nextInt();
    int[] S = new int[N];
    int[] T = new int[N];
    
    for (int i = 0; i < N; i++){
      int tempX = sc.nextInt();
      int tempL = sc.nextInt();
      S[i] = tempX - tempL;
      T[i] = tempX + tempL;
    }
    
    quickSort(T,S);
    
    int ans = 1;
    int max = T[0];
    for(int i = 1; i < N; i++){      
      if (S[i] >= max){
        ans++;
        max = T[i];
      }
    }
    System.out.println(ans);
  }
                        
 public static void PartPartition(int S[],int p, int q,int T[]){  //pが左端要素番号、qが右端
      //pは大きい部分の最初の要素番号
      if (p >= q){
        return;     
      }else{ 
        int left = p; //xに左端を記憶
        int right = q;//yに右端を記憶
        for (int i = p; i < q+1; i++){
          int r = S[q]; //rは基準となる要素の値。今回は最後尾の数
          if (S[i] <= r){
            int temp = S[i];
            S[i] = S[p];
            S[p] = temp;
            temp = T[i];
            T[i] = T[p];
            T[p] = temp;            
            p++;
          }
        }
        PartPartition(S,left,p-2,T);
        PartPartition(S,p,right,T);                
    }  
  }
    public static void quickSort(int S[], int T[]){
      PartPartition(S,0,S.length-1,T);
    }

    
}


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

#define fi first
#define se second
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for (int i = a; i <= (b); i++)
#define ROF(i, a, b) for (int i = a; i >= (b); i--)

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

int main() {
    int n; cin >> n;
    int x = 0, y = 0;
    vi t(n + 1);
    FOR(i, 1, n) {
        int tx, ty; cin >> t[i] >> tx >> ty;
        int d = abs(x - tx) + abs(y - ty), dt = t[i] - t[i - 1];
        // cout << d << ' ' << dt << endl;
        if (d > dt || abs(dt - d) % 2 == 1)
            return cout << "No\n", 0;
        x = tx, y = ty;
        
    }
    cout << "Yes\n";
}


Measured memory_bytes: 3708
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from collections import Counter
def main():
    h, w = map(int, input().split())
    a = []
    for _ in range(h):
        a.extend(list(input()))
    a_ac = Counter(a)
    a_ac_v = list(a_ac.values())
    a_ac_v.sort(reverse=True)
    if h == 1 or w == 1:
        a_ac_v_parity_ac = Counter([i & 1 for i in a_ac_v])
        if h&1 == 1 and w&1 == 1:
            if a_ac_v_parity_ac[1] == 1:
                print('Yes')
            else:
                print('No')
            sys.exit()
        else:
            if a_ac_v_parity_ac[1] >= 1:
                print('No')
            else:
                print('Yes')
            sys.exit()

    num = []
    num.extend([4] * ((h // 2) * (w // 2)))

    if h&1:
        num.extend([2] * (w // 2))
    if w&1:
        num.extend([2] * (h // 2))
    if h&1 and w&1:
        num.extend([1])
    while sum(num):
        if a_ac_v[0] >= num[0]:
            a_ac_v[0] -= num[0]
            num[0] = 0
            a_ac_v.sort(reverse=True)
            num.sort(reverse=True)
        else:
            break
    if num[0] == 0 and a_ac_v[0] == 0:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 74396
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <math.h>
#include <iomanip>
 
using namespace std;
 
int main()
{
	int n, x, l[1001] = {},d=0,cnt = 0;
	cin >> n >> x;
	for (int i = 1; i <= n; i++) cin >> l[i];
	l[n+1] = 100001;
	while (d <= x) {
		d = d + l[cnt];
		cnt++;
	}
	cout << cnt-1 << endl;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	string s,t; cin>>s>>t;
	sort(s.begin(),s.end()),sort(t.rbegin(),t.rend());
	cout<<(s<t?"Yes"s:"No"s)<<"\n"s;
}


Measured memory_bytes: 3640
#include <cstdio>

using namespace std;

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  const int inf = 1'000'000'000;
  int ans = inf;
  for (int i = 0; i < n; ++i) {
    int c, t;
    scanf("%d %d", &c, &t);
    if (t <= m && c < ans) {
      ans = c;
    }
  }
  if (ans == inf) {
    puts("TLE");
  } else {
    printf("%d\n", ans);
  }
}


Measured memory_bytes: 128
ip=input().strip()
while((len)==0):
  ip=input().strip()
m,d=map(int,ip.split())
m1,d1=map(int,input().split())
odd=[1,3,5,7,8,10,12]
eve=[4,6,9,11]
if m in odd:
  if(d==31):
    print(1)
  else:
    print(0)
elif m in eve:
  if(d==30):
    print(1)
  else:
    print(0)
else:
  if(d==28):
    print(1)
  else:
    print(0)


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

using namespace std;

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

	int length = (int)s.length();
	for (int i = 0; i < length; i++)
	{
		// 偶数番目 = 奇数文字目に"R"があれば踏みにくい
		if (i % 2 == 0 && s[i] == 'L')
		{
			cout << "No";
			return 0;
		}

		// 奇数番目 = 偶数文字目に"L"があれば踏みにくい
		if (i % 2 == 1 && s[i] == 'R')
		{
			cout << "No";
			return 0;
		}
	}

	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

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

  int n; cin >> n;
  vi a(n);

  int g = 0;
  rep(i, n) {
    cin >> a[i];
    g ^= a[i];
  }

  rep(i, n) {
    if (i) cout << " ";
    cout << (g ^ a[i]);
  }

  cout << endl;

  return (0);
}


Measured memory_bytes: 3972
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
typedef long long ll;
using namespace std;

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int x, y;
    cin >> x >> y;
    cout << (x ^ y) << endl;
    return 0;
}


Measured memory_bytes: 256
from operator import add
from collections import deque
from itertools import accumulate

N,K = map(int,input().split())
S = input()

if N == 1:
  if S == "1" or K >= 1:
    print(1)
  else:
    print(0)
    
else:
  num = []
  cnt = 1
  ans = 0
  M = 2 * K + 1

  for i in range(1,N):
    if S[i] == S[i - 1]:
      cnt += 1
    else:
      num.append(cnt)
      cnt = 1
  num.append(cnt)

  if S[0] == "0":
    num = [0] + num
  
  acc = list(accumulate(num,add))
  acc = [0] + acc
  A = len(acc)
  
  for left in range(0,A,2):
    right = min(A - 1,left + M)
    ans = max((acc[right] - acc[left]),ans)
    
  print(ans)



Measured memory_bytes: 9632