akhauriyash/Code-Regression huggingface dataset:
function permutation(n,k){
    var ret=[[]];
    var next;
    for(var i=0;i<k;i++){
        next=[];
        ret.forEach(e=>{
            for(var k=1;k<=n;k++){
                if(!e.includes(k)){
                    next.push(e.concat([k]));
                }
            }
        });
        ret=next.concat([]);
    }
    return ret;
}

function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const N=input[0].split(' ')[0]-0;
  var a,b
  permutation(N,N).forEach((e,i)=>{
    if(e.join(' ')===input[1]){
      a=i;
    }
    if(e.join(' ')===input[2]){
      b=i;
    }
  });
  console.log(Math.abs(a-b));
}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  



  


Measured memory_bytes: 62968
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = 1e9 + 1;

int main() {
  string s;
  cin >> s;
  
  int cnt = 0;
  for(int i = 0; i < s.size()/2; i++) {
    if(s[i] != s[s.size()-i-1]) cnt++;
  }

  cout << cnt << endl;
}

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

int main(){
      int n,d,x;cin >> n >> d >> x;
      int arr[n + 5];
      int ans = 0;
      for(int i = 0;i < n;i++)cin >> arr[i];
      for(int i = 1;i <= d;i++){
            for(int j = 0;j < n;j++){
                  if((i - 1) % arr[j] == 0)ans++;
            }
      }
      cout << ans + x;
}

Measured memory_bytes: 256
#include <iostream>

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

    if (N == 0) {
        std::cout << 0 << std::endl;
        return 0;
    }

    std::string bits = "";
    int rest = N;
    while (rest != 0) {
        if (rest % 2 == 0) {
            bits = "0" + bits;
            rest = rest / -2;
        } else {
            bits = "1" + bits;
            rest = (rest - 1) / -2;
        }
    }
    std::cout << bits << std::endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
	static public int ans100 = -1;
	static public int ans10 = -1;
	static public int ans1 = -1;
	public static void main(String[] args)
	{
		ans100 = -1;
		ans10 = -1;
		ans1 = -1;
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();

		String[] substr = str.split(" ", 0);
		int n = Integer.parseInt(substr[0]);
		int m = Integer.parseInt(substr[1]);
		int ans = -1;
		if (m == 0) {
			if (n == 3) ans = 100;
			if (n == 2) ans = 10;
			if (n == 1) ans = 0;
			System.out.println(ans);
			return;
		}
		for (int i=0; i<m; i++) {
			str = scan.nextLine();
			substr = str.split(" ", 0);
			int s= Integer.parseInt(substr[0]);
			int c = Integer.parseInt(substr[1]);
			if (n > 1 && s == 1 && c == 0) {
				System.out.println(ans);
				return;
			}
			if (n == 1 && s == 1 && c == 0) {
				System.out.println(0);
				return;
			}

			if (s ==1) {
				if (n == 3) {
					if (check100(c) == -1) return;
				}
				if (n == 2) {
					if (check10(c) == -1) return;
				}
				if (n == 1) {
					if (check1(c) == -1) return;
				}

			}
			if (s ==2) {
				if (n == 3) {
					if (check10(c) == -1) return;
				}
				if (n == 2) {
					if (check1(c) == -1) return;
				}
				if (n == 1) {
					System.out.println(ans);
					return;
				}
			}
			if (s ==3) {
				if (n == 3) {
					if (check1(c) == -1) return;
				}
				if (n == 2) {
					System.out.println(ans);
					return;
				}
				if (n == 1) {
					System.out.println(ans);
					return;
				}

			}
		}
		scan.close();
		if (n == 3 && ans100 == -1) ans100=1;
		if (n == 2 && ans10 == -1) ans10=1;
		if (n == 1 && ans1 == -1) ans1=1;
		if (n > 2 && ans10 == -1) ans10=0;
		if (n > 1 && ans1 == -1) ans1=0;

		if (n == 3) {
			ans = ans100 * 100 + ans10 *10 +ans1;
		}
		if (n == 2) {
			ans = ans10 *10 +ans1;
		}
		if (n == 1) {
			ans = ans1;
		}
		System.out.println(ans);
	}

	static int check100(int c) {
		if (ans100 == -1) {
			ans100 = c;
		} else if (ans100 != c) {
			System.out.println(-1);
			return -1;
		}
		return 0;
	}
	static int check10(int c) {
		if (ans10 == -1) {
			ans10 = c;
		} else if (ans10 != c) {
			System.out.println(-1);
			return -1;
		}
		return 0;
	}
	static int check1(int c) {
		if (ans1 == -1) {
			ans1 = c;
		} else if (ans1 != c) {
			System.out.println(-1);
			return -1;
		}
		return 0;
	}
}


Measured memory_bytes: 22100
#include <cmath>
#include <cstdio>
double x, y, a; int s, t;
int main() {
	while(~scanf("%d,%d", &s, &t)) {
		x += s * cos(a);
		y += s * sin(a);
		a += t / 180.0 * 3.14159265358979;
	}
	printf("%d\n%d\n", (int)y, (int)x);
	return 0;
}

Measured memory_bytes: 3108
using System;

class MainClass {
    static void Main() {
        string[] s = Console.ReadLine().Split(' ');
        int a = int.Parse(s[0]);
        int b = int.Parse(s[1]);
        if (a <= 8 && b <= 8)Console.WriteLine("Yay!");
        else Console.WriteLine(":(");
    }
}

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

int finding(int n) {
    int sum = 0;
    while ( n > 0) {
        sum += n % 10;
        n /= 10;    
    }
    return sum;
}

