akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

ll a, b, c;
main(){
    scanf("%lld %lld.%lld", &a, &b, &c);
    printf("%lld\n", a*(100*b+c)/100);
    return 0;
}

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

int main() {
    int64_t N,M;
    cin >> N >> M;
    int baton = 0;
    int j = 1;
    int k;
    vector<pair<int,int>> ab(M, pair<int,int>(0,0));

    if(N%2 != 0){//奇数
        k = N/2;
        for(int i = 0; i < M; i++){
            if(baton == 0){
                ab.at(i).first = j;
                ab.at(i).second = N+1-j;
                j++;
                baton = 1;
            }else{
                ab.at(i).first = k;
                ab.at(i).second = N+1-k;
                k--;
                baton = 0;
            }
        }
    }else{//偶数
        k = N/2-1;
        for(int i = 0; i < M; i++){
            if(baton == 0){
                ab.at(i).first = j;
                ab.at(i).second = N+1-j;
                j++;
                baton = 1;
            }else{
                ab.at(i).first = k;
                ab.at(i).second = N-k;
                k--;
                baton = 0;
            }
        }

    }

    sort(ab.begin(), ab.end());

    for(int i = 0;i < M; i++){
        cout << ab.at(i).first << " " << ab.at(i).second << endl;
    }
}


Measured memory_bytes: 3896
import java.util.*;
class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String str = scan.next();
        String str2 = "ABC";
        if (str.equals(str2)){
            System.out.println("ARC");
        } else {
            System.out.println("ABC");
        }
        }
        }

Measured memory_bytes: 35756
N,M=map(int,input().split())

G = [[]for i in range(N)]
for i in range(M):
	a,b=map(lambda x:int(x)-1, input().split())
	G[a].append(b)
	G[b].append(a)

for i in range(N):
	print(len(G[i]))


