akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

using namespace std;

int main() {
    int W, H, x, y, r;

    cin >> W >> H >> x >> y >> r;

    if ((x >= r) && (x <= W - r) && (y >= r) && (y <= H - r))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3064
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a, b, c;
    
    scanf("%d %d %d", &a, &b, &c);
    
    if (a<b && b<c) {
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    
    return 0;
}


Measured memory_bytes: 2076
H,W = map(int, input().split())
L = []
while H != 0 or W != 0:
 L.append([H, W])
 H,W = map(int, input().split())

def draw(H,W):
 for i in range(H):
  print("#" * W)
 print("")

for (H, W) in L:
 draw(H,W)

Measured memory_bytes: 7700
def solve():
  N = int(input())
  A = list(map(int, input().split()))
  ave = sum(A)/N
  B = list(map(lambda x:abs(x-ave),A))
  for i in range(N):
    B[i] = [B[i],i]
  B.sort(key=lambda x:(x[0],x[1]))
  ans = B[0][1]
  return ans
print(solve())

Measured memory_bytes: 62016
package main

import "fmt"

func main() {
	var lastMonth, lastDay int
	fmt.Scanf("%d %d\n", &lastMonth, &lastDay)

	nSekiDays := 0
	for d := 22; d <= lastDay; d++ {
		d1 := d % 10
		d10 := d / 10
		if d1 >= 2 && d1*d10 <= lastMonth {
			nSekiDays += 1
		}
	}

	fmt.Println(nSekiDays)
}


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

using namespace std;

const int N = 2e5+ 10;
const int M = 4e5 + 10;//undirect edge

struct Edge{
	int to, next, val;
}e[M];

char col[N];
int aflag[N], bflag[N], q[N], del[N], ecnt, head[N];

inline void adde(int x, int y) {
	e[++ecnt].to = y;
	e[ecnt].next = head[x];
	head[x] = ecnt;
}

int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	scanf("%s", col + 1);
	for(int i = 1, la, lb; i <= m; ++i) {
		scanf("%d %d", &la, &lb);
		adde(la, lb);
		adde(lb, la);
		if(col[lb] == 'A') aflag[la] += 1;
		else bflag[la] += 1;
		if(col[la] == 'A') aflag[lb] += 1;
		else bflag[lb] += 1;
	}	
	int qhd = 1, qtl = 1;
	for(int i = 1; i <= n; ++i){
		if(!aflag[i] || !bflag[i])
			q[qtl++] = i;
	}
	while(qhd != qtl){
		int u = q[qhd++], qwq;
		if(del[u]) continue;
		del[u] = 1;
		if(col[u] == 'A') qwq = 1;
		else qwq = 2;
		for(int i = head[u]; i; i = e[i].next){
			if(!del[e[i].to]){
				if(qwq == 1) {
					aflag[e[i].to]--;
					if(!aflag[e[i].to])
						q[qtl++] = e[i].to;
				}else {
					bflag[e[i].to]--;
					if(!bflag[e[i].to])
						q[qtl++] = e[i].to;
				}				
			}

		}
		
	}
	for(int i = 1; i <= n; ++i)
		if(!del[i]){
			printf("Yes");
			return 0;
		}
	printf("No");
	return 0;	
}


Measured memory_bytes: 8704
import fractions
n,x=map(int,input().split())
x_list=list(map(int,input().split()))
x_list.append(x)

x_list.sort()
x_sa=[]
a=x_list[1]-x_list[0]
for i in range(1,n):
  b=x_list[i+1]-x_list[i]
  a=fractions.gcd(a,b)
print(a)

