akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#pragma warning(disable : 4996)

typedef long long ll;
#define all(x) (x).begin(), (x).end()  // sortなどの引数を省略
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define max3(x, y, z) max(x, max(y, z))
#define min3(x, y, z) min(x, min(y, z))

#ifdef _MSC_FULL_VER  //デバッグ出力
#define dout cout
#define debug() if (true)
#define check(x) std::cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) std::cout << "☆" << x << endl
#else
#define dout \
  if (false) cout
#define debug() if (false)
#define check(x) \
  if (false) cout << "★" << #x << "の値:" << (x) << endl
#define pass(x) \
  if (false) cout << "☆" << x << endl
#endif

using namespace std;
//#define int long long;

double dist(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
ll idist(ll x1, ll y1, ll x2, ll y2) {
  return (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}

signed main() {
  string s;
  cin >> s;
  if (s[0] == s[1] and s[1] == s[2] and s[0] == 'R') {
    cout << 3;
  } else if ((s[0] == s[1] or s[1] == s[2] )and s[1]=='R') {
    cout << 2;
  } else if(s[0] == 'R' or s[1] == 'R' or s[2] == 'R'){
    cout << 1;
  } else {
    cout << 0;
  }
}


Measured memory_bytes: 3612
#include<stdio.h>
#define MAX 100005
#define NIL -1
struct Node_struct { int p, l, r; }; /*p: 親(parent), l: 一番左の子(left child), r:右の兄弟(right sibling)*/
typedef struct Node_struct Node;
Node T[MAX];
int D[MAX];

void print(int u) {
  int i, c;
  printf("node %d: parent = %d, depth = %d, ", u, T[u].p, D[u]);

  if (T[u].p==NIL) printf("root, ");
  else if (T[u].l==NIL)printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for (i = 0, c = T[u].l; c != NIL; i++, c = T[c].r) {
    if (i) printf(", ");
    printf("%d", c);
  }
  printf("]\n");

}

void calcDepth(int u, int p) {
  D[u] = p;
  if (T[u].l!=NIL) calcDepth(T[u].l, p+1);
  if (T[u].r!=NIL) calcDepth(T[u].r, p);
}

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

  for (i = 0; i<n; i++) {
    scanf("%d %d", &id, &k);
    for (j = 0, sib = NIL; j<k; j++) { //子を入力する (input children)
      scanf("%d", &child);
      T[child].p = id;
      if (j == 0) T[id].l = child; //idの一番左の子 (the most left child of id)
      else T[sib].r = child; //左の兄弟に繋げる (connect to left sibling)
      sib = child;//次の子供の左の兄弟 (the left sibling of the next child)
    }
  }

  //根を求める (find the root)
  for (i = 0; i<n; i++) {
    if (T[i].p == -1) root = i;
  }

  //それぞれのノードの深さを求める (find depth of each node)
  calcDepth(root, 0);

  //出力 (output)
  for (i = 0; i<n; i++) print(i);

  return 0;
}



Measured memory_bytes: 3304
d,g = map(int,input().split())
pc = [[int(i) for i in input().split()] for j in range(d)]

num = 2**d

score = 0
ans = 0

use = [0,1]

def nokori(use,score):
    tmp = 0
    for i in range(d):
        #print(use, d-1-i, d-1-i not in use)
        if d-1-i not in use:
            if pc[d-1-i][0] * (d-1-i+1) * 100 >= score:
                tmp += (score +(d-1-i+1) * 100 - 1) // ( (d-1-i+1) * 100 )
                return tmp
            elif pc[d-1-i][0] * (d-1-i+1) * 100 + pc[d-1-i][1] >= score:
                tmp += pc[d-1-i][0]
                return tmp
            else:
                tmp += pc[d-1-i][0]
                score -= pc[d-1-i][0] * (d-1-i+1) * 100 + pc[d-1-i][1]
kouho = []

kouho.append(nokori([-1],g))
#exit()

for i in range(num):
    use = []
    ans = 0
    score = 0
    cur = i
    #print(i)
    for j in range(d):
        if cur == 0:
            continue
        elif cur% 2 == 1:
            #print(i % 2,j)
            score += pc[j][0] * (j+1) * 100 + pc[j][1]
            ans += pc[j][0]
            use.append(j)
            #print(use,j,cur)
        #else:
            #cur -= 1
            #continue
        cur = cur // 2
    #print(use,i)
    if score >= g:
        kouho.append(ans)
    else:
        #print(use)
        #print(ans,score)
        kouho.append(ans+nokori(use,g-score))
        #print(ans+nokori(use,d-score))

#print(kouho)
kouho.sort()
print(kouho[0])


Measured memory_bytes: 3064
def solve(string):
    h, w, d, *a = map(int, string.split())
    n = h * w
    a, q, lr = a[:n], a[n], a[n + 1:]
    index = [0 for _ in range(n)]
    for i, _a in enumerate(a):
        index[_a - 1] = i
    diff = [0] * d + [
        abs(i0 // w - i1 // w) + abs(i0 % w - i1 % w) for i0, i1 in zip(index, index[d:])
    ]
    for i in range(n):
        if i >= d:
            diff[i] += diff[i - d]
    return "\n".join([str(diff[r - 1] - diff[l - 1]) for l, r in zip(lr[::2], lr[1::2])])


if __name__ == '__main__':
    n, m, d = map(int, input().split())
    ins = '{} {} {}\n'.format(n, m, d) + '\n'.join([input() for _ in range(n)])
    n = int(input())
    print(solve(ins + '\n{}\n'.format(n) + '\n'.join([input() for _ in range(n)])))


Measured memory_bytes: 36920
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,A,B;
int main(){
	n=read(),A=read(),B=read();
	printf((B-A)&1?"Borys\n":"Alice\n");
	return 0;
}



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

using namespace std;

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

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


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

	cin >> N >> K;
	vector<int>v(K);
	for (auto &i : v)cin >> i;
	v.push_back(v.front() + N);
	long long int ans = N;
	for (int i = 1; i <= K; i++) {
		ans = min(ans, N - (v[i] - v[i - 1]));
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#貰うDP, 集めるDP.
#配るDPはiからi+1/i+2を更新
n=int(input())
h=[int(x) for x in input().split()]
dp=[0]
f_inf=float('inf')
dp.extend([f_inf]*n)
#初期値: print(dp)
for i in range(1, n):
  #chmin
  dp[i]=min(dp[i], dp[i-1]+abs(h[i]-h[i-1]))
  if i>1:
    dp[i]=min(dp[i], dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])
#各足場までの最小コスト列: print(dp)

Measured memory_bytes: 85980
#include <bits/stdc++.h> 
using namespace std;  
long INF=1000000000000000;
int main() {
    vector<long> A(3);
    for(int i=0;i<3;i++) cin>>A.at(i);
    long K;
    cin>>K;
    
    sort(A.begin(),A.end());
    
    for(int i=0;i<K;i++) A.at(A.size()-1)*=2;
    
    long ans=0;
    for(int i=0;i<3;i++)ans+=A.at(i);
    
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000000

int main(){
	
	int N;
	
	cin>>N;
	vector<string> S;
	vector<int> C;
	S.resize(N);
	C.resize(N);
	
	for(int i=0;i<N;i++)cin>>S[i]>>C[i];
	
	vector E(N,vector(21,vector(2,vector (0,vector<long long>()))));
	
	for(int i=0;i<N;i++){
		for(int j=1;j<=20;j++){
			for(int k=0;k<2;k++){
				if(S[i].size()<j)break;
				string s,t;
				for(int l=0;l<N;l++){
					string s,t;
					int sid,tid;
					if(k==0){
						s = S[i].substr(S[i].size()-j);
						t = S[l];
						sid = i;
						tid = l;
					}
					else{
						s = S[l];
						t = S[i].substr(0,j);
						sid = l;
						tid = i;
					}
					
					while(s.size()>0&&t.size()>0&&s[0]==t.back()){
						s.erase(s.begin());
						t.pop_back();
					}
					
					
					
					
					
					if(s.size()>0&&t.size()>0)continue;
					string x = max(s,t);
					reverse(x.begin(),x.end());
					if(x==s||x==t){
						E[0][0][0].push_back({i,j,k,C[l]});
					}
					else if(s.size()>0){
						E[sid][s.size()][0].push_back({i,j,k,C[l]});
					}
					else{
						E[tid][t.size()][1].push_back({i,j,k,C[l]});
					}
					
				}
			}
		}
	}

	vector<vector<vector<long long>>> dis(N,vector(21,vector<long long>(2,Inf)));
	dis[0][0][0]=0;
	priority_queue<vector<long long>,vector<vector<long long>>,greater<vector<long long>>> Q;
	Q.push({0,0,0,0});
	
	while(Q.size()!=0){
		long long d = Q.top()[0];
		int a = Q.top()[1],b = Q.top()[2],c = Q.top()[3];
		Q.pop();
		if(d!=dis[a][b][c])continue;
		for(int i=0;i<E[a][b][c].size();i++){
			int e = E[a][b][c][i][0],f = E[a][b][c][i][1],g = E[a][b][c][i][2];
			long long D = E[a][b][c][i][3];
			
			if(D+d<dis[e][f][g]){
				dis[e][f][g]=D+d;
				Q.push({D+d,e,f,g});
			}
			
		}
	}
	
	long long ans = Inf;
	
	for(int i=0;i<N;i++){
		string T(S[i].rbegin(),S[i].rend());
		if(S[i]==T)ans = min(ans,(long long)C[i]);
		ans = min(ans,C[i]+dis[i][S[i].size()][0]);
	}
	
	if(ans==Inf)cout<<-1<<endl;
	else cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 4080
#include <stdio.h>
int main(){
  int n;
  scanf("%d", &n);
  int i;
  double ans = 0;
  for(i=0;i<n;i++){
    double x;
    char u[4];
    scanf("%lf%s",&x,u);
    if(u[0] == 'J'){
      ans += x;
    }else{
      ans += x * 380000.0;
    }
  }
  printf("%lf\n", ans);
  return 0;
}


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

using namespace std;

const int N_MAX = 100002;

struct Element
{
    int val;
    int index;
    int indexSorted;
};

bool operator < (const Element &a, const Element &b)
{
    return a.val < b.val;
}

int n;

Element v[N_MAX];

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> v[i].val;
        v[i].index = i;
    }
    sort(v + 1, v + n + 1);
    for(int i = 1; i <= n; i++)
        v[i].indexSorted = i;
    int ans = 0;
    for(int i = 1; i <= n; i++)
        ans += (abs(v[i].index - v[i].indexSorted) & 1);
    cout << (ans >> 1) << "\n";
    return 0;
}


Measured memory_bytes: 1408
#import re
import sys
input = sys.stdin.readline
#import heapq
#import bisect
#from collections import deque
#import math

def main():
    n, m = map(int, input().split())
    ans = 0
    if n == 3:
        A = [10] * 3
        for i in range(m):
            s, c = map(int, input().split())
            s -= 1
            if A[s] == 10:
                A[s] = c
            elif A[s] != c:
                ans = -1
                break
        if A[0] == 0:
            ans = -1
        if A[0] == 10:
            A[0] = 1
        if A[1] == 10:
            A[1] = 0
        if A[2] == 10:
            A[2] = 0
        if ans == -1: print(-1)
        else: print(str(A[0]) + str(A[1]) + str(A[2]))
    
    if n == 2:
        A = [10] * 2
        for i in range(m):
            s, c = map(int, input().split())
            s -= 1
            if A[s] == 10:
                A[s] = c
            elif A[s] != c:
                ans = -1
                break
        if A[0] == 0:
            ans = -1
        if A[0] == 10:
            A[0] = 1
        if A[1] == 10:
            A[1] = 0
        if ans == -1: print(-1)
        else: print(str(A[0]) + str(A[1]))
    
    if n == 1:
        A = 10
        for i in range(m):
            s, c = map(int, input().split())
            if A == 10:
                A = c
            elif A != c:
                ans = -1
                break
        if A == 10:
            A = 0
        if ans == -1: print(-1)
        else: print(str(A))
        
        


    
if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
def fill(ans, l, r, level):
    if r - l <= 1:
        return
    m = (l + r) // 2
    for i in range(l, m):
        for j in range(m, r):
            ans[i][j] = level
    fill(ans, l, m, level + 1)
    fill(ans, m, r, level + 1)


n = int(input())
ans = [[0] * n for _ in range(n)]
fill(ans, 0, n, 1)
for i, row in enumerate(ans[:-1]):
    print(*row[i + 1:])


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

#define MAX 50
#define INF 1000000

int h, w;
char maze[MAX][MAX];
int reached[MAX][MAX];
int cnt;
queue<pair<int, int>> que;

void init()
{
    for (int i = 0; i < MAX; i++)
    {
        for (int j = 0; j < MAX; j++)
        {
            reached[i][j] = -1;
        }
    }

    cin >> h >> w;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> maze[i][j];
        }
    }
    que.push(make_pair(0, 0));
    reached[0][0] = 1;
}

