akhauriyash/Code-Regression huggingface dataset:
//Catchharsh
    #include<bits/stdc++.h>
    #define ll long long int 
    #define ld long double
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define F first
    #define S second
    #define pb push_back
    #define endl '\n'
    const ll MOD = 1e9+7;
    const ll INF = 1011111111;
    const ll LLINF = 1000111000111000111LL;
    const ld EPS = 1e-10;
    const ld PI = 3.14159265358979323;
    using namespace std;
    ll power (int x,int n)
    {
        if(n==0)
        return 1;
        else if(n%2==0)
        return power((x*x),n/2);
        else
        return x*power((x*x),(n-1)/2); 
    }
    vector<ll> seve;
    void  seveprime()
    {
      int prime[1000000]={0};
      for(int i=2;i*i<1000000;i++)
       {
        if(prime[i]==0)
         {
      	  for(int j=i*2;j<=1000000;j+=i)
           prime[j]=1;
         }
       }
       for(int i=2;i<=1000000;i++)
       {
       	if(prime[i]==0)
       		seve.pb(i);
       }
    }
    int main()
    {   
         IOS;
         string s,ss;
         int n,m,i,j,k;
         cin>>s>>ss;
         n=s.length();
         m=ss.length();
         int dp[n+1][m+1];
         for(i=0;i<=n;i++)
         {
         	for(j=0;j<=m;j++)
         	{
         		if(i==0||j==0)
         			dp[i][j]=0;
         		else
         		{
         			if(s[i-1]==ss[j-1])
         				dp[i][j]=dp[i-1][j-1]+1;
         			else
         				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
         		}
         	}
         }   
         // for(i=1;i<=n;i++)
         // {
         // 	for(j=1;j<=m;j++)
         // 		cout<<dp[i][j]<<" ";
         // 	cout<<endl;
         // }
         string ans;
      i=n;j=m;
      while(i>0&&j>0)
      {
         		if(s[i-1]==ss[j-1])
         			{
         				ans.pb(s[i-1]);
         				i--;j--;
         			}
         		else
         		{
                    if(dp[i-1][j]>dp[i][j-1])
                    	i--;
                    else
                    	j--;
         		}
         }
         for(i=ans.length()-1;i>=0;i--)
         	cout<<ans[i];
    }

Measured memory_bytes: 35456
a[6]={2,3,5,10,12,15},b[6]={380,550,850,1520,1870,2244},m[51];main(n,d,T){for(n=1;n<51;n++)for(m[n]=9999,d=5;~d;d--)if((T=n-a[d])>=0&&m[n]>(T=m[T]+b[d]))m[n]=T;for(;scanf("%d",&n),n;)printf("%d\n",m[n/100]);exit(0);}

Measured memory_bytes: 600
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
/*
D G
p1 c1
...
pD cD

D <= 10
pi num of problems <= 100
ci complete bonus <= 1000000
score: 100i
G goal score

output total num of problems
*/
ll pow(int x, int n){
  if(n == 0)
    return 1;
  else
    return x * pow(x, n - 1);
}

bool bit(int b, int i){
  return (b >> i) % 2 == 1;
}

int D;
ll G;

int* p;
ll* c;
int p_num;

ll positive(ll x){
  return max(x, (ll)0);
}

ll calc_score(int b){
  // total score of completed
  ll cscore = 0;
  for(int i = 0; i < D; i++)
    if(bit(b, i)) cscore += 100 * (i + 1) * p[i] + c[i];


  // total score of not completed
  ll G1 = G - cscore;
  ll score = 0;
  p_num = 0;
  for(int i = D - 1; i >= 0; i--){


    int num;
    if(bit(b, i)){
      num = p[i];
    } else {
      num = min( (ll)ceill( (long double)( positive(G1) / (100 * (i + 1) ) )) , (ll)p[i] - 1);      
      G1 -= 100 * (i + 1) * num;
    }
    score += 100 * (i + 1) * num + (num == p[i] ? c[i] : 0);
    p_num += num;

  }


  return score;
}


int main(){
  scanf("%d %lld", &D, &G);

  p = (int*)malloc(sizeof(int) * D);
  c = (ll*)malloc(sizeof(ll) * D);

  for(int i = 0; i < D; i++){
    scanf("%d %lld", &p[i], &c[i]);

  }

  int ans = 0;
  for(int i = 0; i < D; i++)
    ans += p[i];
  
  for(int b = 0; b < pow(2, D); b++){


    ll score = calc_score(b);

    
    if(score >= (ll)G && p_num < ans)
      ans = p_num;
  }

  cout << ans << endl;

  free(p);
  free(c);
  
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef std::vector<ll> lls;
#define MIN(a, b) ( ((a)<(b)) ? (a) : (b) )
#define MAX(a, b) ( ((a)>(b)) ? (a) : (b) )

void cinv(lls& llVec, ll n) {
	ll val;
	llVec.reserve((size_t)(n));
	for (ll i = 0; i < n; i++) {
		cin >> val;
		llVec.push_back(val);
	}
}


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

	ll gu = N / 2;
	ll ki = N - gu;

	cout << ki / (double)N << '\n';

	return 0;
}



Measured memory_bytes: 256
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

immutable mod = 10^^9 + 7;

