akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll INF = 1'000'000'000'000'000'000;
namespace utils{
#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
    using V_Set = unordered_set<int>;
    using E_Set = unordered_map<int, V_Set>;

    ll operator"" _64(unsigned long long x){ return ll(x); }
    ull operator"" _64u(unsigned long long x){ return ull(x); }

    template<class T>
    vector<T> make_vector(int n, T t){
        return vector<T>(n, t);
    }
    template<class ...Ts>
    auto make_vector(int n, Ts ... ts){
        return vector<decltype(make_vector(ts...))>(n, make_vector(ts...));
    }

    template<class T>
    ostream& operator<<(ostream& os, const vector<T>& v){
        for (auto &&x : v) { os << x << ' '; } cout << endl; return os ;
    }
}
using namespace utils;

class solver{
    istream& is;
    ostream& os;

public:
    solver(istream& I, ostream& O) :is(I), os(O) {}
    void run(){
        ll N, M;
        is >> N >> M;
        if(!is) return;
        vector<int> rem(N, 1);
        vector<bool> maybe_red(N, false);
        maybe_red[0] = true;
        for (int i = 0; i < M; ++i) {
            int x, y;
            is >> x >> y;
            x--; y--;
            rem[x]--;
            rem[y]++;
            if(maybe_red[x]){
                maybe_red[y] = true;
            }
            if(rem[x] == 0){
                maybe_red[x] = false;
            }
        } // end i
        int count = 0;
        for (auto &&mr : maybe_red) {
            count += mr;
        } // end mr
        os << count << endl;

    }
};

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_B.txt";
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int loop = 0;
    while(fs) {
        loop++;
        cout << '#' << loop << "#------\n";
        solver(fs, cout).run();
    }
    if(loop <= 1) {
        cout << "===" << endl;
        while(cin) solver(cin, cout).run();
    }
#else
    solver(cin, cout).run();
#endif
    return 0;
}


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


#define mod 1000000007
#define ull unsigned long long int
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
 
/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<ll,ll>   pi;
 
 
 
/* MATH */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return true; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
ll pow(ll a,ll b,ll m)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a)%m;
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

ll ncr(int n, int k)  
{  
	if(k>n)return 0;
    ll res = 1;  
    if ( k > n - k )  
        k = n - k;  
    for (int i = 0; i < k; ++i)  
    {  
        res *= (n - i);  
        res /= (i + 1);  
    }  
  
    return res;  
} 
  
//
/* MACROS */
 
#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 
#define  deb(x)       cout << '>' << #x << ':' << x << endl;


void  solve()
{
	ll n,k;
	cin>>n>>k;
	ll arr[n];
	forn(i,n)
	{
		cin>>arr[i];
	}
	sort(arr,arr+n,greater<ll>());
	ll ans=0;
	for(int i=0;i<n;i++)
	{
		if(i>=k)ans+=arr[i];
	}
	cout<<ans<<endl;

}


