akhauriyash/Code-Regression huggingface dataset:
void main()
{
    long a, b;
    rdVals(a, b);

    foreach (i; 1 .. 10001)
    {
        long x = i * 8 / 100;
        long y = i * 10 / 100;

        if (x == a && y == b)
        {
            i.writeln;
            return;
        }
    }

    writeln(-1);
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include<iostream>
using namespace std;
struct Card {char suit,value;};
void bubble(struct Card A[],int N){
    for(int i =0;i<N;i++){
        for(int j=N-1;j>=i+1;j--){
            if(A[j].value<A[j-1].value){
                Card t=A[j];A[j]=A[j-1];A[j-1]=t;
            }
        }
    }
}
void selection(struct Card A[],int N){
    for(int i=0;i<N;i++){
        int minj=i;
        for(int j=i;j<N;j++){
            if(A[j].value<A[minj].value)minj=j;
        }
        Card t=A[i];A[i]=A[minj];A[minj]=t;
    }
}
void print(struct Card A[],int N){
    for(int i=0;i<N;i++){
        if(i>0)cout<<" ";
        cout << A[i].suit << A[i].value;
    }
    cout << endl;
}
bool isStable(struct Card C1[],struct Card C2[],int N){
    for(int i=0;i<N;i++){
        if(C1[i].suit !=C2[i].suit)return false;
    }
    return true;
}
int main(){
    Card C1[100],C2[100];
    int N;
    char ch;
    cin >> N;
    for(int i=0;i<N;i++){
        cin>>C1[i].suit>>C1[i].value;
    }
    for(int i=0;i<N;i++)C2[i]=C1[i];
    bubble(C1,N);
    selection(C2,N);
    print(C1,N);
    cout<<"Stable"<<endl;
    print(C2,N);
    if(isStable(C1,C2,N)){
        cout<<"Stable"<<endl;
    }else{
        cout<<"Not stable" <<endl;
    }
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>

int main(){
    using namespace std;
    int n,k;
    cin >> n;
    cin >> k;
    int p[n];
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    int num[k];
    for(int i=0;i<k;i++){
        int min = 1001;
        int index = 0;
        for(int j=0;j<n;j++){
            if(p[j] != -1 && p[j]<min){
                min = p[j];
                index = j;
            }
        }
        num[i] = min;
        //cout << "input " << num[i];
        p[index] = -1;
    }
    int sum=0;
    for(int i=0;i<k;i++){
        sum += num[i];
    }
    cout << sum;
}

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

#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const int mod = 1e9+7;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    vector<ll>v(n);
    for(auto &i:v){
        cin >> i;
    }
    sort(v.begin(),v.end());
    ll ans = 0;
    f(n - k){   
        ans += v[i];
    }
    cout << ans << '\n';
}

Measured memory_bytes: 1792
/*Lucky_Glass*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

const int N=300;

int r,c;
char maz[N+30][N+30];
int ans[N+30][N+30];
bool xx[N+30];

int main(){
	scanf("%d%d%*d",&r,&c);
	for(int i=1;i<=r;i++)
		scanf("%s",maz[i]+1);
	int lasr=1,cnt=0;
	for(int i=1;i<=r;i++){
		int lef=1;
		bool non=true;
		for(int j=1;j<=c;j++)
			if(maz[i][j]=='#'){
				non=false;
				cnt++;
				// printf("? %d %d %d %d\n",i,j,cnt,lef);
				for(int k=lasr;k<=i;k++){
					ans[k][lef]+=cnt;
					ans[k][j+1]-=cnt;
					xx[k]=false;
				}
				lef=j+1;
			}
		if(!non){
			for(int j=lasr;j<=i;j++)
				ans[j][lef]+=cnt;
			lasr=i+1;
		}
		else xx[i]=true;
	}
	for(int i=1;i<=r;i++){
		for(int j=1;j<=c;j++){
			if(xx[i])
				ans[i][j]=ans[i-1][j];
			else
				ans[i][j]+=ans[i][j-1];
			printf("%d",ans[i][j]);
			if(j==c) putchar('\n');
			else putchar(' ');
		}
	}
	return 0;
}


Measured memory_bytes: 1152
const input = require("fs").readFileSync("/dev/stdin", "utf8")
;(input => {
    const rows = input.split('\n')
    const N = rows[0].split(' ').map(Number)[0]
    const M = rows[0].split(' ').map(Number)[1]
    const X = rows[1].split(' ').map(Number)

    X.sort((a, b) => a - b)

    const dp = []
    for (var i = 0; i < M - 1; i++) {
        dp[i] = X[i + 1] - X[i]
    }

    dp.sort((a, b) => b - a)
    dp.splice(0, N - 1)

    console.log(dp.length ? dp.reduce((a, b) => a + b) : 0)

})(input)


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int main() {
    int k, n;
    cin >> k >> n;
    cout << (500 * k >= n ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] args){
		int n;
		int[] a=new int[100];
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		for(int i=0;i<n;i++){
			a[i]=sc.nextInt();
		}
		for(int i=n-1;i>0;i--){
			System.out.print(a[i]+" ");
		}
		System.out.println(a[0]);
    }
}



Measured memory_bytes: 26236
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n;
  cin >> n;
  long long d[n];
  for(int i=0;i<n;i++){
    cin >> d[i];
  }
  sort(d, d+n);
  cout << d[n/2]-d[n/2-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
using namespace std;
typedef unsigned long long ull;
typedef pair<ll, ll>P;

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

const ll mod = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool fl = false;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
string abc = "abcdefghijklmnopqrstuvwxyz";
struct edge { ll to, cost; };
struct edge1 { ll from, to, cost; };
double pai = 3.141592653589793;

int main() {
	int n, d, x, ans = 0;
	cin >> n >> d >> x;
	ans += x;
	for (int i = 0;i < n;i++) {
		int a;
		cin >> a;
		for (int j = 1;j <= d;j += a) {
			ans++;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
from itertools import accumulate as acc
N, K, *A = map(int, open(0).read().split())
B = [0]+list(acc(A))
M = list(acc(a if a>0 else 0 for a in A))
ans = -10**30
for i in range(N-K+1):
  mi = B[i+K]-B[i]
  c = M[N-1] - M[i+K-1]
  if i>0:
    c += M[i-1]
  ans = max(ans,mi+c,c)
print(ans)


Measured memory_bytes: 16780
#include <iostream>
#include <math.h>
#include <cstring>
#include <vector>
using namespace std;

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

    int k;
    float a, b;
    cin >> k >> a >> b;
    int low = ceil(a/k);
    int high = floor(b/k);
    if(high-low>=0) cout << "OK" << endl;
    else cout << "NG" << endl;

    return 0;
}

Measured memory_bytes: 3688
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
using namespace std;
int n,k;
vector<int> e[2222];
int dp[2222][2222];
int tmp[2222];
int sz[2222];
void upd(int&x,int y){
	if(x==-1 || x>y)x=y;
}
void dfs(int x,int f){
	dp[x][0] = 1;
	for(int i=1; i<=k; i++)
		dp[x][i] = 0;
	sz[x] = 1;
	for(vector<int>::iterator it = e[x].begin(); it!=e[x].end(); it++){
		int y=*it;
		if(y == f)continue;
		dfs(y,x);

		memset(tmp,-1,sizeof(tmp));
		for(int j=0; j<=k; j++){
			if(j<k)upd(tmp[max(j+1,k-j)],dp[y][j]+dp[x][k-j]);
			if(j)upd(tmp[max(j,k-j+1)],dp[y][k-j]+dp[x][j]);

			if(j==0)upd(tmp[j], dp[x][0] + dp[y][0]);else
			if(j*2-1<=k)
				upd(tmp[j], dp[x][j] + dp[y][j-1]);
		}
		for(int j=0; j<=k; j++){
			dp[x][j] = tmp[j];
			if(j)dp[x][j] = min(dp[x][j],dp[x][j-1]);
		}
		sz[x] += sz[y];
	}
//	for(int j=0; j<=k; j++)
//		printf("%d %d: %d\n", x, j, dp[x][j]);
}
int main(){
	scanf("%d%d",&n,&k);
	++k;
	for(int i=1; i<n; i++){
		int x,y;
		scanf("%d%d",&x,&y);
		e[x].push_back(y);
		e[y].push_back(x);
	}
	dfs(1,1);
	int res = -1;
	for(int i=1; i<=n; i++)
		upd(res, dp[i][k] + n - sz[i]);
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 17920
//ITP1_6_B
//????????????  ???

using System;
using System.Collections.Generic;

class ITP1_6_B
{
    static void Main(string[] args)
    {
        //n??????????????°?????£??\

        int n = int.Parse(Console.ReadLine());

        bool[,] barray = new bool[4, 13];
        string[] sarray = new string[n];

        //n???sarray???????????£??\

        for (int i = 0; i < n; i++)
        {
            sarray[i] = (Console.ReadLine());

            //????????§????????????st???????´???????barray?????????????????´??????true????????????

            string[] st = sarray[i].Split(' ');
            barray[ch(st[0]), int.Parse(st[1]) - 1] = true;

        }

        //?¶???????????????????????????????????????????
        for (int row = 0;row < 4; row++)
        {
            for(int columm = 0;columm < 13; columm++)
            {
                if(barray[row, columm] == false)
                    Console.WriteLine(ch(row) + " "+ (columm+1));
            }
        }

    }

    private static int ch(string v)
    {
        switch (v)
        {
            case "S":
                return 0;

            case "H":
                return 1;

            case "C":
                return 2;

            case "D":
                return 3;

            default:
                break;
        }

        return 0;
    }

    private static string ch(int v)
    {
        switch (v)
        {
            case 0:
                return "S";

            case 1:
                return "H";

            case 2:
                return "C";

            case 3:
                return "D";

            default:
                break;
        }

        return "error";
    }

}

/*class card
{
    public int num;
    public string mark;


}*/

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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; }

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n, -1) { }
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    void merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return;
        if (-par[x] < -par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
    }
};

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

    int N;
    cin >> N;

    vector<ll> x(N), y(N);
    for(int i = 0; i < N; i++) cin >> x[i] >> y[i];

    using pint = pair<int, int>;
    using Edge = pair<ll, pint>;
    vector<Edge> edges;

    vector<int> ids(N);

    iota(ids.begin(), ids.end(), 0);
    
    sort(ids.begin(), ids.end(), [&](int i, int j){return x[i] < x[j];});
    for(int i = 0; i + 1 < ids.size(); ++i){
      int u = ids[i], v = ids[i+1];
      edges.push_back(Edge(x[v]-x[u], pint(u, v)));
    }

    sort(ids.begin(), ids.end(), [&](int i, int j){return y[i] < y[j];});
    for(int i = 0; i + 1 < ids.size(); ++i){
      int u = ids[i], v = ids[i+1];
      edges.push_back(Edge(y[v]-y[u], pint(u, v)));
    }

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

    UnionFind uf(N);

    ll res = 0;
    for(auto e : edges){
      int u = e.second.first, v = e.second.second;
      ll cost = e.first;
      if(uf.issame(u, v)) continue;
      uf.merge(u, v);
      res += cost;
    }

    cout << res << endl;

    return 0;
}