int main() {
    int N,A,B;
    cin >> N >> A >> B;
    int total = 0;
    for ( int i = 1 ; i <= N; ++i) {
        int sum = finding(i);
        if(sum >= A && sum <= B) total += i;
    }
    cout << total << endl;;

}

Measured memory_bytes: 256
a = int(input())
b = input()

t = ["SS","SW","WS","WW"]
l = []
for j in range(4):
  if t[j][0] == "S" and b[0] == "o":
    l.append("S" if t[j][1] == "S" else "W")
  elif t[j][0] == "S" and b[0] == "x":
    l.append("S" if t[j][1] == "W" else "W")
  elif t[j][0] == "W" and b[0] == "x":
    l.append("S" if t[j][1] == "S" else "W")
  elif t[j][0] == "W" and b[0] == "o":
    l.append("S" if t[j][1] == "W" else "W")
  for i in range(1,a):
    if t[j][i] == "S" and b[i] == "o":
      t[j]+="S" if t[j][i-1] == "S" else "W"
    elif t[j][i] == "S" and b[i] == "x":
      t[j]+="S" if t[j][i-1] == "W" else "W"
    elif t[j][i] == "W" and b[i] == "x":
      t[j]+="S" if t[j][i-1] == "S" else "W"
    elif t[j][i] == "W" and b[i] == "o":
      t[j]+="S" if t[j][i-1] == "W" else "W"
    else:
      t[j] = -1
      break
s = -1
if all(i == -1 for i in t):
  print(-1)
else:
  for j,k in enumerate(t):
    # print(j,k)
    # if k !=-1:
    #   if t[j][-1] == "S" and b[-1] == "o" and t[j][0] == "S":
    #     s = t[j]
    #   elif t[j][-1] == "S" and b[-1] == "x" and t[j][0] == "W":
    #     s = t[j]
    #   elif t[j][-1] == "W" and b[-1] == "x" and t[j][0] == "S":
    #     s = t[j]
    #   elif t[j][-1] == "W" and b[-1] == "o" and t[j][0] == "W":
    #     s = t[j]
    if k !=-1:
      if k[-1] ==  k[0] :
        if k[-2] ==l[j]:
          s = k
  if s == -1:print(-1)
  else:print(s[:-1])
  

Measured memory_bytes: 3924
#[全部作る]
s = input() 
S = [_ for _ in s]
N = len(S)-1
ans_lis = []
pra_lis = []
calis = []
for x in range(2**N):
    lis = [''] * (N)
    for y in range(N):
        if((x >> y) & 1):
            lis[N-1-y] = "+"
    pra_lis.append(lis)
for z in pra_lis:
    z.append('')
    for x in range(len(S)):
        calis.append(S[x])
        calis.append(z[x])
 #   print('calis',calis)
    calis = []
    ans_lis.append(calis)
ans = 0
for l in ans_lis:
    ans_num = '0'
    for r in l:
        if r == '':
            pass
        elif r == '+':
            ans += int(ans_num)
         #   print(ans_num)
            ans_num = '0'
        else:
            ans_num += r
        #print(ans_num)
    ans += int(ans_num)
print(ans + int(s))

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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

ll gcd(ll x, ll y)
{
  if (x % y == 0)
  {
    return y;
  }
  return gcd(y, x % y);
}

int main()
{
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A+B > C+D){
    cout << "Left" << endl;
  }else if (A+B < C+D){
    cout << "Right" << endl;
  }else{
    cout << "Balanced" << endl;
  }
  return 0;
}

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

#define LLINF (1LL<<60)
typedef unsigned long long ll;

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)
#define mod 1000000007

//C++14 (GCC 5.4.1)

ll powmod(ll x,int n){
    ll ans=1,y=x;
    int k=n;
    while(k){
        if(k&1) ans= (ans*y)%mod;
        y=(y*y)%mod;
        k/=2;
    }
    return ans;
}
#define inv(x) powmod(x,mod-2)
#define needF 2000
ll f[needF+1], rf[needF+1];//f[x]=x!
void initF() {
    f[0] = 1;
    repd(i,1,needF+1) f[i]=( f[i-1]*i ) % mod;
    rf[needF] = inv(f[needF]);
    rrepd(i, needF-1, 0) rf[i] = (rf[i+1] * (i+1)) % mod;
}
ll nCk(int n, int k) {
    if(k==0||n==k)return 1;
    if(n<k)return 0;
    ll bc = ( rf[n-k]*rf[k] ) % mod;
    return (f[n]*bc) % mod;
}
#define nHk(n,k) nCk((n)+(k)-1,k)


int main() {
    int N,K;
    cin >>N>>K;
    ll ans;
    initF();
    repd(i,1,K+1){
        cout<< (nCk(N-K+1,i)*nCk(K-1,i-1))%mod<<endl;
    }
    
    return (0);
}

Measured memory_bytes: 256
def main():
    n, a, b = map(int, input().split())
    h = [int(input()) for _ in range(n)]
    low, high = 0, 1000000000000000000
    while low < high:
        mid = (low + high) // 2
        tmp = 0
        for _h in h:
            if _h > mid * b:
                tmp += (_h - mid * b + a - b - 1) // (a - b)
        if tmp > mid:
            low = mid + 1
        else:
            high = mid
    print(low)


if __name__ == '__main__':
    main()


Measured memory_bytes: 7072
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int D, N;
	cin >> D >> N;
	int T = 1;
	rep(i, D) T *= 100;

	if (N != 100) cout << N * T << endl;
	else cout << 101 * T << endl;

    return 0;
}


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

const int maxN=1e9;

