akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(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);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};

int main(){
  ll a,b,N;
  cin>>a>>b>>N;
  ll x = min(N, b-1);
  cout<<floor(a*x/b) - a*floor(x/b)<<endl;
  return 0;
}


Measured memory_bytes: 3796
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
int ABS(int a){
	return max(a,-a);
}
int dp1[1<<7][7];
int dist[1<<7];
long long dp2[8][10100];
long long val[1<<7];
long long dp3[11000];
char in[20];
int v[20];
int p[20];
int x[20];
int y[20];
int g[20][20];
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	map<string,int> m;
	for(int i=0;i<b;i++){
		scanf("%s%d%d",in,v+i,p+i);
		string tmp=in;
		m[tmp]=i;
	}
	for(int i=0;i<a;i++)for(int j=0;j<b;j++)
		g[i][j]=-1;
	for(int i=0;i<a;i++){
		int q;
		scanf("%d%d%d",&q,x+i,y+i);
		for(int j=0;j<q;j++){
			int r;
			scanf("%s%d",in,&r);
			string tmp=in;
			int num=m[tmp];
			if(p[num]>r)g[i][num]=p[num]-r;
		}
	}
	for(int i=0;i<(1<<a);i++)for(int j=0;j<a;j++)
		dp1[i][j]=999999999;
	for(int i=0;i<a;i++)dp1[1<<i][i]=ABS(x[i])+ABS(y[i]);
	for(int i=0;i<(1<<a);i++)for(int j=0;j<a;j++){
		for(int k=0;k<a;k++){
			dp1[i|(1<<k)][k]=min(dp1[i|(1<<k)][k],dp1[i][j]+ABS(x[j]-x[k])+ABS(y[j]-y[k]));
		}
	}
	for(int i=0;i<(1<<a);i++){
		dist[i]=999999999;
		for(int j=0;j<a;j++)dist[i]=min(dist[i],dp1[i][j]+ABS(x[j])+ABS(y[j]));
	}
	for(int i=0;i<(1<<a);i++){
		for(int j=0;j<=a;j++)for(int k=0;k<=c;k++)dp2[j][k]=-999999999;
		dp2[0][0]=0;
		for(int j=0;j<a;j++)for(int k=0;k<=c;k++){
			dp2[j+1][k]=max(dp2[j+1][k],dp2[j][k]);
			if(!(i&(1<<j)))continue;
			for(int l=0;l<b;l++)if(~g[j][l]&&k+v[l]<=c)dp2[j][k+v[l]]=max(dp2[j][k+v[l]],dp2[j][k]+g[j][l]);
		}
		for(int j=0;j<=c;j++)val[i]=max(val[i],dp2[a][j]);
	}
	for(int i=0;i<d;i++){
		for(int j=0;j<(1<<a);j++){
			if(i+dist[j]<=d)dp3[i+dist[j]]=max(dp3[i+dist[j]],dp3[i]+val[j]);
		}
	}
	long long ret=0;
	for(int i=0;i<=d;i++)ret=max(ret,dp3[i]);
	printf("%lld\n",ret);
}

Measured memory_bytes: 1796
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
  int n;
  ll o = 0;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a.at(i);
    o += (a.at(i) - 1) / 2;
    if(a.at(i))
      a.at(i) = (a.at(i) - 1) % 2 + 1;
  }
  if(a.at(0) == 2) {
    o++;
    a.at(0) = 0;
  }
  for(int i = 1; i < n; i++) {
    if(a.at(i - 1) == 1 && a.at(i)) {
      o++;
      a.at(i)--;
    } else if(a.at(i) == 2) {
      o++;
      a.at(i) = 0;
    }
  }
  cout << o << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
	double n;cin>>n;
	double x=ceil(n/1.08);
	if((int)floor(x*1.08)==int(n)){
		cout<<x<<endl;
		return 0;
	}
	if((int)floor((x-1)*1.08)==int(n)){
		cout<<x-1<<endl;
		return 0;
	}
	cout<<":("<<endl;
	return 0;
}

Measured memory_bytes: 256
import datetime
year,month,day = map(int, input().split("/"))
comp1 = datetime.datetime(year, month, day, 0, 0, 0)
comp2 = datetime.datetime(2019, 4, 30, 0, 0, 0)
print("Heisei" if (comp1 <= comp2) else "TBD")


Measured memory_bytes: 9340
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

#include <inttypes.h>
using namespace std;

