akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
int ka[214514],inv[214514];
int coef[114514];
void setkaijo(int n){
	ka[0]=1;
	for(int i=1;i<=n;i++){
		ka[i] = ka[i-1] * i;
		ka[i] %= inf;
	}
}
int modpow(int x,int k){
	// x ^ k mod inf
	int res = 1;
	while(k>0){
		if(k%2)res = (res*x)%inf;
		x = (x*x)%inf;
		k >>=1;
	}
	return res;
}
void setinv(int n){
	for(int i=0;i<=n;i++){
		inv[i] = modpow(ka[i],(ll)inf-2);
	}
}
int comb(int n,int k){
	if( k<0 || n<0 || k>n)return 0;
	if(k==0 || k==n)return 1;
	int res = (ka[n] * inv[k]) % inf;
	res = (res*inv[n-k]) % inf;
	return res;
}
signed main(){
	int n;
	cin>>n;
	vector<int> a;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		a.pb(x);
	}
	vector<int> b;
	for(int i=0;i<n-1;i++){
		b.pb(a[i+1]-a[i]);
	}
	setinv(114514);
	setkaijo(114514);
	coef[1] = ka[n-1];
	for(int i=2;i<=n-1;i++){
		coef[i] = modpow( i, inf-2 ) * coef[1];
		coef[i] %= inf;
		coef[i] += coef[i-1];
	}
	int ans = 0;
	for(int i=0;i<n-1;i++){
		ans += b[i] * coef[i+1];
		ans %= inf;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5620
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pairs;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}


int main(){
    ll a,b; cin>>a>>b;
    if(a>b)cout<<"a > b"<<endl;
    else if (a<b) cout<<"a < b"<<endl;
    else cout<<"a == b"<<endl;
    return 0;
}
 
    
    



Measured memory_bytes: 3092
#include <stdio.h>
#include <math.h>

int main(int argc, const char * argv[]) {

    int w,n,i = 1;
    int tmp;
    scanf("%d",&w);
    scanf("%d",&n);
    
    int swap[n * 2];
    int num[w];
    
//    if(w > 30 || n > 30){
//        exit(0);
//    }
    
    while(i < n*2){
        scanf("%d,%d",&swap[i],&swap[i+1]);
        i = i + 2;
    }
    for(i = 1; i <= w; i++){
        num[i] = i;
    }
    
    i = 1;
    
    while(i < n * 2){
        tmp = num[swap[i]];
        num[swap[i]] = num[swap[i+1]];
        num[swap[i+1]] = tmp;
        i = i + 2;
    }
    
    for(i = 1; i <= w; i++){
        printf("%d\n",num[i]);
    }
    return 0;
}

Measured memory_bytes: 596
import math

N, K = map(int, input().split())

ans = 0
if K <= N:
    ans += N - K + 1
for i in range(1, min(K, N + 1)):
    ans += (1 / 2) ** math.ceil(math.log2(K / i))

ans /= N
print('{:.10f}'.format(ans))


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

int main(){
    int k, a, b;
    bool flag = false;
    cin >> k >> a >> b;
    for(int i = a; i <= b; i++){
        if(i % k == 0){
            flag = true;
        }
    }
    if(flag == true)cout << "OK" << endl;
    else cout << "NG" << endl;
}

Measured memory_bytes: 3592
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
n = int(input())
a = list(map(int, input().split()))

x = {}
y = {}
for i in range(n):
    t = i - a[i]
    s = i + a[i]
    if t in x:
        x[t] += 1
    else:
        x[t] = 1
    if s in y:
        y[s] += 1
    else:
        y[s] = 1
cnt = 0
for i in x.keys():
    if i in y:
        cnt += x[i]*y[i]
print(cnt)

Measured memory_bytes: 58776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
string YES[2] = {"NO", "YES"};
string yes[2] = {"No", "Yes"};

int main(){
    ll h, w, m; cin >> h >> w >> m;
    vector<ll> hc(h, 0), wc(w, 0);
    map<pair<ll, ll>, ll> mp;
    rep(i, m){
        ll x, y;    cin >> x >> y;
        x--, y--;
        hc[x] += 1; wc[y] += 1;
        mp[{x, y}] = 1;
    }
    ll hm = MAX(hc), wm=MAX(wc);
    set<ll> ht, wt;
    rep(i, h) if(hm==hc[i]) ht.insert(i);
    rep(i, w) if(wm==wc[i]) wt.insert(i);
    ll res=hm+wm-1;
    for(auto x: ht){
        for(auto y: wt){
            if(mp[{x, y}]) continue;
            cout << res+1 << endl;
            return 0;
        }
    }
    cout << res << endl;
}


Measured memory_bytes: 54672
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int i,j,k,n,m,l,x,y,route[2][21][21];

int main(){
	scanf("%d",&n);
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(i!=j)route[0][i][j]=999999999;
		}
	}
	
	scanf("%d",&m);
	for(i=0;i<m;i++){
		scanf("%d,%d,%d,%d",&j,&k,&x,&y);
		route[0][j-1][k-1]=x;
		route[0][k-1][j-1]=y;
	}

	for(l=1;pow(2.0,l-1)<n-1;l++){
		for(i=0;i<n;i++){
			for(j=0;j<n;j++){
				route[l%2][i][j]=route[(l+1)%2][i][j];
				for(k=0;k<n;k++){
					if(route[l%2][i][j]>route[(l+1)%2][i][k]+route[(l+1)%2][k][j]){
						route[l%2][i][j]=route[(l+1)%2][i][k]+route[(l+1)%2][k][j];
					}
				}
			}
		}
	}

	l=(l-1)%2;

	scanf("%d,%d,%d,%d",&x,&y,&j,&k);
	printf("%d\n",j-k-route[l][x-1][y-1]-route[l][y-1][x-1]);

	return 0;
}

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