int minN=maxN;
int *q;
int *k;
int *beg;

int64_t routes(int *p,int *k)
{	
	if(p==q-1){return abs(*q);}
	if(p==q){ return 0;}

	int64_t cost;
	if(*k!=-1)cost=*k;
	else
	{
		int64_t cost1=abs(*(p+1))+routes(p+1,k+1);
		int64_t cost2=abs(*(p+1)+*(p+2))+routes(p+2,k+2);
		cost=min(cost1,cost2);
		*k=cost;
	}
		
	
	
	//if(ind!=-1)*(k+ind)=cost;

	return cost;
}
	
	
	
	
	

int main()
{

int n;
cin>>n;


int arr[n];
int dif[n-1];

int *p=&dif[0];
q=p+n-2;

int costs[n]={-1};
k=&costs[0];
for(int i=0;i<n;i++)costs[i]=-1;
beg=k;


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


	if(i!=0)dif[i-1]=arr[i]-arr[i-1];

	
}


cout<<routes(p-1,k);

return 0;
}


Measured memory_bytes: 9424
#include <stdio.h>

int main(void)
{
	int s, b, i, c;
	
	while (scanf("%d", &b) != EOF){
		s = 0;
		c = 600 / b;
		for (i = 0; i < c; i++)
		{
			s += b * b * i * b * i;
		}
		printf("%d\n", s);
	}
	return (0);
}

Measured memory_bytes: 596
#include "bits/stdc++.h"
using namespace std;
#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
typedef long long ll;

const int INF = 1e9;
const long long LLINF = 1e18;

ll n;
ll sum;
ll ans=0;
map<ll, ll> cnt;
int main() {
    cin>>n;
    cnt[0]=1;
    REP(i, 1, n+1){
        ll a;
        cin>>a;
        sum+=a;
        ans+=cnt[sum];
        cnt[sum]++;
    }
    cout<<ans<<endl;
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int X,A,B;
    cin>>X>>A>>B;
    X -= A;
    int n = X/B;
    X -= n*B;
    cout<<X<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
int main(){
  int n;cin>>n;
  vector<double>x(n),y(n);
  double ans=0;
  for(int i=0;i<n;i++)
  {
    cin>>x.at(i)>>y.at(i);
  }
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<n;j++)
    {
      if(i!=j)
      {
        ans+=sqrt((x.at(i)-x.at(j))*(x.at(i)-x.at(j))+(y.at(i)-y.at(j))*(y.at(i)-y.at(j)));
      }
    }
    
  }
  cout<<std::fixed<<std::setprecision(10)<<ans/n;
}

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

using namespace std;

#define N 300000

const int mod=1000000007;
int n,m,p,a[N],b[N],bit[N],f[N],x[N],y[N];
struct node{
	int x,y;
	node(int x=0,int y=0):x(x),y(y){}
	bool operator < (const node &p) const{
		return x<p.x||(x==p.x&&y>p.y);
	}
	bool operator != (const node &p) const{
		return x!=p.x||y!=p.y;
	}
}c[N];

void upd(int &x,int y){x=(x+y)%mod;}

void add(int k,int x){
	for (;k<=p;k+=k&(-k)) upd(bit[k],x);
}

int qry(int k){
	int ret=0;
	for (;k;k-=k&(-k)) upd(ret,bit[k]);
	return ret;
}

int main(){
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;++i) scanf("%d",a+i);
	for (int i=1;i<=m;++i) scanf("%d",b+i);
	for (int i=1,j=1;i<=n;++i){
		for (;j<=m&&a[i]>b[j];++j);
		if (j>1&&j<=m){
			c[++p]=node(a[i]-b[j-1],b[j]-a[i]);
			x[p]=a[i]-b[j-1];
			y[p]=b[j]-a[i];
		}
	}
	sort(x+1,x+p+1); sort(y+1,y+p+1);
	for (int i=1;i<=p;++i)
		c[i]=node(lower_bound(x+1,x+p+1,c[i].x)-x,lower_bound(y+1,y+p+1,c[i].y)-y);
	sort(c+1,c+p+1);
	for (int i=1;i<=p;++i)
		if (c[i]!=c[i-1]) add(c[i].y,qry(c[i].y-1)+1);
	printf("%d\n",(qry(p)+1)%mod);
	
	return 0;
}
			

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

int main()
{
    long long N, D;
    cin >> N >> D;
    D *= D;

    long long p, q;
    int ans = 0;

    for(int i = 0; i < N; i++)
    {
        cin >> p >> q;
      	long long pq = (p * p) + (q * q);
        if( pq <= D) ans ++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3532
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
vector<int> v1,v2;

int main(){
	int n,m,p;
	int i,j,k;
	int a,b,c;
	int s=1e9;
	cin>>n>>m>>p;
	for(i=0;i<n;i++){
		cin>>a;
		v1.push_back(a);
	}
	for(i=0;i<m;i++){
		cin>>a;
		v2.push_back(a);
	}
	for(i=0;i<p;i++){
		cin>>a>>b>>c;
		a--,b--;
		a=v1[a]+v2[b]-c;
		if(s>a)s=a;
	}
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	a=v1[0]+v2[0];
	if(s>a)s=a;
	cout<<s<<endl;
}

Measured memory_bytes: 1400
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String W = sc.next();
        String[] T = new String[10000];
        int i = 0;
        do{
            T[i] = sc.next();
            if(T[i].equals("END_OF_TEXT")){
                break;
            }
            T[i] = T[i].toLowerCase();
            i++;
        } while (true);
        int wordCount = 0;
        for (int j = 0; j < i; j++) {
            if (W.equals(T[j])) {
                wordCount++;
            }
        }
        System.out.println(wordCount);
        sc.close();
    }   
}


