akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

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

    string s;
    cin >> s;

    int ans = 0;
    int l = 0, r = s.size() - 1;
    while(l < r){
        if(s[l] != s[r]){
            if(s[l] == 'x') l++;
            else if(s[r] == 'x') r--;
            else{
                cout << "-1" << endl;
                return 0;
            }
            ans++;
        }else{
            l++, r--;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
//abc131_c.cpp
//Sun Sep 15 10:14:58 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

ll gcd (ll a, ll b){ //最大公約数
	if (b == 0){
		return a;
	}
	return gcd(b, a%b);
}

ll lcm (ll a, ll b){ //最小公倍数
	ll temp = gcd(a,b);
	return (a/temp)*b;
}

int main(){
	ll a,b,c,d;
	cin >> a >> b >> c >> d;

	ll cd = lcm(c,d);

	ll x = (a-1)/c;
	ll y = (a-1)/d;
	ll xy = (a-1)/cd;

	ll xx = b/c;
	ll yy = b/d;
	ll xxyy = b/cd;

	cout << b-xx-yy+xxyy-(a-1-x-y+xy)<< endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
N = int(input())
tests = [[] for _ in range(N)]
ans = 0

for i in range(N):
    for _ in range(int(input())):
        x, y = map(int, input().split())
        tests[i].append((x-1, y))
        
for i in range(1<<N):
    FLG = True
    count = bin(i).count("1")
    for j in range(N):
        if i>>j & 1:
            for test in tests[j]:
                if int(bin(i>>test[0])[-1]) != test[1]:
                    FLG = False
                    break
            if not FLG:
                break
    if FLG:
        ans = max(ans, count)

print(ans)

Measured memory_bytes: 3064
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
	a.append(a[i] + A[i])
for i in range(M):
	b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
	if a[i] > K:
		break
	while b[j] > K - a[i]:
		j -= 1
	ans = max(ans, i + j)
print(ans)



Measured memory_bytes: 47544
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

int main() {
ll n;
cin>>n;
ll a[n]={};
ll b[n]={};
deque<ll> d;
ll aa;
for(ll i=0; i<n; i++){
cin>>a[i];}
ll counter=1000000;
for(ll i=0; i<n; i++){
if(i%2==0){
d.push_back(a[i]);}
else
d.push_front(a[i]);}
if(n%2==0){
while(!d.empty()){
aa=d.front();
d.pop_front();
cout<<aa<<" ";}}
else{
while(!d.empty()){
aa=d.back();
d.pop_back();
cout<<aa<<" ";}}}


Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define int long long
int n=1;
P dat[444444];
void init(int x){
	while(n<x)n*=2;
}
void eval(int k,int l,int r){
	dat[k].first+=dat[k].second;
	if(r-l>1){
		dat[k*2+1].second+=dat[k].second/2;
		dat[k*2+2].second+=dat[k].second/2;
	}
	dat[k].second=0;
}
void update(int a,int b,int k,int x,int l,int r){
	eval(k,l,r);
	if(r<=a||b<=l)return;
	if(a<=l&&r<=b){
		dat[k].second+=(r-l)*x;
		eval(k,l,r);
	}
	else{
		update(a,b,k*2+1,x,l,(l+r)/2);
		update(a,b,k*2+2,x,(l+r)/2,r);
	}
}
int query_calc(int a,int k,int l,int r){
	eval(k,l,r);
	if(r-l==1)return dat[k].first;
	if(a<(l+r)/2)return query_calc(a,k*2+1,l,(l+r)/2);
	else return query_calc(a,k*2+2,(l+r)/2,r);
}
int query(int x){
	return query_calc(x,0,0,n);
}
signed main(){
	int N,q;
	cin>>N>>q;
	init(N);
	while(q--){
		int Q;
		cin>>Q;
		if(Q==0){
			int s,t,x;
			cin>>s>>t>>x;
			update(s-1,t,0,x,0,n);
		}
		else{
			int i;
			cin>>i;
			cout<<query(i-1)<<endl;
		}
	}
}
	



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

#define all(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;
const int INT_INF = 1e9;
const ll INF = 1LL << 30;

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

    ll sum = 0;
    for(int i = 0; i < n; i++){
        if(a[i] % 2 == 1) continue;
        while(a[i] % 2 != 1){
            sum++;
            a[i] /= 2;
        }
    }
    cout << sum << endl;
}



Measured memory_bytes: 384
#include<cstdio>
#include<algorithm>
using namespace std;
int w[2010], cnt, n, dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
long long Res[600][600];
long long gcd(long long a, long long b) {
	return b ? gcd(b, a%b) : a;
}
int main() {
	int i, j, pv = 0;
	for (i = 2;; i++) {
		for (j = 2; j*j <= i; j++) {
			if (i%j == 0)break;
		}
		if (j*j > i)w[++cnt] = i;
		if (cnt >= 2000)break;
	}
	scanf("%d", &n);
	for (i = 3; i <= n + n; i += 2) {
		pv++;
		for (j = 1; j <= n; j++) {
			int x = j, y = i - j;
			if (1 > y || y > n)continue;
			Res[x][y] = w[pv];
		}
	}
	for (i = n/2*2+2-1; i >= -n; i -= 2) {
		pv++;
		for (j = 1; j <= n; j++) {
			int x = j, y = i + j;
			if (1 > y || y > n)continue;
			Res[x][y] *= w[pv];
		}
	}
	long long Mx = -1e9;
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= n; j++) {
			if ((i + j) % 2 == 0) {
				long long r = 1;
				for (int k = 0; k < 4; k++) {
					int x = i + dx[k], y = j + dy[k];
					if (x<1 || x>n || y<1 || y>n)continue;
					r = r / gcd(r, Res[x][y])*Res[x][y];
				}
				Mx = max(Mx, r);
				Res[i][j] = r + 1;
			}
		}
	}
	if (n == 2) {
		puts("4 7");
		puts("23 10");
		return 0;
	}
	for (i = 1; i <= n; i++) {
		for (j = 1; j <= n; j++)printf("%lld ", Res[i][j]);
		puts("\n");
	}	
}

