akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

const int MAX_V=10;
int d[10][10];
int V;
const int INF=100000000;

void warshall_floyd(){
	for(int k = 0; k < V; k++){
		for(int i = 0; i < V; i++){
			for(int j = 0; j < V; j++){
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
}

int main(){

	int n;
	while(cin>>n&&n!=0){
		for(int i = 0; i < 10; i++)
			fill(d[i],d[i]+10,INF);
		set<int> s;
		for(int i = 0; i < n; i++){
			int a,b,c;
			cin>>a>>b>>c;
			d[a][b]=c;
			d[b][a]=c;
			s.insert(a);
			s.insert(b);
		}
		V=s.size();
		for(int i = 0; i < V; i++){
			d[i][i]=0;
		}

		warshall_floyd();
		int idx;
		int minValue=INF;
		for(int i = 0; i < V; i++){
			int sum=0;
			for(int j = 0; j < V; j++){
				if(i!=j&&d[i][j]!=INF){
					sum+=d[i][j];
				}
			}
			if(minValue>sum){
				minValue=sum;
				idx=i;
			}
		}
		cout<<idx<<" "<<minValue<<endl;
	}


	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 

using namespace std;

int main()
{
   FAST/**/
   
   ll m1,d1,m2,d2;
   cin>>m1>>d1>>m2>>d2;
   
   if(m1!=m2)
       cout<<1;
   
   else cout<<0;
   
   return 0;
}  
   

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

int main() {
  int N;
  cin >> N;
  vector<int> h(N), dp(N);
  for(int i = 0; i < N; i++) {
    cin >> h.at(i);
  }
  dp.at(0) = 0;
  dp.at(1) = abs(h.at(0) - h.at(1));
  for(int i = 1; i < N-1; i++) {
    dp.at(i+1) = min({dp.at(i-1) + abs(h.at(i-1) - h.at(i+1)), dp.at(i) + abs(h.at(i) - h.at(i+1))});
    }
  cout << dp.at(N-1);
}

Measured memory_bytes: 1024
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func stringifyArray(arr []int) string {
	return strings.TrimRight(fmt.Sprintf("%+v", arr)[1:], "]")
}

func main() {
	scanner.Split(bufio.ScanWords)

	a, _ := nextInt()
	b, _ := nextInt()

	fmt.Printf("%d %d %f\n", a/b, a%b, float64(a)/float64(b))
}



Measured memory_bytes: 1104
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n+1); ++i)
using namespace std;
using ll = long long;
const ll INF = +10010010000;

typedef pair<ll,ll> P;
const ll MO = 1000000007;

int main(){
    ll n;
    cin >> n;
    vector<ll> c(5);
    rep(i,5)cin>>c[i];
    ll mini = c[0];
    rep(i,5){
        mini = min(mini,c[i]);
    }
    cout << 4+(n+(mini-1))/mini << endl;
    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define CHKR
#define ll long long
#define pb push_back
//#define mp make_pair
#define fr first
#define sc second
#define ARRS int(2e5+500)
#define BARRS int(6e4+600)
#define MAX ((long long)(1e9+1))
#define EP ((long double)(1e-9))
#define MMAX ((long long)(1e9+10))
#define HS1 ((long long)(1000001329))
#define HS2 ((long long)(1000001531))
#define MOD ((long long)1000000009ll)
#define SQ 31622780
#define PI 3.14159265358979323846264338327950288419716939937510
#define BG 4294967232ll
#define MH 200008


ll a[ARRS];
unsigned ll rev(unsigned ll x){
    ll p=x,c=0;
    while(p){
        c=c*10ll+p%10ll;
        p/=10ll;
    }
    return c;
}

ll l;
ll b[40];
set<pair<ll,ll> > st;
unsigned ll m,n;
unsigned ll pm=1;
void go(ll x){
    if(x==m){
        if(b[m-1]==0||b[m-1]==-1)return;
        unsigned ll t=0;
        for(int i=m-1; i>=0; i--){
            t=t*10ull+b[i];
            //cout<<b[i]<<endl;
        }
        if(rev(t)<t)return;
       // cout<<m<<" "<<t<<" "<<rev(t)<<" "<<rev(t)-t<<endl;
        if(rev(t)-t==n)st.insert({t,pm});
        return;
    }
    if(b[x]!=-1){go(x+1);return;}
    int m1=0,m2=0;
    for(int i=0; i<=9; i++){
        for(int j=0; j<=9; j++){
            if((j-i+10)%10==a[x]){
                if(j>i&&m1)continue;
                if(j<i&&m2)continue;
                if(x==0&&j==0)continue;
                b[x]=i;
                b[m-x-1]=j;
                //if(m-x-1>10&&abs(i-j)>1)continue;
                if(i==j&&x)pm=pm*10ull;
                if(i==j&&!x)pm=pm*9ull;
                if(j>i)m1=1,pm=pm*(10ull-j);
                if(j<i)m2=2,pm=pm*(10ull-i);
              //  cout<<i<<" "<<j<<" "<<j-i+10<<" "<<a[x]<<" "<<x<<endl;
                ll y=-1;
                if(j<i){
                    y=x+1;
                    while(a[y]==9)
                        {a[y]=0;y++;}
                    a[y]++;
                }
                go(x+1);
                b[x]=-1;
                b[m-x-1]=-1;
                if(j<i){
                    a[y]--;
                    for(int i=x+1; i<y; i++)
                        a[i]=9;
                }
                if(j>i)pm=pm/(10ull-j);
                if(j<i)pm=pm/(10ull-i);
                if(i==j&&x)pm=pm/10ull;
                if(i==j&&!x)pm=pm/9ull;
                if(i==j)return;
            }

        }
    }
}

#ifndef CHKR
int main(){
#else
int doit(fstream &in,fstream &out){
    cin.rdbuf(in.rdbuf());
    cout.rdbuf(out.rdbuf());
#endif
    #ifdef KHOKHO
        #ifndef CHKR
        freopen("in.in","r",stdin);
        freopen("out.out","w+",stdout);
        #endif //CHKR
    #endif //KHOKHO
    ll d=MAX,p,s=0,c=0;
    cin>>n;
    m=0;
    p=n;
    while(p){
        a[m]=p%10;
        p/=10;
        m++;
    }

    for(m=0; m<=19; m++){
        for(int i=0; i<30; i++)b[i]=-1;
        go(0);
    }
    ll pas=0;
    for(auto t:st){
        pas+=t.sc;
    }

    cout<<pas;
    return 0;
}


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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N,M,Q; cin >> N >> M >> Q;
    vector<vector<int>> T(N, vector<int>(N,0));
    REP(i,M){
        int l,r; cin >> l >> r;
        l--; r--;
        T[l][r]++;
    }

    REP(i,N){
        REP(j,N-1){
            T[i][j+1] += T[i][j];
        }
    }

    for(int i=N-1; i>=1; i--){
        REP(j,N){
            T[i-1][j] += T[i][j];
        }
    }

    REP(i,Q){
        int p,q; cin >> p >> q;
        p--; q--;
        cout << T[p][q] << endl;
    }
    return 0;
}

Measured memory_bytes: 4612
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product
import sys
import bisect
import string
import math
import time


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


def S(): return input()


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


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def debug(table, *args):
    ret = []
    for name, val in table.items():
        if val in args:
            ret.append('{}: {}'.format(name, val))
    print(' | '.join(ret), file=sys.stderr)


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N, M = MI()
    A = LI()
    ans = N - sum(A)

    if ans < 0:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 74804
#coding:utf-8
import itertools
import numpy as np
# d, g = 2, 700
# ls_p = [3, 5]
# ls_c = [500, 800]
d, g = map(int,input().split())
ls_p = []
ls_c = []
for i in range(d):
    p, c = map(int,input().split())
    ls_p.append(p)
    ls_c.append(c)
ls_p = np.array(ls_p)
min = ls_p.sum()
ls_c = np.array(ls_c)
nums = [0, 1]
ls_isFull = np.array([list(i) for i in itertools.product(nums, repeat=d)])[:-1]
ls_count = ls_isFull * ls_p

w = np.arange(1,d+1) * 100
#print (ls_count.dot(w) + ls_isFull.dot(ls_c))

def get_idx(ls):
    return max(np.where(ls==0)[0])


for i in range(len(ls_count)):
    
    if ls_count[i].sum() >=  min:
        continue
    idx = get_idx(ls_isFull[i])
    for j in range(ls_p[idx]):

        score = ls_count[i].dot(w) + ls_isFull[i].dot(ls_c)
        #print ( ls_count[i], score)

        if (score >= g) &  (ls_count[i].sum() < min):
            min = ls_count[i].sum()
            #print (min)
            continue
        ls_count[i][idx]+=1
print (min)


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
        string s;
        cin>>s;
        string t;
        for(int i=0; i<s.size(); i++){
                if(s[i]!='B')
                        t+=s[i];
                else if(t.size()>0)
                        t.pop_back();
        }
        cout<<t;
}

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

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

K, X = map(int, input().split())
mn = max(X - K + 1, -1000000)
mx = min(X + K - 1, 1000000)
print(*range(mn, mx + 1, 1))



Measured memory_bytes: 6988
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;


struct maxTree {
    int score;
    int coordinate;
    vector<int> down;
    bool check;
};

maxTree tree[10000];
int score[10000];
int setScore = 0;

void search(int coordinate) {
    if (tree[coordinate].check) return;
    tree[coordinate].score = score[setScore];
    tree[coordinate].check = true;
    ++setScore;
    for (int i = 0; i < tree[coordinate].down.size(); i++) {
        search(tree[coordinate].down[i]);
    }
}

signed main() {
    int N;
    cin >> N;
    vector<pair<int, int>> path(N - 1);
    for (int i = 0; i < N - 1; i++) {
        cin >> path[i].first >> path[i].second;
        path[i].first--;
        path[i].second--;
    }
    for (int i = 0; i < N; i++) {
        tree[i].coordinate = i;
        tree[i].check = false;
    }
    for (int i = 0; i < N - 1; i++) {
        tree[path[i].first].down.push_back(path[i].second);
        tree[path[i].second].down.push_back(path[i].first);
    }
    int maxCoordinate = -1, rootCoordinate = 0;
    for (int i = 0; i < N; i++) {
        maxCoordinate = max(maxCoordinate, (int) tree[i].down.size());
        if (maxCoordinate == (int) tree[i].down.size()) rootCoordinate = i;
    }
    vector<int> tempScore(N);
    for (int i = 0; i < N; i++) cin >> tempScore[i];
    sort(tempScore.begin(), tempScore.end(), greater<>());
    for (int i = 0; i < N; i++) score[i] = tempScore[i];
    search(rootCoordinate);
    int ans = accumulate(tempScore.begin(), tempScore.end(), 0LL) - *max_element(tempScore.begin(), tempScore.end());
    cout << ans << endl;
    for (int i = 0; i < N; i++) {
        if (i == N - 1) {
            cout << tree[i].score << endl;
        } else {
            cout << tree[i].score << " ";
        }
    }
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
int main()
{
    int n;
    cin>>n;
    long a[n];
    for(int i = 0; i<n; i++)
        cin>>a[i];
    int ssum[n];
    ssum[n-1] = a[n-1];
    for(int i = n-2; i>=0; i--)
        ssum[i] = (a[i] + ssum[i+1])%M;
    long long int sum = 0;
    for(int i  = 0; i<n-1; i++)
        sum = (sum + (a[i]*ssum[i+1])%M)%M;
    cout<<sum<<endl;
    
        
    
}

Measured memory_bytes: 5904
mlist = [int(input()) for i in range(5)]
minmin = 10
cnt = 0
for i in mlist:
  if i%10 != 0:
    minmin = min(minmin,i%10)
  else:
    cnt+=1
ans = 0
for i in mlist:
  if i%10 != 0:
    ans += (i//10 +1)*10
  else:
    ans +=i
if cnt <5:
  ans = ans + minmin - 10
else:
  ans = sum(mlist)
print(ans)

Measured memory_bytes: 38384
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};

bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

bool augment(const Graph& g, int u,
    vector<int>& matchTo, vector<bool>& visited) {
  if (u < 0) return true;
  FOR(e, g[u]) if (!visited[e->dst]) {
    visited[e->dst] = true;
    if (augment(g, matchTo[e->dst], matchTo, visited)) {
      matchTo[e->src] = e->dst;
      matchTo[e->dst] = e->src;
      return true;
    }
  }
  return false;
}
int bipartiteMatching(const Graph& g, int L) {
  const int n = g.size();
  vector<int> matchTo(n, -1);
  int match = 0;
  REP(u, L) {
    vector<bool> visited(n);
    if (augment(g, u, matchTo, visited)) ++match;
  }
  return match;
}

int gcd(int a, int b) {
  return b!=0 ? gcd(b, a%b) : a;
}

int main() {
  int m, n;
  while(cin >> m >> n, m||n) {
    vector<int> b(m);
    vector<int> r(n);
    REP(i,m)
      cin >> b[i];
    REP(i,n)
      cin >> r[i];

    Graph g(m+n);
    REP(i,m) {
      REP(j,n) {
        if (gcd(b[i],r[j]) != 1) {
          g[i].push_back(Edge(i, m+j, 1));
          g[m+j].push_back(Edge(m+j, i, 1));
        }
      }
    }
    cout << bipartiteMatching(g, m) << endl;
  }
}

Measured memory_bytes: 5236
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextInt();
		}

		// 計算
		int result = 0;
		ArrayList<Integer> list = new ArrayList<Integer>();
		for(int i = 0; i < n; i++){
		    if(list.size() == 0){
		        list.add(a[i]);
		    }else{
		        int lowerIndex = lowerBound(list, a[i]) - 1;
		        if(lowerIndex >= 0){
		            list.remove(lowerIndex);
		            list.add(lowerIndex, a[i]);
		        }else{
		            list.add(0, a[i]);
		        }
		    }
		}
		result = list.size();
		
		// 出力
		System.out.println(result);
	}

	static int lowerBound(ArrayList<Integer> list, int n){
		int index = ~Collections.binarySearch(list, n, (x,y) -> x.compareTo(y) >= 0 ? 1 : -1);
		return index;
	}
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;

template<class T>
inline bool chmax(T &a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
};

template<class T>
inline bool chmin(T &a, T b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
};

struct Data {
  int x, y, h;
  bool operator < (const Data &d) const {
    return h < d.h;
  }
};

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

  vector<Data> data(N);

  int x, y, h;

  rep(i, 0, N) {
    cin >> x >> y >> h;
    data[i] = { x, y, h };
  }

  /* h == 0 が最後に見るようにするため */
  sort(All(data));
  reverse(All(data));

  int ans_cx, ans_cy, ans_h;

  rep(cx, 0, 101) {
    rep(cy, 0, 101) {
      int H = -1;
      bool flag = true;
      rep(i, 0, N) {
        Data d = data[i];
        x = d.x;
        y = d.y;
        h = d.h;

        int tmp = abs(x - cx) + abs(y - cy);
        int H2 = h + tmp;

        if (h == 0) {
          if (H <= tmp) {
            continue;
          } else {
            flag = false;
            break;
          }
        }

        if (H == -1) {
          H = H2;
        } else if (H != H2) {
          flag = false;
          break;
        }
      }

      if (flag) {
        ans_cx = cx;
        ans_cy = cy;
        ans_h = H;
        break;
      }
    }
  }

  cout << ans_cx << " " << ans_cy << " " << ans_h << endl;
};


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N;
  cin >> N ;
  vector<int> P(N);
  for(int i=0;i<N;i++){
    cin >>P.at(i);}

  sort(P.begin(), P.end());
  int j=0,k=0;
  for(int i=0; i<N;i++){
  if(j != P.at(i)){
    k++;
  j=P.at(i);
  }
    
}
  cout << k <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define V vector<int>