Measured memory_bytes: 8432
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

char c[5];

int main(){
	scanf("%s",c);
	int ans = 0;
	for(int i = 0; i < 4; i++)
		if(c[i] == '-') ans--;
		else ans++;
	cout << ans;
}

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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> ls(n);
  for (auto &l : ls) {
    cin >> l;
  }
  
  vector<int> ds;
  ds.emplace_back(0);
  for (auto &l : ls) {
    ds.emplace_back(*ds.rbegin() + l);
  }
  
  cout << distance(ds.begin(), upper_bound(ds.begin(), ds.end(), x)) << endl;
  
  return 0;
}

Measured memory_bytes: 256
n, y = map(int, input().split())

for i in range(y//10000 + 1):
  for j in range(y//5000 + 1):
    if (y-i*10000-j*5000)//1000 == n-i-j and n-i-j>=0:
      print(i, j, n-i-j)
      exit()
      
print(-1, -1, -1)

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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())
#define all(a) (a).begin(), (a).end()

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

//print
#define pv(val) cerr << #val << '=' << (val) << endl

const int INF = 1e9;

int main(void){

	int N, K; cin >> N >> K;

	vector<int> p(N);
	REP(i,N) cin >> p[i];
	
	SORT(p);

	int ans = 0;
	REP(i,K) ans += p[i];
	
	cout << ans << endl;


	return 0;

}


Measured memory_bytes: 3628
import java.util.*;

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

        int N = sc.nextInt();
        int[] H = new int[N];

        if(N==1){
            System.out.println("Yes");
            return;
        }

        for(int i=0; i<N; i++){
            H[i] = sc.nextInt();
        }
        
        for(int i=N-1; i>=1; i--){
            if(H[i]+1==H[i-1]){
                H[i - 1] -= 1;
            }
            else if(H[i]+1<H[i-1]){
                System.out.println("No");
                return;
            }
            if(i==1){
                System.out.println("Yes");
            }
        }
    }
}