Measured memory_bytes: 26420
#include <bits/stdc++.h>
#define lli long long int
#define vec2 vector<vector<lli>> 
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define FRE freopen("explicit.in","r",stdin);freopen("explicit.out","w",stdout)
#define mp make_pair
#define pll pair <lli,lli>
#define vll vector <lli>
#define pq2 priority_queue<pair<lli,lli>>
#define f first
#define s second
#define pb push_back
#define pf push_front
#define minii LLONG_MAX
#define ld long double 
const long double pi = 3.1415926535898;
#define dec greater<lli>()
//const lli mod=1000000007;
const lli mod=100000000;
using namespace std;

int main()
{
    fio;
    lli n;
    cin>>n;
    lli a[n];
    for (int i=1;i<=n;i++)
    cin>>a[i];
    lli dp[3005][3005];
    memset(dp,0,sizeof(dp));
    for (int i=n;i>=1;i--)
    {
        for (int j=i;j<=n;j++)
        {
            dp[i][j]=max(a[i]-dp[i+1][j],a[j]-dp[i][j-1]);
        }
    }
    cout<<dp[1][n];
    return 0;
}


Measured memory_bytes: 74196
//abc146_a.cpp
//Sat Nov 30 19:01:15 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	if (s=="SUN"){
		cout << 7 << endl;
	}else if (s=="MON"){
		cout << 6 << endl;
	}else if (s=="TUE"){
		cout << 5 << endl;
	}else if (s=="WED"){
		cout << 4 << endl;
	}else if (s=="THU"){
		cout << 3 << endl;
	}else if (s=="FRI"){
		cout << 2 << endl;
	}else if (s=="SAT"){
		cout << 1 << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
#define ll long long
using namespace std;
void deb(){
    cout<<"a";
    exit(0);
}
ll fp(ll a){return a*a*a*a*a;}
int main(){
    ll x;
    cin>>x;
    rep(a,-120,121){
        rep(b,-120,121){
            if(fp(a)-fp(b)==x){
                cout<<a<<" "<<b<<endl;
                return 0;
            }
        }
    }
}

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

#ifdef DEBUG
#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))

#define LOGM(msg) (cerr << (msg))

#define LOGV(vec, sep) {                                        \
    cerr << #vec << " =";                                       \
    for (const auto& v : (vec)) cerr << " " << v;               \
    cerr << (sep); }

#define LOGA(arr, N, sep) {                                     \
        cerr << #arr << " =";                                   \
        for (int i = 0; i < N; ++i) cerr << " " << (arr)[i];    \
        cerr << (sep); }

#define LOGA2(arr, N, M, sep) {                                 \
        cerr << #arr << " =\n";                                 \
        for (int i = 0; i < N; ++i) {                           \
            for (int j = 0; j < M; ++j)                         \
                cerr << (arr)[i][j] << " ";                     \
            cerr << endl;                                       \
        } cerr << (sep); }
#else
#define LOG(var, sep)
#define LOGM(msg)
#define LOGV(vec, sep)
#define LOGA(arr, N, sep)
#define LOGA2(arr, N, M, sep)
#endif

using namespace std;
using ll = long long;
using ii = pair<ll, ll>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

ll solve(int N, const vector<ll>& xs)
{
    return 0;
}

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

    int D, T, S;
    cin >> D >> T >> S;

    int t = (D + S - 1)/S;

    cout << (t <= T ? "Yes" : "No") << '\n';

    return 0;
}


Measured memory_bytes: 3636
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int [] in = new int [a];
        int sum = 0;
        for(int i=0;i<a;i++){
                             int b = sc.nextInt();
                             sum+=b;
                             in[i]=sum;
                            }
		int ans = sum;
        for(int i=0;i<a-1;i++){ans=Math.min(ans,Math.max(sum-2*in[i],2*in[i]-sum));
                              }
		System.out.println(ans);
	}
}


Measured memory_bytes: 25044
#include<stdio.h>
int main(void)
{
	int a,b,c,d,e,sum;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	scanf("%d",&d);
	scanf("%d",&e);
	if(a>0){
		sum=sum+(b-a)*e;
	}
	else if(a<0){
		sum=(-a)*c;
		sum+=d;
		sum=sum+b*e;
	}
	printf("%d\n",sum);
	return 0;
}



Measured memory_bytes: 2148
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <cassert>
#include <iomanip>
using namespace std;

#define rep(i,a,b) for(int i = (a); i <= (b); ++i)
#define per(i,a,b) for(int i = (a); i >= (b); --i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define sqr(x) (x) * (x)

typedef long long ll;
typedef long double ld;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef pair<PII,int> PIII;

const int N = 1000005;
const int P = 1000000007;
const ll mod = P;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ld eps = 1e-8;
ll qmod(ll a,ll n,ll mod){ll ans=1;while(n){assert(ans>0);if(n&1ll)ans=ans*a%mod;n>>=1;a=a*a%mod;}return ans%mod;}

//head

//your code goes there

int main()
{
        set<string> ss; ss.clear();
        string s; int k; cin >> s >> k;
        rep(i,0,SZ(s)-1)
        {
                string t;
                rep(j,0,4)
                {
                        if(i+j>=SZ(s)) break;
                        t += s[i+j];
                        ss.insert(t);
                }
        }
        for(auto x : ss)
        {
//                cout << x << endl;
                --k;
                if(k==0)
                {
                        cout << x << endl;
                        return 0;
                }
        }
        return 0;
}


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

using namespace std;