Measured memory_bytes: 2940
#include <bits/stdc++.h> 
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define size_of_array(array) (sizeof(array)/sizeof(array[0]))
using ll =long long;
using namespace std;
using Graph=vector<vector<int>>;
using Field=vector<vector<int>>;

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

    for(int i=x-k+1;i<x+k;++i){
        cout<<i<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

int N, M;
vector<int> G[100005];
int in[100005];
int level[100005];
int ret[100005];
int color[100005];
vector<int> order;

bool visit(int v){
  color[v] = 1;
  rep(i,G[v].size()){
    int e = G[v][i];
    if (color[e] == 2) continue;
    if (color[e] == 1) return false;
    if (!visit(e)) return false;
  }
  order.push_back(v); color[v] = 2;
  return true;
}
bool topologicalSort() {
  REP(u, 1, N+1) if (!color[u] && !visit(u)) return false;
  reverse(order.begin(),order.end());
  return true;
}

void dfs(int v){
  rep(i,G[v].size()){
    if(level[G[v][i]] == level[v] + 1) ret[G[v][i]] = v;
    dfs(G[v][i]);
  }  
}

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

  rep(i,N-1+M){
    int A, B;
    cin >> A >> B;
    G[A].push_back(B);
    in[B]++;
  }

  int root = -1;
  REP(i,1,N+1){
    if(in[i] == 0){
      root = i;
      break;
    }
  }

  topologicalSort();
  level[root] = 1;
  rep(i,order.size()){
    int v = order[i];
    rep(j,G[v].size()){
      level[G[v][j]] = level[v] + 1;
    }
  }
  ret[root] = 0;
  rep(i,order.size()){
    int v = order[i];
    rep(j,G[v].size()){
      if(level[G[v][j]] == level[v] + 1) ret[G[v][j]] = v;
    }
  }
  
  REP(i,1,N+1){
    cout << ret[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 11508
require 'pp'
N = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)

ans = 0
hash = Hash.new(0)
sum = 0
N.times do |i|
  x = a[i]
  sum += x
  hash[x - sum] += 1
  ans += hash[-sum]
  # pp sum, hash
end

puts ans


Measured memory_bytes: 31228
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const L = parseInt(arg[0].split(" ")[0]);
    const R = parseInt(arg[0].split(" ")[1]);
    
    if(R - L + 1 >= 2019) {
        // 2つの数の差が2019以上のとき、必ず2019の倍数が存在するので0
        console.log(0);
    } else {
        const Lmod = L % 2019;
        const Rmod = R % 2019;
        
        let min = Infinity;
        
        for(let i=Lmod; i<Rmod; i++) {
            for(let k=parseInt(i)+1; k<=Rmod; k++) {
                min = Math.min((i * k) % 2019, min);
            }
        }
        
        console.log(min);
    }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include<iostream>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
pair<int, int>x[1000]; int n, a, b, s1, s2, dp[1100000];
int main() {
	while (true) {
		cin >> n; s1 = 0; s2 = 0; if (n == 0)break;
		for (int i = 0; i < n; i++) { cin >> a >> b; x[i] = make_pair(a, b); s1 += a; s2 += b; }
		sort(x, x + n);
		if (x[n - 1].first * 2 <= s1) { cout << s1 + s2 << endl; }
		else {
			for (int i = 0; i < 1100000; i++)dp[i] = 0; dp[0] = 1;
			int nokori = x[n - 1].first - (s1 - x[n - 1].first);
			vector<int>f; f.push_back(0);
			for (int i = 0; i < n - 1; i++) {
				vector<int>g;
				for (int a1 : f) {
					if (dp[a1 + x[i].second] == 0) { g.push_back(a1 + x[i].second); dp[a1 + x[i].second] = 1; }
				}
				for (int i = 0; i < g.size(); i++)f.push_back(g[i]);
			}
			int g = 0; for (int i = nokori; i >= 0; i--) { if (dp[i] == 1) { g = i; break; } }
			cout << (nokori - g) + s1 + s2 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 7372
#include <algorithm>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll, ll> P;
inline ll min(ll x, ll y) { return x < y ? x : y; }
inline ll max(ll x, ll y) { return x > y ? x : y; }

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)

int main() {
    int A, B;
    cin >> A >> B;
    cout << max(A - B * 2, 0);
    return 0;
}

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

int fee[7][7] = {
  {0,    300,  500,  600,  700,  1350, 1650},
  {300,  0,    350,  450,  600,  1150, 1500},
  {500,  350,  0,    250,  400,  1000, 1350},
  {600,  450,  250,  0,    250,  850,  1300},
  {700,  600,  400,  250,  0,    600,  1150},
  {1350, 1150, 1000, 800,  600,  0,    500 },
  {1650, 1500, 1350, 1300, 1150, 500,  0   }
};
 
int dist[7][7] = {
  {0,  6,  13, 18, 23, 43, 58},
  {6,  0,  7,  12, 17, 37, 52},
  {13, 7,  0,  5,  10, 30, 45},
  {18, 12, 5,  0,  5,  25, 40},
  {23, 17, 10, 5,  0,  20, 35},
  {43, 37, 30, 25, 20, 0,  15},
  {58, 52, 45, 40, 35, 15, 0}
};

bool isHalf(int dst, int s, int t) {
  
  int const LIM_L = 17*60+30;
  int const LIM_U = 19*60+30;
  
  if(dst > 40) return false;
  
  if(
    (LIM_L <= s && s <= LIM_U)
    || (LIM_L <= t && t <= LIM_U)
  ) return true;
  
  return false;
}

int main() {
  
  while(1) {
    int s, h, m;
    cin >> s >> h >> m;
    if(s == 0) break;
    int stime = h*60 + m;
    
    int d;
    cin >> d >> h >> m;
    int dtime = h*60 + m;
    
    int dst = dist[s-1][d-1];
    
    if(isHalf(dst, stime, dtime)) {
      cout << ceil(fee[s-1][d-1]/50/2.0)*50 << endl;
    }
    else cout << fee[s-1][d-1] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1244
fn main() {
    let (n, a, b): (u64, u64, u64) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap(),
        )
    };
    let rep = n / (a + b);
    let rem = n % (a + b);
    let ans = rep * a + if a <= rem { a } else { rem };
    println!("{}", ans);
}

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

int main(){
    string s,t,u,v(3,'a');
    cin >> s >> t >> u;
    v[0] = s[0];
    v[1] = t[1];
    v[2] = u[2];
    cout << v << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
vector<string>v;
void dfs(string str,string t="",int cnt=0){
    if(cnt==2){
        v.push_back(t);
        return;
    }else{
        for(int i=0;i<str.size();i++){
            dfs(str,t+str[i],cnt+1);
        }
    }
}
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int a,b;
    while(cin>>a>>b){
        a%2==1 && b%2==1?cout<<"Yes"<<endl:cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    double n, m;
    cin >> n >> m;

    vector<double> a(n);
    double total = 0;
    rep(i, n){
        cin >> a[i];
        total += a[i];
    }
    int cnt = 0;
    rep(i, n){
        if(a[i] >= total * (1.0 / (4.0 * m))){
            cnt++;
        }
    }
    //cout << cnt << endl;
    if(cnt >= m){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <string.h>
#include <cstdlib>
#include <iomanip>
#include <stdio.h>

using namespace std;


int main(){

        int a,b;

        scanf("%d %d\n",&a,&b);

        printf("%d %d %f\n",a/b,a%b,(double)a/(double)b);

}


Measured memory_bytes: 3212
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;


namespace AtC
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var H = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var max = 0;
            var count = 0;
            for (int i = 0; i < H.Length; i++)
            {
                if (max <= H[i])
                {
                    count++;
                    max = H[i];
                }
            }

            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 13268
i = list(map(int, input().split()))
num_list = []
if(i[1]-i[0]+1<i[2]):
	i[2] = i[1] - i[0] + 1
for j in range(i[2]):
	num_list.append(i[0]+j)
for j in reversed(range(i[2])):
	num_list.append(i[1]-j)
ans = sorted(list(set(num_list)))
for k in range(len(ans)):
	print(ans[k])

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

using namespace std;

const int MAX_N = 100000, INDEX = 1;

int n, a[MAX_N + INDEX], b[MAX_N + INDEX];
long long ans = 0;

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

    cin >> n;

    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i];
    }

    long long sum = 0;
    for (int i = n; i >= 1; i--) {
        ans += (b[i] - (a[i] + sum) % b[i]) % b[i];
        sum += (b[i] - (a[i] + sum) % b[i]) % b[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

int main(){
  int N,K;
  cin >> N >> K ;
  vi V(N,0);
  rep(i,K){
    int d=0;
    cin >> d;
    rep(j,d){
      int x;
      cin >> x;
      V.at(x-1)=3;
    }

  }
  int count=0;
  rep(i,N) {
    if(V.at(i)==3)count++;
  }
  cout << N-count << endl;
  
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int A, B, C;
    cin >> A >> B >> C;

    if (((A < C) && (C < B)) || ((B < C) && (C < A))) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

typedef unsigned long long ull;

int main(){
    string x;
    cin >> x;

    while(x != "0"){
        int S = 0;
        for (int i=0;i<x.size();i++){
            S += (int)x[i] - (int)'0';
        }
        cout << S << endl;
        cin >> x;
    }
    return 0;
}

Measured memory_bytes: 3148
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	static class Tuple implements Comparable<Tuple> {
		int src, dst, cost;

		Tuple(int src, int dst, int cost) {
			this.src = src;
			this.dst = dst;
			this.cost = cost;
		}

		@Override
		public int compareTo(Tuple o) {
			return Integer.compare(this.cost, o.cost);
		}
	}

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		String[] tokens = in.readLine().split(" ");
		int H = Integer.parseInt(tokens[0]);
		int W = Integer.parseInt(tokens[1]);
		Tuple[][] cost = new Tuple[10][10];
		int[][] distMatrix = new int[10][10];
		for (int i = 0; i < 10; ++i) {
			tokens = in.readLine().split(" ");
			for (int j = 0; j < 10; ++j) {
				cost[i][j] = new Tuple(i, j, Integer.parseInt(tokens[j]));
				distMatrix[i][j] = cost[i][j].cost;
			}
		}

		// 対角成分以外をqueueに入れる
		Queue<Tuple> que = new PriorityQueue<>();
		for (int i = 0; i < 10; ++i) {
			for (int j = 0; j < 10; ++j) {
				if (i == j)
					continue;
				que.add(cost[i][j]);
			}
		}

		// 順に評価する
		while (!que.isEmpty()) {
			Tuple tuple = que.poll();
			int c = tuple.cost;
			for (int med = 0; med < 10; ++med) {
				if (tuple.src == med || tuple.dst == med) {
					continue;
				}
				c = Math.min(c, distMatrix[tuple.src][med] + distMatrix[med][tuple.dst]);
			}
			distMatrix[tuple.src][tuple.dst] = c;
			// 次に経由する部分を評価
			// src->tuple.src->tuple.dst
			for (int src = 0; src < 10; ++src) {
				if (tuple.src == src || tuple.dst == src) {
					continue;
				}
				if (distMatrix[src][tuple.src] + c < distMatrix[src][tuple.dst]) {
					distMatrix[src][tuple.dst] = distMatrix[src][tuple.src] + c;
				}
			}
			// tuple.src->tuple.dst->dst
			for (int dst = 0; dst < 10; ++dst) {
				if (tuple.src == dst || tuple.dst == dst) {
					continue;
				}
				if (c + distMatrix[tuple.dst][dst] < distMatrix[tuple.src][dst]) {
					distMatrix[tuple.src][dst] = c + distMatrix[tuple.dst][dst];
				}
			}
		}

		// これをもとに置き換える
		int[][] A = new int[H][W];
		for (int i = 0; i < H; ++i) {
			tokens = in.readLine().split(" ");
			for (int j = 0; j < W; ++j) {
				A[i][j] = Integer.parseInt(tokens[j]);
			}
		}
		int result = 0;
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				if (A[i][j] == 1 || A[i][j] == -1) {
					continue;
				}
				result += distMatrix[A[i][j]][1];
			}
		}
		System.out.println(result);
	}

}


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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define F first
#define S second
#define pb push_back
#define pii pair <int, int>
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define reunique(a) (a).resize(unique(all(a)) - (a).begin())
#define ld long double
#define int long long

int a[15][15];
int m[15][15];

void SOLVE(){
    for (int i = 1; i <= 3; i++){
        for (int j = 1; j <= 3; j++){
            cin >> a[i][j];
        }
    }
    int n;
    cin >> n;
    for (int ii = 0; ii < n; ii++){
        int x;
        cin >> x;
        for (int i = 1; i <= 3; i++){
            for (int j = 1; j <= 3; j++){
                if (a[i][j] == x)
                m[i][j] = 1;
            }
        }
    }
    for (int i = 1; i <= 3; i++){
        for (int j = 1; j <= 3; j++){
            a[i][j] = m[i][j];
        }
    }
    bool ok = 0;
    if (a[1][1] && a[1][2] && a[1][3]) ok = 1;
    if (a[2][1] && a[2][2] && a[2][3]) ok = 1;
    if (a[3][1] && a[3][2] && a[3][3]) ok = 1;
    if (a[1][1] && a[2][1] && a[3][1]) ok = 1;
    if (a[1][2] && a[2][2] && a[3][2]) ok = 1;
    if (a[1][3] && a[2][3] && a[3][3]) ok = 1;

    if (a[1][1] && a[2][2] && a[3][3]) ok = 1;
    if (a[3][1] && a[2][2] && a[1][3]) ok = 1;

    cout << (ok ? "Yes\n" : "No\n");
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12);
    int Q = 1;
    //cin >> Q;
    while (Q--){
        SOLVE();
    }

    return 0;
}




Measured memory_bytes: 256
#include<algorithm>
#include<cstring>
#include<cctype>
#include<cstdio>
#define rep(i,x,y) for(int i=x; i<=y; ++i)

using namespace std;
int n,x,y;
double a,p,ans;

int main()
{
	scanf("%d%d%d",&n,&x,&y);
	a=x-y,p=y;
	while(n)
	{
		ans+=a+p*(2*n+1)/2;
		a=a+a/n+3*p/n/2;
		p=p+2*p/n;
		--n;
	}
	printf("%.15lf\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#define mp make_pair
using namespace std;

typedef pair<int,int> P;
typedef pair<int,P> PP;

int main(){
	int n;
	while(cin >> n,n){
		int w = 0;
		vector<PP> vec;
		bool flag = true;
		for(int i = 0;i < n;i++){
			int m,a,b;
			cin >> m >> a >> b;
			vec.push_back(mp(a,mp(2,m)));
			vec.push_back(mp(b,mp(1,m)));
		}
		sort(vec.begin(),vec.end());
		for(int i = 0;i < vec.size();i++){
			int typ = vec[i].second.first,m = vec[i].second.second;
			if(typ == 1){
				w -= m;
			}else{
				w += m;
				if(w > 150) flag = false;
			}
		}
		if(flag) cout << "OK" << endl;
		else cout << "NG" << endl;
	}
	return 0;
}

Measured memory_bytes: 3056
#include <iostream>
#include <cmath>

using namespace std;
long x;

int main() {
    cin >> x;
    for (int a = -120; a < 120; a++) {
        for (int b = -120; b < 120; b++) {
            if (pow(a, 5) - pow(b, 5) == x) {
                cout << a << ' ' << b << endl;
                return 0;
            }
        }
    }
    return 0;
}


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

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        System.out.println(problem140a(n));
    }

    private static int problem140a(int n) {
        return (int)Math.pow(n, 3);
    }
}

Measured memory_bytes: 20948
import java.util.Scanner;

public class Main {
	final static double[] LV500 = { 35.5, 37.5, 40, 43, 50, 55, 70 };
	final static double[] LV1000 = { 71, 77, 83, 89, 105, 116, 148 };
	final static String[] lv = { "AAA", "AA", "A", "B", "C", "D", "E" };

	public static void main(String[] arg) {
		Scanner in = new Scanner(System.in);
		while (in.hasNext()) {
			double _500 = in.nextDouble();
			double _1000 = in.nextDouble();
			String s = "NA";
			for (int i = 0; i < 7; i++) {
				if (LV500[i] > _500) {
					for (int j = i; j < 7; j++) {
						if (LV1000[j] > _1000) {
							s = lv[j];
							break;
						}
					}
					break;
				}
			}
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 20604
#include<bits/stdc++.h>
using namespace std;
int main()
{   
	int A,B,P,M,T;
	cin>>A>>B;
	P=A+B;
	M=A-B;
	T=A*B;
	cout<<max(max(P,M),T); 
	return 0;  		
}	

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

using ll = long long;
using vi = vector<int>;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back

struct edge{int to;};
using graph = vector<vector<edge>>;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll x;
    cin >> x;
    ll v = 100;
    int y = 0;
    while (v < x) {
        v = (ll)(((long double) v) * 1.01L);
        y++;
    }
    cout << y << endl;
}


Measured memory_bytes: 3640
import sys
readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readints():return list(map(int,readline().split()))


h,w = readints()

start = readints()
start = (start[0]-1)*w + start[1]-1

goal = readints()
goal = (goal[0]-1)*w + goal[1]-1

maze = [readstr() for i in range(h)]

dist = [10**10]*(h*w)

a = [set() for i in range(2)]
i = 0
a[i].add(start)
dist[start] = 0

while a[i]:
    p = a[i].pop()
    if dist[goal] <= dist[p]:
        break
    y = p//w
    x = p%w
    for dy in range(-2,3):
        for dx in range(-2,3):
            if 0<=y+dy<h and 0<=x+dx<w and maze[y+dy][x+dx]=='.':
                q = (y+dy)*w + x+dx
                if abs(dy)+abs(dx)==1:
                    if dist[q]>dist[p]:
                        a[i].add(q)
                        dist[q] = dist[p]
                else:
                    if dist[q]>dist[p]+1:
                        a[i-1].add(q)
                        dist[q] = dist[p] + 1
    if not a[i]:
        i = [1,0][i]

print(-1 if dist[goal]==10**10 else dist[goal])


Measured memory_bytes: 86948
#include <stdio.h>
#include <stdlib.h>

typedef struct {
	char mark;
	int num;	
}card;

void BubbleSort(card *, int );
void SelectionSort(card *, int );
int juage(card *, card *, int );
int main(void){
	card arr[40],barr[40],sarr[40];
	int i,j,N;
	char tmp[3];
	scanf("%d",&N);
	for(i=0; i<N; i++){
		scanf("%s",tmp);
		barr[i].mark = sarr[i].mark = arr[i].mark = tmp[0];
		barr[i].num = sarr[i].num = arr[i].num = atoi(&tmp[1]);
//		printf("%c%d ",arr[i].mark,arr[i].num);
	}
	BubbleSort(barr, N);
	printf("Stable\n");
	SelectionSort(sarr, N);
	if(juage(barr,sarr, N)){
		printf("Not stable\n");
	}
	else {
		printf("Stable\n");
	}
	return 0;	
}
int juage(card *barr,card *sarr, int _N){
	int i;
	for(i=0; i<_N; i++){
		if(barr[i].mark != sarr[i].mark){
			return 1;
		}
	}
	return 0;
}
void BubbleSort(card *arr, int _N){
	int i,j,ntmp;
	char mtmp;
	for(i=0; i< _N-1; i++){
		for(j = _N-1; j>0; j--){
			if(arr[j].num < arr[j-1].num){
				ntmp = arr[j].num;
				mtmp = arr[j].mark;
				arr[j].num = arr[j-1].num;
				arr[j].mark = arr[j-1].mark;
				arr[j-1].num = ntmp;
				arr[j-1].mark = mtmp;
			}
		}
	}
	for(i=0; i < _N-1; i++){
		printf("%c%d ",arr[i].mark,arr[i].num);
	}
		printf("%c%d",arr[_N-1].mark,arr[_N-1].num);
	printf("\n");
}	

void SelectionSort(card *arr, int _N){
	int minj,i,j,ntmp;
	char mtmp;
	for(i=0; i<_N; i++){
		minj = i;
		for(j=i; j<_N; j++){
			if(arr[j].num < arr[minj].num){
				minj = j;
			}
		}
		ntmp = arr[i].num;
		mtmp = arr[i].mark;	
		arr[i].num = arr[minj].num;
		arr[i].mark = arr[minj].mark;
		arr[minj].num = ntmp;
		arr[minj].mark = mtmp;
	}		
	for(i=0; i < _N-1; i++){
		printf("%c%d ",arr[i].mark,arr[i].num);
	}
		printf("%c%d",arr[_N-1].mark,arr[_N-1].num);
	printf("\n");
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  
  vector<vector<char>> S(H, vector<char>(W));
  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      cin >> S.at(i).at(j);
    }
  }

  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      int c = 0; //地雷カウンタ
      if(S.at(i).at(j) == '#') {
        continue;
      }
      if(i > 0 && j > 0 && S.at(i-1).at(j-1) == '#') { //左上
        c++;
      } 
      if(i > 0 && S.at(i-1).at(j) == '#') {//真上
        c++;
      } 
      if(i > 0 && j < W-1 && S.at(i-1).at(j+1) == '#') { //右上
        c++;
      }
      if(j < W-1 && S.at(i).at(j+1) == '#') { //右横
        c++;
      } 
      if(i < H-1 && j < W-1 && S.at(i+1).at(j+1) == '#') { //右下
        c++;
      } 
      if(i < H-1 && S.at(i+1).at(j) == '#') { //真下
        c++;
      } 
      if(i < H-1 && j > 0 && S.at(i+1).at(j-1) == '#') { //左下
        c++;
      } 
      if(j > 0 && S.at(i).at(j-1) == '#') { //左横
        c++;
      }
      string c_str = to_string(c);
      S.at(i).at(j) = c_str.at(0);
    }
  }

  for(int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++) {
      cout << S.at(i).at(j);
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 3664
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)){
			int[] ary = new int[3];
			for(int i=0; i< ary.length ; i++) {
				ary[i]= sc.nextInt();
				if(ary[i] < 1 || ary[i] > 10000){
					System.exit(0);
				}
			}
			Arrays.sort(ary);
			System.out.println(String.format("%d %d %d", ary[0],ary[1],ary[2]));
		}
	}
}

