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

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ld long double
#define forn(low,high,i) for(i = low; i < high; i++)
#define forrev(high,low,i) for(i = high; i >= low; i--)
#define all(v) v.begin(),v.end()
#define decimal_digits cout << fixed << setprecision(15);

string to_string(string s) { return '"' + s + '"';}
string to_string(char s) { return string(1, s);}
string to_string(const char* s) { return to_string((string) s);}
string to_string(bool b) { return (b ? "true" : "false");}
template <typename A> string to_string(A);
template <typename A, typename B>string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A> string to_string(A v) {bool f = 1; string r = "{"; for (const auto &x : v) {if (!f)r += ", "; f = 0; r += to_string(x);} return r + "}";}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << to_string(H); debug_out(T...);}
#define pr(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

#define GOOGLE 0
#define MULTIPLE_TC 0

const int inf = 1e9;
const long long INF = 1e18;
const int mod = 1e9 + 7;
const int bit32 = log2(inf) + 3;
const int bit64 = log2(INF) + 3;

inline int add(long long a, long long b){a += b; if(a >= mod) a -= mod; return a;}
inline int sub(long long a, long long b){a -= b; if(a < 0) a += mod; return a;}
inline int mul(long long a, long long b){a %= mod; b %= mod; return (int)((long long) a * b % mod);}
inline int modexpo(long long a, long long b){int res = 1; while(b > 0){ if(b & 1) res = mul(res, a); a = mul(a, a); b /= 2;} return res;}
inline int divide(long long a, long long b){return mul(a, modexpo(b, mod - 2));}
inline int inv(long long a){return modexpo(a, mod - 2);}

clock_t time_p = clock();

void ktj(){
  time_p = clock() - time_p;
  cerr << "Time elapsed : " << (float)(time_p)/CLOCKS_PER_SEC << "\n";
}

void pre(){ // Reset each global variable (esp. for graphs)
  
}

void solve(){
  long long n, d, ans = 0;
  cin >> n >> d;
  for (int i = 0; i < n; i++) {
    long long x, y;
    cin >> x >> y;
    x = x * x + y * y;
    if (x <= d * d)
      ans++;
  }
  cout << ans << '\n';
}

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

  pre();

  int t = 1, T;

  if(MULTIPLE_TC)
    cin >> t;

  for(T = 1; T <= t; T++){
    if(GOOGLE)
      cout << "Case #" << T << ": ";
    solve();
  }

  ktj();
}


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

bool tog(int i){    return !i;}

long long knap(vector<ll> &weight, vector<ll> &val, ll max_weight, ll n , ll index)
{
   ///sort obj in increasing orderof weight
   vector<pair<ll,ll>> obj(n);
   for(int i=0 ; i<n ; i++)
    obj[i].first = weight[i] , obj[i].second = val[i];
   sort(obj.begin() , obj.end());

    /// init DP array , DP[i][j] = max profit with weight "j" by considering all "i"th objects
    dp = vector<vector<ll>> (2 , vector<ll>(max_weight+1));

    for(ll i=1 ; i<=n ; i++)                    /// obj == { weight , val }
    {
        for(ll j=1 ; j<=max_weight ; j++)
        {
            if( obj[i-1].first <= j)
                dp[i&1][j] = max(
                           dp[!(i&1)][j] ,                               /// object not selected
                           dp[!(i&1)][max( 0ll , j-obj[i-1].first)] + obj[i-1].second /// obj selected
                              );
            else
                dp[i&1][j] = max(dp[!(i&1)][j] , dp[i&1][j-1]);
        }
    }
    //for(auto i:dp)    {        for(auto j:i)            cout<<j<<"\t";        cout<<endl;    }
    return max({dp[0][max_weight] , dp[1][max_weight]});
}
int main()
{
    ll n,  max_weight;
    cin>>n>>max_weight;
    dp = vector<vector<ll>>(n+1 , vector<ll>(max_weight+1,-1));

    vector<ll> val(n) , weight(n);
    for(ll i=0 ; i<n ; i++)
        cin>>weight[i] >> val[i];

    ll ans = knap(weight , val , max_weight , n , 0);
    cout<<endl<<ans;
}


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

using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF (1<<28)
#define int long long


signed main(){
  int n;
  cin>>n;
  int ans=0;
  int a[4]={25,10,5,1};
  lp(i,4){
    ans+=n/a[i];
    n%=a[i];
  }
  cout<<ans<<endl;
  return 0;
}



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

int main()
{
    int n, i, dp[100009][2];
    string s;
    cin >> s;

    dp[0][0] = dp[0][1] = 0;

    for(i = 0; i < s.size(); i++)
    {
        dp[i+1][0] = dp[i][1] + (s[i] == '0');
        dp[i+1][1] = dp[i][0] + (s[i] == '1');
    }

    cout << min(dp[s.size()][0], dp[s.size()][1]);
}


Measured memory_bytes: 4512
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;