int main()
{
    int cnt = 0;
    init();

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

    while (!que.empty())
    {
        int x = que.front().first;
        int y = que.front().second;
        que.pop();

        for (int i = 0; i < 4; i++)
        {
            int nx = x + dx[i];
            int ny = y + dy[i];

            if (ny < 0 || ny >= h || nx < 0 || nx >= w)
                continue;

            if (reached[ny][nx] == -1 && maze[ny][nx] == '.')
            {
                que.push(make_pair(nx, ny));
                reached[ny][nx] = reached[y][x] + 1;
            }
        }
    }

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (maze[i][j] == '#')
                cnt++;
        }
    }
    if (reached[h - 1][w - 1] == -1)
        cout << -1 << endl;
    else
        cout << h * w - reached[h - 1][w - 1] - cnt << endl;
}


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

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

int lcm(int a, int b){
    return a/gcd(a,b)*b;
}

//ABC131
signed main(void){
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);

    int a,b,c,d; cin>>a>>b>>c>>d; a--;
    int cc=b/c-a/c;
    int dd=b/d-a/d;
    int l=lcm(c,d);
    int ll=b/l-a/l;
    cout<<b-a-(cc+dd-ll)<<endl;

}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i <= (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
   int n;
   cin >> n;
   map<ll,ll> mp;
   vector<int> ball(n);
   rep(i,n){
      int a;
      cin >> a;
      ball[i] = a;
      mp[a]++;
   }
   ll ans = 0;
   rep(i,n){
      ans += mp[i+1]*(mp[i+1]-1)/2;
   }
   rep(i,n){
      dunk(ans - mp[ball[i]] + 1);
   }
   return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
        using namespace std;
        #define int long long
const int MAX = 510000;
const int MOD = 1000000007;

     signed main(){
             cout << std::setprecision(15) ;
         int n;
         cin>>n;
         int a[n],b[n+1]={};
         map<int,int> mp;
         for(int i=0;i<n;i++){cin>>a[i];b[a[i]]++;}
         int ans=0;
         for(int i=0;i<=n;i++)ans+=b[i]*(b[i]-1)/2;
        for(int i=0;i<n;i++){
                cout<<ans-(b[a[i]]-1)<<endl;
        }

         
}

        


Measured memory_bytes: 5760
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	static class TaskSolver {
		int n;
		long x;
		long ans;
		long[] P;
		long[] BP;
		
		public void go(int pos, long rem) {
			if(rem < 1) return ;
			if(rem >= BP[pos]) {
				ans += P[pos];
				return ;
			}
			long mid = BP[pos] / 2 + 1;
			if(rem == mid) {
				ans += P[pos - 1] + 1;
			} else if(rem < mid) {
				go(pos - 1, rem - 1);
			} else {
				ans += P[pos - 1] + 1;
				go(pos - 1, rem - mid);
			}
		}
		
		public void solve(MyScanner in, MyWriter out) throws IOException {
			n = in.nextInt();
			x = in.nextLong();
			P = new long[n + 5];
			BP = new long[n + 5];
			P[0] = 1; BP[0] = 1;
			for(int i = 1; i <= n; i++) {
				P[i] = P[i - 1] * 2 + 1;
				BP[i] = 1 + BP[i - 1] + 1 + BP[i - 1] + 1;
			}
			ans = 0;
			go(n, x);
			out.println(ans);
		}
	}

	public static void main(String[] arg) {
		try {
			MyScanner in = new MyScanner();
			MyWriter out = new MyWriter();
			TaskSolver Solver = new TaskSolver();
			Solver.solve(in, out);
			out.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	static class MyWriter extends PrintWriter {
		MyWriter() throws FileNotFoundException {
			super(System.out);
		}

		void printArrayInOneLine(int[] a) {
			print('[');
			for (int i = 0; i < a.length; i++) {
				print(a[i] + " ");
			}
			println(']');
		}
	}

	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (Exception e) {
					return null;
				}
			}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public String nextLine() {
			try {
				return br.readLine();
			} catch (Exception e) {
				e.printStackTrace();
			}
			return null;
		}
	}
}