Measured memory_bytes: 16280
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (ll i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 
const int mod = 1e9 + 7, mxn = 1e5 + 1;

int solve(){
    int n, ans = 0;
    cin>> n;
    rep(i, 1, n){
        ans += (n / i);
        if(n%i == 0)
            ans--;
    }    
    cout<< ans<< "\n";
    return 0;
}
//Counting problems: Sometimes easier to find complement of the answer
 
int main()
{
    fast;
    int t = 1;
    //cin>> t;
    while(t--){  
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);
 
/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/
        
// lower bound   >=  
// upper bound   >
// vector<int>().swap(vec); //free memory from vec


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

using namespace std;
int main(){
int a=0,b=0,c=0,d=0;
scanf("%d %d %d",&a,&b,&c);
if (a > c){
   swap(a,c);}
if (a > b){
   swap(a,b);}
if (b > c){
   swap(b,c);}
   printf("%d %d %d\n",a,b,c);
return 0;
}


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

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


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    cout << fixed << setprecision(10);

    double l;
    cin >> l;

    l /= 3;
    cout << l * l * l << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i= (a); i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() { ll H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  ll ans = 0;
  ans += (H2 - H1) * 60;
  ans += (M2 - M1);
  ans -= K;
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<lli,lli> pll;
typedef std::vector<lli> vll;
typedef std::vector<pll> vpll;
typedef std::vector<bool> vbb;
typedef map<lli,lli>mll;
typedef map<lli,lli,greater<lli>>mllg;
lli MOD=1e9 +7;
const lli INF=1e18;
#define forr(i,p,n) for(i=p; i<n; i++)
#define be(a) a.begin(),a.end()
#define mp make_pair
#define um unordered_map
#define eb emplace_back 
#define pb push_back 
#define F first
#define S second
lli sub(lli a,lli b,lli p=MOD){return ((a%p)-(b%p)+p)%p;}
lli mult(lli a,lli b, lli p=MOD) {return ((a%p)*(b%p))%p;}
lli add(lli a, lli b, lli p=MOD) {return (a%p + b%p)%p;}
lli fpow(lli n, lli k, lli p = MOD) {lli r = 1; while(k > 0) {if (k & 1) r = r * n%p; n = n * n%p; k = k >> 1;} return r;}
lli inv(lli a, lli p = MOD) {return fpow(a, p - 2, p);}
lli fdiv(lli a,lli b,lli p=MOD){
	lli yinv=inv(b);
	lli ans=(a*yinv)%p;
	return ans;
}
ull I1018=1000000000000000000;const ull I10e5=100000;const lli I10e6=1e6;
lli ZERO=0;ull I10e9=1000000000;lli ONE=1;
void printVecpll(std::vector<pll> v){
	for(auto p:v){
		cout<<(char)p.first<<" "<<p.second<<endl;
	}
}
void printVec(std::vector<lli> v){
	for(lli i=0;i<v.size();i++){
		cout<<v[i]<<" ";
	}
	cout<<endl;
}
vll read_vec(lli n){
	lli i;
	vll v(n);
	forr(i,0,n){
		cin>>v[i];
	}
	return v;
}
void print_um(unordered_map<lli,lli>m){
	for(pair<lli,lli>p:m){cout<<p.first<<" "<<p.second<<endl;   }
}
std::vector<bool> is_prime;
std::vector<lli> primes;
void sieve(lli n){
	is_prime.resize(n+2,true);
	primes.clear();
	lli p;
	for(p=2;p*p<=n;p++){
		if(is_prime[p]){
			lli i;
			for(i=p*p;i<=n;i+=p){
				is_prime[i]=false;
			}
		}
	}
	is_prime[0]=is_prime[1]=false;
	lli i;
	for(i=2;i<=n;i++){
		if(is_prime[i]){
			primes.eb(i);
		}
	}
}

//     //FACTORIAL
// std::vector<lli> fact_vec(10004);
// void fact_fun(lli n){
// 	lli i;
// 	fact_vec[0]=1;
// 	for(i=1;i<=n+2;i++){
// 		fact_vec[i]=(fact_vec[i-1]*i)%MOD;
// 	}
// }

    //declare

// class Sol{      	
// public: 
// 	Sol(){			
// 	}
// };
int main(){	
	ios::sync_with_stdio(false);
	cin.tie(0);
 //    #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
 //    #endif
	
	lli n;
	cin>>n;
	lli i;
	bool flag=false;
	for(i=1;i<=9;i++){
		if(n%i==0){
			lli t=n/i;
			if(t<=9 && t>0){
				flag=true;
				break;
			}
		}
	}
	if(flag){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}   




Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
bool judge(string s,int j,int k,int n){
    for(int i = 0;i<n;i++){
        if(s[j+i]!=s[k+i]) return false;
    }
    return true;
}
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int tmpans = 0;
    for(int i = 1;i<n;i++){
        int streak = 0;
        int tmp = 0;
        for(int j = 0;j<n-i;j++){
            if(s[j]==s[j+i]) streak++;
            else{
                if(streak<=i) tmp = max(streak,tmp);
                else tmp = max(i,tmp);
                streak = 0;
            }
            //cout << s[j] << " " << s[j+i] << endl;
        }
        if(streak<=i) tmp = max(streak,tmp);
        else tmp = max(i,tmp);
        tmpans = max(tmpans,tmp);
        //cout << tmpans << endl;
    }
    cout << tmpans << endl;
}

Measured memory_bytes: 256
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,m = iim()

pe = []
ch = []
for i in range(n):
    pe.append(iil())

for j in range(m):
    ch.append(iil())

for k in pe:
    dist = 1000000000
    point = 0
    for ind,l in enumerate(ch):
        if abs(k[0]-l[0])+abs(k[1]-l[1]) < dist:
            dist = abs(k[0]-l[0])+abs(k[1]-l[1])
            point = ind+1
    print(point)

Measured memory_bytes: 3064
class Dice:
    def __init__(self):
        self.u=1
        self.w=2
        self.s=3
        self.e=4
        self.n=5
        self.d=6
        self.dic={"W":0,"S":1,"E":2,"N":3}
     
    def __init__(self,u,w,s,e,n,d):
        self.u=u
        self.w=w
        self.s=s
        self.e=e
        self.n=n
        self.d=d
        self.dic={"W":0,"S":1,"E":2,"N":3}
 
    def rot(self,way):
        if isinstance(way,str):
            way=self.dic[way]
 
        if(way==0):
            c=self.u
            self.u=self.e
            self.e=self.d
            self.d=self.w
            self.w=c
        elif way==1:
            c=self.u
            self.u=self.n
            self.n=self.d
            self.d=self.s
            self.s=c
        elif way==2:
            c=self.u
            self.u=self.w
            self.w=self.d
            self.d=self.e
            self.e=c
 
import random
u,s,e,w,n,d=map(int,input().split())
dice=Dice(u,w,s,e,n,d)
u,s,e,w,n,d=map(int,input().split())
dice_b=Dice(u,w,s,e,n,d)
ok=False
for i in range (1000):
    dice.rot(random.randint(0,3))
    if(dice.u==dice_b.u and dice.d==dice_b.d and dice.w==dice_b.w and dice.s==dice_b.s and dice.e==dice_b.e and dice.n==dice_b.n):
        ok=True
if ok:
    print('Yes')
else :
    print('No')


Measured memory_bytes: 8192
#include<iostream>
#include<vector>

using namespace std;



int main()
{
	int n;
	cin >> n;
	int odd = 0;
	int even = 0;
	int forth = 0;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		if (x % 2 == 0) {
			if (x % 4 == 0)forth++;
			else even++;
		}
		else odd++;
	}
	if (odd <= forth) {
		cout << "Yes" << endl;
	}
	else if (odd - 1 == forth && even == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}



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

const int SIZE = 1000;
bool prime[SIZE * SIZE + 1];
int table[SIZE][SIZE];
int dp[SIZE][SIZE];
int pr[SIZE][SIZE];

int main() {
	int m, n;
	int y = 500, x = 499;
	int a = 1;

	prime[0] = true;prime[1] = true;
	for (int i = 2;i <= SIZE*SIZE;i++) {
		if (!prime[i]) {
			for (int j = i * 2;j <= SIZE*SIZE;j += i) {
				prime[j] = true;
			}
		}
	}
	
	table[y][x] = a;a++;x++;
	for (int i = 1;i < SIZE;i++) {
		for (int j = 0;j < i;j++) {
			table[y][x] = a;
			a++;
			if (i % 2 == 0)y++;
			else y--;
		}
		for (int j = 0;j < i + 1;j++) {
			table[y][x] = a;
			a++;
			if (i % 2 == 0)x++;
			else x--;
		}
	}
	while(true) {
		scanf("%d %d", &m, &n);
		if (m == 0 || n == 0)return 0;
		
		for (int i = 0;i < SIZE;i++) {
			for (int j = 0;j < SIZE;j++) {
				dp[i][j] = 0;
				pr[i][j] = 0;
			}
		}
		
		for(int i = SIZE - 1;i >= 0;i--){
			for(int j = SIZE - 1;j >= 0;j--){
				if (table[i][j] <= m) {
					if (i + 1 < SIZE) {
						if (j > 0 && table[i + 1][j - 1] <= m){
							if (dp[i][j] < dp[i + 1][j - 1] || (dp[i][j] == dp[i + 1][j - 1] && pr[i][j] < pr[i + 1][j - 1])) {
								dp[i][j] = dp[i + 1][j - 1];
								pr[i][j] = pr[i + 1][j - 1];
							}
						}
						if (table[i + 1][j] <= m){
							if (dp[i][j] < dp[i + 1][j] || (dp[i][j] == dp[i + 1][j] && pr[i][j] < pr[i + 1][j])) {
								dp[i][j] = dp[i + 1][j];
								pr[i][j] = pr[i + 1][j];
							}
						}
						if (j + 1 < SIZE && table[i + 1][j + 1] <= m){
							if (dp[i][j] < dp[i + 1][j + 1] || (dp[i][j] == dp[i + 1][j + 1] && pr[i][j] < pr[i + 1][j + 1])) {
								dp[i][j] = dp[i + 1][j + 1];
								pr[i][j] = pr[i + 1][j + 1];
							}
						}
					}
					if (!prime[table[i][j]]) {
						dp[i][j]++;
						if (pr[i][j] == 0) {
							pr[i][j] = table[i][j];
						}
					}
				}
			}
		}
		
		for (int i = 0;i < SIZE;i++) {
			for (int j = 0;j < SIZE;j++) {
				if (table[i][j] == n) {
					printf("%d %d\n", dp[i][j], pr[i][j]);
				}
			}
		}
	}
}

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

using namespace std;

int main() {
  int x;
  cin >> x;
  int M = 1;
  if ( x <= 3 ) {
    cout << 1 << endl;
    return 0;
  }
  for ( int i = 2; i <= floor( sqrt(x) ); i++ ) {
    for ( int j = 2; j < x; j++ ) {
      int p = pow( i, j );
      if ( p <= x ) {
        M = max( M, p );
      }
      else break;
    }
  }
  cout << M << endl;
  return 0;
}


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

int main(){
	unsigned long long a;
    scanf("%lld",&a);
    unsigned long long sum=a*(a+1)/2;
    unsigned long long sumthree=(3+(a/3)*3)*(a/3)/2;
    unsigned long long sumfive=(5+(a/5)*5)*(a/5)/2;
    unsigned long long sumfiveteen=(15+(a/15)*15)*(a/15)/2;
    if(a>=15){
    	printf("%llu\n",sum-sumthree-sumfive+sumfiveteen);
	}else if(a>=5){
    	printf("%llu\n",sum-sumthree-sumfive);
	}else if(a>=3){
    	printf("%llu\n",sum-sumthree);
	}else{
		if(a==2){
			printf("3\n");
		}else{
			printf("1\n");
		}
	}
    return 0;

}

Measured memory_bytes: 1732
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] v = new int[N];
        for (int i = 0; i < N; i++) {
            v[i] = sc.nextInt();
        }
        System.out.println(solve(v,K,N));
    }

    static  int solve(int[] v, int K,int N){

        int max = 0;
        for (int L = 0; L <=K  ; L++) {
            for (int R = 0; R <= K-L  ; R++) {
                if( L+R > N) break;
                int d = K- (L+R);
                int sum = 0;
                List<Integer> list = new ArrayList<>();
                for (int i = 0; i < R; i++) {
                    list.add(v[i]);
                    sum += v[i];
                }
                for (int i = N-1 ; i >= N-L; i--) {
                    list.add(v[i]);
                    sum += v[i];
                }
                Collections.sort(list);
                for (int i = 0; i < Math.min(list.size(),d); i++) {
                    int num = list.get(i);
                    if(num>=0) break;
                    sum -= num;
                }
                max = Math.max(max,sum);
            }
        }
        return max;

    }
}


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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, k, t;
ll ans;