void main() {
    int n;
    auto s = new string[](2);

    scan(n);
    iota(2).each!(i => s[i] = readln.chomp);

    if (n == 1) {
        writeln(3);
        return;
    }

    int pos = 0;
    int joutai;
    long ans;

    if (s[0][0] == s[1][0]) {
        joutai = 0;
        ans = 3;
        pos = 1;
    }
    else {
        joutai = 1;
        ans = 6;
        pos = 2;
    }

    while (pos < n) {
        if (pos == n - 1) {
            if (joutai == 0) {
                (ans *= 2) %= mod;
            }
            break;
        }

        if (s[0][pos] == s[1][pos]) {
            if (joutai == 0) {
                (ans *= 2) %= mod;
            }
            pos++;

            joutai = 0;
        }
        else {
            if (joutai == 0) {
                (ans *= 2) %= mod;
            }
            else {
                (ans *= 3) %= mod;
            }
            pos += 2;

            joutai = 1;
        }

        debug {
            stderr.write(ans, " ");
        }
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if((b<=c&&a<=c)||(c<=a&&d<=a))
   cout<<0<<endl;
   else
   {
  if(a<c&&b>=d)
   cout<<d-c<<endl;
  else if(a>=c&&b<d)
   cout<<b-a<<endl;
  else if(a<c&&b<d)
   cout<<b-c<<endl;
  else if(a>=c&&b>=d)
   cout<<d-a<<endl;
   
   }
}

Measured memory_bytes: 256
def main():
    N,K = map(int,input().split())
    have = set()
    for _ in range(K):
        d = int(input())
        a = list(map(int,input().split()))
        for z in a:
            have.add(z)
    print(N-len(have))
if __name__ == "__main__":
    main()

Measured memory_bytes: 9180
#include<stdio.h>

int main(void){

    int N,P[20],i,result=0;

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

    for(i = 1;i < N - 1;i++){
        if(P[i] > P[i - 1] && P[i] < P[i + 1]){
            result++;
        }else if(P[i] < P[i - 1] && P[i] > P[i + 1]){
            result++;
        }
    }

    printf("%d",result);
    return 0;
}

Measured memory_bytes: 128
fa = [1]
P = 10**6+3
for i in range(1, P):
    fa.append(fa[-1]*i%P)

for _ in range(int(input())):
    x, d, n = map(int, input().split())
    if d == 0:
        print(pow(x, n, P))
    else:
        y = pow(d, P-2, P) * x % P
        if y+n-1 >= P:
            print(0)
        else:
            print(pow(d, n, P) * fa[y+n-1] * pow(fa[y-1], P-2, P) % P)

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

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main() {
  int i;
  int number[3];
  for(i = 0; i < 3; i++) {
    scanf("%d", &number[i]);
  }
  qsort(number, 3, sizeof(int), asc);
  printf("%d\n", number[2] - number[0]);
  return 0;
}


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

int main() {
  string S;
  int N,M;
  cin>>N>>S;
  long long X,ans;
 
  X=0;
  ans=0;
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
          for(int u=0;u<10;u++){
            for(int p=0;p<N;p++){
              if(X==0&&S[p]-'0'==i){
                X++;
                continue;
              }
                            if(X==1&&S[p]-'0'==j){
                X++;
                continue;
              }
                            if(X==2&&S[p]-'0'==u){
                X=0;
               ans++;
                break;
              }
            }
            X=0;
          }
        }
    }
  cout <<ans<< endl;
}

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

int main(){
    char c;
    cin >> c;
    switch(c){
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':
            cout << "vowel" << endl;
            break;
        default:
            cout << "consonant" << endl;
            break;
    }
}


Measured memory_bytes: 256
package main

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

func main() {
	N, M := ReadInt(), ReadInt()
	graph := make([][]int, N+1)
	for i := 0; i < N+M-1; i++ {
		a, b := ReadInt(), ReadInt()
		graph[a] = append(graph[a], b)
	}

	used := make(map[int]bool)
	sortedNode := []int{}
	for i := 1; i <= N; i++ {
		dfs(graph, used, i, &sortedNode)
	}
	for i, j := 0, len(sortedNode)-1; i < j; {
		sortedNode[i], sortedNode[j] = sortedNode[j], sortedNode[i]
		i++
		j--
	}
	// orderOfNode[i]: iの順番
	orderOfNode := make([]int, N+1)
	for i, n := range sortedNode {
		orderOfNode[n] = i
	}
	// parent[i]: iの親
	parent := make([]int, N+1)
	parent[sortedNode[0]] = 0
	for u, vs := range graph {
		for _, v := range vs {
			if parent[v] > 0 {
				if orderOfNode[u] > orderOfNode[parent[v]] {
					parent[v] = u
				}
			} else {
				parent[v] = u
			}
		}
	}
	for i := 1; i <= N; i++ {
		fmt.Println(parent[i])
	}
}