inline int ctoi(const char c)
{
	return c >= '0'&&c <= '9' ? c - '0' : -1;
}

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

	int max = 0;
	int diff = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == j) {
				continue;
			}
			else {
				diff = abs(a[i] - a[j]);
				if (diff > max) {
					max = diff;
				}
			}
		}
	}
	cout << max << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int main()
{
	int N, k;
	cin >> N >> k;
	long long ans = 0;
	REP(i, 0, N - 1) {
		ans += ans / (k - 1) + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define rep( i, n ) for( int ( i ) = 0; ( i ) < ( n ); ( i )++ )
#define repr( i, n ) for( int ( i ) = ( n ); ( i ) >= 0; ( i )-- )
#define FOR( i, m, n ) for( int ( i ) = ( m ); ( i ) < ( n ); ( i )++ )
#define all( x ) ( x ).begin(), ( x ).end()
typedef long long lint;
using namespace std;

int main( void ){
	
	lint n,k,cnt;
	
	cnt = 0;
	
	cin >> n >> k;
	
	rep( i, n ){
		if( i + k <= n ){
			cnt++;
		}
	}
	
	cout << cnt << endl;
	
	return 0;
	
}

Measured memory_bytes: 256
n,k = map(int, input().split())
pp = list(map(lambda x: int(x) - 1, input().split()))
cc = list(map(int, input().split()))

cycles = []
seen = set()
for p in pp:
    i = p
    tmp = []
    while i not in seen:
        v = cc[i]
        tmp.append(v)
        seen.add(i)
        i = pp[i]
    if tmp:
        cycles.append(tmp)

ans = -float('inf')

def calc(resid, cycle):
    if resid == 0:
        return 0
    m = len(cycle)
    dp = [cycle[:]]
    for k in range(1, resid):
        tmp = [0] * m
        for j in range(m):
            tmp[j] = dp[k-1][j] + cycle[(j + k)%m]
        dp.append(tmp)
    mx_resid = max(map(max, dp))
    return mx_resid

for cycle in cycles:
    per_cycle = sum(cycle)
    m = len(cycle)
    if per_cycle > 0:
        cnt_cycle, resid = divmod(k, m)
        mx_resid = calc(resid, cycle)
        ans_cycle = cnt_cycle * per_cycle + mx_resid
        ans = max(ans, ans_cycle)
        
        cnt_cycle = max(0, k // m - 1)
        resid = min(k, m)
        mx_resid = calc(resid, cycle)
        ans_cycle = cnt_cycle * per_cycle + mx_resid
        ans = max(ans, ans_cycle)
    else:
        cnt_cycle = 0
        resid = min(k, m)
        mx_resid = calc(resid, cycle)
        ans_cycle = cnt_cycle * per_cycle + mx_resid
        ans = max(ans, ans_cycle)


print(ans)

Measured memory_bytes: 325552
// AOJ 1389 Digits Are Not Just Characters
// 2019.2.28 bal4u

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

#define BASE 1000000000  // >= 10^9
char s0_buf[12];
int s0[12], len;
char *bp;

// 文字列から数字部分を取り出し、バイナリに変換。文字列はグローバル変数bpで指す
int s2n()
{
	int ans = 0;
	while (isdigit(*bp)) {
		ans = 10 * ans + (*bp++ & 0xf);
	}
	return ans;
}

int main()
{
	int i, N, s, ans;
	char s_buf[12];
	
	scanf("%d", &N);
	scanf("%s", bp = s0_buf);
	len = 0;
	while (*bp) {
		if (isdigit(*bp)) s0[len] = s2n();
		else s0[len] = BASE + *bp++;
		len++;
	}
/*
	printf("len=%d:", len);
	for (i = 0; i < len; i++) printf("%d ", s0[i]); printf("\n");
*/
	while (N--) {
		scanf("%s", bp = s_buf);
		ans = 0; for (i = 0; *bp && i < len; i++) {
			if (isdigit(*bp)) s = s2n();
			else s = BASE + *bp++;
			if (s < s0[i]) { ans = -1; break; }
			if (s > s0[i]) { ans = 1; break; }
		}
		if (!ans) {
			ans = (*bp == 0 && i < len) ? -1 : 1;
		}
		putchar(ans > 0 ? '+' : '-');
		putchar('\n');
	}
	return 0;
}



Measured memory_bytes: 2064
N, L = map(int, input().split())
 
ans = float('inf')
diff_ = float('inf')
max_taste = (L-1) * N + (N*(N+1)) // 2

for i in range(1, N+1):
    tgt = L+i-1
    taste = max_taste - tgt
    diff = abs(max_taste - taste)
    if diff < diff_:
        diff_ = diff
        ans = taste

print(ans)


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

bool has_only_single_char(const string& s)
{
  char c = s.front();
  for (size_t i = 1; i < s.size(); i++) {
    if (c != s.at(i)) {
      return false;
    }
  }
  return true;
}

bool can_convert(const string& s, const string& t)
{
  unordered_map<char, char> m;
  unordered_set<char> inuse;
  for (size_t i = 0; i < s.size(); i++) {
    auto it = m.find(s.at(i));
    if (it == m.end() && inuse.find(t.at(i)) != inuse.end()) {
      return false;
    }
    if (it == m.end()) {
      m[s.at(i)] = t.at(i);
      inuse.insert(t.at(i));
      continue;
    }
    if (it->second != t.at(i)) {
      return false;
    }
  }
  return true;
}

int main()
{
  string s, t;
  cin >> s >> t;
  bool s_has_only_single_char = has_only_single_char(s);
  bool t_has_only_single_char = has_only_single_char(t);
  if (s_has_only_single_char && t_has_only_single_char) {
    cout << "Yes\n";
    return 0;
  } else if (t_has_only_single_char) {
    cout << "No\n";
    return 0;
  }

  if (can_convert(s, t)) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }

  return 0;
}


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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define REPS(i, m, n) for (int i = (m); i <= (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) for (int i = 0; i <= (int)(n); i++)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define rreps(i, x) for (int i = (int)(x); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val) { fill( (T*)array, (T*)(array+N), val ); }
template <class T1, class T2, class Pred = std::less<T2> >
struct sort_pair_second {
    bool operator()(const std::pair<T1,T2>&left, const std::pair<T1,T2>&right) {
        Pred p;
        return p(left.second, right.second);
    }
};

int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K; cin >> K;
    cout << a[K-1] << endl;

}

Measured memory_bytes: 892
//AtCoder 
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    vector<ll> pt(5);
    for(auto&& p:pt){
        cin>>p;
    }
    ll k; cin>>k;
    bool ans=(pt[4]-pt[0]<=k);
    cout<<(ans?"Yay!":":(")<<endl;
    return 0;
}

Measured memory_bytes: 256
import math
a, b, h, m = map(int, input().split())

# 角度を割り出す
hour = m * (360 // 60)
minutes = h * (360 // 12) + (0.5 * m)

angle = 0
if abs(hour - minutes) > 180:
    angle = 360 - (abs(hour - minutes))
else:
    angle = abs(hour - minutes)

ans = ((b ** 2) + (a ** 2)) - (2 * a * b * math.cos(math.radians(angle)))

print(math.sqrt(ans))


Measured memory_bytes: 9456
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define tp          tuple<int,int,int>
#define fastio      ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int N = 1e6 + 6;

int main()  {
    fastio;
    int n;
    cin>>n;
    vector<int>vec(n) , fre(N);
    for(int i = 0 ; i < n ; i++ ) {
        cin>>vec[i];
        fre[vec[i]]++;
    }

    int gcd = vec[0];

    for(auto x : vec) {
        gcd = __gcd(x , gcd);
    }
    if(gcd !=1) {
        cout<<"not coprime\n";
        return 0;
    }
    // for(auto x : fre) {
    //     if(x> 1) {
    //         cout<<"setwise coprime\n";
    //         return 0;
    //     }
    // }

    for(int i =2 ; i < N ; i++ ) {
        int tot = 0;
        for(int j = i ; j < N ; j += i) {
            tot += fre[j];
        }
        if(tot > 1) {
            cout<<"setwise coprime\n";
            return 0;
        }
    }
    cout<<"pairwise coprime\n";
    return 0;

    
    
}

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

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] a = new int[n];
		for(int i=0;i<n;i++) {
			a[i] = in.nextInt();
		}
		Arrays.sort(a);
		if(n==2) {
			System.out.println(a[1]+" "+a[0]);
			in.close();
			return;
		}
		int max = a[n-1];
		int idx = 0;
		while(a[idx]<max/2) {
			idx++;
		}
		int half = a[idx];
		if(idx>0) {
			if((double)max/2-a[idx-1]<a[idx]-(double)max/2) {
				half = a[idx-1];
			}
		}
		System.out.println(max+" "+half);
		in.close();
	}

}