Measured memory_bytes: 26388
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<stdio.h>
#include<string>
#include<vector>
#include<sstream>
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a != c)
	{
		cout << 1 << endl;
	}
	else cout << 0 << endl;
	return 0;
}

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

int main() {
  int n ;
  cin >> n ;
  vector<int> a(n) ;
  rep(i,n) cin >> a.at(i) ;
  deque<int> dq ;
  if(n%2){
  	rep(i,n){
   		if(i%2) dq.push_back(a.at(i)) ;
   		else    dq.push_front(a.at(i)) ;
  		}
  }
  else{
    rep(i,n){
   		if(i%2) dq.push_front(a.at(i)) ;
   		else    dq.push_back(a.at(i)) ;
  		}
  }
  rep(i,n) cout << dq[i] <<endl;
}

Measured memory_bytes: 3840
use std::cmp::max;
use std::io::*;
use std::str::FromStr;

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

fn main() {
    let n: usize = read();
    let mut arr = vec![0; 9];
    for _ in 0..n {
        let x: usize = read();
        match x {
            1..=399 => arr[0] = 1,
            400..=799 => arr[1] = 1,
            800..=1199 => arr[2] = 1,
            1200..=1599 => arr[3] = 1,
            1600..=1999 => arr[4] = 1,
            2000..=2399 => arr[5] = 1,
            2400..=2799 => arr[6] = 1,
            2800..=3199 => arr[7] = 1,
            _ => arr[8] += 1,
        }
    }
    let ans: usize = arr.clone().into_iter().sum();
    println!("{} {}", max(ans - arr[8], 1), ans);
}


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