ll N;
ll dp[110][4][4][4];// i, pre2, pre1. A:0, G:1, C:2
ll ans;
int main() {
	cin>>N;
	REP(j,0,4){
		REP(k,0,4){
			REP(l,0,4) {
				if ((j == 0 and k == 1 and l == 2)
					or (j == 0 and k == 2 and l == 1)
					or (j == 1 and k == 0 and l == 2)) {
					continue;
				}
				dp[3][j][k][l]=1;
			}
		}
	}
	REP(i,3,N){
		REP(j,0,4){
			REP(k,0,4){
				REP(l,0,4){
					REP(m,0,4){
						if((k==0 and l==1 and m==2)
						   or (k==0 and l==2 and m==1)
						   or (k==1 and l==0 and m==2)
						   or (j==0 and k==1 and l==1 and m==2)
						   or (j==0 and k==3 and l==1 and m==2)
						   or (j==0 and k==1 and l==3 and m==2)){

							continue;
						}
						dp[i+1][k][l][m]+=dp[i][j][k][l];
						dp[i+1][k][l][m]%=mod;
					}
				}
			}
		}
	}
	REP(j,0,4){
		REP(k,0,4) {
			REP(l, 0, 4) {
				ans += dp[N][j][k][l];
				ans %= mod;
			}
		}
	}
	p(ans);

	return 0;
}


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

using namespace std;
//????????§???????????§???????????¨????????±??????????????????
int main() {
  string line;
  while(true) {
    cin >> line;
    if(line == "0") break;
    int sum = 0;
    for(unsigned int i=0; i<line.length(); i++) {
      sum += line[i] - '0';
    }
    cout << sum << endl;
  }
  return 0;
}

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


int main(){
  int N;
  cin>>N;
  if(N<10){
    cout<<0<<endl;
    return 0;
  }
  int yaku[101];
  REP(i, 101)yaku[i]=0;
  yaku[1]=1;
  for(int i=2; i<=N; ++i){
    int m=i;
    for(int j=2; j<=i; ++j){
      while(m%j==0){
        ++yaku[j];
        m/=j;
      }
    }
  }
  //REP(i, 101)cout<<yaku[i]<<" ";
  int count=0, count2=0, ans = 0;
  REP(i, 101){
    if(yaku[i]>=74) ++count;
  }
  ans += count;
  count=0;
  REP(i, 101){
    if(yaku[i]>=24) ++count;
    else if(yaku[i]>=2) ++count2;
  }
  //cout<<count<<" "<<count2<<endl;
  ans += count*count2;
  ans += count*(count-1);
  count=0;
  count2=0;
  REP(i, 101){
    if(yaku[i]>=14) ++count;
    else if(yaku[i]>=4) ++count2;
  }
  //cout<<count<<" "<<count2<<endl;
  ans += count*count2;
  ans += count*(count-1);
  count=0;
  count2=0;
  REP(i, 101){
    if(yaku[i]>=4) ++count;
    else if(yaku[i]>=2) ++count2;
  }
  ans += count*(count-1)/2*count2 + count*(count-1)*(count-2)/2;
  cout<<ans<<endl;

  //cout<<count<<" "<<count2<<endl;


  return 0;
}


Measured memory_bytes: 256
'use strict';

function Main(input) {
  const N = Number(input.split("\n")[0]);
  const A = input.split("\n")[1];
  const B = input.split("\n")[2];
  const C = input.split("\n")[3];

  let count = 0;

  for(let i=0; i<N; i++) {
    const a = A.substr(i, 1)
    const b = B.substr(i, 1)
    const c = C.substr(i, 1)
    if ((a === b && a !== c) || (b === c && a !== b) || (a === c && a !== b)) {
      count++;
    }
    if (a !== b && b !== c && c !== a) {
      count += 2;
    }
  }

  console.log(count);

};

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


Measured memory_bytes: 9420
#include <cstdio>
#include <cstring>
using namespace std;

int main(){
	int n;
	scanf("%d",&n);
	int in;
	char input;
	int data[4][13];//1:s,2:h,3:c,4:d
	memset(data,0,sizeof(data));
	for(int i=0;i<n;i++){
		scanf(" %c %d",&input,&in);
		switch(input){
			case 'S':
				data[0][in-1]=1;
				break;
			case 'H':
				data[1][in-1]=1;
				break;
			case 'C':
				data[2][in-1]=1;
				break;
			case 'D':
				data[3][in-1]=1;
				break;
		}
	}
	for(int i=0;i<4;i++){
		for(int j=0;j<13;j++){
			if(data[i][j]==0){
				switch(i){
					case 0:
						printf("S ");
						break;
					case 1:
						printf("H ");
						break;
					case 2:
						printf("C ");
						break;
					case 3:
						printf("D ");
				}
				printf("%d\n",j+1);
			}
		}
	}
	return 0;
}

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

RESTAURANTS = []
for i in range(1, n + 1):
    s, p = input().split()
    p = int(p)
    RESTAURANTS.append((s, p, i))
RESTAURANTS.sort()

SLICE = [0]
for i in range(n - 1):
    if RESTAURANTS[i][0] != RESTAURANTS[i + 1][0]:
        SLICE.append(i + 1)
SLICE.append(n)

for i in range(len(SLICE) - 1):
    a, b = SLICE[i], SLICE[i + 1]
    RESTAURANTS2 = RESTAURANTS[a:b]
    for restaurant in RESTAURANTS2[::-1]:
        print(restaurant[2])


Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

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

int main()
{
	int n, x;
	vi a(1);
	cin >> n >> x;
	a.resize(n);
	for (int i = 0; i < n;i++) {
		cin >> a[i];
	}

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

	for (int i = 0; i < n; i++) {
		x -= a[i];
		if (x == 0) {
			cout << i + 1 << endl;
			return 0;
		}
		else if (x < 0) {
			cout << i << endl;
			return 0;
		}
	}

	cout << a.size() - 1 << endl;
	return 0;
}

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