Measured memory_bytes: 52348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const double PI = acos(-1);  


int n;
vector<string> ans;
void dfs(string s, char maxi='a'){
  
  if(n==s.length()){
    ans.push_back(s);
    return;
  }
  for(char i='a'; i<=maxi; i++){
    string ns = s+i;
    if(i==maxi) dfs(ns, maxi+1);
    else dfs(ns, maxi);
  }

}


int main(){
  cin >> n;
  ll res=0;
  dfs("", 'a');
  sort(ans.begin(), ans.end());
  for(auto x: ans) cout << x << endl;
}

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

//Jogging
public class Main{

	static long gcd(long a, long b){
		if(a < b){
			long tmp = a;
			a = b;
			b = tmp;
		}
		while(b!=0){
			long r = a%b;
			a = b;
			b = r;
		}
		return a;
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int[] d = new int[n];
			int[] v = new int[n];
			for(int i=0;i<n;i++){
				d[i]=sc.nextInt();
				v[i]=sc.nextInt();
			}
			int[] a = new int[n];
			Arrays.fill(a, 1);
			for(int i=0;i<n;i++){
				for(int j=i+1;j<n;j++){
					int k1 = d[i]*v[j];
					int k2 = d[j]*v[i];
					int g = (int)gcd(k1,k2);
					k1/=g;
					k2/=g;
					int g1 = (int)gcd(a[i],k2);
					int g2 = (int)gcd(a[j],k1);
					a[i]*=k2/g1;
					a[j]*=k1/g2;
				}
			}
			for(int i=0;i<n;i++)System.out.println(a[i]);
		}
	}
}