int main(void){
	char a[9];
	int t,i,h,b;

while(1){
	gets(a);
		if((a[0]=='0')&&(a[2]=='0')){
			return 0;
		}
	h=0;
	b=0;

	for(t=0;t<4;t++){
		if(a[t]==a[t+5]){
			h++;
		}
	}
	for(i=0;i<4;i++){
		for(t=0;t<4;t++){
			if(a[t]==a[i+5]){
				b++;
			}
		}
	}
	b-=h;
	printf("%d %d\n",h,b);
}



return 0;
}

Measured memory_bytes: 524
def to_fizzbuzz(number):
    if number % 15 == 0:
        return 'FizzBuzz'

    if number % 3 == 0:
        return 'Fizz'

    if number % 5 == 0:
        return 'Buzz'

    else:
        return str(number)
        # return i

def main():
    N = int(input())
    # this list concludes "FizzBuzz", "Fizz" or "Buzz"
    fblist = []
    for number in range(1, 10**6):
        result = to_fizzbuzz(number)
        fblist.append(result)

    # the list up to N
    n_list = fblist[0:N]
    # this list contains only numbers and up to N

    n_numlist = []

    for s in n_list:
        if s.isdigit() == True:
            n_numlist.append(int(s))

    print(sum(n_numlist))


main()