unordered_map<int, int> mp;
int res[N];
int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> t;
        ++mp[t];
        if (mp[t] == 2) {
            res[k++] = t;
        } if (mp[t] == 4) {
            ans = max(ans, 1LL * t * t);
        }
    }
    if (k <= 1) {
        cout << ans << endl;
        exit(0);
    }
    sort(res, res + k, greater<int>());
    ans = max(ans, 1LL * res[0] * res[1]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7280
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}
class Edge{
public:
    int from, to;
    long long cost;
    Edge(): from(0), to(0), cost(0){};
    Edge(int u, int v, long long w): from(u), to(v), cost(w){};
    ~Edge(){};
};

void Warshall_Floyd(std::vector<Edge> &edge, int V,
    std::vector<std::vector<long long> > &d)
{
    int E = edge.size();
    const long long infty = 1e+16;
    for(int i=0; i<V; i++){
        for(int j=0; j<V; j++) d[i][j] = (i==j) ? 0 : infty;
    }
    // initialize
    for(int i=0; i<E; i++){
        d[edge[i].from][edge[i].to] = edge[i].cost;
        d[edge[i].to][edge[i].from] = edge[i].cost;
    }
    for(int i=0; i<V; i++) d[i][i] = 0;

    // dp
    for(int k=0; k<V; k++){
        for(int i=0; i<V; i++){
            for(int j=0; j<V; j++) d[i][j] = std::min(d[i][j], d[i][k] + d[k][j]);
        }
    }
}