func dfs(graph [][]int, used map[int]bool, u int, ans *[]int) {
	if used[u] {
		return
	}
	used[u] = true
	for _, v := range graph[u] {
		dfs(graph, used, v, ans)
	}
	*ans = append(*ans, u)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 25332
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
ll n;
ll ara[100009];
int    main()
{
    scanf("%lld",&n);
    for(ll i=1;i<=n;i++) scanf("%lld",ara+i);
    ll sum=0;
    ll cnt=0;
    ll mini=LLONG_MAX;
    for(ll i=1;i<=n;i++)
    {
        if(ara[i]<0) cnt++;
        sum+=fabs(ara[i]);
        ll d=fabs(ara[i]);
        mini=min(mini,d);
    }
    if(cnt%2) sum-=2*mini;
    printf("%lld\n",sum);
}



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
const int MAX=1001;
int lcs(string X,string Y) 
{
	int i=0,j=0,c[MAX][MAX],x=X.length(),y=Y.length();
	for(i=0;i<=x;i++)c[i][0]=0;
	for(i=0;i<=y;i++)c[0][i]=0;
	for(i=1;i<=x;i++) 
	for(j=1;j<=y;j++) 
	if(X[i-1]==Y[j-1])c[i][j]=c[i-1][j-1]+1; 
	else c[i][j]=max(c[i][j-1],c[i-1][j]);
	return c[x][y];
}
int main()
{
	int n;cin>>n;
	string X,Y;
	while(n--)
	{
		cin>>X>>Y;
		cout<<lcs(X,Y)<<endl;
	}
}

Measured memory_bytes: 7108
# coding: utf-8
# Your code here!
N, K = list(map(int,input().split()))
p = list(map(int,input().split()))

e = 0.0
for i in range(K):
    e = e + (p[i] + 1) / 2.0

emax = e
for i in range(K,len(p)):
    e = e - (p[i-K] + 1) / 2.0 + (p[i] + 1) / 2.0
    if emax < e:
        emax = e

print(emax)


Measured memory_bytes: 25060
#include <bits/stdc++.h>
using namespace std;
int main(){
 int a[12]={1,3,1,2,1,2,1,1,2,1,2,1};
  int x,y;
  cin>>x>>y;
  if(a[x-1]==a[y-1]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
s1=list(input())
q=int(input())
s0=[]
f=1
for i in range(q):
  a=list(input().split())
  #print(i,a,s)
  if int(a[0])==1:
    f=(f+1)%2
  else:
    if (f+int(a[1]))%2==0:
      s0.append(a[2])
    else:
      s1.append(a[2])
if f==1:
  print("".join(s0[::-1])+"".join(s1))
else:
  print("".join(s1[::-1])+"".join(s0))
  

Measured memory_bytes: 6940
let inf, n, m, g, us = Scanf.scanf "%d %d" @@ fun n m -> Array.(100000000, n, m, make n [], make_matrix n n 0)
let h u v d = g.(u) <- (v, d) :: g.(u); g.(v) <- (u, d) :: g.(v); us.(u).(v) <- 1; us.(v).(u) <- 1
let f s ds ps = let q = ref [] in ds.(s) <- 0; for i = 0 to n - 1 do q := i :: !q done;
  while !q <> [] do let mi = ref (max_int, -1) in List.(iter (fun i -> mi := min !mi (ds.(i), i)) !q;
  let u = snd !mi in q := filter (fun i -> i <> u) !q; iter (fun (v, d) -> if ds.(v) > ds.(u) + d then (ds.(v) <- ds.(u) + d; ps.(v) <- [u]) else if ds.(v) = ds.(u) + d then ps.(v) <- u :: ps.(v)) g.(u)) done; Array.iteri (fun v -> List.iter (fun u -> us.(u).(v) <- 0)) ps
let _ = for _ = 1 to m do Scanf.scanf " %d %d %d" @@ fun u v d -> h (u - 1) (v - 1) d done; Array.(for i = 0 to n - 1 do f i (make n inf) (make n []) done; Printf.printf "%d\n" @@ fold_left (fold_left (+)) 0 us / 2)

Measured memory_bytes: 4608
#include<iostream>
#include<algorithm>
#include<vector>
 
#define INF 100000000
 
using namespace std;
 
int V,match[2001];
bool used[2001];
vector<int>G[2001];
 
void add_edge(int u,int v){
  G[u].push_back(v);
  G[v].push_back(u);
}
 
bool dfs(int v){
  used[v]=true;
  for(int i=0;i<G[v].size();i++){
    int u=G[v][i],w=match[u];
    if(w<0 || !used[w] && dfs(w)){
      match[v]=u;
      match[u]=v;
      return true;
    }
  }
  return false;
}
 
int bipartite_matching(){
  int res=0;
  fill(match,match+2001,-1);
  for(int v=0;v<V;v++){
    if(match[v]<0){
      fill(used,used+2001,false);
      if(dfs(v))res++;
    }
  }
  return res;
}
 
int main(void){
 
  int n,m,l,u,v,d,graph[101][101],p[1001],t[1001];
 
  while(cin >> n >> m >> l,n|m|l){  
 
    for(int i=0;i<2001;i++)G[i].clear();
 
    fill(graph[0],graph[101],INF);
    for(int i=0;i<101;i++)graph[i][i]=0;
    for(int i=0;i<m;i++){
      cin >> u >> v >> d;
      graph[u][v]=graph[v][u]=d;
    }
     
    for(int i=0;i<l;i++){
      cin >> p[i] >> t[i];
    }
     
    for(int k=0;k<n;k++)
      for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      graph[i][j]=min(graph[i][j],graph[i][k]+graph[k][j]);
 
    for(int i=0;i<l;i++){
      for(int j=0;j<l;j++){
	if(i!=j && graph[p[i]][p[j]]+t[i]<=t[j])add_edge(i,j+l);
      }
    }
    V=2*l;
    cout << l-bipartite_matching() << endl;
  }
  return 0;
}

Measured memory_bytes: 9736
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i=0;i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
signed _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
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; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

signed _main(){
  // 入力
  int N,M,ans=0;
  cin >> N >> M;
  vv<int> light(M);
  rep(i,M){
    int k; cin >> k;
    rep(j,k){
      int s; cin >> s;
      s--;
      light[i].push_back(s);
    }
  }
  v<int> p(M,0);
  rep(i,M){
    cin >> p[i];
  }

  // bit 全探索
  for (int bit = 0; bit < (1 << N); ++bit) {
    int cnt=0;
    rep(i,M){
      int sum=0;
      fore(j,light[i]){
        if (bit & (1 << j)) sum++;
      }
      if(sum%2==p[i]) cnt++;
      else break;
    }
    //cout << "c " << cnt << endl;
    if(cnt==M) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <stack>
#include <stdio.h>
#include <string>
#include <queue>
#include <vector>
using namespace std;

struct Card {
	string suit;
	int number;
};
Card A[100000];
Card B[100000];

int partition(Card A[], int p, int r) {
	int x = A[r].number;
	int i = p - 1;

	for (int j = p; j < r; j++) {
		if (A[j].number <= x) {
			i++;
			swap(A[i], A[j]);
		}
	}

	swap(A[i + 1], A[r]);
	return i + 1;
}

void quickSort(Card A[], int p, int r) {
	if (p < r) {
		int q = partition(A, p, r);
		quickSort(A, p, q - 1);
		quickSort(A, q + 1, r);
	}
}

Card L[500001];
Card R[500001];

void merge(Card B[], int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	for (int i = 0; i < n1; i++) L[i] = B[left + i];
	for (int i = 0; i < n2; i++) R[i] = B[mid + i];
	L[n1].number = 1000000001;
	R[n2].number = 1000000001;

	int i = 0, j = 0;
	for (int k = left; k < right; k++) {
		if (L[i].number <= R[j].number) {
			B[k] = L[i];
			i++;
		}
		else {
			B[k] = R[j];
			j++;
		}
	}
}

void mergeSort(Card B[], int left, int right) {
	if (left + 1 < right) {
		int mid = (left + right) / 2;
		mergeSort(B, left, mid);
		mergeSort(B, mid, right);
		merge(B, left, mid, right);
	}
}


int main()
{
	Card c;
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> c.suit >> c.number;
		A[i] = c;
		B[i] = c;
	};

	mergeSort(B, 0, n);
	quickSort(A, 0, n - 1);

	bool s = true;
	for (int i = 0; i < n; i++) {
		if (A[i].suit != B[i].suit || A[i].number != B[i].number) {
			s = false;
			break;
		}
	}

	if (s) cout << "Stable" << endl;
	else cout << "Not stable" << endl;

	for (int i = 0; i < n; i++) {
		cout << A[i].suit << " " << A[i].number << endl;
	}
}



Measured memory_bytes: 26580
N = int(input())
H =list(map(int,input().split()))

ans = 0
table = [0] * N
for i in range(1,N):
    if H[i] <= H[i-1]:
        table[i] = table[i-1] + 1
    if ans < table[i]:
        ans = table[i]

print(ans)

Measured memory_bytes: 15020
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << fixed << setprecision(20);

    int N;
    cin >> N;
    vector<ll>A(N + 1);
    cin >> A;
    ll sum = accumulate(ALL(A), 0LL);

    vector<ll>B(N);
    cin >> B;

    for (int i = 0; i < N; i++) {
        ll n = min(B[i], A[i]);
        B[i] -= n;
        A[i] -= n;
        n = min(B[i], A[i + 1]);
        B[i] -= n;
        A[i + 1] -= n;
    }

    cout << sum - accumulate(ALL(A), 0LL) << endl;
    return 0;
}

Measured memory_bytes: 1792
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

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

//for loop関係
#define rep(i,a,n) for(int i=(a);i<(n);++i)
#define repe(i,a,n) for(int i=(a);i<=(n);++i)
#define rrep(i,n,a) for(int i=(n);n>(a);--i)
#define rrepe(i,n,a) for(int i=(n);n>=(a);--i)

//略記
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define ENDL << "\n"

using ll = long long;
using P = pair<int,int>;
using itn = int;

//定数
const int INF = 1<<30;
const ll MOD = 1000000007;
const long double PI =(acos(-1));

//Degree <-> Radian
double toRad(double d){ double rad; rad=d*PI/180; return rad; }
double toDegree(double rad){ double d; d=rad*180/PI; return d; }
//The least common multiple : lcm
ll lcm(int a,int b){ return a*b/__gcd(a,b); }
//素数判定
bool isPrime(int n){
    int i; 
    if(n<2) return 0;
    else if(n==2) return 1;
    if(n%2==0) return 0;
    for(i=3;i*i<=n;i+=2) if(n%i==0) return 0;
    return 1;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    bool flag=0;
    while(n){
        if(n%10==7) flag=1;
        n/=10;
    }
    if(flag){
        cout << "Yes" ENDL;
    }else cout << "No" ENDL;
    
    return 0;
}

Measured memory_bytes: 3652
a = [0]*5
a[0] = int(input())
a[1] = int(input())
a[2] = int(input())
a[3] = int(input())
a[4] = int(input())
q = [0]*5
t = 0
for i in range(5):
  q[i] = a[i] % 10
  q[i] = (10 - q[i])%10
  t += (a[i]+9)//10*10
t -= max(q)
print(t)

Measured memory_bytes: 3064
def bingocheck(ANS):
    if'A00' in ANS and 'A10' in ANS and 'A20' in ANS:
        return 1
    if'A01' in ANS and 'A11' in ANS and 'A21' in ANS:
        return 1
    if'A02' in ANS and 'A12' in ANS and 'A22' in ANS:
        return 1
    if'A00' in ANS and 'A01' in ANS and 'A02' in ANS:
        return 1
    if'A10' in ANS and 'A11' in ANS and 'A12' in ANS:
        return 1
    if'A20' in ANS and 'A21' in ANS and 'A22' in ANS:
        return 1
    if'A00' in ANS and 'A11' in ANS and 'A22' in ANS:
        return 1
    if'A02' in ANS and 'A11' in ANS and 'A20' in ANS:
        return 1
    return 0




A0 = list(map(int,input().split()))
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
n = int(input())
ANS = []
for i in range(n):
    b = int(input())
    for i in range(3):
        if b == A1[i]:
            ANS.append('A1'+str(i))
    for i in range(3):
        if b == A2[i]:
            ANS.append('A2'+str(i))
    for i in range(3):
        if b == A0[i]:
            ANS.append('A0'+str(i))
    if bingocheck(ANS)==1:
        print('Yes')
        break
else:
    print('No')


Measured memory_bytes: 3064
N = int(input())
X = input()
ans = [1 for _ in range(N)]
#original 1 count
l = 0
for k in range(N):
  if X[k] == '1':
    l+=1
if l == 0:
  for _ in range(N):
    print(1)
  exit()
if l == 1:
  if X[-1] == '1':
    for _ in range(N-1):
      ans[_] = 2
  else:
    ans[-1] = 2 
  for k in range(N):
    if X[k] =='1':
      ans[k] = 0 
  for _ in range(N):
    print(ans[_])
  exit()


intN = int(X, 2)
N1 = intN %(l-1)
N0 = intN % (l+1)


start = []
if N == 1:
  if X[0] == '1':
    print(0)
    exit()
  else:
    print(1)
    exit()
else:
  s1 = 1
  s0 = 1
  for k in range(N-1, -1, -1):
    if X[k] == '1':      
      ia = (N1 - s1)%(l-1)
    else:
      ia = (N0 + s0)%(l+1)
    start.append(ia)
    s1 = s1*2%(l-1)
    s0 = s0*2%(l+1)
start = start[::-1]
"""
ml = len(bin(l+1))-2
poplist = [0 for _ in range(N)]
t = 1
while t < N + 1:
  t *= 2
  for k in range(t//2, N, t):
    for j in range(t//2):
      if k+j>N-1:
        break
      poplist[k+j] += 1
"""

def popcount(n):
  c = 0
  n = bin(n)[2:]
  for k in range(len(n)):
    if n[k] == '1':
      c+=1
  return c

for k in range(len(start)):
  for count in range(10*5):
    if start[k] == 0:
      ans[k] += count
      break
    else:
      start[k] = start[k] % popcount(start[k])

for k in range(N):
  print(ans[k])

Measured memory_bytes: 106304
#include <stdio.h>
#include <stdlib.h>
struct Card{
  char EGARA;
  int NUM;
};
void BubbleSort(struct Card *);
void SelectionSort(struct Card *);
int isStable(struct Card *,struct Card *);
void print(struct Card *);


int n;

int main(){
  int i;
 struct Card A[1000], B[1000];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf(" %c",&A[i].EGARA);
    scanf("%d",&A[i].NUM);
  }
  for(i=0;i<n;i++){
    B[i]=A[i];
  }
  BubbleSort(A);
  SelectionSort(B);
  print(A);
  printf("Stable\n");
  print(B);
  if(isStable(A,B)==1)
    printf("Stable\n");
  else
    printf("Not stable\n");
    return 0;
}

void BubbleSort(struct Card *A){
  int i,j;
  struct Card m;
  for(i=0;i<n;i++){
    for(j=n-1;j>=i+1;j--){
      if(A[j].NUM<A[j-1].NUM){
	m=A[j];
	A[j]=A[j-1];
	A[j-1]=m;
      }
    }
  }
}

void SelectionSort(struct Card *B){
  int i,minj,j;
  struct Card m;
  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(B[j].NUM<B[minj].NUM){
	minj=j;
      }
    }
    m=B[i];
    B[i]=B[minj];
    B[minj]=m;
  }
}

