akhauriyash/Code-Regression huggingface dataset:
#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) - 1; i >= 0; i--)
#define range(a) a.begin(), a.end()

ll f(ll n, ll a, ll b, ll c, ll d) {
  if (a > c) {
    a = n - 1 - a;
    c = n - 1 - c;
  }
  if (b > d) {
    b = n - 1 - b;
    d = n - 1 - d;
  }
  if (n == 3) {
    if (a == 1 && b == 0 && c == 1 && d == 2) {
      return 4;
    }
    if (a == 0 && b == 1 && c == 2 && d == 1) {
      return 4;
    }
    return abs(c - a) + abs(d - b);
  }
  ll m = n / 3;
  if (a / m == c / m && b / m == d / m) {
    return f(m, a % m, b % m, c % m, d % m);
  }
  if (a / m != c / m && b / m != d / m) {
    return abs(c - a) + abs(d - b);
  }
  if (a / m == 0 && b / m == 1 && c / m == 2 && d / m == 1) {
    swap(a, b);
    swap(c, d);
  }
  if (a / m == 1 && b / m == 0 && c / m == 1 && d / m == 2) {
    return min(
      f(n, a, b, m - 1, m - 1) + f(n, m - 1, m - 1, c, d),
      f(n, a, b, 2*m, m-1) + f(n, 2*m, m-1, c, d)
  );
  }
  if (a / m == c / m) {
    a %= m;
    c %= m;
  } else {
    b %= m;
    d %= m;
  }
  if (a / m < c / m) {
    swap(a, b);
    swap(c, d);
  }
  ll o = m / 3;
  if (a / o != c / o && b / o != d / o) {
    return abs(c - a) + abs(d - b);
  }
  if (a / o == 2) {
    a %= m;
    c %= m;
  }
  if (d / o - b / o == 1) {
    return f(m, a, b % o, c, d % o + o);
  }
  return f(m, a, b % o, c, d % o + 2 * o) + (d / o - b / o - 2) * o;
}

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

  ll p = 1;
  for (int i = 1; i <= 30; i++) {
    p *= 3;
  }
  while (Q--) {
    ll a, b, c, d; cin >> a >> b >> c >> d;
    a--; b--; c--; d--;
    cout << f(p, a, b, c, d) << endl;
  }
}

Measured memory_bytes: 384
#include<stdio.h>

int main(void){
  
  int n,k;
  int p[1005];
  
  scanf("%d %d",&n,&k);
  int i,j;
  for(i=0;i<n;i++){
    scanf("%d",&p[i]);
  }
  int tmp;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(p[i] < p[j]){
        tmp = p[i];
        p[i] = p[j];
        p[j] = tmp;
      }
    }
  }
  
  int ans=0;

  for(i=0;i<k;i++){
    ans = ans + p[i];
   // printf("%d,",p[i]);
  }
  
  printf("%d",ans);
  
  return 0;
}