int main() {
   int n, m;
   cin >> n >> m;
   vector<pair<int, bool>> tasks(n);

   rep(i, m) {
      int p;
      string s;
      cin >> p >> s;
      p--;

      if (s == "AC") {
         tasks[p].second = true;
      }
      if (s == "WA" && !tasks[p].second) {
         tasks[p].first++;
      }
   }
   llong p, ans;
   p = ans = 0;
   rep(i, n) {
      if (tasks[i].first > 0 && tasks[i].second)
         p += tasks[i].first;
      if (tasks[i].second)
         ans++;
   }
   cout << ans << " " << p << endl;
   return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
#define INF 100000000
#define IINF 9999999999999;
using vint = std::vector<int>;
using ll = long long;
using vll = std::vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = std::min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = std::max(a, b); }
#define output(x) cout << x << endl;
typedef pair<int, int> P;

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

int main()  {
    int a, b;
    cin >> a >> b;
    long int ans = a * b;
    if(ans % 2 == 0) cout << "Even" << endl;
    else cout << "Odd" << endl;
}

Measured memory_bytes: 256
#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;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)
const long long int MOD = 1000000007;

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

	int x, n;
	cin >> x >> n;
	set<int> st;
	rep(i, n) {
		int p;
		cin >> p;
		st.insert(p);
	}
	int now1 = x, now2 = x;
	while (1) {
		if (!st.count(now1)) {
			cout << now1 << endl;
			return 0;
		}
		if (!st.count(now2)) {
			cout << now2 << endl;
			return 0;
		}
		now1--; now2++;
	}
	return 0;
}

Measured memory_bytes: 3648
import math
a,b,C=map(int,input().split())
radC=math.radians(C)
S=a*b*math.sin(radC)*(1/2)
c=a**2+b**2-2*a*b*math.cos(radC)
L=a+b+math.sqrt(c)
h=2*S/a
list=[S,L,h]
for i in list:
    print('{:.08f}'.format(i))
    



Measured memory_bytes: 5724
def parser():
    while 1:
        data = list(input().split(' '))
        for number in data:
            if len(number) > 0:
                yield (number)


input_parser = parser()


def gw():
    global input_parser
    return next(input_parser)


def gi():
    data = gw()
    return int(data)


MOD = int(1e9 + 7)

# numpy and scipy are available for use
import numpy
import scipy
#https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_e
#Colorful Hats 2
"""
"""

# reads a single line
N = gi()
tails = [0] * (N + 5)

tails[0] = 3
ans = 1
for i in range(N):
    a = gi()
    ans *= tails[a]
    ans %= MOD
    tails[a] -= 1
    tails[a + 1] += 1

print(ans)


Measured memory_bytes: 20780
#include<stdio.h>
int main(void){
    int n,num;
    int i,j;
    char c;
    int card[5][53]={0};
    scanf("%d\n",&n);
    for(i=1;i<=n;i++){
        scanf("\n%c %d",&c,&num);
        if(c=='S')
            card[1][num]=1;
        else if(c=='H')
            card[2][num]=1;
        else if(c=='C')
            card[3][num]=1;
        else if(c=='D')
            card[4][num]=1;
    }
    for(i=1;i<=4;i++)
        for(j=1;j<=13;j++)
            if(card[i][j]==0){
                if(i==1)
                    printf("S %d\n",j);
                else if(i==2)
                    printf("H %d\n",j);
                else if(i==3)
                    printf("C %d\n",j);
                else if(i==4)
                    printf("D %d\n",j);
            }
    return 0;
}

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

int max(int a, int b) {
	if (a>=b) {
		return a;
	}
	else {
		return b;
	}
}

int main() {
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	int S = 0;
	int min = A*X + Y * B;
	for (int i = 1; i <= 100000; i++) {
		S = i * 2 * C + max(0, X - i) * A + max(0, Y - i) * B;
		if (S < min) {
			min = S;
		}
	}
	cout << min << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct {
  int a;
  int b;
  int c;
  int d;
  int e;
  int f;
} DICE;

int main()
{
  DICE p, q;
  char dir;
  scanf("%d %d %d %d %d %d\n", &p.a, &p.b, &p.c, &p.d, &p.e, &p.f);
  q  =p;
  while (1) {
    scanf("%c", &dir);
    switch (dir) {
    case 'N': // a,e,f,b=b,a,e,f;
      q.a = p.b;
      q.e = p.a;
      q.f = p.e;
      q.b = p.f;
      break;
    case 'E': // a,c,f,d=d,a,c,f
      q.a = p.d;
      q.c = p.a;
      q.f = p.c;
      q.d = p.f;
      break;
    case 'W': // a,c,f,d=c,f,d,a;
      q.a = p.c;
      q.c = p.f;
      q.f = p.d;
      q.d = p.a;
      break;
    case 'S': // a,e,f,b=e,f,b,a
      q.a = p.e;
      q.e = p.f;
      q.f = p.b;
      q.b = p.a;
      break;
    default:
      goto OUT;
    }
    p = q;
  }
 OUT:
  printf("%d\n", p.a);
  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 1001001001001001001;  // > 10^18
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;


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

    string a = "";
    a += s[0];
    a += to_string(s.length()-2);
    a += s[s.length()-1];

    cout << a << endl;
    return 0;
}




Measured memory_bytes: 256
s = gets.to_i
if s == 1 || s == 2
  puts 4
  exit
end

res = [s]
while res[-1] != 1
  if res[-1] % 2 == 0
    res << res[-1] / 2
  else
    res << 3 * res[-1] + 1
  end
end
puts res.size + 1


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

const int maxn = 1e5 + 7 ;

vector < int > g[ maxn ] ;
vector < bool > visited( maxn , false ) ;
vector < int > s_num( maxn ) ;


int main() 
{
     int n ;
     cin >> n;
     int ans = 1 ;
     for ( int i = 2 ; i < 35 ; i++ )
     {
          for ( int j = 2 ; ; j++ )
          {
              int x = pow( i ,j ) ;
              if( x <= n )ans = max ( ans , x ) ;
              else break ; 
                  
          }
     }
    cout << ans << endl ;
}

Measured memory_bytes: 3328
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
using namespace std;
template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }

