akhauriyash/Code-Regression huggingface dataset:
import qualified Data.ByteString.Char8 as BC
import Data.IORef
import Control.Monad
import Data.Maybe(fromJust)
 
main :: IO()
main = BC.getLine >> BC.getContents >>= solve.map (fst.fromJust.BC.readInt).BC.lines >>= print
 
solve :: [Int] -> IO Int
solve (x:y:xs) = do
                  a <- newIORef (y - x)
                  b <- newIORef (min x y)
                  forM_ xs $ \z -> do
                    a' <- readIORef a
                    b' <- readIORef b
                    when (z - b' > a') $ writeIORef a (z - b')
                    when (z < b')      $ writeIORef b z
                  readIORef a

Measured memory_bytes: 5900
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    r,D,x=mi()
    for i in range(10):
        x = x*r - D
        print(x)
        




if __name__ == "__main__":
    main()

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

struct UnionFind {
  vector<int> d; // 親の番号、但し根の場合はサイズのマイナス
  UnionFind(int n): d(n,-1) {}
  int root(int x) { // 根を見つける
    if (d[x] < 0) return x;
    return d[x] = root(d[x]); // 経路圧縮
  }
  bool unite(int x, int y) { // 結合
    x = root(x); y = root(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return root(x) == root(y);} // 親が一緒
  int size(int x) { return -d[root(x)];} // サイズ
};

int main(){
    int n,k,l;
    cin>>n>>k>>l;
    UnionFind uf0(n); // 初期化
    UnionFind uf1(n); // 初期化
    int p,q;
    rep(i,k){ 
        cin>>p>>q;
        p--;
        q--;
        uf0.unite(p,q);
    }
    rep(i,l){ 
        cin>>p>>q;
        p--;
        q--;
        uf1.unite(p,q);
    }
    map<pair<int,int>,int> m;
    rep(i,n){
        m[pair<int,int>(uf0.root(i),uf1.root(i))]++;
    }
    rep(i,n){
        cout<<m[pair<int,int>(uf0.root(i),uf1.root(i))]<<" ";
    }
    cout<<endl;
    return 0;
}



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

using namespace std;

bool is_square(int n)
{
    int sqrN = 1;
    while (sqrN * sqrN < n) ++sqrN;
    return sqrN * sqrN == n;
}

int main()
{
#ifdef jcg
    assert(freopen("input.in", "r", stdin));
//    assert(freopen("output.out", "w", stdout));
#endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int N, D;
    cin >> N >> D;

    vector<vector<int>> ps;
    int ans = 0;

    for (int i = 0; i < N; ++i)
    {
        vector<int> p(D);
        for (int &x : p) cin >> x;
        for (auto &q : ps)
        {
            int sum = 0;
            for (int k = 0; k < D; ++k)
                sum += (p[k] - q[k]) * (p[k] - q[k]);
            if (is_square(sum))
                ++ans;
        }
        ps.emplace_back(p);
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

vector<int> G[100000];
vector<int> a(100000);
vector<int> deg;

int dfs(int cur, int prev){
    if(deg[cur]==1)return a[cur];
    ll sigma = 0;
    int maxC = 0;
    for(auto e:G[cur]){
        if(e==prev)continue;
        int res = dfs(e,cur);
        maxC = max(maxC,res);
        sigma+=res;
    }
    
    int t = 2*a[cur] - sigma;
    if( t<0 || t>a[cur] || sigma-t > 2*min(sigma-maxC,sigma/2) )throw -1;
    
    return t;
}

int main(){
    int n;
    cin>>n;
    rep(i,n)cin>>a[i];
    
    deg.resize(n,0);
    rep(i,n-1){
        int s,t;
        cin>>s>>t;
        s--,t--;
        deg[s]++;
        deg[t]++;
        G[s].pb(t);
        G[t].pb(s);
    }
    
    if(n==2){
        if(a[0]==a[1])cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
        return 0;
    }
    
    int root = 0;
    while(deg[root]==1)root++;
    
    int res;
    try{
        res = dfs(root,-1);
    }catch(int e){
        cout<<"NO"<<endl;
        return 0;
    }
    if(res==0){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 13184
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	string s;
	cin>>s;
	
	int curr=0;
	
	reverse(all(s));
	
	ll ans=0;
	
	rep(x,0,s.size()){
		if (s[x]=='A'){
			if (curr%2==0) ans+=curr/2;
			else curr=0;
		}
		else if (s[x]=='B'){
			if (curr%2==1) curr++;
			else curr=0;
		}
		else{
			if (curr%2==0) curr++;
			else curr=1;
		}
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
long long a,b,ans,kcl,idxkcl;
int main(){
	cin>>a>>b;
	kcl = 1e9;
	for(int i =1;i<=a;i++){
		if(abs(i+b-1)<=kcl){
			kcl = abs(i+b-1);
			idxkcl =i;
		}
	}
	for(int i =1;i<=a;i++){
		if(i==idxkcl)continue;
		ans+=i+b-1;
	}
	cout<<ans<<endl;
	// cout<<kcl<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

constexpr int dx[] = {-1, 0, 1, 0};
constexpr int dy[] = {0, -1, 0, 1};

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

template <typename T>
std::unordered_map<size_t, T> count_item(std::vector<T>& v) {
	int n = v.size();
	std::unordered_map<size_t, T> c;
	for(T& e : v) {
		c[e]++;
	}
	return c;
}

int main() {
	int n;
	cin >> n;
	vector<ll> input(n);
	ll sum = 0;
	REP(i, n) {
		cin >> input[i];
		sum += input[i];
	}
	unordered_map<size_t, ll> a = count_item<ll>(input);
	int q;
	cin >> q;
	vector<ll> result;
	REP(i, q) {
		ll b, c;
		cin >> b >> c;
		sum = sum - (b * a[b]) + (c * a[b]);
		a[c] += a[b];
		a[b] = 0;
		result.push_back(sum);
	}

	EACH(e, result) { cout << e << endl; }

	return 0;
}


Measured memory_bytes: 8944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

ll N;

int main() {
    cin >> N;
    ll ans = N * (N-1) / 2;
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 3644
n=int(input())
s=input()
r,g,b=0,0,0
for ss in s:
  if ss=="R":r+=1
  elif ss=="G":g+=1
  elif ss=="B":b+=1

ans=r*g*b
for i in range(n-2):
  for j in range(i+1,n-1):
    k=j+(j-i)
    if k>=n:break
    if not(s[i]==s[j] or s[j]==s[k] or s[i]==s[k]):
      ans-=1
print(ans)


Measured memory_bytes: 9208
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
import std.container : DList;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    Node node = new Node();
    node.value = int.max;

    int q = readint;
    for (int i = 0; i < q; i++) {
        auto qu = readints;
        switch (qu[0]) {
        case 0: // insert
            {
                auto x = new Node();
                x.value = qu[1];
                if (node !is null) {
                    auto prev = node.prev;
                    if (prev !is null) {
                        prev.next = x;
                        x.prev = prev;
                    }

                    node.prev = x;
                    x.next = node;
                }
                node = x;
                break;
            }
        case 1: // move
            {
                int d = qu[1];
                if (d >= 0) {
                    for (int j = 0; j < d; j++) {
                        node = node.next;
                    }
                }
                else {
                    for (int j = 0; j < -d; j++) {
                        node = node.prev;
                    }
                }
                break;
            }

        case 2: // erase
            {
                assert(node !is null);
                auto prev = node.prev;
                auto next = node.next;
                if (prev !is null) {
                    prev.next = next;
                }
                if (next !is null) {
                    next.prev = prev;
                }

                node = next;
                break;
            }

        default:
            break;
        }
    }

    auto x = node;
    while (x.prev !is null) x = x.prev;
    while (x !is null) {
        if (x.value == int.max) break; // sentinel
        writeln(x.value);
        x = x.next;
    }
}

class Node {
    int value;
    Node next;
    Node prev;
}


Measured memory_bytes: 56176
import java.util.Scanner;

  class Main{
    public static void main(String[] args){
      Scanner stdIn = new Scanner(System.in);
      int a = stdIn.nextInt();
      int b = stdIn.nextInt();
      int[] S = {a+b,a-b,a*b};
      int M = S[0];
      for(int i=0; i<=2; i++){
        if(M <= S[i]){
          M = S[i];
        }
      }
      System.out.println(M);
    }
  }

Measured memory_bytes: 21844
import numpy as np
import heapq

k, n = map(int, input().split())

As = np.asarray(input().split(), dtype=np.int32)

H = []

for i in range(len(As)):
    if i == 0:
        heapq.heappush(H, As[-1]-k-As[0])
    else:
        heapq.heappush(H, As[i-1] - As[i])

print(k + H[0])

Measured memory_bytes: 40584
#include<iostream>
#include<algorithm>

using namespace std;

int const N = 2e5 + 41;

int used[N], n, x, ans[N];

int main(){
	scanf("%d%d",&n,&x);
	n = n * 2 - 1;
	if(x == n || x == 1){
		printf("No\n");
		return 0;
	}
	for(int i=1;i<=n;++i){
		ans[i] = i;
	}
	if(n == 3){
		if(x == 2){
			printf("Yes\n1\n2\n3\n");
		}else{
			printf("No\n");
		}
		return 0;
	}

	if(x == n - 1){
		swap(ans[n/2 + 1], ans[n-1]);
		swap(ans[n/2], ans[n]);
		swap(ans[n/2-1], ans[1]);
		swap(ans[n/2+2], ans[2]);
	}else{
		swap(ans[n/2 + 1], ans[x]);
		swap(ans[n/2], ans[1]);
		swap(ans[n/2-1], ans[n]);
		swap(ans[n/2+2], ans[n-1]);
	}

	printf("Yes\n");
	for(int i=1;i<=n;++i){
		printf("%d\n",ans[i]);
	}


	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;


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

string s;
cin >> s;
int n = SZ(s);

string ans;
if(s[0] == s[n-1]) {
    if(n % 2 == 1) ans = "Second";
    else ans = "First";
} else {
    if(n % 2 == 1) ans = "First";
    else ans = "Second";
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 512
import numpy as np
import math
N=int(input())
X=list(map(float,input().split()))
Xmin=int(math.floor(np.min(X)));Xmax=int(math.ceil(np.max(X)))
P=np.array([i for i in range (Xmin,Xmax+1)])
Sum=np.zeros(len(P),dtype=float)
for i in range(len(P)):
    Sum[i]=np.sum((np.array(X)-P[i])*(np.array(X)-P[i]))
print(int(np.min(Sum)))

Measured memory_bytes: 12488
import java.util.*;

public class Main {
    static final int MOD = 1000000007;
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
		int length = arr.length;
		long[][] dp = new long[length + 1][4];
		dp[0][0] = 1;
 		for (int i = 1; i <= length; i++) {
		    char c = arr[i - 1];
		    if (c == '?') {
		        dp[i][0] = dp[i - 1][0] * 3;
		        dp[i][0] %= MOD;
		    } else {
		        dp[i][0] = dp[i - 1][0];
		    }
		    for (int j = 1; j <= 3; j++) {
		        if (c == '?') {
		            dp[i][j] += dp[i - 1][j] * 3;
		            dp[i][j] += dp[i - 1][j - 1];
		        } else {
		            dp[i][j] += dp[i - 1][j];
		            if (c - 'A' + 1 == j) {
		                dp[i][j] += dp[i - 1][j - 1];
		            }
		        }
               dp[i][j] %= MOD;
		    }
		}
		System.out.println(dp[length][3]);
    }
}



Measured memory_bytes: 34288
#include<stdio.h>
#include <limits>
#include <algorithm>

using namespace std;

int imax = std::numeric_limits<int>::max();

int m[2][100];
bool c[100];

int solve(int i, int v[100], int n) {
	if (i == n - 1) {
		if (!c[i-1] && v[i] == v[i-1])
			return 1;
		return 0;
	}
	
	int resnc = imax;
	if (c[i-1] || v[i] != v[i-1]) {
		resnc = m[0][i];
		if (resnc == -1) {
			resnc = solve(i+1, v, n);
			m[0][i] = resnc;
		}
	}
	
	int resc = m[1][i];
	if (resc == -1) {
		c[i] = true;
		resc = solve(i+1, v, n) + 1;
		c[i] = false;
		m[1][i] = resc;
	}
	
	return min(resc, resnc);
}

int main() {
	int n;
	scanf("%d", &n);
	
	int v[100];
	for (int i = 0; i < n; i++) {
		scanf("%d", &v[i]);
		m[0][i] = -1;
		m[1][i] = -1;
		c[i] = false;
	}
	
	m[0][0] = solve(1, v, n);
	c[0] = true;
	m[1][0] = 1 + solve(1, v, n);
	printf("%d", min(m[0][0], m[1][0]));
	
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
		ArrayList<String> list = new ArrayList<String>();
		
		while(true){
			String str = br.readLine();
			if("0 0".equals(str)) break;
			list.add(str);
		}
		
		for(int i = 0 ; i <list.size() ; i++){
			String[] stra = list.get(i).split(" ");
			int h = Integer.parseInt(stra[0]);
			int w = Integer.parseInt(stra[1]);
			for(int j = 0 ; j < h ;j++){
				for(int k = 0 ; k < w ;k++){
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
	}

}

Measured memory_bytes: 25920
import sys
import numpy as np
from functools import lru_cache

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MOD = 998_244_353

def main(A, B, C, D):
    dp = np.zeros((C + 1, D + 1), np.int64)
    dp[C, D] = 1
    for d in range(D, 0, -1):
        dp[C, d - 1] = dp[C, d] * C % MOD
    for c in range(C - 1, -1, -1):
        x = 0
        for d in range(D, -1, -1):
            dp[c, d] = (d * dp[c + 1, d] + x) % MOD
            x += dp[c + 1, d]
            x *= c
            x %= MOD
    return dp[A, B]

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.from_dtype(np.int64)
    signature = (i8, i8, i8, i8)

    cc = CC('my_module')
    cc.export('main', signature)(main)
    cc.compile()

from my_module import main

A, B, C, D = map(int, read().split())
print(main(A, B, C, D))

Measured memory_bytes: 97052
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
#define dump(x) cerr<<#x<<"="<<x<<endl

int main() {
    int n; cin >> n;
    vector<ll> h(n);
    rep(i, n) cin >> h.at(i);

    int cnt = 0;
    bool br = false;
    bool next = false;
    rep(i, 1000000){
        rep(j, n){
            if(h.at(j)!=0) break;
            if(j==n-1){
                br = true;
            }
        }
        if(br) break;

        cnt++;
        rep(j, n){
            if(h.at(j)!=0){
                dump(h.at(j));
                h.at(j)--;
                next = true;
            }
            else if(!next){
                continue;
            }
            else break;
         
        }
        next = false;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
//not answered
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
#include <algorithm>

int main() {
  int n;
  cin >> n;
  
  vector<lli> a(n);
  for(int i = 0; i < n; i++)
    cin >> a[i];
  
  vector<lli> dp0(n+1);
  vector<lli> dp1(n+1);
  
  dp0[0] = a[0];
  dp1[0] = - a[0];
  for(int i = 1; i < n; i++){
    dp0[i] = max(dp0[i-1] + a[i], dp1[i-1] - a[i]);
    dp1[i] = max(dp0[i-1] - a[i], dp1[i-1] + a[i]);
  }
  
  cout << dp0[n-1] << endl;
  
}

Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int x[10],i,j,y[10],ans1=0,ans2=0;
	for(i=0;i<10;i++){
		cin>>x[i];
	}
	sort(x,x+10);
	for(i=9;i>6;i--){
		ans1+=x[i];
	}
	for(j=0;j<10;j++){
		cin>>y[j];
	}
	sort(y,y+10);
	for(j=9;j>6;j--){
		ans2+=y[j];
	}
	cout<<ans1<<" "<<ans2<<endl;
	return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
using ll = int64_t;
using P = pair<ll,ll>;
ll INF = 1000000007;
// ll INF = 9223372036854775807;
// ll INF = 998244353;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    ll k;
    string s;
    cin >> k >> s;
    string res = "";
    if(s.size() <= k) res = s;
    if(s.size() > k){
        res += s.substr(0,k);
        res += "...";
    }
    cout << res << endl;
}

Measured memory_bytes: 3640
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);

		for (int i=1; i<=5; i++){
			int x = sc.nextInt();
			if (x == 0){
				System.out.println(i);
				return;
			}
		}

	}

}

Measured memory_bytes: 35736
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, k;
	cin >> n >> k;
	int ans = 0;
	while (n--)
	{
		int x;
		cin >> x;
		ans += x >= k;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int A,B;
  char op;
  int S;
  
  cin>>A>>op>>B;
  
  if(op=='+'){
    S=A+B;
  }
  else if(op=='-'){
    S=A-B;
  }
  
  cout<<S<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int s(int a, int b) {
	int sum = 0;
	for (int i = a; a <= b; a++)
		sum += a;
	return sum;
}
int main() {
	int n, l;
	cin >> n >> l;
	if(l >= 0)
		cout << s(l + 1, l + n - 1);
	else if (l < 0) {
		if(n > - l)
			cout << s(l, l + n - 1);
		else
			cout << s(l, l + n - 2);
	}
}

Measured memory_bytes: 256
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define ll long long int
#define fab(a,b,i) for(int i=a;i<b;i++)
#define pb push_back
#define db double
#define mp make_pair
#define endl "\n"
#define f first
#define se second
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
ll dp[3005][3005][2],n,a[3005];
ll recurse(int l,int r,int i)
{
	if(l>r)
		return 0;
	if(dp[l][r][i]!=-1)
		return dp[l][r][i];
	if(l==r )
		if(i==0)
		return dp[l][r][i]=a[l]+recurse(l+1,r,1);

		else
			return dp[l][r][i]=recurse(l+1,r,0)-a[l];
	if(i==0)
	dp[l][r][i]=max(recurse(l+1,r,1)+a[l],recurse(l,r-1,1)+a[r]);
	else
		dp[l][r][i]=(min(recurse(l+1,r,0)-a[l],recurse(l,r-1,0)-a[r]));
	return dp[l][r][i];


}

int main()
{ quick;

	cin>>n;
	memset(dp,-1,sizeof(dp));
	fab(0,n,i)
	cin>>a[i];
	cout<<recurse(0,n-1,0)<<endl;
	/*fab(0,n,i)
	{
		fab(0,n,j)
		{
			fab(0,2,k)
			cout<<dp[i][j][k]<<" ";
			cout<<endl;
		}
		cout<<endl;
	}*/

	return 0;
}

Measured memory_bytes: 141568
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#define ll long long
#define out(a) printf("%lld ",a)
using namespace std;
int n;
ll l,r,lbound,rbound,mid=0,qaq;
ll now;
int a[100050];
bool flag,f;
int read()
{
	int s=0,t=1; char c;
	while (c<'0'||c>'9') {if (c=='-') t=-1; c=getchar();}
	while (c>='0'&&c<='9') {s=s*10+c-'0'; c=getchar();}
	return s*t;
}
int main()
{
	n=read(); l=2;
	for (int i=1;i<=n;i++)
	  a[i]=read();
	  r=1e18;
	  lbound=l; rbound=r;
	while (l<=r) {
	  f=false;
	  mid=(l+r)>>1; now=mid;
	  for (int i=1;i<=n;i++) {
	    now=(now/a[i])*a[i];
//	    if (now<2&&i!=n) {
//	      f=true; break;
//	    }
//	    if (now<a[i]) {
//	      f=true; break;
//	    }
	  }
	  if (now<2) f=true;
	    if (now==2) flag=true;
	    //printf("%d\n",now);
	  if (not f) r=mid-1;
	  else l=mid+1;
    }
    while (lbound<=rbound) {
    	f=false;
      mid=(lbound+rbound)>>1; now=mid;
      for (int i=1;i<=n;i++) {
        now=(now/a[i])*a[i];
//        if (now<2&&i!=n) {
//	      f=true; break;
//	    }
//	    if (now<a[i]) {
//	      f=true; break;
//	    }
	  }
	  if (now<=2) f=true;
        if (now==2) flag=true;
      //printf("%d\n",now);
      if (not f) rbound=mid-1;
      else lbound=mid+1;
  }
    if (flag) out(l),out(--lbound);
    else puts("-1");
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std ;
#define rep( i, s, t ) for( register int i = s; i <= t; ++ i )
#define re register
#define int long long
const int N = 1e6 + 5 ; 
char s[N] ; 
int f[N][2] ;
signed main()
{
	scanf("%s", s + 1 ) ;
	int n = strlen( s + 1 ), Ans = 0 ; s[0] = '0' ;
	f[n + 1][0] = 0, f[n + 1][1] = 100 ;
	for( re int i = n; i >= 0; -- i ) {
		int u = s[i] - '0' ; 
		f[i][1] = min( f[i + 1][1] - u - 1, f[i + 1][0] - u ) + 10 ;
		f[i][0] = min( f[i + 1][1] + u + 1, f[i + 1][0] + u ) ;
	}
	cout << f[0][0] << endl ;
	return 0 ;
}

Measured memory_bytes: 16896
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll maxi =-1e18;
    maxi =max({maxi,a*c,a*d,b*d,c*b});
    cout<<maxi<<endl;
    return 0;

}

Measured memory_bytes: 3672
S=input()
if '01'<=S[0:2]<='12':
    MMYY=True
else:
    MMYY=False
if '01'<=S[2:4]<='12':
    YYMM=True
else:
    YYMM=False
if MMYY and YYMM:
    print('AMBIGUOUS')
elif MMYY and not YYMM:
    print('MMYY')
elif not MMYY and YYMM:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3060
# 146A
S = input()

if S == 'SUN':
    answer = (7)
elif S == 'MON':
    answer = (6)
elif S == 'TUE':
    answer = (5)
elif S == 'WED':
    answer = (4)
elif S == 'THU':
    answer = (3)
elif S == 'FRI':
    answer = (2)
elif S == 'SAT':
    answer = (1)

print(answer)

Measured memory_bytes: 9056
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr,0,sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9+7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t  main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n, r;
        cin >> n >> r;
        if(n >= 10){
            cout << r << '\n';
            return 0;
        }
        cout << r + 100 * (10 - n) << '\n';
    } 
}

Measured memory_bytes: 31488
#include <iostream>
using namespace std;
using ll = long long;

ll w, h, n;
ll x, y;
ll d[100005];
ll ans = 1ll << 60ll;

int main() {
    cin >> w >> h >> n;
    for (int i = 0; i < n; i++) {
        cin >> x >> y;
        
        d[x] = max(d[x], y);
    }

    for (int i = w - 2; i >= 0; i--) {
        d[i] = max(d[i], d[i + 1]);
    }

    for (int i = 0; i < w; i++) {
        ans = min(ans, i + d[i + 1]);
    }

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



Measured memory_bytes: 3884
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if((a+b)%2 == 0){
    cout<<(a+b)/2<<'\n';
  }
  else{
    cout<<(a+b)/2+1<<'\n';
  }
  return 0;
}



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

static const int N = 100;

int main(int argc, char const *argv[])
{
    int n, p[N+1], m[N+1][N+1];
    cin >> n;

    for(int i=1; i<=n; i++) cin >> p[i-1] >> p[i];

    for(int i=1; i<=n; i++) m[i][i] = 0;

    for(int l=2; l<=n; l++){
        for(int i=1; i<=n-l+1; i++){
            int j= i+l-1;
            m[i][j] = (1<<21);
            for(int k=i; k<=j-1; k++){
                m[i][j] = min(m[i][j], m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
            }
        }
    }

    cout << m[1][n] << endl;

    return 0;
}



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

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

int iin() {
    int i;
    scanf("%d", &i);
    return i;
}

long long llin() {
    long long i;
    scanf("%lld", &i);
    return i; 
}

double din() {
    double i;
    scanf("%lf", &i);
    return i;
}

char cin() {
    char c;
    scanf("%c", &c);
    return c;
}

void stin(char *s) {
    scanf("%s", s);
}

void iout(int i) {
    printf("%d\n", i);
}

void llout(long long i) {
    printf("%lld\n", i);
}

void dout(double i) {
    printf("%lf\n", i);
}

void cout(char c) {
    printf("%c\n", c);
}

void stout(char *s) {
    printf("%s\n", s);
}

int main() {
    char b = cin();
    if (b == 'A') {
        cout('T');    
    } else if (b == 'C') {
        cout('G');
    } else if (b == 'G') {
        cout('C');
    } else if (b == 'T') {
        cout('A');
    }
    return 0;
}

Measured memory_bytes: 128
def max(a,b) a>b ? a:b end

s=gets.chomp
slen=s.length

cnt = 1
rindex = 0
rcnt = 1
s+="R"
ary = Array.new(slen, 0)
slen.times do |i|
  if s[i] == s[i+1]
    cnt += 1
  else
    if s[i] == "R"
      rcnt = cnt
      cnt = 1
      rindex = i
    else
      sum = rcnt + cnt
      r, l = sum/2, sum/2

      max = max(rcnt, cnt)
      if sum % 2 != 0
        if rcnt > cnt
          r += 1
        else
          l += 1
        end
        if max % 2 == 0
          r, l = l, r
        end
      end
      ary[rindex] = r
      ary[rindex+1] = l
      
      cnt = 1
    end
  end
end

puts ary.join(" ")

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){
  
  int n;
  cin >> n;
  if((n%10) == 3)cout << "bon" << endl;
  else if((n%10) == 0 || (n%10) == 1 || (n%10) == 6 || (n%10) == 8)cout << "pon" << endl;
  else cout << "hon" << endl;



  return 0;
}

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

#define ALL(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




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

/*　吾輩はやれば出来る子である。 
　　　　∩∩ 
　　　（´･ω･） 
　　 ＿|　⊃／(＿＿_ 
　／　└-(＿＿＿_／ 
　￣￣￣￣￣￣￣ 
　やる気はまだない 

　　 ⊂⌒／ヽ-、＿_ 
　／⊂_/＿＿＿＿ ／ 
　￣￣￣￣￣￣￣　　*/

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

using namespace std;

typedef unsigned int uint;
typedef long long int llint;
typedef unsigned long long int ullint;

//#define DEBUG

#ifdef DEBUG
#define dump(i) cout << "[*] " #i " : " << i << endl;
#define debug(i) i
#else
#define dump(i)
#define debug(i)
#endif
#define rep(i, max) for (int i = 0; i < (max); ++i)

inline void solve() {
  string s;
  cin >> s;
  int c[0xff] = {};
  for (char ch : s) {
    ++c[ch];
  }
  char small = 0;
  for (char ch = 'a'; ch <= 'z'; ++ch) {
    if (c[ch] == 0) {
      small = ch;
      break;
    }
  }

  if (small != 0) {
    cout << s << small << endl;
  } else {
    int in = 100;
    char moji;
    bool flag = false;
    for (int i = s.size() - 1; i >= 0; --i) {
      for (char j = s[i]; j <= 'z'; ++j) {
        if (c[j] == 0) {
          in = i;
          moji = j;
          flag = true;
          break;
        }
      }
      if (flag) { break; }
      c[s[i]] = 0;
    }

    if (flag) {
      for (int i = 0; i < in; ++i) {
        cout << s[i];
      }
      cout << moji << endl;
    } else {
      cout << -1 << endl;
    }
  }
}

int main() {
        /*
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        cout.tie(nullptr);
        //*/
#ifdef DEBUG
        clock_t _begin = clock();
#endif

        solve();

#ifdef DEBUG
        cerr << "[*] time : " << (double)(clock() - _begin) * 1000 / CLOCKS_PER_SEC << " [ms]" << endl;
#endif
        return 0;
}

Measured memory_bytes: 256
//include,namespace
 #include<bits/stdc++.h>
 #include<iostream> 
 #include <queue>
 #include <vector>
 #include <string>
 using namespace std;
//REPmacro
 #define all(x) (x).begin(),(x).end()             //ソート
 #define FOR(i,x,n)for(int i=(x);i<(n);i++)
 #define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
 #define REP(i, n) FOR(i, 0, n)
 #define REP_R(i, n) FOR_R(i, 0, n)
//long long(define)
 using ll = long long;
 typedef long long ll;
 typedef long long int64;
 typedef long long lint;
 typedef long long lli;

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
////////////////いろいろあるよ//////////////////////////////////
int main(){
    vector<int> data = {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 a;
  cin >> a;
    cout << data[a-1] << endl;
	return 0; 
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int m = max({A, B, C});
  int sum = (m - A) + (m - B) + (m - C);
  if (sum % 2 == 0) {
    cout << sum / 2 << endl;
  } else {
    cout << (sum + 3) / 2 << endl;
  }
  return 0;
}

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

using namespace std;

int main()
{
	int A[6], N, S, T;

	string com;

	while (true)
	{
		cin >> N;

		if (N == 0) { break; }

		A[0] = 1;
		A[1] = 2;
		A[2] = 3;
		A[3] = 5;
		A[4] = 4;
		A[5] = 6;

		S = 1;

		for (int i = 0; i < N; i++)
		{
			cin >> com;

			if (com == "North")
			{
				T = A[0];

				A[0] = A[1];
				A[1] = A[5];
				A[5] = A[3];
				A[3] = T;
			}

			if (com == "East")
			{
				T = A[0];

				A[0] = A[4];
				A[4] = A[5];
				A[5] = A[2];
				A[2] = T;
			}

			if (com == "West")
			{
				T = A[0];

				A[0] = A[2];
				A[2] = A[5];
				A[5] = A[4];
				A[4] = T;
			}

			if (com == "South")
			{
				T = A[0];

				A[0] = A[3];
				A[3] = A[5];
				A[5] = A[1];
				A[1] = T;
			}

			if (com == "Right")
			{
				T = A[1];

				A[1] = A[2];
				A[2] = A[3];
				A[3] = A[4];
				A[4] = T;
			}

			if (com == "Left")
			{
				T = A[1];

				A[1] = A[4];
				A[4] = A[3];
				A[3] = A[2];
				A[2] = T;
			}

			S += A[0];
		}

		cout << S << endl;
	}

	return 0;
}

Measured memory_bytes: 3148
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			if (n == 0 && m == 0)
				break;
			int[] book = new int[m];
			int sum = 0;
			for (int i = 0; i < m; i++) {
				book[i] = scanner.nextInt();
				sum += book[i];
			}
			int ave = sum / n - 1;
			loop: while (true) {
				int count = 0;
				ave++;;
				int s = ave;
				int i = 0;
				while (count != n) {
					if (i == m) {
						break loop;
					}
					if (s - book[i] >= 0) {
						s -= book[i];
						i++;
					} else {
						count++;
						s = ave;
					}
				}
			}
			System.out.println(ave);
		}
	}
}

Measured memory_bytes: 20956
s = input()
a = int(s[:2])
b = int(s[2:])
if 1<=a<=12 and 1<=b<=12:
  print("AMBIGUOUS")
elif 1<=a<=12:
  print("MMYY")
elif 1<=b<=12:
  print("YYMM")
else:
  print("NA")

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

#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

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

  while(scanf("%d",&n) != EOF){
    res = 0;
    rep(i,10) rep(j,10) rep(k,10) rep(l,10){
      if(i+j+k+l == n) res++;
    }

    printf("%d\n", res);
  }

  return 0;
}

Measured memory_bytes: 0
import java.util.*;
class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long total=0;
        for(int i=1; i<=N; i++){
            if(i%3 != 0 && i%5 != 0) total += i;
        }

        System.out.println(total);

    }

}

Measured memory_bytes: 35484
def is_bust(value):
    bust_value = 22
    return_value = ''

    if value >= bust_value:
        return_value = 'bust'
    else:
        return_value = 'win'

    return return_value
        
str = input().split()
a1 = int(str[0])
a2 = int(str[1])
a3 = int(str[2])

print(is_bust(a1 + a2 + a3))

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

int main() {
  string T; cin >> T;
  string ans;
  for (char t : T) {
    if (t == '?') {
      ans += 'D';
    } else {
      ans += t;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3924
import java.util.*;
import java.util.Arrays;
public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int [] a = new int[4];
    
        a[0] = n%10;
        n /=10;
        a[1] = n%10;
        n /=10;
        a[2] = n%10;
        n /=10;
        a[3] = n;
        int [] b = new int [4];
        for(int i=0;i<4;i++){
            b[i] = a[3-i];
        }
        
        


        int p=0;
        
        for(int i=0;i<3;i++){
            if(b[i]==b[i+1]){
                p = 1;
            }
            else if(b[2]==b[3]){
                p=1;
            }
             
            
        }
        if(p==1){
            System.out.println("Bad");
        }
        else {
            System.out.println("Good");

        }
    }
}

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

using db = double;
using ll = long long;
using vi = vector <int>;
#define op operator
#define pb push_back

int main() {
	ios :: sync_with_stdio(0);

	int a, b, n = 0; char c;
	int sum = 0, cnt = 0;
	while(cin >> a >> c >> b) {
		sum += a * b;
		cnt += b;
		n ++;
	}
	cout << sum << '\n';
	cout << int(round(db(cnt) / n)) << '\n';

	return 0;
}

Measured memory_bytes: 3176
#include<stdio.h>

int main(void){

    int a,b,ans;
    char op;

    while(1){
    scanf("%d %c %d",&a,&op,&b);
    if(op == '?')break;
    if(op == '+'){
        ans = a+b;
    }else if(op == '-'){
        ans = a-b;
    }else if(op == '*'){
        ans = a*b;
    }else if(op == '/'){
        ans =a/b;
    }
    printf("%d\n",ans);
    }
return 0;
}

Measured memory_bytes: 600
N, K = map(int, input().split())

if K % 2 == 1:
    div = N // K
    print(div**3)
else:
    div = N // K
    if div * K + K/2 <= N:
        print(div**3 + (div+1)**3)
    else:
        print(2 * div**3)


Measured memory_bytes: 2940
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    A, B = map(int, readline().split())

    if A <= 8 and B <= 8:
        print('Yay!')
    else:
        print(':(')

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9112
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
const long long INF = LLONG_MAX;
using namespace std;
using ll = long long;
using P  = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main()
{
    string s;
    int A, B;
    cin >> A >> B;
    cin >> s;
    if(s.size() != A+B+1)
    {
        cout << "No" << endl;
        return 0;
    }
    int p = s.find('-');
    if(p != A)
    {
        cout << "No" << endl;
        return 0;
    }
    rep(i, s.size()) 
    {
        if(i == A) continue;
        if(!(0 <= (s[i] - '0') && (s[i] - '0') <= 9)) 
        {
          cout << "No" << endl;
          return 0;
        }
    }
    // ll a = stoll(s.substr(0, A));
    // ll a = stoll(s.substr(0, A));
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
    int a, b, c; cin >> a >> b >> c;
    int k; cin >> k;
    while (a >= b) {
        b *= 2;
        k--;
    }
    while (b >= c) {
        c *= 2;
        k--;
    }
    if (0 <= k) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3588
N,M=map(int, input().split())
from collections import defaultdict
A=list(map(int, input().split()))
B=[]
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
# a 偶数
twos=0
D=defaultdict(int)
for i in range(N):
    B.append(A[i]//2)
    a=A[i]
    now=0
    while a%2==0:
        a//=2
        now+=1
    D[now]+=1
    twos=max(twos, now)
if len(set(D.values()))!=1:
    print(0)
    exit()
now=1
for i in range(N):
    now=lcm(now, B[i])

# 1.5 * 3 2*5
from math import ceil

ans=M//(now)-M//(now*2)


print(ans)

Measured memory_bytes: 94760
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    int r = sc.nextInt();
    int D = sc.nextInt();
    int x = sc.nextInt();

    for(int i=1; i<=10 ; i++ ){
      x = r*x-D;
      System.out.println(x);
    }
  }
}

Measured memory_bytes: 23764
//JSD
#include<iostream>
#include<vector>
#define ll long long
using namespace std;
ll counter[200001]={0};
vector<int > tree[200001];
bool visited[200001];
ll ans[200001]={0};
void dfs(int s,ll sum){
	visited[s]=1;
	ans[s]+=sum+counter[s];
	for(auto x: tree[s]){
		if(!visited[x]){
			dfs(x,sum+counter[s]);
		}
	}
}
int main(){
	int n,q;
	cin>>n>>q;
	for(int i=0;i<n-1;i++) {
		int u,v;
		cin>>u>>v;
		tree[u].push_back(v);
		tree[v].push_back(u);
	}
	while(q--){
		ll v,x;
		cin>>v>>x;
		counter[v]+=x;
	}
	dfs(1,0);
	for(int i=1;i<=n;i++){
		cout<<ans[i]<<" ";
	}
	return 0;
}

Measured memory_bytes: 25856
def main():
    S = input()
    T = input()
    ds = {}
    dt = {}
    for i, v in enumerate(S):
        if v in ds:
            ds[v].append(i)
        else:
            ds[v] = [i]
    for i, v in enumerate(T):
        if v in dt:
            dt[v].append(i)
        else:
            dt[v] = [i]
    for i in ds:
        l = ds[i]
        for j in dt:
            if l == dt[j]:
                break
        else:
            return 'No'
    return 'Yes'
print(main())


Measured memory_bytes: 20272
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
using namespace std;
int main(){
	int r;
	cin>>r;
	if(r<1200)cout<<"ABC"<<endl;
	else if(r<2800)cout<<"ARC"<<endl;
	else cout<<"AGC"<<endl;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;

alias Pair = Tuple!(int, "a", int, "b");

void main() {
    int N;
    scan(N);
    auto L = readln.split.to!(int[]).sort();

    long ans;

    foreach (i ; 0 .. N) {
        foreach (j ; i + 1 .. N) {
            ans += L[j + 1 .. $].lowerBound(L[i] + L[j]).length;
        }
    }

    writeln(ans);
}






void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

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

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 380
n, w = map(int, input().split())
weight = []
value = []
for _ in range(n):
    wi, vi = map(int, input().split())
    weight.append(wi)
    value.append(vi)
weight.append(0)
value.append(0)
dp = [[0] * (w + 1) for _ in range(n + 1)]
for i in range(n):
    for j in range(w + 1):
        if j - weight[i] >= 0:
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - weight[i]] + value[i])
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j])
print(dp[n][w])

Measured memory_bytes: 121068
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define MEMSET(a, n, x) REP(i, n) a[i]=x;
#define ARRIN(a, n) REP(i, n) cin>>a[i];
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;

struct point{
  LL x;
  LL y;
  bool operator<(const point &r) const {
    return x==r.x?y<r.y:x<r.x;
  };
};

int main(){
  int n;
  cin>>n;
  point po[n];
  LL t, u;
  REP(i, n){
    cin>>t>>u;
    po[i].x=t;
    po[i].y=u;
  }
  if(n<=2){
    cout<<1<<endl;
    return 0;
  }
  LL xt, yt, xw, yw, p, q;
  int ans=INF;
  sort(po, po+n);
  REP(i, n-1){
    FOR(j, i+1, n){
      p=(po[j].x-po[i].x);
      q=(po[j].y-po[i].y);
      int aw=n;
      REP(k, n-1){
        xw=po[k].x+p;
        yw=po[k].y+q;
        FOR(l, k+1, n){
          if(po[l].x==xw&&po[l].y==yw){
            --aw;
            break;
          }
        }
      }
      ans=min(ans, aw);
    }
  }

  ECHO(ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define maxn 1000009
using namespace std;
int n,m;
char s[maxn];
int main(){
    cin>>n>>m;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            scanf("%s",s);
            if(strcmp(s,"snuke")==0){
                printf("%c%d\n",j-1+'A',i);
                //system("pause");
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

def dev(a):
    li = []
    i = 1
    while(i*i<=a):
        if a%i==0:
            li.append(i)
            li.append(a//i)
        i+=1
    return li

#def prime(i):
    


a,b = map(int,input().split())

c = gcd(a,b)
d = dev(c)
d.sort()
e=str(d)
for i in range(1,len(d)):
    if d[i] != 1:
        for j in range(i+1,len(d)):
            if d[j]%d[i]==0:
                d[j] = 1
            
            
ans = 1
for i in range(len(d)):
    if d[i] != 1:
        ans += 1

print(ans)

Measured memory_bytes: 3316