Measured memory_bytes: 1736
#include<iostream>
using namespace std;
int main() {
	int i, j, max;
	int v[10];
	for (i = 0; i < 10; i++) {
		cin >> v[i];
	}
	for (i = 0; i < 3; i++) {
		max = v[i];
		for (j = i; j < 10; j++) {
			if (max < v[j]) {
				max = v[j];
				v[j] = v[i];
				v[i] = max;
			}
		}

	}

	cout << v[0] <<"\n";
	cout << v[1] << "\n";
	cout << v[2] << "\n";
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int N, A[100010], B[100010]; 
int ans[100010]; 
vector<pair<int, int>> E[100010]; 
void dfs(int now, int parent, int color){
	int a = 1; 
	for(int i = 0; i < E[now].size(); i++){
		if(E[now].at(i).first == parent) continue; 
		if(a == color) a++; 
		ans[E[now].at(i).second] = a; 
		dfs(E[now].at(i).first, now, a); a++;
	}
}
int main(){
	cin >> N; 
	for(int i = 0; i < N-1; i++){
		cin >> A[i] >> B[i]; 
		A[i] --; B[i] --; 
		E[A[i]].push_back(make_pair(B[i], i)); 
		E[B[i]].push_back(make_pair(A[i], i)); 
	}
	int index = -1; int mx = -1;
	for(int i = 0; i < N; i++){
		if((int) E[i].size() > mx){
			index = i; mx = (int) E[i].size(); 
		}
	}
	dfs(0, -1, -1); 
	cout << mx << endl; 
	for(int i = 0; i < N-1; i++) cout << ans[i] << endl; 
}

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

int main(){
  char a,b;
  cin >>a >>b;
  if(a==b) cout << "H" << endl;
  else cout << "D" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(void){
    int x,y,a,b;
    cin >> x >> y;
    a=(4*x-y)/2;
    b=(y-2*x)/2;
    if(a>=0&&(4*x-y)%2==0&&b>=0&&(y-2*x)%2==0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl; 
    }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long int ll;
template<typename T> T changeMax(T& a, T b){if(a < b)a = b;return 0;}

int main()
{
    int n, ans = 0;
    cin >> n;
    string s;
    cin >> s;
    for(int i = 0; i < n-2; i++){
        if(s[i] == 'A'&&s[i+1] == 'B'&&s[i+2]=='C'){
            ans++;
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	map<char, bool> m;
	for (int i = 0; i < s.size(); i++)
		m[s[i]] = true;
	for (char i = 'a'; i <= 'z'; i++)
		if (!m[i])
		{
			cout << i << endl;
			return 0;
		}
	cout << "None" << endl;

	return 0;
}


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

template <typename T>
T gcd(T a, T b) {
  if (a % b == 0) {
    return b;
  } else {
    return gcd(b, a % b);
  }
}

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];

  ll ans = a[0];
  for (int i = 1; i < n; i++) {
    ans = min(ans, gcd(ans, a[i]));
  }
  cout << ans << endl;
}


Measured memory_bytes: 3944
"""
author : halo2halo
date : 16, Jan, 2020
"""

import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
T, A = map(int, readline().split())
H = np.array([int(x) for x in readline().split()])
# print(H)
H = 1000 * T - H * 6
# print(H)
H = abs(H - A*1000)
# print(H)

ans = 0
tmp = 10000000
for num, i in enumerate(H):
    if tmp >= i:
        ans = num
        tmp = i
print(ans + 1)


Measured memory_bytes: 12400
program B175
    implicit none
    integer(8) :: N
    integer(8), allocatable, dimension(:) :: L
    integer(8) :: i, j, k, ans

    read(5,*) N
    allocate(L(N))
    read(5,*) (L(i), i = 1, N)

    ans = 0
    do i = 1, N-2
        do j = i+1, N-1
            do k = j+1, N
                call judge(L(i),L(j),L(k),ans)
            end do
        end do
    end do
    
    write(6,*) ans
    

    stop
end program B175

subroutine judge(L1,L2,L3,ans)
    implicit none
    integer(8) :: L1, L2, L3, ans, a1, a2, a3, i
    integer(8), dimension(3) :: a
    
    a(1) = L1
    a(2) = L2
    a(3) = L3

    a1 = maxval(a)
    a3 = minval(a)

    do i = 1, 3
        if (a(i) == a1) then
            a(i) = 0
        else if (a(i) == a3) then
            a(i) = 0
        end if
    end do

    a2 = maxval(a)

    if (a1 < a2 + a3) then
        ans = ans + 1
    end if

    return
end subroutine

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> ab;
  ab.resize(n*m);
  rep(i,2*m) cin >> ab[i]; 

  for(int i = 1; i <= n; i++){
    cout << count(ab.begin(),ab.end(),i) << endl;
  }
}

Measured memory_bytes: 3460
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, std::vector<long long> A){
  vector<ll> v(N+1, 0);
  for(ll i=0; i<N; i++) {
    v[A[i]]++;
  }
  ll ans = 0;
  for(ll j=1; j<=N; j++)
    ans += (v[j] * (v[j]-1)) / 2;
  //std::cout << ans << std::endl;
  for(ll i=0; i<N; i++) {
    if(v[A[i]]>1) {
      std::cout << ans-(v[A[i]]-1) << std::endl;
    }
    else
      std::cout << ans << std::endl;
  }
  //std::cout << v << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, std::move(A));
  return 0;
}



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

using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (1e10)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x) { cout << setprecision(16) << x << endl; }
template<class T, class... A> void print(const T& first, const A& ... rest) { cout << first << " "; print(rest...); }
struct PreMain { PreMain() { cin.tie(0); ios::sync_with_stdio(false); } } premain;


class Bit
{
public:
	vector<int> bit;
	int M;

	Bit(int M) :
		bit(vector<int>(M + 1, 0)), M(M) {}

	int sum(int i) {
		if (!i) return 0;
		return bit[i] + sum(i - (i & -i));
	}

	void add(int i, int x) {
		if (i > M) return;
		bit[i] += x;
		add(i + (i & -i), x);
	}
};

int main() {
	string S;

	cin >> S;

	vector<int> posS[26];

	REP(i, S.length()) {
		posS[S[i] - 'a'].push_back(i);
	}

	//奇数の数を数える
	vector<int> oddA;
	REP(i, 26) {
		if (1 == (posS[i].size() % 2)) {
			oddA.push_back(i);
		}
	}

	//Sが偶数なのに奇数がある、Sが奇数なのに奇数が2つ以上あるときは-1
	if ((S.length() % 2) < oddA.size()) {
		print(-1);
		return 0;
	}

	vector<pair<int,int>> P0;
	REP(i, 26) {
		REP(j, posS[i].size() / 2) {
			auto& pos = posS[i];
			P0.push_back(make_pair(
				pos[j],
				pos[pos.size() - j - 1]
			));
		}
	}

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

	vector<pair<int, int>> P;
	REP(i, P0.size()) {
		P.push_back(make_pair(P0[i].first, i));
		P.push_back(make_pair(P0[i].second, (S.length() - 1 - i)));
	}
	if (0 < oddA.size()) {
		auto& tmp = posS[oddA[0]];
		P.push_back(make_pair(tmp[tmp.size() / 2], S.length() / 2));
	}

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


	//転倒数を数える
	ll ans = 0;
	Bit bit(P.size());
	REP(i, P.size()) {
		auto p = P[i].second + 1;
		ans += i - bit.sum(p);
		bit.add(p, 1);
	}

	print(ans);

	return 0;
}

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

#define pb push_back
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define MAXX 1005
#define int long long int
#define INT_BITS 32
const int MOD = 1000000007;

int power(int a,int n)
{

    int res = 1;
    while(n)
    {
        if(n&1)
        {
            n--;
            res = ((res%MOD)*(a%MOD))%MOD;
        }
        else
        {
            n/=2;
            a = ((a%MOD)*(a%MOD))%MOD;
        }
    }
    return (res%MOD);
}


int gcd(int a,int b)
{
    if(b == 0)
        return a;
    return gcd(b,a%b);
}
int ncr(int n, int r, int p=MOD)
{
    // Optimization for the cases when r is large
    if (r > n - r)
        r = n - r;
  
    // The array C is going to store last row of
    // pascal triangle at the end. And last entry
    // of last row is nCr
    int C[r + 1];
    memset(C, 0, sizeof(C));
  
    C[0] = 1; // Top row of Pascal Triangle
  
    // One by constructs remaining rows of Pascal
    // Triangle from top to bottom
    for (int i = 1; i <= n; i++) {
  
        // Fill entries of current row using previous
        // row values
        for (int j = min(i, r); j > 0; j--)
  
            // nCj = (n-1)Cj + (n-1)C(j-1);
            C[j] = (C[j] + C[j - 1]) % p;
    }
    return C[r];
}