Measured memory_bytes: 5376
#include <iostream>
#include <complex>
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
  ld a, b, c;
  cin >> a >> b >> c;
  ld d = sqrt(a * b);
  if (a + b + 2 * d < c)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

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

int main()
{
    long long n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;

    long long mi = min(min(min(min(a, b), c), d), e);
    long long res = n / mi + (n % mi == 0 ? 0 : 1);
    res += 5;
    res--;
    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc163/tasks/abc163_f>
 問題文============================================================
 F - path pass i
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> c(N); for(auto& in:c){ cin >> in; in--;}
    
    vector<vector<ll>> G(N);
    for(int i = 0; i < N-1; i++){
        ll a,b; cin >> a >> b;
        a--; b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    
    vector<ll> num(N),S(N);
    vector<ll> ans(N,N*(N-1)/2);
    ll sum = 0;
    function<ll(ll,ll)> dfs = [&](ll v,ll p){
        S[v]=1;
        
        ll t = num[c[v]];
        for(auto next:G[v]){
            if(next == p) continue;
            ll prev = sum - num[c[v]];
            S[v] += dfs(next,v);
            ll nextv = sum - num[c[v]];
            ans[c[v]] -= (nextv - prev)*(nextv - prev - 1)/2;
        }
        num[c[v]] = t + S[v];
        sum++;
        return S[v];
    };
    dfs(0,-1);
    
    for(int i = 0; i < N;i++){
        ll prev = 0, nextv = N-num[i];
        ans[i] -= (nextv - prev)*(nextv - prev - 1)/2;
    }
    for(auto t:c) ans[t]++;
    
    for(auto a:ans) cout << a << endl;
    
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 45432
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define clr(a) memset(a, 0, sizeof(a))
#define sz(x) x.size()
#define rep(n) for (ll i = 0; i < n; i++)
#define repc(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, x, y) for (ll i = x; i < y; i++)
#define DEC(i, x, y) for (ll i = x; i >= y; i--)
#define all(v) v.begin(), v.end()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define alla(a, n) a, a + n
using namespace std;
 
// Some typedef's
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> ii;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<ii> vii;
 
template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}
 
ll lcm(ll a, ll b) { return (a * (b / __gcd(a, b))); }
 
// Some contants
const ll inf = 1e12 + 7;
const double eps = 1e-9;
const double pi = 1.00 * acos(-1.00);


ll n;
const int MAXN  = 1e5 + 5;
ll inp[MAXN] = {0};

void solve(){




} 
 
int main()
{
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);

    const ll lim = 1e18;
 
    cin >> n;
    ll pro = 1;
    repc(i,n){
        cin >> inp[i];
        if(inp[i]==0){
            cout << 0 << endl;
            return 0;
        }
    }
    repc(i, n){
        ll temp = pro*inp[i];
        if(pro > temp || temp > lim){
            cout << -1 << endl;
            return 0;
        }
        pro = temp;
    }
    cout << pro << endl;
    //solve();

 
    return 0;
 
 
}


Measured memory_bytes: 4432
#include<cstdio>
#include<cstring>
#include<algorithm>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const int INF=1<<29;

inline int popcount(int x){
	x=((x>>1)&0x55555555)+(x&0x55555555);
	x=((x>>2)&0x33333333)+(x&0x33333333);
	x=((x>>4)+x)&0x0f0f0f0f;
	x+=(x>>8);
	x+=(x>>16);
	return x&0x3f;
}