int main()
{
    FastIO;
    ll t=1;
   	//bcin>>t;
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 1920
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<math.h>
int main(){
    int n,k=1,f=1;
    scanf("%d",&n);
    char s[n],t[n],a[n+n];
    scanf("%s %s",s,t);
      a[0]=s[0];
        a[1]=t[0];
    for(int i=2;i<n+n;i++){
    if(i%2!=0)
        a[i]=t[k++];
    if(i%2==0)
        a[i]=s[f++];
    }
    for(int i=0;i<n+n;i++)
    printf("%c",a[i]);
    return 0;
}


Measured memory_bytes: 128
//#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<cmath>
#include<map>
#include<functional>
#include<queue>
#include<set>
#include<stack>
#include<iomanip>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0;i<(n);i++)
template<typename T =ll> using v = vector<T>;
template<typename T =ll> using vv = v<v<T>>;
template<typename T =ll,typename U =ll> using p = pair<T,U>;
template<typename T> T chmin(T &a,T b) {return a=min(a,b);}
template<typename T> T chmax(T &a,T b) {return a=max(a,b);}
const ll INF = (ll)1e9;

void a(){
    double r; cin >> r;
    cout<< fixed <<setprecision(15) <<2*M_PI*r<<endl;
}

void b(){
    ll n,m; cin >> n >> m;
    ll sum=0;
    rep(i,m){
        ll a;
        cin >> a;
        sum+=a;
    }
    cout << ((sum<=n?n-sum:-1));
}


void c(){
    ll n; cin >> n;
    auto a = v<>(n,0);
    ll up = 0;
    for(ll i=1;i<n;i++) {
        cin >> up;
        up--;
        a[up]++;
    }
    for(auto i:a){
        cout << i << endl;
    }
}

void d(){

}

void e(){

}

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

Measured memory_bytes: 4792
#include <bits/stdc++.h>
#define int long long

int sumofdigits(int x) {
  int sum = 0;
  while (x > 0) {
    sum += x % 10;
    x /= 10;
  }
  return sum;
}

void PrintMap(std::map<int, int>& m) {
  for (auto iter: m) {
    std::cout << iter.first << " => " << iter.second << "\n";
  }
}

int digits(int x) {
  int d = 0;
  while (x > 0) {
    x /= 10;
    d++;
  }
  return d;
}

signed main() {
  int n;
  std::cin >> n;
  int rtn = (int)std::floor(std::sqrt((double)n));
  
  int min = 100;
  for (int a = 1; a <= rtn; a++) {
    if (n % a == 0) {
      int b = n / a;
      if (std::max(digits(a), digits(b)) < min) {
        min = std::max(digits(a), digits(b));
      }
    }
  }
  
  std::cout << min << '\n';
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) ((X > Y)? X : Y)
#define MIN(X, Y) ((X < Y)? X : Y)
//　10min
int main(void){
  int n;
  int ans = 0;
  
  scanf("%d", &n);

  for(int i = 1; i <= n; i++){
    if(i < 10){
      ans++;
    }else if(i > 99 && i < 1000){
      ans++;
    }else if(i > 9999 && i < 100000){
      ans++;
    }
  }
  
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 128
n = int(input())
l = list(map(int,input().split()))
a = 0
b = 0
for i in range(n):
    if i%2==0:
        a+=max(l)
        del l[l.index(max(l))]
    else:
        b+=max(l)
        del l[l.index(max(l))]
print(a-b)

Measured memory_bytes: 3060
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    INF = 10**18
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]

    N,M = LI()
    root = []
    for _ in range(M):
        a,b,c = LI()
        root.append((a-1,b-1,c))
    node = [-INF]* N

    node[0] = 0
    up = False
    for _ in range(N):
        up = False
        for a,b,c in root:
            if node[a] + c > node[b]:
                node[b] = node[a] + c
                if b == N-1: up = True
    if up:
        print('inf')
    else:
        print(node[N-1])


if __name__ == '__main__':
    main()

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

const ll INF = 1e18;
const ll MOD = 1000000007;
const ll MX = 0; //最大値

#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define ALL(x) (x).begin(),(x).end()
#define MAX(x) *max_element(ALL(x))
#define PB push_back
#define F first
#define S second

ll n, k;
vector<ll> A;

ll cut(ll mid){
    ll res = 0;
    rep(i, n) res += ((A[i] - 1) / mid);
    return res;
}

int main(){
    cin >> n >> k;
    A.resize(n);
    rep(i, n) cin >> A[i];
    
    ll left = 1, right = *max_element(ALL(A));
    while(right != left){
        ll mid = (right + left) / 2;
        if(cut(mid) > k) left = mid + 1;
        else right = mid;
    }

    cout << left << endl;
    
    return 0;
}

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

int binarySearch(vector<int> v,int key){
    int left =0;
    int right = v.size();
    int mid;
    while(left < right){
        mid = (left + right)/2;
        if(v[mid] == key) return 1;
        else if(key < v[mid]) right = mid;
        else {left = mid + 1;}
    }
    return 0;
}

int main(){
    int n; cin >> n;
    vector<int> v(n);
    for (int i=0;i<n;i++){
        cin >> v[i];
    }
    int q; cin >> q;
    vector<int> s(q);
    for (int i=0;i<q;i++){
        cin >> s[i];
    }
    int res = 0;
    for (int i=0;i<q;i++){
        res += binarySearch(v,s[i]);
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3848
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  double ans = 0;
  rep2(i, 1, n+1){
    double add = (double)1/n;
    if(i >= k){
      ans += add;
      continue;
    }
    double d =log2((double)k/i);
    int co = ceil(d);
    // cerr << d << " " << co << endl;
    add *= pow(0.5, co);
    ans += add;
  }
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}

Measured memory_bytes: 4068
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstdlib>
using namespace std;
int main(){
	int h,w;
	char s[60][60];
	bool TF=false;
	string a="";
	int count=0,nx,ny;
	cin>>h>>w;
	for(int i=0;i<h;i++){
		cin>>s[i];
	}
	for(int i=0;i<h;i++){//y
		for(int j=0;j<w;j++){//x
			count=0;
			for(int k=-1;k<=1;k++){
				for(int l=-1;l<=1;l++){
					nx=i+k;//now_x
					ny=j+l;//now_y
					if(nx==i && ny==j && s[nx][ny]=='#'){
						a="#";
					}
					if(0<=nx && 0<=ny && nx<h && ny<w && s[nx][ny]=='#'){
						count++;
					}
				}
			}
			cout<<a;
			if(a!="#")cout<<count;
			a="";
		}
		cout<<endl;
	}
	return 0;
}

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

int main(){
  int n; cin >> n;
  string s,t; cin >> s >> t;
  int ans = s.size()+t.size();
  for(int i = n; 0 <= i; i--)
  if(s.find(t.substr(0,i)) != string::npos){
    ans -= i;
    break;
  }
  cout << ans;
  cout << "\n";
  return 0;
}


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

a = [i+1 for i in range(9)]

while(1):
    if k <= len(a):
        print (a[k-1])
        break

    b = []
    k = k - len(a)
    x = a
    a = b
    b = x

    for x in b:
        for i in [-1,0,1]:
            d =  x%10  + i
            if d < 0 or d > 9: continue
            a.append( x*10 + d)


Measured memory_bytes: 11028
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;


const int VMAX = 10;

int dist[VMAX][VMAX];
signed main() {
  string s;
  cin >> s;
  regex re("^A?KIHA?BA?RA?$");
  smatch match;
  if (regex_match(s, match, re)) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


Measured memory_bytes: 384
s=input()
t=input()

sl = [s[i] for i in range(0,len(s))]
tl = [t[i] for i in range(0,len(t))]
slsort = sorted(sl)
tlreversesort = sorted(tl, reverse=True)

# print(slsort)
# print(tlreversesort)

if slsort < tlreversesort:
    print('Yes')
else:
    print('No')




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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;

/*
 * Supports range sum queries on a mutable array of Ts.
 * Requires that T's + operator is associative and that T() is the
 * additive identity: T() + t = t = t + T() for any T t.
 */
template<typename T> struct segment_tree {
    int S;
    vector<T> table;

    segment_tree<T>(int _S) : S(_S) {
        table.resize(2 * S);
    }

    segment_tree<T>(auto begin, auto end) : segment_tree(distance(begin, end)) {
        copy(begin, end, table.begin() + S);
        for (int i = S - 1; i > 0; i--)
            table[i] = table[2 * i] + table[2 * i + 1];
    }

    // Replaces the element at index i with v
    void replace(int i, T v) {
        table[i += S] = v;
        for (i /= 2; i > 0; i /= 2) {
            table[i] = table[2 * i] + table[2 * i + 1];
        }
    }

    // Returns the value of the element at index i
    const T& operator()(int i) const { return table[S + i]; }

    // Returns the sum of the elements at indices in [i, j)
    T operator()(int i, int j) const {
        T left{}, right{};
        for (i += S, j += S; i < j; i /= 2, j /= 2) {
            if (i&1) left = left + table[i++];
            if (j&1) right = table[--j] + right;
        }
        return left + right;
    }
};

struct max_ll {
    ll val;

    max_ll() : val(0) {}
    max_ll(ll val) : val(val) {}

    max_ll operator+(const max_ll& other) const {
        return max_ll(max(val, other.val));
    }
};

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

    int N;
    cin >> N;

    vi H(N);
    vll A(N);
    for(int i=0;i<N;i++) cin >> H[i];
    for(int i=0;i<N;i++) cin >> A[i];

    segment_tree<max_ll> segtree(N);
    for(int i=0;i<N;i++) {
        int h = H[i]-1;
        ll cur = A[i];
        if (h > 0) cur += segtree(0, h).val;

        segtree.replace(h, cur);
    }

    ll ans = segtree(0, N).val;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5760
#include<iostream> 
using namespace std; 
int main() {
	int n; 
	cin >> n; 
	if (n==1)
	{
		cout << "Hello World\n";
	}
	else
	{
		int a, b; 
		cin >> a >> b; 
		cout << a + b << "\n";
	}
}

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

        ll x,k,d; cin>>x>>k>>d;
        x=abs(x);
        ll tr=(x/d);
        if(tr>=k){ cout<<x-k*d<<endl;}
        else if((k-tr)%2==0){ cout<<x-tr*d<<endl; }
        else{ cout<<abs(x-tr*d-d)<<endl; }

}
int main(){
solve();
}


Measured memory_bytes: 3624
#include<stdio.h>
int main(void)
{
	int i,n,a,b,sum1,sum2;
	scanf("%d",&n);
	while(n!=0) {
		sum1=0;
		sum2=0;
		for(i=1;i<=n;i++) {
			scanf("%d %d",&a,&b);
			if(a>b) {
				sum1+=(a+b);
			}
			else if(a<b) {
				sum2+=(a+b);
			}
			else {
				sum1+=a;
				sum2+=b;
			}
		}
		printf("%d %d\n",sum1,sum2);
	scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 600
using System;

namespace C___Attack_Survival
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var n = int.Parse (input[0]);
            var k = int.Parse (input[1]);
            var q = int.Parse (input[2]);
            var a = new int[q];
            var point = new int[n];
            for (var i = 0; i < q; i++)
            {
                a[i] = int.Parse (Console.ReadLine ());
            }
            for (var i = 0; i < n; i++)
            {
                point[i] = k - q;
            }
            for (var i = 0; i < q; i++) //a
            {
                point[a[i] - 1] += 1;
            }
            foreach (var p in point)
            {
                if (p <= 0)
                {
                    Console.WriteLine ("No");
                }
                else
                {
                    Console.WriteLine ("Yes");
                }
            }
        }
    }
}

Measured memory_bytes: 16092
#define ab(a, b) (a<b?b-a:a-b)
#define mi(a, b) (a<b?a:b)
unsigned long c[100001];
main(){
  int N,h[100000],i;
  scanf("%d", &N);
  for(i = 0; i < N; i++){    
  	scanf("%d", h+i);
  }
  c[0] = 0;
  c[1] = ab(h[0], h[1]);
  for(i = 2; i < N; i++){    
  	c[i] = c[i-1] + ab(h[i], h[i-1]);
    c[i] = mi(c[i], (c[i-2] + ab(h[i], h[i-2])));
  }
  
  printf("%d\n",c[N-1]);
}

Measured memory_bytes: 1280
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// #include <functional> 
// using namespace __gnu_pbds;
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MaX 300005
using namespace std;

 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
// typedef tree<int, null_type, less<int>, rb_tree_tag, 
//              tree_order_statistics_node_update> 
//     new_data_set; 
bool isprime(ll n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
  
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}


int main()
{
    fast();
    int ans=0,n,i,x;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>x;
        if(x%2==1 and i%2==1)
            ans++;        
    }
    cout<<ans;
}


