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

int main(){
  int n,x;
  cin >> n >> x;
  vector<int> p(n);
  for(int i = 0; i < n; i++){
    cin >> p[i];
  }
  int d = 0;
  int ans = 1;
  for(int i = 0; i < n; i++){
    d += p[i];
    if(d > x){
      cout << ans << endl;
      return 0;
    }
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

void solve()
{
	int e;
	while(cin >> e, e)
	{
		int min_val = 999999999;
		for(int z = 0; z <= 100; ++z)
		{
			if(e < z * z * z)
			{
				break;
			}
			for(int y = 0; y <= 1000; ++y)
			{
				int temp = z * z * z + y * y;
				if(e < temp)
				{
					break;
				}
				int x = e - temp;
				min_val = min(min_val, x + y + z);
			}
		}
		cout << min_val << endl;
	}
}

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

Measured memory_bytes: 1160
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: i32 = read();
    let sum: i32 = n.to_string().chars().map(|c| c as i32 - 48).sum();
    println!("{}", if n % sum == 0 { "Yes" } else { "No" });
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include<stdio.h>

int main(){
	int k, len = 0;
	char str[100];
	scanf("%d %s", &k, str);
	for(int i = 0; str[i] != '\0'; i++){
		len++;
	}
	if(len <= k){
		printf("%s\n", str);
	}
	else{
		for(int i = k; i <= k + 3; i++){
			if(i < k + 3){
				str[i] = '.';
			}
			else{
				str[i] = '\0';
			}
		}
		printf("%s\n", str);
	}
	return 0;
}

Measured memory_bytes: 1624
#include<iostream>
using namespace std;
int main(){
  int N,a,b,c;
  
  while( cin >> N ){
    for(int i=0;i<N;i++){
      cin >> a >> b >> c;
      if(a*a==b*b+c*c || b*b==a*a+c*c || c*c==a*a+b*b){
	cout << "YES"<< endl;
      }
      else{
	cout << "NO"<< endl;}
    }
    break;
  }

    
  return 0;
}

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


int main() {
    ll n,m;
    cin >> n >> m;
    vector<int> a(n+1,1);
    rep(i,m){
        ll ai;
        cin >> ai;
        a[ai] = false;
    }
    vector<ll> dp(n+1);
    dp[0] = 1;
    for(ll now = 0;now<n;now++){
        for(ll next = now+1;next <= min(n,now+2);next++){
            if(a[next]){
                dp[next] += dp[now];
                dp[next] %= MOD;
            }
        }
    }
    cout << dp[n];
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 1408
import java.util.Scanner;

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

    		double r=sc.nextDouble();


    		double ans1=r*r*Math.PI;
    		double ans2=r*2*Math.PI;

    		System.out.printf("%.6f %.6f\n",ans1,ans2);

    		}
    		}
    		


Measured memory_bytes: 28332
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <ctime>
#include <algorithm>
#define N 301000
template <typename T> inline void read(T &x) {
	x = 0; char c = getchar(); bool flag = false;
	while (!isdigit(c)) { if (c == '-')	flag = true; c = getchar(); }
	while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); }
	if (flag)	x = -x;
}
using namespace std;
inline void MIN(int &a, int b) {
	if (b < a)	a = b;
}
int n;
int h[N], sum[N];
namespace jzp1 {
	inline void sol() {
		for (int i = 1; i <= n; ++i)	read(h[i]);
		int tmp1 = 0, tmp2 = 0;
		for (int i = 1; i <= n; i += 2) {
			tmp1 += h[i], tmp2 += h[i + 1];
		}
		printf("%d %d\n", max(tmp1, tmp2), min(tmp1, tmp2));
	}
}

inline bool che(int k) {
	int tmp = 0;
	for (int i = 1; i <= n; ++i) if (i & 1) {
		if (sum[i] - tmp >= k) {
			MIN(tmp, sum[i + 1]);
		} else if (i == n)	return false;
	}
	return true;
}

int main() {
	read(n);
	if (n % 2 == 0) {
		jzp1::sol();
		return 0;
	}
	int r = 0, tot = 0, totsum = 0;
	for (int i= 1; i <= n; ++i) read(h[i]), r += h[i], totsum += h[i];
	for (int i = 1; i <= n; ++i) {
		if (i & 1)	sum[i] = sum[i - 1] + h[i];
		else	sum[i] = sum[i - 1] - h[i], tot += h[i];
	}
	int l = -r, res = 0;
	while (l <= r) {
		int mid = (l + r) >> 1;
		if (che(mid))	res = mid, l = mid + 1;
		else	r = mid - 1;
	}
	printf("%d %d\n", res + tot, totsum - (res + tot));
	return 0;
}

/*
5
20 100 10 1 10
//120 21

6
4 5 1 1 4 5
//11 9

5
1 10 100 10 1
//102 20
*/

Measured memory_bytes: 5548
S_ = input()
T = input()


def check(S1, S2):
    for i in range(len(S1)):
        if S1[i] == S2[i] or S1[i] == "?":
            continue
        else:
            return(False)

    return(True)


ans_list = []
for i in reversed(range(len(S_) - len(T) + 1)):
    result = check(S_[i:i+len(T)], T)
    if result:
        ans = list(S_)
        for j in range(len(T)):
            ans[i+j] = T[j]
        for j in range(len(ans)):
            if ans[j] == "?":
                ans[j] = "a"
        ans_list.append("".join(ans))

if len(ans_list) == 0:
    print("UNRESTORABLE")
else:
    print(min(ans_list))