Measured memory_bytes: 12000
#pypyは内包表記使わない, rstrip注意
#提出前に見返すこと！
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    h,w = map(int, input().split())
    if h==1 or w==1:
        print(1)
        exit()
    if h%2==0 and w%2==0:
        print(h*w//2)
    elif h%2==1 and w%2==0:
        a = h//2 + 1
        b = h//2
        print((a+b)*(w//2))
    elif h%2==0 and w%2==1:
        a = w//2 + 1
        b = w//2
        print((a+b)*(h//2))
    else:
        a = w//2 + 1
        b = w//2
        c = h//2
        print((a+b)*c + a)

if __name__ == '__main__':
    main()

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

int bfscount = 1;

void bfs(vector<vector<int>> &branch, vector<int> &c, vector<int> &d, int node)
{
  for (int i = 0; i < branch.at(node).size(); i++) {
    if (branch.at(node).at(i) == 0) continue;
    if (d.at(branch.at(node).at(i)) != 0) continue;
    d.at(branch.at(node).at(i)) = c.at(bfscount);
    bfscount++;
    bfs(branch, c, d, branch.at(node).at(i));
  }
}

int main()
{
  int n;
  cin >> n;
  vector<vector<int>> branch(n, vector<int>(0));
  vector<int> c(n), d(n);
  for (int i = 0; i < n-1; i++) {
    int a, b;
    cin >> a >> b;
    branch.at(a-1).push_back(b-1);
    branch.at(b-1).push_back(a-1);
  }
  for (int i = 0; i < n; i++) cin >> c.at(i);
  sort(c.begin(), c.end());
  reverse(c.begin(), c.end());
  int m = 0;
  for (int i = 1; i < n; i++) m += c.at(i);
  cout << m << endl;
  bfs(branch, c, d, 0);
  d.at(0) = c.at(0);
  for (int i = 0; i < n-1; i++) cout << d.at(i) << " ";
  cout << d.at(n-1) << endl;
}


Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	string in;
	cin>>n>>in;
//	in="<"+in+">";
//	n+=2;
	vp dp(n);
	vi ri,le;
	int co=0;
	rep(i,n){
		if(in[i]=='>'){
			co++;
			ri.pb(i);
		}
		dp[i].first=co;
	}
	co=0;
	rep(i,n){
		if(in[n-1-i]=='<'){
			co++;
			le.pb(n-1-i);
		}
		dp[n-1-i].second=co;
	}
//	rep(i,ri.size())cout<<ri[i]<<endl;
//	rep(i,le.size())cout<<le[i]<<endl;
//	rep(i,n)cout<<dp[i].first<<" "<<dp[i].second<<endl;
	int out=max(dp[0].second,dp[n-1].first);
	rep(i,n-1){
		int a=dp[i].first,b=dp[i+1].second;
		if(a<=b){
			int t=le[b-min(a+1,b)];
			out=max(out,t+1);
		}
		if(a>=b){
			int t=ri[a-min(a,b+1)];
			out=max(out,n-t);
		}
	}
	cout<<out<<endl;
}
//  < < < > < < > > >
//  0 0 0 1 1 1 2 3 4
//  5 4 3 2 2 1 0 0 0

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repp(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)
#define p(a, b) printf(a, b);
#define c(s) cout << (s) << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define cyn(c) cout << (c ? "Yes" : "No") << endl;
#define cYN(c) cout << (c ? "YES" : "NO") << endl;
#define pyn(c) printf("%s\n", c ? "Yes" : "No");
#define pYN(c) printf("%s\n", c ? "YES" : "NO");
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> P;
template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int main()
{
    int K,S,cnt=0; cin>>K>>S;
    rep(i,K+1){
        rep(j, K + 1){
            if(S-(i+j)>=0&&S-(i+j)<=K)cnt++;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;


namespace atPra
{
    class Class1
    {
        static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(null);
            int[] A = new int[N];
            for (int i = 0; i < N;i++){
                A[i] = int.Parse(str[i]);
            }
            //最大値を求める
            int max = 0;
            for (int i = 0; i < N;i++){
                if (A[i] >= max) max = A[i];
            }
            //最小値を求める
            int min = 1000000000;
            for (int i = 0; i < N; i++)
            {
                if (A[i] <= min) min = A[i];
            }
            Console.WriteLine(max - min);
        }
    }
}

Measured memory_bytes: 11092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
  public static void main(String[] args) {
	  FastReader sc = new FastReader();
	  int a = sc.nextInt();
	  String s = sc.next();
	  if (a < 3200) {
		  System.out.println("red");
	  } else {
		  System.out.println(s);
	  }
  }
  
  static class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }
  
    String next() { 
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException  e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

    double nextDouble() { 
      return Double.parseDouble(next());
    }

    String nextLine() {
      String str = "";
        try{
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
      }
  }
}


Measured memory_bytes: 23252
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cctype>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<cstring>
//#include<windows.h>
//#include<time.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mer make_pair
#define mme memset
using namespace std;

const double pie1=3.1415926;//π1
const double pie2=3.14159265358979;//π2
const double pie3=3.14159265358979323846;//π3
const int vbi=999999999;
const int vli=-vbi;
const long long vbl=999999999999999999;
const long long vll=-vbl;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> piii;
typedef pair<pii,pii> pi4;
typedef pair<pll,ll> plll;
typedef pair<int,pii> ipii;
typedef pair<ll,pll> lpll;
typedef pair<pll,pll> pl4;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef set<int> sti;
typedef set<ll> stl;
typedef set<pii> spi;
typedef set<pll> spl;
priority_queue<int> pqi;
priority_queue<ll> pql;
queue<int> qi;
queue<ll> ql;

/*void bin_v(){
	char bin[1000];
	gets(bin);
}*/

bool pss(int a){
	for(int i=2;i<=sqrt(a);i++)
		if(a%i==0)
			return false;
	return true;
}
/////////////////////////////////////////////////////////////////////////////////////////

int main(){
	//my name is Veex_WCY
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	ll a[n+10],b[n+10],c[n+10];
	b[0]=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		b[i]=a[i]+b[i-1];
	}
	int ok=1;
	ll sum=b[n-1]-a[n];
	while(n-ok*2>1){
		ok++;
		ll ans=b[n-ok]-b[ok-1];
//		cout<<ans<<' '<<sum<<endl;
		sum=ans*2-sum;
	}
	c[int(n/2)+1]=sum;
	for(int i=int(n/2)+2;i<=n;i++)
		c[i]=(a[i-1]-c[i-1]/2)*2;
	for(int i=int(n/2);i>=1;i--)
		c[i]=(a[i]-c[i+1]/2)*2;
	for(int i=1;i<=n;i++)
		cout<<c[i]<<' ';
	return 0;
}


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

int abs(int a){
  return (a < 0 ? -a : a);
}

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cout << (abs(a-b)<=d && abs(b-c)<=d || abs(a-c)<=d ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())

a = n // 9 + 1

ans = 10**10
tmp = 0

for i in range(a):
    six = (n - 9 * i) // 6
    one = (n-9*i-6*six)
    si = six
    nine = i
    tmp = 0
    while nine > 0:
        tmp += nine % 9
        nine = nine // 9
    while six > 0:
        tmp += six % 6
        six = six // 6
    ans = min(ans,tmp+one)

print(ans)

Measured memory_bytes: 3064
#include <bits/extc++.h>

using namespace std;

template <class T>
struct segtree {
  int n;
  vector<T> t;
  segtree(int _n = 0) : n(_n), t(2 * n) {}
  T& operator[](int i) { return t[n + i]; }
  void build() {
    for (int i = n; i-- > 1;) t[i] = t[2 * i] * t[2 * i + 1];
  }
  T fold(int l, int r) const {
    T a{}, b{};
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) a = a * t[l++];
      if (r & 1) b = t[--r] * b;
    }
    return a * b;
  }
  void set(int i, const T& a) {
    t[i += n] = a;
    while (i >>= 1) t[i] = t[2 * i] * t[2 * i + 1];
  }
};

struct node {
  int v;
  friend node operator*(const node& a, const node& b) {
    return a.v < b.v ? b : a;
  }
};

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int h, w, m;
  cin >> h >> w >> m;
  vector<vector<int>> js(h);
  vector<int> a(w);
  while (m--) {
    int i, j;
    cin >> i >> j;
    --i, --j;
    js[i].push_back(j);
    ++a[j];
  }
  int res = 0;
  segtree<node> seg(w);
  for (int j = 0; j < w; ++j) seg[j] = {a[j]};
  seg.build();
  for (int i = 0; i < h; ++i) {
    for (int j : js[i]) {
      seg.set(j, {--a[j]});
    }
    res = max(res, int(size(js[i])) + seg.t[1].v);
    for (int j : js[i]) {
      seg.set(j, {++a[j]});
    }
  }
  cout << res << '\n';
}


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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<ll, ll> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){cerr<<"\n";} template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	s+="00";
	int n=sz(s);
	const ll INF = 1e18;
	VL dp = {0, INF};
	rep(i, n){
		VL nxt(2, INF);
		rep(j, 2) rep(d, 10){
			int nj = j + s[i] -'0';
			int pc = d - nj + (d<nj? 10: 0);
			nxt[d < nj] = min(nxt[d<nj], dp[j] +pc +d);
		}
		swap(dp, nxt);
	}
	cout << dp[0] <<"\n";
	return 0;
}


