akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;

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

	vector<int> march(5, 0);
	for (int i = 0; i < N; i++)
	{
		string tmp;
		cin >> tmp;
		char c = tmp[0];
		switch (c)
		{
		case 'M':
			march[0]++;
			break;
		case 'A':
			march[1]++;
			break;
		case 'R':
			march[2]++;
			break;
		case 'C':
			march[3]++;
			break;
		case 'H':
			march[4]++;
			break;
		default:
			break;
		}
	}
	long ans = 0;
	for (int i = 0; i < 32; i++)
	{
		vector<int> m(5);
		m[0] = i / 16;
		m[1] = (i - m[0] * 16) / 8;
		m[2] = (i - m[0] * 16 - m[1] * 8) / 4;
		m[3] = (i - m[0] * 16 - m[1] * 8 - m[2] * 4) / 2;
		m[4] = (i - m[0] * 16 - m[1] * 8 - m[2] * 4 - m[3] * 2);
		int sum = 0;
		for (int i = 0; i < 5; i++)
			sum += m[i];
		if (sum==3)
		{
			long tmp=1;
			for (int i = 0; i < 5; i++)
			{
				if (m[i]==1)
					tmp *= march[i];
			}
			ans += tmp;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  int n = N;
  string ans = "No";
  rep(i,0,N/4){
    n -= 4*i;
    if(n==0){
      ans = "Yes";
      break;
    }
    rep(j,0,N/7){
      n -= 7;
      if(n==0){
        ans = "Yes";
        break;
      }
    }
    n = N;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#define ll long long
using namespace std;

int main(void){
    ll n, m, ans, cnt;
    cin >> n >> m;
    if(n%3==0||m%3==0){
        cout << 0 << endl;
        return 0;
    }
    ans = m*n;
    ll cnt1=n>>1, cnt2=m>>1;

    // cnt1 = n-cnt1;
    // cnt2 = m-cnt2;
    // cnt = (n-cnt1)*m - max(cnt1/2*m, cnt1*(m>>1));
    // ans = min(ans, cnt);
    // 
    // cnt = (m-cnt2)*n - max(cnt2/2*n, cnt2*(n>>1));
    // ans = min(ans, cnt);

    cnt1 = n-n/3;
    cnt = (m-m/2)*cnt1 - (n-cnt1)*m;
    ans = min(ans, cnt);

    cnt2 = m-m/3;
    cnt = (n-n/2)*cnt2 - (m-cnt2)*n;
    ans = min(ans, cnt);

    cnt1 = ceil(n*1.0/3);
    cnt1 = n-cnt1;
    cnt = (n-cnt1)*m - (m/2)*cnt1;
    ans = min(ans, cnt);

    cnt2 = ceil(m*1.0/3);
    cnt2 = m-cnt2;
    cnt = (m-cnt2)*n - (n/2)*cnt2;
    ans = min(ans, cnt);

    if(m>=3) ans = min(ans, n);
    if(n>=3) ans = min(ans, m);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

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

int main(){
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i, h) cin >> s[i];
    auto isOutOfRange = [](int h, int w, int H, int W) {
        return h < 0 || h >= H || w < 0 || w >= W;
    };
    rep(y, h) rep(x, w) {
        if(s[y][x] == '#') {
            bool f = false;
            rep(i, 4) {
                int nx = x + dx[i];
                int ny = y + dy[i];
                if(isOutOfRange(ny, nx, h, w) || s[ny][nx] =='.') continue;
                f = true;
            }
            if(f == false) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

        int[] sum = new int[110000];
        sum[0] = 100000;
        for (int i = 1; i < N; ++i) {
            StringBuilder a = new StringBuilder(Integer.toString(i));
            StringBuilder b = new StringBuilder(Integer.toString(N - i));
            for (int j = 0; j < a.length(); j++) {
                sum[i] += Integer.parseInt(a.substring(j, j + 1));
            }
            for (int j = 0; j < b.length(); j++) {
                sum[i] += Integer.parseInt(b.substring(j, j + 1));
            }
        }

        Arrays.sort(sum);
        for (int i = 0; i < 110000; i++) {
            if (sum[i] != 0) {
                System.out.println(sum[i]);
                break;
            }
        }
    }
}

Measured memory_bytes: 47448
#include<bits/stdc++.h>
using namespace std;
typedef long long llong;
#define rep(i,n) for(llong i=0;i<(llong)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
llong mod=1e9+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  llong n,k;
  double sum=0.0;
  double maxi=0.0;
  cin>>n>>k;
  vector<llong> p(n);
  rep(i,n)cin>>p.at(i);
  for(llong i=0;i<=n-k;i++){
    if(i==0){
      for(llong j=0;j<k;j++){
      sum+=p.at(i+j)+1;
      }
    }
    else{
      sum=sum-p.at(i-1)+p.at(i+k-1);
    }
    if(sum>maxi) maxi=sum;
  }
  maxi/=2.0;
  cout<<setprecision(10);
  cout<<maxi<<endl;
  return 0;
  }


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  long long int a=0,b=0,c=0,d=0,n=0,count=0,ans=0;
  string s;
  cin>>s;
  rep(i,s.size()-1) if(s[i]!=s[i+1]) ans++;
  cout<<ans<<endl;
}
///////////////////////////

Measured memory_bytes: 512
from sys import stdin,stdout
from numba import njit
@njit
def solve(n):
	fctrs=[0]*(n+1)
	ans=0
	for i in range(1,n+1):
		for j in range(i,n+1,i):
			fctrs[j]+=1
	for i in range(1,n+1):
		ans+=(i*fctrs[i])
	return ans
n=int(stdin.readline())
print(solve(n))

Measured memory_bytes: 188440
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		String S = sc.next();
		String T = sc.next();
		sc.close();
		
		String ans = "No";
		for(int i=0;i<T.length();i++) {
			String newT = T.substring(i)  + T.substring(0,i);
			if(S.equals(newT)) {
				ans = "Yes";
				break;
			}
		}
		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


Measured memory_bytes: 21844
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

x = [a, b, c, d]
y = [b, c, d, e]

def chk(x, y):
    return(abs(x - y))


result = 'Yay!'
for i in x:
    for j in y:
        if i != j:
            if chk(i, j) > k:
                result = ':('

print(result)

Measured memory_bytes: 3064
while True:
    n=int(input())
    if n == 0: break
    ss = [ input() for _ in range(n) ]
    ts = [ s for s in ss if all ( t.find(s) < 0 for t in ss if not (t == s)) ]
    m = len(ts)

    def overlap(c, d):
        sc = ts[c]
        sd = ts[d]
        s = len(sc)
        return max ( s - i for i in range(s+1) if sd.startswith(sc[i:]) )

    ov = [ [ overlap(c,d) for d in range(m) ] for c in range(m)]

    memo = [ [ -1 for _ in range(1<<m) ] for _ in range(m) ]
    # c : the tail city
    # cs : cities to be used (bit set)
    def rec(c, cs):
        if cs == 0: return 0
        if memo[c][cs] >= 0: return memo[c][cs]
        ans= max (ov[c][d] + rec(d, cs - (1<<d)) for d in range(n) if not (((1<<d) & cs) == 0))
        memo[c][cs] = ans
        return ans

    # naive version
    # c : the tail city
    # cs : cities to be used (set)
    # def rec(c, cs):
    #     if len(cs) == 0: return 0
    #     return max (overlap(c, d) + rec(d, cs - {d}) for d in cs)
    # maxov =  max ( rec(i, { j for j in range (m) if not (j == i) } ) for i in range (m) )

    maxov =  max ( rec(i, ((1<<m) - 1) - (1<<i) ) for i in range (m) )
    ans = sum (len(t) for t in ts) - maxov
    print(ans)



Measured memory_bytes: 9452
n, a, b, c, d = map(int, input().split())
s = input()
if any(s[i]==s[i+1]=="#" for i in range(a-1, c-2)) or any(s[i]==s[i+1]=="#" for i in range(b-1, d-2)):
    print("No")
elif c<d:
    print("Yes")
else:
    if any(s[i-1]==s[i]==s[i+1]=="." for i in range(b-1, d)):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
# define rep(i,n) for(int i=0;i<n;i++)
void solve(){
    string s;
    cin>>s;
    lli sum=0;
    int n=s.length();
    for(int i=0;i<n;i++){
        sum+=s[i]-'0';
    }   
    if(sum%9==0)
    cout<<"Yes"<<endl;
    else{
        cout<<"No"<<endl;
    }
}
int main()
{
    int t;
   // cin>>t;
    t=1;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3528
N, K = map(int, input().split())
A = list(map(int, input().split()))
F = list(map(int, input().split()))

A.sort()
F.sort(reverse=True)

max_a = max(A)
max_f = max(F)

left = 0
right = max_a * max_f

while left <= right:
    x = (left + right) // 2

    sum_ = 0
    for i in range(N):
        if A[i] * F[i] > x:
            sum_ += (A[i] - int(x / F[i]))

    if sum_ > K:
        left = x + 1

    if sum_ <= K:
        right = x - 1


print(left)


Measured memory_bytes: 119500
# C - Go to School

N = int(input())
A = [int(a) for a in input().split()]
D = {}
for i in range(N):
    D[i] = A[i]
sort = sorted(D.items(), key=lambda x: x[1])
ans = [i[0] + 1 for i in sort]
print(*ans)


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

int main(){
  int N,Z,W;cin>>N>>Z>>W;
  vll a, b;
  a.push_back(Z);b.push_back(W);
  for (int i=1;i<=N;++i){ll a_;cin>>a_;a.push_back(a_);b.push_back(a_);}
  

  ll X[N+1][N];
  ll Y[N+1][N];

  for (int i=0;i<N;++i){
    X[N][i]=abs(a[N]-b[i]);Y[N][i]=abs(b[N]-a[i]);
  }
  

  for (int i=N-1;i>=1;--i){
    for (int j=0;j<i;++j){
      X[i][j]=max(Y[i+1][i], X[i+1][j]);
      Y[i][j]=min(Y[i+1][j], X[i+1][i]);
    }
  }

  cout << X[1][0] << endl;
  return 0;
}

Measured memory_bytes: 53888
def solve():
    s = input()
    n = len(s)
    mod = 2019

    reminder = [0]*mod
    pre_rem = 0

    for i in range(n):
        pre_rem = (int(s[n-i-1])*pow(10, i, mod) + pre_rem) % mod
        reminder[pre_rem] += 1

    ans = reminder[0]
    for rem_num in reminder:
        if rem_num >= 2:
            ans += (rem_num * (rem_num -1))//2
    print(ans)
    
solve()

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

using namespace std;

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

	string **DP = new string*[s.length() + 1];
	for (int i = 0; i <= s.length(); i++)
		DP[i] = new string[2];

	for (int i = 0; i <= s.length(); i++) {
		for (int j = 0; j < 2; j++) {
			DP[i][j] = "";
		}
	}

	string add;
	for (int i = 1; i <= t.length(); i++) {
		for (int j = 1; j <= s.length(); j++) {
			add = DP[j - 1][0];
			if (s[j - 1] == t[i - 1])
				add += s[j - 1];
			DP[j][1] = (((add.length() > DP[j - 1][1].length()) ? add : DP[j - 1][1]).length() > DP[j][0].length()) ?
				((add.length() > DP[j - 1][1].length()) ? add : DP[j - 1][1]) : DP[j][0];
		}
		for (int j = 0; j <= s.length(); j++)
			DP[j][0] = DP[j][1];
	}
	cout << DP[s.length()][1] << endl;
	for (int i = 0; i <= s.length(); i++)
		delete[] DP[i];
	delete[] DP;

	return 0;
}

Measured memory_bytes: 8576
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//236
	int n;
	cin>>n;
	vi a(n+1),b(n);
	for(int &i:a)cin>>i;
	for(int &i:b)cin>>i;
	ll sum = 0;
	REP(i,0,n-1) {
		int mi = min(a[i],b[i]);
		a[i]-=mi;
		b[i]-=mi;
		sum+=mi;
		mi = min(a[i+1],b[i]);
		a[i+1]-=mi;
		b[i]-=mi;
		sum+=mi;
	}
	cout<<sum;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3928
#include<iostream>
using namespace std;
const double eps=1e-13;
double p,q,a;
int n;
int ans=0;
void dfs(double pq,int s,int depth,int seki){
  if(pq>=-eps&&pq<=eps){
    ans++;
    //cout<<seki<<" "<<depth<<" "<<pq<<" "<<s<<endl;
    return;
  }
  for(int i=s;i<=a/2;i++){
    if(seki*i>a)
      break;
    if((pq-(1.0/i))>=-eps&&depth+1<=n){
      dfs((pq-(1.0/i)),i,depth+1,seki*i);
    }
  }
}
int main(){
  while(cin>>p>>q>>a>>n,p+q+a+n){
    ans=0;
    for(int i=1;i<=a/2;i++){
      if((p/q)-(1.0/i)>=-eps)
	dfs((p/q)-(1.0/i),i,1,i);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3184
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
using namespace std;

int main(){

	int N,M,table[101],ans,d,v;

	while(true){
		scanf("%d %d",&N,&M);
		if(N == 0 && M == 0)break;

		for(int i = 1; i <= M; i++)table[i] = 0;

		ans = 0;

		for(int i = 0; i < N; i++){
			scanf("%d %d",&d,&v);
			table[d] = max(table[d],v);
		}

		for(int i = 1; i <= M; i++)ans += table[i];

		printf("%d\n",ans);
	}

   return 0;
}

Measured memory_bytes: 2732
X = int(input())

if X >= 400 and X <= 599:
  print('8')
elif X >= 600 and X <= 799:
  print('7')
elif X >= 800 and X <= 999:
  print('6')
elif X >= 1000 and X <= 1199:
  print('5')
elif X >= 1200 and X <= 1399:
  print('4')
elif X >= 1400 and X <= 1599:
  print('3')
elif X >= 1600 and X <= 1799:
  print('2')
else:
  print('1')

Measured memory_bytes: 9188
#include <stdio.h>

int main()
{
    int n, x;

    while (scanf("%d %d", &n, &x))
    {
        int counts = 0;
        if (n == 0 && x == 0)
            break;
        for (int i = 1; i < n - 1; i++)
        {
            for (int j = i + 1; j < n; j++)
            {
                for (int k = j + 1; k < n + 1; k++)
                {
                    if (i + j + k == x)
                        counts++;
                }
            }
        }
        printf("%d\n", counts);
    }
}


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

int main() {
	char c;
	cin >> c;
	if( c == 'a') {
		cout << "vowel" << endl;
	}
	else if( c == 'i') {
		cout << "vowel" << endl;
	}
	else if( c == 'u') {
		cout << "vowel" << endl;
	}
	else if( c == 'e') {
		cout << "vowel" << endl;
	}
	else if( c == 'o') {
		cout << "vowel" << endl;
	}
	else {
		cout << "consonant" << endl;
	}
}


Measured memory_bytes: 256
/*
 _     _    ___  ___  __ __ 
| |   | |  |__ \|__ \/_ /_ |
| |__ | |__   ) |  ) || || |
| '_ \| '_ \ / /  / / | || |
| |_) | |_) / /_ / /_ | || |
|_.__/|_.__/____|____||_||_|

*/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

#define N  100005

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		ll n;
		cin>>n;
		ll a[n+1],b[n];
		rep(i,1,n)cin>>b[i];
		a[1]=b[1];
		a[n]=b[n-1];
		rep(i,2,n)a[i]=min(b[i-1],b[i]);
		ll ans=0;
		rep(i,1,n+1)ans+=a[i];
		cout<<ans<<endl;
	}
	return 0;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int32_t main()
{
	FIO;
	int n; cin >> n;
	string s; cin >> s;
	int ans = 0;
	mii prec[n];

	for (int i = 0; i < n; ++i)
	{
		if (i)
			prec[i] = prec[i - 1];

		prec[i][s[i]]++;
	}

	mii sufc[n];

	for (int j = n - 1; j >= 0; --j)
	{
		if (j + 1 < n)
			sufc[j] = sufc[j + 1];

		sufc[j][s[j]]++;
	}

	for (int j = 1; j + 1 < n; ++j)
	{
		for (int i = 0; i < j; ++i)
			if (j + j - i < n && s[i] != s[j] && s[i] != s[j + j - i] && s[j] != s[j + j - i])
				ans--;

		if (s[j] == 'R')
			ans += prec[j - 1]['B'] * sufc[j + 1]['G'] + prec[j - 1]['G'] * sufc[j + 1]['B'];

		if (s[j] == 'G')
			ans += prec[j - 1]['B'] * sufc[j + 1]['R'] + prec[j - 1]['R'] * sufc[j + 1]['B'];

		if (s[j] == 'B')
			ans += prec[j - 1]['G'] * sufc[j + 1]['R'] + prec[j - 1]['R'] * sufc[j + 1]['G'];
	}

	cout << ans << '\n';
	return 0;
}

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

using namespace std;
int _w;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if( c > a + b ) {
		cout << a + b + 1 + b << endl;
	} else {
		cout << c + b << endl;
	}
	return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include <vector>
using namespace std;
int main(){
	int A[3];
	int counta=0;
	int countb=0;
	cin>>A[0]>>A[1]>>A[2];
	
	for(int i=0;i<3;i++){
		if(A[i]==5)counta++;
		if(A[i]==7)countb++;
	}
	
	if(counta == 2 && countb==1)
			cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using TP = tuple<ll,ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
}
signed main(){
  init_io();
  ll n,x,t,tako=0;
  cin >> n >> x >> t;
  for(int i=0;;i++){
    if(tako<n){
      tako += x;
    }else{
      cout << t*i<<endl;
      break;
    }
  }
}


Measured memory_bytes: 3608
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

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

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

const int INF = 1001001001;

int main()
{
	int n, m;
	while(scanf("%d%d", &n, &m), n){
		vvi C(m, vi(m, INF));
		vvi T = C;
		rep(i, n){
			int a, b, c, t;
			scanf("%d%d%d%d", &a, &b, &c, &t);
			--a;
			--b;
			C[a][b] = C[b][a] = c;
			T[a][b] = T[b][a] = t;
		}
		
		rep(k, m) rep(i, m) rep(j, m){
			C[i][j] = min(C[i][j], C[i][k]+C[k][j]);
			T[i][j] = min(T[i][j], T[i][k]+T[k][j]);
		}
		
		int k;
		scanf("%d", &k);
		rep(i, k){
			int a, b, r;
			scanf("%d%d%d", &a, &b, &r);
			--a;
			--b;
			printf("%d\n", r==0 ? C[a][b] : T[a][b]);
		}
	}
	return 0;
}

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

int a[15];

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> a[i];
  sort(a, a + n);
  int x = 0;
  for (int i = 0; i < n - 1; i++) {
    x += a[i];
  }
  cout << (a[n - 1] < x ? "Yes" : "No") << endl;
}

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

int main()
{
    int n;
    cin>>n;
    int s=0;
    int l=n;
    while(l)
    {
        s++;
        l/=10;
    }
    if(!(s%2))
    {
        int k=9,sum=0;
        for(int i=1; i<=s/2; i++)
        {
            sum+=k;
            k*=100;
        }
        cout<<sum;
    }
    else
    {
        int k=9,sum=0;
        for(int i=1; i<=s/2; i++)
        {
            sum+=k;
            k*=100;
        }
        sum+=n-k/9+1;
        cout<<sum;
    }
    return 0;
}


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

int N = 0;
int A[3020] = {0};

int solve() {
  int ans = 0;
  for (int i = 0; i < N; i++) {
    ans += A[i] - 1;
  }
  return ans;
}

int main() {
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  printf("%d\n", solve());
  return 0;
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
F = int(input())

X=[A, B, C, D]
Y=[E, F]

k = sorted(X)
del(k[0])
l = sorted(Y)
del(l[0])
    
n = sum(k)
m = sum(l)

print(n+m)


Measured memory_bytes: 5596
#include<stdio.h>
#define MAX 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, G[MAX][MAX];

int prim(){
  int u, min, i, v;
  int d[MAX], p[MAX], color[MAX];

  for( i = 0 ; i < n ; i++ ){
    d[i] = INFTY;
    p[i] = -1;
    color[i] = WHITE;
  }

  d[0] = 0;

  while(1){
    min = INFTY;
    u = -1;
    for( i = 0 ; i < n ; i++ ){
      if( min > d[i] && color[i] != BLACK ){
	u = i;
	min = d[i];
      }   
    }
    if( u == -1 ) break;
    color[u] = BLACK;
    for( v = 0 ; v < n ; v++ ){
      if( color[v] != BLACK && G[u][v] != INFTY ){
	if( d[v] > G[u][v] ){
	  d[v] = G[u][v];
	  p[v] = u;
	  color[v] = GRAY;
	}
      }
    }
  }
  int sum=0;
  for( i = 0 ; i < n ; i++ ){
    if( p[i] != -1 ) sum += G[i][p[i]];
  }

  return sum;
}


int main(){
  int i, j, a;

  scanf("%d",&n);

  for( i = 0 ; i < n ; i++ ){
    for( j = 0 ; j < n ; j++ ){
      scanf("%d",&a);
      G[i][j] = ( a == -1 ) ? INFTY : a;
    }
  }

  printf("%d\n",prim());

  return 0;
}



Measured memory_bytes: 2052
// problem: "https://atcoder.jp/contests/abc126/tasks/abc126_f"

#include<iostream>
#include<math.h>

using namespace std;

int main()
{
    int m,k;

    cin>>m>>k;
    if(k>=pow(2,m))
        cout<<-1;
    else
    {
        int i;
        if(m==1 && k==1)
            cout<<-1;

        else if(m==0)
            cout<<0<<' '<<0;

        else if(k==0)
            for(i=0;i!=pow(2,m);i++)
                cout<<i<<' '<<i<<' ';

        else
        {
            cout<<0<<' '<<k<<' '<<0<<' ';
            for(i=pow(2,m)-1;i>=1;i--)
                if(i!=k)
                    cout<<i<<' ';

            cout<<k<<' ';

            for(i=1;i!=pow(2,m);i++)
                if(i!=k)
                    cout<<i<<' ';
        }
    }

    return 0;
}


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

int cnt(int n, int *a);
int main(void);

int cnt(int n, int *a){
    int count, i;
    count = 0;
    while(1){
        for(i=0; i<n; i++){
            if(a[i] % 2)
               return count;
            a[i] /= 2;
        }
        count++;
    }
}

int main(void){
    int n, count, ii1;
    scanf("%d", &n);
    int a[n];
    for(ii1=0; ii1<n; ii1++){
       scanf("%d", &a[ii1]);
    }
    count = cnt(n, a);
    printf("%d\n", count);

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define W(x) cout<<x<<endl;
#define Debug(x) cout<<"#DEBUG "<<x<<endl;
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    cout<<a-(a>b)<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int S = stdIn.nextInt();
		int s = S%60;
		int m = S/60%60;
		int h = S/3600;
		System.out.println(h+":"+m+":"+s);
	}
}

Measured memory_bytes: 17300
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n = int(input())
    pre_t = 0
    pre_x = 0
    pre_y = 0
    for _ in range(n):
        t, x, y = map(int, input().split())
        d_dis = abs(x - pre_x) + abs(y - pre_y)
        d_t = abs(t - pre_t)
        if d_dis > d_t:
            print('No')
            sys.exit()
        elif (d_t - d_dis) % 2 == 1:
            print('No')
            sys.exit()
        else:
            pre_t = t
            pre_x = x
            pre_y = y
    print('Yes')

if __name__ == '__main__':
    main()


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

using ll = long long;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}

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

  int cnt = 0;
  if(N[0] == '2') {
    cnt++;
  }

  if(N[1] == '2') {
    cnt++;
  }

  if(N[2] == '2') {
    cnt++;
  }

  if(N[3] == '2') {
    cnt++;
  }

  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX_H (260)

typedef struct
{
    int key;
    int parent_id;
    int left_id;
    int right_id;
} Node;

int H;
Node A[MAX_H + 1];

int main()
{
    scanf("%d", &H);
    
    for ( int i = 1; i <= H; i++ ) {
	Node node;
	int key;
	node.parent_id = (i >> 1);
	node.left_id   = (i << 1);
	node.right_id  = node.left_id + 1;
	scanf("%d", &node.key);
	A[i] = node;
    }

    for ( int i = 1; i <= H; i++ ) {
	Node node = A[i];
	printf("node %d: key = %d, ", i, node.key);
	if ( i > 1 ) {
	    printf("parent key = %d, ", A[node.parent_id].key);
	}
	if ( node.left_id <= H ) {
	    printf("left key = %d, ", A[node.left_id].key );
	}
	if ( node.right_id <= H ) {
	    printf("right key = %d, ", A[node.right_id].key);
	}

	printf("\n");
    }

    return 0;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<int> A(N);
    for (auto &x: A) cin >> x;
    int All = 0;
    for (auto &x: A) All ^= x;
    for (int i = 0; i < N; i++) {
        if (i) cout << " ";
        cout << (All ^ A[i]);
    }
    cout << "\n";
    return 0;
}

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

int main() {
  int H,W;

  cin >> H >> W;
  vector<vector<char>> vec(H,vector<char> (W));
  for(int i=0;i<H;++i){
    for(int j=0;j<W;++j){
      cin >> vec.at(i).at(j);
    }
  }

  for(int i=0;i<H;++i){
    for(int j=0;j<W;++j){
      cout << vec.at(i).at(j);
    }
    cout << endl;
    for(int j=0;j<W;++j){
      cout << vec.at(i).at(j);
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3616
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

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


Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        int W = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        _out.println(Math.max(Math.max(a - b - W, 0), Math.max(b - a - W, 0)));
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

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

int gcd(int a, int b) {
  int c=0;
  while (a%b) {
    c = a%b;
    a = b;
    b = c;
  }
  return b;
}

int main() {
  int n=0, X=0, ans=0;
  cin >> n >> X;
  
  vector<int> vec(n+1);
  
  for (int i=0; i<n; i++) {
    cin >> vec.at(i);
  }
  
  vec.at(n) = X;
  
  sort(vec.begin(), vec.end());
  
  int big=0, small=0;
  if (vec.size() > 2) {
    if (vec.at(1)-vec.at(0) > vec.at(2)-vec.at(1)) {
      big = vec.at(1)-vec.at(0);
      small = vec.at(2)-vec.at(1);
    } else {
      big = vec.at(2)-vec.at(1);
      small = vec.at(1)-vec.at(0);
    }

    ans = gcd(big, small);

    for (int i=3; i<n+1; i++) {
      if (vec.at(i)-vec.at(i-1) > ans) ans = gcd(vec.at(i)-vec.at(i-1), ans);
      else ans = gcd(ans, vec.at(i)-vec.at(i-1));
    } 
  } else {
    ans = vec.at(1) - vec.at(0);
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 640
def getSum(n):
    sum1 = 0
    while(n > 0):
        sum1 += int(n%10)
        n = int(n/10)
    return sum1
n = int(input())
dig_sum = getSum(n)
if (dig_sum) == 1:
    if n == 1:
        print(1)
    else:
        print(10)
else:
    print(dig_sum)


Measured memory_bytes: 2940
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
typedef long long LL;

int main() {
  int X; cin >> X;
  if (X == 3 || X == 5 || X == 7) cout << "YES" << endl;
  else                            cout << "NO" << endl;
}


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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

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

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

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll ans = (N / (A+B)) * A + min(N % (A + B), A);

  cout << ans << endl;
};


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

int n, k, a, mx;

int f(int p, int q) {
	if (q == 0) return p;
	return f(q, p % q);
}

int main()
{
	int t;
	cin >> n >> k;
	while (n--) {
		scanf("%d", &t);
		a = f(a, t);
		mx = max(mx, t);
	}
	if (mx < k || k % a) cout << "IMPOSSIBLE";
	else cout << "POSSIBLE";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<algorithm>
#include<string.h>
using namespace std;

struct Node { int key; Node *parent, *left, *right; };

Node *root, *NIL;

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->parent = NIL;
  z->left = NIL;
  z->right = NIL;
  while (x != NIL) {
    y = x;
    if (z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;

  if (y == NIL) {
    root = z;
  } else if (z->key < y->key) {
    y->left = z;
  } else {
    y->right = z;
  }
}

void Preorder(Node *p) {
  printf(" %d", p->key);
  if (p->left != NIL) Preorder(p->left);
  if (p->right != NIL) Preorder(p->right);
}

void Inorder(Node *p) {
  if (p->left != NIL) Inorder(p->left);
  printf(" %d", p->key);
  if (p->right != NIL) Inorder(p->right);
}

void Postorder(Node *p) {
  if (p->left != NIL) Postorder(p->left);
  if (p->right != NIL) Postorder(p->right);
  printf(" %d", p->key);
}

int main() {
	int n;
  scanf("%d", &n);

  char str[12];
  int key;
  for ( int i = 0; i < n; i++ ) {
    scanf("%s", str);
    if ( strcmp(str, "insert") == 0 ) {
      scanf("%d", &key);
      insert(key);
    } else if ( strcmp(str, "print") == 0 ) {
      Inorder(root);
      printf("\n");
      Preorder(root);
      printf("\n");
    }
  }

  return 0;
}



Measured memory_bytes: 26144
#include<iostream>
using namespace std;
int main(){
    int H,W; 
    while (true){
        cin >> H >> W;
        if(H != 0 || W != 0){
            for(int i = 1; i <= H; i++){
                if(i % 2 == 1){
                    for(int j = 1; j <= W; j++){
                        if(j % 2 == 1){
                            cout << '#';
                        } else if(j % 2 == 0) {
                            cout << '.';
                        }
                    }
                } else if(i % 2 == 0) {
                    for(int j = 1; j <= W; j++){
                        if(j % 2 == 1){
                            cout << '.';
                        } else if(j % 2 == 0) {
                            cout << '#';
                        }
                    }
                }
                cout << endl;
            }
            cout << endl;
        } else {
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3100
IDENTIFICATION DIVISION.
        PROGRAM-ID. AtCoder.
      
        ENVIRONMENT DIVISION.
      
        DATA DIVISION.
        WORKING-STORAGE SECTION.
        01 INP PIC X(100).
        01 A PIC 9(15).
        01 B PIC 9(15).
      	01 C PIC 9(15).
      	01 E PIC 9(15).
      	01 D PIC 9(15).
      	01 X PIC 9(15).
      	01 Y PIC 9(15).
      	01 W PIC 9(15).
      	01 F PIC ZZZZZZZZZ9.
      	01 t PIC 9(15).
	    01 temp1 PIC 9(15).
        01 temp2 PIC 9(15).
      	01 temp3 PIC 9(15).
        01 N PIC 9(15).
        PROCEDURE DIVISION.
      	MAIN.
      		ACCEPT INP.
			PERFORM VARYING temp1 FROM 1 BY 1
            UNTIL INP(temp1:1) = SPACE
        	END-PERFORM.
        	SUBTRACT 1 FROM temp1.
        	MOVE INP(1:temp1) TO A.
        	ADD 2 TO temp1.
        	PERFORM VARYING temp2 FROM temp1 BY 1
            UNTIL INP(temp2:1) = SPACE
        	END-PERFORM.
        	COMPUTE N = temp2 - temp1.
        	MOVE INP(temp1:N) TO B.
      		ADD 1 TO temp2.
      		PERFORM VARYING temp3 FROM temp2 BY 1
            UNTIL INP(temp3:1) = SPACE
        	END-PERFORM.
        	COMPUTE N = temp3 - temp2.
        	MOVE INP(temp2:N) TO C.
      		COMPUTE D = A + B + C.
      		IF A >= B AND A >= C THEN
      			COMPUTE E = D - A
      		ELSE IF B >= C AND B >= A THEN
      			COMPUTE E = D - B
      			ELSE
      				COMPUTE E = D - C
      			END-IF
      		END-IF.
      		MOVE E to F.
      		DISPLAY F.
		STOP RUN.

Measured memory_bytes: 384
#include<iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include <stdlib.h>
#include<string>
#include<queue>
#include<algorithm>
#include<math.h>
using namespace std;
int gcd(int x,int y){
	int r;
	if(x%y==0){
		return y;
	}else{
		r=x%y;
		gcd(y,r);
	}
}
int main(){
	int ans,N,hp[100000];
	cin>>N;
	for(int i=0;i<N;i++){
		cin>>hp[i];
	}
	ans=hp[0];
	for(int i=1;i<N;i++){
		ans=gcd(ans,hp[i]);	
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 640
//
import java.math.*;
import java.util.*;
import java.io.*;
  
public class Main { 
  
    static BufferedReader in;
    static PrintWriter out = new PrintWriter(System.out);
    static String file = "../in";
    static int test = 10; // 0 for local testing, 1 for std input
    static int inf = 1_000_000, mod = 1_000_000_007;

    void swap(int[]ary, int i, int j)
    {
        int t = ary[i];
        ary[i] = ary[j];
        ary[j] = t;
    }
    
    String[] split() throws Exception
    {
        return in.readLine().split(" ");
    }

    int readInt() throws Exception
    {
        return Integer.valueOf(in.readLine());
    }

    int[] toIntArray() throws Exception
    {
        String[] sp = split();
        int n = sp.length;
        int[] ary = new int[n];
        for(int i = 0; i < n; i++) ary[i] = Integer.valueOf(sp[i]);
        return ary;
    }

    String reverse(String str)
    {
        return new StringBuilder(str).reverse().toString();
    }

    long choose(int n, int a)
    {
        long nf = 1;
        for(int i = 1; i <= a; i++)
        {
            nf *= i;
            nf %= mod;
            nf *= pow(i, mod - 2);
            nf %= mod;
        }
        return nf;
    }

    long pow(int a, int pow)
    {
        return pow(0L + a, pow);
    }
    
    long pow(long a, int pow)
    {
        long res = 1;
        while(pow > 0)
        {
            if(pow % 2 != 0) {
                res *= a;
                res %= mod;
            }
            a = a * a;
            a %= mod;
            pow /= 2;
        }

        return res;
    }    

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

    public static void main(String[] args) throws Exception
    {
        int _k = Integer.valueOf("1");
        if(test > 0) in = new BufferedReader(new InputStreamReader(System.in));
        else in = new BufferedReader(new FileReader(file));
        if(test < 0) {String[] str = in.readLine().split(" ");}
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
/***********************************************************************/
        // System.out.println((-100 + 0) / 2);

        new Main().a();
        out.flush();
    }

    void a() throws Exception
    {
        int[] ary = toIntArray();
        int n = ary[0], k = ary[1];
        
        ary = toIntArray();        

        Arrays.sort(ary);
        
        int gcd = ary[0];


        for(int a : ary) 
        {
            gcd = gcd(a, gcd);
        }


        if(k % gcd == 0 && k <= ary[n - 1]) out.println("POSSIBLE");
        else out.println("IMPOSSIBLE");
    }

    int find(int[] f , int p)
    {
        int fp = f[p];
        while(fp != f[fp]) fp = f[f[fp]];
        return f[p] = fp;
    }
}


Measured memory_bytes: 46548
n,m,c = map(int,input().split())
b = list(map(int,input().split()))
count = 0
for i in range(n):
    a = list(map(int,input().split()))
    p = c
    for j in range(m):
        p += a[j]*b[j]
    if p > 0:
        count += 1
print(count)

Measured memory_bytes: 3060
using System;

namespace AtCoder{
    public static class AtCoder{
        public static void Main(){
            string s = Console.ReadLine();
            string t = Console.ReadLine();

            int len = s.Length;
            if(s == t.Substring(0, len)){Console.WriteLine("Yes");}
            else{Console.WriteLine("No");}
        }
    }
}

Measured memory_bytes: 25900
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <deque>
using namespace std;
typedef long long int ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    while(1){
        string s; cin >> s;
        if(s=="-")break;
        int n; cin >> n;
        while(n--){
            int x; cin >> x;
            s=s.substr(x)+s.substr(0,x);
        } 
        cout << s << endl;
    }
}


Measured memory_bytes: 3200
import bisect

N, M = map(int, input().split())
A = list(map(int, input().split()))
A.sort()

# ある値以上のAiがいくつあるかの情報を累積和で保持
num_A_or_more = [0]*(10**5)
for a in A:
  num_A_or_more[a-1] += 1


for i in range(1, 10**5):
  j = 10**5 - i
  num_A_or_more[j-1] += num_A_or_more[j]


# x以上となる手の組み合わせがM種類以上あるかどうかを判定
def check(x):
  count = 0
  for a in A:
    idx = max(x-a-1, 0)
    if idx >= 10**5:
      continue
    count += num_A_or_more[idx]
  
  return count>=M


# 2分探索でM種類以上の手の組み合わせがある満足度の最大値を求める
left = 0
right = 2*10**5 + 1
mid = (left + right) // 2
while right - left > 1:
  if check(mid):
    left = mid
  else:
    right = mid
    
  mid = (left + right)//2

# これがM種類以上の手の組み合わせがある満足度の最大値
x = left


# 降順に並べなおして累積和を求めておく
rev_A = A[::-1]
accum_A = [rev_A[0]]
for i, a in enumerate(rev_A):
  if i == 0:
    continue
  accum_A.append(accum_A[-1] + a)

ans = 0
count = 0
surplus = 2*10**5 # M種類を超えた場合は、一番小さくなる握手の組を最後に削る
for ai in rev_A:
  idx = bisect.bisect_left(A, x-ai)
  if idx == N:
    break
  ans += (N-idx)*ai + accum_A[N-idx-1]
  count += N - idx
  surplus = min(surplus, ai+A[idx])


print(ans - (count-M)*surplus)

Measured memory_bytes: 16996
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=3005,M=1e9+7;
int f[N][N],a[N],g[N][N],n,Q,x,y;
int ksm(int x,int y){
	if (!y)return 1;
	int z=ksm(x,y/2);
	z*=z;z%=M;
	if (y&1)z*=x;
	return z%M;
}
signed main(){
	scanf("%lld%lld",&n,&Q);
	for (int i=1;i<=n;i++)scanf("%lld",&a[i]);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			if (a[i]>a[j])f[i][j]=1;
	int K=ksm(2,Q),Inv=ksm(2,M-2);		
	while (Q--){
		scanf("%lld%lld",&x,&y);
		g[x][y]=f[y][x];
		g[y][x]=f[x][y];
		f[y][x]=(f[y][x]*Inv+g[y][x]*Inv)%M;
		f[x][y]=(f[x][y]*Inv+g[x][y]*Inv)%M;
		for (int i=1;i<=n;i++)
			if (i!=x&&i!=y)g[x][i]=f[y][i],g[i][x]=f[i][y];
		for (int i=1;i<=n;i++)
			if (i!=x&&i!=y)g[y][i]=f[x][i],g[i][y]=f[i][x];
		for (int i=1;i<=n;i++)
			if (i!=x&&i!=y){
				f[x][i]=(g[x][i]*Inv+f[x][i]*Inv)%M;
				f[y][i]=(g[y][i]*Inv+f[y][i]*Inv)%M;
				f[i][x]=(g[i][x]*Inv+f[i][x]*Inv)%M;
				f[i][y]=(g[i][y]*Inv+f[i][y]*Inv)%M;
			}
		for (int i=1;i<=n;i++)g[i][x]=g[i][y]=g[x][i]=g[y][i]=0;
	}
	int ans=0;
	for (int i=1;i<n;i++)
		for (int j=i+1;j<=n;j++)(ans+=f[i][j])%=M;
	printf("%lld\n",ans*K%M);	
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef tuple<int,int,int> iii;
typedef vector<iii> viii;

#define umap unordered_map
#define uset unordered_set
#define pb push_back
#define LSOne(x) (x & (-x))
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()

const int iinf = 1e9+7;
const ll inf = 1e18+7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int n,k; cin >> n >> k;
    vi v(n);
    vector<bool> dp(k+1,false);
    for (auto& i : v) cin >> i;
    for (int i = 0; i <= k; ++i)
        for (auto& x : v) {
            if (i >= x && !dp[i-x]) dp[i] = true;
        }
    if (dp[k]) cout << "First" << endl;
    else cout << "Second" << endl;
}


Measured memory_bytes: 384
import bisect
import sys

sys.setrecursionlimit(10000)
INF = float('inf')

N, Q = list(map(int, next(sys.stdin).split()))
STX = [list(map(int, next(sys.stdin).split())) for _ in range(N)]
D = [int(next(sys.stdin)) for _ in range(Q)]

ans = [-1] * Q
nexts = [-1] * Q

for s, t, x in sorted(STX, key=lambda stx: (stx[2], stx[1])):
    # [lo, hi) に出発した人は x で止まる
    # x の小さい順にソート済みなのでここで確定
    lo = max(0, bisect.bisect_left(D, s - x))
    hi = min(len(D), bisect.bisect_left(D, t - x))

    p = lo
    while p < hi:
        if nexts[p] == -1:
            ans[p] = x
            nexts[p] = hi
            p += 1
        else:
            prev = p
            p = nexts[p]
            nexts[prev] = hi

print('\n'.join(map(str, ans)))


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

using namespace std;

#define REP(i,m) for(int i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define INF 1000000001
#define INFL (1LL << 60)
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define ll long long int
#define P pair<ll, ll>

int main() {
  bool x[1001] = { };
  FOR(i, 1, 32) x[i*i] = true;
  FOR(i, 1, 11) x[i*i*i] = true;
  FOR(i, 1, 4) x[i*i*i*i*i] = true;
  x[128] = true;
  int p;
  cin >> p;
  while(!x[p]) p--;
  cout << p << endl;
  return 0;
}


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

int main(){
  int n,m;
  cin >> n >> m;
  int a[m][2];
  for(int i=0;i<m;i++){
    cin >> a[i][0] >> a[i][1];
  }
  int minimum = 1;
  int maximum = n;
  for(int i=0;i<m;i++){
    minimum = max(minimum,a[i][0]);
    maximum = min(maximum,a[i][1]);
  }
  if(minimum > maximum){
    cout<< 0;
  }else{
    cout << maximum-minimum+1;
  }
}


Measured memory_bytes: 1024
a, b = map(int, input().split())
y, x = 1, 1 
moves = ((1, 0), (0, 1), (0, -1), (-1, 0), (-1, -1), (1, -1), (-1, 1), (1, 1))

if a <= b:
    c1, c2 = '.', '#'
    res = [['.']*100 for _ in range(100)]
else:
    c1, c2 = '#', '.'
    a, b = b, a
    res = [['#']*100 for _ in range(100)]

while a > 1 and b > 1:
    res[y][x] = c1
    for dy, dx in moves:
        res[y+dy][x+dx] = c2

    x += 4
    if x > 98:
        y += 4
        x = 1

    a -= 1
    b -= 1

    
for i in range(b):
    res[y][x] = c2
    x += 2
    if x > 98:
        y += 4
        x = 1

print(100, 100)
for h in range(100):
    print(''.join(res[h]))


Measured memory_bytes: 65460
#include <bits/stdc++.h>
   
#define ll long long
#define F first
#define S second
#define pb push_back
using namespace std;
   
void data() {
    #ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
} 
const int N = 1e6 + 200;

int main ()
{
    data();
    int n;
    cin >> n;
    ll a[n + 1];
    ll x = 0;
    for (int i = 1; i <= n; i++)
    {
    	cin >> a[i];
    	x ^= a[i];
    }
    for (int i = 1; i <= n; i++)
    {
    	cout << (x ^ a[i]) << " ";
    }

}


Measured memory_bytes: 5020
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		boolean ok = true;
		List<Integer> x = new ArrayList<>();
		List<Integer> y = new ArrayList<>();
		for(int i = 1; i <= N; i++) {
			int a = sc.nextInt();
			if(a != i) {
				x.add(i);
				y.add(a);
			}
		}
		if(x.size() > 2)
			ok = false;
		if(x.size() == 2)
			if(!y.contains(x.get(0)) || !y.contains(x.get(1)))
				ok = false;
		System.out.println(ok ? "YES" : "NO");

	}

}


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

using namespace std;

int main() {
    long h;
    cin >> h;
    long sum = 0;
    long monster = 1;
    while (h != 1){
        sum += monster;
        h /= 2;
        monster *= 2;
    }
    sum += monster;
    cout << sum << endl;
    
}

Measured memory_bytes: 256