Measured memory_bytes: 3064
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (h, w) = (v[0], v[1]);
    let mut grid = vec![];
    for _ in 0..h {
        let s = read::<String>()
            .chars()
            .map(|x| x == '#')
            .collect::<Vec<_>>();
        grid.push(s);
    }

    let white_count = grid.iter()
        .map(|ref colomn| colomn.iter().map(|&x| if !x { 1 } else { 0 }).sum::<i32>())
        .sum::<i32>();

    let mut que = VecDeque::new();
    que.push_back((1, (0, 0)));
    let mut checked = HashSet::new();
    while let Some((step, pos)) = que.pop_front() {
        let (x, y) = pos;
        if checked.contains(&(x, y)) {
            continue;
        }
        checked.insert((x, y));

        if (x, y) == (w - 1, h - 1) {
            println!("{}", white_count - step);
            return;
        }

        for (next_x, next_y) in get_adjacents(x, y, w, h) {
            if grid[next_y][next_x] || checked.contains(&(next_x, next_y)) {
                continue;
            }
            que.push_back((step + 1, (next_x, next_y)));
        }
    }
    println!("-1");
}

fn get_adjacents(x: usize, y: usize, w: usize, h: usize) -> Vec<(usize, usize)> {
    let mut adjacents = vec![];
    if x > 0 {
        adjacents.push((x - 1, y));
    }
    if y > 0 {
        adjacents.push((x, y - 1));
    }
    adjacents.push((x, y));
    if y < h - 1 {
        adjacents.push((x, y + 1));
    }
    if x < w - 1 {
        adjacents.push((x + 1, y));
    }
    adjacents
}

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

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


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  int control_cnt;
  int val = 1;
  cin >> N >> K;
  
  while(control_cnt < N){
    int K1,K2;
    K1 = val * 2;
    K2 = val + K;
    if(K1 <= K2){
      val = K1;
    }else{
      val = K2;
    }
    control_cnt++;
  }
  cout << val << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int kiC = 0;
		for(int i = 0; i < n; i++) {
			long a = sc.nextLong();
			if(a%2==1) {
				kiC++;
			}
		}
		System.out.println(kiC%2==0 ? "YES" : "NO");
	}
}

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

const int MAXN = 1e6+5;
bool vis[MAXN];

int main() {
   long long k;
   cin >> k;

   long long ans = -1;
   long long sum = 0;

   for(int i = 1; i <= k; ++i)
   {
       sum = ((sum * (10 % k)) % k + 7 % k) % k;

       if(vis[sum])
        break;
       else if(sum == 0)
       {
            ans = i;
            break;
       }

       vis[sum] = true;
   }

   cout << ans << endl;

    return 0;
}


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

