akhauriyash/Code-Regression huggingface dataset:
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


x, a, b = map(int, input().split())
if abs(x-a)>abs(x-b):
    print("B")
else:
    print("A")

Measured memory_bytes: 2940
import sys
input = sys.stdin.buffer.readline

N = int(input())
a = list(map(int, input().split()))

# dp[i][j] 区間a[i,j)だけ残った時点で互いの点数を一旦0とし、ゲームを最後まで続けた場合のX-Yの値
dp = [[0]*(N+1) for _ in range(N+1)] # 初期値を対角成分だけ0、その他をfloat("inf")にすると1000ms程度遅くなる

# こちらもメモ化再帰ではpypy3でも間に合わない
# j==i+1, i+2, ...とループしてdpテーブルの上三角部分を対角線と平行に埋めていく。jをshift_iと書き換えてループ
for shift_i in range(1, N+1):
    for i in range(N+1):
        if i+shift_i >= N+1:
            continue
        elif ((i+shift_i)-i)%2 == N%2: # 先手番
            dp[i][(i+shift_i)] = max(a[i] + dp[i+1][(i+shift_i)], a[(i+shift_i)-1] + dp[i][(i+shift_i)-1])
        else:
            dp[i][(i+shift_i)] = min(-a[i] + dp[i+1][(i+shift_i)], -a[(i+shift_i)-1] + dp[i][(i+shift_i)-1])

print(dp[0][N])

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 998244353;
const int maxn = 400;
const int maxa = 300*300 + 400;

int n;
int a[maxn];

ll dp1[maxn][maxa];
ll dp2[maxn][maxa];

void push(ll &x, ll y) {
    x %= mod;
    y %= mod;
    x += y;
    x %= mod;
}

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

    int s = 0;

    cin>>n;
    for (int i=0; i<n; i++) {
	cin>>a[i];
	s += a[i];
    }



    // dp1[][j]: # of ways to have j of color R (2 options, B or G, for times we don't paint ith elem as R).
    // dp2[][j]: # of ways to paint elems such that sum=j for color R.

    // for cases of the form (R,G,B)=(s/2,s/2,0) we over count when bad is multipled by 3.
    // The multiple of 3 is a cyclic remapping of (R,G,B) -> (B,R,G)

    // [BBRR] -> [RRGG] -> GGBB -> ..
    

    dp1[0][0] = dp2[0][0] = 1;

    ll all = 1;

    for (int i=0; i<n; i++) {
	all *= 3ll; all %= mod;
	for (int j=0; j<=s; j++) {
	    push(dp1[i+1][j], 2ll*dp1[i][j]);
	    push(dp1[i+1][j+a[i]], dp1[i][j]);

	    push(dp2[i+1][j], dp2[i][j]);
	    push(dp2[i+1][j+a[i]], dp2[i][j]);
	}
    }


    ll res = all;
    ll bad = 0;
    for (int j=(s+1)/2; j<=s; j++) {
	bad += dp1[n][j];
	bad %= mod;
    }
    ll dup = (s%2 == 0 ? dp2[n][s/2] : 0);

    // watch(res);
    // watch(bad);
    // watch(dup);

    res -= (3ll*bad%mod);
    res %= mod;
    res += (3ll*dup%mod);
    res %= mod;


    res %= mod;
    res += mod;
    res %= mod;
    cout<<res<<endl;
    
    return 0;
}


Measured memory_bytes: 427412
#include <cstdio>
#include <string>
#include <unordered_set>

int main() {
  int n;
  std::unordered_set<std::string> dic = {};
  scanf("%d", &n);
  while (n-- > 0) {
    char cbuf[10], sbuf[20];
    scanf("%s %s", cbuf, sbuf);
    std::string command = cbuf, str = sbuf;
    if (command == "insert") {
      dic.insert(str);
    } else {
      auto fi = dic.find(str);
      if (fi == dic.end()) {
        printf("no\n");
      } else {
        printf("yes\n");
      }
    }
  }
  return 0;
}



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

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

  vector<pair<int, int>> v(n);
  for (auto &i : v) cin >> i.first >> i.second;

  sort(v.rbegin(), v.rend());

  cout << v[0].first + v[0].second << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main() {
   string s;
  cin>>s;
  int sum=0;
  for(int i=0;i<s.size();i++) {
      sum+=(s[i]-48);
  }
  if(sum%9==0)
    cout<<"Yes";
  else 
    cout<<"No";
}

Measured memory_bytes: 3724
import sys
input = sys.stdin.readline
from collections import *

def judge(x):
    d = defaultdict(int)
    q = deque([])
    
    for i in range(x):
        q.append(S[i])
        
    d[''.join(q)] = 0
    
    for i in range(x, N):
        q.append(S[i])
        q.popleft()
        k = ''.join(q)
        
        if k in d:
            if i-x+1-d[k]>=x:
                return True
        else:
            d[k] = i-x+1
    
    return False

def binary_search():
    l, r = 0, N
    
    while l<=r:
        m = (l+r)//2
        
        if judge(m):
            l = m+1
        else:
            r = m-1
    
    return r

N = int(input())
S = input()[:-1]
print(binary_search())

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

using namespace std;

typedef long long ll;

