akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int main()
{
  int n,m;
  lli ar[5000];
  lli br[5000];
  cin>>n>>m;
  sa(ar,n,lld);
  sa(br,n,lld);
  rep(i,n) ar[i]--;
  vector<vector<int> > cycles;
  bool vis[5000]={0};
  rep(i,n){
      if(vis[i]) continue;
      int j=i;
      vector<int> c;
      do{
          vis[j]=true;
          c.pb(j);
          j=ar[j];
      }while(j!=i);
      cycles.pb(c);
  }
  lli ans=LONG_LONG_MIN;
  for(auto x:cycles){
      lli tsum=0;
      for(auto p:x){
          tsum+=br[p];
          //cout<<p<<"p ";
      }
      vector<int> nc;
      for(auto p:x)
        nc.pb(p);
        for(auto p:x)
        nc.pb(p);
      //cout<<tsum<<"tt ";
      lli nsum=0;
     if(m<x.size()){
         rep(i,x.size()) {nsum=0;rep(j,m)nsum+=br[nc[i+j]],ans=max(ans,nsum); }
         //rep(i,m) nsum+=br[nc[i]],ans=max(ans,nsum); 
     }
    else if(tsum<=0){
        rep(i,x.size()) {nsum=0;rep(j,x.size())nsum+=br[nc[i+j]],ans=max(ans,nsum); }
    }
    else {
        int y=m%x.size();
        //nsum=m/x.size()*tsum;
        ans=max(ans,nsum);
        //if(!y){
            nsum=(m/x.size()-1)*tsum;
            y=x.size();
            rep(i,x.size()){
            lli lsum=0;
            rep(j,y){
                lsum+=br[nc[i+j]];
                ans=max(ans,nsum+lsum);
            }
        }
        //    continue;
        //}
         nsum=m/x.size()*tsum;
         y=m%x.size();
        rep(i,x.size()){
            lli lsum=0;
            rep(j,y){
                lsum+=br[nc[i+j]];
                ans=max(ans,nsum+lsum);
            }
        }
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(){
    string o, e;
    cin >> o >> e;

    int len_o = o.length();
    int len_e = e.length();

    for(int i = 0; i < len_o; i++){
        if(i == len_o - 1){
            if(len_o > len_e){
                cout << o[i] << endl;
            }else{
                cout << o[i] << e[i] << endl;
            }
        }else{
            cout << o[i] << e[i];
        }
    }
}

Measured memory_bytes: 256
#ABC150C_CountOrder.rb
n = gets.to_i
p = gets.split.map(&:to_i)
q = gets.split.map(&:to_i)

if p == q
  puts 0
  exit
end

ar = (1..n).to_a
br = ar.permutation(n).to_a.sort

a = 0
b = 0
br.each_with_index do |bb,i|
  if bb == p
    a = i+1
  elsif bb == q
    b = i+1
  end
end

puts (a - b).abs
  


Measured memory_bytes: 7384
n = int(input())
s = [[0] * 13 for i in range(4)]
for i in range(n):
	t = input().split()
	if t[0] == "S":
		u = 0
	elif t[0] == "H":
		u = 1
	elif t[0] == "C":
		u = 2
	elif t[0] == "D":
		u = 3
	s[u][int(t[1]) - 1] = 1
for i in range(4):
	for j in range(13):
		if s[i][j] != 1:
			if i == 0:
				st = 'S'
			elif i == 1:
				st = 'H'
			elif i == 2:
				st = 'C'
			elif i == 3:
				st = 'D'
			print(st, end=" ")
			print(j + 1)



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

int fx(int n){
	int i, ret = 0;
	REP(i,1, n+1){
		if(n%i == 0) ret++;
	}
	return ret;
}

int main(){
	int i,j,k,n,m,l,f,x,y,z; string s;
	cin >> n;

	f = 0;
	rep(i, n+1){
		if(i%2==0) continue;
		if(fx(i) == 8) ++f;
	}
	cout << f << endl;
}	

Measured memory_bytes: 256
package main

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

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func main() {
	defer write.Flush()

	var r, d, x int64
	fmt.Fscan(read, &r, &d, &x)

	for i := 0; i < 10; i++ {
		x = x*r - d
		fmt.Fprintln(write, x)
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>    //C++の標準ライブラリのヘッダを全て読み込む
 
int main() {
    using std::cout;
    using std::endl;
    using std::cin;
    using std::string;

    int A,B,temp;
    char op;
    cin >> A >> op >> B;

    A += (op == '+') ? B : -B;

    cout << A << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  string a;
  cin >> a;
  if (a == "ooo"){
    cout << 1000 << endl;
  }else if(a == "xox" || a == "xxo" || a == "oxx"){
    cout << 800 << endl;
  }else if(a == "xxx"){
    cout << 700 << endl;
  }else{
    cout << 900 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
import math
res = float('inf')
L, R = map(int, input().split())
length = min(R - L, 3000)
for i in range(L, L + length):
  for j in range(i+1, L + length + 1):
    temp = (i * j) % 2019
    if temp < res:
      res = temp
print(res)

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

int main() {
    int a,b,c;
    cin>>a>>b>>c;
    int min_sum=min(a+b,b+c);
    min_sum=min(min_sum,c+a);

    cout<<min_sum<<endl;

}

Measured memory_bytes: 256
/*
 * main.c
 *
 *  Created on: 2020/03/28
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}

void yesno(int ans) {
	if (ans == 1) {	printf("Yes\n");
	} else {		printf("No\n");	}
	return;
}

void okng(int ans) {
	if (ans == 1) { printf("OK\n");
	} else { 		printf("NG\n");	}
	return;
}

int main()
{
	char S[11] = {0};
	char T[12] = {0};
	int len = 0, ans = 0;
	scanf("%s", S);
	scanf("%s", T);
	len = strlen(S);
	if (strncmp(S,T,len) == 0) {
		ans = 1;
	}

	yesno(ans);
	//okng(ans);
	return 0;
}


Measured memory_bytes: 1712
#include <stdio.h>
#include <string.h>
#define MAX 1000

int LCS_Length(char *, char *);
int main(void){

  int n, i;
  char data[MAX];
  char check[MAX];

  scanf("%d",&n);

  for(i = 0;i < n;i++){
  scanf("%s",data);
  scanf("%s",check);
  printf("%d\n", LCS_Length(data,check));
  }
  return 0;
}

int LCS_Length(char *x, char *y){
  int m = strlen(x);
  int n = strlen(y);
  int i, j;
  //1スタートだから
  int c[m+1][n+1];

  for(i = 0;i <= m;i++)
    c[i][0] = 0;

  for(j = 0;j <= n;j++)
    c[0][j] = 0;
  
  for(i = 1;i <= m;i++){
    for(j = 1; j <= n;j++){
      if(x[i-1] == y[j-1])
	c[i][j] = c[i-1][j-1] + 1;
      else if(c[i-1][j] >= c[i][j-1])
	c[i][j] = c[i-1][j];
      else
	c[i][j] = c[i][j-1];
      
    }
  }
  return c[i-1][j-1];
}

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

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

//pow(llpow,modpow)
template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main( ){
    int n;
    cin>>n;
    vi a(n);
    vi tosort(n);
    rep(i,0,n){
        cin>>a[i];
        tosort[i]=a[i];
    }
    sort(tosort.begin(),tosort.end());
        int res[2]={tosort[n/2-1],tosort[n/2]};
        if(res[1]==res[0]){
            rep(i,0,n)cout<<res[0]<<endl;
        }
        else {
            rep(i,0,n){
                if(a[i]<=res[0])cout<<res[1]<<endl;
                else cout<<res[0]<<endl;
            }
        }
    return 0;
}




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

using namespace std;

#define ll long long int
#define ld long double
#define MAX 100000000007
#define MOD 1000000007
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)

int main(){

    fast;

    ll n,m,x,i,j;
    cin >> n >> m >> x;

    ll a[n+1][m+1];
    ll sk[m+1] = {0};

    for(i=1;i<=n;i++){
        for(j=0;j<=m;j++){
            cin >> a[i][j];
        }
    }

    for(i=1;i<=m;i++){
        for(j=1;j<=n;j++){
            sk[i]=sk[i]+a[j][i];
        }
    }

    int flg = 1;

    for(i=1;i<=m;i++){
        if(sk[i]<x){
            flg = 0;
            break;
        }
    }

    if(flg){

        for(i=1;i<=m;i++){
            sk[i]=0;
        }

        ll mina = MAX;

        for(i=0;i<(1<<n);i++){
            ll cost = 0;
            for(ll skl=1;skl<=m;skl++){
                sk[skl]=0;
            }
            for(j=0;j<n;++j){
                if((i&(1<<j))!=0){
                    ll t1 = j+1;
                    for(ll bk=1;bk<=m;bk++){
                        sk[bk] = sk[bk]+a[t1][bk];
                    }
                    cost = cost + a[t1][0];

                }
            }
            int flg = 1;
            for(ll bk=1;bk<=m;bk++){
                if(sk[bk]<x){
                    flg = 0;
                }
            }
            if(flg){
                mina = min(mina,cost);
            }
        }

        cout << mina << endl;

    }
    else{
        cout << -1 << endl;
    }


}


//    cout << fixed << setprecision(2);


Measured memory_bytes: 3656
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toInt() }
    val array = IntArray(n){0}

    for(i in 0 until n-1){
        array[a[i]-1]++
    }
    for(i in 0 until n)
        println(array[i])
}

Measured memory_bytes: 69716
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

#define debug(x) (#x " : " + to_string(x))
#define debug_cout(x) (cout << #x << " : " <<  to_string(x) << endl)
//#define debug_cout(x) ( )
#define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; i++)
#define rep1(i, n) for(int i=1, i##_len=(n); i<i##_len; i++)
#define rrep(i, n) for(int i=(n)-1; i >= 0; i--)
#define rrep1(i, n) for(int i=(n); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair((a), (b));
using namespace std;
using ll = long long;
//#define int long long
template<class T> bool chmax(T& a, T& b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T& b) { if (a > b) { a = b; return true; } return false; }
constexpr int INF = 2e9;

/*****/

string S;
int SLen;

ll rec(int begin, int go, ll num)
{
	if (go > 0)
	{
		num += stoll(S.substr(begin, go));
	}

	begin += go;

	if (begin == SLen)
	{
		return num;
	}

	ll sum = 0;
	for (int nextGo = 1; begin + nextGo <= SLen; nextGo++)
	{
		sum += rec(begin, nextGo, num);
	}

	return sum;
}

int main()
{
	cin >> S;
	SLen = S.length();

	cout << rec(0, 0, 0) << endl;

	return 0;
}


Measured memory_bytes: 256
from collections import deque

def main():
    N = int(input())
    q = deque()
    o = []
    for _ in range(N):
        query = list(map(int, input().split()))
        if query[0] == 0:
            if query[1] == 0:
                q.appendleft(query[2])
            elif query[1] == 1:
                q.append(query[2])
        elif query[0] == 1:
            o.append(q[query[1]])
        elif query[0] == 2:
            if query[1] == 0:
                q.popleft()
            elif query[1] == 1:
                q.pop()
    print(*o, sep='\n')

main()



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

int zahyou_num;
int zahyou_list[300001];

/* syo-zyun */
int qsort_comp(const void* x,const void* y) {
	int* a=(int*)x;
	int* b=(int*)y;
	if(*a>*b)return 1;
	if(*a<*b)return -1;
	return 0;
}

int get_id(int zahyou) {
	int left,right,mid;
	left=0;right=zahyou_num-1;
	while(left<=right) {
		mid=(left+right)/2;
		if(zahyou_list[mid]==zahyou)return mid;
		else if(zahyou_list[mid]<zahyou)left=mid+1;
		else right=mid-1;
	}
	return 0;
}

int st_num,p_num;
int input_s[100000];
int input_t[100000];
int input_p[100000];

int rope_exist[300001];
int rope_vanished[300001];
int rope_cut[300001];

int main(void) {
	int i;
	int start,end;
	int temp;
	long long result;
	scanf("%d%d",&st_num,&p_num);
	zahyou_num=1;
	zahyou_list[0]=0;
	for(i=0;i<st_num;i++) {
		scanf("%d%d",&input_s[i],&input_t[i]);
		zahyou_list[zahyou_num++]=input_s[i];
		zahyou_list[zahyou_num++]=input_t[i];
	}
	for(i=0;i<p_num;i++) {
		scanf("%d",&input_p[i]);
		zahyou_list[zahyou_num++]=input_p[i];
	}
	qsort(zahyou_list,zahyou_num,sizeof(int),qsort_comp);
	for(i=0;i<p_num;i++) {
		rope_cut[get_id(input_p[i])]++;
	}
	for(i=1;i<zahyou_num;i++)rope_cut[i]+=rope_cut[i-1];
	for(i=0;i<st_num;i++) {
		start=get_id(input_s[i]);
		end=get_id(input_t[i]);
		if(start<end) {
			if((rope_cut[end]-rope_cut[start])%2==0) {
				rope_exist[start]++;
				rope_exist[end]--;
			} else {
				rope_exist[start]++;
				rope_vanished[end]--;
			}
		} else {
			if((rope_cut[start]-rope_cut[end])%2==0) {
				rope_exist[end]++;
				rope_exist[start]--;
			} else {
				rope_vanished[end]++;
				rope_exist[start]--;
			}
		}
	}
	result=0;
	for(i=1;i<zahyou_num;i++) {
		rope_exist[i]+=rope_exist[i-1];
		rope_vanished[i]+=rope_vanished[i-1];
		if(rope_cut[i]!=rope_cut[i-1]) {
			temp=rope_exist[i];
			rope_exist[i]=rope_vanished[i];
			rope_vanished[i]=temp;
		}
	}
	for(i=0;i+1<zahyou_num;i++) {
		result+=(long long)(zahyou_list[i+1]-zahyou_list[i])*
			(long long)rope_exist[i];
	}
	printf("%lld\n",result);
	return 0;
}

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

#define int long long
#define INF (int)0x3f3f3f3f*(int)0x3f3f3f3f

int n,m;
int ans = INF;

signed main()
{
	cin >> n;
	for(int i = 1; i*i <= n; i ++) {
		if(n%i == 0)
		{
			ans = min(ans,i+n/i-2);
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
/*input
3 6
3 4 5
*/
#include <bits/stdc++.h>
using namespace std;
#define TEMPLATE

#ifdef TEMPLATE
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef vector<pi> vpi;
typedef vector<vpi> vpii;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<pd> vpd;
typedef vector<bool> vb;
typedef vector<vb> vbb;
typedef std::string str;
typedef std::vector<str> vs;

#define x first
#define y second
#define debug(...) cout<<"["<<#__VA_ARGS__<<": "<<__VA_ARGS__<<"]\n"

const int MOD = 1000000007;
const ll INF = std::numeric_limits<ll>::max();
const int MX = 100101;
const ld PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270L;

template<typename T>
pair<T, T> operator+(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x + b.x, a.y + b.y); }
template<typename T>
pair<T, T> operator-(const pair<T, T> &a, const pair<T, T> &b) { return pair<T, T>(a.x - b.x, a.y - b.y); }
template<typename T>
T operator*(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.x + a.y * b.y); }
template<typename T>
T operator^(const pair<T, T> &a, const pair<T, T> &b) { return (a.x * b.y - a.y * b.x); }
#endif

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int N, X;
	cin >> N >> X;
	int sum = 0;
	int ats = 1;
	int a;
	for (int i = 0; i < N; ++i)
	{
		cin >> a;
		sum += a;
		if (sum <= X) ats++;
	}
	printf("%d\n", ats);
}

/* Look for:
* special cases (n=1?)
* overflow (ll vs int?)
* the exact constraints (multiple sets are too slow for n=10^6 :( )
* array bounds
*/


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

a = []
maxA = 0
secondA = 0

for i in range(n):
    a.append(int(input()))
    if a[i] > maxA:
        secondA = maxA
        maxA = a[i]
    elif a[i] > secondA:
        secondA = a[i]

for i in range(n):
    if a[i] == maxA:
        print("{}".format(secondA))
    else:
        print("{}".format(maxA))


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

const int MAXN = 25;
int n, a[MAXN], ans;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 1; i < n - 1; i++) {
		int cnt = 0;
		cnt += (a[i] > a[i - 1]);
		cnt += (a[i] > a[i + 1]);
		if (cnt == 1)
			ans++;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define INF (int)1e9
#define INFL (ll)1e11
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int ext_gcd(int a, int b, int &x, int &y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	int tmp = ext_gcd(b, a%b, y, x);
	y -= a / b * x;
	return tmp;
}

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

	int a, b;
	cin >> a >> b;

	int x, y;
	ext_gcd(a, b, x, y);
	cout << x << " " << y << "\n";
	
	return 0;
}


Measured memory_bytes: 3220
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	p := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &p[i])
	}
	mn := 200000
	count := 0
	for i := 0; i < n; i++ {
		if mn >= p[i] {
			count++
			mn = p[i]
		}
	}
	fmt.Printf("%d\n", count)
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a;
  cin >> a;
  int count = 0;
  string ret;
  ret = to_string(a);
  for (int i=0; i<ret.size(); i++) {
    if (ret.at(i) == '1') {
      count++;
    }
  }
  cout << count << endl;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static long a = sc.nextLong();
    static long b = sc.nextLong();
    static long n = sc.nextLong();
	static long n_max = 0;
	static long result = 0;
    static long _result = 0;
  
    public static void main(String[] args) {
		n_max = b > n ? n : b;      
        for (long i = n_max; i >= n_max - a; i--){
				_result = a * i / b - a * (i / b);
          		if (result < _result)
          			result = _result;
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 35564
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;
using vi = vector<int>;

#define in(v) v; cin >> v;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rrep(i,n) for(long long i=(n);i>=0;--i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))

// ========== debug ==========
template<class T>ostream& operator<<(ostream& os,const vector<T>& vec){os<<"{";for(size_t i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
ostream& operator<<(ostream& os,const vector<char>&v){for(size_t i=0;i<v.size();++i)os<<v[i];return os;}
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>& rhs){os<<"("<<rhs.first<<", "<<rhs.second<<")";return os;}

#ifdef LOCAL
void debug() {cerr << "\n";}
template<class First> void debug(const First& first) {cerr<<first<<"\n";}
template<class First, class... Rest> void debug(const First& first, const Rest&... rest) {cerr<<first<<",";debug(rest...);}
void debug2() {cerr << "\n";}
template<class First> void debug2(const First& first) {cerr<<first<<" ";}
template<class First, class... Rest> void debug2(const First& first, const Rest&... rest) {cerr<<first<<" ";debug2(rest...);}
#else
#define debug(...) 42
#define debug2(...) 42
#endif
// ===========================

int main() {
  int H, W, K;
  ins(H, W, K);

  char c[6][6];
  rep(i, H) rep(j, W) {
    cin >> c[i][j];
  }
  int ans = 0;
  rep(bit1, 1<<H) rep(bit2, 1<<W) {
    int count = 0;
    rep(i, H) rep(j, W) {
      if (bit1 & (1 << i) || bit2 & (1 << j))
        continue;
      if (c[i][j] == '#')
        ++count;
    }
    if (count == K)
      ++ans;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 1 << 21;
using pii = std::pair<int, int>;
#define SORT(v) std::sort(v.begin(), v.end())
int main(void) {
	int N, b,x;
	long long ans = 0;
	std::cin >> N;
	std::vector<int> a(N);
	for (int i = 0; i < N; ++i) {
		std::cin >> x;
		a[i] = x-(i+1);
		
	}
	SORT(a);
	b = a[N / 2];
	for (int i = 0; i < N; i++) {
		ans += std::abs(a[i] - b);
	}
	std::cout << ans << std::endl;
	return 0;
	
}

Measured memory_bytes: 1024
N = int(input())
S = input()

level = [0] * (N + 1)
level_tmp = 0
for i in range(N):
    level_tmp += (1 if S[i] == '(' else -1)
    level[i + 1] = level_tmp

# print("#", level)

left = '(' * max(0, -1 * min(level))
right = ')' * max(0, level[-1] + max(0, -1 * min(level)))

print(left + S + right)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int arr[n];
    int i,alice=0,bob=0;
    for(i=0;i<n;i++){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    for(i=0;i<n;i++)
    {
        if(i%2==0)
        alice+=arr[i];
        else
        {
            bob+=arr[i];
        }
        
    }

    cout<<abs(alice-bob)<<endl;
}

Measured memory_bytes: 3616
import java.util.*;

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

Measured memory_bytes: 23764
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
using mint=modint998244353;
pair<mint, int> f(pair<mint, int> a, pair<mint, int> b){
	return make_pair(a.first+b.first, a.second+b.second);
}
pair<mint, int> g(pair<mint, mint> x, pair<mint, int> a){
	return make_pair(x.first*a.first+x.second*a.second, a.second);
}
pair<mint, mint> h(pair<mint, mint> y, pair<mint, mint> x){
	return make_pair(x.first*y.first, y.first*x.second+y.second);
}
pair<mint, int> e(){
	return make_pair(0, 0);
}
pair<mint, mint> id(){
	return make_pair(1, 0);
}
int main()
{
    int n, q;
    scanf("%d %d", &n, &q);
    vector<pair<mint, int>> a(n);
    for(int i=0; i<n; i++){
        int a1;
        scanf("%d", &a1);
        a[i]=make_pair(a1, 1);
    }
	lazy_segtree<pair<mint, int>, f, e, pair<mint, mint>, g, h, id> seg(a);
    while(q--){
        int t, l, r;
        scanf("%d %d %d", &t, &l, &r);
        if(t==0){
            int b, c;
            scanf("%d %d", &b, &c);
            seg.apply(l, r, make_pair(b, c));
        }else{
            printf("%d\n", seg.prod(l, r).first.val());
        }
    }
    return 0;
}


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

int main() {
    int N,K;
    cin >> N >> K;
    vector<int> d(N+1,0);
    
    int cnt = 0;
    int ans = 0;
    for(int i = 0; i < N;i++){
        int a;
        cin >> a;
        d[a]++;
    }
    sort(d.begin(),d.end());
    for(int i = 1; i <= N; i++){
        if(d[i] > 0){
            cnt++;
        }
    }
    for(int i = 0; i < N; i++){
         if(cnt <= K){
            break;
        }
        if(d[i] > 0){
        ans +=d[i];
        cnt--;
        }      
        }
    cout << ans << endl;

}

Measured memory_bytes: 1024
// https://atcoder.jp/contests/abc147/submissions/8853537
// https://outline.hatenadiary.jp/entry/2019/12/17/021530
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

const int mod = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<int64_t> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    int64_t sum = 0;
    for (int i = 0; i < 60; i++) {
        int64_t cnt = 0;    // 数列Aの各要素を二進表記したときの，各要素のi桁目にある1の個数
        for (int j = 0; j < n; j++) cnt += (a[j]>>i)&1;
        int64_t tmp = cnt*(n-cnt)%mod;  // i桁目のXORの総和
        for (int j = 0; j < i; j++) tmp = tmp*2%mod;
        sum += tmp;
    }

    cout << sum%mod << endl;
}


Measured memory_bytes: 2688
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e15;
const int MOD = 1e9 + 7;

signed main() {
	int W, a, b;
	cin >> W >> a >> b;
	int big = max(a, b);
	int small = min(a, b);
	int ans = max(0ll, big - small - W);
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> P;
typedef long long int ll;
typedef pair<int,int> Pii;
const int INF=(1<<30)-1;
const ll INFl=9223372036854775807;
const int MAX=310;
const ll MOD=1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}


int n;
int a[100100];
int main(void){
	cin>>n;
	REP(i,n)
		cin>>a[i];
	int ans=gcd(a[0],a[1]);
	
	for(int i=2;i<n;i++){
		ans=gcd(a[i],ans);
	}
	cout<<ans<<endl;
}

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

int a , b, x,y ;
cin >> a;
cout << endl;
cin >> b;
cout << endl;
 cin>> x ;
 cout << endl;
 cin>>y;
 if (a> b){
    cout << (x*b)+ (y*(a-b));
 }
else {
    cout << x*a;
}
return 0 ;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
A = []
for i in range(N):
    a,b = map(int,input().split())
    A.append([a,b])
A.sort()

for i in range(N):
    K = K - A[i][1]
    if K <= 0:
        print(A[i][0])
        exit(0)


Measured memory_bytes: 24236
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;

//
#define int long long
#define pb(x) push_back(x)
#define m0(x) memset((x), 0, sizeof(x))
#define mm(x) memset((x), -1, sizeof(x))

//container
#define ALL(x) (x).begin(), (x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define UNIQUE(v) (v).erase(unique((v).begin(), (v).end()), (v).end());
#define PERM(c) \
  sort(ALL(c)); \
  for (bool c##p = 1; c##p; c##p = next_permutation(ALL(c)))

// debug
#define GET_VAR_NAME(variable) #variable
#define test(x) cout << GET_VAR_NAME(x) << " = " << x << endl;

// bit_macro
#define bit(n) (1LL << (n))
#define bitset(a, b) (a) |= (1 << (b))
#define bitunset(a, b) (a) |= ~(1 << (b))
#define bitcheck(a, b) ((((a) >> (b)) & 1) == 1)
#define bitcount(a) __builtin_popcountll((a))

//typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

//constant
const int INF = (int)1e18;
const int MOD = (int)1e9 + 7;
const double PI = (double)acos(-1);
const double EPS = (double)1e-10;
const int dx[] = {-1, 0, 0, 1, 0, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, 0, 1, -1, 1, -1};

//
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); }
//
inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}
template <class T>
inline string toString(T x) {
  ostringstream sout;
  sout << x;
  return sout.str();
}

//
struct Accelerate_Cin {
  Accelerate_Cin() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};

signed main() {
  int a, b, k;
  cin >> a >> b >> k;

  int cont = 0;
  for (int i = 100; 1 <= i; i--) {
    if (a % i == 0 && b % i == 0) cont++;
    if (cont == k) {
      cout << i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
# define ll long long
# define mod 1000000007
using namespace std;
int main()
{
	int a[3][3],b[3][3];
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>a[i][j];
			b[i][j]=0;
		}
	}
	int n;
	cin>>n;
	for(int k=0;k<n;k++){
		int x;
		cin>>x;
		for(int i=0;i<3;i++){
			for(int j=0;j<3;j++){
				if(x==a[i][j])
				b[i][j]=1;
			}
		}
	}/*
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cout<<b[i][j]<<" ";
		}
		cout<<"\n";
	}*/
	int flag=0,sum3=0,sum4=0;
	for(int i=0;i<3;i++){
		int sum1=0,sum2=0;
		for(int j=0;j<3;j++){
			sum1+=b[i][j];
			sum2+=b[j][i];
			if(i==j)
			sum3+=b[i][j];
			if(j+i==2)
			sum4+=b[i][j];
		}
		if(sum1==3||sum2==3){
			flag=1;
			break;
		}
	}
	if(sum3==3||sum4==3)
	flag=1;
	if(flag==1)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
/*-------------------------------"ANJAN AGARWALA"-----------------------------

         _/_/_/_/    _/_/    _/   _/_/_/_/   _/_/_/_/    _/_/    _/   
        _/    _/    _/ _/   _/         _/   _/    _/    _/ _/   _/        
       _/_/_/_/    _/   _/ _/         _/   _/_/_/_/    _/  _/  _/         
      _/    _/    _/    _/_/   _/    _/   _/    _/    _/    _/_/  
     _/    _/    _/      _/   _/_/_/_/   _/    _/    _/      _/   

-------------------------------------@anjn98---------------------------------*/

//#define opti
#ifdef opti
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif

#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long long int LL;
typedef unsigned long long int ull;
ll power(ll x,ll y,ll p){ll r=1; x=x%p; while(y){ if(y&1) r= r*x%p; y=y>>1; x=x*x%p; } return r; }
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;*/

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int csrand(int l=0, int r=1e9){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

#define IO              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FILEIO          freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define all(v)          v.begin(),v.end()
#define PR(a)           cout<<"("<<a<<")";
#define ED              cout<<'\n';
#define endl            '\n'
#define loop(j,a,n)     for(int j=a;j<=n;j++)
#define loop1(j,a,n)    for(int j=a;j>=n;j--)
#define fr1(j,n)        for(int j=0;j<n;j++)
#define fr(n)           for(int i=0;i<n;i++)
#define trav(x,s)       for(auto x:s)
#define SC(n)           scanf("%d",&n)
#define PB              push_back
#define MP              make_pair
#define pii             pair<int,int>
#define pll             pair<long long int,long long int>
#define F               first
#define S               second 
#define binf            2000000000000000001
#define mod             1000000007

const int N=3e3+99;
int n;
double dp[N][N],prob[N];
bool vis[N][N];
double solve(int i,int cnt)
{
    if(i==n+1)
        return cnt > n-cnt ?    1.0 :   0.0 ; 

    if(vis[i][cnt]) return dp[i][cnt];

    vis[i][cnt]=1;
    dp[i][cnt] =    prob[i]*solve(i+1,cnt+1)   +    (1.0-prob[i])*solve(i+1,cnt);

    return dp[i][cnt];
}

int main() 
{
    IO


    for(int i=0;i<N;i++)
        for(int j=0;j<N;j++) dp[i][j]=-1.0;
    
    cin>>n; 

    for(int i=1;i<=n;i++) cin>>prob[i];

    double ans=solve(1,0);
    
    cout<<fixed<<setprecision(10);
    cout<<ans<<endl;

}




 

Measured memory_bytes: 84864
import sys
sys.setrecursionlimit(10**6)

def f(data):
    tmp=links[data[0]]
    for x in tmp:
        if ans[x]==-1:
            ans[x]=data[0]
            q.append([x, data[0]])

from collections import deque

N, M=map(int, input().split())
links=[[] for _ in range(N+1)]
for _ in range(M):
    A, B=map(int, input().split())
    links[A].append(B)
    links[B].append(A)
    
q=deque()
q.append([1, -1])#imadoko, dokokara, 
ans=[-1]*(N+1)
ans[0]=0
ans[1]=0
while len(q)>0:
    data=q.popleft()
    f(data)
    
print('Yes')
print(*ans[2:], sep='\n')

Measured memory_bytes: 103176
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fast() ios_base::sync_with_stdio(0),cin.tie(0)
int32_t main()
{int n,i;
 cin>>n;
 vector<int> v(n),dp(n);
 for(i=0;i<n;++i)
 cin>>v[i];
 dp[0]=0;
 dp[1]=abs(v[1]-v[0]);
 for(i=2;i<n;++i)
 dp[i]=min({dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2])});
 //for(auto x:dp)
 //cout<<x<<" ";
 //cout<<"\n";
 cout<<dp[n-1];
 return 0;
}





Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main()
{
	int a, b;
	int c = 0;
	int x[3000];
	int y[3000];
	cin >> a;
	cin >> b;
	for ( int i = 0; a != 0 || b != 0; i++){
		x[i] = a;
		y[i] = b;
		cin >> a;
		cin >> b;
		c++;
	}
	for (int i = 0; i < c; i++){
		if(x[i] > y[i]) swap(x[i], y[i]);
	}
	
	for ( int i = 0; i < c; i++){
		cout << x[i] << " " << y[i] << endl;
	}
	return 0;
}


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

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

    int mi = a[0],ans = a[1]- a[0];
    for(int i=0;i<n-1;i++){
        mi = min(mi, a[i]);
        ans = max(ans, a[i+1] - mi);
    }

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


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;

int main()
{
    fast_io
    ll i,j,cnt=0,n,s;
    cin>>n>>s;
    ll x,mini=INT_MAX;
    for(i=0; i<n; i++)
    {
        cin>>x;
        mini=min(x,mini);
        if(x<=s)
        {
            cnt++;
            s-=x;
        }
    }
    if(cnt==n)
    {
        cnt+=(s/mini);
    }

    cout<<cnt<<endl;

    return 0;
}





Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
using namespace std;
 
 
const int N=1e6+5,MOD=1e9;
 
const int dx[]={0,1,-1,0},
          dy[]={1,0,0,-1};
 
typedef long long ll;
 
int n,m,k,a[N],b[N],q,u,x,y,tc,c,ans;
 
char s[N],s2[N];
 
vector<int> v;

int main() {
    
    scanf("%d%d%d",&n,&k,&q);
    for(int i=0;i<q;i++){
        scanf("%d",&x);
        x--;
        a[x]++;
    }
    for(int i=0;i<n;i++){
        if (a[i]+k>q)
            printf("Yes\n");
        else
            printf("No\n");
    }
}

Measured memory_bytes: 4736
import sys
s = input()
t = input()
l = len(t)
if t in s:
    print(s.replace('?', 'a'))
    sys.exit()
m = -1
for i in range(len(s) - l + 1):
    f = True
    for j in range(l):
        if s[i:i+l][j] == '?' or s[i:i+l][j] == t[j]:
            pass
        else:
            f = False
    if f:
        m = i
if m < 0:
    print('UNRESTORABLE')
else:
    print((s[0:m] + t + s[m+l:]).replace('?', 'a'))


Measured memory_bytes: 3064
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int ta, ao;
	ta = (c + b - 1) / b;
	ao = (a + d - 1) / d;
	if (ta <= ao)cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef vector<bool> vb;


#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m;i>=n;i--)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

ll h,w;
vs s;
ll res=0;
vvll flag(405,vll(405,0));
vector<vector<vpll>> G(405,vector<vpll>(405));
queue<pll> que;


void solve(){
  cin >> h >> w;
  s.resize(h);
  rep(i,0,h) cin >> s[i];
 
  rep(i,0,h){
   rep(j,0,w){
     if(flag[i][j]) continue;
     flag[i][j]=1;
     que.push(pll(i,j));
     ll black=0,white=0;
     while(!que.empty()){
      pll p=que.front();
       que.pop();
       ll y,x;
        tie(y,x)=p;
      (s[y][x]=='#')?black++:white++;
       
       if(y+1<h&&s[y+1][x]!=s[y][x]&&flag[y+1][x]==0) {
         flag[y+1][x]=1;
         que.push(pll(y+1,x));
       }
       if(y-1>=0&&s[y-1][x]!=s[y][x]&&flag[y-1][x]==0) {
         flag[y-1][x]=1;
         que.push(pll(y-1,x));
       }
       if(x+1<w&&s[y][x+1]!=s[y][x]&&flag[y][x+1]==0) {
         flag[y][x+1]=1; 
         que.push(pll(y,x+1));
       }
         if(x-1>=0&&s[y][x-1]!=s[y][x]&&flag[y][x-1]==0) {
          flag[y][x-1]=1;
           que.push(pll(y,x-1)); 
       
         }
      
     }
     res+=black*white;
   }
  }
  cout << res << endl;
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}  

Measured memory_bytes: 5632
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<list>
#include<stack>
#include<cstring>
#include<string>
#include<cmath>
using namespace std;

int main(){
	int N;
	while(cin>>N,N){
		int M,W,D,dp[31][10];
		char S[30][9];
		for(int i=0;i<10;i++) dp[0][i]=i;
		cin>>M>>W>>D; M--; W--;
		for(int i=0;i<D;i++){
			for(int j=0;j<N;j++){
				if(j<N-1) cin>>S[i][j];
				if(j<N-1 && S[i][j]=='1'){
					dp[i+1][j] = dp[i][j+1];
					dp[i+1][j+1] = dp[i][j];
				}
				else if(j==0 || S[i][j-1]=='0'){
					dp[i+1][j] = dp[i][j];
				}
			}
		}
		if(dp[D][W]==M){
			puts("0"); continue;
		}
		int ws = dp[D][W],ans1=-1,ans2;
		for(int i=0;i<D;i++){
			for(int j=0;j<N-1;j++){
				if(S[i][j]=='0' && (j==0 || S[i][j-1]=='0') && (j==N-2 || S[i][j+1]=='0') &&
					((dp[i][j]==M && dp[i][j+1]==ws) || (dp[i][j]==ws && dp[i][j+1]==M))){
					ans1 = i+1; ans2 = j+1;
					goto OUT;
				}
			}
		}
		OUT:
		if(ans1==-1) puts("1");
		else printf("%d %d\n",ans1,ans2);
	}
}

Measured memory_bytes: 1148
#include <cstdio>
#include <map>
#include <cstring>
#include <algorithm>
using namespace std;
const int maxn=2e5+10;

char c[maxn];
map<int,int> dp;
int ans[maxn];
int n,a[maxn];

int main()
{
	scanf("%s",c+1);
	n=strlen(c+1);
	
	for(int i=1;i<=n;i++)
		a[i]=a[i-1]^(1<<(c[i]-'a'));
	dp.clear();
	dp[0]=0;
	ans[0]=0;
	
	for(int i=1;i<=n;i++)
	{
		ans[i]=n+10;
		if (dp.find(a[i])!=dp.end()) ans[i]=dp[a[i]]+1;
		for(int j=0;j<26;j++)
		{
			if (dp.find(a[i]^(1<<j))==dp.end()) continue;
			ans[i]=min(ans[i],dp[a[i]^(1<<j)]+1);
		}
		if (dp.find(a[i])==dp.end())
			dp[a[i]]=ans[i];
		else dp[a[i]]=min(dp[a[i]],ans[i]);
	}
	
	printf("%d\n",ans[n]);
	return 0;
}

Measured memory_bytes: 11520
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#define rep(i,n) for(int i =0;i<(int)(n);i++)
typedef long long ll;
using namespace std;
int main() {
    double l;
	cin >> l;
	double dd = l / 3;
	double ans = dd * dd*(l - 2 * dd);
	printf("%.7lf", ans);
	return 0;
}


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


int main() {
	int N, M;
	scanf("%d %d", &N, &M);
	int a[10010] = { 0 };
	int i;
	int sum = 0;

	for (i = 1; i < M + 1; i++) {
		scanf("%d", &a[i]);
		sum =sum + a[i];
	}
	if (N >= sum) {
		printf("%d", N - sum);
	}
	else {
		printf("-1");
	}
		return 0;
}


Measured memory_bytes: 1776
require 'bigdecimal'
require 'bigdecimal/util'

n,k = gets.strip.split.map(&:to_f)
m = n
array = []

coin = 0

while n > 0 do
  x = k / n
  while x > 2 ** coin do
    coin += 1
  end
  array << coin
  n -= 1
end

ans = 0.0.to_f
array.each do |ele|
  ans += (1.to_f / ((2 ** ele) * m).to_f)
end
p ans

Measured memory_bytes: 2740
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll n = 0;
  cin >> n;
  ll res = 0;
  for(int i = 1;i <= n;i++){
    ll now = 0;
    for(int j = 1;j <= n;j++){
      if(i % j == 0)now++;
    }
    if(i % 2 == 1 && now == 8)res++;
  }
  cout << res << endl;
}

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

signed main()
{
    long int N;
    long int a[100000] = {0}, b[100000] = {0};
    long int t=0, i, c;
    cin >> N;
    for(i=0;i<N;i++){
        cin >> a[i] >> b[i];
    }
    for(i=N-1;i>=0;i--){
        if((a[i]+t)%b[i]==0)c=0;
        else c = (b[i] - (a[i]+t) % b[i]);
        t += c;
        //cout << c << endl;
    }
    cout << t << endl;
    return 0;

}

Measured memory_bytes: 1792
/*input
chokudai
chokudaiz
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s,t;
    cin>>s>>t;
    if(t.substr(0,s.length())==s)
    cout<<"Yes\n";
    else
    cout<<"No\n";
}

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

using namespace std;

int h, w, k;

void combi(int before, int n, int r, vector<vector<int> > & vec, vector<int> & tmp){
    if(tmp.size() == r){
        vector<int> to_copied = tmp;
        vec.push_back(to_copied);
        return;
    }
    for(int i=before+1; i<n; i++){
        tmp.push_back(i);
        combi(i, n, r, vec, tmp);
        tmp.pop_back();
    }
}

void color1(vector<vector<char>> &maap, vector<int> row){
    for(int i:row){
        for(int j=0; j<w; j++){
            maap[i][j] = 'r';
        }
    }    
}

void color2(vector<vector<char>> &maap, vector<int> col){
    for(int i=0; i<h; i++){
        for(int j : col){
            maap[i][j] = 'r';
        }
    }    
}

int inspect(vector<vector<char>> &maap){
    int n = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(maap[i][j] == '#')
                n++;
        }
    }
    return n;
}

int main()
{
    vector<vector<int>> rows, cols;
    vector<vector<char>> maap(6, vector<char>(6, '#'));
    cin >> h >> w >> k;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> maap[i][j];
        }
    }
    vector<int> tmp1, tmp2;
    int ans = 0;
    for(int r=0; r<=h; r++)
        combi(-1, h, r, rows, tmp1);
    for(int r=0; r<=w; r++)
        combi(-1, w, r, cols, tmp2);
    for(vector<int> row : rows){
        for(vector<int> col : cols){
            vector<vector<char> > tmp_map = maap;
            color1(tmp_map, row);
            color2(tmp_map, col);
            int n = inspect(tmp_map);
            if(n == k){
                // cout << "rows : " ;
                // for(int r : row) cout << r << ' ';
                // cout << "'\n cols : ";
                // for(int c : col) cout <<c << ' ';
                // cout << '\n';
                ans++;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3608
import java.util.Scanner;

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

		int A = sc.nextInt();
		int B = sc.nextInt();

		int plus = A + B;
		int minus = A - B;
		int kakeru = A * B;

		int res = Math.max(plus, minus);

		if(res > kakeru){
			System.out.println(res);
		} else {
			System.out.println(kakeru);
		}
		
	}
}


Measured memory_bytes: 21844
s = input()
t = s.replace('x','')
if t != t[::-1]:
	print(-1)
	exit()
x = []
cnt = 0
for i in s:
	if i == 'x':
		cnt += 1
	else:
		x.append(cnt)
		cnt = 0
else:
	x.append(cnt)
res = 0
for i in range(len(x)//2):
	res += abs(x[i]-x[-i-1])
print(res)


Measured memory_bytes: 3956