Measured memory_bytes: 3528
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int top,stack[200];
void push(int x){
	top++;
	stack[top]=x;
}
int pop(){
	top--;
	return stack[top+1];
}
int main(){
	int a,b,top=0;
	char s[200];
	while(scanf("%s",s)!=EOF){
		if(s[0]=='+'){
			a=pop();
			b=pop();
			push(a+b);
		}
		else if(s[0]=='-'){
			a=pop();
			b=pop();
			push(b-a);
		}
		else if(s[0]=='*'){
			a=pop();
			b=pop();
			push(a*b);
		}
		else{
			push(atoi(s));
		}
	}
	printf("%d\n",stack[1]);
	return 0;
}






















Measured memory_bytes: 2088
#include <stdio.h>
constexpr int kMod = int(1E9 + 7);
constexpr int kN = int(1E5 + 10);
int a[kN];
int main() {
	int n, cnt, x = 0, y = 0, z = 0;
	long long int ans = 1;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for (int i = 1; i <= n; i++) {
		cnt = 0;
		if (x == a[i]) cnt++;
		if (y == a[i]) cnt++;
		if (z == a[i]) cnt++;
		ans = (ans * cnt) % kMod;
		if (x == a[i]) x++;
		else if (y == a[i]) y++;
		else if (z == a[i]) z++;
		//else a[kMod] = kN;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int t = 0,count = 0;
		int b = a;
		while (b>0){
			b = b/10;
			t ++;
		}
		for (int i = 1; i < t; i+=2){
			if (i==1){
				count+=9;
			} else {
				int min=1,max=9,j=i;
				while (j>1){
					min*=10;
					max*=10;
					max+=9;
					j--;
				}
				count+=max-min;
				count++;
			}
		}
		if(t%2==1) {
			int min = 1,j = t;
			while (j>1){
				min*=10;
				j--;
			}
			count+=a-min;
			count++;
		}
		System.out.println(count);
		sc.close();
	}
}

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<std::vector<char> > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 


ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }
ll lcm(ll a, ll b) { return a*(b/gcd(a,b)); }