Measured memory_bytes: 1948
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i,N) repf(i,0,N)
#define reps(i,N) repfs(i,1,N)
#define repf(i,a,b) for(int i=a;i<b;i++)
#define repfs(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,N) for(int i=N-1;i>=0;i--)
#define reprs(i,N) for(int i=N;i>0;i--)
#define pb push_back
#define pob pop_back

template<typename T> 
void chmax(T &a,T b){ a = max(a, b);};
template<typename T> 
void chmin(T &a,T b){ a = min(a, b);};

typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int n;
ll x;
ll s[51];
ll p[51];

ll f(int n, ll x){
	if (x <= 1) return 0;
	else if(x < 1 + s[n-1]) return f(n-1, x-1);
	else if(x == 1 + s[n-1]) return p[n-1];
	else if (x== 2 + s[n-1]) return p[n-1] + 1;
	else if (x < 2 + s[n-1] * 2) return p[n-1] + 1 + f(n-1, x-(2+s[n-1]));
	else return p[n-1] * 2 +1;
}

void solve(){
	s[0]=1;
	p[0]=1;
	rep(i,n){
		s[i+1] = s[i]*2 + 3;
		p[i+1] = p[i]*2 + 1;
	}
	ll ans= f(n,x);
	cout<<ans<<endl;
}

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


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  bool ok = true;

  int N;
  cin >> N;
  
  int A;
  rep(i, N){
    cin >> A;
    if(A % 2 == 0){
      if(A % 3 != 0 && A % 5 != 0){
        ok = false;
        break;
      }
    }
  }
  
  if(ok){
    cout << "APPROVED" << endl;
  }else{
    cout << "DENIED" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main( int argc , char *argv[] )
{
	int k,n;

	scanf( "%d %d\n" , &n , &k );

	if( k == 1 ) {
		printf( "0\n" );
	} else {
		printf( "%d\n" , n - k );
	}

	return 0;
}


Measured memory_bytes: 128
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

void precalc() {
}

const int maxn = (int) 2e5 + 10;
char s[maxn];

int n;

int read() {
  if (scanf("%s", s) < 1) {
    return 0;
  }
  return 1;
}

void solve() {
  n = (int) strlen(s);

  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (!cnt || !(s[cnt - 1] == 'S' && s[i] == 'T')) {
      s[cnt++] = s[i];
    } else {
      --cnt;
    }
  }
  printf("%d\n", cnt);
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}

Measured memory_bytes: 384