Measured memory_bytes: 50384
#include<iostream>

using namespace std;

int a[220];

int main(){
    int N,ans=0;
    cin >> N;
    for (int i = 0;i < N;i++){
        cin >> a[i];
    }

    while(true){
        bool odd = false;
        for (int i = 0;i < N;i++){
        if(a[i] % 2 == 1){
            odd = true;
        }
    }
    if(odd){
        break;
    }
        for(int j = 0;j < N;j++){
            a[j] /= 2;
        }
        ans++;
    }
    cout << ans << endl;
}

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

void solve() {
    long long a, b, c, d, n;
    cin >> a >> b >> c >> d;
    cin >> n;
    long long min_abc = min(c, min(4 * a, 2 * b));
    long long ans = 0;
    if (d < 2 * min_abc) {
        ans = d * (n / 2);
        if (n % 2 != 0) {
            ans += min_abc;
        }
    } else {
        ans = min_abc * n;
    }
    cout << ans << endl;
}

int main() {
//    freopen("/Users/simon/Downloads/test.in", "r", stdin);
    //    freopen("/Users/simon/Downloads/test.out", "w", stdout);
    solve();
}


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

int main() 
{
    int n;
    cin >> n;
    vector<int> v;
    for (int i=0; i<=25; i++)
        for (int j=0; j<=14; j++)
            v.push_back(4*i+7*j);
    vector<int>::iterator it = find(v.begin(), v.end(), n);
    if (it != v.end())
	    cout << "Yes";
    else
	    cout << "No";
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

const MOD: i64 = 1_000_000_007;

fn main() {
    let (n, m) = scan!(usize, usize);
    let vs = scan!(usize; m);
    let mut dp = vec![0; n + 1];
    for v in vs {
        dp[v] = -1;
    }
    dp[0] = 1;
    if dp[1] != -1 {
        dp[1] = 1
    }

    for i in 2..dp.len() {
        if dp[i] == -1 {
            continue;
        }

        if dp[i - 1] != -1 {
            dp[i] += dp[i - 1]
        }
        dp[i] %= MOD;
        if dp[i - 2] != -1 {
            dp[i] += dp[i - 2]
        }
        dp[i] %= MOD;
    }
    println!("{}", dp[n]);
}


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

int main()
{
	int a;
	while(cin>>a)
	{
	int b =0;
	for(int c=0;c<10;c++)
		for(int d =0;d<10;d++)
			for(int e =0;e<10;e++)
				for(int f =0;f<10;f++)
				{
					if
						(c+d+e+f==a)
						b=b+1;
				}
				cout<<b<<endl;
	}
				
}

Measured memory_bytes: 3000
n=int(input())
XY=[list(map(int,input().split()))+[i] for i in range(n)]

XY.sort(key=lambda x:(x[0],x[1]))
edges=[]
for i in range(1,n):
  a,b,c,d=XY[i-1][0],XY[i-1][1],XY[i][0],XY[i][1]
  edges.append((abs(a-c),XY[i-1][2],XY[i][2]))
XY.sort(key=lambda x:(x[1],x[0]))
for i in range(1,n):
  a,b,c,d=XY[i-1][0],XY[i-1][1],XY[i][0],XY[i][1]
  edges.append((abs(b-d),XY[i-1][2],XY[i][2]))
  
group=[i for i in range(n)]
def find(x):
  while group[x]!=x:
    x=group[x]
  return x
def union(x,y):
  if find(x)!=find(y):
    group[find(y)]=group[find(x)]=min(find(y),find(x))
    
edges.sort()
ans=0
for c,x,y in edges:
  if find(x)!=find(y):
    union(x,y)
    ans+=c
print(ans)


Measured memory_bytes: 55372
//
// Created by Tzyark on 2018/9/19.
// 题意：两个人玩石头剪子布，赢了得一分，输了扣一分，平局不得分。规定只能出石头和布。
//      已知对手的出招步骤。在保证到任何一轮出石头的次数都要大于等于出布的次数的情况下，求这个人最多的多少分。
// 贪心的出招，尽可能出布。
#include <iostream>
using namespace std;
int main() {
    string s;
    cin >> s;
    int g = 0;
    int p = 0;
    int ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'g') {
            if (p < g) p++, ans++;
            else g++;
        } else {
            if (p < g) p++;
            else g++, ans--;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main()
{
    int a[9][9],b;
    for(int j=0;j<9;j++)
        for(int i=0;i<9;i++)
        {
            a[i][j]=(i+1)*(j+1);
        }
    cin >> b;
    for(int j=0;j<9;j++)
        for(int i=0;i<9;i++)
        {
            if(a[i][j]==b)
            {
                cout<<"Yes";
                return 0;
            }
        }
            cout<<"No";
}


Measured memory_bytes: 256
import sys
import math
import numpy as np
from collections import Counter, defaultdict, deque

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)


def S():
    return input().rstrip()


def I():
    return int(input())


def MI():
    return map(int, input().split())


inf = float("inf")

n, m = MI()
way = defaultdict(set)
for _ in range(m):
    a, b = MI()
    way[a].add(b)
    way[b].add(a)

passed = [0] * (n + 1)
q = set([1])
while q:
    qq = set()
    for room in q:
        for next in way[room]:
            if not passed[next]:
                passed[next] = room
                qq.add(next)
    q = qq

if all(passed[2:]):
    print("Yes")
    for p in passed[2:]:
        print(p)
else:
    print("No")


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

using namespace std;

int main() {
	int n, a;
	int dpLen[101];

	memset(dpLen, 0, sizeof(dpLen));
	cin >> n;
	for (int i = 1; i <= n; ++i) {
		cin >> a;
		if (a == 0) {
			continue;
		}
		dpLen[i] = dpLen[i - 1] + 1;
	}
	cout << *max_element(dpLen, dpLen + n + 1) + 1 << endl;

	return 0;
}


Measured memory_bytes: 3124
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#define ll long long
using namespace std;
const int N=101101;
int c[N];
ll n;
int solve(int x){
	int sum=0;
	for (int i=1; i<=100; i++)
		if (x>=i)	x-=i,sum++;
		else break;
	return sum;
}
int main(){
	scanf("%lld",&n);
	ll q=sqrt(n);
	int tot=0;
	for (int i=2; i<=q; i++){
		if (n%i==0){
			tot++;
			while (n%i==0)	c[tot]++,n/=i;
		}
	}
	if (n!=1)	c[++tot]=1;
	int ans=0;
	for (int i=1; i<=tot; i++)
		ans=ans+solve(c[i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2156
import java.util.*;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		// System.out.println(s);
		if(s.equals("Sunny")){
			System.out.println("Cloudy");
		}else if(s.equals("Cloudy")){
			System.out.println("Rainy");
		}else if(s.equals("Rainy")){
			System.out.println("Sunny");
		}
	}
}

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

int main(){
    int a,b,c,max=INT_MIN, ans=1, k;
    int d,e;
    cin >> a >>b >> c;
    cin >> k;
    if(a >= b && a>= c){
        max = a;
        d=b;
        e=c;
    }else if(b >= a && b >= c){
        max = b;
        d=a;
        e=c;
    }else{
        max = c;
        d=a;
        e=b;
    }
    for(int i=0;i < k; i++){
        max *= 2;
    }
    ans = max + d+ e;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
#-*- coding: utf-8 -*-

import sys

if __name__ == '__main__':
    while 1:
        line = raw_input()
        if line == '0 0':
            break
        a, b = map(int, line.split())
        print '#'*b
        for i in range(a-2):
        	print '#'+'.'*(b-2)+'#'
        print '#'*b
        print


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

int main(){
  int n; double t,a; cin >> n >>  t >> a;
  int ans = 0;
  double ans_d = 1000000000000000000.0;
  rep(i,n){
    int ii; cin >> ii;
    double Tx = t - ii*0.006;
    if(fabs(Tx - a) < fabs(ans_d - a)){
      ans_d = Tx;
      ans = i;
    }
  }
  cout << ans+1 << endl;
}

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll S[2005];
ll T[2005];

ll dp[2005][2005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    REP(i, N) {
        cin >> S[i];
    }
    REP(i, M) {
        cin >> T[i];
    }
    memset(dp, 0, sizeof(dp));
    REP(i, M + 1) {
        dp[0][i] = 1;
    }
    REP(i, N) {
        dp[i + 1][0] = 1;
        REP(j, M) {
            dp[i + 1][j + 1] = dp[i + 1][j] + dp[i][j + 1];
            if (S[i] != T[j])
                dp[i + 1][j + 1] -= dp[i][j];
            dp[i + 1][j + 1] = (dp[i + 1][j + 1] + MOD) % MOD;
        }
    }

    cout << dp[N][M] << endl;
    return 0;
}

Measured memory_bytes: 31744
#include<stdio.h>
int main()
{
int q,i,x1,y1,x2,y2,x3,y3,x4,y4;
scanf("%d",&q);
for(i=1;i<=q;i++)
{
scanf("%d%d%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
if((x2-x1)==0 && (x4-x3)==0)
{
printf("2\n");
}
else if(((x2-x1)==0 && (y4-y3)==0)||((x4-x3)==0 && (y2-y1)==0))
{
printf("1\n");
}
else if((x2-x1)==0 || (x4-x3)==0)
{
printf("0\n");
}
else
{
if(((y2-y1)*(x4-x3))-((y4-y3)*(x2-x1))==0)
{
printf("2\n");
}
else if(((x2-x1)*(x4-x3))+((y2-y1)*(y4-y3))==0)
{
printf("1\n");
}
else
{
printf("0\n");
}
}
}
return 0;
}



Measured memory_bytes: 2140
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;
int main() {
long long S, ans = 0;
cin >> S;
int len = to_string(S).size() - 1;
for (int i = 0; i < pow(2, len); ++i) {
        long long temp = 0;
        for (int j = 0; j < len; ++j) {
                long long a = pow(10, len + 1 - j); 
                if ((i >> (len - 1 - j)) & 1) {
                        ans += temp + (S % a) / (a / 10);
                        temp = 0;
                } else {
                        temp *= 10; 
                        long long b = (S % a) / (a / 10);
                        temp += b * 10; 
                }   
        }   
        ans += temp + S % 10; 
}
cout << ans << endl;
}

Measured memory_bytes: 256
function myout(text){console.log(text);}//standard output
function Main(input) {
	//input = parseInt(input);
	//input = input.split(" ");
	//input = input.split("\n");
	//input = input.split(" ").map((a)=>Number(a));
	input = input.split("\n").map((a)=>Number(a));
  var N = input[0];
  input.shift();
  var output = "second";
  for(var i = 0; i < N; i++){
    if(input[i] % 2 == 1){
       output = "first";
      break;
    }
  }
  myout(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 17816
// inputに入力データ全体が入る
function Main(input) {
	var ans = 0
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.trim().split("\n").slice(1)
	input.sort()
	for (var i = 0; i < input.length; i++) {
		if (input[i - 1]) {
			if (input[i - 1] !== input[i]) {
				ans++
			} 
		} else {
			ans = 1
		}
	}

	//出力
	console.log(ans)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require('fs').readFileSync('./input.txt', 'utf-8'));

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

ll mpow(ll x, ll p){
    ll ret = 1;
    while(p != 0){
        if(p % 2){
            ret = (ret * x) %MOD;
            p -= 1;
        }
        x = (x * x) % MOD;
        p /= 2;
    }
    return ret;
}


int main(){
    int n;
    cin >> n;
    int d;
    ll ans = 1;
    vector<int> c(n+1, 0);
    for(int i=0;i<n;i++){
        cin >> d;
        if((i == 0 && d != 0) || (i != 0 && d == 0)) ans = 0;
        c[d]++;
    }
    for(int i=0;i<n;i++){
        ans = (ans * mpow(c[i], c[i+1])) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())
n, k = readmi()
if k == 1:
    print(0)
else:
    a = n - k
    print(a)

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

char getHand(char c)
{
    if (c == 'r')
        return 'p';
    else if (c == 's')
        return 'r';
    else
        return 's';
}

void Main()
{
    int n = in(), k = in(), r = in(), s = in(), p = in();
    string t = in();
    string hand;
    ll ans = 0;
    vector<bool> flag(n, false);

    auto fn = [&](const char c) {
        if (c == 'r')
            return p;
        else if (c == 's')
            return r;
        else
            return s;
    };

    rep(i, n)
    {
        if (i < k)
        {
            ans += fn(t[i]);
            continue;
        }
        if (t[i] == t[i - k])
        {
            if (flag[i - k])
            {
                ans += fn(t[i]);
            }
            else
            {
                flag[i] = true;
            }
        }
        else
        {
            ans += fn(t[i]);
        }
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define int long long
using namespace std;
main(){
int t;
//cin>>t;
//while(t--){
int n , m;
cin>>n>>m;
int A[n];
int sum = 0;
int sum1 = 0;
for(int i=0 ; i<n ; i++){
    cin>>A[i];
    sum += A[i];
}

for(int i=0 ; i<n-1 ; i++){
   int tmp = A[i] + A[i+1];
   if(tmp<=m) continue;
   if(A[i]>m){
        A[i] = m;
        A[i+1] = 0;
   }
   else if(A[i]<=m){
    A[i+1] = m - A[i];
   }
}

for(int i=0 ; i<n ; i++){
    //cout<<A[i]<<" ";
   sum1 += A[i];
}
//cout<<endl;
cout<<sum - sum1<<endl;
//}
}


Measured memory_bytes: 4416
import java.util.*;
import java.util.ArrayList;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        ArrayList<Integer> a = new ArrayList<>();
        for (int i=0;i<n;i++){
            a.add(scanner.nextInt());
        }
        int alice=0;
        int bob=0;
        Collections.sort(a);
        for (int i=0;i<n;i++){
            if (i%2==0){
                alice += a.get(n-i-1);
            }else {
                bob += a.get(n-i-1);
            }
            a.remove(n-i-1);
        }
        System.out.println(alice-bob);

    }

}

Measured memory_bytes: 22996
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int n,x,y;
	cin >> n >> x >> y;
	vector<vector<int> > d(n, vector<int>(n,-1));
	x--;y--;
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < n; j++)
		{
			d[i][j] = min(min(abs(i-j), abs(i-x) + abs(j-y)+1), abs(i-y)+abs(j-x)+1);
		}
	}

	vector<int> count(n,0);
	for(int i = 0; i < n;i++)
	{
		for(int j = 0; j < n; j++)
		{
				// cout << d[i][j] << " " ;
				count[d[i][j]]++;
		}
		// cout << endl;
	}

	for(int i = 1; i < n; i++)
		cout << count[i]/2 << endl;

}

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

#define FAST ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define show(x) cout<<(x)<<endl
#define REP(i,a,n) for (int i=a;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define UM unordered_map
#define PB push_back
#define V vector
#define EPS 1e-8
typedef unsigned long ul;
typedef long long ll;
typedef string str;
/*FIN*/
const ll INF = 1e7;
int main() {
	FAST;
	int n;
	V<int> h(100002,0);
	V<ll> dp(100002);
	cin>>n;
	REP(i,1,n+1) cin>>h[i];

	dp[0] = INF;
	dp[1] = 0;
	REP(i,2,n+1) dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	show(dp[n]);
	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
int main()
{
	int v1, v2, v3;
	std::cin >> v1 >> v2 >> v3;
	if ( v1 < v2 && v2 < v3 )
	{
	std::cout << "Yes" << std::endl;
	}
	else
	{
	std::cout << "No" << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3084
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] p = {3, 5, 7, 11, 13};
		int num = 0;
		for(int i = 0; i < 3; i++) {
			for(int j = i + 1; j < 4; j++) {
				for(int k = j + 1; k < 5; k++) {
					if(p[i] * p[j] * p[k] <= n)num++;
				}
				if(Math.pow(p[i], 3) * p[j] <= n)num++;
			}
			if(Math.pow(p[i], 7) <= n)num++;
		}
		System.out.println(num);
	}
}


Measured memory_bytes: 23764
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-12;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;


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

	cin >> N >> M >> K;
	if (K == 1000000000) {
		vector<int>v(N, 1);
		for (int i = 0; i < M; i++)v[i] = K;
		for (auto i : v)cout << i << " ";
		cout << endl;
		return 0;
	}
	vector<int>v(N, 1000000000);
	for (int i = 0; i < M; i++)v[i] = K;
	for (auto i : v)cout << i << " ";
	cout << endl;

	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int n,fat[100050],num[100050];
vector <int> V[100050];
int dfs(int now,int f)
{
	fat[now]=f;
	int tot=1;
	for(int i=0;i<V[now].size();i++)
		if(V[now][i]!=f)tot+=dfs(V[now][i],now);
	return num[now]=tot;
}
int main()
{
	cin>>n;
	for(int i=1;i<n;i++)
	{
		int x,y;
		cin>>x>>y;
		V[x].push_back(y);
		V[y].push_back(x);
	}
	num[1]=dfs(1,1);
	int z=n,sum=0;
	while(fat[z]!=z)
	{
		sum++;
		z=fat[z];
	}
	z=n;
	for(int i=1;i<=(sum-1)/2;i++)z=fat[z];
	if(num[z]>=n-num[z])cout<<"Snuke";
	else cout<<"Fennec";
	return 0;
} 

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B;
  cin >> A >> B;
  if ((B - 1) % (A - 1) == 0) {
    cout << (B - 1) / (A - 1);
  }
  else {
    cout << (B - 1) / (A - 1) + 1;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 100010
using namespace std;
int main(){
	long long n,a[N],num=0,as[N],sum=0,i;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]<0)
			num++;
		as[i]=abs(a[i]);
		sum+=as[i];
	}
	if(num%2==0)
		cout<<sum<<endl;
	else
	{
		sort(as,as+n);
		cout<<sum-as[0]*2<<endl;
	}
	return 0;
}

Measured memory_bytes: 1792
#include <cmath>//ABC 147-F
#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define LL long long
#define MAXN 400001
#define MOD 1000000007ll
using namespace std;
LL N,X,D;
int stk[MAXN],sum;
bool vis[MAXN];
LL gcd(LL x,LL y)
{
    return y?gcd(y,x%y):x;
}
struct DB{
    LL v;
    int kind,num;
}p[MAXN];
bool comp(DB x,DB y)
{
    return x.v==y.v?x.kind<y.kind:x.v<y.v;
}
int cnt;
LL sig(LL x)
{
    return x<0?-1:1;
}
int main()
{
    cin>>N>>D>>X;
    //D*=2;
    if(X==0&&D==0)
    {
        cout<<1<<endl;
        return 0;
    }
    if(X==0)
    {
        cout<<N+1<<endl;
        return 0;
    }
    LL G=gcd(X,D);
    LL B=abs(X/G);
    LL A=abs(D/G);
    LL ANS=0;
    for(LL i=0;i<B&&i<=N;i++)
    {
        cnt=0;
        for(LL j=0;j+i<=N;j+=B)
        {
            LL U=(j+i)*(j+i-1)/2+j/B*A*sig(X*D),V=(i+j)*(N+N-j-i-1)/2+j/B*A*sig(X*D);
    
            cnt++;
            p[cnt].kind=0;
            p[cnt].v=min(U,V);
            p[cnt].num=j/B;
            
            cnt++;
            p[cnt].kind=1;
            p[cnt].v=max(U,V);
            p[cnt].num=j/B;
        }
        
        sort(p+1,p+cnt+1,comp);
        p[0].v=p[1].v;
        sum=0;
        for(int j=1;j<=cnt;j++)
        {
            if(sum)
            {
                ANS+=(p[j].v-p[j-1].v);
            }
            else
                ANS++;
            if(p[j].kind==0)
            {
                sum++;
                
            }
            else
            {
                sum--;
            }
        }
        //ANS++;
    }
    cout<<ANS<<endl;
    
    return 0;
}


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

int main() {
  string S;
  cin >> S;
  if(S == "SAT"){
    cout << 1;
  }
  if(S == "FRI"){
    cout << 2;
  }
  if(S == "THU"){
    cout << 3;
  }
  if(S == "WED"){
    cout << 4;
  }
  if(S == "TUE"){
    cout << 5;
  }
  if(S == "MON"){
    cout << 6;
  }
  if(S == "SUN"){
    cout << 7;
  }
}

Measured memory_bytes: 3608
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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;}

bool diff[110];

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

  int n;
  string s;
  cin >> n;
  vector<int> b(n), ans(n);
  REP(i, n) cin >> b[i];

  REP(i, n){
    if(i-b[i]+1 < 0){
      cout << -1 << endl;
      return 0;
    }

    if(b[i] != 1){
      int tmp = b[i];
      REP(j, tmp-1) b[i-j] = b[i-j-1];
      b[i-tmp+1] = tmp;
    }
    REP(j, n) cerr << b[j] << " ";
    cerr << endl;
  }
  
  ROF(i,n-1,0) cout << b[i] << endl;
  
  return 0;
}