int main(){
	int h,w; scanf("%d%d",&h,&w);
	char s[128][17];
	int len[128];
	rep(i,h) scanf("%s",s[i]), len[i]=strlen(s[i]);

	static int pc[1<<16];
	rep(S,1<<w) pc[S]=popcount(S);

	static int dp[2][16][1<<16];
	rep(i,2) rep(j,w) rep(S,1<<w) dp[i][j][S]=-INF;
	dp[1][w-1][0]=0;
	rep(i,h){
		int y=i%2;
		rep(j,w){
			// i 行目の 0~j-1 列目に k 文字置いた
			for(int k=max(len[i]-(w-j),0);k<=min(len[i],j);k++){
				// j 個から k 個選ぶ組み合わせ
				for(int S1=(1<<k)-1,_,__;S1<(1<<j);_=S1&-S1,__=S1+_,S1=((S1&~__)/_>>1)|__){
					// i-1 行目の j~w-1 列目に l 文字置いた
					for(int l=max((i>0?len[i-1]:0)-j,0);l<=min(w-j,(i>0?len[i-1]:w));l++){
						// w-j 個から l 個選ぶ組み合わせ
						for(int S2=(1<<l)-1,_,__;S2<(1<<w-j);_=S2&-S2,__=S2+_,S2=((S2&~__)/_>>1)|__){
							int S=S1|S2<<j;

							if(j>0){
								// s[i][k] を置かない
								dp[y][j][S&~(1<<j)]=max(dp[y][j][S&~(1<<j)],dp[y][j-1][S]);
								// s[i][k] を置く
								int plus=0;
								if(k>0 && s[i][k-1]==s[i][k] && S&1<<j-1) plus++; // 左と隣接
								if(i>0 && s[i][k]==s[i-1][len[i-1]-pc[S2]] && S&1<<j) plus++; // 上と隣接
								dp[y][j][S|(1<<j)]=max(dp[y][j][S|(1<<j)],dp[y][j-1][S]+plus);
							}
							else{ // j==0
								// s[i][k] を置かない
								dp[y][j][S&~(1<<j)]=max(dp[y][j][S&~(1<<j)],dp[1-y][w-1][S]);
								// s[i][k] を置く
								int plus=0;
								if(i>0 && s[i][k]==s[i-1][len[i-1]-pc[S2]] && S&1<<j) plus++; // 上と隣接
								dp[y][j][S|(1<<j)]=max(dp[y][j][S|(1<<j)],dp[1-y][w-1][S]+plus);
							}

							if(S2==0) break;
						}
					}

					if(S1==0) break;
				}
			}
		}
	}

	int ans=0;
	rep(S,1<<w) ans=max(ans,2*dp[(h-1)%2][w-1][S]);
	printf("%d\n",ans);

	return 0;
}

Measured memory_bytes: 9476
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{
	vector<int> a ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k; cin >> k;
	k--;
	cout << a[k] << endl;
	return;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

sumB = sum(B)
bouns = 0
for i in range(len(A)-1):
    if A[i+1] - A[i] == 1:
       bouns += C[A[i]-1]
print(sumB + bouns)

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)

int ans = -inf;
int a[20];
int f[105][10];
int p[105][11];
int n;
void func() {
    
    rep(i, 20) {
        if (a[i] != 0) break;
        if (i == 19) return;
    }
    
    int score = 0;
    //rep(i, 10) cout << a[i] << " "; cout << endl;
    rep(i, 105) {
        int tmp = 0;
        rep(j, 10) if (a[j] == 1 && f[i][j] == 1) tmp++;
        score += p[i][tmp];
    }
    ans = max(ans, score);
}
void dfs(int pos) {
    if (pos == 10) {
        func();
        return;
    }
    a[pos] = 0; dfs(pos + 1);
    a[pos] = 1; dfs(pos + 1);
}
int main() {
    cin >> n;
    rep(i, n) rep(j, 10) cin >> f[i][j];
    rep(i, n) rep(j, 11) cin >> p[i][j];
    dfs(0);
    cout << ans << endl;
    
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
   
fn read<T: FromStr>() -> T {
	let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
	let a1: i32 = read();
	let a2: i32 = read();
	let a3: i32 = read();
	if a1 + a2 + a3 >= 22 {
		println!("bust");
	} else {
		println!("win");
	}
}

Measured memory_bytes: 4352
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


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

}
  
double sum = 0;
for(int i = 0;i<n;i++){
   
   if(b[i]=="JPY"){
     
       sum = sum+a[i];
     
   }else{
       sum = sum+a[i]*380000.0;
   }
  
   

}
  
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 256
dic = {}
for n in range(ord("a"), ord("z")+1):
    dic[chr(n)] = 0
s = input()
for l in s:
    dic[l] += 1

ans = "None"
for n in range(ord("a"), ord("z")+1):
    if dic[chr(n)] == 0:
        ans = chr(n)
        break
print(ans)


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

M = 0
for i in range(1, N + 1):
    if i * (i + 1) // 2 >= N:
        M = i
        break

ans = []
for i in reversed(range(1, M + 1)):
    if i <= N:
        ans.append(i)
        N -= i

for i in ans:
    print(i)

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