void print(struct Card *A){
  int i;
  for(i=0;i<n;i++){
    if(i>0)
      printf(" ");
    printf("%c%d",A[i].EGARA,A[i].NUM);
  }
  printf("\n");
}

int isStable(struct Card *A,struct Card *B){
  int i;
  for(i=0;i<n;i++){
    if(A[i].EGARA!=B[i].EGARA)
      return 0;
  }
  return 1;
}
    
	
	



Measured memory_bytes: 2108
# solution

import io
import sys
import math

n,h,*l=map(int,open(0).read().split())

array=max(l[::2])

c=0;f=1

for b in sorted(l[1::2])[::-1]:
	if b>array:
		h-=b
		c+=1
		if h<1:
			f=0
			break
print(c+(~-h//array+1)*f)

Measured memory_bytes: 26020
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
#define MOD_CONST 1000000007
typedef long long int lli;

int main(){
    int a, b;
    cin >> a >> b;
    if(a >= 10){
        puts("-1");
    }else if(b >= 10){
        puts("-1");
    }else{
        cout << (a * b) << endl;
    }
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;

int main() {
    int n;
    cin >> n;
    int L[n+1], R[n+1];
    L[n] = 0; R[0] = 0;
    for (int i = 0; i < n; i++) {
        cin >> L[i] >> R[i];
    }

    sort(L, L+n+1, greater<int>());
    sort(R, R+n+1);

    long ans = 0;
    for (int i = 0; i <= n; i++) {
        ans += (long)max(0, 2*(L[i]-R[i]));
    }

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

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

using PDI = pair<double, int32>;

const int64 mod = 1e9+7;

class RMQ{
private:
	int32 n;
	vector<int64> node, lazy;
	vector<bool> lazyFlag;
public:
	RMQ(){}
	RMQ(vector<int64> v){
		int sz = v.size();
		n = 1; while(n < sz) n *= 2;
		node.resize(2*n-1, INF_LL);
		lazy.resize(2*n-1, 0);
		lazyFlag.resize(2*n-1, false);
		for(int32 i = 0;i < sz;i++) node[i+n-1] = v[i];
		for(int32 i = n-2;i >= 0;i--) node[i] = min(node[2*i+1], node[2*i+2]);
	}

	void eval(int32 k, int32 l, int32 r){
		if(lazyFlag[k]){
			node[k] += lazy[k];
			if(r-l > 1){
				lazy[2*k+1] += lazy[k];
				lazy[2*k+2] += lazy[k];
				lazyFlag[2*k+1] = lazyFlag[2*k+2] = true;
			}
			lazy[k] = 0;
			lazyFlag[k] = false;
		}
	}

	void add(int32 a, int32 b, int64 x, int32 k=0, int32 l=0, int32 r=-1){
		if(r < 0) r = n;
		eval(k, l, r);
		if(b <= l || r <= a) return;

		if(a <= l && r <= b){
			lazy[k] += x;
			lazyFlag[k] = true;
			eval(k, l, r);
		}else{
			add(a, b, x, k*2+1, l, (l+r)/2);
			add(a, b, x, k*2+2, (l+r)/2, r);
			node[k] = min(node[k*2+1], node[k*2+2]);
		}
	}

	void update(int32 a, int64 x, int32 k=0, int32 l=0, int32 r=-1){
		if(r<0) r = n;
		eval(k, l, r);
		if(a+1 <= l || r <= a) return;

		if(r-l > 1){
			if(node[k] > x) node[k] = x;
			update(a, x, k*2+1, l, (l+r)/2);
			update(a, x, k*2+2, (l+r)/2, r);
		}else{
			node[k] = x;
		}
	}

	int64 query(int32 a, int32 b, int32 k=0, int32 l=0, int32 r=-1){
		if(r < 0) r = n;
		eval(k, l, r);

		if(b <= l || r <= a) return INF_LL;
		if(a <= l && r <= b) return node[k];

		return min(query(a, b, k*2+1, l, (l+r)/2), query(a, b, k*2+2, (l+r)/2, r));
	}
};

int main(void){
	int32 N, Q, A, B;
	cin >> N >> Q >> A >> B;
	RMQ rmq[2];
	rmq[0] = RMQ(vector<int64>(N+1, INF_LL)); rmq[1] = RMQ(vector<int64>(N+1, INF_LL));
	int64 bef = B;
	REP(i, Q){
		int64 x;
		cin >> x;
		if(i == 0){
			rmq[0].update(A, abs(B-x)-A); rmq[1].update(A, abs(B-x)+A);
			rmq[0].update(B, abs(A-x)-B); rmq[1].update(B, abs(A-x)+B);
		}else{
			int64 val = min(x+rmq[0].query(0, x+1), rmq[1].query(x, N+1)-x);
			rmq[0].add(0, N+1, abs(bef-x));
			rmq[1].add(0, N+1, abs(bef-x));
			rmq[0].update(bef, val-bef);
			rmq[1].update(bef, val+bef);
		}
		bef = x;
	}
	int64 res = INF_LL;
	REP(i, N+1){
		chmin(res, min(rmq[0].query(i, i+1)+i, rmq[1].query(i, i+1)-i));
	}
	cout << res << endl;
}

Measured memory_bytes: 18404
N, Ma, Mb = list(map(int, input().split()))
D = [tuple(map(int, input().split())) for _ in range(N)]

def listup(L, D):
    for a, b, c in D:
        for (ka, kb), kc in L.copy().items():
            key = (ka+a, kb+b)
            L[key] = min(L[key], kc+c) if key in L else kc+c
        

L1 = {(0,0):0}
L2 = {(0,0):0}
listup(L1, D[:N//2])
listup(L2, D[N//2:])

ans = 10**9
for m in range(1,401):
    ma = Ma * m
    mb = Mb * m
    if ma>400 or mb>400: break
    for key1 in L1:
        ta1, tb1 = key1
        ta2 = ma - ta1
        tb2 = mb - tb1
        key2 = (ta2, tb2)
        if key2 in L2: ans = min(ans, L1[key1]+L2[key2])

print(ans if ans!=10**9 else -1)

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll A, B, C;
int main(){
  cin >> A >> B >> C;
  if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0){
    cout << 0 << endl;
    return 0;
  }
  ll ans = A * B;
  ans = min(ans, min(B * C, C * A));
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3604
#include <iostream>

using namespace std;

struct Process {
  char name[10];
  int time;
};

static const int MAX = 60000;
Process P[MAX];
int tail, head;

void enqueue (struct Process& p) {
  P[tail] = p;
  tail = (tail + 1) % MAX;
}

void dequeue (struct Process& p) {
  p = P[head];
  head = (head + 1) % MAX;
}

int main () {
  int n, q;

  cin >> n >> q;

  for (int i = 0; i < n; i++) {
    cin >> P[i].name >> P[i].time;
  }

  int count = 0;

  tail = n;

  struct Process p;

  while (head != tail) {
    dequeue(p);
    p.time -= q;
    if (p.time <= 0) {
      count += q + p.time;
      cout << p.name << " " << count << endl;
    } else {
      count += q;
      enqueue(p);
    }
  }

}

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

using namespace std;

const int N = 200 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

struct block {
    int c, l, r;
    block() = default;
    block(int c, int l, int r) : c(c), l(l), r(r) { }
};

int n;
int a[N];

bool read() {
    if (!(cin >> n))
        return false;

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

    return true;
}

bool check(int nn) {
    vector<block> cur = { block(0, 1, a[0]) };

    for (int i = 1; i < n; ++i) {
        if (a[i] > a[i - 1]) {
            cur.emplace_back(0, a[i - 1] + 1, a[i]);
        } else {
            for (; !cur.empty() && (cur.back().l > a[i] || cur.back().c == nn - 1); cur.pop_back()) { }

            if (cur.empty())
                return false;
            
            auto b = cur.back();
            cur.pop_back();
            b.r = min(b.r, a[i]);
            if (b.l <= b.r - 1) cur.emplace_back(b.c, b.l, b.r - 1);
            cur.emplace_back(b.c + 1, b.r, b.r);
            if (b.r + 1 <= a[i]) cur.emplace_back(0, b.r + 1, a[i]);
        }
    }

    return true;
}

void solve() {
    auto l = 1;
    auto r = n;

    for (; l < r; ) {
        auto m = (l + r) / 2;

        if (check(m))
            r = m;
        else
            l = m + 1;
    }

    cout << l << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    while (read())
        solve();

    return 0;
}



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

int dp[50];

int solve(int id){

  if(dp[id] != -1) return dp[id];
  if(id == 1 || id == 0) return dp[id] = 1;
  int ret = 0;

  return dp[id] = solve(id-1) + solve(id-2);

}


int main(){

  memset(dp,-1,sizeof(dp));
  int n; 

  cin >> n;

  cout << solve(n) << endl;

}

Measured memory_bytes: 1164
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto s = readln.chomp;
  auto w = readln.chomp.to!int;
  string x = "";
  foreach (i; iota(0,s.length,w)) {
    x ~= s[i];
  }
  x.writeln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  cin >> n;
  vector<int> vec(n);
  REP(i, n) {
    cin >> vec[i];
  }
  int ans = 0;
  for(int i = 1; i < n-1; i++) {
    vector<int> tmp={vec[i-1], vec[i], vec[i+1]};
    sort(tmp.begin(), tmp.end());
    // cout << "[ ";
    // REP(i, tmp.size()) {
    //   cout << tmp[i] << " ";
    // }
    // cout << " ]" << endl;
    if (tmp[1] == vec[i]) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define fast  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define mod 1000000007
// order_of_key and *find_by_order
int32_t main()
{
	fast;
	int a, b, c;
	cin >> a >> b >> c;
	int k;
	cin >> k;
	if (k <= a) {
		cout << k;
	}
	else if (k <= (a + b)) {
		cout << a;
	}
	else {
		cout << a - (k - (a + b));
	}











}

Measured memory_bytes: 3648
fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val block = readLine()!!.split(" ").map { it.toLong() }
    val canMove = IntArray(n)
    canMove[n-1] = 0
    for(i in (0 until n-1).reversed()) {
        if(block[i] >= block[i+1]) {
            canMove[i] = canMove[i+1] + 1
        } else {
            canMove[i] = 0
        }
    }
    println(canMove.max())
}

Measured memory_bytes: 59032
import java.util.*;
import java.io.*;
class Main{
  public static void main(String args[]){
    int n=readI();
    if(n%7==0){
      n/=7;
    }
    if(n%2==0||n%5==0){
      pl("-1");
      System.exit(0);
    }
    int k=1,m=0;
    for(int i=0;;i++){
      k=k%n;
      m+=k;
      m=m%n;
      if(m==0){
        pl((i+1)+"");
        break;
      }
      k*=10;
    }
  }

  static final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  public static void pr(String str){
    System.out.print(str);
  }
  public static void pl(String str){
    System.out.println(str);
  }
  public static String read(){
    try{
      return ctos((char)br.read());
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static char readC(){
    try{
      return (char)br.read();
    }catch(IOException e){
      e.printStackTrace();
      return (char)-1;
    }
  }
  public static String readL(){
    try{
      return br.readLine();
    }catch(IOException e){
      e.printStackTrace();
      return "";
    }
  }
  public static String readS(){
    StringBuilder sb = new StringBuilder();
    while(true){
      try{
        int k = br.read();
        if(k==-1||(char)k==' '||(char)k=='\n'){break;}
        sb.append((char)k);
      }catch(IOException e){
        e.printStackTrace();
      }
    }
    return sb.toString();
  }
  public static int readI(){
    return stoi(readS());
  }
  public static long readLong(){
    return stol(readS());
  }
  public static long stol(String s){
    return Long.parseLong(s);
  }
  public static String[] readSs(){
    return readL().split(" ");
  }
  public static int[] readIs(){
    return stoi(readSs());
  }
  public static int stoi(String s){
    return Integer.parseInt(s);
  }
  public static int[] stoi(String s[]){
    int a[]=new int[s.length];
    for(int i=0;i<s.length;i++){
      a[i]=stoi(s[i]);
    }
    return a;
  }
  public static String itos(int i){
    return String.valueOf(i);
  }
  public static String[] itos(int[] a){
    String s[]=new String[a.length];
    for(int i=0;i<a.length;i++){
      s[i]=itos(a[i]);
    }
    return s;
  }
  public static String ctos(char c){
    return String.valueOf(c);
  }
  public static String cstos(char[] c){
    return new String(c);
  }
  public static char stoc(String s){
    return s.charAt(0);
  }
  public static char[] stocs(String s){
    return s.toCharArray();
  }
}


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

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

	string s;
	cin >> s;
	
	for(int i=0; i<s.size(); i++) {
		if(i == 3 && s[i] == '7') {
			cout << 8;
		} else {
			cout << s[i];
		}
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author vikas.k
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();

            out.print(a + b <= 9 ? a + b : "error");
        }

    }

    static class FastScanner {
        private BufferedReader bufferedReader;
        private StringTokenizer stringTokenizer;

        public FastScanner(InputStream inputStream) {
            bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        }

        public String next() {
            if (stringTokenizer == null || !stringTokenizer.hasMoreElements()) {
                try {
                    stringTokenizer = new StringTokenizer(bufferedReader.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return stringTokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 21460
#include <iostream>
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>
#include <queue>
#include <ctype.h>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
#define more(a,b) (((a)>(b))?(a):(b))
#define less(a,b) (((a)<(b))?(a):(b))
using namespace std;


int main(void)
{
	int N, K; cin >> N >> K;
	int ans = 0;
	while (N > 0) {
		ans++;
		N /= K;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repd(i,n) for(ll i = n - 1; i >= 0; i--)
#define all(x) x.begin(), x.end()

ll n, k, m, M = 1e9 + 7;

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

cin >> n;

ll f;
for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) f = i;
}

f = n / f;

ll num = 0, prd = 1;
while(prd <= f) {
    prd *= 10;
    num++;
}

cout << num << endl;
}

Measured memory_bytes: 3596
#include <stdio.h>          // printf(), scanf()
#include <stdlib.h>         // exit()

#define MAX_V 100000
#define MAX_E 200000
#define QUE_SIZE 100000

typedef struct edge_tbl
{
	int to;
	int next;
} edge;

const int nil = -1;
int g[MAX_V];
edge es[MAX_E];
int color[MAX_V];
int V;
int n_edge;

int queue[QUE_SIZE];
int que_in;
int que_out;

void
cleanup(int ecode)
{
	exit(ecode);
}

int
que_empty()
{
	return que_in == que_out;
}

void
que_push(int x)
{
	queue[que_in] = x;
	que_in = (que_in + 1) % QUE_SIZE;
	if (que_in == que_out)
	{
		fprintf(stderr, "Queue overflow. size:%d\n", QUE_SIZE);
		cleanup(1);
	}
}

void
que_pop()
{
	if (que_out == que_in)
	{
		fprintf(stderr, "Queue underflow\n");
		cleanup(1);
	}

	que_out = (que_out + 1) % QUE_SIZE;
}

int
que_front()
{
	return queue[que_out];
}

void
bfs(int u, int c)
{
	int v;
	int r;
	int l;

	color[u] = c;
	que_push(u);
	while (!que_empty())
	{
		r = que_front(); que_pop();
		for (l = g[r]; l != nil; l = es[l].next)
		{
			v = es[l].to;
			if (color[v] == nil)
			{
				color[v] = c;
				que_push(v);
			}
		}
	}
}

void
assign_color()
{
	int u;

	int id = 1;
	for (u = 0; u < V; ++u)
		color[u] = nil;

	for (u = 0; u < V; ++u)
	{
		if (color[u] == nil)
			bfs(u, id++);
	}
}

void
add_edge(int u, int v)
{
	es[n_edge].to = v;
	es[n_edge].next = g[u];
	g[u] = n_edge;
	n_edge++;
}

int
main(int argc, char** argv)
{
	int m;
	int q;
	int s, t;
	int i;

	n_edge = 0;
	que_in = 0;
	que_out = 0;

	scanf("%d %d", &V, &m);
	for (i = 0; i < V; ++i)
		g[i] = nil;

	for (i = 0; i < m; ++i)
	{
		scanf("%d %d", &s, &t);
		add_edge(s, t);
		add_edge(t, s);
	}

	assign_color();
	scanf("%d", &q);
	for (i = 0; i < q; ++i)
	{
		scanf("%d %d", &s, &t);
		printf("%s\n", (color[s] == color[t]) ? "yes" : "no");
	}

	return 0;
}

Measured memory_bytes: 3316
import scala.annotation.tailrec

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    try {
      @tailrec
      def sub(n: Int, count: Int): Unit = {
        if (n == 0) {

        } else {
          println(s"Case ${count}: ${n}")
          sub(sc.nextInt, count + 1)
        }
      }
      sub(sc.nextInt, 1)
    } catch {
      case e: NoSuchElementException =>
        println("error: stdin is not found. Please take numbers.")
    }
  }
}

Measured memory_bytes: 62584
from math import gcd
n=int(input())
A=list(map(int,input().split()))
left,right=[0]*n,[0]*n

left[0]=A[0]
for i in range(1,n-1):
    left[i]=gcd(left[i-1],A[i])

right[-1]=A[-1]
for i in range(1,n-1)[::-1]:
    right[i]=gcd(right[i+1],A[i])

ans=max(left[-2],right[1])
for i in range(1,n-1):
    ans=max(ans,gcd(left[i-1],right[i+1]))

print(ans)

Measured memory_bytes: 86484
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
using namespace std;
int main() {
    int x, y;
    cin >> x >> y;
    double a = 2 * x - (double)y / 2;
    double b = (double)y / 2 - x;
    if (a < 0 || b < 0 || a - floor(a) > 0 || b - floor(b) > 0) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 3680
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		for(;;){
			int H = sc.nextInt();
			int W = sc.nextInt();
			
			if(H == 0 && W == 0)
				break;
		
			for(int i = 0;i < H;i++){
				if(i == 0 || i == H - 1){
					for(int j = 0;j < W;j++){
						System.out.print("#");
					}
				}else{
					for(int j = 0;j < W;j++){
						if(j == 0 || j == W - 1)
							System.out.print("#");
						else
							System.out.print(".");
					}
				}
					System.out.print("\n");
				}
			System.out.print("\n");
		}
	}
}

Measured memory_bytes: 29580
#include <iostream>
#include <string>
#include <stdio.h>
#include <queue>
#include <stack>
#include <string.h>
#include <algorithm>
#include <math.h>
#include <bits/stdc++.h>
#define ll long long
#define wtcl return
using namespace std;

inline ll read()
{
	ll s = 0, f = 1;
	char ch = getchar();
	for(; ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = - 1;
	for(; ch >= '0' && ch <= '9'; ch = getchar()) s = ((s << 3ll) + (s << 1ll) + (ch ^ 48ll));
	return s * f ;
}
inline void out(ll x)
{
	if(x<0) putchar('-'),x=-x;
	if(x>9) out(x/10);
	putchar(x%10+'0');
}

int main()
{
	int n;
	cin>>n;
	int ans = 0;
	for(int i=0;i<n;i++)
	{
		int x;
		x=read();
		ans = ans + x - 1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384