Measured memory_bytes: 256
/// Zhupengfei 2018
/// Hereby declare: this program is in public domain.

/// Solution for problem:

#include <bits/stdc++.h>

#ifdef LOCAL
#pragma GCC poison printf // To avoid fastio problems
#pragma GCC poison scanf
#endif

using namespace std;

long long dp[5001]={};
int a[5001]={};
const int mod= (int) (1 << 23) * 17 * 7 + 1;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n, K;
	cin>>n>>K;
	dp[0]=1;
	for(int j=0;j<n;j++) {
		cin>>a[j];
		if(a[j]<K) {
			for(int x=K;x>=a[j];x--) {
				dp[x]=(dp[x]+dp[x-a[j]])%mod;
			}
		}
	}
	int ans=0;
	for(int j=0;j<n;j++){
		if(a[j]<=K) {
			for(int x=a[j];x<=K;x++) {
				dp[x]=(dp[x]-dp[x-a[j]] + mod)%mod;
			}
			bool flag=false;
			for(int x=0;x<K;x++){
				if(dp[x]>=1 && x+a[j]>=K) flag=true;
			}
			if(!flag) ans++;
			for(int x=K;x>=a[j];x--) {
				dp[x]=(dp[x]+dp[x-a[j]])%mod;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 384
#include <stdio.h>

int main(){
	int A, B, output = 1;
	scanf("%d %d", &A, &B);
	
	for(int i = 0; i < A; i++){
		(output + B > output*2) ? output *= 2 : output += B;
	}
	
	printf("%d\n", output);
	return 0;
}

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

int main()
{
	int A, B;
	int x;
  	int count = 0;
  
	cin >> A >> B;

  for(int i=A;i<=B;i++){
      if(i%10 == i/10000){
        if((i/10)%10 == (i%10000)/1000){
          count++;
        }
      }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
//#include <functional>
using namespace std;
int main(void){
    int i,a,s=0,t=0;
    cin >> i ;
    vector<int> v(i);
    for(int j=0;j<i;j++){
        cin >> v[j];
    }
    sort(v.begin(),v.end(),greater<int>());
    a=1;
    for(int j=1;j<i;j++){
        if(v[j]==v[j-1]&&a==1){
            if(s==0){
                s=v[j];
            }
            else if(t==0){
                t=v[j];
            }
            a=0;
        }
        else{
            a=1;
        }
    }
    if(t==0){
        cout<< 0;
    }
    else{
        cout<<(long long int)s*t;
    }
}


Measured memory_bytes: 640
s = input()
i = res = 0
tmp = ''
while i < len(s):
  if tmp == s[i]:
    if i == len(s) - 1:
      break
    else:
      tmp = s[i] + s[i+1]
      i += 2
  else:
    tmp = s[i]
    i += 1
  res += 1
print(res)

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

int main() {
    string s;
    cin >> s;
    int topping = 0;
    for (int i = 0; i < 3; i++){
        if(s.at(i) == 'o') topping++;
    }
    cout << 700 + 100 * topping << endl;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(){
   int a, b, c, d, e, f;

   scanf("%d", &a);
   scanf("%d", &b);
   scanf("%d", &c);

   if (a > b) {
      d = a;
      a = b;
      b = d;
   }

   if (b > c) {
      e = b;
      b = c;
      c = e;
   }

   if (a > b) {
      f = b;
      b = a;
      a = f;
   }

   printf("%d %d %d\n", a, b, c);

   return 0;
}


Measured memory_bytes: 2068
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<list>
#include<algorithm>
#include <ctype.h>
#include<deque>
using namespace std;
using ll = long long int;

ll a, b;

int main(void) {
	cin >> a >> b;

	ll ret = a + b;
	if (ret / 2 * 2 == ret)
		cout << ret / 2 << endl;
	else
		cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define hyperspeed ios::sync_with_stdio(false);cin.tie(NULL);
#define ll long long  
#define ull unsigned long long
#define ui unsigned int
#define li long int
#define uli unsigned long int
#define pb push_back
#define ld long double
#define vi vector<int>
#define vvi vector<vector<int>>
#define vli vector<li>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pi pair<int,int>
#define FOR(i,s,n) for(auto i=s;i<n;++i)
#define FORN(i,s,n) for(auto i=s;i<=n;++i)
#define FORR(i,s,n) for(auto i=s;i>=n;--i)
#define FORE(i,a) for(auto i : a)
#define mp make_pair
const int MOD = 1e9+7;

void solve(int t) {
    int a,b,c;
    int k;
    cin >> a >> b >> c;
    cin >> k;
    int ops = 0;
    while(b<=a) {
        b*=2;
        ops++;
    }
    while(c<=b) {
        c*=2;
        ops++;
    }
    if(ops<=k) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

int32_t main()
{
    hyperspeed
    int test=1;
    int t = 1;
    while(test--) {
        solve(t);
        t++;
    }
    return 0;
}

//--n1m5


Measured memory_bytes: 3688
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N = k()
A = l()
S = sum(A)
minx = S
sum = 0

for x in A:
    sum += x
    minx = min(minx, abs(sum-(S-sum)))

print(minx)


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

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

    double L; cin >> L;
    double e = L / 3;
    double ans = e * e * e;
    cout << fixed << setprecision(10) << ans << "\n";
}

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

using namespace std;
#define forr(i, n) for(ll i = n-1; i >= 0; i--)
#define forn(i, n) for(ll i = 0; i < n; i++)
#define forab(i, a, n) for(ll i = a; i < n; i++)
#define forabr(i, a, b) for(ll i = a; i >= b; i--)
#define endl '\n'
#define f first
#define s second
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(7); cout.setf(ios::fixed);
#define fale_io ifstream fin("grants.in"); ofstream fout("grants.out");
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()

typedef long long ll;
typedef string S;

const ll mod = 1e9 + 7;
const ll Inf = LONG_LONG_MAX;
const double long PI = 3.1415926535;

ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll max(ll a, ll b){if(a > b)return a;return b;}
ll gcd (ll a, ll b) {while (b) {a %= b;swap (a, b);}return a;}
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }

S s;

int main() {
    fast_io;
    cin >> s;
    if((s[2] == s[3]) && (s[4] == s[5]))
        cout << "Yes";
    else
        cout << "No";
}


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

typedef long long ll;

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

  ll T=1, A=1;
  for(int i=0; i<n; i++){
    ll t, a;
    cin >> t >> a;

    ll n=max((ll)ceil((long double)T/t), (ll)ceil((long double)A/a));
    T = t*n;
    A = a*n;
  }

  cout << T+A << endl;

  return 0;
}


Measured memory_bytes: 512