int main(){
  int N; cin >> N; vector<long long > A(N); 
  for(int i = 0; i < N; i++){ cin >> A[i];}
                                 
  sort(A.begin(),A.end());
  
  ll ans = 0;
  
  if( N % 2 ){
    // when N is a odd number 
   for(int p = 0; p <= 1; p++){
     if( p ){ reverse(A.begin(),A.end());} ll res = 0;
             
    vector<long long> B(N);
             
    B[ ( N -1 )/ 2 ] = A[N-1];
    for(int i = 1; i <= ( N - 1) / 2 ; i++){
      if( i % 2){ B[ ( N - 1) / 2  + i] = A[ i-1];}
      else{ B[ ( N  - 1) / 2 + i ] = A[ N - i];}}
    
    for(int j = 1; j <= ( N - 1) / 2; j++){
      if(j % 2){ B[( N - 1) / 2 - j] = A[j];}
      else{ B[ (N - 1)/ 2 - j] = A[N - j - 1];}} 
    
    for(int i = 0; i < N - 1; i++){ res += abs( B[i+1] - B[i]);}
    ans = max( ans, res);}
   }// if closed
  
  else{
     // when N is a even number 
   for(int p = 0; p <= 1; p++){
     if( p ){ reverse(A.begin(),A.end());} ll res = 0;
             
    vector<long long> B(N);
             
    B[ (N / 2) - 1 ] = A[N-1];
    for(int i = 0; i <= N / 2 - 1 ; i++){
      if( i % 2){ B[ N / 2  + i] = A[ N - i- 1];}
      else{ B[ N / 2 + i ] = A[i];}}
    
    for(int j = 2; j <=  N / 2; j++){
      if(j % 2){ B[ N / 2 - j] = A[ N - j];}
      else{ B[ N/ 2 - j] = A[j - 1];}} 
    
    for(int i = 0; i < N - 1; i++){ res += abs( B[i+1] - B[i]);}
    ans = max( ans, res);}
   }// else closed
  
    
    
    
    
    
              
      cout << ans << endl; return 0;}
              
       
        

Measured memory_bytes: 1792
// 2020-07-25 21:12:26
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  ll n;
  cin >> n;
  vector<ll> a(n+1);
  rep(i, n) cin >> a[i];
  a[n] = 0;
  ll m = 1000, s = 0;
  rep(i, n) {
    if(a[i] < a[i+1]) {
      ll d = m / a[i];
      m -= a[i] * d;
      s += d;
    } else if(a[i] > a[i+1]) {
      ll d = s * a[i];
      m += d;
      s = 0;
    }
  }
  cout << m << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <map> 
#include<set>
#include<queue>

typedef long long ll;


#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h, w, n,k,m; string s,t;
char maze[60][60];
int dis[101][101]; int graph[50][50]; bool vis[50];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);

}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
int main() {
	cin >> n;
	int res = 0;
	int bcnt = 0; int acnt = 0; int abcnt = 0;
	rep(i, n) {
		string str;
		cin >> str;
		rep(j, str.size()-1) {
			if (str[j] == 'A') {
				if (str[j + 1] == 'B') {
					res++;
				}
			}
		}
		bool flg = true;
		if (str[0] == 'B') {
			bcnt++; flg = false;
		}
		int f = str.size() - 1;
		if (str[f] == 'A') {
			acnt++;
			if (!flg) {
				abcnt++; bcnt--; acnt--;
			}
		}
	}
	if (0 == abcnt) {
		res += min(bcnt, acnt);
	}
	else if(abcnt!=0&&bcnt+acnt>0){
		res +=abcnt+ min(bcnt, acnt);
	}
	else if (bcnt + acnt == 0) {
		res += abcnt - 1;
	}
	cout << res << endl;
}

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

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF (LLONG_MAX - 1e5)
#define fcout cout << fixed << setprecision(10)

using namespace std;

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

    int n;
    cin >> n;
    if (n == 0) {
        cout << "0" << endl;
        return 0;
    }

    string s;

    while (n != 0) {
        if (n % 2 == 0) {
            s += "0";
        } else {
            n--;
            s += "1";
        }

        n /= -2;
    }
    reverse(s.begin(), s.end());
    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 1000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int a,b,c,k;
   cin>>a>>b>>c>>k;
   int ans=0;
   ans+=min(a,k);
   k-=min(a,k);
   if(k>0)
   k-=min(b,k);
   if(k>0)
    ans-=min(c,k);
   cout<<ans<<endl;


}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

using ll = long long;
using ull = unsigned long long;
using namespace std;

int main(){
    string s; cin >> s;
    int n = s.length();
    vector<int> data(n); rep(i,n) data[(n-1)-i] = s[i] - '0';

    ll ans = 0;
    rep(i,1<<(n-1)){
        vector<int> data2(n-1); rep(j,n-1) data2[j] = (i & 1<<j);
        ll sum = data[0]; int count = 1;
        rep(j,n-1){
            if(data2[j] == 0){
                sum += data[j+1]*pow(10,count);
                count++;
            }
            else{
                sum += data[j+1];
                count = 1;
            }
        }
        ans += sum;
    }
    cout << ans << endl;
}



Measured memory_bytes: 4016
#include <iostream>
#include <bits/stdc++.h>
#define endl '\n'
#define MAXN 1000010
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define ALL(x)  x.begin(), x.end()
using namespace std;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, n1, t; cin >> n >> t;
    vi start, ended;
    vii intervals;
    n1 = n;
    while (n1--){
        int l, r; cin >> l >> r;
        intervals.emplace_back(l, r);
        start.push_back(l);
        ended.push_back(r);
    }
    sort(ALL(start));
    sort(ALL(ended));
    int max = -MAXN;
    for (int i = 0; i < t; ++i) {
        auto it = upper_bound(ALL(ended), i);
        auto it1 = upper_bound(ALL(start),i);
        int cant = it - ended.begin();
        int cant1 = it1 - start.begin();
        cant1 = n - cant1;
        int sum =  n - cant - cant1;
        if(sum > max) {
            max = sum;
        }
    }
    cout << max << endl;
    return 0;
}



