akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define INF (1LL<<50)
#define MOD 1000000007

int main()
{
    int a1, a2, b1, b2;
    int result;
    scanf("%d", &a1);
    scanf("%d", &a2);
    scanf("%d", &b1);
    scanf("%d", &b2);

    if(a2>=b1 && a1>=b2) result = 0;
    else if(a2<=b1 && a1<=b2) result = 0;
    else{
        int tmp1 = (a1 < b1) ? b1 : a1;
        int tmp2 = (a2 < b2) ? a2 : b2;
        result = tmp2 - tmp1;
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
 
#include <iostream>
#include <algorithm>
 
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <cstring>
#include <string>
#include <utility>
#include <array>
#include <complex>
#include <valarray>
 
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>
 
 
using namespace std;
//#define int long long
 
typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;
 
#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
 
const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll INFLL = 1LL<<62;
const double EPS = 1e-12;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;
 
#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod
#define inside(y, x, h, w) (0 <= (y) && (y) < (h) && 0 <= (x) && (x) < (w)) ? true : false

string s;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
	cin >> s;
	int n = s.size();
	int ans = n;
	rep(i, n - 1) {
		if (s[i] != s[i + 1]) ans = min(ans, max(i + 1, n - (i + 1)));
	}
	cout << ans << endl; 
}


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

main(){
    int x,a,b;
    cin>>x>>a>>b;
    if(a>=b){
    cout<<"delicious"<<endl;
    }
    else if(a < b && b <= a + x){
        cout<<"safe"<<endl;
    }
    else if(b > a + x){
        cout<<"dangerous"<<endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,c,ans;
    scanf("%d%d%d",&a,&b,&c);
    if(a/c==0)
    {
        ans=b/c;
    }
    else
    {
        if(a%c==0)
            ans=(b/c)-(a/c)+1;
        else
            ans=(b/c)-(a/c);
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 1728
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, d=DVSR): return pow(x, d - 2, d)
def DIV(x, y, d=DVSR): return (x * INV(y, d)) % d
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N=II()

LSTP=[]
LSTN=[]
for i in range(N):
    cnt = 0
    cntMin = 0
    s = input()
    for c in s:
        if c == "(":
            cnt += 1
        else:
            cnt -= 1
        cntMin = min(cntMin, cnt)
    # print(cntMin)
    if cnt >= 0:
        LSTP.append((cntMin, cnt))
    else:
        LSTN.append((-(cnt-cntMin), -cnt))

LSTP.sort(reverse=True)
LSTN.sort(reverse=True)

res = 0
for cntMin, cnt in LSTP:
    if res + cntMin < 0:
        print("No")
        exit(0)
    res += cnt

res2 = 0
for cntMin, cnt in LSTN:
    if res2 + cntMin < 0:
        print("No")
        exit(0)
    res2 += cnt

if res - res2 == 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 172512
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int c, n, m, s, g;
	LinkedList<E>[] es;

	@SuppressWarnings("unchecked")
	void run(){
		for(;;){
			c=sc.nextInt();
			n=sc.nextInt(); // ¬Ì
			m=sc.nextInt();
			s=sc.nextInt()-1;
			g=sc.nextInt()-1;
			if((c|n|m|(s+1)|(g+1))==0){
				break;
			}
			es=new LinkedList[n];
			for(int i=0; i<n; i++){
				es[i]=new LinkedList<E>();
			}
			for(int i=0; i<m; i++){
				int u=sc.nextInt()-1;
				int v=sc.nextInt()-1;
				int w=sc.nextInt()/10;
				es[u].add(new E(v, w));
				es[v].add(new E(u, w));
			}
			solve();
		}
	}

	void solve(){
		int[][] d=new int[n][c+1];
		// ¡¢éÆ±ëC`PbgÌ
		PriorityQueue<P> que=new PriorityQueue<P>();

		for(int i=0; i<n; i++){
			Arrays.fill(d[i], INF);
		}
		d[s][c]=0;
		que.offer(new P(s, c, 0));
		for(; !que.isEmpty();){
			P p=que.poll();
			if(d[p.v][p.c]<p.d){
				continue;
			}
			for(E e : es[p.v]){
				if(d[e.to][p.c]>d[p.v][p.c]+e.cost){
					d[e.to][p.c]=d[p.v][p.c]+e.cost;
					que.offer(new P(e.to, p.c, d[e.to][p.c]));
				}
				if(p.c>0&&d[e.to][p.c-1]>d[p.v][p.c]+e.cost/2){
					d[e.to][p.c-1]=d[p.v][p.c]+e.cost/2;
					que.offer(new P(e.to, p.c-1, d[e.to][p.c-1]));
				}
			}
		}
		int min=INF;
		for(int i=0; i<=c; i++){
			min=min(min, d[g][i]);
		}
		min*=10;
		println(""+min);
	}

	class E{
		int to, cost;

		E(int to, int cost){
			this.to=to;
			this.cost=cost;
		}
	}

	class P implements Comparable<P>{
		int v, c, d;

		P(int v, int c, int d){
			this.v=v;
			this.c=c;
			this.d=d;
		}

		@Override
		public int compareTo(P p){
			return d-p.d;
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 13000
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define REP(i,n) for(int i=0;i<(n);++i)
typedef long long llong;
using namespace std;

int main(){
	int n, m;
	cin >> n >> m;
	string a[50], b[50];
	REP(i, n) cin >> a[i];
	REP(j, m) cin >> b[j];

	bool jud = false;
	REP(i, n - m + 1){
		REP(j, n - m + 1){
			bool jud2 = true;
			REP(k, m){
				if(a[i + k].substr(j, m) != b[k]) jud2 = false;
			}
			if(jud2){
				jud = true;
				goto Exit;
			}
		}
	}

Exit:;
	if(jud) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
import sys
import math

N, K = list(map(int, stdin.readline().rstrip().split()))

d = []
A = []
n = {}
for i in range(K):
    d.append(int(input()))
    #A.append(stdin.readline().rstrip().split())
    tmp = list(map(int, stdin.readline().rstrip().split()))
    A.append(tmp)
    for a in tmp:
        n[a] = 1

count = 0
for j in range(1, N+1):
    if n.get(j, 0) == 0:
        count += 1

print(count)


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

int main() {
    int n, k, r, s, p;
    cin>>n >>k >>r >>s >>p;
    vector<char> t(n);
    vector<bool> hand(n,true);
    long ans=0;
    rep(i,n){
        cin>>t[i];
        if(i<k){
            if(t[i]=='r') ans+=p;
            else if(t[i]=='s') ans+=r;
            else ans+=s;
        }else{
            if(t[i]==t[i-k] && hand[i-k]){
                ans+=0;
                hand[i]=false;
            }else if(t[i]=='r'){
                ans+=p;
            }else if(t[i]=='s'){
                ans+=r;
            }else if(t[i]=='p'){
                ans+=s;
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3748
// C - Dubious Document 2
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
string S, T;

bool match(int k){
	rp(i,0,T.size()) if(S[k+i] != '?' && S[k+i] != T[i]) return false;
	return true;
}

string create(int k){
	string s = S;
	s.replace(k, T.size(), T);
	replace(s.begin(), s.end(), '?', 'a');
	return s;
}

string solve(){
	for(int i=S.size()-T.size(); i>=0; --i) if(match(i)) return create(i);
	return "UNRESTORABLE";
}

int main(){
	cin>>S>>T;
	cout<< solve() <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

const char *mcxi = "mcxi";

int integer(char *s)
{
    int n;
    int i;
    int tmp = 1;

    for (n = i = 0; s[i]; i++){
        if ('2' <= s[i] && s[i] <= '9') tmp = s[i] - '0';
        else {
            switch (s[i]){
                case 'm': n += tmp * 1000; break;
                case 'c': n += tmp * 100; break;
                case 'x': n += tmp * 10; break;
                case 'i': n += tmp; break;
            }
            tmp = 1;
        }
    }
    return n;
}

int main(void)
{
    int n;

    scanf("%d", &n);
    while (n-- > 0){
        char s1[32], s2[32];
        int n1, n2;
        int i;
        int digit;
        int ten;

        scanf("%s %s", s1, s2);
        n1 = integer(s1);
        n2 = integer(s2);
        n1 += n2;
        for (digit = 0, ten = 1000; n1 > 0; ten /= 10, digit++){
            switch (n1 / ten){
                case 0: break;
                case 1:
                    putchar(mcxi[digit]);
                    n1 -= ten;
                    break;
                default:
                    putchar(n1 / ten + '0');
                    putchar(mcxi[digit]);
                    n1 -= (n1 / ten) * ten;
                    break;
            }
        }
        puts("");
    }

    return 0;
}

Measured memory_bytes: 588
#include"bits/stdc++.h"


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 1010;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,m;

ll K;

char st[maxn][maxn];

int A[maxn][maxn];

struct Mat{
	int a[3][3];
}Ans,M;

Mat mul(Mat a,Mat b){
	Mat c;memset(c.a,0,sizeof(c.a));
	REP(i,1,2)REP(j,1,2)REP(k,1,2)c.a[i][j]=(1ll*a.a[i][k]*b.a[k][j]+c.a[i][j])%mod;
	return c;
}

int solve(int r,int c,int t){
	int V=fexp(t,K-1);
	int E=0;
	if(r)REP(i,1,n)REP(j,1,m-1)E+=A[i][j]&A[i][j+1];
	else REP(i,1,n-1)REP(j,1,m)E+=A[i][j]&A[i+1][j];
	Ans.a[1][1]=Ans.a[2][2]=1;
	M.a[1][1]=r+c;M.a[2][1]=E;M.a[2][2]=t;
	K-=2;
	for(;K;K>>=1,M=mul(M,M))if(K&1)Ans=mul(Ans,M);
	E=(1ll*E*Ans.a[1][1]+1ll*t*Ans.a[2][1])%mod;
	return (V-E+mod)%mod;
}

void Work(){
	if(K==1){puts("1");return;}
	int r=0,c=0;
	REP(i,1,n)r+=A[i][1]&&A[i][m];
	REP(i,1,m)c+=A[1][i]&&A[n][i];
	if(r&&c){puts("1");return;}
	int t=0;
	REP(i,1,n)REP(j,1,m)t+=A[i][j];
	if(!r&&!c){printf("%d\n",fexp(t,K-1));return;}
	printf("%d\n",solve(r,c,t));
}

void Init(){
	read(n,m,K);
	REP(i,1,n)scanf("%s",st[i]+1);
	REP(i,1,n)REP(j,1,m)A[i][j]=st[i][j]=='#';
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define ins insert
#define pii pair<int,int>
#define fs first
#define sc second
#define mpr make_pair
#define iter iterator
#define all(X) X.begin(),X.end()
#define sau(X) sort(all(X)),X.resize(unique(all(X))-X.begin())
#define exist(X,ele) binary_search(all(X),ele)
 
template<typename T1,typename T2>
ostream& operator << (ostream& out,const pair<T1,T2>& X)
{
	out<<"{"<<X.fs<<","<<X.sc<<"}";
	return out;
}
 
template<typename T>
ostream& operator << (ostream& out,const vector<T>& X)
{
	for(auto i:X) out<<i<<" ";
	return out;
}
 
inline void cmin(int& x,int y)
{
	x=min(x,y);
}
 
inline void cmax(int& x,int y)
{
	x=max(x,y);
}
 
const int inf=5000000000000000ll;
 
int N;
int a[20][2];
 
int ans=inf;
bool used[20];
 
void go(int pos,int lst,int cost)
{
	if(pos==N)
	{
		cmin(ans,cost);
		return;
	}
	if(cost>=ans) return;
	int ncost=0;
	for(int i=0;i<N;i++)
	{
		if(!used[i])
		{
			int& cur=a[i][abs(pos-i)%2];
			if(lst<=cur)
			{
				int cnt=0;
				for(int j=0;j<N;j++)
				{
					if(i!=j && !used[j] && max(a[j][0],a[j][1])>=cur) cnt++;
				}
				if(cnt>=N-1-pos)
				{
					used[i]=true;
					go(pos+1,cur,cost+ncost);
					used[i]=false;					
				}
			}
			ncost++;
		}
	}
}
 
main()
{
	ios::sync_with_stdio(false);
	
	cin>>N;
	for(int i=0;i<N;i++)
		cin>>a[i][0];
	for(int i=0;i<N;i++)
		cin>>a[i][1];
	go(0,-1,0);
	if(ans==inf) ans=-1;
	cout<<ans<<endl;
	
	return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

using namespace std;

int main(){
  
  string s;
  int m,h;

  while(cin>>s,(s!="-")){
    cin>>m;
        
    for(int i=0;i<m; i++){
      cin>>h;

      for(int j=0;j<h; j++){	
	s.push_back(s[0]);
	s.erase(s.begin());
      }
    }

    cout <<s<<endl;

  }

  

  return 0;
}



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

typedef pair<int, int> P;
const int MAX_SIZE = 50;
const int MAX_TASK_SIZE = 1000;

int R, C, M, a = 0;
int p[MAX_SIZE][MAX_SIZE] = {};
char f[MAX_SIZE][MAX_SIZE];
int costs[3][MAX_SIZE][MAX_SIZE];

int move(P src, P des, int t) {
  if (src == des) {
    return t;
  }
  f[src.first][src.second] = '@';
  int ret = 0;
  int dr[] = {-1, 1, 0, 0};
  int dc[] = {0, 0, -1, 1};
  for (int k = 0; k < 4; ++k) {
    int i = src.first  + dr[k];
    int j = src.second + dc[k];
    if (i + 1 && j + 1 && i < R && j < C && f[i][j] == '.') {
      ret = move(P(i, j), des, t + 1);
      if (ret) {
        int cost = costs[1][i][j] + costs[2][i][j];
        a += cost;
        if (p[i][j]) {
          int d = (t - p[i][j]) * costs[0][i][j] - cost;
          if (d < 0) a += d;
        }
        p[i][j] = t;
        break;
      }
    }
  }
  f[src.first][src.second] = '.';
  return ret;
}

int calc(P tasks[]) {
  int t = 1;
  int i0 = tasks[0].first, j0 = tasks[0].second;
  a = costs[1][i0][j0] + costs[2][i0][j0];
  p[i0][j0] = t++;
  for (int i = 0; i < M - 1; ++i) {
    t = move(tasks[i], tasks[i + 1], t);
  }
  return a;
}

int main() {
  int n;
  P tasks[MAX_TASK_SIZE];
  char s[MAX_SIZE + 1];
  cin >> R >> C >> M;
  for (int i = 0; i < R; ++i) {
    cin >> s;
    for (int j = 0; j < C; ++j) {
      f[i][j] = s[j];
    }
  }
  for (int k = 0; k < 3; ++k) {
    for (int i = 0; i < R; ++i) {
      for (int j = 0; j < C; ++j) {
        cin >> n;
        costs[k][i][j] = n;
      }
    }
  }
  for (int i = 0; i < M; ++i) {
    int r, c;
    cin >> r >> c;
    tasks[i] = P(r, c);
  }
  cout << calc(tasks) << endl;
}

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pi;
typedef long long i64;

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

  int a, b, c;
  cin >> a >> b >> c;
  int ans = max({a * 10 + b + c, b * 10 + a + c, c * 10 + a + b});
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include<iomanip>

using namespace std;

long double facctorialMethod(int k){
    long double sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    vector<vector<int>> p(n, vector<int>(2));
    for(int i = 0; i < n; i++){
        v.at(i) = i;
        cin >> p.at(i).at(0) >> p.at(i).at(1);
    }

    long double sum = 0;
    long double a;
    do {
        // cout << v.at(0) << v.at(1) << v.at(2) << endl;
        for(int i = 0; i < n-1; i++){
            a = sqrt(pow(p.at(v.at(i+1)).at(0) - p.at(v.at(i)).at(0),2) + pow(p.at(v.at(i+1)).at(1) - p.at(v.at(i)).at(1),2));
            
            // cout << p.at(i+1).at(0) << "-" << p.at(i).at(0) << endl;
            // cout << p.at(i+1).at(1) << "-" << p.at(i).at(1) << endl;
            // cout << a << endl;
            sum += a;
        }
        // cout << endl;
    } while( next_permutation(v.begin(), v.end()) );
    
    cout << fixed << setprecision(10) << sum/facctorialMethod(n) << endl;
}

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

const int SIZE = 100;

int main()
{
	int costs[ SIZE ][ SIZE ];
	int n;

	while( cin >> n ){
		for( int i = 0; i < n; ++i ){
			for( int j = 0; j < n; ++j ){
				costs[ i ][ j ] = 0x7fffffff;
			}
		}
		for( int i = 0; i < n; ++i ){
			costs[ i ][ i ] = 0;
		}
		vector< pair< int, int > > decks;
		for( int i = 0; i < n; ++i ){
			int f, b;
			cin >> f >> b;
			decks.push_back( make_pair( f, b ) );
		}
		/*
		for( int s = 0; s < n - 1; ++s ){
			int e = s + 1;
			costs[ s ][ e ] = decks[ s ].first * decks[ s ].second * decks[ e ].first * decks[ e ].second;
		}
		*/
		for( int span = 1; span < n; ++span ){
			for( int s = 0; s < n - span; ++s ){
				int e = s + span;
				for( int k = s; k < e; ++k ){
					costs[ s ][ e ] = min( costs[ s ][ e ], costs[ s ][ k ] + costs[ k + 1 ][ e ] + decks[ s ].first * decks[ k ].second * decks[ k + 1 ].first * decks[ e ].second );
				}
			}
		}
		cout << costs[ 0 ][ n - 1 ] << endl;
	}

	return 0;
}

Measured memory_bytes: 1228
// finish date: 2018/04/10

#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define bigmod 1000000007
#define INF 1050000000
#define pii pair<int,int>


int main() {
    int N;
    cin >> N;
    vi A(N), B(N);
    ll sum = 0;
    rep(i, N) {
        cin >> A[i] >> B[i];
        sum += A[i];
    }
    int mi = INF;
    rep(i, N) {
        if (A[i] > B[i]) {
            mi = min(mi, B[i]);
        }
    }
    if (mi == INF) cout << 0 << endl;
    else cout << sum - mi << endl;


    return 0;
}

Measured memory_bytes: 384
N = int(input())
A = list(map(int,input().split()))

A.sort()

def judge(i,A):
    size = A[i]
    flag = True
    for j in range(N):
        if j!=i:
            if 2*size >= A[j]:
                size+=A[j]
            else:
                flag=False
                break
    return flag

def bisect(s,t,A):
    if t-s==1:
        return t
    else:
        i = (s+t)//2
        if judge(i,A):
            return bisect(s,i,A)
        else:
            return bisect(i,t,A)

if judge(0,A):
    print(N)
else:
    print(N-bisect(0,N,A))


Measured memory_bytes: 14224
n = input()
a = list(map(int, input().split()))
count = 0
while 1:
  if [int(i/2) for i in a] == [round(i/2, 1) for i in a]:
    count+=1
    a = [int(i/2) for i in a]
  else:
    print(count)
    break

Measured memory_bytes: 3060
N = int(input())
candies_i = list(map(int, input().split()))
candies_j = list(map(int, input().split()))

l = []

for i in range(N):
    total_li = sum(candies_i[:i+1])
    total_lj = sum(candies_j[i:])
    total = total_li + total_lj
    l.append(total)

print(max(l))


Measured memory_bytes: 9116
import itertools

N = int(input())
# for i in range(N):
#     sum = 0
#     ans = 0
#     for j in itertools.permutations(range(i)):
#         for t, k in enumerate(j):
#             sum += (t+1)%(k+1)
#         ans = max(ans, sum)
#         sum=0
#     print(i, ans)

print((N)*(N-1)//2)

Measured memory_bytes: 38256
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

vector<int> c, ans;

const int MAX = 1e4;
vector<int> G[MAX];
int t = 0;

void dfs(int v, int p = -1) {
  ans[v] = c[t++];
  for (int u: G[v]) {
    if (u == p) continue;
    dfs(u, v);
  }
}

int main() {
  int n;
  cin >> n;
  rep(i, n - 1) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  c.resize(n);
  rep(i, n) cin >> c[i];
  
  sort(c.begin(), c.end(), greater<int>());
  int score = accumulate(c.begin(), c.end(), 0) - c[0];
  ans.resize(n);
  dfs(0);
  cout << score << endl;
  rep(i, n) cout << ans[i] << (i == n - 1 ? '\n' : ' ');



  
  return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

typedef vector<vector<pair<double,int>>> wgraph;
typedef pair<double,int> pli;

vector<double> bfs(wgraph v,int x){
  priority_queue<pli,vector<pli>,greater<pli>> q;
  vector<double> dist(v.size(),1e18);
  dist[x]=0;
  q.push({0LL,x});

  while(q.size()){
    pli p=q.top(); q.pop();
    double d=p.F;int now=p.S;
    if(dist[now]<d){ continue; }
    for(auto to:v[now]){
      if(dist[to.S]>d+to.F){
        dist[to.S] = d+to.F;
        q.push({dist[to.S], to.S});
      }
    }
  }
  return dist;
}


int main(){
  vector<int> x(1010,0),y(1010,0),r(1010,0);
  rep(i,2){
    cin >> x[i] >> y[i];
  }
  int n;
  cin >> n;
  n+=2;
  REP(i,2,n){
    cin >> x[i] >> y[i] >> r[i];
  }
  wgraph v(n);
  rep(i,n)rep(j,n)if(i!=j){
//    double z = sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]))-r[i]-r[j];
    double z = hypot(x[i]-x[j],y[i]-y[j])-r[i]-r[j];
    z = max(z,0.0);
    v[i].emplace_back(z,j);
//    v[j].emplace_back(z,i);
  }
  vector<double> dist=bfs(v,0);
  double ans = dist[1];
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 37872
use std::vec::Vec;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let n: usize = read();
    let h: Vec<usize> = read_vec();

    let mut wi = 0;
    let mut ans = 0;
    for i in 0..n-1 {
      let now = h[i];
      let right = h[i+1];
      if now >= right {
        wi += 1;
      } else {
        ans = max(ans, wi);
        wi = 0;
      }
    }
    ans = max(ans, wi);
    println!("{}", ans);
}


Measured memory_bytes: 8444
#include <stdio.h>

int main(void)
{
	
	int h, w, x, y;
	
	while ((h != 0)||(w != 0)){
		
		scanf("%d %d", &h, &w);
		
		if ((h != 0)||(w != 0)){
			
			for (x = 0; x < h; ++x){
				
				for (y = 0; y < w; ++y){
					
					if ((x % 2) == 1){
						
						if ((y % 2) == 1){
							printf("#");
						}
						else {
							printf(".");
						}
						
					}
					
					else {
						if ((y % 2) == 1){
							printf(".");
						}
						else {
							printf("#");
						}
					}
					
						
						
				}
				
				printf("\n");
				
			}
			
			printf("\n");
			
		}
		
	
	}
	
	return 0;
}

Measured memory_bytes: 1824
#include<bits/stdc++.h>
using namespace std;
const int nax = 1e5 + 5;
vector<int> edges[nax];
int in_degree[nax]; // the number of edges going to 'b'
int dist[nax];
bool visited[nax];

void dfs(int a) {
    assert(!visited[a]);
    visited[a] = true;
    for(int b : edges[a]) {
        dist[b] = max(dist[b], dist[a] + 1);
        --in_degree[b];
        if(in_degree[b] == 0) {
            dfs(b);
        }
    }
}

int main() {
    int n, m;
    scanf("%d%d", &n, &m);
    while(m--) {
        int a, b;
        scanf("%d%d", &a, &b);
        edges[a].push_back(b);
        ++in_degree[b];
    }
    for(int i = 1; i <= n; ++i) {
        if(!visited[i] && in_degree[i] == 0) {
            dfs(i);
        }
    }
    int answer = 0;
    for(int i = 1; i <= n; ++i) {
        answer = max(answer, dist[i]);
    }
    printf("%d\n", answer);
}

Measured memory_bytes: 14668
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);

void main()
{

    auto n = lread();
    auto a = aryread();
    auto ans = new long[](n + 1);
    foreach (i; 0 .. n)
    {
        ans[a[i]] = i + 1;
    }
    // writeln(ans);
    foreach (i; 1 .. (ans.length))
    {
        write(ans[i], ' ');
    }
}
//https://rclone.org/

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}


Measured memory_bytes: 7508
#include <stdio.h>

int main(void)
{
	int i=0,j=0;
	
	for(i=1;i<10;i++)
	{
		for(j=1;j<10;j++)
		{
			printf("%dx%d=%d\n",i,j,i*j);
		}
	}
	return 0;
}

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

using namespace std;
int main() {
  int n, l;
  cin >> n >> l;
  int orgTotal = 0;
  int eat = 0;
  int diff = 9999;
  for (int i = 0; i < n; i++) {
    int apple = l + i;
    orgTotal += apple;
    diff = min(diff, abs(apple));
    if (diff == abs(apple)) eat = apple;
  }
  cout << orgTotal - eat << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define SIZE 400
#define NUM 501

const int Mod = 998244353;

int main()
{
	int i, N, Q;
	char S[200001];
	scanf("%d %d", &N, &Q);
	
	char block[NUM];
	int j, k, l, r, d, q, n = (N - 1) / SIZE, m = N - n * SIZE, flag[NUM];
	long long ans, ans_block[NUM] = {}, fill_block[10], pow[200001];
	for (i = 1, pow[0] = 1; i < N; i++) pow[i] = pow[i-1] * 10 % Mod;
	for (i = 1; i <= 9; i++) {
		for (j = 1, fill_block[i] = i; j < SIZE; j++) fill_block[i] = (fill_block[i] * 10 + i) % Mod;
	}
	for (i = 0; i <= n; i++) {
		block[i] = 1;
		flag[i] = 1;
		if (i < n) ans_block[i] = fill_block[1] * pow[m+(n-i-1)*SIZE] % Mod;
		if (i == n) for (j = 0, ans_block[i] = 0; i * SIZE + j < N; j++) ans_block[i] = (ans_block[i] * 10 + 1) % Mod;
	}
	
	for (q = 1; q <= Q; q++) {
		scanf("%d %d %d", &l, &r, &d);
		l--;
		r--;
		i = l / SIZE;
		if (flag[i] == 1) {
			for (j = i * SIZE; j < N && j < (i + 1) * SIZE; j++) S[j] = block[i];
			flag[i] = 0;
		}
		for (j = l, i = j / SIZE; j <= r && j < (i + 1) * SIZE; j++) {
			ans_block[i] = (ans_block[i] + pow[N-j-1] * (Mod - S[j]) % Mod + pow[N-j-1] * d) % Mod;
			S[j] = d;
		}
		if (j <= r) {
			for (i++; i < r / SIZE; i++) {
				flag[i] = 1;
				block[i] = d;
				ans_block[i] = fill_block[d] * pow[m+(n-i-1)*SIZE] % Mod;
			}
			if (flag[i] == 1) {
				for (j = i * SIZE; j < N && j < (i + 1) * SIZE; j++) S[j] = block[i];
				flag[i] = 0;
			}
			for (j = i * SIZE; j <= r; j++) {
				ans_block[i] = (ans_block[i] + pow[N-j-1] * (Mod - S[j]) % Mod + pow[N-j-1] * d) % Mod;
				S[j] = d;
			}
		}
		
		for (i = 0, ans = 0; i < n; i++) ans += ans_block[i];
		ans = (ans + ans_block[n]) % Mod;
		printf("%lld\n", ans);
	}
	fflush(stdout);
	return 0;
}

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

using namespace std;

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

	vector<int> arr(N);
	for (auto &a: arr) {
		cin >> a;
	}

	int swaps = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = N-1; j >= i+1; --j) {
			if (arr[j] < arr[j-1]) {
				swap(arr[j], arr[j-1]);
				++swaps;
			}
		}
	}

	cout << arr[0];
	for (int i = 1; i < N; ++i) {
		cout << ' ' << arr[i];
	}
	cout << '\n';

	cout << swaps << endl;
}


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

#define sz(x) (int)(x.size())
#define FOR(x,y,z) for(int x = y; x <= z; x++)
#define int long long

const int N = 1e5 + 2, inf = 1e18;

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);  

    int n, k;
    cin >> n >> k;
    int odd = n/2 + (n&1);
    cout << (odd >= k ? "YES" : "NO" );
}


Measured memory_bytes: 256
///not today

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

#define SZ(x) (int)(x).size()
#define pb push_back
#define ll long long
#define xmax(x, y) (x) = max((x), (y))
#define xmin(x, y) (x) = min((x), (y))
#define F first
#define S second
#define pii pair<int, int>
#define pll pair<long long, long long>
//#define int long long
#define pipii pair<int, pair<int, int> >
#define pf push_front

int32_t main(){
    int a, b;
    cin >>a >>b;
    if(a == 1 or a == 3 or a == 5 or a == 7 or a == 8 or a == 10 or a == 12){
        cout << (b == 31);
    }
    else if(a == 2){
        cout << (b == 28);
    }
    else{
        cout << (b == 30);
    }
}


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

using namespace std;

int main() {
  int h, w;
  cin >> h >> w;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      string s;
      cin >> s;
      if (s == "snuke") {
        cout << (char) ('A' + j) << (i + 1) << endl;
        return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;

/* --------------------------------------------------- */

const int MOD = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

const int MAX = 1000010;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(int n, int k) {
    if(n < k) return 0;
    if(n < 0 || k < 0 ) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
    int x, y;
    cin >> x >> y;

    if((2 * y - x) % 3 != 0 || (2 * x - y) % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    ll a = (2 * y - x) / 3 , b = (2 * x - y) / 3;
    ll n = a + b;
    COMinit();
    mint ans = COM(n, a);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 27064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String strIn = br.readLine();
		Integer count = 0;
		for (int i = Integer.parseInt(strIn.split(" ")[0]); i <= Integer.parseInt(strIn.split(" ")[1]); i++) {
			if ((Integer.parseInt(strIn.split(" ")[2]) % i) == 0) {
				count++;
			}
		}
		System.out.println(count);
	}

}

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

int main() {
	int N, count;
	cin >> N;
	count = N;
	vector<int> vec (N);
	for(int i = 0;i < N;i++){
		cin >> vec.at(i);
	}
	sort(vec.begin(),vec.end());
	for(int i = 1;i < N;i++){
		if(vec.at(i-1) == vec.at(i)){
			count--;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define   nl   <<'\n'
#define   ll   long long
#define   pb   push_back
#define   eb   emplace_back
#define   tc   int t; cin>>t; while(t--)
#define   fio  ios_base::sync_with_stdio(0); cin.tie(0)


int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*c,max(a*d,max(b*c,b*d))) nl;
}   

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; ++i)
typedef long long ll;
using namespace std;
const int INF = 1e9;

int main() {
    int n, q;
    cin >> n;
    ll sum = 0;
    vector<ll> a(n);
    map<ll, ll> mp;
    rep(i, n) {
        cin >> a[i];
        mp[a[i]]++;
        sum += a[i];
    }

    cin >> q;
    while (q--) {
        ll b, c;
        cin >> b >> c;

        sum -= b * mp[b];
        sum += c * mp[b];

        mp[c] += mp[b];
        mp[b] = 0;

        cout << sum << "\n";
    }

    return 0;
}

Measured memory_bytes: 10120
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ck(i, j) ((i) >= 0 && (i) < (j))
using namespace std;
char tile[21][21];
int  w, h, dy[] = {-1,0,1,0}, dx[] = {0,-1,0,1};

int dfs(int y, int x){
  tile[y][x] = '#';
  int res = 1;
  rep(i, 4){
    int ny = y+dy[i], nx = x+dx[i];
    if(ck(ny, h) && ck(nx, w) && tile[ny][nx] == '.')
      res += dfs(ny, nx);
  }

  return res; 
}

int main(){
  while(scanf("%d%d", &w, &h) && w && h){
    rep(i, h)  scanf("%s", tile[i]);
    rep(i, h) rep(j, w)
      if(tile[i][j] == '@') printf("%d\n", dfs(i, j));
  } 
  return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
const int mx = 1005;
const int inf = 3000;
char a[mx][mx];
int n, m, up[mx][mx], ans = 0;

int main(){
    cin.tie(0);    
	ios::sync_with_stdio(false);
    cin >> n >> m;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
            cin >> a[i][j];
        }
    }
    for(int i = 0; i < 1003; i++) {
        up[0][i] = up[i][0] = up[n+1][i] = up[i][m+1] = 3000;
    }
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= m; j++){
        up[i][j] = a[i][j] == '#' ? 0 : min(up[i-1][j], up[i][j-1]) + 1;
        }
    }
    for(int i = n; i > 0; i--) {
        for(int j = m; j > 0; j--){
        up[i][j] = min(up[i][j], min(up[i+1][j], up[i][j+1]) + 1);
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= m; j++){
         ans = max(ans, up[i][j]);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 5248
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const int MOD = 1e9 +7;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,p[200010],f[200010]={};
    cin>>n;
    rep(i,n){
        cin>>p[i];
        f[p[i]]=f[p[i]-1]+1;
    }
    ll ans=0;
    rep(i,n+1) ans=max(ans,f[i]);
    cout<<n-ans<<endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  // ここにプログラムを追記
 int a, b, c, d;
 cin >> a;
 c = a / 100;
 b = a / 10 - c * 10;
 d = a - c * 100 - b * 10;
 cout << d + b + c << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,d,e,f;
    double ans=0;
    int answa,anssu;
    cin>>a>>b>>c>>d>>e>>f;
    for(int i=0;i*a*100<=f;i++){
        for(int j=0;j*b*100<=f-100*a*i;j++){
            if(i==0 && j==0)continue;
            int wa=i*a*100+j*b*100;
            for(int k=0;k*c+wa<=f;k++){
                for(int kk=0;kk*d+wa+k*c<=f;kk++){
                    if(k*c+kk*d>wa*e/100)continue;
                    double no=100*(double)(k*c+kk*d)/(double)wa;
                    if(no>=ans){
                        answa=wa+kk*d+k*c;
                        anssu=kk*d+k*c;
                        ans=no;
                    }
                }
            }
        }
    }
    cout<<answa<<" "<<anssu<<endl;
}


Measured memory_bytes: 256
import sys

n, k = map(int, sys.stdin.readline().split())

def main():
    res = 0
    c = n // k
    res += c ** 3
    if k & 1:
        return res
    if n - k * c < k // 2:
        return res * 2
    else:
        return res + (c + 1) ** 3

if __name__ == '__main__':
    ans = main()
    print(ans)

Measured memory_bytes: 3060
s = input()
cnt = 0
for i in range(len(s)):
    if i%2 == 0:
        if s[i] == "L":
            cnt += 1
    if i%2 == 1:
        if s[i] == "R":
            cnt += 1
if (cnt == 0):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define MAX 100000
int main()
{
	int a;

	cin >> a;

	if (a / 10 == 9 || a % 10 == 9) {
		cout << "Yes";

	}
	else {
		cout << "No";
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;
const ll mod = 1e9+7;
#define rep(i,a,b) for(ll i=a;i<b;i++)

void swap(ll &a , ll &b){
    ll t = a;
    a = b;
    b = t;
}

ll min(ll a, ll b){
    if(a<b)return a;
    return b;
}

ll max(ll a, ll b){
    if(a>b)return a;
    return b;
}

 ll pow(ll a, ll b) {
    a %= mod;
    ll ans = 1;
    while (b > 0) {
        if (b & 1)
            ans = ans * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return ans;
}


int main(){


   ios_base :: sync_with_stdio(0);
   cin.tie(0);
   ll n;
   cin>>n;
   double a[n+1];
   rep(i , 1 ,n+1){
    cin>>a[i];
   }
   double dp[n+1][n+1];
    memset(dp ,0.0 , sizeof(dp));
   dp[0][0] = 1.0;

   for(int i = 1;i<=n;i++){
    dp[i][0] = dp[i-1][0]*(1-a[i]);
   }


   for(int i = 1;i<=n;i++){
    for(int h = 1; h<=i;h++){
            dp[i][h] = dp[i-1][h-1]*a[i]+dp[i-1][h]*(1-a[i]);
    }
   }
    double ans = 0;

    for(int i =0;i<=n;i++ ){
        ll tails = n-i;
        if(i>tails){
            ans += dp[n][i];
        }
    }
    cout<<setprecision(10)<< fixed <<ans ;





}


Measured memory_bytes: 70656
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    int i,N;
    char S[105];
    char T[105];
    scanf("%d",&N);
    scanf("%s%s",S,T);
    for(i=0;i<N;i++)
    {
        printf("%c",S[i]);
         printf("%c",T[i]);
    }
    return 0;
}


Measured memory_bytes: 128
import io.StdIn._
import math._

object Main extends App {
  val n = readInt()
  val hs = readLine() split(' ') map(_.toLong)

  val dp = new Array[Long](n)
  dp(0) = 0
  dp(1) = abs(hs(0) - hs(1))

  for (i <- 2 until n) {
    dp(i) = min(abs(hs(i)-hs(i-1))+dp(i-1), abs(hs(i)-hs(i-2))+dp(i-2))
  }

  println(dp.last)
}

Measured memory_bytes: 62616
/**
  @file b.cpp
  @title B - Foods Loved by Everyone
  @url https://atcoder.jp/contests/abc118/tasks/abc118_b
**/

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

typedef long long LL;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, N) for (int i = 0; i < (N); ++i)

int main() {
  int N, M;
  cin >> N >> M;

  map<int, int> memo;
  for (int i = 1; i <= M; i++) {
    memo.emplace(i, 0);
  }

  int tmpK, tmpA;
  for (int i = 0; i < N; i++) {
    cin >> tmpK;
    for (int j = 0; j < tmpK; j++) {
      cin >> tmpA;
      memo[tmpA]++;
    }
  }

  int ans = 0;
  for (int i = 1; i <= M; i++) {
    if (memo[i] == N) {
      ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


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

int main()
{
	int *pa;
	int n;

	cin >> n;

	pa = new int[n];

	for (int i = 0; i < n; i++){

		cin >> pa[i];
	}

	cout << pa[n - 1];

	for (int j = 1; j <= n-1; j++){
		
		cout << " " << pa[n - 1 - j];
	}

	cout << endl;

	delete[] pa;

	return 0;

}

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

int main(){
 int m,n,a,sum=0,count=0;
 cin>>n>>m;
 vector<int>store;
 for(int i=1;i<=n;i++){
    cin>>a;
    store.push_back(a);
    sum+=a;
 }
 for(int i=0;i<n;i++){
    if((store[i]/(sum*1.0))>=((1.0/(4.0*m))))count+=1;
 }
 if(count<m) cout<<"No";
 else cout<<"Yes";
 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define loop(i ,a,b) for(int i = a;i<b;i++)
#define rloop(i,a,b) for(int i = a ; i>b;i--)
#define loopll(i,a,b) for( long long int i = a; i<b;i++)
#define rloopll(i,a,b) for(long long int i = a; i>b;i--)
#define eb emplace_back
#define pii pair<int ,int>
#define pll pair<ll ,ll>
#define f first
#define mk make_pair
#define intmin INT_MIN
#define intmax INT_MAX
#define cout(x) cout<<x<<" ";
using namespace std;
void vec(vector<int> & v){

    for(int i = 0;i<v.size() ; i++){
        cout<<v[i]<< " ";
    }
    cout<<endl;
}
void vec_ll(vector<long long int> & v){

    for(int i = 0;i<v.size() ; i++){
        cout<<v[i]<< " ";
    }
    cout<<endl;
}
int parsestring(string temp){
    int num= 0;
    int digs = temp.size() - 1;
    for(int i = 0 ;i<=digs;i++){
        num += pow(10 , digs -i)*(temp[i] - '0');
    }
    return num;
}
bool prime(ll n) {
if (n < 2) return false;
for (ll x = 2; x*x <= n; x++) {
if (n%x == 0) return false;
}
return true;
}

string ter(ll n){
    string t ="";
        while(n>0){
            t += to_string(n%3);
            n /=3;
        }
        return t;
}
ll power(int base ,int exp , int mod){
    ll ans = 1;
    for(int i = 1;i<=exp ; i++){
        ans = ((ans%mod)*(base%mod))%mod;
    }
    return ans%mod;
}
int sumdig(ll num){
    int sum = 0;
    string s = to_string(num);
    loop( i , 0 , s.size()){
        sum += s[i]-'0';
    }
    return sum;
}

vector<vector<int>> adj(2e5 + 100 , vector<int>());
vector<bool> vis(2e5  +100 , false);
int mod = 1e9 + 7;
int dfs(int x){
    int ans = 0;
    stack<int> s;
    s.push(x);
    while(s.size()){
        int t = s.top();
        s.pop();
        vis[t] = true;
        ans++;
        for(int i = 0;i<adj[t].size() ;i++){
            if(!vis[adj[t][i]]){
                s.push(adj[t][i]);
            }
        }
    }
    return ans;
}
int bin(vector<int> &v , int l , int r , int key){
    while(r - l > 1){
        int m = (l+r)/2;
        if(v[m] <=key){
            l= m;
        }
        else{
            r = m;
        }
    }
    return r;
}
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    int ans = 0;
    for(int i = 0;i<n;i++){
        cin>>a[i];
        if(i%2 == 0 && a[i]%2 == 1){ans++;}
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 7848
#include<stdio.h>
int main(void) {
    int n,d,x[10][10],i,j,k,dist,ans = 0, tmp;
    scanf("%d%d",&n,&d);
    for(i = 0; i < n; i++) {
        for(j = 0; j < d; j++) {
            scanf("%d",&tmp);
            x[i][j] = tmp;
        }
    }
    for(i = 0; i < n-1; i++) {
        for(j = i+1; j < n; j++) {
            dist = 0;
            for(k = 0; k < d; k++) {
                dist += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            for(k = 0; k < dist; k++) {
                if(k*k == dist) {
                    ans ++;
                }
            }
            if(dist == 1) {ans ++;}
            
        }
    }
    printf("%d\n",ans);
    return 0;
}

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

using namespace std;

int main()
{
    int x, y;
    cin>>x>>y;
    if(x>8 || y>8)
    {
        cout<<":("<<endl;
    }
    else
    {
         cout<<"Yay!"<<endl;
    }
    return 0;
}


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

signed main(){
	int N, i, ans = 1;
	scanf("%lld", &N);
	vector<int> A(N);
	for(i = 0; i < N; i++){
		scanf("%lld", &A[i]);
		if(A[i] == 0){
			printf("0\n");
			return 0;
		}
	}
	for(i = 0; i < N; i++){
		if(ans > (int)(1e18) / A[i]){
			printf("-1\n");
			return 0;
		}
		ans *= A[i];
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3988