Measured memory_bytes: 23508
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void){
    int n,ans=0;
    scanf("%d",&n);
    int a;
    for (int i=0; i<n; i++){
        scanf("%d",&a);
        ans+=a-1;
    }
    printf("%d\n",ans);
	return 0 ;
}

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

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

  int B[N+1];
  for(int i=1;i<N;i++){
    cin>>B[i];
  }
  B[0]=1000000;
  B[N]=1000000;

  int ans=0;
  for(int i=0;i<N;i++){
    ans+=min(B[i+1],B[i]);
  }

  cout<<ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }

int main(){
    ll A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    ll res = 1e18;
    REP(ab, 1e5+1) {
        ll abn = ab * 2 * C;
        ll an = 0;
        if (X-ab > 0) an = (X-ab) * A;
        ll bn = 0;
        if (Y-ab > 0) bn = (Y-ab) * B;
        chmin(res, abn + an + bn);
    }

    cout << res << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
#define skip continue
#define NAME "code"
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
void faster(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
 
const int MAXN = 1e5 + 1;
const int INF = 1e9 + 2;
const ld pi = acos(-1);

ll x, y, x2, y2;
string s;

int main() {

    faster();

    cin >> s;

    for(int i = 0; i < s.size(); ++i){
        if(s[i] == 'N') x = 1;
        if(s[i] == 'S') x2 = 1;
        if(s[i] == 'W') y = 1;
        if(s[i] == 'E') y2 = 1; 
    }

    if(x == x2 && y == y2){
        cout << "Yes";
    }
    else{
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>

using namespace std;

typedef long long ll;

#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())

vector<pair<int, ll>> par;

int root(int x) {
	if (par[x].first == x)return x;
	return par[x].first = root(par[x].first);
}

ll size(int x) {
	if (par[x].first == x)return par[x].second;
	return size(par[x].first);
}

void unite(int x, int y) {
	int rx = root(x);
	int ry = root(y);
	if (rx == ry)return;
	if (par[rx].second < par[ry].second) {
		par[rx].first = ry;
		par[ry].second += par[rx].second;
	}
	else {
		par[ry].first = rx;
		par[rx].second += par[ry].second;
	}
}

bool same(int x, int y) {
	int rx = root(x);
	int ry = root(y);
	return rx == ry;
}

int main() {

	ll n;
	int m;
	cin >> n >> m;
	FOR(i, n) {
		par.push_back(make_pair(i, 1));
	}
	vector<int> a(m), b(m);
	vector<ll> ans(m);
	FOR(i, m) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
	}

	ans[m - 1] = n * (n - 1) / 2;
	for (int i = m - 1; i > 0; i--) {
		if (same(a[i], b[i]))ans[i - 1] = ans[i];
		else {
			ll x = size(a[i]), y = size(b[i]);
			ans[i - 1] = ans[i] - x * y;
			unite(a[i], b[i]);
		}
	}

	FOR(i, m)cout << ans[i] << endl;

	return 0;
}


Measured memory_bytes: 4464
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#define INF 1000000009;
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}
string names;

string karuta[100100];
int nn[400];
vector<pair<int, int>> workk;
long long summ;
int main() {
	string manji;
	int counto=0;
	
	cin >> manji;
	for (int i = 0; i < manji.size(); i++) {
		if (i % 2 == 0) {
			if (manji[i] == '0') {
				counto++;
		}
		}
		else {
			if (manji[i] == '1') {
				counto++;
			}
		}
	}
	if (counto <= manji.size()/2) {
		cout << counto << endl;
		return 0;
	}
	else {
		cout << manji.size()-counto << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define rvc(i,S) for(int i=0;i<(int)S.size();++i)
#define fore(i,x) for(int i = head[x] ; i ; i = e[i].next)
#define mp make_pair
#define pb push_back
#define int long long
#define PII pair<int,int>
#define maxn 1000005
#define ll long long 
#define fi first
#define int ll
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std; 
int n,m;
signed main()
{cin>>n>>m;
 if((n+1)/2>=m) puts("YES");
 else           puts("NO");
	
	
 } 

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

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N, A, B;
  cin >> N >> A >> B;
  string S;
  cin >> S;
  int sum = 0;
  int foreigner = 0;
  for (int i = 0; i < N; i++)
  {
    if (S[i] == 'a')
    {
      if (sum < A + B)
      {
        cout << "Yes" << endl;
        sum++;
      }
      else
        cout << "No" << endl;
    }
    else if (S[i] == 'b')
    {
      if (sum < A + B && foreigner < B)
      {
        cout << "Yes" << endl;
        sum++;
        foreigner++;
      }
      else
        cout << "No" << endl;
    }
    else
      cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 848
from time import time
start=time()
from copy import deepcopy
from random import randint

d=int(input())
c=list(map(int,input().split())) #scoreを減らす
s=[] #scoreを増やす
for i in range(d):
    t=list(map(int,input().split()))
    s.append(t)
last=[0]*26 #それぞれのコンテストが最後に行われたのは何日目か
ans_lst=[]

for i in range(1,d): #364日、1日目ならi=1
    temp_best=-100000000
    for j in range(26): #それぞれの日において、26個のコンテストを順番にピックアップ
        temp=s[i-1][j]
        for k in range(26): #ピックアップされていないコンテストは、スコアを減らす
            if j!=k:
                temp-=(c[k]*(i-last[k]))
        temp_last=deepcopy(last)
        temp_last[j]=i
        for k in range(26):
            temp+=s[i][k]
            for l in range(26):
                if k!=l:
                    temp-=(c[l]*(i+1-temp_last[l]))
        if temp>temp_best:
            temp_best=temp
            rem=j
    ans_lst.append(rem)
    last[rem]=i
    
temp_best=-100000000 #365日目は、次の日のことは考えなくてよい
for j in range(26): #26個のコンテストを順番にピックアップ
    temp=s[i-1][j]
    for k in range(26): #ピックアップされていないコンテストは、スコアを減らす
        if j!=k:
            temp-=(c[k]*(i-last[k]))
    if temp>temp_best:
        temp_best=temp
        rem=j
ans_lst.append(rem) #AtCoder運営お疲れ様です

score=0
las=[0]*26
for i in range(d):
    for j in range(26):
        las[j]+=1
    score+=s[i][ans_lst[i]]
    las[ans_lst[i]]=0
    for j in range(26):
        score-=c[j]*las[j]

for q in range(1,15):
    for p in range(d-q):
        las=[0]*26
        temp_score=0
        temp_ans_lst=deepcopy(ans_lst)
        temp_ans_lst[p],temp_ans_lst[p+q]=temp_ans_lst[p+q],temp_ans_lst[p]
        for i in range(d):
            for j in range(26):
                las[j]+=1
            temp_score+=s[i][temp_ans_lst[i]]
            las[temp_ans_lst[i]]=0
            for j in range(26):
                temp_score-=c[j]*las[j]
        if temp_score>score:
            score=temp_score
            ans_lst=temp_ans_lst

while time()-start<1.9:
    las=[0]*26
    temp_score=0
    temp_ans_lst=deepcopy(ans_lst)
    a=randint(0,d-2)
    b=randint(0,d-2)
    temp_ans_lst[a],temp_ans_lst[a+1]=temp_ans_lst[a+1],temp_ans_lst[a]
    temp_ans_lst[b],temp_ans_lst[b+1]=temp_ans_lst[b+1],temp_ans_lst[b]
    for i in range(d):
        for j in range(26):
            las[j]+=1
        temp_score+=s[i][temp_ans_lst[i]]
        las[temp_ans_lst[i]]=0
        for j in range(26):
            temp_score-=c[j]*las[j]
    if temp_score>score:
        score=temp_score
        ans_lst=temp_ans_lst

for i in ans_lst:
    print(i+1)

Measured memory_bytes: 89812
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int solve(const vector<int>& h) {
  if (h.empty()) return 0;
  int mh = *min_element(h.begin(), h.end());
  vector<int> sub;
  int res = mh;
  for (int x : h) {
    int y = x - mh;
    if (y == 0) {
      res += solve(sub);
      sub.clear();
    } else {
      sub.push_back(y);
    }
  }
  res += solve(sub);
  return res;
}

int main() {
  int N;
  while (cin >> N) {
    vector<int> h(N);
    for (int i = 0; i < N; i++) cin >> h[i];
    cout << solve(h) << endl;
  }
  return 0;
}


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

if l[0] <= 0:
    x = 1
    ans1 = 1-l[0]
else:
    x = l[0]
    ans1 = 0
def check(l,x):
    ans=0
    for i in range(1,n):
        if x < 0:
            if x + l[i] <= 0:
                ans += 1-(x+l[i])
                x = 1
            else:
                x = x + l[i]
        else:
            if x + l[i] >= 0:
                ans += x + l[i] + 1
                x = -1
            else:
                x = x + l[i]
    return ans
ans1 += check(l,x)
if l[0] >= 0:
    x = -1
    ans2 = l[0]+1
else:
    ans2 = 0
    x = l[0]
ans2 += check(l,x)
print(min(ans1,ans2))


Measured memory_bytes: 14504
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ll long long
#define pi pair<int,int>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define ld long double
#define pld pair<ld,ld>
#define lg length()
#define sz size()
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pi>
#define vpl vector<pl>
#define pb push_back
#define INF 1000000005
#define LINF 1000000000000000005
using namespace std;
const int maxn = 2999 + 100;
double dp[maxn];
int32_t main()
{
	ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#ifdef LOCAL_DEFINE
	ifstream cin("input.txt");
#endif
	int N;
	cin >> N;
	double p;
	cin >> p;
	dp[1] = p;
	dp[0] = 1 - p;
	for (int i = 2; i <= N; i++)
	{
		cin >> p;
		for (int j = i; j >= 0; j--)
			dp[j] = (j > 0 ? dp[j - 1] * p : 0) + dp[j] * (1 - p);
	}
	double ans = 0;
	for (int i = N; i > N - i; i--)
		ans += dp[i];
	cout << setprecision(12) <<ans << '\n';
}


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

int main(){
  ll N;
  cin >> N;
  
  ll num = pow(N, 0.5);
  while (N % num != 0){
    num--;
  }
  
  ll ans = num + N / num -2;
  cout << ans << endl;
}

Measured memory_bytes: 4008
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int h,w;
    cin >> h >> w;
    char a[h][w];
    map<char,int> mp;
    rep(i,h){
        rep(j,w){
            cin >> a[i][j];
            mp[a[i][j]]++;
        }
    }
    bool fl = true;
    if(h%2==0&&w%2==0){
        rep(i,alpha.size()){
            if(mp[alpha[i]]%4!=0){
                fl = false;
                break;
            }
        }
        if(fl) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
    }
    int k,cnt,cnt1;
    if((h%2!=0 && w%2==0)||(w%2!=0 &&h%2==0)){
        if(h%2!=0) k=w;
        else k=h;
        k/=2;
        cnt = 0;
        rep(i,alpha.size()){
            if(mp[alpha[i]]%4==2) cnt++;
            if(mp[alpha[i]]%4==1 || mp[alpha[i]]%4==3){
                fl = false;
                break;
            }
        }
        if(fl&&cnt<=k) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
    }
    k=h+w-2;
    k/=2;
    cnt = 0;
    cnt1 = 0;
    rep(i,alpha.size()){
        if(mp[alpha[i]]%4==1) cnt1++;
        if(mp[alpha[i]]%4==2) cnt++;
        if(mp[alpha[i]]%4==3){
            cnt1++;
            cnt++;
        }
    }
    if(cnt<=k&&cnt1==1) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int ans=1000;
int main(){
  int N;
  cin>>N;
  for (int i=0;i<N;i++){
    int A,temp=0;
    cin>>A;
    while(A%2==0){
      temp++;
      A/=2;
    }
    ans=min(ans,temp);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3660
import sys
import numpy as np 
dist = 0
pairs_num = 0
dist_ary = []
i = 0
j = 1
n, d = map(int, input().split())
n_point = [input().split() for i in range(n)]
while i < n:
    while j < n:
        dist = 0
        for y,z in zip(n_point[i],n_point[j]):
            dist += (int(y)-int(z))**2
        dist_ary.append(dist)
        j+=1
    i+=1
    j = i+1
for i in range(len(dist_ary)):
    if np.sqrt(dist_ary[i]).is_integer():
        pairs_num +=1
print(pairs_num)

Measured memory_bytes: 12500
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include<unordered_map>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) vdeb(da[i]);
    std::cout << std::endl;
}

using namespace std;

const ll MOD = 1000000007;

ll modpow(ll a, ll b){//a^b
    ll ret = 1;
    while(b){
        if(b&1) ret = ret * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return ret;
}

int main(){
    ll n,k; cin >> n >> k;
    vector<ll> da(k+1, -1);
    da[k] = modpow(k, n);
    for(int i = k; i > 1;i--){
        if(da[k/i] == -1){
            da[k/i] = modpow(k/i, n);
            rip(j, k/i + 1, 2){
                da[k/i] = (da[k/i]-da[k/i/j]+MOD)%MOD;
            }
        }
        da[k] = da[k]-da[k/i]+MOD;
        da[k] %= MOD;
    }
    ll ans = 0;
 
    rip(i,k+1,1) ans += da[k/i] * i, ans %= MOD;
    // vdeb(da);
    cout << ans%MOD << endl;
    // cout << modpow(k, n) << endl;
}


Measured memory_bytes: 4052
#include <iostream>
#include <vector>
#include <algorithm>
#include <deque>
#include <tuple>
using namespace std;
typedef pair<int,int> P;
int V[100][100];//[v][i] leads to
int isDark[100];//-1???????????????.0~M-1??§??????
const int INF = 100000;
int D[16];
int N,M,K;

int dist[1<<16];
int move_to[1<<16][100];
bool isvisit[1<<16];

int main(){
    cin>>N>>M>>K;
    fill(isDark,isDark+100,-1);
    fill(dist,dist+(1<<16),INF);
    fill(isvisit,isvisit+(1<<16),false);
    for(int i=0;i<M;i++){
        cin>>D[i];
        D[i]--;
        isDark[D[i]]=i;
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<K;j++){
            cin>>V[i][j];
            V[i][j]--;
        }
    }
    for(int b=0;b<(1<<M);b++){
        for(int k=0;k<K;k++){
            move_to[b][k]=0;
            for(int m=0;m<M;m++){
                if(b&(1<<m)){
                    int to = V[D[m]][k];
                    if(isDark[to]!=-1){
                        move_to[b][k]|=1<<isDark[to];
                    }
                }
            }
        }
    }
    deque<P> que;
    dist[(1<<M)-1]=0;
    que.emplace_back(0,(1<<M)-1);
    while(!que.empty()){
        int d,v;
        tie(d,v)= que.front(); que.pop_front();
        if(!v){
            cout<<d<<endl;
            return 0;
        }
        if(isvisit[v]) continue;
        isvisit[v]=true;
        for(int k=0;k<K;k++){
            int to = move_to[v][k];
            if(dist[to]>d+1){
                que.emplace_back(d+1,to);
                dist[to]=d+1;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 29244
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    H = int(input())
    W = int(input())
    N = int(input())

    if H < W:
        print(ceil(N/W))
    else:
        print(ceil(N/H))

if __name__ == '__main__':
    main()


Measured memory_bytes: 5876
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-3223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

int H,W;
int A[2000][2000];
int M = 0;
int m = INT_MAX;

int MM[2000][2001],mm[2000][2001],MM2[2000][2001],mm2[2000][2001],dp[2000][2001][2][2];
int solve(int y, int x, int downway, int Mm){
	if(x == W+1 || x == -1) return INT_MAX;
	if(y == H) return 0;
	if(dp[y][x][downway][Mm] != -1) return dp[y][x][downway][Mm];
	int re = INT_MAX;
	if(downway == 0){
		/*for(int i=x; i<=W; i++){
			if(Mm == 0) re = min(re, max({M-mm[y][i], MM[y][i]-m, solve(y+1,i,downway, Mm)}) );
			else re = min(re, max({MM2[y][i]-m, M-mm2[y][i], solve(y+1,i,downway, Mm)}) );
		}*/
		if(Mm == 0) re = min( max({M-mm[y][x], MM[y][x]-m, solve(y+1,x,downway, Mm)}) , solve(y,x+1,downway,Mm) );
		else re = min( max({MM2[y][x]-m, M-mm2[y][x], solve(y+1,x,downway, Mm)}) , solve(y,x+1,downway,Mm) );
	}
	else{
		/*for(int i=x; i>=0; i--){
			if(Mm == 0) re = min(re, max({M-mm[y][i], MM[y][i]-m, solve(y+1,i,downway, Mm)}) );
			else re = min(re, max({MM2[y][i]-m, M-mm2[y][i], solve(y+1,i,downway, Mm)}) );
		}*/
		if(Mm == 0) re = min( max({M-mm[y][x], MM[y][x]-m, solve(y+1,x,downway, Mm)}) , solve(y,x-1,downway,Mm) );
		else re = min( max({MM2[y][x]-m, M-mm2[y][x], solve(y+1,x,downway, Mm)}) , solve(y,x-1,downway,Mm) );
	}
	
	return dp[y][x][downway][Mm] = re;
}

int main() {
	iostream::sync_with_stdio(false);

	cin >> H >> W;
	for(int i=0; i<H; i++){
		for(int j=0; j<=W; j++){
			dp[i][j][0][0] = -1;
			dp[i][j][0][1] = -1;
			dp[i][j][1][0] = -1;
			dp[i][j][1][1] = -1;
			if(i == H || j == W) continue;
			cin >> A[i][j];
			M = max(M, A[i][j]);
			m = min(m, A[i][j]);
		}
	}

	for(int i=0; i<H; i++){
		mm[i][0] = M;
		MM[i][W] = m;
		MM2[i][0] = m;
		mm2[i][W] = M;
	}
	for(int i=0; i<H; i++){
		for(int j=1; j<=W; j++){
			mm[i][j] = min(mm[i][j-1], A[i][j-1]);
			MM2[i][j] = max(MM2[i][j-1], A[i][j-1]);
		}
		for(int j=W-1; j>=0; j--){
			MM[i][j] = max(MM[i][j+1], A[i][j]);
			mm2[i][j] = min(mm2[i][j+1], A[i][j]);
		}
	}
	/*
	for(int i=0; i<H; i++){
		for(int j=0; j<=W; j++){
			cout << mm[i][j] << " ";
		}
		cout << endl;
	}
	for(int i=0; i<H; i++){
		for(int j=0; j<=W; j++){
			cout << MM[i][j] << " ";
		}
		cout << endl;
	}
	for(int i=0; i<H; i++){
		for(int j=0; j<=W; j++){
			cout << mm2[i][j] << " ";
		}
		cout << endl;
	}
	for(int i=0; i<H; i++){
		for(int j=0; j<=W; j++){
			cout << MM2[i][j] << " ";
		}
		cout << endl;
	}*/

	int ans = INT_MAX;
	ans = min(ans, solve(0, 0, 0, 0));
	ans = min(ans, solve(0, 0, 0, 1));
	ans = min(ans, solve(0, W, 1, 0));
	ans = min(ans, solve(0, W, 1, 1));
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 144272
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.util.Comparator;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class CID {
        public void solve(int testNumber, LightScanner in, PrintWriter out) {
            int n = in.ints();
            int m = in.ints();
            CID.City[] c = new CID.City[m];
            CID.City[] s = new CID.City[m];

            for (int i = 0; i < m; i++) {
                s[i] = c[i] = new CID.City(i, in.ints(), in.ints());
            }
            Arrays.sort(s, Comparator.comparing(q -> q.year));
            int[] b = new int[n + 1];
            for (CID.City q : s) {
                b[q.pref]++;
                q.app = b[q.pref];
            }
            for (CID.City q : c) {
                out.println(String.format("%06d", q.pref) + String.format("%06d", q.app));
            }
        }

        private static class City {
            int index;
            int year;
            int pref;
            int app = -1;

            public City(int index, int pref, int year) {
                this.index = index;
                this.year = year;
                this.pref = pref;
            }

        }

    }

    static class LightScanner {
        private BufferedReader reader = null;
        private StringTokenizer tokenizer = null;

        public LightScanner(InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        public String string() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new UncheckedIOException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int ints() {
            return Integer.parseInt(string());
        }

    }
}



Measured memory_bytes: 136952
#include "bits/stdc++.h"
using namespace std;
#define fst first
#define scd second
int main()
{
	int n, total = 0;
	scanf("%d", &n);
	vector<int> c(n), v(n);
	for(int i = 0; i < n; scanf("%d", &v[i++])){}
	for(int i = 0; i < n; ++i)
	{
		scanf("%d", &c[i]);
		v[i] -= c[i];
	}
	sort(v.begin(), v.end());
	for(int i = n - 1; i >= 0; --i)
	{
		if(total + v[i] > total)
		{
			total += v[i];
		}
		else
		{
			break;
		}
	}
	printf("%d\n", total);
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    p,q,r = LI()
    print(p+q+r-max(p,q,r))
    return

#B
def B():
    n = I()

    return

#C
def C():
    n = I()

    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    A()


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    int count = 0;
    while (true) {
        for (int i = 0; i < n; i++) {
            if (a.at(i) % 2 != 0) {
                cout << count << endl;
                exit(0);
            }
            a.at(i) /= 2;
        }
        count ++;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S = sc.next();
        int r_counter = 0;
        for (int i = 0; i < N; i++) {
            if (S.charAt(i) == 'R') {
                r_counter++;
            }
        }
        int res_counter = 0;
        for (int i = 0; i < r_counter; i++) {
            if (S.charAt(i) != 'R') {
                res_counter++;
            }
        }
        System.out.println(res_counter);
        sc.close();
    }
}

Measured memory_bytes: 40472
#include <bits/stdc++.h>
#define endl "\n"
#define sz(x) ((ll)(x).size())
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define prt(x) cout << (x)
#define prtl(x) cout << (x) << endl
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define rrep(i,a,b) for(ll i=a; i>b; i--)
#define mp(a, b) make_pair(a, b)
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vc = vector<char>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using vvc = vector<vector<char>>;
using ll = long long int;
using P = pair<long long int, long long int>;
using Map = map<long long int, long long int>;

vvll dp(1000, vll(1000, -1));

ll dfs(ll h, ll w, ll a, ll b, const vvc &m){
    if(dp[a][b] > -1){return dp[a][b];}
    if(a == h-1&&b == w-1){return dp[a][b] = 0;}
    ll p = 1000;
    if(a+1<h){
        ll x = dfs(h, w, a+1, b, m);
        if(m[a][b] != m[a+1][b]){x++;}
        p = min(p, x);
    }
    if(b+1<w){
        ll y = dfs(h, w, a, b+1, m);
        if(m[a][b] != m[a][b+1]){y++;}
        p = min(p, y);
    }
    return dp[a][b] = p;
}

int main(){
    ll H, W; cin >> H >> W;
    vvc map(H, vc(W));
    rep(i,0,H){
        rep(j,0,W){
            cin >> map[i][j];
        }
    }
    ll k = dfs(H, W, 0, 0, map);
    if(map[0][0] == '#'){
        prtl(k/2 + 1);
    }else{
        prtl((k+1)/2);
    }
}

Measured memory_bytes: 8064
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let t: f64 = read();
    let x: f64 = read();
    println!("{}", t / x);
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


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

int main(){
  int n;
  cin>>n;
  int points[n];
  for(int i=0;i<n;i++){
    bool base[3]={false,false,false};int outs=0;
    string action;int point=0;
    while(outs!=3){
      cin>>action;
      if(action=="HIT"){
        if(base[0]==false)base[0]=true;
        else if(base[1]==false)base[1]=true;
        else if(base[2]==false)base[2]=true;
        else point++;
      }
      else if(action=="HOMERUN"){
        int runner=0;
        for(int k=0;k<3;k++){
          if(base[k]==true)runner++;
        }
        for(int k=0;k<3;k++){
          base[k]=false;
        }
        point=point+runner+1;
      }
      else if(action=="OUT"){
        outs++;
      }
    }
    points[i]=point;
  }
  for(int i=0;i<n;i++){
    cout<<points[i]<<endl;
  }
}

Measured memory_bytes: 3136
#include<stdio.h>

 #define max(a,b) \
   ({ __typeof__ (a) _a = (a); \
       __typeof__ (b) _b = (b); \
     _a > _b ? _a : _b; })
 #define min(a,b) \
   ({ __typeof__ (a) _a = (a); \
       __typeof__ (b) _b = (b); \
     _a > _b ? _b : _a; })

#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;

int main()
{
    int n;
    scanf("%d", &n);
    int a[n];
    rep(i, n) scanf("%d", a+i+1);
    ll dp[n+1];
    dp[0] = 1000;
    for(int k=1; k<=n ; k++){
        dp[k] = 0;
        for(int i=0; i<k-1; i++){
            int m = 99999;
            for(int j=i+1; j<k; j++){
                m = min(m, a[j]);
            }
            dp[k] = max(dp[k], dp[i]/m*a[k]+dp[i]%m);
        }
    }
    ll ans = 0;
    rep(i, n+1) ans = max(ans, dp[i]);
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 1736