int main()
{
	int32_t H, W, N;
	scanf("%d%d%d", &H, &W, &N);

	int32_t colors[10000];
	memset(colors, 0, sizeof(colors));
	int32_t color_index = 0;
	for (int32_t i = 0; i < N; i++) {
		int32_t a;
		scanf("%d", &a);
		for (int32_t j = 0; j < a; j++) {
			colors[color_index++] = i + 1;
		}
	}

	int32_t res[100][100];
	color_index = 0;
	for (int32_t row = 0; row < H; row++) {
		if (row % 2 == 0) {
			for (int32_t col = 0; col < W; col++) {
				res[row][col] = colors[color_index++];
			}
		} else {
			for (int32_t col = W - 1; col >= 0; col--) {
				res[row][col] = colors[color_index++];
			}
		}
	}

	for (int32_t row = 0; row < H; row++) {
		for (int32_t col = 0; col < W; col++) {
			printf("%d", res[row][col]);
			if (col < W - 1)
				printf(" ");
		}
		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#include <limits>
#include <set>
#include <stack>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define Max(a,b) ((a) < (b) ? (b) : (a))
#define Min(a,b) ((a) > (b) ? (b) : (a))
#define AAA (1000000007)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pairII;


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


int main() {
	int i, j, k;
	//int N, M, K;

	int A[200000];
	int color[200000] = { 0 };
	ll N, K;
	cin >> N >> K;
	//N = 200000;
	rep(i, 0, N) {
		cin >> A[i];
//		A[i] = i + 2;
		A[i]--;
	}
	vector<int> B;
	vector<int> C;
	bool isClose = false;
	int a = 0;
	int ToLoop = 0;
	while (!isClose)
	{
		color[a] = 1;
		B.push_back(a);
		int b = A[a];
		//次が探索済みなら
		if (color[b] == 1) {
			isClose = true;
			int c=0;
			while (B[c] != b) {
				c++;
			}
			ToLoop = c;
			while (B[c] != a) {
				C.push_back(B[c]);
				c++;
			}
			C.push_back(B[c]);

		}
		a = b;

	}

	if (ToLoop >= K) {
		cout << B[K]+1;
		return 0;
	}
	K -= ToLoop;
	K %= C.size();
	cout << C[K]+1;


	return 0;

}


Measured memory_bytes: 7132
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    vint a(n); rep(i,n) cin >> a[i];
    int res=0;
    rep(i,n){
        if(i%2==0 && a[i]%2==1) res++;
    }
    cout<<res<<endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];

void print_arr(vector<int> &a){
    rep(i,a.size()-1){
        printf("%d ",a[i]);
    }
    printf("%d\n",a[a.size()-1]);
}

int cnt = 0;

void insertion_sort(vector<int> &a, int g){
    reps(i,g,(int)a.size()-1){
        int v = a[i];
        int j = i - g;
        while(j>=0 && a[j]>v){
            a[j+g] = a[j];
            j -= g;
            cnt++;
        }
        a[j+g] = v;
    }
}

void shell_sort(vector<int> &a){
    int n = (int)a.size();
    cnt = 0;
    vector<int> g;
    if(n==1) g.push_back(1);
    while(n>1){
        n = ceil(n/2);
        g.push_back(n);
    }
    rep(i, g.size()) insertion_sort(a, g[i]);
    
    cout << g.size() << endl;
    print_arr(g);
    cout << cnt << endl;
    rep(i,a.size()) cout << a[i] << endl;
}

int main(){
    int n; cin >> n;
    vector<int> a(n);
    collect(a, n);
    shell_sort(a);
    return 0;
}


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

int main()
{
 int a,b;
  cin >> a >> b;
if (a < b)
{int tmp = a;
 a = b;
 b = tmp;
}
  if (a == 3 && b == 2)
    cout << 1 << endl;
  else if (a == 3 && b == 1)
    cout << 2 << endl;
  else
    cout << 3 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+9;
int a[N],b[N];
int n,m,x,y,z,ans;
string s,t;
int main(){
	cin>>x>>y>>z>>n;
	if(x>=n) ans=n;
	else if(x+y>=n) ans=x;
	else ans=x-(n-x-y);
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 3636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskE solver = new TaskE();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskE {
		FastScanner in;
		PrintWriter out;
		boolean LOCAL_RUN = false;
		final String N = "123";

		public void solve(int testNumber, FastScanner in, PrintWriter out) {
			this.in = in;
			this.out = out;

			if (send("" + (int) 1e9)) {
				int ans = 1;
				while (!send("" + (ans + 1))) {
					ans *= 10;
				}
				out.println("! " + ans);
				out.flush();
				return;
			}

			int len = 1;
			while (send("" + (int) (Math.pow(10, len - 1)))) {
				++len;
			}
			--len;

			int l = (int) (Math.pow(10, len - 1));
			int r = (int) (Math.pow(10, len)) - 1;
			while (r - l > 1) {
				int m = (l + r) / 2;
				if (!send("" + m + "0")) {
					l = m;
				} else {
					r = m;
				}
			}

			out.println("! " + r);
			out.flush();
		}

		private boolean send(String s) {
			if (LOCAL_RUN) {
				boolean u = Long.parseLong(s) <= Long.parseLong(N);
				boolean v = s.compareTo(N) <= 0;
				boolean res = (u && v) || (!u && !v);
				System.out.println(s + " " + res);
				return res;
			}
			out.println("? " + s);
			out.flush();
			return in.next().equals("Y");
		}

	}

	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;

		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}

	}
}



Measured memory_bytes: 23716
#include<bits/stdc++.h>
#define MAX 1000000007
#define ll long long int
#define fo(i,n) for(int i=0;i<n;i++)
#define ull unsigned long long int
#define pb push_back
#define eb emplace_back
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
//    int t;
//    cin>>t;
    int x=1;
//    while(t--) {
     int r;
     cin>>r;
     double circum = 2*r*3.14159265358979323;
     cout<<circum<<endl;



       x++;
//    }
    return 0;
}