void solve()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int x=a*c;
    x=max(x,a*c);
    x=max(x,a*d);
    x=max(x,b*c);
    x=max(x,b*d);
    if(x<0)
    {
        if((a<0 and b>0) or (c<0 and d>0))
            x=0;
    }
    cout<<x;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T = 1;
    //cin >> T;
    for(int i = 1 ; i <= T ; i++)
    {
        solve();
    }

    return 0;
}
                                                                                                 


Measured memory_bytes: 3620
N,x = map(int, input().split())
a = list(map(int,input().split()))

sum_a = sum(a)
if sum_a < x:
    print(N-1)
    exit()
elif sum_a == x:
    print(N)
    exit()

rest = sum_a - x
a.sort()
for i in range (N-1, -1, -1):
    rest -= a[i]
    if rest <= 0:
        print(i)
        exit()
print(0)

Measured memory_bytes: 3064
# from collections import deque
n,k=map(int,input().split())
a=list(map(int,input().split()))
# v=deque()
# for i in range(n):
#     v.append(a[i])
# print(v)

ans=0
for i in range(1,k+1):
    if i<=n:
        for j in range(i+1):
            tmp=[]
            # print("{0} {1}".format(i,j))
            for l in range(j):
                if l<n:
                    tmp.append(a[l])
            for r in range(i-j):
                if n-1-r>=0:
                    tmp.append(a[-1-r])
            # print(tmp)
            tmp.sort(reverse=True)
            # print(tmp)
            for m in range(k-i):
                if len(tmp)>0:
                    if tmp[-1]<0:
                        tmp.pop()
            ans=max(ans,sum(tmp))

print(ans)