Measured memory_bytes: 4796
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{   
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    string ret = a+b>c+d ? "Left" :
                    a+b<c+d ? "Right" : "Balanced";
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using ll = int64_t;
using ld = double;
using ull = uint64_t;
using namespace std;
using namespace __gnu_pbds;     

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20);
    int n;
    cin >> n;
    int p = -1;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        if (x == p) {
            ++ans;
            p = -1;
        } else {
            p = x;
        }
    }

    cout << ans << "\n";
}

Measured memory_bytes: 256
#include<iostream>
using namespace std ;
int main()
{
    int n;
    cin>>n;

    int sum=0;
  if(n%1000==0)
  {
      cout<<sum; }



  else{
    for(int i=1000 ; ; i=i+1000)
    {
        if(n<i)
        {
            sum=i-n;
            break;
        }
    }

    cout<<sum;
}
}


Measured memory_bytes: 3632
import sys
import math


input = sys.stdin.readline


def main():
    ac = (A*math.sin((H*60+M)*math.pi/360.0), A*math.cos((H*60+M)*math.pi/360.0))
    bc = (B*math.sin(M*math.pi/30.0), B*math.cos(M*math.pi/30.0))
    print(((ac[0]-bc[0])**2 + (ac[1]-bc[1])**2)**0.5)


if __name__ == "__main__":
    A, B, H, M = map(int, input().split())
    main()


Measured memory_bytes: 9524
var
	n,b,i:int64;
    a:Array[1..200000] of int64;
begin
	read(n);
    for i:=1 to n do begin
    	read(a[i]);
    end;
    for i:=1 to n do begin
        b:=b xor a[i];
    end;
    for i:=1 to n do begin
    	writeln(b xor a[i]);
    end;
end.

Measured memory_bytes: 3884
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[200];
	for(int i=0;i<n;i++) cin>>a[i];
	int ans=0;
	while(1){
		int flag=1;
		for(int i=0;i<n;i++){
			if(a[i]%2==1){
				flag=0;
				break;
			}
			else a[i]/=2;
		}
		if(flag==0) break;
		ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
using namespace std;

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

    return 0;
}


Measured memory_bytes: 888
n=int(input())
#a,b=map(int,input().split())
al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

ans=0

for i in range(n):
    ans+=1.0/al[i]

ans=1.0/ans

print('{:.9f}'.format(ans))

Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	while (1) {
		int n, a, b, c, x;
		cin >> n >> a >> b >> c >> x;
		if (n == 0) return 0;
		vi y(n);
		int ans = 0;
		rep(i, 0, n) {
			cin >> y[i];
			while (y[i] != x) {
				x = (a*x + b) % c;
				ans++;
				if (ans > 10000) break;
			}
			if (i + 1 != n) {
				x = (a*x + b) % c;
				ans++;
			}
		}
		if (ans > 10000) cout << -1 << endl;
		else cout << ans << endl;
	}
}



Measured memory_bytes: 2980
#include<iostream>
using namespace std;
  
int main(){
    int a[5][4][11],n;
  
    for(int i=1;i<=4;i++)
    for(int j=1;j<=3;j++)
    for(int k=1;k<=10;k++)a[i][j][k]=0;
    cin>>n;
    for(int i=0;i<n;i++){
        int b,f,r,v;
        cin>>b>>f>>r>>v;
        a[b][f][r]+=v;
    }
  
    for(int f=1;f<=4;f++){
        if(f>1)cout<<"####################\n";
        for(int b=1;b<=3;b++){
            for(int r=1;r<=10;r++){
                cout<<" "<<a[f][b][r];
        }
        cout<<endl;
    }
}
  
    return 0;
}


Measured memory_bytes: 3116
import sys
input=sys.stdin.readline
N,M,L=map(int,input().split())

def warshall_floyd(d):
  #d[i][j]: iからjへの最短距離
  for k in range(size_v):
    for i in range(size_v):
      for j in range(size_v):
        d[i][j]=min(d[i][j],d[i][k]+d[k][j])
  return d

# vlistに点のリスト、dist[vi][vj]に辺(vi,vj)のコストを入れて呼び出す
size_v=N+1
dist=[[float("inf")]*size_v for i in range(size_v)]
for _ in range(M):
  A,B,C=map(int,input().split())
  dist[A][B]=C
  dist[B][A]=C
for i in range(size_v):
  dist[i][i]=0 #自身のところに行くコストは0

dist=warshall_floyd(dist)
#print(dist)

dist2=[[float("inf")]*size_v for i in range(size_v)]
for i in range(size_v):
  for j in range(size_v):
    if dist[i][j]<=L:
      dist2[i][j]=1
for i in range(size_v):
  dist2[i][i]=0 #自身のところに行くコストは0

dist2=warshall_floyd(dist2)
#print(dist2)

Q=int(input())
for _ in range(Q):
  s,t=map(int,input().split())
  answer=dist2[s][t]-1
  if answer==float("inf"):
    print(-1)
  else:
    print(answer)

Measured memory_bytes: 124508
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Sagor
 */

#include <fstream>
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <iomanip>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