Measured memory_bytes: 3800
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <functional>
#include <initializer_list>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
long long gcd(long long a, long long b) {
  // the greatest common divisor
  while (b != 0) {
    long long r = a % b;
    a = b;
    b = r;
  }
  return a;
}
long long lcm(long long a, long long b) {
  // the least common multiple
  return (a / gcd(a, b)) * b;
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int d = a % b;
  REPC(i, 1, b) {
    int e = i * d % b;
    if (e == c) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;

  return 0;
}

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

using namespace std;

#define rep(i, a, b) for(ll i = a; i < ll(b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;

int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin.exceptions(cin.failbit);
    ll a,b;
    cin>>a>>b;
    cout<<a*b/__gcd(a,b)<<endl;
}

Measured memory_bytes: 256
///Code Forces - DP Educational Contest


#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>


const int NMAX = 101;
const int WMAX = 100001;

struct Object {

	long long int v;
	int w;
};


int main() 
{
	int N, W;
	std::cin >> N >> W;
	
	std::vector<Object> objects(NMAX + 1);
	for (int i = 1; i <= N; ++i) {
		std::cin >> objects[i].w >> objects[i].v;
	}
	
	std::vector<long long int> DP(WMAX, 0);

	for (int i = 1; i <= N; ++i) {
		
		std::vector<long long int> new_DP(WMAX, 0);
		for (int j = 1; j <= W; ++j) {
			new_DP[j] = DP[j];

			if (objects[i].w <= j) {
				new_DP[j] = std::max(new_DP[j], DP[j - objects[i].w] + objects[i].v);
			}

		}

		DP = new_DP;

	}
	
	std::cout << DP[W];

	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll bit[100010];
ll n;
void add(ll k,ll x){
  while(k<=n){
    bit[k]+=x;
    k+=k&-k;
  }
}
ll sum(ll k){
  ll ret=0;
  while(k>0){
    ret+=bit[k];
    k-=k&-k;
  }
  return ret;
}
int main(){
  cin>>n;
  vector<ll> b(n);
  for(ll i=0;i<n;i++){
    cin>>b[i];
  }
  fill(bit,bit+n+1,0);
  ll ans=0;
  vector<ll>v=b;
  sort(v.begin(),v.end());
  //v.erase(unique(v.begin(),v.end()),v.end());
  for(ll i=0;i<n;i++){
    ll u=n,d=-1;
    while(true){
      ll mid=(u+d)/2;
      if(v[mid]==b[i]){
        b[i]=mid+1;
        break;
      }
      if(v[mid]>b[i]){
        u=mid;
      }
      if(v[mid]<b[i]){
        d=mid;
      }
    }
  }
  for(ll i=0;i<n;i+=2){
    if(b[i]%2==0)ans++;
  }
  cout<<ans<<endl;
}
  


Measured memory_bytes: 2560
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import random
import re
import string
import sys
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import lru_cache, reduce
from math import gcd
from operator import add, itemgetter, mul, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


a = int(sys.stdin.buffer.readline())
if a >= 1800:
    print(1)
elif a >= 1600:
    print(2)
elif a >= 1400:
    print(3)
elif a >= 1200:
    print(4)
elif a >= 1000:
    print(5)
elif a >= 800:
    print(6)
elif a >= 600:
    print(7)
else:
    print(8)


Measured memory_bytes: 27168
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

/* the recursive version can't go to 2e5 */

const int inf = 1e9;
int n; string s;

bool isW(const int i)
{ return s[i] == '.'; }
bool isB(const int i)
{ return !isW(i); }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    while (cin >> n >> s) {
        s = '.' + s; n++;
        VI sumB(n+1), sumW(n+1);
        FOR(i,1,n)
            sumB[i] += sumB[i-1] + isB(i);
        FORR(i,n-1,0)
            sumW[i] += sumW[i+1] + isW(i);
        int ans = inf;
        FOR(i,0,n)
            ans = min(ans, sumB[i] + sumW[i+1]);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 2128
#include<stdio.h>

int main(){
char c;
  scanf("%c",&c);

  if( 'a'<=c && c <='z' ) printf("a\n");//printf("%c",c);
  else if( 'A'<=c && c <='z' ) printf("A\n",c);
  //all conditon ? not || it is or
    
return 0;
}

Measured memory_bytes: 1996
package main
  
import (
    "fmt"
    "sort"
)

type Shop struct {
    Name   string
    Score  int
    Number int
}
type Shops []Shop

func (a Shops) Len() int {
    return len(a)
}

func (a Shops) Swap(i, j int) {
    a[i], a[j] = a[j], a[i]
}

func (a Shops) Less(i, j int) bool {
    if a[i].Name == a[j].Name {
        return a[i].Score > a[j].Score
    }
    return a[i].Name < a[j].Name
}

func main() {
    var n int
    fmt.Scan(&n)
    ss := make(Shops, n)
    for i := 0; i < n; i++ {
        var s string
        var p int
        fmt.Scan(&s, &p)
        ss[i] = Shop{s, p, i + 1}
    }
    sort.Sort(ss)
    for i := range ss {
        fmt.Println(ss[i].Number)
    }
}


Measured memory_bytes: 512
def Count(N,i):
    return i*N+1-(i*(i-1))
N, K = map(int,input().split())
sumpat=0
bignum = pow(10,9)+7
for i in range(K,N+2):
    # print(Count(N,i))
    sumpat+= Count(N,i)%bignum
print(sumpat%bignum)

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    cout << *max_element(a.begin(), a.end()) -*min_element(a.begin(), a.end()) << endl;
    return 0;
}

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

typedef long long ll;

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

  int n;
  cin >> n;
  ll a[n];
  ll res = 1L, bound = 1e18L;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i] == 0) {
        puts("0");
        return 0;
    }
  }
  for (ll x : a) {
    if (res > bound / x) {
        puts("-1");
        return 0;
    }
    res *= x;
  }
  cout << res << endl;
  return 0;
}

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