#define S set<int>
#define pb(v) push_back(v)

int main(){
    CIN(N);
    int ans = 0;
    REP(a,N){
        CIN(l);CIN(r);
        ans += abs(l-r)+1;
    }
    COUT(ans);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

@SuppressWarnings("unchecked")
public class Main {
	// public static void printArray(int[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	// public static<T> void printArrayT(T[] a) {
	// 	for (int i = 0; i < a.length; i++) {
	// 		System.out.print(a[i] + ", ");
	// 	}
	// 	System.out.println();
	// }

	public static String joinInt(int[] a, String separator) {
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < a.length; i++) {
			if (i > 0) {
				sb.append(separator);
			}
			sb.append(a[i]);
		}
		return sb.toString();		
	}

	static int[] nextIntArray(Scanner sc, int N) {
		int[] arr = new int[N];
		for (int i = 0; i < N; i++) {
			arr[i] = sc.nextInt();
		}
		return arr;
	}

	static long solve(int N, long X) {
		// System.out.println("-> " + N + ", " + X);
		if (N == 0) {
			return X > 0 ? 1 : 0;
		}
		if (X > 0) {
			X--; // ban
		}
		if (X <= H[N-1]) {
			return solve(N-1, X);
		}
		X -= H[N-1];
		if (X == 1) return 1 + P[N-1];
		X--;
		return solve(N-1, X) + 1 + P[N-1];
	}

	static long[] P;
	static long[] H;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long X = sc.nextLong();

		H = new long[N+1];
		P = new long[N+1];
		H[0] = 1;
		P[0] = 1;
		for (int i = 0; i < N; i++) {
			H[i+1] = H[i] * 2 + 3;
			P[i+1] = P[i] * 2 + 1;
		}
		long ans = solve(N, X);
		System.out.println(ans);

		// System.out.println("BBPPPBPBPPPBB");
		// for (int i = 1; i <= 13; i++) {
		// 	System.out.println(solve(2, i));
		// }
	}
}