int main () {
    string S ;
    cin >> S ;
    set <char> Set ;
    for (char ch = 'a' ; ch <= 'z' ; ch++) {
        Set.insert(ch) ;
    }
    for (int i = 0 ; i < S.size() ; i++) {
        Set.erase(S[i]) ;
    }

    if (Set.size()) {
        S.push_back(*Set.begin()) ;
        cout << S ;
    }
    else {
        string tmp = S ;
        if (next_permutation(S.begin(),S.end())) {
            for (int i = 0 ; i < S.size() ; i++) {
                cout << S[i] ;
                if (S[i] > tmp[i]) return 0 ;
            }
        }
        else {
            cout << -1 ;
        }
    }
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main()
{
	long int n;
	cin>>n;
	long int i,j,p[n],x,s,t=n;
	for(i=0;i<n;i++)
	{
		cin>>p[i];
	}
	s=p[0];
	for(i=1;i<n;i++)
	{
		if(p[i]>s)
		{
			t--;
		}
		if(s>p[i])
		{
			s=p[i];
		}
	}
	cout<<t<<endl;
}

Measured memory_bytes: 5164
local r_eat, g_eat, r_num, g_num, a_num 
= io.read("*n", "*n", "*n", "*n", "*n")

function writeList(num)
    local list = {}
    for i = 1, num do
        list[i] = io.read("*n")
    end
    return list
end

local r_taste = writeList(r_num)
local g_taste = writeList(g_num)
local a_taste = writeList(a_num)

table.sort(r_taste, function(x, y) return x > y end)
table.sort(g_taste, function(x, y) return x > y end)
for i = 1, r_num - r_eat do
    r_taste[#r_taste] = nil
end
for i = 1, g_num - g_eat do
    g_taste[#g_taste] = nil
end

local all_taste = a_taste
for i = 1, #r_taste do
    all_taste[#all_taste + 1] = r_taste[i]
end
for i = 1, #g_taste do
    all_taste[#all_taste + 1] = g_taste[i]
end
table.sort(all_taste, function(x, y) return x > y end)

local result = 0LL
for i = 1, r_eat + g_eat do
    result = result + all_taste[i]
end
print(tostring(result):sub(1, -3))

Measured memory_bytes: 7424
s = gets.strip.split('')

s.each_with_index do |chr, i|
  if (i+1).odd?
    unless ['R','U','D'].include?(chr)
      puts 'No'
      exit
    end
  else
    unless ['L','U','D'].include?(chr)
      puts 'No'
      exit
    end
  end  
end

puts 'Yes'


Measured memory_bytes: 1788
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_MOD			1000000007								// 除数(10の9乗+7)

// 内部変数
static FILE *szpFpI;											// 入力

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// N, K - 取得
	int liN, liK;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d", &liN, &liK);

	// 和 - 取得
	long long llSum = 0;
	for (i = liK; i <= liN + 1; i++) {
		long long llMin = (long long)(i - 1) * (long long)i / 2;
		long long llMax = llMin + (long long)(liN - i + 1) * (long long)i;
		llSum += llMax - llMin + 1;
	}

	return (int)(llSum % D_MOD);
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int f(string s) {
    if (isdigit(s[0])) {
        return stoi(s) / 2 + 1;
    }
    vector<int> a;
    stack<char> st;
    int start = 0;
    for (int i = 0; i < (int)s.size(); i++) {
        if (s[i] == '[') {
            st.push('[');
        }
        else if (s[i] == ']') {
            st.pop();
        }
        if (st.empty()) {
            a.push_back(f(s.substr(start + 1, i - (start + 1))));
            start = i + 1;
        }
    }
    sort(all(a));
    int ret = 0;
    for (int i = 0; i < (int)a.size() / 2 + 1; i++) {
        ret += a[i];
    }
    return ret;
}

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    for (int i = 0; i < n; i++) {
        dump(f(s[i].substr(1, (int)s[i].size() - 2)));
    }
    return 0;
}



Measured memory_bytes: 3288
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
    main(chunk.trim());
});

function main(chunk){
    var lines = chunk.split("\n");
    for(var i=0;i<lines.length;i++){
        console.log(calc(Number(lines[i])));
    }
}
var arr = [2];
function calc(num){
    if(arr[arr.length-1] > num){
        for(var i=0;i<arr.length;i++){
            if(arr[i]>num){
                return i;
            }
        }
    }
    start:for(var i = arr[arr.length-1]+(arr[arr.length-1]%2==0?1:2); i<=num; i+=2){
       for(var j=0;j<arr.length;j++){
          if(i%arr[j]==0){
             continue start;
          }
          if(arr[j]>=Math.sqrt(i)){
             break;
          }
       }
       arr.push(i);
    }
    return arr.length;
}

Measured memory_bytes: 17756
n = int(input())
p = list(map(int, input().split())) 

ans = 0
for i in range(n-2):
    if p[i]<p[i+1]<p[i+2]:
        ans += 1
    elif p[i+2]<p[i+1]<p[i]:
        ans += 1

print(ans)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define ll int
#define pll pair<int,int>
using namespace std;
pll a[300000];//for each number first represents ai and second represents aj
pll merg(pll x,pll y)
{
    if(x.first < y.first)
        swap(x,y);
    pll ans=x;
    if(y.first > ans.second)
        ans.second=y.first;
    return ans;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin>>n;
    for(int i=0;i<(1<<n);i++)
       {
           ll x;
           cin>>x;
           a[i]=make_pair(x,-5e18);
       }
    //bitmask dynamic programming follow as per codeforces tutorial
    for(int j=0;j<n;j++)
    {
        for(int i=0;i<(1<<n);i++)
            if((i>>j)&1)
            a[i]=merg(a[i],a[i^(1<<j)]);
    }
    ll ans=0;
    for(int i=1;i<(1<<n);i++)
        {
            ans=max(ans,a[i].first+a[i].second);//a[i].first+a[i].second denotes the max of a[i]+a[j] for i&j=K
            cout<<ans<<"\n";
        }
    return 0;
}


Measured memory_bytes: 5120
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <sstream>
#include <map>
#include<vector>

using namespace std;
typedef long long ll;

ll ans,mx,sum,mn=1e8,cnt;


int main(){
	ll n;
	cin>>n;
	if(n<1200) cout<<"ABC";
	else cout<<"ARC";
}




Measured memory_bytes: 256
def next(s,t):
	
	s = s + t[-1]
	if s == t:
		print("Yes")
	else:
		print("No")	

	return 


    
#m = int(input())

#for t in range(m):
#	n = int(input())
#arr = list(map(int,input().split()))
s = input()
t = input()
next(s,t)
'''arr = list(map(int,input().split()))
qarr = []
for i in range(b):
	qarr.append(int(input()))

#k = input()
#n = int(input())
Sol(a,b,arr,qarr)'''
#for i in range(n):
#	next(int(input()))



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

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

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<set>
using namespace std;
int mapp[100005];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0; i<n; i++)
        scanf("%d",&mapp[i]);
    sort(mapp,mapp+n);
    int p=n-1;
    long long  res=1;
    int  flag=0;
    while(p)
    {
        p--;
        if(mapp[p+1]==mapp[p])
        {
            res*=mapp[p];
            flag++;
            p--;
            break;
        }

    }
    while(p)
    {
        p--;
        if(mapp[p+1]==mapp[p])
        {
            res*=mapp[p];
            flag++;
            p--;
            break;
        }

    }
    if(flag==2)
        printf("%lld",res);
    else cout<<"0";

}


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