int main(){
    string S;cin>>S;
    int N=S.size();
    char p=S.at(0);
    int count=0;
    for(int i=0;i<N;i++){
        if(S.at(i)!=p){
            count++;
            p=S.at(i);
        }
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
#define db(x) cout<<#x<<"="<<x<<endl
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //y1 j0 j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
#define EPS 1e(-9);
using namespace std;
typedef long long ll;



void Main(){

    int N; cin>>N;

    int d[N];

    rep(i,N){
        cin>>d[i];
    }

    ll ans=0;

    rep(i,N){
        reps(j,i+1,N){
            ans+=d[i]*d[j];
        }
    }

    cout<< ans<<"\n";
}

//-----------------------------------
int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------


Measured memory_bytes: 256
n, m = map(int, input().split())
h_list = list(map(int, input().split()))
m_dic = {}
for i in range(1, n+1):
    m_dic[i] = []
for i in range(m):
    a, b = map(int, input().split())
    m_dic[a].append(b)
    m_dic[b].append(a)

ans = 0
for i in range(1, n+1):
    good = True
    for j in m_dic[i]:
        if h_list[i-1] <= h_list[j-1]:
            good = False
            break
    if good: ans += 1
print(ans)

Measured memory_bytes: 37788
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main() {
	ll n, m, k;
	cin >> n >> m >> k;
	ll flag = 0;
	rep(i, 0, n + 1) {
		rep(j, 0, m + 1) {
			ll a = i * m;
			ll b = j * n;
			ll c = i * j;
			ll d = a + b - c*2;
			if (d == k)flag = 1;
		}
	}
	if (flag == 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}








Measured memory_bytes: 256
def check(n, D):
    N = []
    while n != 0:
        N.append(n % 10)
        n //= 10
    for d in D:
        if d in N:
            return False
    return True

if __name__ == '__main__':
    n, k = [int(x) for x in input().split(' ')]
    D = [int(x) for x in input().split(' ')]
    res = n
    while True:
        if check(res, D):
            break
        else:
            res += 1
    print(res)
    

Measured memory_bytes: 9112
// ABC157B - Bingo

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

int main() {
	int A[3][3];

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> A[i][j];
		}
	}

	int N;
	cin >> N;

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

	bool answer = false;
	sort(b.begin(), b.end());

	for (int i = 0; i < 3; i++) {
		if (binary_search(b.begin(), b.end(), A[i][0])
		  &&binary_search(b.begin(), b.end(), A[i][1])
		  &&binary_search(b.begin(), b.end(), A[i][2])) {
			answer = true;
		}
	}
	for (int i = 0; i < 3; i++) {
		if (binary_search(b.begin(), b.end(), A[0][i])
		  &&binary_search(b.begin(), b.end(), A[1][i])
		  &&binary_search(b.begin(), b.end(), A[2][i])) {
			answer = true;
		}
	}
	if (binary_search(b.begin(), b.end(), A[0][0])
	  &&binary_search(b.begin(), b.end(), A[1][1])
	  &&binary_search(b.begin(), b.end(), A[2][2])) {
		answer = true;
	}
	if (binary_search(b.begin(), b.end(), A[0][2])
	  &&binary_search(b.begin(), b.end(), A[1][1])
	  &&binary_search(b.begin(), b.end(), A[2][0])) {
		answer = true;
	}

	if (answer) {
		cout << "Yes";
	} else {
		cout << "No";
	}
}


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()
{
    vector<int> dp(10030,-1);
    int n, m;
    cin >> n >> m;
    vector<int> a(m),use={0,2,5,5,4,5,6,3,7,6};
    rep(i,m){
        cin >> a[i];
    }
    sort(a.rbegin(), a.rend());
    for(auto e:a){
        dp[use[e]]=1;
    }
    dp[0] = 0;
    rep(i,n+1){
        if(dp[i]==-1)
            continue;
        for(auto e:a){
            dp[i + use[e]] = max(dp[i] + 1, dp[i + use[e]]);
        }
    }
    string ans;
    int remain = dp[n];
    int match = n;
    while(match > 0){
        for(auto e: a){
            if(match<use[e])
                continue;
            if(dp[match-use[e]]==remain-1){
                match -= use[e];
                remain--;
                ans += char('0'+e);
                break;
            }
        }        
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
l = [0] * 4

for i in range(n):
    ans = input()
    if ans == 'AC':
        l[0] += 1
    elif ans == 'WA':
        l[1] += 1
    elif ans == 'TLE':
        l[2] += 1
    elif ans == 'RE':
        l[3] += 1

print('AC x '+ str(l[0]))
print('WA x '+ str(l[1]))
print('TLE x '+ str(l[2]))
print('RE x '+ str(l[3]))

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

int main() {
	int n; scanf("%d", &n);
	int cnt = 0;
	while (n--) {
		int d; scanf("%d", &d);
		for (int i = 1; i*i <= d; i++)if ((d - i) % (2 * i + 1) == 0)goto g;
		cnt++; g:;
	}
	printf("%d\n", cnt);
}

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

struct UnionFind{
    vector<int> par;
    UnionFind(int N) : par(N){
        for(int i = 0; i < N; i++){
            par[i] = -1;
        }
    }
    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        else{
            if(par[rx] > par[ry]) swap(rx, ry);
            par[rx] += par[ry];
            par[ry] = rx;
        }
    }
    bool same(int x, int y){
        return root(x) == root(y);
    }
    void check(){
        for(auto x : par){
            cout << x << " ";
        }
        cout << endl;
    }
};

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

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

    UnionFind Uf(12);
    vector<int> A = {1, 3, 5, 7, 8, 10, 12};
    vector<int> B = {4, 6, 9, 11};
    vector<int> C = {2};
    REP(i, A.size()) A[i]--;
    REP(i, B.size()) B[i]--;
    REP(i, C.size()) C[i]--;

    REP(i, A.size() - 1){
        Uf.unite(A[0], A[i + 1]);
    }
    REP(i, B.size() - 1){
        Uf.unite(B[0], B[i + 1]);
    }

    cout << (Uf.same(x - 1, y - 1) ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import Counter


def solve(N, As):
    counter = Counter(As)
    if len(counter) % 2 == 0:
        return len(counter) - 1
    return len(counter)

if __name__ == "__main__":
    N = int(input())
    As = list(map(int, input().split(" ")))
    print(solve(N, As))


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

template<class T>inline bool chmax(T &a, const T &b) { if (b > a) { a = b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

template<class T>
class SegmentTree {
    using Func = std::function<T(T, T)>;
    private:
        const Func F;
        const T DEF;
        int N;
        std::vector<T> dat;
    public:
        SegmentTree(int n, const Func f, const T def) : F(f), DEF(def) {
            N = 1;
            while (N < n) N *= 2;
            dat.assign(2*N, DEF);
        }
        // a is 0-indexed
        void set(int a, const T v) { dat[a+N] = v; }
        void build() { for (int i=N-1; i>0; --i) dat[i] = F(dat[2*i], dat[2*i+1]); }
        // a is 0-indexed
        void update(int a, const T v) {
            int cur = a + N;
            dat[cur] = v;
            while ((cur /= 2) > 0) dat[cur] = F(dat[2*cur], dat[2*cur+1]);
        }
        // return value of [a, b)
        // a and b are 0-indexed
        T get(int a, int b) const { return get(a, b, 1, 0, N); }
        T get(int a, int b, int k, int l, int r) const {
            if (b <= l || r <= a) return DEF;
            if (a <= l && r <= b) return dat[k];
            T vleft = get(a, b, 2*k, l, (l+r)/2);
            T vright = get(a, b, 2*k+1, (l+r)/2, r);
            return F(vleft, vright);
        }
        // a is 0-indexed
        T at(int a) const { return dat.at(a+N); }
};

void solve() {
    int N;
    cin >> N;
    vector<int> h(N), a(N);
    for (int i=0; i<N; ++i) cin >> h[i];
    for (int i=0; i<N; ++i) cin >> a[i];

    for (int i=0; i<N; ++i) --h[i];
    SegmentTree<ll> st(N, [](ll a, ll b){return max(a, b);}, 0);
    for (int i=0; i<N; ++i) st.update(h[i], st.get(0, h[i]) + a[i]);
    cout << st.get(0, N) << '\n';
}

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

    solve();

    return 0;
}


Measured memory_bytes: 8996
#include <iostream>

#include <vector>

#include <algorithm>

#include <cstdio>

#include <cmath>

#include <cstdlib>

#include <ctime>

#include <cctype>

#include <cstring>

#include <utility>

#include <map>

using namespace std;

typedef pair<int,int> P;

typedef long long ll;

int main()

{

    int n;

    

    cin>>n;

    

    

    cout<< n*n*n<<endl;

    return 0;

}



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

class Main {
    public static void main(String[] args){
    	 Scanner sc = new Scanner(System.in);
         String s = sc.nextLine();
         int inP = 700;
         for(int i=0;i<s.length();i++){
            if(s.charAt(i)=='o'){
                inP+=100;
            }else{
                continue;
            }
         }
         System.out.println(inP);
    }    
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define lp(n) for(int i = 0; i < n; i++)
#define LP(i, a, n) for(int i = a; i < n; i++)
#define lpp(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef struct node node;
int main() {
  int n, q, b, c=0;
  int a[100000];
  cin >> n;
  lp(n) cin >> a[i];
  cin >> q;
  lp(q) {
    cin >> b;
    if(binary_search(begin(a), begin(a) + n, b)) c++;
  }
  cout << c << endl;
  return 0;
}




Measured memory_bytes: 3484
a,b,c,d = map(int, input().split())

while True:
    c -= b
    if c <= 0:
        flag = True
        break
    a -= d
    if a <= 0:
        flag = False
        break
if flag:
    print("Yes")
else:
    print("No")

# a_turn = a / d
# b_turn = c / b

# if a_turn % 1 == 0:
#     a_turn = a // b
# else:
#     a_turn = (a//b) + 1

# if b_turn % 1 == 0:
#     b_turn = c // b
# else:
#     b_turn = (c // b) + 1

# if a_turn == b_turn:
#     print("Yes")
# else:
#     if a_turn > b_turn:
#         print("Yes")
#     else:
#         print("No")


Measured memory_bytes: 8984
while True:
	a,op,b = input().split()
	a=int(a)
	b=int(b)
	if op=='?':break
	elif op=='+':print(a+b)
	elif op=='-':print(a-b)
	elif op=='*':print(a*b)
	elif op=='/':print(a//b)


Measured memory_bytes: 5592
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
#include<cstring>
#include<set>
using namespace std;
using ll = long long;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define all(x) (x).begin(),(x).end()
const ll mod = 1e9+7;
const int INF = 1e9;
const ll INFLONG = 1e18;
ll a[110];
vector<ll> vec;
ll sum=0;
ll len;
void emb(ll n){
  if(n == 1){return;}
  for(ll i=2;i<=n-1;i++){
    if(n % i == 0){
      emb(n/i);
      emb(i);
      return;
    }
  }
  a[n]++;
}
void dp(ll n,ll x){
  if(n >= len){return;}
  if(x == 1){sum++;return;}
  if(vec[n] >= 3){
    if(x%3==0)
    dp(n+1,x/3);
  }
  if(vec[n] >= 5){
    if(x%5==0)
    dp(n+1,x/5);
  }
  if(vec[n] >= 15){
    if(x%15==0)
    dp(n+1,x/15);
  }
  if(vec[n] >= 25){
    if(x%25==0)
    dp(n+1,x/25);
  }
  if(vec[n] >= 75){
    if(x%75==0)
    dp(n+1,x/75);
  }
  dp(n+1,x);
}
int main(){
  ll n;
  cin >> n;
  memset(a,0,sizeof(a));
  rep(i,n){
    emb(i+1);
  }
  rep(i,n){
    if(a[i] != 0){
      vec.push_back(a[i]+1);
      //cout << a[i]+1 << " ";
    }
  }
  //cout << endl;
  len = vec.size();
  dp(0,75);
  cout << sum;
}


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  map<int,int> mp;  
  for(int i = 0; i < n; ++i){
    int x; cin >> x;
    for(int j = -1; j <= 1; ++j){
      mp[x+j]++;
    }
  }
  int ans = 0;
  for(auto e:mp)ChangeMax(ans,e.second);
  cout << ans << endl;
}



Measured memory_bytes: 7880
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
  int n;
  int a[100005],b[100005],c[100005];
  int dp[4][100005];
  
  cin >> n;
  for(int i=0; i<n; i++) cin >> a[i] >> b[i] >> c[i];
 
  dp[1][0] = a[0];
  dp[2][0] = b[0];
  dp[3][0] = c[0];

  for(int i=1; i<n; i++){
    dp[1][i] = max(dp[2][i-1], dp[3][i-1]) + a[i];
    dp[2][i] = max(dp[1][i-1], dp[3][i-1]) + b[i];
    dp[3][i] = max(dp[1][i-1], dp[2][i-1]) + c[i];
  }

  int ans = max(dp[1][n-1],dp[2][n-1]);
  cout << max(ans,dp[3][n-1]) << endl;
  return 0;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll gcd(ll a,ll b)
{
    if (a == 0) 
       return b; 
    if (b == 0) 
       return a; 
   
    // base case 
    if (a == b) 
        return a; 
   
    // a is greater 
    if (a > b) 
        return gcd(a-b, b); 
    return gcd(a, b-a);

}
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  
    ll n;
  cin>>n;
  ll i,j,k;
  ll s=0,g=0;
  for(i=1;i<=n;i++)
  {g=i;
    for(j=1;j<=n;j++)
  {g=gcd(j,i);
      for(k=1;k<=n;k++)
  {s+=gcd(g,k);
      //cout<<gcd(g,k)<<" "<<i<<j<<k<<"\n";
  }}}
      
      cout<<s;
return 0;}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;
using namespace std;

int main() {
  ll x, y;
  cin >> x >> y;
  ll n = x;
  for (int i = 1;; i++) {
    if (n > y) {
      cout << i - 1 << endl;
      break;
    } else
      n *= 2;
  }
}

Measured memory_bytes: 256
n,m = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(m)]

from operator import itemgetter
AB.sort(key = itemgetter(1))

temp = 0
ans = 0
for a,b in AB:
    if b != temp and a >= temp:
        ans += 1
        temp = b
print(ans)

Measured memory_bytes: 29204
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            int iM = int.Parse(sS[1]);
            List<int> lstL = new List<int>();
            List<int> lstR = new List<int>();
            for (int i = 0; i < iM; i++)
            {
                sS = System.Console.ReadLine().Trim().Split(' ');
                lstL.Add(int.Parse(sS[0]));
                lstR.Add(int.Parse(sS[1]));
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = lstR.Min() - lstL.Max() + 1;
            if (iOut < 0) { iOut = 0; }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


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

int n, A[30];

int solve(int i, int m){
    if(m == 0){
        return true;
    }
    if( i>= n){
        return false;
    }
    
    int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return res;
}

int main(){
    int q, M;
    
    scanf("%d", &n);
    for(int i=0; i<n; i++){
        scanf("%d", &A[i]);
    }
    
    scanf("%d", &q);
    for(int j=0; j<q; j++){
        scanf("%d", &M);
        
        if(solve(0, M)){
            printf("%3s", "yes\n");
        }else{
            printf("%2s", "no\n");
        }
    }
    return 0;
}



Measured memory_bytes: 3232
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000
int c[N];
int n, x, y;

int find(int z) {
	int l = -1;
	int r = N;
	int m;
	while ((l + 1) < r) {
		m = (l + r) / 2;
		if (c[m] >= z)l = m;
		else r = m;
	}
	return r;
}


int main() {
	f(i, N)c[i] = -1;
	scanf("%d", &n);
	f(i, n) {
		scanf("%d", &x);
		y = find(x);
		c[y] = x;
	}
	x = 0;
	f(i, N) if (c[i] >= 0)x++;
	printf("%d\n", x);

	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <stack>
#include <vector>
using namespace std;
int r, c, n;
struct Node {
	int dis;
	int sign;
	Node(int _dis, int _sign) {
		dis = _dis, sign = _sign;
	}
};
vector<Node> vec[5];

int judge(int x, int y) {
	if(x == 0) return 1;
	else if(y == c) return 2;
	else if(x == r) return 3;
	else if(y == 0) return 4;
	else return 0;
}

bool cmp1(Node a, Node b) {
	return a.dis < b.dis;
}

bool cmp2(Node a, Node b) {
	return a.dis > b.dis;
}

int main() {
	while(~scanf("%d%d%d", &r, &c, &n)) {
		for(int i = 1; i <= 4; i++) {
			vec[i].clear();
		}
		for(int i = 1; i <= n; i++) {
			int x1, y1, x2, y2;
			scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
			if(judge(x1, y1) == 0 || judge(x2, y2) == 0) continue;
			switch(judge(x1, y1)) {
				case 1: {
					Node node(y1, i);
					vec[1].push_back(node);
					break;
				}	
				case 2: {
					Node node(x1, i);
					vec[2].push_back(node);
					break;
				}
				case 3: {
					Node node(y1, i);
					vec[3].push_back(node);
					break;
				}
				case 4: {
					Node node(x1, i);
					vec[4].push_back(node);
					break;
				}
				case 0:
					break;
				default:
					break;
			}
			switch(judge(x2, y2)) {
				case 1: {
					Node node(y2, i);
					vec[1].push_back(node);
					break;
				}	
				case 2: {
					Node node(x2, i);
					vec[2].push_back(node);
					break;
				}
				case 3: {
					Node node(y2, i);
					vec[3].push_back(node);
					break;
				}
				case 4: {
					Node node(x2, i);
					vec[4].push_back(node);
					break;
				}
				case 0:
					break;
				default:
					break;
			}
		}
		sort(vec[1].begin(), vec[1].end(), cmp1);
		sort(vec[2].begin(), vec[2].end(), cmp1);
		sort(vec[3].begin(), vec[3].end(), cmp2);
		sort(vec[4].begin(), vec[4].end(), cmp2);
		stack<int> box;
		while(!box.empty()) box.pop();
		for(int i = 0; i < vec[1].size(); i++) {
			if(!box.empty()) {
				if(box.top() == vec[1][i].sign) {
					box.pop();
				}
				else {
					box.push(vec[1][i].sign);
				}
			}
			else {
				box.push(vec[1][i].sign);
			}
		}
		for(int i = 0; i < vec[2].size(); i++) {
			if(!box.empty()) {
				if(box.top() == vec[2][i].sign) {
					box.pop();
				}
				else {
					box.push(vec[2][i].sign);
				}
			}
			else {
				box.push(vec[2][i].sign);
			}
		}
		for(int i = 0; i < vec[3].size(); i++) {
			if(!box.empty()) {
				if(box.top() == vec[3][i].sign) {
					box.pop();
				}
				else {
					box.push(vec[3][i].sign);
				}
			}
			else {
				box.push(vec[3][i].sign);
			}
		}
		for(int i = 0; i < vec[4].size(); i++) {
			if(!box.empty()) {
				if(box.top() == vec[4][i].sign) {
					box.pop();
				}
				else {
					box.push(vec[4][i].sign);
				}
			}
			else {
				box.push(vec[4][i].sign);
			}
		}
		if(box.empty()) puts("YES");
		else puts("NO");
	}
	return 0;
}

Measured memory_bytes: 2520
#include <iostream>
using namespace std;
int main() {
    int N, sum = 0, i = 1;
    cin >> N;
    for (; i <= N; i++) {
        sum += i;
        if (sum >= N) break;
    }
    for (int j = 1; j <= i; j++) if (j != sum - N) cout << j << endl;
}


Measured memory_bytes: 256
n,t = map(int,input().split())
ct = [list(map(int,input().split())) for i in range(n)]
ans = 10**4
for i in ct:
    if i[1] <= t:
        ans = min(ans,i[0])
if ans == 10**4:
    print("TLE")
else:
    print(ans)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

int main(){

    string ans = "NO";
    string s;
    cin >> s;
    ll a = 0, b = 0, c = 0, N = s.size();
    rep(i, N){
        if(s[i] == 'a')a++;
        if(s[i] == 'b')b++;
        if(s[i] == 'c')c++;
    }
    if(abs(a - b) < 2 && abs(a - c) < 2 && abs(b - c) < 2)ans = "YES";
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<math.h>
#include<string.h>
using namespace std;

int seiyaku_check(long i,long Min,long Max){
	if(Min <= i && i <= Max){
		return 1;
	}else{
		exit(1);
		//return 0;
	}
}

int main(){
	
	string date;
	
	cin >> date;
	
	if(date <= "2019/04/30"){
		cout << "Heisei" << endl;
	}else{
		cout << "TBD" << endl;
	}
	
return 0;
}


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

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

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

const double eps = 1e-10;

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

const int64 mod = 1e9+7;

using Row = vector<int64>;
using Mat = vector<Row>;


int64 dp[112345][3] = {};
int main(void){
	int32 N;
	cin >> N;
	REP(i, N){
		int32 a[3];
		REP(j, 3) cin >> a[j];
		dp[i+1][0] = max(dp[i][1], dp[i][2])+a[0];
		dp[i+1][1] = max(dp[i][0], dp[i][2])+a[1];
		dp[i+1][2] = max(dp[i][1], dp[i][0])+a[2];
	}
	cout << max({dp[N][0], dp[N][1], dp[N][2]}) << endl;
}


Measured memory_bytes: 2560
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 200000
typedef long long i64;

i64 n;
i64 a[5];

int input() {
	if (scanf("%lld", &n) < 0) return 0;
	for (int i=0; i<5; i++)
		if (scanf("%lld", &a[i]) < 0) return 0;
	return 1;
}

void init() {
}

i64 solve() {
	int k =0;
	for (int i=0; i<5; i++)
		if (a[i] < a[k]) k = i;
	return 4 + (n + a[k] - 1)/ a[k];
}

void output(i64 ans) {
	printf("%lld\n", ans);
}

void cleanup() {
}

int main() {
	//precalc();
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}




Measured memory_bytes: 128
#include <stdio.h>

int main(){
    int n;
    int a[200];

    int i;
    scanf("%d", &n);
    for(i=0; i<n; i++){
        scanf("%d", &a[i]);
    }
    for(i=n-1; i>0; i--){
        printf("%d ", a[i]);
    }
    printf("%d\n", a[0]);
    
}



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

int main(){

  int W,H,x,y,r;

  cin >> W >> H >> x >> y >> r;

  if( x+r <= W && y+r <= H && x-r >= 0 && y-r >= 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}



Measured memory_bytes: 3112
#include <stdio.h>

int main(void) {
	int a,b;
	scanf("%d%d",&a,&b);
	if(a==1&&b==1)printf("Yes");
	else if(a==3&&b==1)printf("Yes");
	else if(a==1&&b==3)printf("Yes");
	else if(a==3&&b==3)printf("Yes");
	else printf("No");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  int N;
   cin >> N;
  int ans = 0;
  for(int i = N ;i > 0;i--){
    int an = 0;
    for(int j = 1;j < i+1 ;j++){
      if(i%j == 0) an++;
      if(an == 8 && i%2 == 1) ans++;
    }
  }
  cout << ans << endl;
  
  
}


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

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

    ll n;
    cin>>n;
    map<ll,ll> mp;
    for(int i=0;i<n;i++){
        ll d;
        cin>>d;
        mp[d]++;
    }
    ll m;
    cin>>m;
    if(m>n){
        cout<<"NO"<<endl;
        return 0;
    }
    ll t;
    for(int i=0;i<m;i++)
    {
        cin>>t;
        mp[t]--;
        if(mp[t]<0){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;

 
}

Measured memory_bytes: 12800
S = input()

## 0を基準として、0と1の境目を調べる
boundary = []
pre_state = '0'
for i in range(len(S)):
  if S[i] != pre_state:
    boundary.append(i)
    pre_state = S[i]
else:
  if S[-1] == '1':
    boundary.append(len(S))
    
if len(boundary) == 0:
  print(len(S))
  exit()
    
## 答えは、端から一番遠い境目
lst = []
for i in range(len(boundary)):
  lst.append(max(boundary[i], len(S)-boundary[i]))
ans = min(lst)
print(ans)


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

int main(){
  int l,r,d;
  cin >> l >> r >> d;
  r = r/d*d;
  if(l%d==0){
    cout << (r-l)/d+1 << endl;
    return 0;
  }
  else {
    cout << r/d-l/d << endl;
    return 0;
  }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const ll MOD = 1000000007;

int main() {
    ll N,M;
    int a=1;
    string ans;
    cin >> N >> M;
    if(N==1) ans="a";
    else if(N==2) ans="aa";
    else if(N==3) ans="aaa";
    vector<int> s(M),c(M);

    for (int i = 0; i < M; i++) {
        cin >> s.at(i) >> c.at(i);
        if(ans.at(s.at(i)-1)!='a'&&
        ans.at(s.at(i)-1)!=('0' + c.at(i))) a=0;
        ans.at(s.at(i)-1) = '0' + c.at(i);
    }

    if(N==1){
       if(ans=="a") ans="0";
    }
    else if(N==2){
       if(ans.at(0)=='a') ans.at(0)='1';
       if(ans.at(1)=='a') ans.at(1)='0';
       if(ans.at(0)=='0') a=0;
    }
    else if(N==3){
       if(ans.at(0)=='a') ans.at(0)='1';
       if(ans.at(1)=='a') ans.at(1)='0';
       if(ans.at(2)=='a') ans.at(2)='0';
       if(ans.at(0)=='0') a=0;
    }

    if(a==0) cout << -1 << endl;
    else cout << ans << endl;
}

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

int main() {
    char b; cin >> b;
    if (b == 'A') {
        cout << 'T' << endl;
    }
    else if (b == 'C') {
        cout << 'G' << endl;
    }
    else if (b == 'G') {
        cout << 'C' << endl;
    }
    else {
        cout << 'A' << endl;
    }
}

Measured memory_bytes: 256
#include "iostream"
#include "vector"
#include "array"
#include "string"
#include "algorithm"
#include "queue"

using namespace std;

#define REP(i,j) for(int i = 0;i < j; i++)
const int INF = 1 << 30;
//303

int sum[1000];
int  dp[1000][1001], c[1000], w[1000], ans[1001];   //dp:[left,right)をまとめられるか
int getSum(int left, int right) { // [left, right)
	if (left == 0) return sum[right - 1];
	return sum[right - 1] - sum[left - 1];
}

int main(void) {
	int n;
	cin >> n;
	REP(i, n) {
		cin >> c[i] >> w[i];
		REP(j, n) {
			dp[i][j] = false;
		}
		sum[i] = w[i];
		if (i != 0) sum[i] += sum[i - 1];
	}

	REP(i,n) dp[i][i + 1] = true;

	for (int i = 2; i <= n; i++) { //区間長i
		for (int left = 0; left + i <= n; left++) { //左端から順々にいく
			int right = left + i;
			if (dp[left][right - 1]) { //rightの左側でまとまっている人を持ち上げられるか
				long long weight = getSum(left, right - 1);
				dp[left][right] |= c[right - 1] >= weight;
			}
			if (dp[left + 1][right]) { //leftの右側でまとまっている人を持ち上げられるか
				long long weight = getSum(left + 1, right);
				dp[left][right] |= c[left] >= weight;
			}
		}
		
	}
	for (int i = 0; i <= n; i++) ans[i] = INF;

	ans[0] = 0;

	REP(i, n) {
		for (int j = i + 1; j <= n; j++) { //ans[i]:i番目の人間までで何人歩いているか
			if (dp[i][j]) ans[j] = min(ans[j],ans[i]+1); 
		}
	}
	cout << ans[n] << endl;
}


Measured memory_bytes: 7044
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
//deque/functional/iterator/list/map/memory/numeric/queue/set/stack/utility/vector
//#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a[100010];
int b[100010];
int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=n;i>=0;i--){
		cin>>a[i];
	}

	for(int i=n;i>=1;i--){
		cin>>b[i];
	}
	ll s=0;
	int k=a[0];
	//cout<<"a "<<k<<endl;
	for(int i=1;i<=n;i++){
		if(k>=b[i]){
			s+=b[i];
			b[i]=0;
		}else{
			b[i]=b[i]-k;
			s+=k;
		}
		//cout<<s<<endl;
		if(a[i]>b[i]){
			s+=b[i];
			k=a[i]-b[i];
		}else{
			s+=a[i];
			k=0;

		}
		//cout<<s<<endl;
	}
	cout<<s<<endl;

return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vll vector<ll>
#define vvll vector<vll>
#define mll map<ll,ll>
#define f(i,m,n) for(i=m;i<n;i++)
#define ee endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define take(v,n) for(i=0;i<n;i++) cin>>v[i];
#define NO() cout<<"NO"<<endl
#define YES() cout<<"YES"<<endl
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sot(v) sort(v.begin(),v.end());
bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
ll mod=1e9+7;
ll powe(ll x, ll y){
    ll res = 1;
    while (y > 0){
        if (y & 1) res = res*x;
        y = y>>1;
        x = x*x;
    }
    return res;
}

vvll dp(1001,vll(1001,-1));
char a[1001][1001];
ll sol(ll i,ll j, ll &n,ll &m)
{
    if(i>=n || j>=m) return 0;
    if(i==n-1 && j==m-1) return 1;
    if(dp[i][j]!=-1) return dp[i][j];
    ll a1=0,a2=0;
    if(i+1<n && a[i+1][j]=='.') a1=sol(i+1,j,n,m);
    if(j+1<m && a[i][j+1]=='.') a2=sol(i,j+1,n,m);
    dp[i][j]=(a1+a2)%mod;
    return dp[i][j];
}

void solve()
{
    ll i,j,k=0,n,m,l;
    cin>>n>>m;
    //char a[n][m];
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            cin>>a[i][j];
        }
    }
    cout<<sol(0,0,n,m);

}

int main() {
    fast;
    ll i,j,l,k,t,n;
    t=1;
    while(t--)
    solve();
}


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

int main(){
  int n,m;
  while(cin>>n,n){
  	cin>>m;
    string s;cin.ignore();getline(cin,s);
    string sn;
    int cnt=0;
    for(int i=0;i<2*n+1;++i) sn+=(i%2)?"O":"I";
    for(int i=0;i<m-(2*n+1);++i){
      if(s.substr(i,2*n+1)==sn)++cnt;
    }
    cout<<cnt<<endl;
  }
  return 0;
}

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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e15;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;

int main() {

    vector<vector<int>> board(3, vector<int>(3));

    rep(y, 3)rep(x, 3) cin >> board[y][x];

    rep(y, 3) {

        set<int> ans;
        rep(x, 3) {
            int a = board[y][x] - board[(y + 1) % 3][x];
            ans.insert(a);
        }
        if (ans.size() != 1) {
            cout << "No" << endl;
            return 0;
        }
    }

    rep(x, 3) {
        set<int> ans;
        rep(y, 3) {
            int a = board[y][x] - board[y][(x + 1) % 3];
            ans.insert(a);
        }
        if (ans.size() != 1) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};

fn main() {
    input! {
        x: usize,
        y: usize
    };
    for i in 0..=x {
        if y == (2 * i + 4 * (x - i)) {
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 2140
#include <iostream>
#include <cstdio>
#include <algorithm>
#define S second
using namespace std;
typedef long long ll;

ll n, k, a, s, ans, tr[200005];
pair<ll, ll> b[200005];

ll qry(ll p) {
	ll re = 0;
	for(; p; p -= p & -p) re += tr[p];
	return re;
}

void upd(ll p) {
	for(; p<=n+1; p += p & -p) tr[p]++;
}

int main() {
	ll i, j;
	cin >> n >> k;
	for(i=1; i<=n; i++) {
		scanf("%lld", &a);
		s += a;
		b[i] = {s-k*i, i};
	}
	sort(b, b+n+1);
	for(i=0; i<=n; i++) {
		ans += qry(b[i].S);
		upd(b[i].S + 1);
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fr(a,b) for(ll i = a; i < b; i++)
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define prDouble(x) cout << fixed << setprecision(10) << x 
#define triplet pair<ll,pair<ll,ll>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
 
double dp[3001][3001];
double solve(vector<double>& ar, int i, int x)
{
    if(x == 0)
        return 1;
    if(i == 0)
        return 0;
    if(dp[i][x] > -0.9)
        return dp[i][x];
    return dp[i][x] = ar[i]*solve(ar, i-1, x-1) + (1-ar[i])*solve(ar,i-1,x);  
}
 
int main() {
    int n;
    cin >> n;
    memset(dp, -1, sizeof dp);
    vector<double> ar(n+1);
    fr(1,n+1)
        cin >> ar[i];    
    prDouble(solve(ar, n, (n+1)/2));
}

Measured memory_bytes: 70784
using System;
using System.Linq;

class P
{
  static void Swap<T>(ref T a, ref T b)
  {
    var c = a;
    a = b;
    b = c;
  }

  static void Main()
  {
    for(var tc=1;; tc++) {
      var a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
      if(a[0] == a[1] && a[0] == 0) break;
      if(a[0] > a[1])
        Swap(ref a[0], ref a[1]);
      Console.WriteLine("{0} {1}", a[0], a[1]);
    }
  }
}

Measured memory_bytes: 9796
#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+1); ++i)
using namespace std;
using ll = long long;
const int INF = -100100100;
typedef pair<int,int> P;

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char>> a(h,vector<char>(w));
    rep(i,h)rep(j,w)cin >> a[i][j];
    rep(i,h){
        bool as = true;
        rep(j,w){
            if(a[i][j]=='#')as=false;
        }
        if(as)rep(j,w)a[i][j] = 's';
    }
    rep(j,w){
        bool as = true;
        rep(i,h){
            if(a[i][j]=='#')as=false;
        }
        if(as)rep(i,h)a[i][j] = 's';
    }
    rep(i,h){
        bool chk = false;
        rep(j,w){
            if(a[i][j]=='s'){
                continue;
            }else{
                chk=true;
            }
            cout << a[i][j];
        }
        if(chk)cout << endl;
        else continue;
    }
    return 0;
}

Measured memory_bytes: 384
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<String,Integer> map = new HashMap<>();
        for (int i=0;i<n;++i)
        {
            String s=sc.next();
            if (map.containsKey(s))
            {
                int c = map.get(s);
                c++;
                map.put(s,c);
                if (c > max) max=c;
            }else
            {
                int c = 1;
                map.put(s,c);
                if (c > max) max=c;
            }
        }

        Set<String> set = new HashSet<>();
        for (String s:map.keySet())
        {
            int c = map.get(s);
            if (c==max) set.add(s);
        }

        List<String> list = new ArrayList<>(set);
        Collections.sort(list);
        for (String s:list) System.out.println(s);

        sc.close();
    }
}

Measured memory_bytes: 82820
local function gcd(a,b)
    if b>0 then
        return gcd(b,a%b)
    else
        return a
    end
end

local x=gcd(io.read("n","n"))

local counter=1
for i=2,math.sqrt(x) do
    if x%i==0 then
        while x%i==0 do
            x=x//i
        end
        counter=counter+1
    end
end
print(x~=1 and counter+1 or counter)

Measured memory_bytes: 888