double solve1(int x1, int y1, int x2, int y2, int x3, int y3) {
    complex<double> a1(x1 - x3, y1 - y3);
    complex<double> a2(x2 - x3, y2 - y3);
    double arg1 = abs(arg(a1 / a2));
    double arg2 = M_PI - abs(arg((a1 - a2) / a2));
    double scale = abs(a2);
    return scale / (2 + 1 / tan(arg1 / 2) + 1 / tan(arg2 / 2));
}

int main() {
    // input
    int x1, y1; scanf("%d%d", &x1, &y1);
    int x2, y2; scanf("%d%d", &x2, &y2);
    int x3, y3; scanf("%d%d", &x3, &y3);
    // solve
    double result = 0;
    setmax(result, solve1(x1, y1, x2, y2, x3, y3));
    setmax(result, solve1(x2, y2, x3, y3, x1, y1));
    setmax(result, solve1(x3, y3, x1, y1, x2, y2));
    // output
    printf("%.12lf\n", result);
    return 0;
}


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

int main() {
  int a, b, c, x;
  cin >> a >> b >> c >> x;
  int ans = 0;
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      for (int k = 0; k <= c; k++) {
        int sum = i * 500 + j * 100 + k * 50;
        if (sum == x) ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main(){
  string s;
  cin>>s;
  int l=0;
  int r=0;
  vector<pair<ll,ll>> p;
  rep(i,s.size()){
    if(i!=0 && s[i-1]=='>' && s[i]=='<'){
      p.push_back(make_pair(l,r));
      l=0; r=0;
    }
    if(s[i]=='<')l++;
    if(s[i]=='>')r++;
  }
  p.push_back(make_pair(l,r));
  ll ans=0;
  for(auto x : p){
    ll big=max(x.first,x.second);
    ll small=min(x.first,x.second);
    if(small==0)ans+=big*(big+1)/2;
    else ans+=big*(big+1)/2+(small)*(small-1)/2;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 6108
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Mmax = 1e5;
int N, M, P[Mmax];
ll Y[Mmax];

int main(){
	cin >> N >> M;
	for(int i=0; i<M; i++) cin >> P[i] >> Y[i];
	
	vector<int> pcount(N+1);
	vector<pair<ll, int>> yidx(M);
	for(int i=0; i<M; i++) yidx[i] = {Y[i], i};
	sort(yidx.begin(), yidx.end());

	vector<ll> ans(M);

	for(int i=0; i<M; i++){
		int n = yidx[i].second;
		pcount[P[n]]++;
		ans[n] = P[n]*1000000ll + pcount[P[n]];
	}

	for(int i=0; i<M; i++){
		cout << setw(12) << setfill('0') << ans[i] << endl;
	}

	return 0;
}


Measured memory_bytes: 5376
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }

int dy[4] = {-1, 0, 1, 0},dx[4] = {0, 1, 0, -1};
int h,w;
string s[20];

int bfs(int sy,int sx){
	queue<pii> q;
	vector<vector<int>> dist(h,vector<int>(w,-1));
	dist[sy][sx]=0;
	q.push(pii(sy,sx));
	while (!q.empty()) {
		pii now=q.front();
		q.pop();
		int y=now.fi,x=now.se;
		rep(i,4){
			int ny=y+dy[i],nx=x+dx[i];
			if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
			if (s[ny][nx] == '#') continue;
			if(dist[ny][nx]==-1){
				q.push(pii(ny,nx));
				dist[ny][nx]=dist[y][x]+1;
			}
		}
	}
	int ret=0;
	rep(i,h)rep(j,w) ret=max(ret,dist[i][j]);
	return ret;
}



int main(int argc, char const *argv[]) {
  int ans=0;
	cin >> h >> w;
	rep(i,h) cin >> s[i];
	rep(i,h)rep(j,w){
		if(s[i][j]=='#') continue;
		int res=bfs(i,j);
		ans=max(ans,res);
	}
	cout << ans << endl;
  return 0;
}


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

int main(){ 
  string s;
  cin >> s;
  bool ok = false;
  for (int i = 0; i < 2; i++) {
    if (s[i] != s[i+1]) ok = true;
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());

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

  int n,m;
  cin >> n >> m;

  cout << ((n == m) ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
// ふがしは初期300+交換+300で最大600本持つ可能性があり、
// これを素直に実装すれば301(うまか[0,300])*901(ふがし[-300,600])
// ところが、sum(c_i)が300以下なので、ふがしを301本以上持つのは無意味
// よってふがしを301以上持つ状態は無いものとして
// 301(うまか[0,300])*601(ふがし[-300,300])で実装してよい
#include<iostream>
#include<vector>
using namespace std;

vector<vector<int>> dp(301, vector<int>(601, -10000));

int main(){
    int n, x, y;
    scanf("%d", &n);
    scanf("%d %d", &x, &y);
    dp[x][300+y] = 0;
    for(int i = 0; i < n; i++){
        vector<vector<int>> ndp = dp;
        int a, b, c, d;
        scanf("%d %d %d %d", &a, &b, &c, &d);
        for(int j = 0; j <= 300; j++){
            for(int k = 0; k <= 600; k++){
                if(dp[j][k] < 0)    continue;
                if(j >= a && k+b <= 600)  ndp[j-a][k+b] = max(ndp[j-a][k+b], dp[j][k]);
                if(k >= c)  ndp[j][k-c] = max(ndp[j][k-c], dp[j][k]+d);
            }
        }
        dp = ndp;
    }
    int ans = 0;
    for(int i = 0; i <= 300; i++){
        for(int j = 300; j <= 600; j++){
            ans = max(ans, dp[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  ll X;
  cin >> X;

  vector<ll> A(1100), B(1100);
  REP(i, 1001) { A.at(i) = B.at(i) = pow(i, 5); }

  REP(i, 1001) {
    REP(j, 1001) {
      // cout << i << "/" << j << endl;
      // cout << A.at(i) - B.at(j) << ":" << (-1) * A.at(i) - B.at(j) << ":"
      //      << A.at(i) + B.at(j) << endl;
      if (A.at(i) - B.at(j) == X) {
        cout << i << " " << j << endl;
        return 0;
      } else if ((-1) * A.at(i) - B.at(j) == X) {
        cout << -i << " " << j << endl;
        return 0;
      } else if (A.at(i) + B.at(j) == X) {
        cout << i << " " << -j << endl;
        return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 4112
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */
  for(i=0;i<n;i++)
    {
      scanf("%d",A+i);
    }

  for(i=0;i<=VMAX;i++)
    {
      C[i] = 0;
    }
  for(j=0;j<n;j++)
    {
      C[A[j]]++;
    }
  for(i=1;i<=VMAX;i++)
    {
      C[i]=C[i]+C[i-1];
    }
  for(j=n-1;j>=0;j--)
    {
      B[C[A[j]]-1]=A[j];
      C[A[j]]--;
    }
  for(i=0;i<n;i++)
    {
      printf("%d",*(B+i));
      if(i<n-1)printf(" ");
    }
  printf("\n");

  return 0;
}


Measured memory_bytes: 9624
a=1000000007
n=int(input())
l=list(map(int,input().split()))
l.sort()
if n%2==1:
  if l[0]!=0:
    print(0)
    exit()
  else:
    l.remove(0)
    sh=2
    f=0
    for i in l:
      if f==0:
        if i!=sh:
          print(0)
          exit()
        else:
          f=1
      else:
        if i!=sh:
          print(0)
          exit()
        else:
          sh+=2
          f=0
  sh=(n-1)//2
  b=1
  for i in range(sh):
    b*=2
    b%=a
  print(b)
else:
  sh=1
  f=0
  for i in l:
    if f==0:
      if i!=sh:
        print(0)
        exit()
      else:
        f=1
    else:
      if i!=sh:
        print(0)
        exit()
      else:
        sh+=2
        f=0
  sh=n//2
  b=1
  for i in range(sh):
    b*=2
    b%=a
  print(b)

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

constexpr int64 P = 200003;

using Complex = complex<double>;

// Reference: http://www.prefield.com/algorithm/math/fft.html
vector<Complex> DFT(const vector<Complex>& p, int n, int sign = 1) {
  const double theta = 2.0 * M_PI / n * sign;
  int unit = 1;
  vector<Complex> q = p;
  for (int m = n; m >= 2; m >>= 1) {
    int mh = m >> 1;
    for (int i = 0; i < mh; i++) {
      Complex w = Complex(cos(theta * unit * i), sin(theta * unit * i));
      for (int j = i; j < n; j += m) {
        int k = j + mh;
        Complex x = q[j] - q[k];
        q[j] += q[k];
        // q[k] = w * x;
        q[k] = Complex(w.real() * x.real() - w.imag() * x.imag(), w.real() * x.imag() + w.imag() * x.real());
      }
    }
    unit *= 2;
  }
  int i = 0;
  for (int j = 1; j < n - 1; j++) {
    for (int k = n >> 1; k > (i ^= k); k >>= 1);
    if (j < i) swap(q[i], q[j]);
  }
  return q;
}
 
vector<Complex> InvDFT(const vector<Complex>& p, int n) {
  auto q = DFT(p, n, -1);
  for(int i = 0; i < n; i++) {
    q[i] /= n;
  }
  return q;
}
 
vector<Complex> MultiplyFFT(
    const vector<Complex>& p1, const vector<Complex>& p2) {
  int d = p1.size() + p2.size() - 1;
  int n = 1;
  while(n < d + 1) n *= 2;
 
  auto q1 = p1;
  q1.resize(n);
  auto q2 = p2;
  q2.resize(n);
  auto r1 = DFT(q1, n);
  auto r2 = DFT(q2, n);
 
  vector<Complex> s(n);
  for(int i = 0; i < n; i++) {
    s[i] = r1[i] * r2[i];
  }
  return InvDFT(s, n);
}

vector<int64> MultiplyFFT(
    const vector<int64>& p1, const vector<int64>& p2) {
  vector<Complex> q1;
  for (int i = 0; i < p1.size(); i++) {
    q1.emplace_back(p1[i], 0);
  }
  vector<Complex> q2;
  for (int i = 0; i < p2.size(); i++) {
    q2.emplace_back(p2[i], 0);
  }
  vector<Complex> r = MultiplyFFT(q1, q2);
  vector<int64> s;
  for (int i = 0; i < r.size(); i++) {
    s.push_back(llround(r[i].real()));
  }
  return s;
}

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

  // i = 2^p
  vector<int64> i_to_p(P, -1);
  vector<int64> p_to_i(P - 1, -1);
  {
    int64 x = 1;
    for (int i = 0; i < P - 1; i++) {
      i_to_p[x] = i;
      p_to_i[i] = x;
      x *= 2;
      x %= P;
    }
  }

  int n;
  cin >> n;

  int64 delta = 0;
  vector<int64> xs(P - 1);
  for (int i = 0; i < n; i++) {
    int64 a;
    cin >> a;
    if (a == 0) continue;
    xs[i_to_p[a]] += 1;
    delta += a * a % P;
  }
  vector<int64> ys = MultiplyFFT(xs, xs);
  int64 ans = 0;
  for (int i = 0; i < ys.size(); i++) {
    int k = i % (P - 1);
    ans += p_to_i[k] * ys[i];
  }
  ans -= delta;
  ans /= 2;
  cout << ans << endl;
}

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

int main(int, char**) {
  int N;
  std::cin >> N;

  std::vector<int> hs(N);
  for(int i{}; i < N; ++i) {
    std::cin >> hs[i];
  }

  std::vector<int> costs(N);
  costs[1] = std::abs(hs[1] - hs[0]);

  for(int i{2}; i < N; ++i) {
    costs[i] = std::min(costs[i - 1] + std::abs(hs[i] - hs[i - 1]), costs[i - 2] + std::abs(hs[i] - hs[i - 2]));
  }

  std::cout << costs[N - 1] << std::endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
using namespace std;

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

	int n; cin >> n;

	map<string, int> count;
	string input;

	while (cin >> input) { ++count[input]; }

	auto max_count{
		max_element(count.begin(), count.end(),
			[](const pair<string, int>& a, const pair<string, int>& b)
			{
				return a.second < b.second;
			}
		)->second
	};

	for (const auto& str_count : count)
	{
		if (str_count.second == max_count)
		{
			cout << str_count.first << '\n';
		}
	}
}

Measured memory_bytes: 19272
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    string s; cin >> s;
    bool f = false;
    int N = s.size();
    REP(i,N) {
        if (i+1<N && s[i]==s[i+1]){
            f = true;
            cout << i+1 << " " << i+2 << endl;
            break;
        }
        else if(i+2<N && s[i]==s[i+2]){
            f = true;
            cout << i+1 << " " << i+3 << endl;
            break;
        }
    }
    if(!f) cout << "-1 -1" << endl;
    return 0;
}

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

int main()
{
  int s;
  cin >> s;
  vector<int> S;
  S.push_back(s);

  int one = 0;

  while (one < 2)
  {
    if (s % 2 == 0)
    {
      s /= 2;
    }
    else
    {
      s = (3 * s) + 1;
    }
    S.push_back(s);

    if (s == 1)
    {
      one++;
    }
  }

  for (int i = 0; i < S.size() - 1; i++)
  {
    for (int j = i + 1; j < S.size(); j++)
    {
      if (S[i] == S[j])
      {
        cout << j + 1 << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

signed main(){
    int a, b, c;
    cin >> a >> b >> c;
    if((b * 10 + c )% 4) cout << "NO" << endl;
    else cout << "YES" << endl;
}

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

int main() {
  string s;
  cin >> s;
  int n = SZ(s);
  cout << s.at(0) << (n-2) << s.at(n-1) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    vector<vector<int>>data(3000,vector<int>(2));
    
    for(int i=0;i<3000;i++){
        for(int j=0;j<2;j++){
            cin >> data.at(i).at(j);
        }
    }
    
    for(int i=0;i<3000;i++){
        if(data.at(i).at(0)==0 && data.at(i).at(1)==0){
            break;
        }
        else if(data.at(i).at(0)<data.at(i).at(1)){
            cout << data.at(i).at(0) << " " << data.at(i).at(1) << endl;
        }
        else {
            cout << data.at(i).at(1) << " " << data.at(i).at(0) << endl;
        }
    }
}


Measured memory_bytes: 3180
#include<stdio.h>
#include<string.h>
int main()
{
   int m,n,i,j,k,s,max=0;
   char a[110][20],b[110][20];
   scanf("%d",&m);
   for(i=0;i<m;i++)
   {
        scanf("%s",a[i]);
   }
   scanf("%d",&n);
   for(j=0;j<n;j++)
   {
       scanf("%s",b[j]);
   }
   for(i=0;i<m;i++)
   {    s=0;
       for(k=0;k<m;k++)
       {
           if(strcmp(a[i],a[k])==0)
               s++;
       }
       for(j=0;j<n;j++)
       {
           if(strcmp(a[i],b[j])==0)
               s--;
       }
       if(max<s)
          max=s;
   }
   printf("%d\n",max);
   return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    string s;   cin >> s;
    ll k;   cin >> k;
    ll i = 0;
    while (s[i] == '1')
        i++;
    if (k-1 < i)
        cout << 1 << endl;
    else
        cout << s[i] << endl;

    return 0;
}

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

int main(void){

    int n;
        cin>>n;
    int ans=n%10;

    if(ans==2 || ans==4|| ans==5|| ans==7|| ans==9 )
        cout<<"hon";
    else if(ans==0 || ans==1|| ans==6|| ans==8)
        cout<<"pon";
    else
        cout<<"bon";

}


Measured memory_bytes: 3672
#include<stdio.h>
#define MAX 10000
#define NIL -1

typedef struct {int p, l, r;}Node;
Node T[MAX];
int n;

/*先行順巡回*/
void preParse(int u){
    if(u == NIL) return;
    printf(" %d", u);
    preParse(T[u].l);
    preParse(T[u].r);
}

/*中間順巡回*/
void inParse(int u){
    if(u == NIL) return;
    inParse(T[u].l);
    printf(" %d", u);
    inParse(T[u].r);
}

/*後行順巡回*/
void postParse(int u){
    if(u == NIL) return;  
    postParse(T[u].l);
    postParse(T[u].r);
    printf(" %d", u);
}

int main(){
    int i, v, l, r, root;
    scanf("%d", &n);
    for(i = 0; i < n; i++) T[i].p = NIL;

    for(i = 0; i < n; i++){
        scanf("%d %d %d", &v, &l, &r);
        T[v].l = l;
        T[v].r = r;
        if(l != NIL) T[l].p = v;
        if(r != NIL) T[r].p = v;
    }

    for(i = 0; i < n; i++){
        if(T[i].p == NIL) root = i;
    }

    printf("Preorder\n");
    preParse(root);
    printf("\n");
    printf("Inorder\n");
    inParse(root);
    printf("\n");
    printf("Postorder\n");
    postParse(root);
    printf("\n");

    return 0;
}


Measured memory_bytes: 2148
def solve():
    n = int(input())
    h = list(map(int, input().split()))
    right = h[len(h)-1]
    flag = True
    for i in reversed(h):
        if i <= right:
            right = i
            continue
        elif i-1 == right:
            continue
        else:
            flag = False
            break
    if flag:
        print('Yes')
    else:
        print('No')


solve()


Measured memory_bytes: 63856
#include <cassert>
#include <algorithm>
#include <cctype>
#include <complex>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <ctime>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <sstream>
#include <tuple>
#include <typeinfo>
#include <unordered_set>
#include <unordered_map>
#include <vector>
using namespace std;

#define REP2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define REPD(i, n) for(int i = (int)(n) - 1; i >= 0; i--)
#define REP(i, n) REP2(i, 0, n)
#define ALL(c) (c).begin(), (c).end()
#define PB(e) push_back(e)
#define FOREACH(i, c) for(auto i = (c).begin(); i != (c).end(); ++i)
#define MP(a, b) make_pair(a, b)
#define BIT(n, m) (((n) >> (m)) & 1)

typedef long long ll;

template <typename S, typename T> ostream &operator<<(ostream &out, const pair<S, T> &p) {
  out << "(" << p.first << ", " << p.second << ")";
  return out;
}

template <typename T> ostream &operator<<(ostream &out, const vector<T> &v) {
  out << "[";
  REP(i, v.size()){
    if (i > 0) out << ", ";
    out << v[i];
  }
  out << "]";
  return out;
}


int main(int argc, char *argv[]) {
  ll N, A, B;
  cin >> N >> A >> B;
  if ((B - A) % 2 == 0) {
    cout << (B - A) / 2 << endl;
  } else {
    cout << min(A + (B - A - 1) / 2, N - B + 1 + (B - A - 1) / 2) << endl;
  }
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000)

def solve(g):
    dp = [-1]*len(g)
    def _solve(f):
        if dp[f] == -1:
            dp[f] = 0
            for c in g[f]:
                dp[f] = max(dp[f], 1 + _solve(c))
        return dp[f]
    for f in range(len(g)):
        _solve(f)
    # print(dp)
    return max(dp)

n, m = map(int, input().split())
g = [[] for _ in range(n)]
for _ in range(m):
    f, t = map(int, input().split())
    g[f-1].append(t-1)

print(solve(g))


Measured memory_bytes: 120220
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	long long ans=0,counta=0;


	string S,temp;

	cin >> S;

	for(int i=0; i<S.length(); i++){

		temp=S[i];
		//cout<<S[i]<<endl;
	

		if(temp == "W" ){
			
			
			ans=ans+i-counta;
				//cout <<i <<" "<<S[i]<<" " <<ans <<" " <<counta<<" "<<i-counta<<endl;
			counta++;

		
	}

	
	


	}

	cout <<ans<<endl;







}

Measured memory_bytes: 640
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>

void push(double S[],int *top,double x){

 S[(*top)]=x;
 (*top)++;

return;
}

double pop(double S[],int *top){

 (*top)--;
 return S[(*top)];

}

int main(){
 char str[81];
 int i,j;
 int R,top;
 char temp[10];
 double S[80];
 double x1,x2;

 while(fgets(str,sizeof str,stdin)!=NULL){

   R=strlen(str);
   j=0; i=0; top=0;

   while(i<=R){

     if(i<R && str[i]!=' ')temp[j++]=str[i++];
     else {

       temp[j]='\0';

       if(isdigit(temp[0]))
          push(S,&top,atof(temp));
       else if( !isdigit(temp[0]) && isdigit(temp[1]) )
          push(S,&top,atof(temp));/*負の数*/
       else {
          x1=pop(S,&top);
          x2=pop(S,&top);
          switch(temp[0]){
            case '+':push(S,&top,x2+x1);
                     break;
            case '-':push(S,&top,x2-x1);
                     break;
            case '*':push(S,&top,x2*x1);
                     break;
            case '/':push(S,&top,x2/x1);
                     break;
          }

       }
       i++;
       j=0;

     }


   }
   printf("%.6lf\n",S[0]);

 }


return 0;
}


Measured memory_bytes: 1972
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define REP(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define TF(flag) (flag)?1:0
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================

int main(void){
  int a,b,h; cin>>a>>b>>h;
  cout<<(a+b)*h/2<<endl;
}














Measured memory_bytes: 256
# coding: utf-8
#88
import re

while True:
    b = input()
    
    if b=="END OF INPUT":
        break
    
    B = re.split('[ ]',b)
    #print(B)
    
    for i in range (len(B)-1):
        print(len(B[i]),end='')
    print(len(B[-1]))


Measured memory_bytes: 6484
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define REP(i, n) for(i=0; i<n; i++)
#define REPR(i, n) for(i=n; i>=0; i--)
#define FOR(i, m, n) for(i=m; i<n; i++)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define prin(ans) cout << ans << endl
#define INF 1000000000
#define MOD 1000000007LL
#define MAX 105
#define NIL -1
#define WHITE 0
#define GRAY 1
#define BLACK 2
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PA;
typedef priority_queue<ll> PQ;
typedef pair<double, double> doup;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef map<ll, ll> Map;
 
ll N, M;
ll fact[100101];
ll rfact[100101];
ll ans=1;
Map mp;
 
ll modPow(ll x, ll n) {
    ll res=1;
    while(n>0) {
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
void prime_factor(ll n) {
    for (ll i=2; i*i<=n; i++) {
        while (n%i==0) {
            mp[i]++;
            n/=i;
        }
    }
    if (n!=1) mp[n]++;
}
 
 
int main(void) {
    cin >> N >> M;
    ll i;
    
    fact[0]=rfact[0]=1;
    for(i=1; i<=100100; i++) {
        fact[i]=i*fact[i-1]%MOD;
        rfact[i]=modPow(fact[i], MOD-2);
    }
    
    prime_factor(M);
    
    for(auto it=mp.begin(); it!=mp.end(); it++) {
        ans*=fact[N+it->second-1]%MOD*rfact[N-1]%MOD*rfact[it->second]%MOD;
        ans%=MOD;
    }
    
    prin(ans);
}

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

int main()
{
    int t;
    cin>>t;
    int count=0,cu=0;
    for(int x=1;x<=t;x++)
    {
        int z;
        cin>>z;
        if(z%2!=0) count++;
        else if(z%10==0 || z%6==0) cu++;
    }
    if(cu+count==t) cout<<"APPROVED";
    else cout<<"DENIED";


    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

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

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 1000 + 47;

int C[MAX];

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	string s;
	cin >> s;
	FOR(i, 0, SZ(s))
	{
		C[s[i]] = 1;
	}

	if ((C['W'] ^ C['E']) == 1 || (C['N'] ^ C['S']) == 1)
	{
		cout << "No" << endl;
		return 0;
	}

	cout << "Yes" << endl;
}

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

signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	long long d;
	cin >> n >> d;
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		long long p, q;
		cin >> p >> q;
		if (p * p + q * q <= d * d)
			++ans;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3640
#include<algorithm>
#include<iostream>
#include<string>

int main(int, char**) {
  std::string s, heads;
  std::cin >> s;
  int qs;
  std::cin >> qs;
  bool reverse{};

  for(int i{}; i < qs; ++i) {
    int q;
    std::cin >> q;
    if(q == 1) {
      // reverse
      reverse = !reverse;
    } else {
      int f;
      char c;
      std::cin >> f >> c;
      if(f == 1) {
        // c:s
        if(reverse) {
          s += c;
        } else {
          heads += c;
        }
      } else {
        if(!reverse) {
          s += c;
        } else {
          heads += c;
        }
      }
    }
  }

  std::reverse(begin(heads), end(heads));
  s = heads + s;
  if(reverse) {
    std::reverse(begin(s), end(s));
  }
  std::cout << s << std::endl;

  return 0;
}


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

# print(N % K)
# print(N % abs(N-K))

# SN = N
# PN = float('inf')
# while PN > N:
#     PN = N
#     N = abs(N-K)
#     print(PN, N)

if N == K:
    print(0)

elif N > K:
    val = N % K
    print(min(abs(val), abs(val-K)))
else:
    SN = N
    PN = float('inf')
    while PN > N:
        PN = N
        N = abs(N-K)
    print(min(SN, PN))


Measured memory_bytes: 3060
package main

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

func main() {
	scan_init()
	n := scanInt()
	d := scanInt()
	count := 0
	for i:= 0; i<n; i ++ {
		x := scanInt()
		y := scanInt()
		if (d*d >= x*x + y*y) {
			count ++
		}
	}
	fmt.Println(count)

}

var sc = bufio.NewScanner(os.Stdin)

func scan_init() {
	sc.Split(bufio.ScanWords)
}
func scanInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}
func scan() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 4904
#include <iostream>
#include <stack>
#include <algorithm>
#include <math.h>
#include <string.h>

using namespace std;

int N, K;
int x[200000];
int len[200000];

int main(int argc, char** argv) {
    cin >> N >> K;
    for (int i=0;i<N;i++) cin >> x[i];
    int m = 1e9;
    for (int i=0; i<N-K+1; i++) {
        int len = x[i+K-1] - x[i];
        int d = min(abs(x[i]), abs(x[i+K-1]));
        int m2 = len + d;
        m = min(m, m2);
    }
    cout << m << endl;;
}

Measured memory_bytes: 640