Measured memory_bytes: 23764
/*
ID: varunra2
LANG: C++
TASK: a
*/

#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG
#include "lib/debug.h"
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#pragma GCC diagnostic ignored "-Wsign-compare"
//#pragma GCC diagnostic ignored "-Wunused-parameter"
//#pragma GCC diagnostic ignored "-Wunused-variable"
#else
#define debug(...) 42
#endif

#define EPS 1e-9
#define IN(A, B, C) assert(B <= A && A <= C)
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))
#define MOD 1000000007
#define MP make_pair
#define PB push_back
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define x first
#define y second

const double PI = acos(-1.0);
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef map<int, int> MPII;
typedef multiset<int> MSETI;
typedef set<int> SETI;
typedef set<string> SETS;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<string> VS;

#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define sz(x) (int)(x).size()
typedef pair<int, int> pii;
typedef vector<int> vi;
#pragma GCC diagnostic ignored "-Wsign-compare"
// util functions

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

  // need some reds at the beginning followed by a bunch of white stones

  int n;
  cin >> n;

  string s;
  cin >> s;

  VI a(n, 0);
  VI b(n, 0);

  for (int i = 0; i < n; i++) {
    if (s[i] == 'W')
      a[i] = 1;
    else
      b[i] = 1;
  }
  for (int i = 1; i < n; i++) {
    a[i] += a[i - 1];
  }
  for (int i = n - 2; i >= 0; i--) {
    b[i] += b[i + 1];
  }

  int ret;

  ret = min(a[n - 1], b[0]);

  for (int i = 0; i < n - 1; i++) {
    // 0 -> i inclusive with 1's
    // i + 1 -> n - 1 inclusive with 0's

    if (a[i] == b[i + 1]) ret = min(ret, a[i]);
  }

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 5192
#include <bits/stdc++.h>
#define REP(i,n)   for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(long long i=(a);((a)<(b)?i<=(b):i>=(b));((a)<(b)?++i:--i))
#define ALL(v)     (v).begin(),(v).end()
#define debug(x)   cerr<<#x<<": "<<(x)<<endl
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