int main() {
	int w, h, x, y, r;
	cin >> w >> h >> x >> y >> r;
	if (x >= r && y >= r && w - x >= r && h - y >= r) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3120
N = int(input())
if N<10:
    print(N)
elif N >= 10 and N < 100:
    print(9)
elif N >= 100 and N < 1000:
    print(N-90)
elif N >= 1000 and N < 10000:
    print(909)
elif N >= 10000 and N < 100000:
    print(N - 9090)
else:
    print(90909)

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

int main(){
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a>=0&&b>=0){
    if(c>=0){
      cout<<b*d<<endl;
      return 0;
    }
    else{
      if(d>=0){
        cout<<b*d<<endl;
        return 0;
      }
      else{
        cout<<a*d<<endl;
        return 0;
      }
    }
  }
  else if(a<0&&b>=0){
    if(d>=0){
      cout<<max(b*d,a*c)<<endl;
      return 0;
    }
    else{
      cout<<a*c<<endl;
      return 0;
    }
  }
  else{
    if(c<0){
      cout<<a*c<<endl;
      return 0;
    }
    else{
      cout<<b*c<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int Y = sc.nextInt();
		sc.close();
		for (int x = 0; x <= N; x++) {
			for (int y = 0; y <= N - x; y++) {
				int z = N - x - y;
				int sum = x * 10000 + y * 5000 + z * 1000;
				if (sum == Y) {
					System.out.println(x + " " + y + " " + z);
					return;
				}
			}
		}
		System.out.println("-1 -1 -1");
	}
}

Measured memory_bytes: 21716
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();
		}
		Arrays.sort(A);
		int a = 0;
		int b = 0;
		int cnt = 0;
		for(int i = N - 1; i >= 0; i--) {
			if(cnt % 2 == 0) {
				a += A[i];
			} else {
				b += A[i];
			}
			cnt++;
		}
		
		System.out.println(a - b);
	}
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define rep(N) for (int i = 0; i < N; ++i)
#define Rep(a, b) for (int i = a; i < b; ++i)
#define For(i, N) for (int i = 0; i < N; ++i)
#define all(v) v.begin(), v.end()
#define rev(v) v.rbegin(), v.rend()
#define makei(N) int N; cin >> N;
#define makel(N) ll N; cin >> N;
#define makes(s) string s; cin >> s;
#define maked(d) double d; cin >> d;
#define makev(v, N) vi v(N); rep(N)cin >> v[i];
#define mod 1000000007
#define distance(x1,y1,x2,y2) sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using msi = map<string, int>;

template<typename T>
void say(T s) {
	cout << s << "\n";
}

template<typename T>
void say(set<T> s) {
	auto itr = s.begin();
	if (itr == s.end())return;
	cout << *(itr++);
	while (itr != s.end()) {
		cout << "\n" << *(itr++);
	}
	cout << "\n";
}

void yn(bool b) {
	if (b)say("yes");
	else say("no");
}

void Yn(bool b) {
	if (b)say("Yes");
	else say("No");
}

void YN(bool b) {
	if (b)say("YES");
	else say("NO");
}

template<typename T>
void maxi(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void mini(T& a, T b) {
	a = min(a, b);
}

void exact_say(double x) {
	cout << setprecision(numeric_limits<double>::max_digits10) << x << endl;
}

template<class T> void getVector(vector<T>& v) {
	for (int i = 0; i < v.size(); ++i)
		cin >> v[i];
}

int main() {
	set<int> sta;
	set<int> stb;
	set<int> stor;
	set<int> stand;
	vector<int> vand;
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		sta.insert(a);
		stor.insert(a);
	}
	for (int i = 0; i < m; ++i) {
		int b;
		cin >> b;
		stb.insert(b);
		stor.insert(b);
	}
	for (auto it = stor.begin(); it != stor.end();++it) {
		if (sta.find(*it) != sta.end() && stb.find(*it) != stb.end()) {
			stand.insert(*it);
		}
	}
	cout << stand.size() << " " << stor.size() << endl;
	say(stand);
	say(stor);
}