int main() {
    int N;
    int l[1000];
  	int r[1000];
  	int sum;  
  	cin >> N;
	for (int i =0; i<N; ++i) cin >> l[i] >> r[i];
  	for (int i = 0; i <N; i++){
      sum += r[i] - l[i] +1;
    
    
    }
  	cout << sum << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <thread>
#include <tuple>
#include <type_traits>
#include <vector>

#include <stdio.h>

using ll = long long;
using namespace std;

ll to5(ll a) { return a * a * a * a * a; }

int main() {
    ios::sync_with_stdio(false);
    int n, y;
    cin >> n >> y;

    for (int i = 0; i <= y / 10000; i++) {
        for (int j = 0; j <= (y - 10000 * i) / 5000; j++) {
            int k = n - i - j;
            if (10000 * i + 5000 * j + 1000 * k == y) {
                printf("%d %d %d\n", i, j, k);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");
    return 0;
}


Measured memory_bytes: 3208
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let k: usize = sc.read();
    let n: usize = sc.read();
    if k % 2 == 0 {
        print!("{}", k / 2);
        for _ in 1..n {
            print!(" {}", k);
        }
        println!();
    } else {
        let mut ans = vec![(k + 1) / 2; n];
        let mut tail = ans.len() - 1;
        for _ in 0..(n / 2) {
            ans[tail] -= 1;
            if ans[tail] == 0 {
                tail -= 1;
            } else {
                for i in (tail + 1)..n {
                    ans[i] = k;
                }
                tail = ans.len() - 1;
            }
        }
        for i in 0..n {
            if ans[i] == 0 {
                break;
            }
            if i > 0 {
                print!(" ");
            }
            print!("{}", ans[i]);
        }
        println!();
    }
}

/// 1 ...
/// 2 ...
/// 3
/// 3 1 ...
/// 3 2 ...
/// 3 3 ...
/// 3 4 ...
/// 3 5 ...
/// 4 ...
/// 5 ...
///
/// 3 3 3 3 3 3 3 3 3 3 3 3 0 0
/// 3 3 3 3 3 3 3 3 3 3 3 3 1 0
/// 3 3 3 3 3 3 3 3 3 3 3 3 1 1
/// 3 3 3 3 3 3 3 3 3 3 3 3 2 2
/// 3 3 3 3 3 3 3 3 3 3 3 3 2 3
/// 3 3 3 3 3 3 3 3 3 3 3 3 2 4
/// 3 3 3 3 3 3 3 3 3 3 3 3 2 5
/// 3 3 3 3 3 3 3 3 3 3 3 3 3
/// 3 3 3 3 3 3 3 3 3 3 3 3 3 1
/// 3 3 3 3 3 3 3 3 3 3 3 3 3 2
/// 3 3 3 3 3 3 3 3 3 3 3 3 3 3
pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 10492
N = int(input())
A_list = list(map(int, input().split()))

def gcd(v1, v2):
    if v2 == 0:
        return v1
    return gcd(v2, v1%v2)

tmp = A_list[0]
for a in A_list:
    tmp = gcd(tmp, a)

print(tmp)

Measured memory_bytes: 14252
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

ll dp[13][1<<13][10]; //桁数, 現在のエレベーター,　前の桁 

bool solve(){
  int n;
  int low[7], up[7];
  
  scanf("%d", &n);
  if(n == 0) return false;
  
  for(int i=0;i<n;i++) scanf("%d%d", low+i, up+i);

  memset(dp, 0, sizeof(dp));

  dp[0][1][0] = 1;

  for(int i=0;i<n*2;i++){
    for(int j=0;j<(1<<(2*n+1));j++){
      for(int k=0;k<10;k++){
        int next[10] = {};

        for(int l=0;l<n;l++){
          //1桁目
          if((1 << (l*2)) & j){
            for(int x=max(1,low[l]);x<=min(9, up[l]);x++)
              next[x] |= 1 << (l*2+2);
            for(int x=max(1,low[l]/10);x<=min(9,up[l]/10);x++)
              next[x] |= 1 << (l*2+1);
          }
          //2桁目
          if((1 << (l*2+1)) & j){
            for(int x=max(0,(low[l]-k*10));x<=min(9, up[l]-k*10);x++)
              next[x] |= 1 << (l*2+2);
          }
        }

        for(int l=0;l<10;l++){
          dp[i+1][next[l]][l] += dp[i][j][k];
        }
        
      }
    }
  }

  ll ans = 0;
  
  for(int i=0;i<=n*2;i++)
    for(int j=0;j<(1<<(2*n));j++)
      for(int k=0;k<10;k++)
        ans += dp[i][j + (1<<n*2)][k];

  cout << ans << endl;
  return true;
}

int main(){
  while(solve());
  
  return 0;
}



Measured memory_bytes: 11560
#include <stdio.h>

#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;

void dfs_visit(int u){
  int v;
  color[u] = GRAY;
  d[u] = ++tt;

  for(v=0 ; v<n ; v++){
    if(M[u][v] == 0) continue;
    if(color[v] == WHITE){
      dfs_visit(v);
    }
  }

  color[u] = BLACK;
  f[u] = ++tt;
}

void dfs(){
  int u;

  for(u=0 ; u<n ; u++) color[u] = WHITE;
  tt = 0;

  for(u=0 ; u<n ; u++){
    if(color[u] == WHITE) dfs_visit(u);
  }
  for(u=0 ; u<n ; u++){
    printf("%d %d %d\n", u+1, d[u], f[u]);
  }
}

int main(){
  int u, v, k, i, j;

  scanf("%d", &n);
  for(i=0 ; i<n ; i++){
    for(j=0 ; j<n ; j++) M[i][j] = 0;
  }

  for(i=0 ; i<n ; i++){
    scanf("%d %d", &u, &k);
    u--;
    for(j=0 ; j<k ; j++){
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
    }
  }

  dfs();

  return 0;
}

Measured memory_bytes: 636
//jinhaonan
#include<set>
#include<map>
#include<list>
#include<ctime>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<cassert>
#include<sstream>
#include<numeric>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
#define For(i,x,y) for(int i=x,_y=y;i<=_y;++i)
#define Rep(i,x,y) for(int i=x,_y=y;i>=_y;--i)
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
inline ll read()
{
	ll x=0;char c=getchar();bool f=0;
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';x=(x<<1)+(x<<3)+c-'0',c=getchar());
	return f?-x:x;
}
inline void write(ll x)
{
	if(x<0)putchar('-'),x=-x;
	if(x>=10)write(x/10);
	putchar(x%10+48);
}
char s[110];
int n,m,a[110];
ll b[110],sum,k;
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	k=read();
	For(i,1,n)
	{
		if(s[i]==s[i-1])
		{
			++b[m];
		}else
		{
			a[++m]=s[i]-'0';
			b[m]=1;
		}
	}
	if(a[1]==1)
	{
		if(b[1]>=k)puts("1");else write(a[2]),puts("");
	}else
	{
		write(a[1]),puts("");
	}
}

Measured memory_bytes: 256
from collections import defaultdict
n=int(input())
dd = defaultdict(int)
A=[int(i) for i in input().split()]
for i in A:
    dd[i]+=1
memo = [0]*(n+1)
for i in dd:
    memo[i]=(dd[i]*(dd[i]-1))//2
ans = sum(memo)
done = [-1]*(n+1)
for i in range(n):
    if done[A[i]]==-1:
        done[A[i]]=(int(ans-memo[A[i]]+(memo[A[i]])*((dd[A[i]]-2)/dd[A[i]])))
        print(done[A[i]])

    else:
        print(done[A[i]])


Measured memory_bytes: 26980
#include<bits/stdc++.h>
using namespace std;
int a[100010];
long long n,ans;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
    cin>>a[i];
    for(int i=1;i<=n;i++)
    {
        ans+=a[i]/2;
        a[i]%=2;
        if(i<n&&a[i]&&a[i+1])
        {
            ans++;
            a[i]--;
            a[i+1]--;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int [] A  = new int [N];
        for(int i=0; i<N; i++){
            A[i] = sc.nextInt();
        }
        boolean judge = true;
        Arrays.sort(A);
        
        for(int i=0; i<N-1; i++){
            if(A[i] == A[i+1]){
                judge = false;
                break;
            }
        }
        
        if(judge) System.out.println("YES");
        else System.out.println("NO");
        
    }
}


Measured memory_bytes: 60140
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){
    ll n = vec.size();
    rep(i,n) cout << "i" << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ll n ; cin >> n;
    vector<pair<ll,ll>> a(n);
    rep(i,n){
        cin >> a.at(i).first;
        a.at(i).second = i;
    }
    sort(a.rbegin(),a.rend());
    vector<vector<ll>> dp(n+1,vector<ll>(n+1,0));

    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(i+j>n) continue;
            ll k1 = 0, k2 = 0;
            if(i-1>=0){
                k1 = dp[i-1][j] + (abs(a[i+j-1].second - ( i - 1)) * a[i+j-1].first);
            }
            if(j-1>=0){
                k2 = dp[i][j-1] + (abs(a[i+j-1].second - ( n - j)) * a[i+j-1].first);
            }
            dp[i][j] = max(k1,k2);            
        }
    }
    ll ans = 0;
    for(int i=0;i<=n;i++){
        ans = max(ans,dp[i][n-i]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 34684
n,y = map(int,input().split())
ans = [-1,-1,-1]

for i in range(n+1):
	for j in range(n-i+1):
		if y == i*10000 + j*5000 + (n-i-j)*1000:
			ans = [i,j,(n-i-j)]
			break
			
print(*ans)


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

int main() {
  int A,B,C,D,L,R ;
  cin >> A >> B >> C >>D;
  L=A+B;
  R=C+D;
  if (L<R) {
    cout << "Right" << endl;
  }
  if (L==R) {
    cout << "Balanced" << endl;
  }
  if (L>R) {
    cout << "Left" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    vector<int> v(3);
    for(int i=0;i<3;i++){
        cin>>v[i];
    }
    int ans = 500;
    for(int i=0;i<2;i++){
        for(int j=i+1;j<3;j++){
            ans = min(ans,v[i]+v[j]);
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
n=int(input())
a=[list(map(int,input().split())) for i in range(n)]
x,y = a[0][0],a[0][1]
for i in range(1,n):
  xr=(x+a[i][0]-1)//a[i][0]
  yr=(y+a[i][1]-1)//a[i][1]
  r=max(xr,yr)
  x=r*a[i][0]
  y=r*a[i][1]
print(x+y)

Measured memory_bytes: 3188
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;
int main()
{
	int N;
	long long x, a[100];
	scanf("%d%lld", &N, &x);
	for (int i = 0; i < N; i++) {
		scanf("%lld", &a[i]);
	}
	sort(a, a + N);
	int i = 0, an = 0;
	while (true) {
		if (x < a[i]) {
			break;
		}
		if (i == N - 1) {
			if (x == a[i]) {
				an++;
				
			}
			break;
		}
		x -= a[i];
		an++;
		i++;
	}
	printf("%d", an);
	return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll A, B;

int main() {

	cin >> A >> B;

	rep(i, 112345) {
		if ((ll)(i * 0.08) == A && (ll)(i * 0.1) == B) {
			cout << i << endl;
			return 0;
		}
	}

	cout << -1 << endl;

	return 0;
}


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

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> l, r;
  for (int i = 0; i < n; i++) {
    int pos;
    cin >> pos;
    if (pos >= 0) r.push_back(pos);
    else l.push_back(-pos);
  }
  reverse(l.begin(), l.end());
  int ans = (int) 1e9;
  if (l.size() >= k) ans = min(ans, l[k - 1]);
  if (r.size() >= k) ans = min(ans, r[k - 1]);
  for (int i = 1; i < k; i++) { // choose r
    if (r.size() >= i && l.size() >= k - i) {
      ans = min(ans, 2 * r[i - 1] + l[k - 1 - i]);
      ans = min(ans, r[i - 1] + 2 * l[k - 1 - i]);
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 1020
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func getFloat() float64 {
	sc.Scan()
	n, _ := strconv.ParseFloat(sc.Text(), 64)
	return n
}

func sum(n []int) int {
	a := 0
	for _, v := range n {
		a += v
	}
	return a
}

func partseFloat(s string) (n float64) {
	n, _ = strconv.ParseFloat(s, 64)
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n, m, x, y := getInt(), getInt(), getInt(), getInt()

	xs := make([]int, n)

	for i := range xs {
		xs[i] = getInt()
	}
	sort.Ints(xs)

	ys := make([]int, m)
	for i := range ys {
		ys[i] = getInt()
	}
	sort.Ints(ys)

	zs := make([]int, y-x)
	for i := 0; i < y-x; i++ {
		zs[i] = x + 1 + i
	}

	cnt := 0
	for _, v := range zs {
		if v > xs[n-1] && v <= ys[0] {
			cnt = 1
			break
		}
	}

	if cnt == 1 {
		fmt.Println("No War")
	} else {
		fmt.Println("War")
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
long long a,b,c,d;
map<long long,long long> m;

long long retrofazon(long long n)
{
	if(n==0) return 0;
	if(m[n]) return m[n];
	long long t,rez=1000000000000000000LL;
	if(n<1000000000000000000LL/d) rez=n*d;
	t=n-n%2;
	rez=min(rez,a+(n%2)*d+retrofazon(t/2));
	t=n+2-n%2;
	if(t/2<n) rez=min(rez,a+(2-n%2)*d+retrofazon(t/2));
	t=n-n%3;
	rez=min(rez,b+(n%3)*d+retrofazon(t/3));
	t=n+3-n%3;
	if(t/3<n) rez=min(rez,b+(3-n%3)*d+retrofazon(t/3));
	t=n-n%5;
	rez=min(rez,c+(n%5)*d+retrofazon(t/5));
	t=n+5-n%5;
	if(t/5<n) rez=min(rez,c+(5-n%5)*d+retrofazon(t/5));
	m[n]=rez;
	return rez;
}
int main()
{
	int t;
	scanf("%d",&t);
	while(t--)
	{
		long long n;
		scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
		printf("%lld\n",retrofazon(n));
		m.clear();
	}
}

Measured memory_bytes: 4952
N = int(input())

ans = 'Yes'
pre = input()

his = {}
his[pre] = 1
for i in range(N-1):
    s = input()
    if s[0] != pre[ len(pre) - 1 ] or (s in his):
        ans = 'No'
        
    his[s] = 1
    pre = s
    
print (ans)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <math.h>
using namespace std;

int main(){
  int N,K,Q;
  cin >> N >> K >> Q;
  vector<int> A(Q);
  for(int i = 0; i < Q; i++){
    cin >> A[i];
  }
  vector<int> p(N);
  for(int i = 0; i < N; i++){
    p[i] = K - Q;
  }

  for(int i = 0; i < Q; i++){
    p[A[i] - 1] = p[A[i] - 1] + 1;
  }

  for(int i = 0; i < N; i++){
    if(p[i] > 0){
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <bits/stdc++.h>
#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll mod=1e9+7;
 
using pear = pair<int,int>;
 
int main(){
    ll n; cin >>n;
    ll z = sqrt(n)+1;
    ll ans = n;
    rep1(i,z){
        if(n%i == 0){
            ll now;
            if(i == 1) now = n-1;
            else now = n/i+i-2;

            if(now < ans) ans = now;
            }
    }
    cout << ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fori(x) for(int i=0;i<x;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long int 
#define ld long double
#define ull unsigned long long int
#define pi acos(-1)
#define test() int T,t=1;cin>>T;
typedef vector<int> VI;
typedef pair<int,int> PII;

void solve()
{
   //freopen("input.txt","r",stdin);
	int n,b,c=0;cin>>n>>b;
	fori(n){
		
		int x,y;cin>>x>>y;
		double d=sqrtl(pow(x,2)+pow(y,2));
		
		if(d<=(double)b) c++;
	}
	printf("%d\n",c);
}
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);

solve();

	return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  ll n;
  cin >> n;
  stack<char> stk;
  while(n != 0){
    n--;
    stk.push(n%26 + 'a');
    n /= 26;
  }
  while(!stk.empty()){
    cout << stk.top();
    stk.pop();
  }
  return 0;
}

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

namespace AtCoder
{
   public class Program
   {
       public static void Main(string[] args)
       {
           new Program().Solve(new ConsoleInput(Console.In, ' '));
       }

       public void Solve(ConsoleInput cin)
       {
       int a=cin.ReadInt;
       int b=cin.ReadInt;
       int n =(a*b);
       if(n%2==1)
            {
                Console.WriteLine("Odd");
            }
       if(n%2==0)
            {
                Console.WriteLine("Even");
            }
        }
       }
   }

   public class ConsoleInput
   {
       private readonly System.IO.TextReader _stream;
       private char _separator = ' ';
       private Queue<string> inputStream;
       public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
       {
           this._separator = separator;
           this._stream = stream;
           inputStream = new Queue<string>();
       }
       public string Read
       {
           get
           {
               if (inputStream.Count != 0) return inputStream.Dequeue();
               string[] tmp = _stream.ReadLine().Split(_separator);
               for (int i = 0; i < tmp.Length; ++i)
                   inputStream.Enqueue(tmp[i]);
               return inputStream.Dequeue();
           }
       }
       public string ReadLine { get { return _stream.ReadLine(); }}
       public int ReadInt { get { return int.Parse(Read); }}
       public long ReadLong { get { return long.Parse(Read); }}
       public double ReadDouble { get { return double.Parse(Read); }}
       public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
       public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
       public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
   }


Measured memory_bytes: 11220
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std;
const int N=200005;
int n,t,a[N],b[N];
long long ans;
int pre(int i){
	return i>1?i-1:n;
}
int sub(int i){
	return i<n?i+1:1;
}
struct data{
	int x,v;
	bool operator < (const data &n) const{
		return v<n.v;
	}
};
priority_queue<data> q;
bool check(int x){
	return b[x]-a[x]>=b[pre(x)]+b[sub(x)];
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=n;i++){
		scanf("%d",&b[i]);
		if(a[i]>b[i]){
			puts("-1");
			return 0;
		}
	}
	for(int i=1;i<=n;i++){
		if(check(i)){
			q.push((data){i,b[i]});
		}
	}
	while(!q.empty()){
		int now=q.top().x;
		q.pop();
		t=(b[now]-a[now])/(b[pre(now)]+b[sub(now)]);
		ans+=t;
		b[now]-=t*(b[pre(now)]+b[sub(now)]);
		if(check(pre(now))){
			q.push((data){pre(now),b[pre(now)]});
		}
		if(check(sub(now))){
			q.push((data){sub(now),b[sub(now)]});
		}
	}
	for(int i=1;i<=n;i++){
		if(a[i]!=b[i]){
			puts("-1");
			return 0;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2936
import java.io.*;
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		for (; N-->0; )
		{
			String x = sc.next(), y = sc.next();
			System.out.println(toString(toInt(x) + toInt(y)));
		}
	}
	
	private static int dd(char c)
	{
		switch (c)
		{
		case 'm': return 1000;
		case 'c': return 100;
		case 'x': return 10;
		case 'i': return 1;
		}
		return 0;
	}
	
	private static int toInt(String s)
	{
		int ret = 0;
		for (int i = 0; i < s.length(); )
		{
			char c = s.charAt(i++);
			int n = 1;
			if (Character.isDigit(c))
			{
				n = c - '0';
				c = s.charAt(i++);
			}
			ret += n * dd(c);
		}
		return ret;
	}
	
	private static String toString(int n)
	{
		int x;
		String ret = "";
		
		x = n % 10;
		ret = (x == 0 ? "" : (x == 1 ? "i" : x + "i")) + ret;
		n /= 10;
		
		x = n % 10;
		ret = (x == 0 ? "" : (x == 1 ? "x" : x + "x")) + ret;
		n /= 10;
		
		x = n % 10;
		ret = (x == 0 ? "" : (x == 1 ? "c" : x + "c")) + ret;
		n /= 10;
		
		x = n % 10;
		ret = (x == 0 ? "" : (x == 1 ? "m" : x + "m")) + ret;
		n /= 10;
		
		return ret;
	}
}
/*
10
xi x9i
i 9i
c2x2i 4c8x8i
m2ci 4m7c9x8i
9c9x9i i
i 9m9c9x8i
m i
i m
m9i i
9m8c7xi c2x8i
*/

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
const int N=105;
typedef pair<int,int>pii;
struct graph{
	static const int N=210,M=11000;
	struct edge{int to,next,f;}e[M<<1];
	int h[N],cur[N],xb;
	inline void addedge(int x,int y,int z){
		e[++xb]=(edge){y,h[x],z};h[x]=xb;
		e[++xb]=(edge){x,h[y],0};h[y]=xb;
	}
	int S,T,d[N],n;
	inline bool bfs(){
		static int q[N];int t=0,w=1;q[1]=S;
		memset(d+1,0,n<<2);d[S]=1;
		for(;t<w;){
			int u=q[++t];
			for(int i=h[u];i;i=e[i].next)if(e[i].f && !d[e[i].to])
				d[e[i].to]=d[u]+1,q[++w]=e[i].to;
		}
		return d[T];
	}
	int dfs(int x,int f){
		if(x==T)return f;
		int ans=0,&i=cur[x],t;
		for(;i;i=e[i].next)if(e[i].f && d[e[i].to]==d[x]+1){
			if(t=dfs(e[i].to,min(f,e[i].f))){
				ans+=t,e[i].f-=t;e[i^1].f+=t;f-=t;
				if(!f)break;
			}
		}
		return ans;
	}
	inline int dinic(int s,int t){
		int ans=0;S=s;T=t;
		for(;bfs();ans+=dfs(s,1<<30))memcpy(cur+1,h+1,n<<2);
		return ans;
	}
}g;
int n,m,x,i,j,k,l,b[N][N],c[N][N],d[N];
vector<int>a[N];
int main(){
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i)for(j=0,a[i].resize(m);j<m;++j)scanf("%d",&a[i][j]);;
	for(i=1;i<=m;++i){
		g.xb=1;g.n=n*2+2;memset(g.h+1,0,g.n<<2);
		for(j=1;j<=n;++j){
			g.addedge(g.n-1,j,1);g.addedge(j+n,g.n,1);
			for(k=0;k<=m-i;++k)g.addedge(j,(a[j][k]-1)/m+1+n,1);
		}
		assert(g.dinic(g.n-1,g.n)==n);
		for(j=1;j<=n;++j){
			for(k=g.h[j];g.e[k].f || g.e[k].to==g.n-1;k=g.e[k].next);
			for(l=0;(a[j][l]-1)/m+1!=g.e[k].to-n;++l);
			b[j][i]=a[j][l];a[j].erase(a[j].begin()+l);
		}
	}
	for(i=1;i<=n;++i)memcpy(c[i]+1,b[i]+1,m<<2);
	for(i=1;i<=m;++i){
		for(j=1;j<=n;++j)d[j]=c[j][i];
		sort(d+1,d+n+1);
		for(j=1;j<=n;++j)c[j][i]=d[j];
	}
	for(i=1;i<=n;++i)for(j=1;j<=m;++j)printf("%d%c",b[i][j],j==m?'\n':' ');
	for(i=1;i<=n;++i)for(j=1;j<=m;++j)printf("%d%c",c[i][j],j==m?'\n':' ');
	return 0;
}

Measured memory_bytes: 768
from itertools import combinations
L, R = map(int, input().split())
if (L % 2019 > R % 2019) or R - L >=2019:
    print(0)
else:
    ans = 2018
    for i, j in combinations(range(L, R + 1), 2):
        a = i % 2019
        b = j % 2019
        mod = (a * b) % 2019
        if ans > mod:
            ans = mod
    print(ans)


Measured memory_bytes: 3060
n = int(input())
n_len = len(str(n))
ans = 0

if n_len == 1:
  ans += n
elif n_len > 1:
  ans += 9

if n_len == 3:
  ans += n - 99
elif n_len > 3:
  ans += 999 - 99

if n_len == 5:
  ans += n - 9999
elif n_len > 5:
  ans += 99999 - 9999

print(ans)


Measured memory_bytes: 38384
#include <algorithm>
#include <cstdio>

int main() {
  using std::max;
  using std::min;

  int n, x, y;
  std::scanf("%d%d%d", &n, &x, &y);
  int l = y - x + 1;
  int a = x - 1;
  int b = n - y;

  for (int k = 1; k != n; k += 1) {
    int ans = 0;

    for (int z : {a, b}) {
      ans += max(0, z - k);

      if (0 <= z - k)
        ans += 1;
      ans += max(0, min(z, z + (l + 1) / 2 - k) - max(0, z + 1 - k)) * 2;
      if (l % 2 == 0) {
        int temp = z + l / 2 - k;
        if (0 <= temp && temp < z)
          ans += 1;
      }
    }

    if (k * 2 < l)
      ans += l;
    if (k * 2 == l)
      ans += l / 2;

    ans += max(0, min(a, a + 2 + b - k) - max(0, a + 2 - k));

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


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

//#define int long long
#define DEBUG 0
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;

signed main() {
	int N; cin >> N;
	string s, f; cin >> s >> f;
	int ans = N * 2;
	rep(i, 0, N) {
		int temp = 0;
		rep(j, 0, N - i) {
			if (s[i + j] == f[j])temp++;
			else temp = 0;
		}
		ans = min(ans, 2 * N - temp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define F(type, i, a, b) for(type i = a; i <= b; i ++)
#define RF(type, i, a, b) for(type i = a; i >= b;i --)
#define sz(a) sizeof(a)
#define deb(a) cerr<<" ["<<#a<<"->"<<a<<"] "
#define next_line cerr<<'\n'
#define all(a) a.begin(), a.end()
#define iter(it, s) for(auto it = s.begin(); it != s.end(); it ++)

using namespace std;

typedef pair<ll,ll> pii;
typedef pair<ll,ll> pll;

ll n, MaxBen = 0LL;
vector<ll> dp(2e5 + 1, -1);
ll Maxval(ll st, vector<ll> &h, vector<ll> &a){
    ll val = a[st], maxIncr = 0LL;
    if(dp[st ] != -1LL)
        return dp[st];
    F(ll, i, 0, st - 1){
        if(h[i] <= h[st]){
            maxIncr = max(maxIncr, Maxval(i, h, a));
        }
    }
    val += maxIncr;
    dp[st] = val;
    MaxBen = max(MaxBen, val);
    return val;
}

ll Query(ll st, ll end, ll node, ll l, ll r, vector<ll> &Tree){
    if(st > end)
        return 0LL;
    if((r < st) || (end < l))
        return 0LL;
    if((l <= st) && (end <= r))
        return Tree[node];
    ll mid = (st + end) >> 1;
    return max( Query(st, mid, 2LL * node, l, r, Tree), 
                Query(1LL + mid, end, 2LL * node + 1LL, l, r, Tree)); 
}

void update(ll st, ll end, ll node, ll indx, ll val, vector<ll> &Tree){
    if((indx < st) || (indx > end))
        return;
    if(st == end){
        Tree[node] = val;
        return;
    }
    ll mid = (st + end) >> 1LL;
    update(st, mid, 2LL * node, indx, val, Tree);
    update(mid + 1LL, end, 2LL * node + 1LL, indx, val, Tree);
    Tree[node] = max(Tree[2LL * node],
                     Tree[2LL * node + 1LL]);
}

void solve()
{
    cin>>n;
    vector<ll> Height(n), Beauty(n), Tree(4LL * n + 1LL, 0LL);
    F(ll, i, 0, n - 1){
        cin>>Height[i];
    }
    F(ll, i, 0, n - 1){
        cin>>Beauty[i];
    }
    // RF(ll, i, n - 1, 0){
    //     Maxval(i, Height, Beauty);
    // }
    //We need to find the maximum value of dp 
    //in heights less than our height
    //For this we need that the heights are in increasing 
    //order ,so that we can query over a range easily and find the
    //maximum of them. For this we can use segment tree .For heights
    //That we don't wanna involve ,we can simply initialize them as 0
    F(ll, st, 0, n - 1){
        ll Maxincr = Query(0LL, n - 1LL, 1LL, 0LL, Height[st] - 2LL, Tree);
        dp[st] = Maxincr + Beauty[st];
        update(0LL, n - 1LL, 1LL, Height[st] - 1LL, dp[st], Tree);
        MaxBen = max(MaxBen, dp[st]);
    }
    cout<<MaxBen<<'\n';
}

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
        //freopen("Debug.txt", "w", stderr);
    #else
    #endif
    solve();
}


Measured memory_bytes: 14288
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>

using namespace std;
typedef long long llong;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<llong, llong> pll;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n, m, k;
	cin >> n >> m >> k;
	for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= m; ++j) {
            int x = i * (m - j) + (n - i) * j;
            if (x == k) {
                printf("Yes\n");
                return 0;
            }
        }
	}
	printf("No\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAX = (1e5)+1;

int X, n, q;
long long r[MAX], t[MAX], a[MAX];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> X >> n;
	for(int i = 1; i <= n; i++) cin >> r[i];
	cin >> q;
	long long mn = 0, mx = X, sum = 0;
	for(int i = 1, j = 1, mul = -1; i <= q; i++) {
		cin >> t[i] >> a[i];
		while(j <= n && r[j] <= t[i]) {
			sum += mul * (r[j] - r[j-1]);
			mn += mul * (r[j] - r[j-1]);
			mx += mul * (r[j] - r[j-1]);
			mn = max(0ll, mn);
			mn = min(1ll * X, mn);
			mx = max(0ll, mx);
			mx = min(1ll * X, mx);
			mul *= -1;
			++j;
		}
		
		a[i] += sum;
		if(a[i] < mn) a[i] = mn;
		if(a[i] > mx) a[i] = mx;
		a[i] += mul * (t[i] - r[j-1]); // always over 1
		a[i] = max(0ll, a[i]);
		a[i] = min(1ll * X, a[i]);

		cout << a[i] << '\n';
	}
}


Measured memory_bytes: 3584
/*
* Author. Silviase(@silviasetitech)
* For AtCoder
*/

import java.util.*;
import java.lang.*;
import java.math.*;


public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int[] ar = new int[4];
        for (int i = 0; i < 6; i++) {
            int j = sc.nextInt();
            ar[j-1]++;
        }
        int count1 = 0;
        int count2 = 0;
        for (int i = 0; i < 4; i++) {
            if (ar[i] == 1) {
                count1++;
            }else if(ar[i] == 2) {
                count2++;
            }
        }
        if (count1 == 2 && count2 == 2) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }


        sc.close();


    }
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int r=0;
    int b=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='R')
        {
            r++;
        }else
        {
            b++;
        }
    }
    if(b>=r)
    {
        cout<<"No"<<endl;
    }else
    {
        cout<<"Yes"<<endl;
    }
}


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

int main(){
  string s;
  cin >> s;
  bool tf = true;
  if(s[0]==s[1])tf = false;
  if(s[1]==s[2])tf = false;
  if(s[2]==s[3])tf = false;
  
  if(tf){
    cout<< "Good" <<endl;
  }
  else{
    cout<< "Bad" << endl;
  }
}
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 100005
using namespace std;
long long n,a,maxa,ans;

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    if(maxa+1<a){
      ans+=(a-1)/(maxa+1);
      maxa=max(maxa,1LL);
    }else maxa=max(maxa,a);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <set>
#include <sstream>
#include <vector>
using namespace std;

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

    int N; // N > 0
    cin >> N;
    int counter = 0;
    for (int i = 1; i <= N; i++)
    {
        if (((int)(floor(log10(i)) + 1)) % 2 != 0)
        {
            counter++;
        }
    }

    cout << counter << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		StringBuilder s = new StringBuilder();
		while (sc.hasNext()) s.append(sc.next().charAt(0));
		System.out.println(s);
		sc.close();			
	}

	public static void main(String args[]) {
		solve();
	}

}

Measured memory_bytes: 35556
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff              first
#define ss              second
#define ll 				long long int
#define int             long long int
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define modp            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define FIO           	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl 			'\n'
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
// void aks()
// {
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
// }


void solve()
{
	int a, b;
	cin >> a >> b;
	cout << a*b << endl;
}
 
int32_t main()
{
	FIO
    //aks();
    //w(t)
    {
    	solve();
    }
    return 0;
}
	

Measured memory_bytes: 3656
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <map> 
#include <set>
#include <string>
#include <functional>
#include <list>
#include <random>
#include <time.h>
#define ll long long
#define oku7 1000000007
#define MAXN (int)1e+5 * 2+1
using namespace std;
std::mt19937 mt((int)time(0));



int costData[100][100];
ll imos[MAXN];
ll input[MAXN];
int dx[4] = { 0, 1, 0,-1 }; // x軸方向への変位
int dy[4] = { 1, 0,-1, 0 }; // y軸方向への変位

char mapData[300][300];

bool chk(int A, int B, int N) {
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			char ij = mapData[(i + A) % N][(j + B) % N];
			char ji = mapData[(j + A) % N][(i + B) % N];
			if (ij != ji) return false;
		}
	}



	return true;
}

int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			char c;
			cin >> c;
			mapData[i][j] = c;
		}
	}

	int ans = 0;
	for (int A = 0; A < N; A++) {
		if (chk(A, 0, N)) ans++;
		
	}
	cout << ans*N << "\n";

}

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

int main()
{
	int a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	if(b-a<=f&&c-a<=f&&d-a<=f&&e-a<=f&&c-b<=f&&d-b<=f&&e-b<=f&&d-c<=f&&e-c<=f&&e-d<=f){
			cout<<"Yay!";
			return 0;
	}
	 cout<<":(";
	return 0; 
}
                                          

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

using namespace std;

int main() {

    int N;
    cin >> N;
    vector<int> P(N);
    for(int i = 0; i < N; i++) cin >> P.at(i);

    int min = N + 1;
    int ans = 0;
    for(int i = 0; i < N; i++) {
        if(min > P.at(i)) {
            ans++;
            min = P.at(i);
        }
    }

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

Measured memory_bytes: 1024
import java.util.Scanner;

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

        long t = a + b;


        long syou = n/t;
        //System.out.println(syou);

        long amari = n%t;
        //System.out.println(amari);

        long nokori = a;
        // 7  1
        if(amari < a){
            nokori = amari;
        }
        long ans = a*syou + nokori;
        System.out.println(ans);

    }

}

Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define  fill(st,et,val,arr) for(int i=st;i<=et;i++)arr[i]=val;
#define all(v) v.begin(),v.end()
template <class T>
inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = ch == '-', ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}
 
const int M=1e9 + 7;
const int MAX=1e5+7;
using namespace std;
bool comp(int a,int b)
{	
	return a>b;
}
void printQ(vector<int> q)
{   
    cout<<"v->  ";
	for(int i=0;i<q.size();i++)
	{
		cout<<q[i]<<" ";
	}
	cout<<endl;
}

int32_t main() 
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n;
	int s;cin>>s;
	int i=1;
	string v[s];
	int a[s];
	int ans1=0;
	map<int,int> mp;
	for(int i=0;i<s;i++)
	{
		cin>>a[i]>>v[i];
		if(v[i]=="AC" && mp[a[i]]==0)
		{
			ans1++;
			mp[a[i]]=i+1;
		}	
	}
	int ans2=0;
	for(int i=0;i<s;i++)
	{
		if(v[i]=="WA")
		{
			if(mp[a[i]]>(i+1))ans2++;
		}
	}
	cout<<ans1<<" "<<ans2<<endl;
	return 0;
}