#define gap                  ' '
#define P_INF                1e10+17
#define N_INF               -1e10+17
#define mod                  1000000007
#define EPS                  0.000000001
#define pi                   2*acos(0.0)
#define fi(i, n)             for(int i=0; i<n; i++)
#define fj(j, n)             for(int j=0; j<n; j++)
#define rfk(k, n)            for(int k=n-1; k>=0; k--)
#define unique(a)            a.resize(unique(a.begin(), a.end()) - a.begin())

typedef double ld;
typedef long long int ll;
typedef unsigned long long int ul;
using namespace std;

class Poor {
public:
    void solve(std::istream &in, std::ostream &out) {
        int a, b, c;
        in >> a >> b >> c;
        if (a == b && a != c)
            out << "Yes" << endl;
        else if (b == c && b != a)
            out << "Yes" << endl;
        else if (c == a && c != b)
            out << "Yes" << endl;
        else
            out << "No" << endl;

    }
};


int main() {
     std::ios_base::sync_with_stdio(0);
     std::cin.tie(nullptr);
     Poor solver;
     std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
     return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;

int main(){
    int L;cin>>L;
    double x=L/3.0;
    double ans=pow(x,3);
    printf("%lf\n",ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
#define se second
#define fr first
#define int  long long int
#define pb push_back
#define inf 1e18
#define slld(x) scanf("%lld",&x)
#define plld(x) printf("%lld\n",x)
#define all(v) v.begin(),v.end()
#define CHAL_BAAP_KO_MT_SIKHA ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define MOD 998244353
#define endl "\n" 
/*
    Damn Fast:TheFuckinMastermind
    while(How to solve the Question?){
                Read the Question Again!!
           }
        do
            Practise
    #Motivation::::0/0  
*/
const int N=5e5;
vector<int> seg[4*N+1];
int a[N+1],ans[N+1];
vector<int> merge(vector<int> v1,vector<int> v2){
    int i=0,j=0;
    vector<int> v;
    while(i<v1.size() and j<v2.size()){
        if(v1[i]<v2[j]){
            v.pb(v1[i]);
            i++;
        }
        else{
            v.pb(v2[j]);
            j++;
        }
    }
    while(i<v1.size()){
        v.pb(v1[i]);
        i++;
    }
    while(j<v2.size()){
        v.pb(v2[j]);
        j++;
    }
    return v;
}
void build(int l,int r,int idx){
    if(l==r){
        seg[idx].pb(ans[l]);
        return;
    }
    int mid=(l+r)/2;
    build(l,mid,2*idx+1);
    build(mid+1,r,2*idx+2);
    seg[idx]=merge(seg[2*idx+1],seg[2*idx+2]);
}
int qury(int l,int r,int ll,int rr,int idx){
    if(l>rr or r<ll)
        return 0;
    if(ll<=l and rr>=r){
        return (lower_bound(seg[idx].begin(),seg[idx].end(),ll)-seg[idx].begin());
    }
    int mid=(l+r)/2;
    return qury(l,mid,ll,rr,2*idx+1)+qury(mid+1,r,ll,rr,2*idx+2);
}
signed main()
{
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin); 
    // freopen("out.txt","w",stdout);
    // #endif  
    CHAL_BAAP_KO_MT_SIKHA
    int n,k;
    cin>>n>>k;
    int a[n+1];
    int mx=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        mx=max(mx,a[i]);
    }
    int l=1,r=mx;
    int ans;
    while(l<=r){
        int mid=(l+r)/2;
        int count=0;
        for(int i=1;i<=n;i++){
            if(a[i]>mid){
                count+=ceil(1.0*a[i]/mid)-1;
            }
        }
        if(count<=k){
            ans=mid;
            r=mid-1;
        }
        else
            l=mid+1;
    }
    cout<<ans<<endl;
}

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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	ll n,D;cin>>n>>D;
	int ans=0;
	rep(i,n){
		ll X,Y;cin>>X>>Y;
		if(X*X+Y*Y<=D*D)ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3640
def main():
    s = input()
    for i in range(1, len(s)):
        r = s[:-i]
        q = len(s[:-i])
        if q % 2 != 0:
            continue
        if r[:q//2] == r[q//2:]:
            ans = q
            break
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
struct point{int x;int y;};
int i,j,k,count1=0,count2=0;

int main(){
    string s,t="keyence";
    cin>>s;
    int ans=0,first;
    for(i=0;i<s.length();i++){
        if(s[i]!=t[i]){
            cerr<<i<<endl;
            break;
        }
    }
    cout<<(s.substr(s.length()-7+i,7-i)==t.substr(i,7-i)?"YES":"NO")<<endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = Integer.parseInt(sc.next());
			Long[] a = new Long[n];
			Long[] b = new Long[n];
			Long[] c = new Long[n];
			for (int i = 0; i < n; i++) {
				a[i] = Long.parseLong(sc.next());
			}
			for (int i = 0; i < n; i++) {
				b[i] = Long.parseLong(sc.next());
			}
			for (int i = 0; i < n; i++) {
				c[i] = Long.parseLong(sc.next());
			}
			Arrays.sort(a);
			Arrays.sort(b);
			Arrays.sort(c);
			long ans = 0;
			for (Long e : b) {
				long u = Arrays.binarySearch(a, e, (x, y) -> x.compareTo(y) >= 0 ? 1 : -1);
				long l = Arrays.binarySearch(c, e, (x, y) -> x.compareTo(y) > 0 ? 1 : -1);
				ans += (~u) * (n - ~l);
			}
			System.out.print(ans);
		}
	}
}

Measured memory_bytes: 69912
procedure quickly_sort(var a:array of longint;l,r:longint);inline;
var i,j,x,y:longint;
begin
  while true do
  begin
    if r<l+74 then
      exit;
    i:=l;j:=r;
    x:=a[(l+r)>>1];
    repeat
      while a[i]>x do inc(i);
      while x<a[j] do dec(j);
      if not(i>j) then
      begin
        y:=a[i];a[i]:=a[j];
        a[j]:=y;inc(i);dec(j);
      end;
    until i>j;
    if l<j then quickly_sort(a,l,j);
    if not(i<r) then
      exit;
    l:=i;
  end;
end;
procedure sort(var a:array of longint;l,r:longint);inline;
var i,j,t:longint;
begin
  if r>l then
  begin
    quickly_sort(a,l,r);
    i:=l;
    for i:=l to r do
    begin
      j:=i; 
      while j>pred(l) do
        if a[j]>a[pred(j)] then
        begin
          t:=a[pred(j)];a[pred(j)]:=a[j];a[j]:=t;
          dec(j);
        end
        else
          break;
    end;
  end;
end;
var a:array[0..100]of longint;
    g,n,i:longint;
begin
  readln(n);
  for i:=1 to n do
    read(a[i]);
  sort(a,2,n+1);
  for i:=1 to n do
    if i mod 2=1 then
      inc(g,a[i])
    else
      dec(g,a[i]);
  writeln(g);
end.

Measured memory_bytes: 128
import math
N = int(input())

dic = dict() #素因数分解してつっこむリスト
def trial_division(n):
    tmp = int(math.sqrt(n)) + 1
    a = n
    for num in range(2, tmp):
        while n%num == 0: #割り切れる時
            if not num in dic:
                dic[num] = 1
            else:
                dic[num] += 1
            n //= num
    if n != 1:
        if not n in dic:
            dic[n] = 1
        else:
            dic[n] += 1

    return dic

# trial_division(5)
for i in range(2, N+1):
    trial_division(i)
    # print (i, dic)
    
# print (dic)
count = 0
for i in dic:
    if dic[i] >= 74:
        count += 1
    if dic[i] >= 24:
        for j in dic:
            if i != j and dic[j] >= 2:
                count += 1
    if dic[i] >= 14:
        for j in dic:
            if i != j and dic[j] >= 4:
                count += 1
    if dic[i] >= 4:
        for j in dic:
            if i < j and dic[j] >= 4:
                for k in dic:
                    if i != k and j != k and dic[k] >= 2:
                        count += 1

print (count)
                         
        


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

int main() {
  vector<int> costs = {2, 5, 5, 4, 5, 6, 3, 7, 6};
  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for (auto& e : a) {
    cin >> e;
  }
  vector<string> dp(n + 7, ".");
  dp[0] = "";
  for (int i = 0; i < n; i++) {
    if (dp[i] == ".") {
      continue;
    }
    string s = dp[i];
    for (auto e : a) {
      s.push_back('0' + e);
      const string& t = dp[i + costs[e - 1]];
      if (s.size() > t.size() || s.size() == t.size() && s > t) {
        dp[i + costs[e - 1]] = s;
      }
      s.pop_back();
    }
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 51712
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef vector<int> vec;
int main(){
  int n,k; cin>>n>>k;
  long double ans=0,memo=0;
  
  for(int i=1;i<n+1;i++){
    long double memo=1.0/n;
    int x=i;
    while(x<k){
      x*=2;
      memo/=2;
    }
    ans+=memo;
  }

  cout<<fixed<<setprecision(12);
  cout<<ans<<endl;
}

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

int main(){
  long long N, A;
  cin >>N;
  int count;
  int ans;
  for (int i=0;i<N ;i++){
    cin >>A;
    count=0;
    for (int j=0;;j++){
        if (A%2==0){
            count++;
            A/=2;
        }
        else{
            break;
        }
    }
    if (i==0){
        ans=count;
    }
    else{
        if (count<ans){
            ans =count;
        }
    }
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int N = 31;

int main() {
  bool d[N];
  memset(d, false, sizeof(d));
  REP(i, 28){
    int n; cin >>n;
    d[n] = true;
  }
  FOR(i, 1, N) if(!d[i]) cout <<i <<endl;
  return 0;
}

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

using namespace std;

int N;
long long int W;
long long int w[105];
long long int v[105];

long long int b[105][105][330];

int main(void) {

	cin >> N >> W;

	long long int  tmp;
	for (int i = 1; i <= N; i++) {
		cin >> tmp; w[i] = tmp;
		cin >> tmp; v[i] = tmp;
	}

	for (int i = 0; i <= N; i++) {
		for (int K = 0; K <= N; K++) {
			for (int m = 0; m <= 300; m++) {
				b[i][K][m] = -1000000000000;
			}
		}
	}

	b[0][0][0] = 0;

	for (int i = 0; i <= N - 1; i++) {
		for (int K = 0; K <= i; K++) {
			for (int m = 0; m <= 300; m++) {
				b[i + 1][K][m] = max(b[i + 1][K][m], b[i][K][m]);
				if (K*w[1] + m + w[i + 1] <= W) { b[i + 1][K + 1][m + w[i + 1] - w[1]] = max(b[i + 1][K + 1][m + w[i + 1] - w[1]], b[i][K][m] + v[i + 1]); }
			}
		}
	}

	long long int ans = 0;

	for (int K = 1; K <= N; K++) {
		for (int m = 0; m <= 300; m++) {
			ans = max(ans, b[N][K][m]);
		}
	}

	/*int i = 2;
	for (int K = 0; K <= i; K++) {
		for (int m = 0; m <= 2; m++) {
			cout << "b[" << i << "][" << K << "][" << m << "]= " << b[i][K][m] << endl;
		}
	}*/

	cout << ans << endl;

	//system("pause");
	return 0;
}

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

int main() {
  int N,x; cin >> N >> x;
  int sum = 0;
  int res = 0;
  vector<int> vec(N);
  for(int i=0; i < N; ++i) {
    cin >> vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  
  for(int i=0; i < N; ++i) {
    res++;
    sum += vec.at(i);
    if(sum > x) {
      res--;
      break;
    }
    if(i == N-1 && sum != x) res--;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#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 rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
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() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    vec a(5);
    for(int i=0; i<5; i++) cin>>a[i];
    auto b=a;
    auto c=a;
    int mn=9,cnt=0;
    rep(i,5){
        a[i] = a[i]%10;
        if(a[i]==0) cnt++;
    }
    rep(i,5){
        if(a[i]%10!=0)b[i] += (10 - a[i]);
        if(min(mn,a[i]) != 0) mn=min(mn,a[i]);
    }

    int sum=0;
    rep(i,5) sum +=b[i];
    if(cnt==5){
        sum=sum;
    }else{
        sum = sum - 10 + mn;

    }
    cout<<sum<<endl; 
}

Measured memory_bytes: 3620
//BISMILLAHIR-RAH-MANIR-RAHIM.
//ABU AYUB MD AHMADUL(CEO-PEREGRINE SPHERE).
//FORMER CEO-SPACEH(2019).
//DEPT.OF CSE,SUST//2018-19.
//------------------------------------------\\
//PRE-CODE========>
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#include<vector>
#include<math.h>
#include<stack>
#include<queue>
#include<string>
#include<algorithm>
#include<map>
#define mp make_pair
#define ins insert
#define lli long long int
#define ll long long
#define pb push_back
#define loop1(i,l,n) for(i=l;i<=n;i++)
#define loop0(i,l,n) for(i=l;i<n;i++)
#define inf (1<<28)
set<int>ist;
map<string,int>msi;
map<string,string>mss;
map<int,string>mis;
map<int,int>mii;
vector<int>v;
vector<pair<int,int> >vv;
//------------------------------------------\\
//LAUNCHING FALCON-20========>
void LIFT_OFF_FALCON_JA20()
{
    int n,m,i,j,k,ans;
    cin>>n;
    int ahm[n]={};
    int dp[n+2]={};
    for(i=0;i<n;i++)
    {
        cin>>ahm[i];

    }
    dp[0]=ahm[0];
    dp[1]=abs(ahm[0]-ahm[1]);
    dp[2]=abs(ahm[0]-ahm[2]);
    for(i=1;i<n;i++)
    {
        dp[i+1]=min(dp[i+1],(abs(ahm[i]-ahm[i+1])+dp[i]));
        //dp[i+2]=min(abs(dp[i]-ahm[i+2]),(abs(dp[i+1]-ahm[i+2])));
        //dp[i+2]=min((dp[i+1]+abs(dp[i+1]-ahm[i+2])),(dp[i]+abs(dp[i]-ahm[i+2])));
        dp[i+2]=min((dp[i]+abs(ahm[i]-ahm[i+2])),(dp[i+1]+abs(ahm[i+1]-ahm[i+2])));
    }

    ans=dp[n-1];
    cout<<ans<<endl;

}
//MAIN FUNCTION========>
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    LIFT_OFF_FALCON_JA20();

    return 0;
}

//------------------------------------------\\
//ABOUT THE SERIES========>
//THE PEREGRINE FALCON SERIES-(JANUARY-2020).
//SPONSERED BY FASTEX AND SPAIT(CEO-SP).
//CONTROLLER=>NASRULLAH SAMI(CEO-FALCON AXIS).
//CO-CHIEF ADVISOR=>G.M NAYEEM(CEO-TECH FRIGATE).
//PRESIDENT=>NAIMUL ISLAM(CEO-QUANTAM SPACE).






Measured memory_bytes: 1024
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
    long long N;
    cin >> N;
    long long sum = 0, i = 1;
    while(i <= N){
        if(i % 3 == 0 || i % 5 == 0){
            i++;
            continue;
        }
        sum += i;
        i++;
    }
    cout << sum << endl;
    return 0;
}

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

int main() {
  
  string s;
  cin >> s;
  
  if ( s[2] == s[3] && s[4] == s[5] ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
  
}



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

#define ll long long int

int main()
{
    double n;
    cin>>n;
    double m=100,rt=0.01;
    ll ans=0;
    while(1)
    {
        if(m>=n)
            break;
        else
        {
            m=m+(m*rt);
            m=floor(m);
            ans=ans+1;
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  Int n,k;
  cin>>n>>k;
  vector< vector<Int> > v(k);
  for(Int i=0;i<k;i++){
    v[i].resize(n/2);
    for(Int j=0;j<n/2;j++) cin>>v[i][j],v[i][j]--;
  }

  auto check=[&](string s){
    for(Int i=0;i<k;i++){
      Int tmp=0;
      for(Int j=0;j<n/2;j++)
	tmp+=(s[v[i][j]]=='1');
      //cout<<i<<":"<<tmp<<endl;
      if(tmp<n/8||tmp>3*n/8) return 0;
    }
    return 1;
  };
  
  srand((unsigned)time(NULL));
  while(1){
    string s;
    for(Int i=0;i<n;i++)
      s.push_back(char('0'+(rand()%2)));
    if(check(s)){
      cout<<s<<endl;
      return 0;
    }
  }
  return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  for (int i = 0; i < N; ++i)
    cin >> H[i];
  sort(H.begin(), H.end(), greater<int>());
  long long ans = 0;
  for (int i = 0; i < N; ++i)
    if (K != 0)
      --K;
    else
      ans += H[i];
  cout << ans << endl;
}

Measured memory_bytes: 1024
# coding: utf-8
#便利そうなので置いとく
import fractions 
import functools 
#再帰関数を使うときは、再帰上限を上げておこうね！
import sys
sys.setrecursionlimit(200000000)
# my functions here!
def pin(type=int):
    return map(type,input().split())
"""
------------------------------------------------------------------
|OBJECTIVE:                                                      |
|Educatinal DP contest("https://atcoder.jp/contests/dp")を解こう!|
------------------------------------------------------------------
"""
#solution:
INF = float("inf")
"""
|#遷移式を考える
|   つまり、漸化式みたいに i回目までの結果を保存して、i+1回目の評価を行う
"""
def Flog_1(N,H):
    dp=[INF for i in range(N)]#{DP table}:最小化問題なので初期値はINF, h1=H[0]）
    dp[0]=0  #h1=0
    dp[1]=abs(H[1]-H[0])#ほら、"2段前"がないから…
    for i in range(2,N):
        hop1=dp[i-1]+abs(H[i-1]-H[i]) 
        hop2=dp[i-2]+abs(H[i-2]-H[i]) 
        #print(hop1,hop2)
        dp[i]=hop1 if hop1<hop2 else hop2
    return dp
def Flog_1_Another(N,H):#"配る"DP
    dp=[INF for i in range(N)]#{DP table}:最小化問題なので初期値はINF, h1=H[0]）
    dp[0]=0  #h1=0
    for i in range(1,N-1):
        pass
    
def Flog_2(N,K,H):
    dp=[INF for i in range(N)]#{DP table}:最小化問題なので初期値はINF, h1=H[0]）
    """
    |# Flog1との違い:飛ぶ段数に（1個か2個という）制限がない
    |    
    """
    dp[0]=0  #h1=0,default position
    for i in range(1,N):#k段前から飛んでくることを考えよ
        temp = INF
        for k in range(1,K+1):
            if i-k < 0:break
            else:
                #print("*",i-k)
                temp = min(temp,(dp[i-k]+abs(H[i-k]-H[i])))
                
        dp[i]=temp
        #print("*",dp)
    return dp
#input
N,K=pin()
H =list(pin())

#output
print(Flog_2(N,K,H)[-1])

Measured memory_bytes: 84188
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
ca=dict(Counter(a))
a.sort()
ans=0
for i in range(n):
  x=a[-1-i]
  tmp=pow(2,len(bin(x))-2)-x
  if x==tmp:
    if ca[x]>=2:
      ca[x]-=2
      ans+=1
  elif ca[x] and tmp in ca and ca[tmp]>0:
    ans+=1
    ca[tmp]-=1
    ca[x]-=1

print(ans)

Measured memory_bytes: 160704
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		char[] ch = scanner.next().toCharArray();
		int w = scanner.nextInt();
		for(int i = 0; i < ch.length; i+=w) {
			System.out.print(ch[i]);
		}
		System.out.println("");
	}

}

Measured memory_bytes: 21716
#include <iostream>

using namespace std;

int main()
{
  string str;
  cin >> str;
  int len = str.length();
  bool flag = true;
  
  for(int i=0; i<len; i++) {
    for(int j=i+1; j<len; j++) {
      if (str[i] == str[j]) {
	flag = false;
      }
    }
  }

  if(flag == true) {
    cout << "yes" << endl;
  } else {
    cout << "no" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}
template<class T> void contout(const T &v){for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n"))cout<<*it;}

const long long MOD = 1000000007;
void solve(){
  ll n,k; cin>>n>>k;
  vector<ll> A(n);
  rep(i,n) cin>>A[i];
  vector<ll> dp(k+1,0);
  dp[k]=1;
  rep(i,n){
    vector<ll> ndp(k+1,0);
    // dp の累積和を先に取っておく
    vector<ll> S(k+2,0);
    rep(j,k+1){
      S[j+1]=S[j]+dp[j];
      S[j+1]%=MOD;
    }
    // iterate
    rep(j,k+1){
      ndp[j]=S[min(j+A[i]+1,k+1)]-S[j];
      ndp[j]%=MOD;
    }
    dp=ndp;
  }
  cout<<(dp[0]+MOD)%MOD<<"\n";
}




Measured memory_bytes: 2664
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
using namespace std;

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

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

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

int n;
string w[100];

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

  cin >> w[0];
  char last = w[0][w[0].length()-1];
  FOR(i, 1, n) {
    cin >> w[i];
    if(last != w[i][0]) {
      cout << "No" << endl;
      return 0;
    }
    FOR(j, 0, i) {
      if(w[j] == w[i]) {
        cout << "No" << endl;
        return 0;
      }
    }
    last = w[i][w[i].length()-1];
  }

  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

VVL G;

ll dfs(ll from, ll now){
    ll sz;
    if(from == -1) sz = G[now].size();
    else sz = G[now].size() - 1;
    map<ll,ll> rec;
    for(auto e : G[now]){
        if(e == from) continue;
        ll ret = dfs(now, e) + 1;
        rec[ret]++;
    }
    ll mx = 0;
    for(auto r : rec){
        if(mx < r.first){
            mx = r.first + r.second - 1;
        }else{
            mx += r.second;
        }
    }
    return max(sz, mx);
}

int main(){
    ll N;
    cin >> N;
    G.resize(N+1);
    rep(i, 2, N+1){
        ll a;
        cin >> a;
        G[i].push_back(a);
        G[a].push_back(i);
    }
    cout << dfs(-1, 1) << endl;
    return 0;
}

Measured memory_bytes: 19712
import copy
n = int(input())
c = [list(map(int, input().split())) for i in range(n-1)]
for i in range(n):
    t = 0
    for j in range(i, n-1):
        if t < c[j][1]:
            t = c[j][1]
        elif t%c[j][2] == 0:
            pass
        else:
            t += c[j][2] - t%c[j][2]
        t += c[j][0]
    print(t)

Measured memory_bytes: 42348
#include <bits/stdc++.h>
using namespace std;
int main(){
	string str;
	cin>>str;
	int q,t,f;
	cin>>q;
	int cnt=0;
	while(q--){
		cin>>t;
		if(t==1)cnt++;
		if(t==2){
			char c;
			cin>>f>>c;
			if(f==1&&cnt%2==0||f==2&&cnt%2!=0)str.insert(str.begin(),c);
			if(f==2&&cnt%2==0||f==1&&cnt%2!=0)str.insert(str.end(),c);
		}
	}
	if(cnt%2!=0)reverse(str.begin(),str.end());
	cout<<str<<endl;
}

Measured memory_bytes: 900
#include<stdio.h>
#define MAX_HEAP_SIZE 500000
int heap[MAX_HEAP_SIZE + 1];

int hsize = 0;

int left(int id);

int right(int id);

void maxHeapify(int rootId);
void buildMaxHeap(void);

int main(){
  int n;

  scanf("%d", &n);
  for(int i = 1; i <= n; i++){
    scanf("%d", &heap[i]);
    hsize++;
  }

  buildMaxHeap();

  for(int i = 1; i <= n; i++){
    if(i <= n)break;
  }
  
  for(int i = 1; i <= n; i++){
    printf(" %d", heap[i]);
  }
  printf("\n");
  
  return 0;
}

int left(int id){
  return 2*id;
}

int right(int id){
  return 2*id + 1;
}

void maxHeapify(int rootId){
  int l = left(rootId);
  int r = right(rootId);
  int largest;
  
  //左の子、自分、右の子で値が最大のノードを選ぶ
  if(l <= hsize && heap[l] > heap[rootId]){
    largest = l;
  }
  else {
    largest = rootId;
  }

  if(r <= hsize && heap[r] > heap[largest]){
    largest = r;
  }

  int tmp;
  if(largest != rootId){ //rootIdの子の方が値が大きいとき
    tmp = heap[rootId];
    heap[rootId] = heap[largest];
    heap[largest] = tmp;
    maxHeapify(largest);
  }
}

void buildMaxHeap(){
  for(int i = hsize/2 ; i >= 1; i--){
    maxHeapify(i);
  }
}
    




Measured memory_bytes: 3696
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int i;
  vector<int> vec(n);
  for(i=0;i<n;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  cout << vec.at(n-1)-vec.at(0);
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int N, A;
	
	scanf("%d", &N);
	scanf("%d", &A);
	
	if (N % 500 <= A){
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	
	return (0);
}

Measured memory_bytes: 128
<?php

class In {

	private $buf = [];
	private $count = 0;
	private $pointer = 0;

	public function nextLine() {
		$ret = '';
		if($this->hasNext()){
			while($this->hasNext()){
				$ret .= $this->next();
			}
		}else{
			$ret = trim(fgets(STDIN));
		}

		return $ret;
	}

	public function next() {
		if(!$this->hasNext()) {
			$str = trim(fgets(STDIN));
			$this->buf = explode(' ',$str);
			$this->count = count($this->buf);
			$this->pointer = 0;
		}

		return $this->buf[$this->pointer++];
	}

	public function hasNext() {
		return $this->pointer < $this->count;
	}

	public function nextInt() {
		return (int)$this->next();
	}

	public function nextDouble() {
		return (double)$this->next();
	}
}

class Out {
	public function println($str = '') {
		echo $str . PHP_EOL;
	}
}

$in = new In();
$out = new Out();

$N = $in->nextInt();
$M = $in->nextInt();

$A = [];
for($i = 0;$i < $N;$i++) {
	$A[] = 0;
}

for ($i = 0;$i < $M;$i++) {
	$a = $in->nextInt()-1;
	$b = $in->nextInt()-1;

	$A[$a]++;
	$A[$b]++;
}

for ($i = 0;$i < $N;$i++) {
	$out->println($A[$i]);
}

?>


Measured memory_bytes: 4604
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  
  int a,b;
  cin>>a>>b;
  int plug=1;
  int result=0;
  while(plug<b){
    plug--;
    plug+=a;
    result++;
    
  }
  cout<<result<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main(void){
  vector<int> A;
  int a;
  for(int i =0; i< 3; i++){
    cin>>a;
    A.push_back(a);
  }
  sort(A.begin(), A.end());
  cout<<A[2]*10+A[1]+A[0]<<endl;
  return 0;
}


Measured memory_bytes: 256