Measured memory_bytes: 35944
#include <bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B;
    cin >> N >> A >> B;
    if((B-A)%2 == 0) cout << "Alice" << endl;
    else cout << "Borys" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a, b, c, d; cin >> a >> b >> c >> d;
	while(true){
		c -= b;
		if(c <= 0) break;
		a -= d;
		if(a <= 0) break;
	}
	cout << (a <= 0 ? "No" : "Yes");
}

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

#define IOS {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}
#define ll long long 

ll powermod(ll x,ll ex,ll md){ll ans=1ll;while(ex>0){if(ex&1ll) ans=(ans*x)%md; ex>>=1ll;x=(x*x)%md;}return ans;}
inline ll gcd(ll a,ll b) {if(b==0)return a;a%=b;return gcd(b,a);}
inline ll max(ll a,ll b) {return((a>b)?a:b);}
inline ll min(ll a,ll b) {return((a>b)?b:a);}

const ll mod=1e9+7;
int main(){
        IOS;
        ll n;
        cin>>n;
        ll a[n];
        ll pfx[n+1]={0};
        for(ll i=0;i<n;i++) cin>>a[i];
        for(ll i=0;i<n;i++) pfx[i+1]=pfx[i]+a[i],pfx[i+1]%=mod;
        ll ans=0;
        for(ll i=1;i<=n;i++){
                ll sum=pfx[n]-pfx[i];
                sum=(sum+mod)%mod;
                sum*=a[i-1];
                sum%=mod;
                ans+=sum;
                ans%=mod;
        }
        cout<<ans<<"\n";
}


Measured memory_bytes: 6740
using System;