int main(){
	int n;
	string s;
	cin>>n>>s;
	
	int ans=0;
	int l=0,r=n-1;
	while(1){
		while(s[l]!='W' and l<n-1) l++;
		while(s[r]!='R' and 0<r) r--;
		if(l>=r) break;
		s[l]='R', s[r]='W';
		ans++;
	}
	//debug(s);
	
	cout<<ans<<endl;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(n);++i);
#define FOR(i,m,n) for(int i=(m);i<(n);i++);
#define VSORT(v) sort(v.begin(),v.end());
#define YES cout<<"Yes"<<endl;
#define NO cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const double PI=acos(-1);
typedef pair<int,int>P;
const int mod =1e9+7;
const int di[]={-1,0,1,0},dj[]={0,-1,0,1};
const int INF = 99999999;
const ll LINF = 9999999999999;

int main()
{
    int a;
    cin>>a;
    cout<<abs(a-1);
}


Measured memory_bytes: 3632
n, a = map(int, input().split())
x = list(map(int, input().split()))
X = max(x)
y = [i - a for i in x]
dp = [[0 for t in range(2 * n * X + 10)] for j in range(n + 1)]
dp[0][n * X] = 1
for j in range(1, n + 1):
    for t in range(2 * n * X + 1):
        if 0 <= t - y[j - 1] <= 2 * n * X:
            dp[j][t] = dp[j - 1][t] + dp[j - 1][t - y[j - 1]]
        elif t - y[j - 1] < 0 or t - y[j - 1] > 2 * n * X:
            dp[j][t] = dp[j - 1][t]
print(dp[n][n * X] - 1)

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

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

using ll = long long;

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

bool judge( std::string S ) {
  for(int i=0; i<sz(S); i++) {
    int b = i;
    int l = sz(S)-i-1;
    if ( b == l ) break;
    if ( S[b] != S[l] ) return false;
  }
  return true;
}

int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  std::string S; std::cin >> S;
  if ( judge(S) && judge(S.substr(0,(sz(S)-1)/2)) && judge(S.substr((sz(S)+3)/2-1, sz(S))) ) 
    std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
 