int main()
{
    int N, M;
    cin >> N >> M;
    vector<Edge> edges(M);
    for(auto& e: edges){
        cin >> e.from >> e.to >> e.cost;
        e.from--; e.to--;
    }

    Vvec<ll> dist(N, vector<ll>(N, 0));
    Warshall_Floyd(edges, N, dist);

    int ans = 0;
    for(auto& e: edges){
        int u = e.from;
        int v = e.to;
        bool flag = true;
        for(int i=0; i<N; i++){
            for(int j=0; j<N; j++){
                if(dist[i][e.from] + e.cost + dist[e.to][j] == dist[i][j]) flag = false;
            }
        }
        if(flag) ans++;
    }

    cout << ans << endl;
}

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

int main() {

    int k, cnt1 = 0, cnt2 = 0, i;
    cin >> k;
    long long n = 0;
    for(i=1; i<k+5; i++){
        n = (n % k)*10 +7;
        if(n % k == 0) break;

    if(i == k && n % k != 0) {cout << -1;
    return 0;}}

    cout << i;

}


Measured memory_bytes: 3620
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
using namespace std;
void printv(vector<int> &v)
{
  for (auto item : v)
    cout << item << " ";
  cout << endl;
}
void printvv(vector<vector<int>> &v)
{
  for (auto item : v)
    printv(item);
  cout << endl;
}
int travelL(int N, int Q, string s, vector<char> t, vector<char> d)
{
  int lpos = -1;
  for (int i = Q-1; i >=0; i--)
  {
    if (lpos >= 0 && t[i] == s[lpos] && d[i] == 'R')
    {
      lpos--;
    }
    else if (lpos + 1 < N && t[i] == s[lpos + 1] && d[i] == 'L')
    {
      lpos++;
    }
  }
  return lpos + 1;
}
int travelR(int N, int Q, string s, vector<char> t, vector<char> d)
{
  int rpos = N;
  for (int i = Q-1; i >=0; i--)
  {
    if (rpos < N && t[i] == s[rpos] && d[i] == 'L')
    {
      rpos++;
    }
    else if (rpos - 1 >= 0 && t[i] == s[rpos - 1] && d[i] == 'R')
    {
      rpos--;
    }
  }
  return N - rpos;
}
int main()
{
  int N, Q;
  string s;
  cin >> N >> Q;
  cin >> s;
  vector<char> t(Q), d(Q);
  for (int i = 0; i < Q; i++)
  {
    cin >> t[i] >> d[i];
  }
  auto l = travelL(N, Q, s, t, d);
  auto r = travelR(N, Q, s, t, d);
  // cout << l <<" "<< r << endl;
  cout << max(N - l - r, 0) << endl;
}

Measured memory_bytes: 1540
def gcd(a, b):
    while b:
        a, b = b, a%b
    return a

n = int(input())
a = list(map(int, input().split()))
left = [0]*(n+1)
right = [0]*(n+1)
for i in range(n):
    left[i+1] = gcd(left[i],a[i])
    right[i+1] = gcd(right[i],a[n-i-1])
left.append(0)
right.append(0)
right.reverse()
ans = 0    
for i in range(n):
    gcdi = gcd(left[i],right[i+2])
    ans = max(ans, gcdi)
    
print(ans)


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