Measured memory_bytes: 79448
S = input()
ps = 'R'
cnt = 0
answer = [0] * len(S)
start = 0
for i,s in enumerate(S):
    if s == 'R':
        if ps == s:
            cnt += 1
        else:
            answer[start] += -(-cnt//2)
            answer[start-1] += cnt//2
            cnt = 1
    if s == 'L':
        if ps == s:
            cnt += 1
        else:
            answer[i-1] += -(-cnt//2)
            answer[i] += cnt//2
            start = i
            cnt = 1
    ps = s
answer[start] += -(-cnt//2)
answer[start-1] += cnt//2
print(" ".join(list(map(str,answer))))

Measured memory_bytes: 10484
#include <stdio.h>
#include <iostream>
#include <string>
#include <set>
#include <algorithm>
using namespace std;

int main(void){
int n;
set<string> setmoji; 
string moji;
string f;
string fr;
string b;
string br;
cin >> n ;
	for(int i=0; i<n;i++){
		setmoji.clear();
		cin >> moji;
		for(int j=1; j<moji.size(); j++){
			fr=f=moji.substr(0,j);
			br=b=moji.substr(j,moji.size()-j);
			reverse(fr.begin(), fr.end());
			reverse(br.begin(), br.end());
			setmoji.insert(f+b);
			setmoji.insert(fr+b);
			setmoji.insert(f+br);
			setmoji.insert(fr+br);    
			setmoji.insert(b+f);
			setmoji.insert(br+f);
			setmoji.insert(b+fr);
			setmoji.insert(br+fr);    
 		}
		cout <<  setmoji.size() <<endl;
	}
return 0;
}

Measured memory_bytes: 1292
//-------------
//include
//-------------
#include <map>
#include <list>
#include <cmath>
#include <vector>
#include <string>
#include <cctype>
#include <random>
#include <cstdlib>
#include <iostream>
#include <algorithm>
using namespace std;
//-------------
//typedef
//-------------
typedef long long LL;
typedef  vector<int> VI;
typedef  pair<int, int> PII;
typedef  vector<int, int> VII;
typedef  map<string, int> MSI;
//-------------
//utillty
//-------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MK make_pair
#define PB push_back
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//-------------
//repetition
//-------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//-------------
//debug
//-------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumpl(x) REP(i,SZ(x))cerr<<i<<x<<"="<<x[i]<<endl;
const int MOD = 1000000007;
int main()
{
	string a;
	cin >> a;
	for (int i = 0; i < a.size()-1;i++)
	{
		string temp = a;
		temp.erase(temp.begin()+i);
		if(find(temp.begin(),temp.end(),a[i])!=temp.end())
		{
			cout << "no" << endl;
			return 0;
		}
	}
	cout << "yes" << endl;
#ifdef _DEBUG
	while(1);
#endif
	return 0;
}

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

int main() {
  ll n;
  cin >> n;
  vector<ll> a(n),sum(n+1,0);
  rep(i,n) cin >> a[i];
  
  rep(i,n) sum[i+1] = sum[i] + a[i];
  
  ll ans = 1e18;
  for(ll i=1;i<n;i++){
    ll x = sum[i];
    ll y = sum[n] - x;
    ans = min(ans, abs(x-y));
    //cout << x << " " << y << endl;
  }
  
  cout << ans << endl;
  
  return(0);
}

Measured memory_bytes: 6420
import java.io.InputStreamReader
import java.io.BufferedReader

fun main(args: Array<String>) {
  val br = BufferedReader(InputStreamReader(System.`in`))

  br.readLine()

  fun MutableMap<Int, Int>.putOrUpdate(key: Int) {
    if(this.containsKey(key)) this.put(key, this.get(key)!!.plus(1))
    else this.put(key, 1)
  }

  val map: MutableMap<Int, Int> = mutableMapOf()
  val a = br.readLine().split(" ").map { it.toInt() }
  for(key in a) {
    map.putOrUpdate(key)
  }

  val ans = map.keys.fold(0L) { acc, k ->
    val v: Int = map.get(k)!!
    when {
      k == v -> acc
      k >  v -> acc + v
      else   -> acc + (v - k)
    }
  }

  println(ans)
}

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

int main(){
  int a,b,n;
  int s,f;

  while(cin >> a >> b >> n){
    s = 0;
    f = a/b;
    a -= b*f;
    a *= 10;
    for(int i=0;i<n;i++){
      f = a/b;
      s += f;
      a -= b*f;
      a *= 10;
    }
    cout << s << endl;
  }
}

Measured memory_bytes: 0
n = int(input())
if n == 0:
    print(0)
    exit()
i = 0
ans = []
while abs(n) > 0:
    ans.append(n%2)
    #n = (n - n % (2 * (-1)**i)) // 2
    n = (n - (n % 2)) // -2
    i += 1
print(''.join(map(str, ans[::-1])))


Measured memory_bytes: 2940
def main():
    n = int(input())
    A = [int(e) for e in input().split()]

    hand = 1000
    for i in range(1, n):
        if A[i] > A[i - 1]:
            hand = (hand % A[i - 1]) + (hand // A[i - 1]) * A[i]

    print(hand)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61924
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> a(9);
	rep(i,n){
		int x;cin >> x;
		bool flg=true;
		rep(j,8){
			if(x<(j+1)*400){
				a.at(j)++;
				flg=false;
				break;
			}
		}
		if(flg) a.at(8)++;
	}
	int ma=0,mi=0;
	rep(i,8){
		if(a.at(i)){
			ma++;
			mi++;
		}
	}
	if(mi==0 && a.at(8)) mi++;
	ma+=a.at(8);
	cout << mi << " " << ma << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;

#define rep(i,n)  for(int i = 0; i < (int)(n);    i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

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

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::string S; std::cin >> S;

  std::vector<int> R(N+1), G(N+1), B(N+1);
  for(int i=0; i<sz(S); i++) {
    if ( S[i] == 'R' ) R[i+1] += R[i] + 1;
    else R[i+1] = R[i];

    if ( S[i] == 'G' ) G[i+1] += G[i] + 1;
    else G[i+1] = G[i];

    if ( S[i] == 'B' ) B[i+1] += B[i] + 1;
    else B[i+1] = B[i];
  }
  

  ll ans = 0;
  for(int j=0; j<N; j++) {
    if ( S[j] == 'R' ) {
      ans += ( G[j] - G[0] ) * ( B[N] - B[j+1] );
      ans += ( B[j] - B[0] ) * ( G[N] - G[j+1] );
    }
    if ( S[j] == 'G' ) {
      ans += ( R[j] - R[0] ) * ( B[N] - B[j+1] );
      ans += ( B[j] - B[0] ) * ( R[N] - R[j+1] );
    }
    if ( S[j] == 'B' ) {
      ans += ( G[j] - G[0] ) * ( R[N] - R[j+1] );
      ans += ( R[j] - R[0] ) * ( G[N] - G[j+1] );
    }

    ll t=0;
    for(int k=0; (j-k>=0) && (j+k<N); k++) {
      if ( S[j-k] != S[j] && S[j] != S[j+k] && S[j-k] != S[j+k] ) t++;
    }
    ans -= t;
  }
  std::cout << ans << std::endl;
  return 0;
}



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

int main() {

	int n, k; cin >> n >> k;

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

		double tmpProb = 0;
		int cnt = 0;
		int point = i;
		while (point <= k - 1) {
			point *= 2;
			cnt++;
		}

		tmpProb += (double)1 / n;
		for (int j = 0; j < cnt; j++) tmpProb *= (double)1 / 2;
		
		prob += tmpProb;

	}
		
	cout << fixed << setprecision(11) << prob << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())

alst = list(map(int, input().split()))
if 0 in alst:
  print(0)
  exit()
  
else:
  ans = 1
  for i in range(n):
    ans *= alst[i]
    if ans > 10**18:
      print('-1')
      exit()

  print(ans)

Measured memory_bytes: 21660
fun main(args: Array<String>) {
    readLine()
    val difficulties = readLine()!!.split(' ').map { it.toInt() }.sorted()
    if (difficulties.size <= 2) {
        println(difficulties[1] - difficulties[0])
        return
    }
    val leftDifficulty = difficulties[difficulties.size / 2 - 1]
    val rightDifficulty = difficulties[difficulties.size / 2]
    val k = rightDifficulty - leftDifficulty
    println(k)
}

Measured memory_bytes: 52484
#include<stdio.h>
int main(void)
{
	int num1[] = { 1,3,5,7,8,10,12 };
	int num2[] = { 4,6,9,11 };
	int flag;
	int i = 0;
	int j = 0;
	int x, y;

	scanf("%d %d",&x, &y);
	for (i = 0; i < 7; i++)
	{
		if (x == num1[i])
		{
			flag = 1;
		}
		
	}
	for (j = 0; j < 4; j++)
	{
		if (x == num2[j])
		{
			flag = 2;
		}
	}
	if (x == 2)
	{
		flag = 3;
	}

	if (flag == 1)
	{
		for (i = 0; i < 7; i++)
		{
			if (num1[i] == y)
			{
				printf("Yes\n");
				break;
			}
		}
		if (i == 7)
		{
			printf("No\n");
		}
	}
	else if (flag == 2)
	{
		for (j = 0; j < 4; j++)
		{
			if (num2[j] == y)
			{
				printf("Yes\n");
				break;
			}
		}
		if (j == 4)
		{
			printf("No\n");
		}
	}
	if (flag == 3)
	{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
def combain(X, Y):
    return int(( X * (X - 1)) / Y)

N = int(input())
S = []

ans = 0

for i in range(N):
    S.append(sorted(input()))

S.sort()

ans = 0

X = 1
for i in range(N-1):
    if S[i] == S[i+1]:
        X += 1
    elif X > 1:
        C = combain(X, 2)
        X = 1
        ans += C

if X > 1:
    C = combain(X, 2)
    X = 1
    ans += C
    
print(ans)

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

typedef long long int ll;
typedef pair<ll,ll> P;

int main(){
    for(int i=1;i<=5;i++){
        int a;
        cin>>a;
        if(!a){
            cout<<i<<endl;
            return 0;
        }
    }


    return 0;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String tmp[], op;
		long a, b;
		while (true) {
			tmp = br.readLine().split(" ");
			a = Long.parseLong(tmp[0]);
			b = Long.parseLong(tmp[2]);
			op = tmp[1];
			tmp = null;
			
			if(op.equals("?"))break;
			else if(op.equals("+"))
				System.out.println(a + b);
			else if(op.equals("-"))
				System.out.println(a - b);
			else if(op.equals("*"))
				System.out.println(a * b);
			else if(op.equals("/"))
				System.out.println(a / b);
		}
	}

}

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

using namespace std;

int main()
{
	string s;
	cin >> s;

	bool flag = false;

	for (char c1 = 'a'; c1 <= 'c'; c1++)
	{
		for (char c2 = 'a'; c2 <= 'c'; c2++)
		{
			for (char c3 = 'a'; c3 <= 'c'; c3++)
			{
				if (c1 == c2 || c2 == c3 || c3 == c1) continue;

				if (s[0] == c1 && s[1] == c2 && s[2] == c3)
				{
					flag = true;
				}
			}
		}
	}

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

	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using ll = long long;
const int INF = 0x3f3f3f3f;
using namespace std;

int n, arr[100001];
int main() {
    IOS
    cin >>n;
    for (int i = 0; i < n; ++i) {
        cin >> arr[i];
    }
    for (int i = n-2; ~i; --i) {
        if (arr[i] > arr[i+1]+1) {
            cout << "No" << endl;
            return 0;
        }
        arr[i] = min(arr[i], arr[i+1]);
    }
    cout<< "Yes" << endl;

    return 0;


}


Measured memory_bytes: 640
#include<stdio.h>
#include <math.h>
#include <stdlib.h>
int main (){
long long int c[52],v[52],i,j,k,e,g,h;
int n,a,b;
double d,f;
f=0;
g=0;
scanf("%d %d %d",&n, &a, &b);
for(i=1;i<=n;i++){
scanf("%lld",&v[i]);
if (v[i]>f) {
f=v[i];
g=0;
}
if (v[i]==f) g=g+1;
}
if (g>=b){
printf("%f\n",f);
e=0;
c[0]=1;
for(i=1;i<=g;i++){
c[i]=c[i-1]*(g-i+1)/i;
}
for(i=a;i<=b;i++){
e=e+c[i];
}
printf("%lld\n",e);
return 0;
}
if (g>=a){
printf("%f\n",f);
e=0;
c[0]=1;
for(i=1;i<=g;i++){
c[i]=c[i-1]*(g-i+1)/i;
}
for(i=a;i<=g;i++){
e=e+c[i];
}
printf("%lld\n",e);
return 0;
}
if (g<a) {
for(i=1;i<=n-1;i++){
for(j=i+1;j<=n;j++){
if (v[i]<v[j]) {
e=v[i];
v[i]=v[j];
v[j]=e;
}
}
}
d=0;
for(i=1;i<=a;i++){
d=d+v[i];
}
d=d/a;
printf("%f\n",d);
for(i=a;i>1;i--){
if (v[i-1] != v[i]){
g=i;
break;
}
}
for(i=a;i<=n;i++){
if (v[i+1] != v[i]){
h=i;
break;
}
}
c[0]=1;
for(i=1;i<=h-g+1;i++){
c[i]=c[i-1]*(h-g+1-i+1)/i;
}
e=c[a-g+1];
printf("%lld\n",e);
}
return 0;
}

Measured memory_bytes: 128
# dp[i][w]: i個目までの品物から、重さwの以下に収まる範囲で取れる価値の最大値

n,W = map(int, input().split())
wv = [list(map(int,input().split())) for _ in range(n)]

dp = [[0 for i in range(W+1)] for j in range(n+1)]

for i in range(1,n+1):
  w,v=wv[i-1]
  for j in range(1,W+1):
    if j>=w:
      dp[i][j] = max(dp[i-1][j],dp[i-1][j-w]+v)
    else:
      dp[i][j] = dp[i-1][j]
print(dp[-1][-1])

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

int A[200000], C[200000];

int main(){
	int N; cin>>N;
	rep(i, N){ scanf("%d",A+i); A[i]--; C[A[i]]++; }//値の種類毎の計数
	ll all = 0; rep(a, N) all += (ll)C[a]*(C[a]-1)/2;//組み合わせの総計
	rep(k, N) printf("%lld\n",all - C[A[k]] + 1);
}

Measured memory_bytes: 3712
/*Infor {{{
 ******************************************************
 * > File Name: a.cpp
 * > Author: samcompu
 * > Mail: admin@samcompu.com
 * > Created Time: 2018年07月01日 星期日 19时30分41秒
 ******************************************************
}}}*/

#include <bits/stdc++.h>

using namespace std;

/*Abbreviation {{{ */
#define FOR(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define ROF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)
#define cini(a) scanf("%d", &(a))
#define cinc(a) scanf("%c", &(a))
#define cinl(a) scanf("%lld", &(a))
#define cins(a) scanf("%s", (a))
#define cind(a) scanf("%lf", &(a))
#define coui(a) printf("%d", (a))
#define couc(a) printf("%c", (a))
#define coul(a) printf("%lld", (a))
#define cous(a) printf("%s", (a))
#define coud(a) printf("%f", (a))
#define SPA printf(" ")
#define LIN printf("\n")
#define ull unsigned long long int
/*}}}*/

/*Constant {{{*/
const int MAXN = 200000;
/*}}}*/

/*Class {{{*/
/*}}}*/

/*Variable {{{*/
int a[MAXN + 1];
/*}}}*/

/*Declare {{{*/
bool camp(int, int);
/*}}}*/

/*Main {{{*/
int main() {
  int n;
  cini(n);
  FOR(i, 1, n) {
    cini(a[i]);
    a[i] -= i;
  }
  sort(a + 1, a + n + 1, camp);
  int b = a[(n / 2) + 1];
  long long ans = 0;
  FOR(i, 1, n) ans += abs(a[i] - b);
  coul(ans);
  return 0;
}
/*}}}*/

/*Define {{{*/
bool camp(int a, int b) {return a < b;}
/*}}}*/


Measured memory_bytes: 1024
#line 1 "D.cpp"
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <vector>

#line 1 "~/git/library/utility/literals.cpp"



/**
 * @brief ユーザ定義リテラル
 * @author えびちゃん
 */

#include <cstddef>
#line 11 "~/git/library/utility/literals.cpp"

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }


#line 1 "~/git/library/utility/make/vector.cpp"
/**
 * @brief 多次元 vector の作成
 * @author えびちゃん
 */

#ifndef H_make_vector
#define H_make_vector

#line 10 "~/git/library/utility/make/vector.cpp"
#include <type_traits>
#line 12 "~/git/library/utility/make/vector.cpp"

namespace detail {
  template <typename Tp, size_t Nb>
  auto make_vector(std::vector<size_t>& sizes, Tp const& x) {
    if constexpr (Nb == 1) {
      return std::vector(sizes[0], x);
    } else {
      size_t size = sizes[Nb-1];
      sizes.pop_back();
      return std::vector(size, make_vector<Tp, Nb-1>(sizes, x));
    }
  }
}  // detail::

template <typename Tp, size_t Nb>
auto make_vector(size_t const(&sizes)[Nb], Tp const& x = Tp()) {
  std::vector<size_t> s(Nb);
  for (size_t i = 0; i < Nb; ++i) s[i] = sizes[Nb-i-1];
  return detail::make_vector<Tp, Nb>(s, x);
}

#endif  /* !defined(H_make_vector) */
#line 9 "D.cpp"

int main() {
  size_t n, k;
  scanf("%zu %zu", &n, &k);

  std::vector<size_t> a(n);
  for (auto& ai: a) scanf("%zu", &ai), --ai;

  auto dp = make_vector<size_t>({63_zu, n});
  dp[0] = a;
  for (size_t i = 1; i < 63; ++i) {
    for (size_t j = 0; j < n; ++j)
      dp[i][j] = dp[i-1][dp[i-1][j]];
  }

  size_t res = 0;
  for (size_t ki = 63; ki--;) {
    if (~k >> ki & 1) continue;
    res = dp[ki][res];
  }

  printf("%zu\n", res+1);
}


Measured memory_bytes: 104420
#include<stdio.h>
int main(){
int a,b,c,i;
while(scanf("%d%d",&a,&b) != EOF){
c = a + b;


if(c < 10)printf("1\n");
else if(10 <= c && c < 100)printf("2\n");
else if(100 <= c && c < 1000)printf("3\n");
else if(1000 <= c && c < 10000)printf("4\n");
else if(10000 <= c && c < 100000)printf("5\n");
else if(100000 <= c && c < 1000000)printf("6\n");
else if(1000000 <= c)printf("7\n");
}
return 0;
}

Measured memory_bytes: 584
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort()
q.sort()

for _ in range(x):
    r.append(p.pop(-1))

for _ in range(y):
    r.append(q.pop(-1))

r.sort()

d = 0
for _ in range(x + y):
    d += r.pop(-1)

print(d)

Measured memory_bytes: 22720
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int N = Integer.parseInt(S[0]);
    int K = Integer.parseInt(S[1]);
    long[] val = new long[N];
    for(int i = 0; i < N; i++){
      val[i] = Long.parseLong(sc.next());
    }
    Arrays.sort(val);
    long ans = 0;
    for(int i = 0; i < N-K; i++){
      ans += val[i];
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 62164
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

ll Mod = 1e9 + 7;
int main()
{
    int N, ans = -1, cnt, A;
    cin >> N;

    for (int i = 1; i <= N; i++) {
        cnt = 0;
        int tmp = i;
        while (tmp%2 == 0) {
            tmp = tmp / 2;
            cnt++;
        }
        if (ans < cnt) {
            A = i;
            ans = cnt;
        }
    }
    cout << A << endl;
    return 0;
}

Measured memory_bytes: 256