#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)
 
ll ii(){ ll x; cin >> x; return x; }
string is(){ string x; cin >> x; return x; }
void oi(ll x){ cout << x; }
void od(ld x){ cout << fixed << setprecision(10) << x; }
void os(string x){ cout << x; }
void oie(ll x){ cout << x << endl; }
void ode(ld x){ cout << fixed << setprecision(10) << x << endl; }
void ose(string x){ cout << x << endl; }
void oe(){ cout << endl; }
 
int main(){
    string S=is();
    REP(i,0,3){
        if(S[i]=='7'){
            ose("Yes");
            return 0;
        }
    }
    ose("No");
 
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main(){
	vector<string> results;
	int N = 0;
	cin >> N;
	for(int i = 0; i < N; i++){
		array<int, 3> triangle_vertex;
		for(int j = 0; j < 3; j++){
			cin >> triangle_vertex[j];
		}
		sort(begin(triangle_vertex), end(triangle_vertex));
		if(pow(triangle_vertex[0], 2) + pow(triangle_vertex[1], 2) == pow(triangle_vertex[2], 2)){
			results.push_back("YES");
		}
		else{
			results.push_back("NO");
		}
	}
	for(const auto& result : results){
		cout << result << endl;
	}
	return 0;
}

Measured memory_bytes: 1268
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
typedef long long ll;
ll INF = 100000000000;

int main() {
		int A,B,Q;
		cin >> A >> B >> Q;
		vector<ll> s(A+2), t(B+2);

		s[0] = -INF;
		for (int i=1; i<=A; i++) cin >> s[i]; s[A+1] = INF;
		t[0] = -INF;
		for (int i=1; i<=B; i++) cin >> t[i]; t[B+1] = INF;
		
		for (int i=0; i<Q; i++) {
				ll x; cin >> x;
				auto sitr = upper_bound(s.begin(), s.end(), x);
				auto titr = upper_bound(t.begin(), t.end(), x);

				int sidx = distance(s.begin(), sitr);
				int tidx = distance(t.begin(), titr);

				vector<ll> sroute{s[sidx-1], s[sidx]};
				vector<ll> troute{t[tidx-1], t[tidx]};

				long ans = INF;
				for (auto S: sroute) {
						for (auto T: troute) {
								long d1 = abs(S-x) + abs(T-S);
								long d2 = abs(T-x) + abs(S-T);
								ans = min(min(ans, d1), d2); 
						}
				}
				cout << ans << endl;
		}
}


Measured memory_bytes: 2944
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
//ll dp[100001];

int main()
{
  int n,k;
  cin>>n>>k;
  int a[n+1];
  ll dp[n+1];
  for(int i=1;i<n+1;i++)
  {
    cin>>a[i];
    //dp[i]=-1;
  }
  dp[0]=0;
  dp[1]=0;
  for(int i=2;i<=n;i++)
  {
    int t=k;
    if(t>=i)
      t=i-1;
    ll p=INT_MAX;
    for(int j=1;j<=t;j++)
    {
      p=min(p,abs(a[i]-a[i-j])+dp[i-j]);
    }
    dp[i]=p;
  }
  cout<<dp[n];
}


Measured memory_bytes: 1408
#include <stdio.h>
#include <math.h>
#include <string.h>
#define pai 3.1415926535

int main(void) {
	char a, b;
	scanf("%c %c", &a, &b);
	if ((a == 'H'&&b == 'H') || (a == 'D'&&b == 'D')) {
		printf("H");
	}
	else {
		printf("D");
	}



	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
	int t; cin>>t;
	int n,m;
	while(t--){
		cin>>n>>m;
		if(n&1) cout<<(n-1)*127+m<<endl;
		else cout<<(n-1)*127+(127-m)<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<atcoder/all>
#define a(x,y)if(std::gcd(x,y)==1)A=x*atcoder::inv_mod(x,y),m=std::min(m,(A>1?A:A+N)-1);
long long m,N,A,i=1;
signed main(){
  std::cin>>N;N*=2;m=N*9;
  for(;i*i<=N;i++)if(N%i==0){a(i,N/i)a(N/i,i)}
  std::cout<<m;
}

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


int main()
{
    int N, Y;
    cin >> N >> Y;

    int ans[3] = {};

    for( int i = 0; i <= Y/10000; ++i ){
        int a = Y - 10000*i;
        for( int j = 0; j <= a/5000; ++j ){
            int b = (a - 5000*j) % 1000;
            if( b == 0 && i + j + (a - 5000*j) / 1000 == N ){
                ans[0] = i;
                ans[1] = j;
                ans[2] = (a - 5000*j) / 1000;
                break;
            }
        }
    }
    
    if( ans[0]+ans[1]+ans[2] == 0 ) cout << "-1 -1 -1" << endl;
    else cout << ans[0] << " " << ans[1] << " " << ans[2] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;
using std::vector;

struct data_t {
	int ind;
	int height;
};

bool cmp(const data_t& left, const data_t& right) {
	return (left.height == right.height) || (left.height < right.height);
}

int main(void) {
	int n,m,a;
	cin >> n;
	cin >> m;
	cin >> a;
	
	while (n!=0||m!=0||a!=0) {
		vector<int> res(n);
		vector<int> p(m),q(m);
		vector<data_t> h(m);
		int ind;
		
		for (int i = 0; i < n; i++) {
			res[i] = i + 1;
		}

		for (int i = 0; i < m; i++) {
			cin >> h[i].height;
			h[i].ind = i;
			cin >> p[i];
			cin >> q[i];
		}

		std::sort(h.begin(),h.end(),cmp);

		for (int i = 0; i < m; i++) {
			ind = h[i].ind;
			std::swap(res[p[ind]-1], res[q[ind]-1]);
		}
			
		cout << res[a-1] << endl;

		cin >> n;
		cin >> m;
		cin >> a;
	}

	return 0;
}

Measured memory_bytes: 3016
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

pub fn gcd(a: isize, b: isize) -> isize {
    if b == 0 {
        a
    } else {
        gcd(b, a % b)
    }
}

pub fn gcd_list(vec: Vec<isize>) -> isize {
    assert!(vec.len() > 1);
    vec.iter().fold(vec[0], |acc, x| gcd(*x, acc))
}

#[fastout]
fn main() {
    input!{
        n: usize, x: isize,
        x_vec: [isize; n],
    }

    let diff: Vec<isize> = (0..n).map(|i| (x_vec[i] - x).abs()).filter(|&x| x != 0).collect();

    let ans = if diff.len() == 1 { diff[0] } else { gcd_list(diff) };

    println!("{}", ans);
}


Measured memory_bytes: 4688
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<pair<ll,ll>> t(N);
    for(int i = 0; i < N; i++){
        ll A,B;
        cin >> A >>B;
        t[i] = make_pair(B,A);
    }
    sort(t.begin(),t.end());
    ll sum = 0;
    for(int i =0 ; i < N; i++){
        sum += t[i].second;
        if(sum > t[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

}


Measured memory_bytes: 3328
using System;

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            for(int i; (i = int.Parse(Console.ReadLine())) != 0;) {
                var sum = -i;
                for(int l = 1; l * l <= i; ++l) {
                    if ((i % l) == 0) {
                        if (i / l != l) {
                            sum += l;
                        }
                        sum += i / l;
                    }
                }
                Console.WriteLine(sum == i ? "perfect number" : sum < i ? "deficient number" : "abundant number");
            }
        }
    }
}

Measured memory_bytes: 5292
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
//double pi=3.1415926535898;
//double pi=acos(-1.0);
#define scarr(a,s,e) for(int i=s;i<=int(e);i++) scanf("%d ",&a[i]);
#define prarr(a,s,e) for(int i=s;i<=int(e);i++) printf("%d ",a[i]);
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define mkp        make_pair
#define fr         first
#define se         second
#define sc(x)      scanf("%d",&x)
#define pr(x)      printf("%d ",x)
#define scl(x)     scanf("%lld",&x)
#define prl(x)     printf("%lld ",x)
#define prln(x)    printf("%d\n",x)
#define r0         return 0;
#define CC         continue;
#define scd(x)     scanf("%lf",&x)
#define prd(x)     printf("%.10f\n",x);
#define bb(x)      cerr<< x <<endl;
#define ii         pair<int,int>
//#define max(a,b) a<b?b:a
//#define min(a,b) a<b?a:b
const ll M   = 1e7+9 ;
const ll inf = 1e19  ;
const int si = 1e5+9 ;
//////////////////////    Hi    ^_^  hack me if you can :P
int a[30];
int main()
{
    int n,k;
    string s;
    cin >> n >> k;
    ms(a,0);
    lop(i,n)
    {
        cin>>s;
            a[s[0]-'A']++;
    }
    int c = 0;
    int ans = 0;
    bool br = 0;
    while(1){
        sort(a,a+26);
        for(int i=25;i>=0;i--){
            if(a[i]==0){
                br = 1;
                break ;
            }
            a[i]--;
            c++;
            if(c==k)
                break;
        }
        if(br)
            break;
        c=0;
        ++ans;
    }
    cout<<ans<<endl;

    r0;
}


/*

ll pwmod(ll a, ll n, ll mod) {
    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}

*/
/*
freopen("output.txt","w",stdout);
freopen("input.txt","r",stdin);
for (int i=0;i<n;i++)            Hi    ^_^  hack me if you can :P
int mx[]= {0,0,1,1,1,-1,-1,-1};
int my[]= {1,-1,0,1,-1,0,1,-1};
bool inside (int i,int j) {return (i>=0 && i<n && j>=0 && j<m);}
*/


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main()
{
    string S, T;
    cin >> S >> T;
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        if (S[i] == T[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import fractions
a, b, c, d = map(int, input().split())
ac = (a-1)//c*c
bc = b//c*c
ccnt = (bc-ac)//c
ad = (a-1)//d*d
bd = b//d*d
dcnt = (bd-ad)//d
e = c*d//fractions.gcd(c,d)
ae = (a-1)//e*e
be = b//e*e
ecnt = (be-ae)//e
print(-a+b+1-ccnt-dcnt+ecnt)
#print(ccnt, dcnt, ecnt)

Measured memory_bytes: 5076
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    let mut m: Vec<Vec<isize>> = vec![vec![INFTY; n]; n];
    for i in 0..n {
        for j in 0..n {
            let weight: isize = iterator.next().unwrap().parse().unwrap();
            if weight != -1 {
                m[i][j] = weight;
            }
        }
    }

    let mut d: Vec<isize> = vec![INFTY; n];
    let mut color: Vec<Color> = vec![Color::WHITE; n];
    let mut p: Vec<isize> = vec![0; n];
    d[0] = 0;
    p[0] = -1;
    loop {
        let mut min_cost = INFTY;
        let mut u: usize = 0;
        for i in 0..n {
            if color[i] != Color::BLACK && d[i] < min_cost {
                min_cost = d[i];
                u = i;
            }
        }

        if min_cost == INFTY {
            break;
        }

        color[u] = Color::BLACK;

        for v in 0..n {
            if color[v] != Color::BLACK && m[u][v] != INFTY {
                if m[u][v] < d[v] {
                    d[v] = m[u][v];
                    p[v] = u as isize;
                    color[v] = Color::GRAY;
                }
            }
        }
    }

    let mut sum = 0;
    for i in 0..n {
        if p[i] != -1 {
            sum += m[i][p[i] as usize]
        }
    }
    return sum.to_string();
}

const INFTY: isize = 2001;

#[derive(Clone, PartialEq)]
enum Color {
    WHITE, GRAY, BLACK
}



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

int main(){
  int a,b,i,j;
  string array[101];
  cin>>a>>b;
  for(i=0;i<a;i++){
    cin>>array[i];
  }
  sort(array,array+a);
  for(i=0;i<a;i++){
    cout<<array[i];
  }
  cout<<endl;
}

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

int main() {
	int H, W, ans = 0;
	cin >> H >> W;
	vector<string> A(H);
	queue<pair<int, int>> a;
	vector<vector<int>> b(H, vector<int>(W, -1));
	for (int i = 0; i < H; i++) {
		cin >> A[i];
		for (int j = 0; j < W; j++) {
			if (A[i][j] == '#') {
				a.emplace(i, j);
				b[i][j] = 0;
			}
		}
	}
	while (!a.empty()) {
		if (a.front().first - 1 != -1) {
			if (b[a.front().first - 1][a.front().second] == -1) {
				a.emplace(a.front().first - 1, a.front().second);
				b[a.front().first - 1][a.front().second] = b[a.front().first][a.front().second] + 1;
			}
		}
		if (a.front().second - 1 != -1) {
			if (b[a.front().first][a.front().second - 1] == -1) {
				a.emplace(a.front().first, a.front().second - 1);
				b[a.front().first][a.front().second - 1] = b[a.front().first][a.front().second] + 1;
			}
		}
		if (a.front().second + 1 != W) {
			if (b[a.front().first][a.front().second + 1] == -1) {
				a.emplace(a.front().first, a.front().second + 1);
				b[a.front().first][a.front().second + 1] = b[a.front().first][a.front().second] + 1;
			}
		}
		if (a.front().first + 1 != H) {
			if (b[a.front().first + 1][a.front().second] == -1) {
				a.emplace(a.front().first + 1, a.front().second);
				b[a.front().first + 1][a.front().second] = b[a.front().first][a.front().second] + 1;
			}
		}
		a.pop();
	}
	for (vector<int>& i : b) ans = max(ans, *max_element(i.begin(), i.end()));
	cout << ans;
}

Measured memory_bytes: 13456
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
 
	Scanner sc  = new Scanner(System.in);
    int N = Integer.parseInt(sc.next());
    int sum=0;

    for(int i=0;i<N+1;i++){
        sum+=i;
    }


        System.out.print(sum);
        System.out.println();
	}
        
}

Measured memory_bytes: 9556
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
int n;
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	in(n);cout<<n*n*n<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
int main() {
    int e;
    while (cin >> e, e) {
        int ret = 1e6;
        for (int z=0; z*z*z<=e; ++z) {
            int y = (int)sqrt(e - z*z*z);
            int x = e - z*z*z - y*y;
            ret = min(ret, x+y+z);
        }
        cout << ret << endl;
    }
    return 0;
}

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

int main() {
    string odd, even, ans = "";
    cin >> odd >> even;

    for (int i = 1; i <= odd.size()+even.size(); i++)
    {
        if (i % 2 == 1) ans.push_back(odd[i / 2]);
        if (i % 2 == 0) ans.push_back(even[i / 2 - 1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int h,w;
int x,y,xx,yy;
char mp[1005][1005];
struct kkk{
	int step,nx,ny;
};
int wx[4]={1,0,0,-1};
int wy[4]={0,1,-1,0};
bool vis[1005][1005];
struct cmp{
	bool operator () (kkk aa, kkk bb){
		return aa.step>bb.step;
	}
};
int main(){
	cin>>h>>w;
	cin>>x>>y;
	cin>>xx>>yy;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>mp[i][j];
		}
	}
	priority_queue<kkk,vector<kkk>,cmp> q;
	kkk now,nxt;
	now.nx=x,now.ny=y,now.step=0;
	q.push(now);
	while(!q.empty()){
		now=q.top();
//		cout<<"x:"<<now.nx<<" y:"<<now.ny<<endl;
		if(now.nx==xx&&now.ny==yy){
			cout<<now.step;
			return 0;
		}
		q.pop();
		if(vis[now.nx][now.ny])continue;
		vis[now.nx][now.ny]=1;
		for(int i=0;i<4;i++){
			if(mp[now.nx+wx[i]][now.ny+wy[i]]=='.'&&!vis[now.nx+wx[i]][now.ny+wy[i]]){
				nxt.nx=now.nx+wx[i],nxt.ny=now.ny+wy[i],nxt.step=now.step;
				q.push(nxt);
			}
		}
		for(int i=max(1,now.nx-2);i<=min(h,now.nx+2);i++){
			for(int j=max(1,now.ny-2);j<=min(w,now.ny+2);j++){
				if(mp[i][j]=='.'&&!vis[i][j]){
					nxt.nx=i,nxt.ny=j,nxt.step=now.step+1;
					q.push(nxt);
				}
			}
		}
	}
	cout<<"-1";
	return 0;
}

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

#define MIN(x, y) ((x) < (y) ? (x) : (y))
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#define ABS(x, y) ((x) > (y) ? ((x) - (y)) : ((y) - (x)))

#define MOD(x, y) ((x) % (y))
#define DIVCEIL(x, y) (((x) + ((y) - 1)) / (y))
#define DIVFLOOR(x, y) (((x) + ((y) / 2)) / (y))
#define DIVROUND(x, y) ((x) - MOD(x, y) >= MOD(x, y) ? DIVCEIL(x, y) : DIVFLOOR(x, y))

constexpr int MAX_N = 30;

long long dp[MAX_N+3];

int main() {
  dp[0] = 1;

  for (int i{}; i < MAX_N; ++i) {
    dp[i+1] += dp[i];
    dp[i+2] += dp[i];
    dp[i+3] += dp[i];
  }

  while (true) {
    int N; cin >> N;
    if (!N) break;
    cout << DIVCEIL(dp[N], 3650) << endl;
  }

  return 0;
}



Measured memory_bytes: 3016
#include <iostream>
#include <math.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <typeinfo>
#include <climits>
#include <ctype.h>
#include <string>
#include <stack>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)
struct omt{omt(){ios::sync_with_stdio(false);cin.tie(0);}}star;

int main(){
    int a, b;
    cin >> a >> b;
    if(a + b > 9) cout << "error" << endl;
    else cout << a + b << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main
{
	public static void main ( String[] args )
	{
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		ArrayList<Integer> a = new ArrayList();

		for( int i = 0; i < N; ++i ) a.add(sc.nextInt());

		int ans = 1 << 30;
		for( int i = -100; i <= 100; ++i ){
			int tmp = 0;
			for( int j = 0; j < N; ++j ){
				tmp += (a.get(j)-i)*(a.get(j)-i);
			}
			ans = Math.min(tmp, ans);
		}
		System.out.println(ans);
	}
}


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

using namespace std;

const int INF = 1 << 30;

struct SegNode
{
  int v;

  SegNode(int v) : v(v) {}

  SegNode operator*(const SegNode &r) const
  {
    return (v < r.v ? *this : r);
  }
} e(INF);

struct SegmentTree
{
  int sz;
  vector< SegNode > seg;

  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    seg.assign(2 * sz - 1, e);
  }

  void update(int k, const SegNode &x)
  {
    k += sz - 1;
    seg[k] = x;
    while(k > 0) {
      k = (k - 1) >> 1;
      seg[k] = seg[2 * k + 1] * seg[2 * k + 2];
    }
  }

  SegNode query(int a, int b, int k, int l, int r)
  {
    if(a >= r || b <= l) return (e);
    if(a <= l && r <= b) return (seg[k]);
    return (query(a, b, 2 * k + 1, l, (l + r) >> 1) * query(a, b, 2 * k + 2, (l + r) >> 1, r));
  }

  SegNode query(int a, int b)
  {
    return (query(a, b, 0, 0, sz));
  }
};

int main()
{
  int N, K;
  string S, T;

  cin >> N >> K;

  cin >> S;
  cin >> T;

  vector< int > sweep(N + 1);
  for(int i = 0; i + 1 < N; i++) {
    if(T[i] != T[i + 1]) sweep[i + 1] = 1;
    sweep[i + 1] += sweep[i];
  }

  SegmentTree seg(N);
  vector< int > dp(N + 1, INF);
  dp[0] = 0;
  seg.update(0, 0);
  for(int i = 1; i <= N; i++) {
    dp[i] = min(dp[i - 1] + (S[i - 1] != T[i - 1]), (seg.query(i - K, i - 1).v + 3 + sweep[i - 1]) / 2);
    seg.update(i, dp[i] * 2 - sweep[i]);
  }
  cout << dp.back() << endl;
}

Measured memory_bytes: 12144
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
int main(){
 cin.tie(nullptr);
 ios::sync_with_stdio(false);
 ll n,m,b,x,y,ans;
 cin>>n>>m;
 vector<ll> vec(n);
 vector<int> a(n,1);
 ans=0;
 fr(i,n){
     cin>>b;
     vec[i] = b;
 }
 fr(i,m){
     cin>>x>>y;
     if(vec[x-1] > vec[y-1]){
         a[y-1] = 0;
     }
     else if(vec[x-1] < vec[y-1]){
         a[x-1] = 0;
     }
     else{
         a[x-1] = 0;
         a[y-1] = 0;
     }
 }
 fr(i,n){
     if(a[i]){
         ++ans;
     }
 }
 cout<<ans;
}

Measured memory_bytes: 4448
#include <iostream>
          using namespace std;
          main(){
            string s;
            cin >> s;
            if (s[0]==s[1]&&s[1]==s[2]) cout << "Yes" << endl;
            else if (s[3]==s[2]&&s[1]==s[2]) cout << "Yes" << endl;
            else cout << "No" << endl;
          }

Measured memory_bytes: 256
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
#import math
#import time
#import random  # randome is not available at Codeforces
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
#eps=10**(-10)
#ts=time.time()
#sys.setrecursionlimit(10**6)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
show_flg=True

a,b=MI()
print(max(0,a-2*b))


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

int main() {
    int A, B;
    cin >> A >> B;
    string S;
    cin >> S;
    bool post=true;
    for (int i=0; i<A; i++){
        if (!('0' <= S.at(i) && S.at(i) <= '9')){
            cout << "No" << endl;;
            return 0;
        }
    }
    if (S.at(A)!='-'){
        cout << "No" << endl;
        return 0;
    }
    for (int i=A+1; i<S.length(); i++){
        if (!('0' <= S.at(i) && S.at(i) <= '9')){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256