Measured memory_bytes: 12800
#40 C - Streamline
N,M = map(int,input().split())
X = list(map(int,input().split()))
X = sorted(X,reverse = False)

# 区間の距離のリスト
if len(X) == 1:
    print(0)
else:
    dist = []
    for i in range(1,M):
        dist.append(X[i]-X[i-1])
    dist = sorted(dist,reverse = False)
    # 区間の距離を降順に N-1 個分消去
    for k in range(N-1):
        dist.pop()
        if len(dist) == 0:
            break
    print(sum(dist))

Measured memory_bytes: 20496
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <functional>
#include <utility>
using namespace std;
typedef long long ll;

int main(){
  int N;
  cin >> N;
  
  double X = (double)N/(1.08);  
  int ans1 = (int)X;
  int ans2 = (int)(X+1);

  if((int)((double)ans1*1.08)==N)cout << ans1 << endl;
  else if((int)((double)ans2*1.08)==N)cout << ans2 << endl;
  else cout << ":(" << endl;

} 

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		long K = sc.nextLong();
		String[] SSplit = S.split("");
		int countOne = 0;
		for (int i = 0; i < SSplit.length; i++) {
			if ("1".equals(SSplit[i])) {
				countOne++;
			} else {
				break;
			}
		}
		if (K <= countOne) {
			System.out.print(1);
		} else {
			System.out.print(SSplit[countOne]);
		}
	}
}