// ---------------------------template starts here-------------------------- 

#define int long long int
#define pb push_back
#define MAX INT_MAX
#define endl "\n"
#define precise std::cout << std::fixed;std::cout << std::setprecision(6); 
#define F first
#define S second  
#define mp make_pair
#define MIN INT_MIN
#define MOD 1000000007
#define FO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

set <int> s;
bool ar[100001];
void seive() {
    ar[0] = ar[1] = true;

    for(int p=2; p*p<=100001; p++) {
        if(ar[p] == false) {
            for(int i=p*p;i<=100001;i+=p)
                ar[i] = true ;
        }
    }

    for(int p=2;p<=100001;p++) {
        if(ar[p] == false)
            s.insert(p);
    }
}

bool is_palindrome(string str) {
    int len = str.length();
    for(int i=0;i<=len/2;i++) {
        if(str[i] != str[len-1-i])
            return false;
    }
    return true;
}

int binexpo(int x, int y, int p) {    
    int res = 1;     // Initialize result  
    x = x % p; // Update x if it is more than or  
                // equal to p  

    while (y > 0)  {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;
}
// --------------------------template ends here------------------------------

void solve() {
    int n, m;
    cin >> n >> m;

    vector <int> v(n);
    int sum = 0;

    for(int i=0;i<n;i++) {
        cin >> v[i];
        sum += v[i];
    }     

    sort(v.begin(), v.end(), greater<int>());

    int c = 0;

    for(int i=0;i<n;i++) {
        if(v[i]*4*m >= sum)
            c++;
    }

    if(c >= m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return;
}

int32_t main() {
    FO;
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int main(){
  string s;
  cin >> s;
  bool ans = true;
  if(s[0]==s[1]){
    ans = false;
  }
  else if(s[1]==s[2]){
    ans = false;
  }
  else if(s[2]==s[3]){
    ans = false;
  }
  if(ans){
    cout << "Good" << endl;
  }
  else{
    cout << "Bad" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = INF+7;

struct edge{int to,cost;};
	
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n;
	cin >> n;

	int x[n],y[n],h[n];
	for(int i=0;i<n;i++){
		cin >> x[i] >> y[i] >> h[i];
	}
	bool found=true,yet=true;
	int H;
	int M=2*INF;
	for(int i=0;i<=100;i++){
		for(int j=0;j<=100;j++){
			int th;
			found=true;
			yet=true;
			H=0;
			M=2*INF;

			//cout << i << " " << j << " " << H << "\n";

			for(int k=0;k<n;k++){
				th = abs(x[k]-j)+abs(y[k]-i)+h[k];
				if(h[k]==0){
					M=min(M,th);
					if(H>M){
						found=false;
						break;
					}
				}
				else if(yet){
					H=th;
					yet=false;
					if(H>M){
						found=false;
						break;
					}
				}else{
					if(th != H || th > M){
						found=false;
						break;
					}
				}
			}
			if(found){
				cout << j << " " << i << " " << H << "\n";
				return 0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>

using namespace std;

#define fi first
#define se second
#define mp make_pair

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010;

int n;
int a[N], b[N];
LL h, w;
LL res[10];
map<PII, bool> hm;

inline int F(int x, int y) {
    return hm[mp(x, y)];
}

int main() {
    scanf("%lld%lld%d", &h, &w, &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d%d", &a[i], &b[i]);
        hm[mp(a[i], b[i])] = 1;
    }
    for (int i = 1; i <= n; ++i) {
        int x = a[i], y = b[i];
        if (x + 2 <= h) {
            if (y + 2 <= w) ++res[F(x, y) + F(x + 1, y) + F(x + 2, y) + F(x, y + 1) + F(x + 1, y + 1) + F(x + 2, y + 1) + F(x, y + 2) + F(x + 1, y + 2) + F(x + 2, y + 2)];
            if (1 <= y - 1 && y + 1 <= w) ++res[F(x, y - 1) + F(x + 1, y - 1) + F(x + 2, y - 1) + F(x, y) + F(x + 1, y) + F(x + 2, y) + F(x, y + 1) + F(x + 1, y + 1) + F(x + 2, y + 1)];
            if (1 <= y - 2) ++res[F(x, y - 2) + F(x + 1, y - 2) + F(x + 2, y - 2) + F(x, y - 1) + F(x + 1, y - 1) + F(x + 2, y - 1) + F(x, y) + F(x + 1, y) + F(x + 2, y)];
        }
        if (1 <= x - 1 && x + 1 <= h) {
            if (y + 2 <= w) ++res[F(x - 1, y) + F(x, y) + F(x + 1, y) + F(x - 1, y + 1) + F(x, y + 1) + F(x + 1, y + 1) + F(x - 1, y + 2) + F(x, y + 2) + F(x + 1, y + 2)];
            if (1 <= y - 1 && y + 1 <= w) ++res[F(x - 1, y - 1) + F(x, y - 1) + F(x + 1, y - 1) + F(x - 1, y) + F(x, y) + F(x + 1, y) + F(x - 1, y + 1) + F(x, y + 1) + F(x + 1, y + 1)];
            if (1 <= y - 2) ++res[F(x - 1, y - 2) + F(x, y - 2) + F(x + 1, y - 2) + F(x - 1, y - 1) + F(x, y - 1) + F(x + 1, y - 1) + F(x - 1, y) + F(x, y) + F(x + 1, y)];
        }
        if (1 <= x - 2) {
            if (y + 2 <= w) ++res[F(x - 2, y) + F(x - 1, y) + F(x, y) + F(x - 2, y + 1) + F(x - 1, y + 1) + F(x, y + 1) + F(x - 2, y + 2) + F(x - 1, y + 2) + F(x, y + 2)];
            if (1 <= y - 1 && y + 1 <= w) ++res[F(x - 2, y - 1) + F(x - 1, y - 1) + F(x, y - 1) + F(x - 2, y) + F(x - 1, y) + F(x, y) + F(x - 2, y + 1) + F(x - 1, y + 1) + F(x, y + 1)];
            if (1 <= y - 2) ++res[F(x - 2, y - 2) + F(x - 1, y - 2) + F(x, y - 2) + F(x - 2, y - 1) + F(x - 1, y - 1) + F(x, y - 1) + F(x - 2, y) + F(x - 1, y) + F(x, y)];
        }

    }
    LL sum = 0;
    for (int i = 1; i <= 9; ++i)
        sum += (res[i] /= i);
    res[0] = (h - 2) * (w - 2) - sum;
    for (int i = 0; i <= 9; ++i)
        printf("%lld\n", res[i]);
    return 0;
}

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

#define debug(x) cerr << #x << ": " << x << "\n"
#define all(a) a.begin() ,a.end()
#define rall(a) a.rbegin() ,a.rend()
#define _sort(a) sort(a.begin() ,a.end())

using namespace std;

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

int main(){
    ios::sync_with_stdio(false) ,cin.tie(0);
    int a, b ,c;
    cin >> a >> b >> c;
    swap(a,b);
    swap(a,c);
    cout << a << " " << b << " " << c;
    return 0;
}
/*
*   created: 
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
int mod =1000000007;
const double PI = acos(-1);
ll lcm(ll x, ll y) { return x / __gcd(x, y) * y; }
void factorization(ll n,map<ll,ll>& mp){
    for(ll i=2;i*i<=n;i++){
        while(n%i==0){
            mp[i]++;
            n /= i;
        }
     }
     if(!(n == 1)) mp[n]++;
}

int main(){
   ll n,p;
   cin>>n>>p;
   map<ll,ll>res;
   factorization(p,res);
   ll ans =1;
   for(auto x:res){
       while(x.second>=n){
           ans*=x.first;
           x.second-=n;
       }
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ff first 
#define ss second
#define mod 1000000007
#define lim 100005
#define nfs_mw ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

bool vis[710] = {}, state[710] = {}, pos[1500] = {}, ngh[710][710] = {};
vector<int> gr[710];

void dfs(int u, bool wtf, pair<int,int>& cnt){
	vis[u] = 1;
	state[u] = wtf;
	if(wtf) cnt.ff++; else cnt.ss++;
	for(int v:gr[u]){
		if(!vis[v]) dfs(v,!wtf,cnt);
		else if(state[v] == state[u]) { cout<<"-1\n"; exit(0); }
	}
}

int main()
{
	nfs_mw;
	int i,j,n,m,u,v;
	cin>>n>>m;
	for(i=0; i<m; i++) {
		cin>>u>>v;
		ngh[u][v] = ngh[v][u] = 1;
	}

	for(i=1; i<=n; i++)
		for(j=1; j<=n; j++)
			if(i!=j && !ngh[i][j])
				gr[i].pb(j);

	vector< pair<int,int> > pairs;
	for(i=1; i<=n; i++) if(!vis[i]){
		pair<int,int> nxt = mp(0,0);
		dfs(i,0,nxt);
		pairs.pb(nxt);
	}

	pos[0] = 1;
	for(auto p:pairs)
		for(j=n; j>=0; j--) {
			if(!pos[j]) continue;
			pos[j] = 0;
			pos[j+p.ff] = 1;
			pos[j+p.ss] = 1;
		}

	int ans = 700*700*700;
	for(j=n; j>=0; j--) if(pos[j]) ans = min(ans, (((j*(j-1))/2) + (((n-j)*(n-j-1))/2)));
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3072
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

  int s;
  cin >> s;

  long long an,am;
  long long i = 1;
  long long ans = 0;
  vi a;
  a.emplace_back(s);
  an = s;
  while(1)
  {
    i++;
    if(an % 2 == 0)
    {
      am = an / 2;
    }
    else
    {
      am = 3 * an + 1;
    }

    a.emplace_back(am);
    an = am;

    bool b = false;
    rep(j,i - 2)
    {
      if(a[j] == am)
      {
        b = true;
        break;
      }
    }
    if(b)
    {
      ans = i;
      break;
    }
  }

  cout << ans << endl;
  return 0;
}
// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

using namespace std;


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

int N, Q, V[(1 << 18)], W[(1 << 18)], x[100005], L[100005], hasquery[(1 << 18)];
ll ans[100005];
vector<pl> queries[(1 << 18)];
vector<pl> depth[(1 << 18)];

void dfs(int x, int d){
	//cerr << x << ' ' << d << '\n';
	vector<pl> v;
	//cerr << x << ' ' << x/2 << '\n';
	if (d == 12 || d == 1){
		depth[x].push_back(pl(0,0));
		depth[x].push_back(pl(W[x],V[x]));
	}
	else{
		for (auto it : depth[x/2]){
			if (it.first + W[x] > 100000) break;
			v.push_back(pl(it.first+W[x],it.second+V[x]));
		}
		int ptd = 0, ptv = 0;
		ll bval = -1;
		while (ptd < depth[x/2].size() && ptv < v.size()){
			if (depth[x/2][ptd].first < v[ptv].first){
				if (depth[x/2][ptd].second > bval){
					depth[x].push_back(depth[x/2][ptd]);
					bval = depth[x/2][ptd].second;
				}
				ptd++;
			}
			else{
				if (v[ptv].second > bval){
					depth[x].push_back(v[ptv]);
					bval = v[ptv].second;
				}
				ptv++;
			}
		}
		while (ptd < depth[x/2].size()){
			if (depth[x/2][ptd].second > bval){
				depth[x].push_back(depth[x/2][ptd]);
				bval = depth[x/2][ptd].second;
			}
			ptd++;
		}
		while (ptv < v.size()){
			if (v[ptv].second > bval){
				depth[x].push_back(v[ptv]);
				bval = v[ptv].second;
			}
			ptv++;
		}
	}
	
	
	/*
	cerr << x << '\n';
	for (auto it : depth[x]){
		cerr << it.first << ' ';
	}
	cerr << '\n';
	*/
	ll p = x;	
	if (d >= 12) p >>= (d-12+1);
	else p = 0;
	
	for (auto it : queries[x]){
		int pt1 = 0, pt2 = depth[p].size()-1;
		while (pt1 < depth[x].size()){
			while (pt2 >= 0 && depth[p][pt2].first + depth[x][pt1].first > it.first){
				pt2--;
			}
			if (pt2 >= 0) ans[it.second] = max(ans[it.second],depth[x][pt1].second+depth[p][pt2].second);
			pt1++;
		}
	}
	if (2*x <= N) dfs(2*x,d+1);
	if (2*x+1 <= N) dfs(2*x+1,d+1); 
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> N;
	for (int i = 1; i <= N; ++i){
		cin >> V[i] >> W[i];
	}
	cin >> Q;
	for (int i = 1; i <= Q; ++i){
		cin >> x[i] >> L[i];
		queries[x[i]].push_back(pl(L[i],i));
		while (x[i] > 0 && !hasquery[x[i]]){
			hasquery[x[i]] = 1;
			x[i] /= 2;
		}
	}
	for (int i = 1; i <= N; ++i){
		sort(queries[i].begin(),queries[i].end());
	}
	depth[0].push_back(pl(0,0));
	dfs(1,1);
	for (int i = 1; i <= Q; ++i){
		cout << ans[i] << '\n';
	}
}

Measured memory_bytes: 420116
L, R = map(int, input().split())
if (L <= 673 <= R and R - L >= 3) or (R - L >= 673):
    print(0)
else:
    mods = []
    mods_append = mods.append
    for i in range(L, R):
        for j in range(i + 1, R + 1):
            m = (i * j) % 2019
            mods_append(m)
            if m == 2:
                break

    print(min(mods))

Measured memory_bytes: 6676
n = gets.to_i
arr = Hash.new(0)
n.times do
  s = gets.chomp
  arr[s] += 1
end
num = 0
ans = []
arr.sort{|x,y|y[1] <=> x[1]}.each do |x, y|
  if num <= y
    ans << x
    num = y
  else
    break
  end
end

ans.sort.each do |an|
  puts an
end

Measured memory_bytes: 41188
#include "bits/stdc++.h"
using namespace std;
#define LL long long int

bool Pallindromic(LL N)
{
    LL M = N;
    vector <LL> V;
    while(N)
        V.push_back(N % 10), N /= 10;

    LL i = V.size()-1;
    while(M && i)
    {
        if(V[i--] != M%10)
            return false;
        M /= 10;
    }
    return true;
}

int main()
{
   LL A, B, Count = 0;
   cin >> A >> B;
   for(LL i = A; i <= B; i++)
   {
       if(Pallindromic(i))
            Count++;
   }
   cout << Count << endl;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, int> pli;

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

	int N;
	cin >> N;

	vector<ll> A(N);
	vector<ll> B(N);
	rep(i, N) cin >> A[i] >> B[i];

	vector<pli> v(N);
	rep(i, N) v[i] = (pli){A[i] + B[i], i};
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());

	ll ans = 0;
	rep(i, N){
		if(i % 2 == 0){
			ans += A[v[i].se];
		}else{
			ans -= B[v[i].se];
		}
	}

	cout << ans << endl;
}


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

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

int main() {
    ll h, w;
    cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1 << endl;
        return 0;
    }
    cout << (h * w) / 2 + (h * w) % 2 << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, m, p, q, r;
int ara[300000];

int main()
{
    cin >> n;

    for(int i = 1; i <= n; i++) scanf("%d", &ara[i]);

    for(int i = n; i > 0; i -= 2){
        printf("%d ", ara[i]);
    }
    int i;
    if(n % 2 == 0) i = 1;
    else i = 2;

    for( ; i <= n; i += 2) printf("%d ", ara[i]);


    return 0;
}


Measured memory_bytes: 2944
#include <stdio.h>
int st[500],head=0;
int main(){
  int b,num=0;
  char a,c;
  
  while( (scanf("%c",&a))!=EOF){ 
    if(num==0&&a=='0'){	st[head]=num;
      head++;}

      if(a<='9'&&a>='0'){num=a-'0'+num*10;}      
      else if(num!=0){	
	st[head]=num;
	head++;
	num=0;
      }
      else {num=0;
	if(a=='+'){
	  st[head-2]+=st[head-1];
	  head--;
	}
	else if(a=='*'){
	  st[head-2]*=st[head-1];
	  head--;
	}

	else if(a=='-'){
	  st[head-2]-=st[head-1];
	  head--;
	}
      }  
  }
    
printf("%d\n",st[head-1]);  

  return 0;
}

Measured memory_bytes: 540
while(True):
    try:
        q = input()
        if q == -1:
            break
        else :
            q = float(q)
            x = q/2
            while  (abs(q-x**3) >= 0.00001*q):
                x = x- (x**3-q)/(3*x**2)
            print '{:.6f}'.format(x)
    except EOFError:
        break

Measured memory_bytes: 4312
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int n,k;
	cin >> n >> k;
	if(k > (n - 1) * (n - 2) / 2)cout << -1 << '\n';
	else{
		vector<P> edge;
		edge.push_back(P(1,2));

		//1をウニの中心にする.
		//3~Nを追加していく.
		int sum = 0;
		int v_num = 0;//3からスタートして何頂点分までウニにするか.
		for(int i = 1;;i++){
			if(sum + i > k)break;
			sum += i;
			v_num = i;
		}

		for(int i = 3;i <= n;i++){
			if(v_num){
				edge.push_back(P(i,1));
				v_num--;
				k -= (i - 2);
			}
			else{
				if(k){
					edge.push_back(P(i,1));
					for(int j = 1;j <= (i - 2) - k;j++){
						edge.push_back(P(j+1,i));
					}
					k = 0;
				}
				else{
					for(int j = 1;j < i;j++){
						edge.push_back(P(j,i));
					}
				}
			}
		}

		cout << edge.size() << endl;
		for(auto e:edge){
			cout << e.first << " " << e.second << endl;
		}
	}
}


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

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

Measured memory_bytes: 3572
package main

import (
	"bufio"
	"fmt"
	"os"
)

func readLine(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func min(a, b int64) int64 {
	if a <= b {
		return a
	}
	return b
}

func count(str string, runes ...rune) int64 {
	cnt := int64(0)
	index := 0
	for _, s := range str {
		if s != runes[index] {
			cnt++
		}
		index = (index + 1) % len(runes)
	}
	return cnt
}

func main() {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, 10000)
	sc.Buffer(buf, 100000+1024)
	line := readLine(sc)

	fmt.Println(min(count(line, '0', '1'), count(line, '1', '0')))
}


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static int[] dp = new int[10001];

		static void Main(string[] args)
		{
			List<int> nm = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
			int n = nm[0];
			int m = nm[1];
			List<int> a = Console.ReadLine().Split(' ').Select(int.Parse).ToList();

			//123456789
			//255456376
			int[] c = new int[] {0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
			dp[1] = -1;
			for (int i = 2; i <= n; i++) {
				int max = -1;
				for (int j = 0; j < m; j++) {
					if (i - c[a[j]] < 0 || dp[i - c[a[j]]] == -1) {
						continue;
					}

					max = Math.Max(max, dp[i - c[a[j]]] + 1);
				}

				dp[i] = max;
			}

			a.Sort();
			a.Reverse();
			StringBuilder ans = new StringBuilder();
			int k = dp[n];
			int count = n;
			for (int i = 0; i < k; i++) {
				for (int j = 0; j < m; j++) {
					if (count >= 0 && count - c[a[j]] >= 0 && dp[count] - 1 == dp[count - c[a[j]]]){
						ans.Append(a[j].ToString());
						count -= c[a[j]];
						break;
					}
				}
			}

			Console.WriteLine(ans.ToString());
		}
	}

	
}


Measured memory_bytes: 13396
#include<iostream>
#include<math.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n; cin>>n;
    ll arr[n+1],dp[n+1]={};
    for(ll i=1;i<=n;i++)
    {
      cin>>arr[i];
    }
    dp[2]=abs(arr[2]-arr[1]);
    if(n==2)
    {cout<<dp[2]; return 0;}
    dp[3]=min(abs(arr[3]-arr[2])+dp[2],abs(arr[3]-arr[1]));
    for(ll i=4;i<=n;i++)
    dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+ dp[i-2] );
     cout<<dp[n];
      return 0;
}


Measured memory_bytes: 5104
// Aizu Vol-1 0184: Tsuruga Castle
// 2017.8.2

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

char *gets(char *);
char buf[100], *p;

int getInt(void)
{
	int n = 0;
	while (isspace(*p)) p++;
	while (isdigit(*p)) n = 10 * n + (*p++ - '0');
	return n;
}

int cnt[7];

int main()
{
	int i, n, k;

	while (1) {
		gets(p = buf);
		if (!(n = getInt())) break;
		for (i = 0; i < 7; i++) cnt[i] = 0;
		for (i = 0; i < n; i++) {
			gets(p = buf);
			if ((k = getInt()) >= 60) cnt[6]++;
			else cnt[k / 10]++;
		}
		for (i = 0; i < 7; i++) printf("%d\n", cnt[i]);
	}
	return 0;
}

Measured memory_bytes: 520
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  int n;
  cin >> n;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  
  h[0]--;
  for (int i = 0; i+1 < n; i++) {
    if (h[i] < h[i+1]) h[i+1]--;
  }
  for (int i = 0; i+1 < n; i++) {
    if (h[i] > h[i+1]) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

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

int main(int argc, char **argv)
{
	string a, b, c; cin >> a >> b >> c;
	queue<char> A, B, C;
	for (auto e : a)
		A.push(e);
	for (auto e : b)
		B.push(e);
	for (auto e : c)
		C.push(e);

	char turn = 'a';
	char win;
	while (true)
	{
		if (turn == 'a')
		{
			if (A.empty())
			{
				win = 'A';
				break;
			}
			turn = A.front(); A.pop();
		}
		else if (turn == 'b')
		{
			if (B.empty())
			{
				win = 'B';
				break;
			}
			turn = B.front(); B.pop();
		}
		else if (turn == 'c')
		{
			if (C.empty())
			{
				win = 'C';
				break;
			}
			turn = C.front(); C.pop();
		}
	}
	std::cout << win << std::endl;
}


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

typedef long long  llong;

int main() {
  llong a, b, x, ans;

  cin >> a >> b >> x;

  if (a == 0) {
    ans = b / x + 1;
  }
  else {
    ans = (b / x) - ((a - 1) / x);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int,  int>;

const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main(){
	string s; cin >>s;
	int n = s.size();
    if(s[0]!='A'){
        cout << "WA" << endl;
	    return 0;
    }
    bool used = false;
	for(int i = 1; i < n; ++i){
        if(i!=1 && i!= n-1 && s[i]=='C'){
          if(used){
            cout << "WA" << endl;
	        return 0;
          }
          used = true;
          continue;
        }
		char base = 'a';
		int tmp = (int)(s[i]- base);
		if(0<=tmp && tmp < 26){continue;}
		else{
			cout << "WA" << endl;
			return 0;
        }
    }
   if(used){cout << "AC" << endl;}
    else{cout << "WA" << endl;}
    return 0;
}


Measured memory_bytes: 256
ans = 0
N,K = map(int,input().split())
for b in range(K+1,N+1):
    x1,y1 = divmod(N-K,b)
    x2,y2 = divmod(N-b+1,b)
    if x1==x2:
        ans += (x1+1)*(y1-y2+1)
    else:
        ans += (x1+1)*(y1+1) + (x2+1)*(b-y2)+b*(x1+x2+2)*(x1-x2-1)//2
if K == 0:
    print(N*N)
else:
    print(ans)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
#include <algorithm>
#include <limits.h>
#include <cmath>
#include <time.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define SQR(X) ((X)*(X))
#define NIL -1

int test = 0;
/* ここからが本編 */
struct Node{
  int r,l,p,d;
};
static struct Node node[100005];
void printChildren(int u)
{
  int c = node[u].l;
  printf(", [");
  if(c != NIL) {
    printf("%d",c);
    c = node[c].r;
    while(c != NIL) {
      printf(", %d",c);
      c = node[c].r;
    }
  }
  puts("]");
}
void setDepth(int u,int p){
  node[u].d = p;
  if(node[u].l != NIL) {
    setDepth(node[u].l,p+1);
  }
  if(node[u].r != NIL) {
    setDepth(node[u].r,p);
  }
}
int main(void)
{
  int i,j,k,l;
  int d;
  int n;
  int id;
  cin >> n;
  rep(i,n) {
    node[i].p = NIL;
    node[i].l = NIL;
    node[i].r = NIL;
  }
  while(cin >> id) {
    int k;
    cin >> k;
    int l;
    if(k) {
      cin >> l;
      node[l].p = id;
      node[id].l = l;
      rep(i,k-1) {
        int c;
        cin >> c;
        node[c].p = id;
        node[l].r = c;
        l = c;
      }
    }
  }
  rep(i,n) {
    if(node[i].p == NIL) setDepth(i,0);
  }
  rep(i,n) {
    printf("node %d:",i);
    printf(" parent = %d",node[i].p);
    printf(", depth = %d",node[i].d);
    if(node[i].p == NIL) {
      printf(", root");
    }
    else if(node[i].l == NIL) {
      printf(", leaf");
    }
    else printf(", internal node");
    printChildren(i);
  }
  return 0;
}

Measured memory_bytes: 4692