int main() {
	int n;
	cin >> n;
	vector<int> v(n * 2);
	for(int i = 0; i < n * 2; i++){
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	int ans = 0;
	for(int i = 0; i < n * 2; i += 2){
		ans += v[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, X;
  int x[100005];
  int div[100005];
  int gcd;
  
  cin >> n >> X;

  for(int i = 0;i < n;i++){
    cin >> x[i];
    div[i] = abs(x[i] - X);
  }

  gcd = div[0];
  for(int i = 1;i < n;i++){
    gcd = __gcd(gcd, div[i]);
  }

  cout << gcd << endl;
}


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define nl puts("");
#define pb push_back
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define line puts("-------");
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
typedef long long int ll;
using namespace std;
int main()
{
    string a;
    cin>>a;
    if(a=="ABC")
        cout<<"ARC";
    else
        cout<<"ABC";
}


Measured memory_bytes: 3624
require 'time'

def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def factorial(n)(n < 2)? 1 : (2..n).inject(:*) end

def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def yn(f) return (f)? "Yes": "No" end

def ynb(f) return (f)? "YES": "NO" end

def ap(a) a.each{|u| p u} end

def bit(n) n.to_s(2).split("").map(&:to_i) end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

n = inp[0]#k,f = inp
a = inp
bo = Rational(0,1)
n.times do |i|
  bo += Rational(1,a[i])
end
p (1.0/bo)
#puts ()? "Yes" : "No"
#puts ()? "YES" : "NO"
#puts ()? "yes" : "no"

Measured memory_bytes: 2168
#include<cstdio>
#define MAXN 500000
struct node{
	int key;
	node *ch[2],*fa;
};
node tree[MAXN+5];
bool first=true;
node *Root,*NIL,*ncnt;
void Init(){
	NIL=&tree[0];
	NIL->fa=NIL->ch[0]=NIL->ch[1]=NIL;
	ncnt=&tree[1];
	Root=NIL;
}
inline node * NewNode(int val){
	node *p=++ncnt;
	p->key=val;
	p->fa=p->ch[0]=p->ch[1]=NIL;
	return p;
}
void Insert(node *&rt,node *fa,int val){
	if(rt==NIL){
		rt=NewNode(val);
		rt->fa=fa;
		return ;
	}
	int d=(val>=rt->key);
	Insert(rt->ch[d],rt,val);
}
void InOrder(node *rt){
	if(rt==NIL)return ;
	InOrder(rt->ch[0]);
	printf(" %d",rt->key);
	InOrder(rt->ch[1]);
}
void PreOrder(node *rt){
	if(rt==NIL)return ;
	printf(" %d",rt->key);
	PreOrder(rt->ch[0]);
	PreOrder(rt->ch[1]);
}
node *Find(node *rt,int val){
	if(rt==NIL)return NIL;
	if(rt->key==val)return rt;
	int d=(val>=rt->key);
	return Find(rt->ch[d],val);
}
node *FindNext(node *rt){
	if(rt==NIL)return NIL;
	node *y=rt->ch[1];
	while(y->ch[0]!=NIL)
		y=y->ch[0];
	return y;
}
void Delete(node *rt,int val){
	node *x,*y,*z=Find(rt,val);
	if(z==NIL)return;
	if(z->ch[0]==NIL||z->ch[1]==NIL)
		y=z;
	else
		y=FindNext(z);
	if(y->ch[0]!=NIL)
		x=y->ch[0];
	else
		x=y->ch[1];
	if(x!=NIL)
		x->fa=y->fa;
	if(y->fa==NIL)
		Root=x;
	else{
		int d=(y==y->fa->ch[1]);
		y->fa->ch[d]=x;
	}
	if(y!=z)
		z->key=y->key;
}
int main(){
	int n,x;
	char op[100];
	Init();
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%s",op);
		if(op[0]=='p')
		{
			InOrder(Root);puts("");
			PreOrder(Root);puts("");
		}
		if(op[0]=='i')
		{
			scanf("%d",&x);
			Insert(Root,NIL,x);
		}
		if(op[0]=='f')
		{
			scanf("%d",&x);
			node *p=Find(Root,x);
			if(p==NIL)puts("no");
			else puts("yes");
		}
		if(op[0]=='d')
		{
			scanf("%d",&x);
			Delete(Root,x);
		}
	}
	return 0;
}

Measured memory_bytes: 15088
#include <bits/stdc++.h>
////////////////////////////////////////////////////////////
#define all(x) (x).begin(), (x).end()
const int inf = 1e9;
const long long INF=1e15;
#define endl '\n'
#define rep(i, n) for(int i=0;i<(n);++i)
#define repp(i, a, b) for(int i=(a);i<=(b);++i)
#define pb push_back
#define eb emplace_back
#define fastio ios::sync_with_stdio(false);cin.tie(0); //cout.tie(0);

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;


void solve() {
	int k; cin >> k;
	vector<string> s;
	repp(i, 1, 9) s.eb(1, '0'+i);
	int level = 1;
	while(s.size() < k) {
		int n = s.size();
		rep(i, n) {
			if(s[i].size() == level)
				if(s[i].back() == '9') {
					s.pb(s[i] + '9');
					s.pb(s[i] + '8');
				} else if(s[i].back() == '0'){
					s.pb(s[i] + '0');
					s.pb(s[i] + '1');
				} else {
					s.pb(s[i] + char(s[i].back()-1) );
					s.pb(s[i] + s[i].back());
					s.pb(s[i] + char(s[i].back()+1) );
				}
		}
		level++;
	}
	sort(all(s), [](string& a, string& b) {
		if(a.size() != b.size()) return a.size()<b.size();
		return a < b;
	});
	//rep(i, k) cout << s[i] << endl;
	cout << s[k-1];
}
int main() {
	fastio;
	solve();
}

Measured memory_bytes: 13936
#include<stdio.h>

char s[100000],p[300];
int shuffle[101];

int main(void){
    int i,j,k,n,head,l;

    while(1){
        scanf("%s",s);
        if(s[0] == '-' && s[1] == '\0')
            break;

        scanf("%d",&n);
        for(i = 0;i < n;i++)
            scanf("%d",&shuffle[i]);

        head = 0;
        l = 0;
        while(s[l++] != '\0');
        l--;

        for(i = 0;i < n;i++){
            for(j = 0;j < shuffle[i];j++){
                s[head + l + j] = s[head + j];
            }
            s[head + l  + j] = '\0';
            head += shuffle[i];
        }
        printf("%s\n",&s[head]);
    }
    return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
#include <vector>
#include <queue>
#include <set>
#include <iostream>
#include <iomanip>
using namespace std;
typedef long long LL;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}


int N, M, Q;
vector<int> a, b, c, d;
int ans=0;

// 全探索するものの転換
// もとの数列を全探索する
void dfs(vector<int> A){
    if(A.size()==N){
        int tmpAns = 0;
        REP(i, Q){
            if(A[b[i]-1] == A[a[i]-1] + c[i]){
                tmpAns += d[i];
            }   
        }
        chmax(ans, tmpAns);
        return;
    }

    int val;
    if(A.size()==0){
        val = 1;
    }else{
        val = A.back();
    }
    A.push_back(val);
    while(A.back()<=M){
        dfs(A);
        A.back()++;
    }
}

int main(){
    cin >> N >> M >> Q;
    a = b = c = d = vector<int>(Q);
    REP(i,Q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }

    dfs(vector<int>(0));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
  string s;
  cin>>s;
  char a=s[0];
  int N=s.size(),cnt=0;
  for(ll i=0;i<N;i++){
    if(a!=s[i]){
      a=s[i];
      cnt++;
    }
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 512
S = str(input())
def detect_dream(string):
    assert string[0] == "d"
    if string[:5] != "dream":
        return False, ""
    if len(string) >= 8:
        if string[:8] in ["dreamere", "dreamerd"]:
            return True, "dreamer"
    if string == "dreamer":
        return True, "dreamer"
    return True, "dream"

def detect_erase(string):
    assert string[0] == "e"
    if string[:5] != "erase":
        return False, ""
    if len(string) >= 6:
        if string[:6] == "eraser":
            return True, "eraser"
    return True, "erase"

while len(S) >= 5:
    if S[0] == "d":
        result, string = detect_dream(S)
    elif S[0] == "e":
        result, string = detect_erase(S)
    else:
        break
    if result:
        S = S.replace(string,"",1)
    else:
        break
if len(S) == 0:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define PI acos(-1)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

int main(){
   int n,k;
   cin>>n>>k;
   vector<int> h(n,0);

   rep(i,n){
      cin>>h[i];
   }
   sort(h.begin(),h.end());

   ll ans=0;
   ll a,b;
   a=h[0];
   b=h[k-1];
   ans=b-a;
   for(int i=k;i<n;i++){
      ll karia=h[i-k+1];
      ll karib=h[i];
      ans=min(ans,karib-karia);
   }

   cout<<ans;
return 0;
}



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

int main(void) {
  long long h, w;
  cin >> h >> w;

  long long result;
  if (h == 1 || w == 1) {
    result = 1;
  } else if (h % 2 == 1 && w % 2 == 1) {
    result = h * w / 2 + 1;
  } else {
    result = h * w / 2;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
//JSD
#include<iostream>
#define ll long long 
using namespace std;
int main(){
	ll n,k,q; cin>>n>>k>>q;
	ll ans[n]={0};
	for(int i=0;i<n;i++) ans[i]=k-q;
	for(int j=0;j<q;j++){
		 int x;(cin>>x);ans[x-1]++;
	}
	for(int i=0;i<n;i++) {
		if(ans[i]>0) cout<<"Yes\n";
		else cout<<"No\n";
	}
	return 0;
}

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

int main(void)
{
  double N,K,sum=0,s,c;
  
  cin >> N >> K;
  
  
  for(int i=1;i<=N;i++)
  {
    s=i;
    c=1;
    while(s<=K-1){
      s=s*2;
      c=c*0.5;
      
    }
    sum+=(1/N)*c;
  }
    
  printf("%.12f\n",sum);


  return 0;
}
    


Measured memory_bytes: 256
n = gets.to_i
hs = gets.split.map(&:to_i)
hs.unshift(0)

dp = [0,0,(hs[2]-hs[1]).abs]
for i in 3..n
  dp[i] = [dp[i-2]+(hs[i]-hs[i-2]).abs,dp[i-1]+(hs[i]-hs[i-1]).abs].min
end

puts dp[n]


Measured memory_bytes: 11908
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

int main(void){
	for(int n; cin >> n, n;){
		vector<string> in(n);
		for(auto & e : in) cin >> e;

		int res = -1;
		rep(i, n){
			int idx = 0;
			int T[5] = {5, 7, 5, 7, 7};

			[&]{
				rep(j, i, n){
					int & e = T[idx];
					e -= in[j].size();
					if(e < 0) return;
					if(e == 0) idx++;

					if(idx == 5) break;
				}

				res = i + 1;
			}();

			if(res != -1) break;
		}

		cout << res << endl;
	}

    return 0;
}

Measured memory_bytes: 3116
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int root[10005];
int findR(int a){
    if(root[a] != a)
        root[a] = findR(root[a]);
    return root[a];
}
class edge{
public:
    int sp, ep, w;
    edge(){}
};
bool cmp(const edge& A, const edge& B){
    return A.w < B.w;
}
vector<edge> vec;

int main(){
    int v, e;
    scanf("%d%d", &v, &e);
    vec.resize(e);
    for(int i = 0; i < e; ++i)
        scanf("%d%d%d", &vec[i].sp, &vec[i].ep, &vec[i].w);
    sort(vec.begin(), vec.end(), cmp);
    int sum = 0, cnt = 0;
    for(int i = 0; i < v; ++i)
        root[i] = i;
    for(int i = 0; i < e && cnt < v-1; ++i){
        int sp = vec[i].sp, ep = vec[i].ep, w = vec[i].w;
        int rSP = findR(sp), rEP = findR(ep);
        if(rSP != rEP){
            sum+=w;
            root[rEP] = rSP;
            cnt++;
        }
    }
    printf("%d\n", sum);
    return 0;
}

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

long long a[200000+50],pre[200000+50],suf[200000+50];

int main()
{
    // cout << "Hello World!" << endl;
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    long long sum=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        pre[i]=pre[i-1]+a[i];
        sum+=a[i];
    }
    
    long long ans=LLONG_MAX;
    for(int i=1;i<=n;i++){
        long long le=pre[i];
        long long ri=sum-pre[i];
        ans=min(ans,abs(le-ri));
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3456
import java.util.*;
class Main{
       public static void main(String s[]){
            Scanner sc = new Scanner(System.in);
int arr[] =new int[3];            
int a = sc.nextInt();
int b = sc.nextInt();
int c = sc.nextInt();
arr[0] = Math.abs(a-b);
arr[1] = Math.abs(b-c);
arr[2] = Math.abs(a-c);
Arrays.sort(arr);
System.out.println(arr[0]+arr[1]);
       }
}


Measured memory_bytes: 23764
#include<stdio.h>

int main(){
char ch[1200];
int diff='a'-'A',i;
for(i=0;i<1200;i++){
	scanf("%c",&ch[i]);
	if(ch[i]>=65&&ch[i]<=90)ch[i]+=diff;
	else if(ch[i]>=97&&ch[i]<=122)ch[i]-=diff;
	else if(ch[i]=='\n')break;
	printf("%c",ch[i]);
}
printf("\n");

return 0;
}

Measured memory_bytes: 524
#include <stdio.h>
#define large 1000000

bool memo[large];//true:素数ではない

int main()
{
    int x;
    scanf("%d",&x);
    for(int i=2;i<large;i++)
    {
        if(!memo[i])
        {
            if(i>=x) 
            {
                printf("%d\n",i);
                return 0;
            }
            for(int j=2;i*j<large;j++) memo[i*j]=true;
        }
    }
}

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

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long x[] = new long[n];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextLong();
        }
        long cost[] = new long[n - k + 1];
        for (int i = 0; i < n - k + 1; i++) {
            long left = x[i];
            long right = x[i + k - 1];
            if (left < 0) {
                if (right < 0) {
                    cost[i] = left * -1;
                    continue;
                } else {
                    cost[i] = right + (left * -1) + Math.min(right, (left * -1));
                    continue;
                }
            } else {
                cost[i] = right;
            }
        }
        Arrays.sort(cost);
        System.out.println(cost[0]);

        sc.close();
    }
}


Measured memory_bytes: 50284
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>



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

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)











int main(){
    string s;
    cin >> s;
    if(s == "Sunny"){
        cout << "Cloudy" << endl;
    }
    else if(s == "Cloudy"){
        cout << "Rainy" << endl;
    }
    else{
        cout << "Sunny" << endl;
    }
}


Measured memory_bytes: 256
use std::cmp;
use std::io;

fn main() {
    let mut input = String::new();
    io::stdin().read_line(&mut input).ok();
    let l: Vec<&str> = input.trim().split_whitespace().collect();
    let d: usize = l[0].parse().unwrap();
    let g: usize = l[1].parse().unwrap();
    let mut ans = 999999;

    let mut v: Vec<(usize, usize)> = Vec::new();
    let mut vcomp: Vec<usize> = Vec::new();

    let mut x = 100;
    for _ in 0..d {
        let mut input = String::new();
        io::stdin().read_line(&mut input).ok();
        let l: Vec<&str> = input.trim().split_whitespace().collect();
        v.push((l[0].parse().unwrap(), l[1].parse().unwrap()));
        vcomp.push(v.last().unwrap().0 * x + v.last().unwrap().1);
        x = x + 100;
    }

    for z in 0..2_usize.pow(d as u32) {
        let mut zbuf = z;
        let mut counter = 0;
        let mut sum_complete = 0;
        let mut sum_count = 0;

        while zbuf > 0 {
            if zbuf & 1 != 0 {
                sum_complete += vcomp[counter];
                sum_count += v[counter].0;
            }
            counter += 1;
            zbuf >>= 1;
        }

        let mut s = d;

        while sum_complete < g {
            s -= 1;
            if (2_usize.pow(s as u32) & z) != 0 {
                if s == 0 {
                    break;
                }
                continue;
            }

            let pp = (s + 1) * 100;
            let mut rest = v[s].0 - 1;

            while rest > 0 {
                sum_count += 1;
                sum_complete += pp;
                if sum_complete >= g {
                    break;
                }
                rest -= 1;
            }

            if s == 0 {
                break;
            }
        }

        if sum_complete < g {
            sum_count = 99999999;
        }
        ans = cmp::min(ans, sum_count);
    }

    println!("{}", ans);
}

Measured memory_bytes: 4352
const log = console.log;

const parseLines = (s: string) => s.trim().split("\n");

const parseSpaceSeparated = (line: string) => line.trim().split(" ");

const parseDecimalInt = (s: string) => parseInt(s);

const parseSpaceSeparatedDecimalInt = (line: string) =>
  parseSpaceSeparated(line).map(parseDecimalInt);

// ----

function Main(input: string): void {
  const [head, body] = parseLines(input);
  const a = parseSpaceSeparatedDecimalInt(body);

  log(Math.max(...a) - Math.min(...a));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	if(a>b){
		printf("0\n");
	}
	else if(n==1){
		if(a==b) printf("%d\n",1);
		else printf("0\n");
	}
	else{
		printf("%lld\n",1LL*(b-a)*(n-2)+1);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define Sort(a)   sort(a.begin(), a.end())
const int INF = 2147483647;
const ll  MOD = 1000000007;

// Dice in Line

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

    vector<int> p(n);
    rep(i, n) cin >> p[i];
    rep(i, n) p[i]++;

    int mx = 0;
    int s = 0;
    queue<int> q;

    rep(i, n) {
        s += p[i];
        q.push(p[i]);
        if(q.size() > k) {
            s -= q.front();
            q.pop();
        }
        if(q.size() == k) {
            mx = max(mx, s);
        }
    }
    double ans = mx;
    ans /= 2;
    printf("%.10f\n", ans);
    return 0;
}

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


int main(void){

	std::string inputs;
	std::cin >> inputs;

	bool flag = false;
	for(auto itr = inputs.begin(); itr != (inputs.end() - 1); itr++){

		if((*itr) == 'A' && *(itr + 1) == 'C'){
			flag = true;
		}
	}

	std::cout << ((flag) ? "Yes" : "No") << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a, b, k;
    cin>>a>>b>>k;
    int temp1 = a;
    for(int i = 1; i <= k; i++)
    {
        if(temp1>b)
            break;
        cout<<temp1<<endl;
        temp1++;
    }
    int temp2 = b - k + 1;
    if((a + k)>(b - k + 1))
        temp2 = temp1;
    for(int i = 1; i <= k; i++)
    {
        if(temp2>b)
        break;
        cout<<temp2<<endl;
        temp2++;
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.*;

class Main{
  public static void main(String[] args)throws IOException{
	
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str = br.readLine();

	String[] strAry = str.split(" ");
	
	int x = Integer.parseInt(strAry[0]);
	int y = Integer.parseInt(strAry[1]);

	System.out.println(x*y +" "+ 2*(x+y));
  }
}

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

using namespace std;

const int max_size = 1001;

int main() {
  int n_input; // number of inputs of pairs of sequences
  cin >> n_input;

  for (int i = 0; i < n_input; i++) {
    string seq1, seq2;
    cin >> seq1 >> seq2;
    int seq1_len = seq1.length(), seq2_len = seq2.length();
    int grid[max_size][max_size] = {{0}};
    for (int rowi = 1; rowi <= seq1_len; rowi++) {
      for (int coli = 1; coli <= seq2_len; coli++) {
	if (seq1[rowi - 1] == seq2[coli - 1]) {
	  grid[rowi][coli] = grid[rowi - 1][coli - 1] + 1;
	} else {
	  int above_grid = grid[rowi - 1][coli], left_grid = grid[rowi][coli - 1];
	  grid[rowi][coli] = (above_grid >= left_grid)?above_grid:left_grid;
	}
      }
    }
    cout << grid[seq1_len][seq2_len] << endl;
  }
}
	  
	

    

Measured memory_bytes: 5132
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define Endl endl
#define NL <<"\n"

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
template<class T> using vv=vector<vector<T>>;
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
//#undef NUIP
#ifdef NUIP
#include "benri.h"
#else
#define out(args...)
#endif
#ifdef __cpp_init_captures
template<typename T>vector<T> table(int n, T v){ return vector<T>(n, v);}
template <class... Args> auto table(int n, Args... args){auto val = table(args...); return vector<decltype(val)>(n, move(val));}
#endif

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  cout<<fixed<<setprecision(0);
	int n,MOD;
	cin>>n>>MOD;
	vector<ll> dp(n+1); dp[n]=1;
	rep(i,n-1){
		int t=min(i+1,n-i);
		out(t,1);
		rep(r,n+1)reps(k,1,MOD){
			int ind=r-k*t;
			if(ind<0) break;
			dp[ind]+=dp[r];
			if(dp[ind]>=MOD) dp[ind]-=MOD;
		}
	}
	out(dp,1);
	ll re=0;
	rep(i,n+1) (re+=dp[i]*(i+0)%MOD)%=MOD;
	//(re+=MOD-n-1)%=MOD; //0 k k k .. k
	cout<<re NL;
  return 0;
}


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

using namespace std;
#define int long long
const int MAXN = 410, MOD = 1e9 + 7;
int dp[MAXN][MAXN], DP[MAXN], a[MAXN], b[MAXN];

int mul(int a, int b) {return (a * b) % MOD;}
int sum(int a, int b) {return (a + b) % MOD;}

int32_t main()
{
    int N, C; cin >> N >> C;
    for (int i = 1; i <= N; i++) cin >> a[i];
    for (int i = 1; i <= N; i++) cin >> b[i];
    dp[0][0] = 1;
    for (int i = 1; i <= N; i++) {
        for (int x = a[i]; x <= b[i]; x++) {
            memset(DP, 0, sizeof DP);
            DP[0] = dp[i - 1][0];
            for (int c = 1; c <= C; c++) DP[c] = sum(mul(DP[c - 1], x), dp[i - 1][c]);
            for (int c = 0; c <= C; c++) dp[i][c] = sum(dp[i][c], DP[c]);
        }
    }
    cout << dp[N][C] << "\n";
}


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

typedef long long ll;


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

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

const long long INF = 1000000000000000;
typedef pair<int, int> P;
ll ma = 1000000000 + 7;
ll h,w, n, m;
char maze[60][60];
int dis[60][60];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };

int main() {
	string s;
	cin >> s;int z = 0;int o = 0;
	for (int i = 0;i < s.size();i++) {
		if (s[i] == '0') {
			z++;
		}
		else {
			o++;
		}
	}
	cout << min(z, o) * 2 << endl;
}

Measured memory_bytes: 512
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
#======================================================#
def main():
    n = II()
    aa = [0] + MII()
    sumv = 0
    for i in range(n):
        if aa[i] > aa[i+1]:
            delta = aa[i] - aa[i+1]
            sumv += delta
            aa[i+1] += delta
    print(sumv)

if __name__ == '__main__':
    main()

Measured memory_bytes: 32176