Measured memory_bytes: 23764
/*input
6
4 2 9 7 1 5
*/
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define mpr make_pair
#define MX 1000000007
#define ui unsigned int
#define ll long long
#define ld long double
#define fi first
#define se second
#define testcases int testcases;cin>>testcases;while(testcases--)
#define printvector(v) for(int i=0;i<v.size();i++) cout<<v[i]<<" ";  cout<<endl
#define printarray(v,n)  for(int i=0;i<n;i++) cout<<v[i]<<" ";  cout<<endl
#define inputarray(v,n)  for(int i=0;i<n;i++)cin>>v[i]
#define debug(i) cout<<"debug: "<<i<<endl
#define pr(i) cout<<i<<endl
#define timetaken cerr<<clock()/double(CLOCKS_PER_SEC)<<endl
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


// class graph{
//     unordered_map<int,vector<int>> adjList;
//     int n;
// public:
//     graph(int n){
//         this->n = n;
//     }
//     void addEdge(int a, int b){
//         adjList[a].pb(b);
//         adjList[b].pb(a);
//     }
    
//     ll dfs(int from, vector<vector<ll>>&dp, int col, int parent){
//         if(dp[from][col] != -1) return dp[from][col];
        
//         ll ans = 1;
//         for(auto to: adjList[from]){
//             ll tmp = 1;
//             if(to != parent){
//                 if(col == 1){
//                     tmp = dfs(to, dp, 1-col, from);
//                 } else {
//                     tmp = dfs(to, dp, col, from) + dfs(to, dp, 1-col, from);
//                 }
//             }
//             ans = (ans*tmp)%MX;
//         }
//         return dp[from][col] = ans%MX;
//     }
// };

// double dp[3000][3000];

// double cal(int n, int x, vector<ll> &a){
//     if(x == 0)return 1;
//     if(n == 0) return 0;
    
//     if(dp[n][x] > -0.9) return dp[n][x];
    
//     double ans = a[n-1]*cal(n-1,x-1,a) + (1-a[n-1])*cal(n-1,x,a);
//     return dp[n][x] = ans;
// }

int main() {
    fast_io
    int n;
    cin>>n;
    vector<ll>a(n); inputarray(a,n);
    vector<vector<ll>>dp(n,vector<ll>(n,0));

    ll sum=0;
    for(int i=0;i<n;++i)sum += a[i];
    
    for(int l=1;l<=n;++l){
        for(int i=0;i<=n-l;++i){
            int j = i+l-1;
            if(l == 1)dp[i][j] = a[i];
            else if(l == 2){
                dp[i][j] = max(a[i],a[j]);
            }else{
                dp[i][j] = max(a[i] + min(dp[i+2][j], dp[i+1][j-1]) , a[j] + min(dp[i+1][j-1], dp[i][j-2]));
            }
        }
    }
    ll x = dp[0][n-1];
    ll y = sum - x;
    pr(x-y);
}

Measured memory_bytes: 70784