int main(void)
{
    int n, m;
    cin >> n >> m;
    cout << lcm(n,m) << endl;
}
/** atcoder **/


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

map<int,int> num;

int main(void){
	int n;
	cin >> n;
	
	rep(i,n){
		int in;
		cin >> in;
		num[in]++;
	}

	vector<ll> ary={0,0};
	for(auto &elem:num) rep(loop,elem.second/2) ary.push_back(elem.first);
	sort(rbegin(ary),rend(ary));

	ll ans = 1LL*ary[0]*ary[1];
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4992
H, W = map(int, input().split())

if (H*W) % 2 == 0:
  if H == 1 or W == 1:
    res = 1
  else:
    res = int(H * W / 2)
else:
  if H == 1 or W == 1:
    res = 1
  else:
    res =  int(H * (W//2) + int(H/2) + 1)
print('{0:d}'.format(res))

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

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

int main(){
  int W,H,C;
  cin>>W>>H>>C;
  int sai=gcd(W,H);
  int cost=0;
  for(int i=0;i<W/sai;i++){
    for(int j=0;j<H/sai;j++){
      cost+=C;
    }
  }
  cout<<cost<<endl;
}



Measured memory_bytes: 3084
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int abc[26]={0};
  cin >> s;
  int flag;
  for(int i=0;i<4;i++){
    flag =s.at(i)-'0';
    flag=flag%26;
    abc[flag]++;
  }
  flag =0;
  bool yeno = true;
  for(int i=0;i<26;i++){
    if(abc[i]==2) flag++;
  }
  if(flag != 2) yeno=false;

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


Measured memory_bytes: 256
/*
  AUTHOR:SOURABH
  CREATED:01:05:20
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ordered_set tree<pll , null_type, less< pll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(i=0;i<x;i++)
#define fs(i,s,x) for(i=s;i<x;i++)
#define fr(i,x) for(i=x;i>=0;i--)
#define fit(it,s) for(it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define mod 1000000007
#define MAX 100005
#define M 32

using namespace std;
using namespace __gnu_pbds;

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

    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll t,i,n,ans;
    mll b;//string s;
    t=1;
    //cin>>t;
    W(t--)
    {
        cin>>n;
        vll a(n);
        fn(i,n)
        cin>>a[i];
        ans=0;
        fn(i,n)
        {
            ans+=b[i-a[i]];
            b[i+a[i]]++;
        }
        cout<<ans;
    }
    return 0;
}






















Measured memory_bytes: 27352
///////////////////////////////////////////// Template /////////////////////////////////////////////
#![allow(non_snake_case, unused)]
use std::collections::*;

//////////////////// missing functions in 1.15.1 ////////////////////
macro_rules! eprint {
	($($t:tt)*) => { {
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	} };
}
macro_rules! eprintln {
	($($t:tt)*) => { {
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	} };
}

//////////////////// useful functions ////////////////////
pub trait SetMin {
	fn setmin(&mut self, v: Self) -> bool;
}
impl<T> SetMin for T where T: PartialOrd {
	fn setmin(&mut self, v: T) -> bool {
		*self > v && { *self = v; true }
	}
}
pub trait SetMax {
	fn setmax(&mut self, v: Self) -> bool;
}
impl<T> SetMax for T where T: PartialOrd {
	fn setmax(&mut self, v: T) -> bool {
		*self < v && { *self = v; true }
	}
}

macro_rules! debug {
	($($v: expr),*) => {
		$(eprint!("{} = {:?} ", stringify!($v), $v);)*
		eprintln!("@ {}:{}", file!(), line!());
	}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:ty),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}
////////////////////////////////////////////////////////////////////////////////////////////////////

fn run() {
	let S = read!([u8]);
	let T = read!([u8]);
	let mut ok = false;
	for i in 0..S.len() {
		ok |= S[i..] == T[0..T.len() - i] && S[0..i] == T[T.len() - i..];
	}
	if ok {
		println!("Yes");
	} else {
		println!("No");
	}
}


Measured memory_bytes: 8572
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_CHAR_MAX		100										// 最大文字数
#define D_CHAR_SP		'('										// 前括弧
#define D_CHAR_EP		')'										// 後括弧

// 内部変数
static char sc1Out[D_CHAR_MAX * 2 + 5];							// 出力内容
static int siBNo;												// セット位置 - 前
static int siANo;												// セット位置 - 後

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// 出力内容に文字追加 - 前
int
fAddCharB(
	char pcChar					// <I> 追加文字
)
{
	siBNo--;
	sc1Out[siBNo] = pcChar;

	return 0;
}

// 出力内容に文字追加 - 後
int
fAddCharA(
	char pcChar					// <I> 追加文字
)
{
	sc1Out[siANo] = pcChar;
	siANo++;

	return 0;
}

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// データ初期化
	siBNo = D_CHAR_MAX;											// セット位置 - 前
	siANo = D_CHAR_MAX;											// セット位置 - 後

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// 文字数取得
	int liCCnt;
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d", &liCCnt);

	// 文字列取得
	char lc1Str[D_CHAR_MAX + 5];
#ifdef D_TEST
	fgets(lc1Str, sizeof(lc1Str), szpFpT);
#else
	fgets(lc1Str, sizeof(lc1Str), stdin);
#endif

	// 出力内容セット
	int liSPCnt = 0;
	for (i = 0; i < liCCnt; i++) {
		if (lc1Str[i] == D_CHAR_SP) {		// 前括弧
			fAddCharA(D_CHAR_SP);				// 後に追加
			liSPCnt++;							// 前括弧のストック
		}
		else {								// 後括弧
			fAddCharA(D_CHAR_EP);				// 後に追加
			if (liSPCnt > 0) {					// 前括弧のストックあり
				liSPCnt--;							// 前括弧のストック
			}
			else {								// 前括弧のストックなし
				fAddCharB(D_CHAR_SP);				// 前に追加
			}
		}
	}

	// 前括弧のストック
	for (i = 0; i < liSPCnt; i++) {
		fAddCharA(D_CHAR_EP);				// 後に追加
	}

	// 後に追加
	fAddCharA('\0');

	// 結果セット
	sprintf(lc1Out, "%s\n", &sc1Out[siBNo]);

	// 結果表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 128
#include <iostream>]
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    cout << N * (N - 1) / 2 << endl;;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 500000
#define M 2000000000

unsigned long long int cnt;
int L[N/2+2], R[N/2+2];

unsigned long long int merge(int A[], int left, int mid, int right){
    int n1, n2, i, j;
    cnt=0;
    n1 = mid - left; n2 = right - mid;

    for(i=0 ; i<n1 ; i++)   L[i] = A[left+i];
    for(i=0 ; i<n2 ; i++)   R[i] = A[mid+i];
    
    L[n1] = R[n2] = M;
    i=0; j=0;

    for(int k=left ; k<right ; k++){
        if(L[i] <= R[j]){
            A[k] = L[i];
            i++;
        }
        else{
            A[k] = R[j];
            j++; 
            cnt += n1 - i; //Lの要素の残りの数
        }
    }
    return cnt;
}

unsigned long long int  mergeSort(int A[], int left, int right){
    unsigned long long int v1, v2, v3;
    if(left+1<right){
        int mid = (left+right) / 2;
        v1 = mergeSort(A, left, mid);
        v2 = mergeSort(A, mid, right);
        v3 = merge(A, left, mid, right);
        return v1+v2+v3;
    }
    else return 0;
}


int main(void){
    int n, a[N];
    scanf("%d", &n);
    for(int i=0 ; i<n ; i++)
        scanf("%d",&a[i]);
    cnt = mergeSort(a, 0, n);
    printf("%lld\n", cnt);
    return 0;
}



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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int main(){
    int n;
    cin >> n;
    int ans = 0;
    while(n > 0){
        if(n % 10 == 2){
            ++ans;
        }
        n /= 10;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int A = scan.nextInt();
        int B = scan.nextInt();
        int answer = A * B - A - B + 1;
        System.out.println(answer);
    }
}


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

int main() {
    vector<int> a(5, 0), b(5, 0);
    for(int i=0; i<5; i++) cin >> a[i];

    int idx = 0, minmod = 9;
    for(int i=0; i<5; i++){
        if(a[i] % 10 != 0){
            b[i] = (a[i] / 10 + 1) * 10;

            if(a[i] % 10 < minmod){
                minmod = a[i] % 10;
                idx = i;
            }
        }
        else{
            b[i] = a[i];
        }
    }

    int cnt = 0;
    for(int i=0; i<5; i++) cnt += b[i];

    cnt = cnt - b[idx]  + a[idx];

    // for(int i=0; i<5; i++) cout << b[i] << endl;

    cout << cnt << endl;

}


Measured memory_bytes: 256
/*
 * main.c
 *
 *  Created on: 2016/08/28
 *      Author: Wakaki
 */
#include<stdio.h>

int main(){

	int i,n;
	int top,north,south,east,west,bottom,temp;
	char direction[8];

	while(1){
		top=1;
		north=2;
		west=3;
		east=4;
		south=5;
		bottom=6;

		scanf("%d",&n);
		if(n==0){
			break;
		}

		for(i=0;i<n;i++){
			scanf("%s",direction);

		    if(direction[0]=='n'){
		    	temp=top;
		    	top=south;
		    	south=bottom;
		    	bottom=north;
		    	north=temp;
		    }
		    else if(direction[0]=='s'){
		    	temp=top;
		    	top=north;
		    	north=bottom;
		    	bottom=south;
		    	south=temp;
		    }
		    else if(direction[0]=='w'){
		    	temp=top;
		    	top=east;
		    	east=bottom;
		    	bottom=west;
		    	west=temp;
		    }
		    else if(direction[0]=='e'){
		    	temp=top;
		    	top=west;
		    	west=bottom;
		    	bottom=east;
		    	east=temp;
		    }
		}
		printf("%d\n",top);
	}

	return(0);
}

Measured memory_bytes: 604
string = input()

if len(string)%2==0 :
    string = string[:-2]
else :
    string = string[:-3]
length = len(string)

while length>0 :
    if string[:length//2]==string[length//2:] :
        print(length)
        break
    length -= 2
    string = string[:-2]

Measured memory_bytes: 3060
n, m = map(int, input().split())
ac = [0] * n
wa = [0] * n


for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'WA':
        if ac[int(p) - 1] == 0:
            wa[p - 1] += 1
    else:
        ac[p - 1] = 1

acs, was = 0, 0

for i in range(n):
    acs += ac[i]
    was += ac[i] * wa[i]

print(acs, was)


Measured memory_bytes: 4596
#include <stdio.h>
int main(void){
    char abs[1000];
    int N;
    scanf("%d",&N);
    scanf("%s",abs);
    int left=0;
    int right=0;
    for(int i=0;i<N;i++){
        if(abs[i]=='('){
            left++;
        }
        else{
            right++;
            if(left!=0){
                right--;
                left--;
            }
        }
    }
    for(int i=0;i<right;i++)printf("(");
    printf("%s",abs);
    for(int i=0;i<left;i++)printf(")");
    return 0;
}


Measured memory_bytes: 128
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines


class UnionFind():
    # 作りたい要素数nで初期化
    # 使用するインスタンス変数の初期化
    def __init__(self, n):
        self.n = n
        # root[x]<0ならそのノードが根かつその値が木の要素数
        # rootノードでその木の要素数を記録する
        self.root = [-1]*(n+1)
        # 木をくっつける時にアンバランスにならないように調整する
        self.rnk = [0]*(n+1)

    # ノードxのrootノードを見つける
    def Find_Root(self, x):
        if self.root[x] < 0:
            return x
        else:
            # ここで代入しておくことで、後の繰り返しを避ける
            self.root[x] = self.Find_Root(self.root[x])
            return self.root[x]

    # 木の併合、入力は併合したい各ノード
    def Unite(self, x, y):
        # 入力ノードのrootノードを見つける
        x = self.Find_Root(x)
        y = self.Find_Root(y)
        # すでに同じ木に属していた場合
        if x == y:
            return
        # 違う木に属していた場合rnkを見てくっつける方を決める
        elif self.rnk[x] > self.rnk[y]:
            self.root[x] += self.root[y]
            self.root[y] = x

        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            # rnkが同じ（深さに差がない場合）は1増やす
            if self.rnk[x] == self.rnk[y]:
                self.rnk[y] += 1

    # xとyが同じグループに属するか判断
    def isSameGroup(self, x, y):
        return self.Find_Root(x) == self.Find_Root(y)

    # ノードxが属する木のサイズを返す
    def Count(self, x):
        return -self.root[self.Find_Root(x)]


N, M = map(int, readline().split())
root = UnionFind(N)
ans = N * (N - 1) // 2
answer = []

for i in readlines()[::-1]:
    answer.append(ans)
    a, b = map(int, i.split())
    if not root.isSameGroup(a, b):
        ans -= root.Count(a) * root.Count(b)
        root.Unite(a, b)

for i in answer[::-1]:
    print(i)

Measured memory_bytes: 18852
#include <iostream>

using namespace std;

int fx(int x){
    return x*x;
};

int main() {
    int d;
    while( cin >> d)
    {
        int l = d;
        int s = 0;
        while(l <= 600 - d)
        {
            s += fx(l) * d;
            l += d;
        }
        cout << s <<endl;
    }
    return 0;
}

Measured memory_bytes: 3100
/**
 * Sergey Kopeliovich (burunduk30@gmail.com)
 */

#include <bits/stdc++.h>

using namespace std;

#define forn(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
	int h, w, d;
	scanf("%d%d%d", &h, &w, &d);
	const char *s = "RYGB";
	int res[h][w];
	forn(i, h) {
		forn(j, w) {
			int a = i + j, b = i - j + w, D = d;
			a /= D, b /= D;
			res[i][j] = (a & 1) * 2 + (b & 1);
			putchar(s[res[i][j]]);
		}
		puts("");
	}
	// forn(i, h) 
	// 	forn(j, w) 
	// 		forn(i1, h) 
	// 			forn(j1, w) 
	// 				if (abs(i - i1) + abs(j - j1) == d)
	// 					assert(res[i][j] != res[i1][j1]);
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
// online submission
#endif
	int a;
	cin>>a;
	long long n=a*a;
	cout<<a*n+a+n;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
//Warshall-Floyd
const long long inf = 1e12;
const int max_v = 1000;
long long k[max_v][max_v]; //最短距離
int n; //頂点数
void warshall_floyd() {
    for(int kk = 1; kk <= n; kk++) {
        for(int ii = 1; ii <= n; ii++) {
            for(int jj = 1; jj <= n; jj++) {
                k[ii][jj] = min(k[ii][jj], k[ii][kk] + k[kk][jj]);
            }
        }
    }
}
int main() {
	// your code goes here
	int m,r,i,j,a,b;
	long long c,memo,mn=1e12;
	vector<int> g;
	cin >> n >> m >> r;
	for(i=0;i<r;i++){
		int R;
		cin >> R;
		g.push_back(R);
	}
	sort(g.begin(),g.end());
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			if(i==j) k[i][j]=0;
			else k[i][j]=1e12;
		}
	}
	for(i=0;i<m;i++){
		cin >> a >> b >> c;
		k[a][b]=c;
		k[b][a]=c;
	}
	warshall_floyd();
	do {
		memo=0;
		for(i=1;i<r;i++) memo+=k[g[i-1]][g[i]];
		mn=min(mn,memo);
	} while (next_permutation(g.begin(), g.end()));
	cout << mn << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);


int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    ll N,M; cin>>N>>M;
    vector<bool> left(N,false); //1-?
    vector<bool> right(N,false); //?-N
    rep(i,M){
        ll A,B; cin>>A>>B;
        if(A==1 || B==1){
            left[A*B]=true;
        }
        else if(A==N || B==N){
            right[(A*B)/N]=true;
        }
    }
    FOR(i,2,N){
        if(left[i] && right[i]){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
}


Measured memory_bytes: 3640
<?php
fscanf(STDIN, "%d %d %d",$n,$a,$b);
if($n==1 && $a==$b)
{
	echo("1");
}
elseif($n==1 || $a > $b)
{
	echo("0");
}
else
{
	echo(($b-$a)*($n-2)+1);
}

Measured memory_bytes: 3576
#include <iostream>
#include <unordered_set>

using namespace std;

int solve(int s)
{
	unordered_set<int> a;

	for (int m = 1; ; ++m) {
		if (!a.insert(s).second) {
			return m;
		}
		if (s % 2 == 0) {
			s = s / 2;
		}
		else {
			s = 3 * s + 1;
		}
	}
	return -1;
}

int main()
{
	int s;
	cin >> s;
	cout << solve(s) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define TRAV(i, a) for(auto & i : (a))
#define SZ(x) ((int)(x).size())
#define PR std::pair
#define MP std::make_pair
#define X first
#define Y second
typedef long long ll;
typedef std::pair<int, int> PII;
typedef std::vector<int> VI;

void fail(){
	std::cout << -1;
	std::exit(0);
}

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

	int n;
	std::cin >> n;

	const ll INF = 1000000000ll*1000000000ll;

	ll have = 1;
	std::vector<ll> moge(n);
	std::vector<ll> A(n+1);

	FOR(i, n){
		std::cin >> A[i];
		ll a = A[i];
		
		have -= a;
		if(have < 0) fail();
		moge[i] = have;

		have *= 2;
		if(have > INF) have = INF;
	}

	std::cin >> A[n];
	if(have < A[n]) fail();

	ll ans = 0;
	ll must = A[n];
	for(int i = n; i >= 1; --i){
		ans += must;

		
		must = std::min(moge[i-1], must)+A[i-1];
	}
	ans++;

	std::cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 5188
#include<bits/stdc++.h>
using namespace std;
int n;
int t[1000000];

int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>t[i],t[i]--;

  int ans=0;
  for(int i=0;i<n;i++){
    int b=t[i];
    if(b<i)continue;
    if(t[b]==i)ans++;
  }
  cout<<ans<<endl;
  
  return 0;
}


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

int main() {
	int n, x;
	cin >> n >> x;
	int a[100];
	for (int i = 0;i < n;i++)cin >> a[i];
	int sum = 0;
	for (int i = 0;i < n;i++)sum += a[i];
	x -= sum;
	sort(a, a + n);
	cout << n + x / a[0] << endl;
}

Measured memory_bytes: 256