class Program
{
    static void Main()
    {
        string[] array = Console.ReadLine().Split(' ');
        int N = int.Parse(array[0]);
        int M = int.Parse(array[1]);
        int X = int.Parse(array[2]);
        int Y = int.Parse(array[3]);

        array = Console.ReadLine().Split(' ');
        int[] x = new int[array.Length];
        for (int i = 0; i < N; i++)
            x[i] = int.Parse(array[i]);

        array = Console.ReadLine().Split(' ');
        int[] y = new int[array.Length];
        for (int i = 0; i < M; i++)
            y[i] = int.Parse(array[i]);

        bool flag = true;

        for (int i = X + 1; i <= Y; i++)
        {
            for (int j = 0; j < N; j++)
            {
                if (x[j] >= i)
                {
                    flag = false;
                    break;
                }
            }
            if (flag)
            {
                for (int j = 0; j < M; j++)
                {
                    if (y[j] < i)
                    {
                        flag = false;
                        break;
                    }
                }
            }
            if (flag) break;
            else if (i != Y) flag = true;
        }
        if (flag) Console.WriteLine("No War");
        else Console.WriteLine("War");
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define ld  double
#define ll long long 
#define pp push
#define pb push_back
#define pf push_front
#define mp make_pair
#define inf 1e9
#define f first
#define s second
#define pll pair<ll,ll>
#define vll vector<ll>
#define vi vector<int>
#define mod 1000000007
using namespace std;
ll n,k;
ll a[102];
ll dp[100007];
ll solve(ll k)
{
    if(dp[k]!=-1)return dp[k];
    else if(k==0)return dp[k]=0;
    ll ans=0;
    for(ll i=0;i<n;i++)
    {
        if(a[i]<=k)
        if(solve(k-a[i])==0){ans=1;break;}
    }
    dp[k]=ans;
    return dp[k];
}
int main()
{
    cin>>n>>k;
    for(ll i=0;i<n;i++)cin>>a[i];
    memset(dp,-1,sizeof(dp));
    if(solve(k)==1)cout<<"First";
    else cout<<"Second";
}

Measured memory_bytes: 4096
#include<cstdio>
#include<cmath>
#define int long long
using namespace std;
signed main()
{
	int n;
	scanf("%lld",&n);
	int ans1;
	int qwq=sqrt(n);
	for(int i=qwq;i>=1;i--)
	{
		if(n%i==0) 
		{
			ans1=i;
			break;
		}
	}
	int ans2=n/ans1;
	printf("%lld",ans2-1+ans1-1);
	return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    N, M = map(int, input().split())
    # AB = [list(map(int, input().split())) for _ in range(M)]
    from_1 = [False] * N
    to_N = [False] * N
    for _ in range(M):
        a, b = map(int, input().split())
        if a == 1:
            from_1[b - 1] = True
        elif b == N:
            to_N[a - 1] = True
    for i in range(1, N):
        if from_1[i] and to_N[i]:
            print('POSSIBLE')
            break
    else:
        print('IMPOSSIBLE')


if __name__ == "__main__":
    main()


Measured memory_bytes: 6132
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n, k;
  cin >> n >> k;
  ll ct = 0;
  while(n) {
  	n/=k;
  	ct++;
  }
  cout << ct << endl;
  return 0;
} //good night.

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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vii = vector<int>;
using pii = pair<int, int>;

const ll INF = numeric_limits<ll>::max(),
         MOD = 1e9 + 7;

const int INF_i = numeric_limits<int>::max(),
          MAX = 3e3;

int n;
vll v, s;
ll dp[MAX][MAX];

ll f(int i, int j) {
    if (i == j) return v[i];
    ll &res = dp[i][j];
    if (res != -1) return res;
    res = v[i] + s[j + 1] - s[i + 1] - f(i + 1, j);
    res = max(res, v[j] + s[j] - s[i] - f(i, j - 1));
    return res;
}

int main() {
    cin.tie(NULL);
    ios_base::sync_with_stdio(false);
    // freopen("in.in", "r", stdin);
    memset(dp, -1, sizeof dp);
    cin >> n;
    v.resize(n);
    s.resize(n + 1);
    for (ll &e : v) cin >> e;
    partial_sum(v.begin(), v.end(), s.begin() + 1);
    s[0] = 0;
    cout << 2 * f(0, n - 1) - s.back() << '\n';
}

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

int main(){
  int n,i,a,j=0;
  cin >> n;
  for(i=0; i<n; i++){
    cin >> a;
    if(a%2==1){
      j++; break;
    }
  }
  if(j==0){
    cout << "second" << endl;
  }else{
    cout << "first" << endl;
  }
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


int N;
ll A[100001];
ll B[100001];

signed main(){
    cin >> N;
    REP(i, N + 1) cin >> A[i];
    REP(i, N) cin >> B[i];
    ll ans = 0;
    REP(i, N){
        if(A[i] >= B[i]){
            ans += B[i];
            continue;
        }else{
            ans += A[i];
            B[i] -= A[i];
            ans += min(A[i + 1], B[i]);
            A[i + 1] -= min(A[i + 1], B[i]);
        }
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main()
{
	int n,m;
	int a=0,b=0,c=0;
	while(~scanf("%d",&n))
	{   
	    a=0;
	    b=0;
	    c=0;
	    int d=n;
		while(n--)
		{   
			scanf("%d",&m);
			if(m%4==0)
			{
				a++;
			}
			if(m%2==0&&m%4!=0)
			{
				b++;
			}
		}  
	   if(b==0)
	   {
	   	  if(a>=d-a-b||a==d-a-b-1)
	   	  {
  	   		printf("Yes\n");
  	   	  }
  	   	  else
   	      printf("No\n");
   	   }
	   if(b!=0)
	   {
   		  if(a>=d-a-b)
	   	  {
  	   		printf("Yes\n");
  	   	  }
	      else
   	      printf("No\n");
   	   }
   	   
	 }	
	
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Scanner;

public class Main {
      public static void main(String[] args) {

               Scanner sc = new Scanner(System.in);
               int loop = sc.nextInt();
               int arr [] = new int [loop];
               boolean  go = true;
               for(int i = 0; i < loop; i++) {
                  arr[i] = sc.nextInt();
                  if(arr[i] % 2 != 0) {
                            go = false;
                  }    
    }

                   sc.close();
                int num = 0;
           
               while (go) {
                    for(int i = 0; i < loop; i++) {
                          arr[i] /= 2;
                          if(arr[i] % 2  != 0) {
                          go = false;
                         break;
                 }
         }
                     num++;      
} //-------- END while
              System.out.println(num);
        }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
#ifdef PRAGMA
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif
#define fst first
#define snd second
#define fore(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define bs binary_search
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int) (n).size())
#define MAXI ((ll)1e16)
#define MINI ((ll)-1e16)
using namespace std;
typedef long long ll;  
     
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b,a%b); } 
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }        
ll n,m,x,y,res=-1;
vector <ll> g[100005];
ll dp[100001];

ll solve(ll i){
	if(i==n+1)return 0;
	if(dp[i]!=-1)return dp[i];
	dp[i]=0;
	for(auto x : g[i]){
		dp[i]=max(dp[i],1+solve(x));
	}
	return dp[i];
	
}
int main(){FIN;
	cin >> n >> m;
	fore(i,0,m){
		cin >> x >> y;
		g[x].pb(y);
	}
	memset(dp,-1,sizeof(dp));
	fore(i,1,n+1){
		res=max(res,solve(i));
	}
	cout << res;
}

Measured memory_bytes: 7936
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    int r, g;
    cin >> r >> g;
    cout << 2*g - r << endl;
    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//
//
//using namespace __gnu_pbds;
using namespace std;

#define pb                     push_back
#define ll                     long long
#define forn(i,n)              for(int i=0; i<(int)n; i++)
#define forn1(i,n)              for(int i=1; i<=(int)n; i++)

#define sfd(a)                 scanf("%d", &a)
#define sffd(a,b)              scanf("%d%d", &a, &b)
#define sffl(a,b)              scanf("%lld%lld", &a,&b)
#define sfl(a)                 scanf("%lld", &a)

#define pii                    pair<int , int>
#define pll                    pair<ll , ll>
#define ff                     first
#define ss                     second
#define mem(a, val)            memset(a, val, sizeof(a))
#define all(x)                 (x).begin(), (x).end()

#define mx                     200005
#define INF_mx                 1e18
#define gcd(a,b)               __gcd(a, b)
#define lcm(a,b)               (a*b)/__gcd(a,b)
#define PRINT                  cout<<"hi"<<endl
#define PI acos(-1)
#define fast_in_out          ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define Q    int q; cin>>q; while(q--)
/*
tree<
       int,
     null_type,
     less<int>,
     rb_tree_tag,
     tree_order_statistics_node_update>t;
*/

int main()
{

     int n, x,y;
     cin>>n>>x>>y;

     int a[n+2];
     mem(a, 0);
     for(int i=1; i<n; i++){
        for(int j=i+1; j<=n; j++){
            a[min(j-i, abs(i-x)+abs(j-y)+1)]++;
        }
     }
     for(int i=1; i<n; i++) printf("%d\n",a[i]);
    return 0;
}
/*

10

5
7 11 11 23 29

5
11 11 11 33 3
*/


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

int main() {
  ll a = 0,b = 0;
  cin >> a >> b;
  if(a > 9 || b > 9){
    cout << -1;
  }
  else{
    cout << a*b;
  }
}

Measured memory_bytes: 3620
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("Ofast")
//#pragma GCC optimization ("unroll-loops")

//#pragma comment(linker,"/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

//order_of_key(k): Number of items strictly smaller than k .
//find_by_order(k): K-th element in a set (counting from zero).
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define full(x,n) x,x+n+1
#define full(x) x.begin(),x.end()
#define finish return 0

#define putb push_back
#define f first
#define s second

//logx(a^n)=loga(a^n)/logx(a)
//logx(a*b)=logx(a)+logx(b)
//logx(y)=log(y)/log(x)
//logb(n)=loga(n)/loga(b)

#define ordered_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
#define putf push_front
#define gainb pop_back

#define gainf pop_front
#define len(x) (int)x.size()

// 1/b%mod=b^(m-2)%mod
// (a>>x)&1==0
// a^b=(a+b)-2(a&b)

typedef double db;
typedef long long ll;

//sum of squares n*(n+1)*(2n+1)/6
//sum of cubes [n*(n+1)/2]^2
//sum of squares for odds n*(4*n*n-1)/3
//sum of cubes for odds n*n*(2*n*n-1)

const int ary=1e5+5;
const int mod=1e9+7;
const ll inf=1e18;

using namespace std;
using namespace __gnu_pbds;
string k;
int D;
ll dp[ary][105],d[ary][105][2],ans;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>k>>D;
	dp[0][0]=1;
	for(int i=0;i<len(k)-1;i++){
		for(int j=0;j<D;j++){
			for(int p=0+(i==0);p<=9;p++){
				int t=(j+p)%D;
				dp[i+1][t]+=dp[i][j];
				dp[i+1][t]%=mod;
			}
		}
		ans+=dp[i+1][0];
		ans%=mod;
	}
	d[0][0][0]=1;
	for(int i=1;i<=len(k);i++){
		for(int j=0+(i==1);j<=9;j++){
			for(int p=0;p<D;p++){
				d[i][(p+j)%D][1]+=d[i-1][p][1];
				d[i][(p+j)%D][1]%=mod;
				if(j<k[i-1]-'0'){
					d[i][(p+j)%D][1]+=d[i-1][p][0];
				}
				else if(j==k[i-1]-'0'){
					d[i][(p+j)%D][0]+=d[i-1][p][0];
					d[i][(p+j)%D][0]%=mod;
				}
			}
		}
	}
	ans+=d[len(k)][0][0]+d[len(k)][0][1];
	ans%=mod;
	cout<<ans;
}

Measured memory_bytes: 28248
//****** @mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define EB emplace_back
#define PB push_back
#define endl "\n"
#define MOD 1000000007
#define MOD2 998244353
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int fast_pow(int x, int y, int p);

void solve(int test) {
    int n,m;cin>>n>>m;
    cout<<((n*(n-1))/2)+((m*(m-1))/2)<<endl;

}
int32_t main() {
    IOS;
    int test = 1;
//    cin >> test;
    for(int i=1;i<=test;i++){
        solve(i);
    }
    return 0;
}
int fast_pow(int x, int y, int p) {
    int res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}


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

using namespace std;

int main(void){
  int h, w;

  while(cin >> h >> w){
	if((h|w) == 0) break;
	bool visited[h][w];
	bool isloop = false;
	char arrow[h][w];
	string str;
	for(int i=0;i<h;i++){
	  cin >> str;
	  for(int j=0;j<w;j++){
		arrow[i][j] = str[j];
	  }
	}
	
	int x=0,y=0;
	memset(visited, false, sizeof(visited));
	while(arrow[x][y] != '.'){
	  if(visited[x][y]){
		isloop = true;
		break;
	  }
	  visited[x][y] = true;
	  if(arrow[x][y] == '>'){
		y++;
	  }else if(arrow[x][y] == '^'){
		x--;
	  }else if(arrow[x][y] == 'v'){
		x++;
	  }else{
		y--;
	  }
	}
	if(isloop){
	  cout << "LOOP" << endl;
	}else{
	  cout << y << " " << x << endl;
	}
  }
}

Measured memory_bytes: 0