Measured memory_bytes: 41964
/*input
2
*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
#define ll          long long
#define pb          push_back
#define pii         pair<long,long>
#define vi          vector<long long>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define repi(i,a,b) for(ll i=a;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define fIO         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define tr(it, a)   for(auto it = a.begin(); it != a.end(); it++)
#define clr(x)      memset(x, 0, sizeof(x))
#define deb(x)      cout << #x << "=" << x << endl
#define deb2(x, y)  cout << #x << "=" << x << "," << #y << "=" << y << endl
#define TIME        cerr << "\nTime elapsed: "<<1.0 * clock() / CLOCKS_PER_SEC << " s.\n"; 
//#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update>;

ll sub(ll a, ll b){return (a-b+hell)%hell;}
ll add(ll a, ll b){return (a+b)%hell;}
ll mul(ll a, ll b){return (a*b)%hell;}
vector<ll>adj[100005];
bool vis[100005];
ll siz,edges;
void dfs(ll i)
{
    vis[i]=1;
    //siz++;
    for(ll j=0;j<adj[i].size();j++)
    {        
        edges++;
        if(!vis[adj[i][j]])
            dfs(adj[i][j]);
    }
}
const ll mod = 1000000007;
ll mpow(ll base, ll exp) {
  base %= mod;
  ll result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

int main()
{
fIO;
ll n,sum=0,t=1,m,ans;
//cin >> t;
while(t--){
  cin>>n;
  ll sum=0;
  rep(i,1,n+1){
    rep(j,1,n+1){
      rep(k,1,n+1){
        int x=__gcd(i,j);
        x=__gcd(x,k);
        sum+=x;
      }
    }
  }
  cout<<sum;














}
TIME;
    
}

Measured memory_bytes: 6152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int a[101];
int main()
{
 	int i,n,sum=0,w=0;
 	cin>>n;
 	for(i=1;i<=n;i++)
 	{
 		cin>>a[i];
	 }
	 sort(a+1,a+n+1);
	 for(i=1;i<=n;i++)
	 {
		sum+=a[i];  
    }
    if(sum%10!=0) 
    {
    	cout<<sum;
    	return 0;
	}
 	for(i=1;i<=n;i++)
 	{
 		if(a[i]%10!=0)
 		{
 			cout<<sum-a[i];
 			return 0;
		 }
	 }
	 cout<<0;
	 return 0;
}


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

using namespace std;
int N;

int main() {
   cin >> N;
   int tmp = sqrt(N);
   cout << tmp * tmp << endl;
   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
char mapp[105][105];
const int maxn = 1e5 + 5;
long long t[maxn];
long long pret[maxn];
int main(){
    int n;
    std::cin >> n;
    for(int i = 1; i <= n; ++ i) std::cin >> t[i];
    for(int i= 1; i <= n ;++ i) {
        pret[i] = pret[i - 1] + t[i];
    }
    int m;
    std::cin >> m;

    for(int i = 1; i <= m; ++ i){
        long long pi,xi;
        std::cin >> pi >> xi;
        long long ret = pret[n] - t[pi] + xi;
        std::cout << ret << std::endl;
    }
}

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

using namespace std;

int main() {
  int N, count = 0;
  cin >> N;
  int len = to_string(N).size(), tlen = 1;
  queue<string> b, a;
  b.push("3");
  b.push("5");
  b.push("7");
  while (tlen <= len && !b.empty()) {
    auto head = b.front(); b.pop();
    int size = head.size()+1;
    a.push(head);
    if (size <= len) {
      tlen = min(tlen, size);
      b.push(head+"3");
      b.push(head+"5");
      b.push(head+"7");
    }
  }
  while (!a.empty()) {
    auto head = a.front(); a.pop();
    int n = stoi(head);
    if (n > N) continue;
    bool f = true;
    int c3 = 0, c5 = 0, c7 = 0;
    for (char c : head) {
      switch (c) {
        case '3': c3+=1; break;
        case '5': c5+=1; break;
        case '7': c7+=1; break;
        default: f = false; break;
      }
    }
    if (f && c3 > 0 && c5 > 0 && c7 > 0) count += 1;
  }
  cout << count << endl;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pw(x) (1ll << (x))
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define per(i,l,r) for(int i=(r)-1;i>=(l);--i)
#define dd(x) cout << #x << " = " << x << ", "
#define de(x) cout << #x << " = " << x << endl

//-----
int n, x;
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cin >> n >> x;
	int ans = n, mi = INT_MAX;
	rep(i, 0, n) {
		int ai; cin >> ai;
		x -= ai;
		mi = min(mi, ai);
	}
	cout << ans + (x / mi);
	return 0;
}

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

using namespace std;
typedef long long int ll;

#define INF (1e9)

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

    string ans = "";

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

        N /= -2;
    }

    if (ans == "") ans = "0";
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define rep(i,k,n) for(int (i)=(k);(i)<(n);(i)++)
#define max(a,b) (a)>(b)?(a):(b)
#define min(a,b) (a)<(b)?(a):(b)
#define abs(a,b) (a)< 0 ?(a):-(a)
#define llong long long

int next(int*,int,int);

int main(){
	int N,M,Q; scanf("%d %d %d",&N,&M,&Q);
	int a[Q],b[Q],c[Q],d[Q];
	rep(i,0,Q){
		scanf("%d %d %d %d",&a[i],&b[i],&c[i],&d[i]);
		a[i]--; b[i]--;
	}
	int A[N];
	rep(i,0,N) A[i]=1;
	int max = 0;
	do{
		int point = 0;
		rep(i,0,Q){
			if( A[b[i]] - A[a[i]] == c[i] ){
				point += d[i];
			}
		}
		max = max(max,point);
	}while( next(A,N,M) );
	printf("%d",max);
	return 0;
}

int next(int *A,int N,int M){
	rep(i,1,N+1){
		if( A[N-i] != M ){
			A[N-i]++;
			rep(j,N-i+1,N) A[j]=A[j-1];
			return 1;
		}
	}
	return 0;
}


Measured memory_bytes: 1732
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n = readline() |> parseInt
	k = Int[]
	r = 0
	while n != 0
		if n%((-2)^(r+1)) != 0
			push!(k,1)
			n -= (-2)^r
		else
			push!(k,0)
		end
		r += 1
	end
	if length(k) == 0
		print(0)
	end
	for i in 1:length(k)
		print(k[length(k)-i+1])
	end
end

main()

Measured memory_bytes: 109332
package main

import (
	"fmt"
	"sort"
	"strings"
)

func main() {
	var n, l int

	var sarray []string

	fmt.Scan(&n, &l)

	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)

		sarray = append(sarray, s)
	}

	sort.Strings(sarray)

	ss := strings.Join(sarray[:], "")

	fmt.Println(ss)

}


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

using namespace std;

template<typename T>
class Dijkstra {
 public:
  int n;
  T INF = numeric_limits<T>::max();
  vector< vector< pair<int,T> > > g;
  vector<T> dis;
  vector<int> prev;
  
  Dijkstra(int _n) : n(_n) {
    g.resize(n);
  }

  void add_edge(int u, int v, T w) {
    assert(0 <= u && u < n && 0 <= v && v < n);
    assert(w >= 0);
    g[u].emplace_back(v, w);
  }

  vector<T> short_path(int s) {
    dis = vector<T>(n, INF);
    prev = vector<int>(n, -1);

    set< tuple<T,int,int> > bag; // cost, vertex, prev
    bag.insert(make_tuple(0, s, -1));
    while (bag.size()) {
      int u, v, p;
      T w, cost;
      tie(cost, u, p) = *bag.begin();
      bag.erase(bag.begin());
      if (dis[u] > cost) {
        dis[u] = cost;
        prev[u] = p;
        for (auto i : g[u]) {
          tie(v, w) = i;
          bag.insert(make_tuple(w + cost, v, u));
        }
      }
    }
    return dis;
  }
};

int main() {
  ios_base::sync_with_stdio(false);

  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  int n;
  cin >> n;
  n += 2;
  vector<int> x(n), y(n), r(n);
  for (int i = 0; i < n - 2; i++) {
    cin >> x[i] >> y[i] >> r[i];
  }
  x[n - 2] = x1; y[n - 2] = y1;
  x[n - 1] = x2; y[n - 1] = y2;

  auto dis = [&](int i, int j) {
    double dx, dy, d;
    dx = x[i] - x[j];
    dy = y[i] - y[j];
    d = sqrt(dx * dx + dy * dy) - r[i] - r[j];
    return max(.0, d);
  };
  
  Dijkstra<double> g(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      g.add_edge(i, j, dis(i, j));
    }
  }

  double ans = g.short_path(n - 2)[n - 1];
  cout << fixed << setprecision(10) << ans << '\n';

  return 0;
}
 


Measured memory_bytes: 81780
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace A
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int[] items = RIntAr();
            Console.WriteLine(items[1] % items[0] == 0 ? items[1] + items[0] : items[1] - items[0]);
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}


Measured memory_bytes: 13140
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	
	s := scanText()

	a,b,c,d := string(s[0]),string(s[1]),string(s[2]),string(s[3])

	if a==b && c==d && a!=c {
		fmt.Println("Yes")
	} else if a==c && b==d && a!=b {
		fmt.Println("Yes")
	} else if a==d && b==c && a!=b {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
using ll = long long;
using ld = long double;
using str = string;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<str>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;

// Constant variables
const ld PI = (acos(-1));
const ll MOD = 1000000007;

// I/O Asynchronizing
struct __io_async{
    __io_async(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
};

int main() {
    int n, k, cnt = 0;
    cin >> n >> k;
    while(n > 0) {
        n /= k;
        cnt++;
    }
    cout << cnt << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ll long long
#define endl "\n"
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T> using ordered_set = tree<T, null_type, std::less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int N = 1e5 + 10, inf = 1e9 + 10, mod = 1e9 + 7;
int a[300], d[N], n, k;
int main()
{
    //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //freopen("prices.in", "r", stdin);
    //freopen("prices.out", "w", stdout);
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        d[a[i]] = 1;
    }
    for(int i = 1; i <= k; i++)
    {
        d[i] = 0;
        for(int j = 1; j <= n; j++)
        {
            if(i >= a[j])
            {
                if(!d[i - a[j]])d[i] = 1;
            }
        }
    }
    if(d[k])cout << "First";
    else cout << "Second";
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define MAXN 200005
using namespace std;
int a[MAXN];
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>a[i];
    int sum=0;
    for(int i=0;i<k;i++)
        sum+=a[i];
    int res=sum;
    for(int i=k;i<n;i++)
    {
        sum=sum-a[i-k]+a[i];
        res=max(res,sum);
    }
    double ans=k*0.5+0.5*res;
    printf("%f",ans);
    return 0;
}


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

typedef struct{
	int id;
	int score;
	int time;
	int wrong[10];
}team;

int comp(const void* c1, const void*c2){
	team* t1 = (team*)c1;
	team* t2 = (team*)c2;
	if(t1->score - t2->score){
		return t2->score - t1->score;
	}else if(t1->time - t2->time){
		return t1->time - t2->time;
	}else{
		return t2->id - t1->id;
	}
}

int M,T,P,R;
team teams[50];

int main(void){
	int i,j;
	while(scanf("%d %d %d %d",&M,&T,&P,&R),M|T|P|R){
		for(i=0;i<T;i++){
			teams[i].id=i+1;
			teams[i].score=0;
			teams[i].time=0;
			for(j=0;j<10;j++){
				teams[i].wrong[j]=0;
			}
		}
		int m,t,p,j;
		for(i=0;i<R;i++){
			scanf("%d %d %d %d",&m,&t,&p,&j);
			if(j==0){
				teams[t-1].score++;
				teams[t-1].time+=m+20*(teams[t-1].wrong[p-1]);
			}else{
				teams[t-1].wrong[p-1]++;
			}
		}
		qsort(teams,T,sizeof(team),comp);
		for(i=0;i<T;i++){

			if(i==0){
				printf("%d",teams[i].id);
			}else{
				if(teams[i-1].score==teams[i].score && teams[i-1].time==teams[i].time){
					printf("=%d",teams[i].id);
				}else{
					printf(",%d",teams[i].id);
				}
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 608
n = int(input())
h_list = list(map(int,input().split()))
cost_min_list = [0] * n
cost_min_list[0] = 0
cost_min_list[1] = abs(h_list[1] - h_list[0])
for i in range(2, n):
    cost_min_list[i] = min(cost_min_list[i - 1] + abs(h_list[i] - h_list[i - 1]),
                           cost_min_list[i - 2] + abs(h_list[i] - h_list[i - 2]))
print(cost_min_list[n - 1])

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

using namespace std;

typedef long long int LL;


int main(int argc, char const *argv[])
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	ios::sync_with_stdio(0);
	cin.tie(0);

	//Code
	int n;
	cin >> n;

	cout << pow(n, 3) << '\n';

}

//__int128_t with a value range of − 2 127 . . . 2 127 − 1
// n'th fibonacci (pow((1 + sqrt(5)), n) - pow((1 - sqrt(5)), n)) / (pow(2,n) * sqrt(5));
// the number of digits of an integer x in base b is b log b ( x ) + 1 c

Measured memory_bytes: 256
let () = Scanf.scanf "%d" @@ fun n ->
  let sum = ref 0 in
  let dp = Array.make (n + 1) 0 in
  for i = 1 to n do
    let rec iter j =
      if j <= n then (dp.(j) <- j + dp.(j); iter (i + j)) in
    iter i;
    sum := !sum + dp.(i);
  done;
  Printf.printf "%d\n" !sum


Measured memory_bytes: 85152
n,a,b=map(int,input().split())
mod_num=10**9+7

ans=pow(2,n,mod_num)

def get_combi_mod(n, k, MOD):
    if n < k:
        return 0
    if n-k < k:
        k = n-k
    comb = 1
    for x in range(n-k+1, n+1):
        comb = (comb * x) % MOD
    d = 1
    for x in range(1, k+1):
        d = (d * x) % MOD
    comb *= pow(d, MOD-2, MOD)
    return comb % MOD

ans-=1
ans-=get_combi_mod(n,a,mod_num)
ans-=get_combi_mod(n,b,mod_num)
print(ans%mod_num)

Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val (k, s) = readLine()!!.split(" ").map{it.toInt()}
    var count = 0
    for(x in 0..k){
        for(y in 0..k) {
            var z = s - x - y
            if(z in 0..k) count++
            }
        }
    println(count)
}


Measured memory_bytes: 37872
#include<cstdio>

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

using namespace std;

#define rectsum(dp) (dp[b][r]-dp[t][r]-dp[b][l]+dp[t][l])

int main(){
	int h,w,q; scanf("%d%d%d",&h,&w,&q);
	static char B[1000][1001];
	rep(i,h) scanf("%s",B[i]);

	static int dp_J[1001][1001];
	static int dp_O[1001][1001];
	static int dp_I[1001][1001];
	rep(i,h) rep(j,w) {
		dp_J[i+1][j+1]=dp_J[i+1][j]+dp_J[i][j+1]-dp_J[i][j]+(B[i][j]=='J'?1:0);
		dp_O[i+1][j+1]=dp_O[i+1][j]+dp_O[i][j+1]-dp_O[i][j]+(B[i][j]=='O'?1:0);
		dp_I[i+1][j+1]=dp_I[i+1][j]+dp_I[i][j+1]-dp_I[i][j]+(B[i][j]=='I'?1:0);
	}

	while(q--){
		int t,l,b,r; scanf("%d%d%d%d",&t,&l,&b,&r); t--; l--;
		printf("%d %d %d\n",rectsum(dp_J),rectsum(dp_O),rectsum(dp_I));
	}

	return 0;
}

Measured memory_bytes: 13000
s=input().split()
t=input().split()

A=0

for Ai in t:
    A=A+int(Ai)


J=0

M=s[1]
MM=4*int(M)

for i in t:
   if int(i) >= A/MM:
       J=J+1

if J >= int(M):
    print("Yes")
else:
    print("No")


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

string data[10];

void revstr(string &str, string *target) {
  *target = "";

  for(int i = 1; i <= str.length(); i++) {
    *target += str[str.length()-i];
  }
}

string str[10];
bool flag[10];
int cnt;

bool isFix(int level) {
  for(int j = 0; j < 5; j++) {
    if(str[level][j] == str[j][level-5]) return false;
  }
  return true;
}

void rec(int level) {
  if(level == 0) {
    for(int i = 0; i < 10; i++) flag[i] = false;
  }
  if(level == 10) {
    cnt++;
    return;
  }

  for(int i = 0; i < 10; i++) {
    if(!flag[i]) {
      flag[i] = true;
      str[level] = data[i];
      if(level < 5) {
	rec(level+1);
      } else if(level >= 5 && isFix(level)) {
	rec(level+1);
	flag[i] = false;
	return;
      }
      revstr(data[i], &str[level]);
      if(str[level] != data[i]) {
	if(level < 5) {
	  rec(level+1);
	} else if(level >= 5 && isFix(level)) {
	  rec(level+1);
	  flag[i] = false;
	  return;
	}
      }
      flag[i] = false;
    }
  }
}

int main() {
  while(1) {
    for(int i = 0; i < 10; i++) {
      cin >> data[i];
      if(data[i] == "END") return 0;
    }
    cnt = 0;
    rec(0);
    cout << cnt/8 << endl;
  }
}

Measured memory_bytes: 916
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define m 1000000007

int main(){
    ll sum=0, n=0, ans=0;
    int i=0, j=0;

    cin >> n;

    ll arr[n];

    for(i=0; i<n; i++){
        cin >> arr[i];
        sum += arr[i]%m;
        sum %= m;
    }

    for(i=0; i<n-1; i++){
        sum -= (arr[i]%m);
        if(sum<0) sum += m;
        ans += ((sum%m)*(arr[i]%m))%m;
        ans %= m;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5100
def main():
    x, k, d = map(int, input().split())
    x = abs(x)
    count = x // d
    if count > k:
        ans = x - (k*d)
    else:
        if k % 2 == count % 2:
            ans = x - (count*d)
        else:
            ans = x - (count+1) * d
    print(abs(ans))
    
if __name__ == '__main__':
    main()

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

int main() {
  int N, S, T = 0;
  cin >> N;
  for(int i = 0; i < N; i++){
    string S;
    cin >> S;
    if (S == "Y") {
      T = 1;
    }
  }
  if (T == 1){
    cout << "Four" << endl;
  }
  else {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    a,b,c,k=parseMap(split(readline()))
    println((a-b)*ifelse(k%2==0,1,-1))
end
main()

Measured memory_bytes: 113328
while line = gets do
  a, b = line.chomp.split.map(&:to_i)
  a, b = b, a if a < b
  x, y = a, b
  # GCD
  while (r = a % b) != 0 do
    a = b
    b = r
  end
  puts "#{b} #{x * y / b}"
end

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

#define rep(i, n) for(int i = 0; i < (n); i++)
using ll = long long;
constexpr ll INF = 1000000000;

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

using namespace std;
int main() {
	string n; cin >> n;

	if (n[0] == n[2])cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=1e5+5;
int to[MN<<1],nxt[MN<<1],deg[MN],h[MN],cnt;
inline void ins(int s,int t){
	to[++cnt]=t;nxt[cnt]=h[s];h[s]=cnt;deg[t]++;
	to[++cnt]=s;nxt[cnt]=h[t];h[t]=cnt;deg[s]++;
}
bool t[MN],vis[MN];
char ch[MN];
int n,ans,sum,que[MN],f[MN];
void dfs(int st,int fa=0){
	sum+=deg[st];sum+=(deg[st]=(!t[st])^(deg[st]&1));
	for(reg int i=h[st];i;i=nxt[i])
		if(!vis[to[i]]&&to[i]!=fa){
			dfs(to[i],st);ans=min(ans,f[st]+f[to[i]]);
			f[st]=min(f[st],f[to[i]]-2*deg[st]);
		}
}
int main(){
	scanf("%d",&n);reg int he=0,ta=0;
	for(reg int i=1,s,t;i<n;i++)scanf("%d%d",&s,&t),ins(s,t);
	scanf("%s",ch+1);
	for(reg int i=1;i<=n;i++)t[i]=(ch[i]=='B');
	for(reg int i=1;i<=n;i++)if(deg[i]<2&&t[i])que[ta++]=i;
	while(he<ta){
		reg int v=que[he++];vis[v]=true;
		for(reg int i=h[v];i;i=nxt[i])if((--deg[to[i]])==1&&t[to[i]])que[ta++]=to[i];
	}
	if(ta==n)return 0*puts("0");
	for(reg int i=1;i<=n;i++)
		if(!vis[i]&&!t[i]){
			dfs(i);return 0*printf("%d\n",sum+ans);
		}
	return 0;
}

Measured memory_bytes: 7808
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <numeric>
#include <tuple>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
#define ALL(x)   (x).begin(),(x).end()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define mp       make_pair
#define eb       emplace_back

int main() {
	int r, g;
	cin >> r >> g;
	cout << r + (g - r) * 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <cfloat>
using namespace std;

class Edge
{
public:
    int to, len;
    Edge(int to0, int len0){
        to = to0;
        len = len0;
    }
};

double INF = DBL_MAX / 2.0;
double EPS = 1.0e-9;

double solve(vector<int>& ticket, vector<vector<Edge> >& edges, int a, int b)
{
    int n = ticket.size();
    int m = edges.size();

    vector<vector<double> > minCost(m, vector<double>(1<<n, INF));
    multimap<double, pair<int, int> > mm;
    mm.insert(make_pair(0.0, make_pair(a, (1<<n)-1)));
    minCost[a][(1<<n)-1] = 0.0;

    while(!mm.empty()){
        multimap<double, pair<int, int> >::iterator it = mm.begin();
        double cost = it->first;
        int x = it->second.first;
        int y = it->second.second;
        mm.erase(it);

        if(x == b)
            return minCost[x][y];
        if(cost > minCost[x][y] + EPS)
            continue;

        bitset<8> bs(y);
        for(unsigned i=0; i<edges[x].size(); ++i){
            int to = edges[x][i].to;
            int len = edges[x][i].len;
            for(int j=0; j<n; ++j){
                if(!bs[j])
                    continue;
                bs[j] = false;
                double cost1 = cost + (double)len / ticket[j];
                if(cost1 < minCost[to][bs.to_ulong()] - EPS){
                    minCost[to][bs.to_ulong()] = cost1;
                    mm.insert(make_pair(cost1, make_pair(to, bs.to_ulong())));
                }
                bs[j] = true;
            }
        }
    }

    return INF;
}

int main()
{
    for(;;){
        int n, m, p, a, b;
        cin >> n >> m >> p >> a >> b;
        if(n == 0)
            break;

        vector<int> ticket(n);
        for(int i=0; i<n; ++i)
            cin >> ticket[i];

        vector<vector<Edge> > edges(m);
        for(int i=0; i<p; ++i){
            int x, y, z;
            cin >> x >> y >> z;
            edges[x-1].push_back(Edge(y-1, z));
            edges[y-1].push_back(Edge(x-1, z));
        }

        double ret = solve(ticket, edges, a-1, b-1);
        if(ret == INF)
            cout << "Impossible" << endl;
        else
            printf("%.10f\n", ret);
    }
}

Measured memory_bytes: 2668
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

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

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


int main() {
  string s;
  cin >> s;
  int N = s.size();
  int dis = N - 7;
  bool f = false;
  for(int i = 0; i + dis <= N; i++) {
	string ne = s;
	ne = ne.erase(i,dis);
	//	cout << ne << endl;
	if(ne == "keyence") {
	  f = true;
	}
  }
  if(f) cout << "YES" << endl;
  else cout << "NO" << endl;
}



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

vector< vector< int > > G;
int visit[100010];
int attr[100010];

bool dfs(int node,int mark){
  visit[node] = 1;
  attr[node] = mark;
  for(int i : G[node]){
    if(!visit[i] && dfs(i,!mark)){
      return true;
    }else if(attr[i] == mark){
      return true;
    }
  }
  return false;
}


int main(){
  ll v,e;
  fill(attr,attr+100010,-1);
  fill(visit,visit+100010,0);
  G.clear();
  
  cin >> v >> e;
  G.resize(v);
  for(int i = 0;i < e;++i){
    int a,b;
    cin >> a >> b;
    --a;--b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  if(dfs(0,0)){
    cout << v*(v-1)/2 - e << endl;
  }else{
    ll even = 0;
    ll odd = 0;
    for(int i = 0;i < v;++i){
      if(attr[i] == 0)
        ++even;
      else if(attr[i] == 1)
        ++odd;
    }
    cout << even*odd - e << endl;
  }
  return 0;
}


Measured memory_bytes: 6912
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

D, G = MAP()
G //= 100
DC = []
MAX = 0
for i in range(D):
    d, c = MAP()
    c //= 100
    MAX += d
    DC.append((d, c))

# dp[i][j] := i点問題まで見て、合計j問解いた状態でのスコア最大値
dp = list2d(D+1, MAX+1, 0)
for i in range(D):
    d, c = DC[i]
    for j in range(MAX+1):
        for k in range(d+1):
            if j+k > MAX:
                break
            if k == d:
                # 全完ボーナス付
                dp[i+1][j+k] = max(dp[i+1][j+k], dp[i][j] + (i+1) * k + c)
            else:
                # 通常
                dp[i+1][j+k] = max(dp[i+1][j+k], dp[i][j] + (i+1) * k)

# スコアがG以上となる最小の解いた問題数を出力
for j in range(MAX+1):
    if dp[D][j] >= G:
        print(j)
        break


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

void print(char ch[], int a, int b);
void reverse(char ch[], int a, int b);
void replace(char ch[], int a, int b, char p[]);
int main(void) {
  char ch[1001];
  char com[8];
  char p[1002];
  int q, a, b, i;
  scanf("%s %d", &ch, &q);
  for (i = 0; i < q; i++) {
    scanf("%s", &com);
    scanf("%d %d", &a, &b);
    if (strcmp(com, "print") == 0) {
      print(ch, a, b);
    } else if (strcmp(com, "reverse") == 0) {
      reverse(ch, a, b);
    } else if (strcmp(com, "replace") == 0) {
      scanf("%s", &p);
      replace(ch, a, b, p);
    }
  }
  return 0;
}
void print(char ch[], int a, int b){
  int i;
  for (i = a; i <= b; i++) {
    putchar(ch[i]);
  }
  putchar('\n');
}
void reverse(char ch[], int a, int b) {
  int i, j, tmp;
  for (i = a, j = b; i <= a + (b - a) / 2; i++, j--) {
    tmp = ch[i];
    ch[i] = ch[j];
    ch[j] = tmp;
  }
}
void replace(char ch[], int a, int b, char p[]) {
  int i, j;
  for (i = a, j = 0; i <= b; i++, j++) {
    ch[i] = p[j];
  }
}



Measured memory_bytes: 2100
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
#define ll long long
#define ull unsigned long long
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define yes cout << "Yes" << endl
#define no cout << "No" << endl
#define FOR(i,start,stop)  for(int i=(start); i < (stop); i++)
#define FORD(i,start,stop) for(int i=(start); i >= (stop); i--)
#define RIP(i,stop) FOR(i,0,stop)
#define PI 3.141592653589793
#define PRECISION(c,f) fixed << setprecision(c) << f
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a,b,k; 
  cin >> k >> a >> b;

  bool can = false;
  //if(k == 1) can = true;
  FOR(i,a,b+1){
    if(i%k == 0) can = true;
    if(can) break;
  }

  if(can) cout << "OK" << endl;
  else cout << "NG" << endl;

  return 0;
}


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

int main(){
    int N, K;
    cin >> N >> K;
    int a = N / K;
    if (K % 2 == 1) {
        int64_t ans = pow(a, 3);
        cout << ans << endl;
    }
    else{
        int b = a;
        if (N % K >= K / 2) b++;
        int64_t ans = pow(a, 3) + pow(b, 3);
        cout << ans << endl;
    }
}

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

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


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

int main(){

  int a[3];
  int max_i = 0;

  for(int i = 0; i < 3; i++){
    cin >> a[i];
    if(a[max_i] < a[i])
      max_i = i;
  }

  int sum = 0;

  for(int i = 0; i < 3; i++)
    if(i != max_i)
      sum += a[i];

  cout << sum << endl;

  return 0;

}


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

using namespace std;

int main()
{
    int num,n;
    static int var=1,index=-1,counter=-1;
    vector<int>vec;
    cin>>num;
    for(int i=0;i<num;i++)
    {
        cin>>n;
        vec.push_back(n);
    }
    for(int u=0;u<vec.size();u++)
    {
        if(vec[u]==var && index==-1)
          {var+=1;index=u;counter=index;}
        else if(vec[u]==var && index!=-1)
        {
            var+=1;counter+=u-index-1;index=u;
        }
    }
    if(index!=vec.size()-1 && counter!=-1)
    {
        counter+=vec.size()-index-1;
    }
    if(counter==-1)
        cout<<-1<<endl;
    else
        cout<<counter<<endl;
    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
string s;
long long r,g,b;
long long n,ans;
int main(){
	cin>>n;
	cin>>s;
	for(int i=0;i<n;i++){
		if(s[i]=='R') r++;
		else if(s[i]=='G') g++;
		else b++;
	} 
	ans=r*b*g;
	for (int j=1;j<n;j++){
		for (int i=0;i<j;i++){
			int k=2*j-i;
			if (k>=n) continue;
			if (s[i]!=s[j] && s[j]!=s[k] && s[k]!=s[i]){
				ans--;
			}
			
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

#define For(i, l, r) for (register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for (register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Rep(i, r) for (register int i = (0), i##end = (int)(r); i < i##end; ++i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

inline int read() {
	int x(0), sgn(1); char ch(getchar());
	for (; !isdigit(ch); ch = getchar()) if (ch == '-') sgn = -1;
	for (; isdigit(ch); ch = getchar()) x = (x * 10) + (ch ^ 48);
	return x * sgn;
}

void File() {
#ifdef zjp_shadow
	freopen ("E.in", "r", stdin);
	freopen ("E.out", "w", stdout);
#endif
}

const int N = 310, Mod = 998244353;

inline int fpm(int x, int power) {
	int res = 1;
	for (; power; power >>= 1, x = 1ll * x * x % Mod)
		if (power & 1) res = 1ll * res * x % Mod;
	return res;
}

using Info = bitset<N>;

Info A[N];

int n, m;

struct Linear_Base {

	Info Base[N]; int res = 0;

	void Insert(Info cur) {
		bool flag = false;
		Fordown (i, m, 1) 
			if (cur[i]) {
				if (Base[i].any()) cur ^= Base[i];
				else { Base[i] = cur; flag = true; break; }
			}
		if (!flag) ++ res; 
	}

} T;


int main () {
	
	File();

	n = read(); m = read();

	For (i, 1, n) {
		For (j, 1, m) A[i][j] = read();
		T.Insert(A[i]);
	}

	int ans = 1ll * (fpm(2, n) - fpm(2, T.res) + Mod) * fpm(2, m - 1) % Mod;
	printf ("%d\n", ans);

    return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
#include  <math.h>

int main()
{
	double x1,y1,x2,y2;
	double a;

	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	a=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));

	printf("%lf\n",a);
	return  0;
}

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

#define pb(s) push_back(s)
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))

typedef long long ll;

ll a,b,x;


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

    cin>>a>>b>>x;
    ll ans=b/x-a/x;
    if(a%x==0)ans++;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256