akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
int A[100];
using namespace std;
int main()
{
	int i,j,k,v,N;
	cin >> N; 
	for(i=0;i<N;i++)
		cin >> A[i];
	for(i=0;i<N;i++)
	{
		v=A[i];
		j=i-1;
		while(j>=0&&A[j]>v)
		{
			A[j+1] = A[j];
			j--;
		}
		A[j+1]=v;
		for(k=0;k<N;k++)
		{
			cout << A[k];
			if(k<N-1)
				cout <<" ";
		}
		cout << endl;
	}
	return 0;
}


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

int main() {
	int n;
	int num_ac = 0;
	int num_wa = 0;
	int num_tle = 0;
	int num_re = 0;
	string t;

	cin >> n;


	for(int i=0; i<n; i++) {
		
		cin >> t;

		if(t == "AC") {
			num_ac++;
		} else if(t == "WA") {
			num_wa++;
		} else if(t == "TLE") {
			num_tle++;
		} else if(t == "RE") {
			num_re++;
		}
	}

	cout << "AC x " << num_ac << endl;
	cout << "WA x " << num_wa << endl;
	cout << "TLE x " << num_tle << endl;
	cout << "RE x " << num_re;
}

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

int main(){
  int n;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  vi updown(n-1);
  if(a[0] == a[1]){
    rep(i,n-1){
      if(a[i] < a[i+1]){
        updown[0] = 1;
        break;
      }
      else if(a[i] > a[i+1]){
        updown[0] = -1;
        break;
      }
    }
    if(updown[0] == 0){
      cout << 1000 << endl;
      return 0;
    }
  }
  
  rep(i,n-1){
    if(a[i] > a[i+1]) updown[i] = -1;
    else if(a[i] < a[i+1]) updown[i] = 1;
    else {
      if(i != 0){
        updown[i] = updown[i-1];
      }
    }
  }
  vector<string> torihiki(n);
  if(updown[0] == 1) torihiki[0] = "buy";
  rep(i,n-2){
    if(updown[i] == 1){
      if(updown[i+1] == -1) torihiki[i+1] = "sell";
    }
    if(updown[i] == -1){
      if(updown[i+1] == 1) torihiki[i+1] = "buy";
    }
  }
  ll money = 1000;
  ll kabu = 0;
  rep(i,n-1){
    if(torihiki[i] == "buy"){
      kabu = money/a[i];
      money -= kabu*a[i];
    }
    if(torihiki[i] == "sell"){
      money += kabu*a[i];
      kabu = 0;
    }
  }
  if(kabu != 0){
    money += kabu*a[n-1];
  }
  cout << money << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<string> vs;

template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec){
    os << "[";
    for(int i = 0; i < vec.size(); i++){
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

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

long long mul(const long long& a, const long long& b, const long long& mod) {
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod) {
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod) {
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod) {
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod) {
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x) {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

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

    int x = 0;
    int maximum = x;
    repeat (i, S.size()) {
        switch (S[i]) {
            case 'I':
                ++x;
                break;
            case 'D':
                --x;
                break;
            default:
                break;
        }
        maximum = max(x, maximum);
    }
    cout << maximum << endl;
    return 0;
}


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

#define 	pi 				3.1415926536
#define 	mod 			1000000007
#define 	ll  			long long int
#define 	rep(i, a, b) 	for(int i = a ; i < b ; i++)
#define     repn(i, a, b)   for(int i = a ; i > b ; i--)
#define 	mod1 			1000003
#define     mod2            998244353
#define 	hi   			"hello"
#define 	nl 				"\n"
#define 	ws 				" "
#define     sz              size()
#define     len             length()
#define 	F 				first
#define 	S 				second
#define 	PB 				push_back
#define 	MP				make_pair
#define 	B 				begin()
#define     RB              rbegin()
#define 	E 				end()
#define     UB              upper_bound
#define     LB              lower_bound
#define     present(k, m)   (m.find(k)!=m.end())?1:0
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define 	vi 				vector<int>
#define     pii              pair<int, int>
#define     pll             pair<long long int, long long int>
#define     vll             vector<long long int>
#define 	vs 				vector<string>
#define     vc              vector<char>
#define 	print1(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		for(auto i : a)cout<<i;cout<<"\n"
#define 	boost 			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;


/*############################# DSU ##############################*/
vi parent(1e5), Size(1e5), Rank(1e5);

void make_set(int v){
    parent[v]=v;
    Size[v] = 1;
    // Rank[v] = 0;
}
 
int find_set(int v){
	return (parent[v]==v) ?  v : parent[v] = find_set(parent[v]);
}
 
void union_sets(int a, int b){
	a = find_set(a);
	b = find_set(b);
	if(a != b){
        if(Size[a] < Size[b])
            swap(a, b);
        // if(Rank[a] < Rank[b])
        //     swap(a, b);
		parent[b] = a;
        Size[a] += Size[b];
        // if(Rank[a] == Rank[b])
        //     Rank[a]++;
    }
}
/*############################# DSU ##############################*/


bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }

bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }

double logn(double n, double r) { return (n > r - 1) ? 1 + logn(n / r, r) : 0; }

ll pw2[32];
void cal(){ pw2[0] = 1; rep(i, 1, 32)pw2[i] = 2*pw2[i-1]; }

/* ################################################################ */

vector<vector<ll>> adj(2e5);
// vector<bool> visit;

void solve()
{
    ll n, m, a, b; cin>>n>>m;
    vll h(n+1, 0), mx(n+1, 0);
    rep(i, 1, n+1){
        cin>>h[i];
    }
    // visit.assign(n+1, false);
    rep(i, 0, m){
        cin>>a>>b;
        adj[a].PB(b);
        adj[b].PB(a);
    }
    rep(i, 1, n+1){
        for(auto j : adj[i]){
            mx[i] = max(mx[i], h[j]);
        }
    }
    ll ans = 0;
    rep(i, 1, n+1){
        if(h[i]>mx[i])ans++;
    }
    cout<<ans<<nl;

}


int main()
{
    // boost;
    cal();
    int t = 1, k = 1;
    // cin>>t;
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
}

Measured memory_bytes: 14084
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;

int main(){
    int n,x;cin>>n>>x;
    vector<int> l(n);
    REP(i, n){
        cin >> l[i];
    }

    int ans=n+1;
    int sum=0;
    REP(i, n){
        sum += l[i];
        if(sum>x){
            ans = i+1;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
  x, n = list(map(int, input().split()))
  if n == 0:
    print(x)
    exit()
  pp = list(map(int, input().split()))
  
  i = 0
  while True:
    if x-i not in pp:
      print(x-i)
      exit()
    if x+i not in pp:
      print(x+i)
      exit()
    i += 1
  
  
if __name__ == "__main__":
  main()


Measured memory_bytes: 61864
import sys, math
from collections import deque

def input():
    return sys.stdin.readline()[:-1]

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

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    A, B = i2(N)
    print(min(B)+max(A))
        

if __name__ == '__main__':
    main()


Measured memory_bytes: 36172
import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n=in.nextInt();
		int count=0;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				if (i*j<n) count++;
				else break;
			}
		}
		System.out.println(count);
	}
}

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

int main() {
    int n, m;
    cin >> n >> m;
    map<int, string> results = {};
    int a; string b;
    vector<int> isSolved(n);
    vector<int> wa_count(n);
    for (int i = 0; i < m; ++i) {
        cin >> a >> b;
        if (isSolved.at(a - 1) == 0 && b == "AC") {
            isSolved.at(a - 1) = 1;
        } else if (isSolved.at(a - 1) == 0 && b == "WA") {
            wa_count.at(a - 1)++;
        }
    }
    int ac = 0;
    int wa = 0;
    for (int j = 0; j < n; ++j) {
        if (isSolved.at(j) == 1) {
            wa += wa_count.at(j);
            ac++;
        }
    }
    
    cout << ac << " " <<  wa << endl;
}


Measured memory_bytes: 1024
from collections import deque

N = int(input())

A = []
while True:
    try:
        temp=list(map(int,input().split()))
        A.append(temp)
    except:
        break;
#print(A)
To = [[] for i in range(N)]
Cost = [[] for i in range(N)]
for i in range(len(A)):
  #print(A[i])
  To[A[i][0]-1].append(A[i][1]-1)
  To[A[i][1]-1].append(A[i][0]-1)
  Cost[A[i][0]-1].append(A[i][2])
  Cost[A[i][1]-1].append(A[i][2])
#print(To,Cost)

ans = [-1]*N #到達未到達を判定するために-1を初期値として与える。
ans[0] = 0  #0を根にして、0とパリティが一致する場合には0とする。
Queue = deque([])
Queue.append(0) #0を根にする

while Queue:
  v = Queue.popleft() #vは点
  for i in range(len(To[v])): #vから行けるリストつまりToの中にある点の数だけ回す。
    u = To[v][i] #vから行ける点
    w = Cost[v][i] #その点に行くためのコスト
    if ans[u] != -1: #すでに訪れていたらスキップ
      continue
    ans[u] = (ans[v]+w)%2
    Queue.append(u)
print(*ans, sep="\n")

Measured memory_bytes: 59632
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
using namespace std;

int main()
{
    int n;

    cin >> n;
    vector<pair<int, int>> red;
    vector<pair<int, int>> blue;
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        red.emplace_back(b, a);
    }
    for (int i = 0; i < n; i++) {
        int c, d;
        cin >> c >> d;
        blue.emplace_back(c, d);
    }

    sort(red.begin(), red.end(), greater<pair<int, int>>());
    sort(blue.begin(), blue.end());
    int ans = 0;

    for (auto bit = blue.begin(); bit != blue.end(); bit++) {
        auto it = red.begin();
        while (it != red.end()) {
            if (it->first < bit->second && it->second < bit->first) {
                ans++;
                red.erase(it);
                break;
            }
            it++;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 760
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int K = scanner.nextInt();
		String S = scanner.next();
		String str = S;
		String[] S1 = str.split("");
		
		String S2 = S1[K - 1].toLowerCase();
		
		for (int i = 0; i < K - 1; i++) {
			System.out.print(S1[i]);
		}
		
		System.out.print(S2);
		
		for (int j = K; j < N; j++) {
			System.out.print(S1[j]);
		}
	}
}

Measured memory_bytes: 21332
n, m = map(int, input().split())
lst = []
for _ in range(n):
    lst.append([0, 0])

for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == 'AC':
        lst[p-1][0] = 1
    elif lst[p-1][0] == 0:
        lst[p-1][1] += 1

correct = 0
wrong = 0
for i in range(n):
    correct += lst[i][0]
    if lst[i][0] == 1:
        wrong += lst[i][1]
print(correct, wrong)

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

using namespace std;

int main() {
    char steps[100];
    cin >> steps;
    
    
    bool easy = true;
    for (int i = 0; i < strlen(steps); i++)
    {
        if (i % 2 != 0)
        {
            if (steps[i] != 'L' && steps[i] != 'U' && steps[i] != 'D') {
                easy = false; 
                break;
            }
        } else {
            if (steps[i] != 'R' && steps[i] != 'U' && steps[i] != 'D') {
                easy = false;
                break;
            }
        }
    }
    
    if (easy) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}


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

int p, q, r;
string expr;
int i;

int calc(){
	switch( expr[i++] ){
		case '0':
			return 0;
		case '1':
			return 1;
		case '2':
			return 2;
		case '-':
			return 2 - calc();
		case 'P':
			return p;
		case 'Q':
			return q;
		case 'R':
			return r;
		case '(':
			int a = calc();
			
			if( expr[i++] == '+' ){
				a = max( a, calc() );
			}
			else{
				a = min( a, calc() );
			}
			++i;
			return a;
	}
	return 0;
}

int main(){
	for(; cin >> expr, expr[0] != '.'; ){
		int cnt = 0;
		for( p = 0; p <= 2; ++p ){
			for( q = 0; q <= 2; ++q ){
				for( r = 0; r <= 2; ++r ){
					i = 0;
					if( calc() == 2 ){
						++cnt;
					}
				}
			}
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 0
A, B, C, X, Y = map(int, input().split())

cost = 0

ab = min(X, Y)
cost += min(ab * 2 * C, (A + B) * ab)
X -= ab
Y -= ab

cost += min(C * 2, A) * X
cost += min(C * 2, B) * Y

print(cost)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(ll i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const int INF=2*1e9;
int main()
{
    ll n,a,b;
    cin>>n>>a>>b;
    cout<<n/(a+b)*a+min(a,n%(a+b));
}


Measured memory_bytes: 256
import numpy as np
H, W = map(int, input().split())
S = np.array([list(input()) for i in range(H)])=="."

R = np.zeros((H,W), dtype=int)
L = np.zeros((H,W), dtype=int)
U = np.zeros((H,W), dtype=int)
D = np.zeros((H,W), dtype=int)
for i in range(H):
  U[i]= (U[i-1]+1)*S[i]
  D[-i-1]= (D[-i]+1)*S[-1-i]
for i in range(W):
  L[:,i]= (L[:,i-1]+1)*S[:,i]
  R[:,-1-i]= (R[:,-i]+1)*S[:,-i-1]
print (np.max(L+R+U+D-3))

Measured memory_bytes: 219744
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n)  for (int i = 0; i < (int) (n); i++)
#define REP1(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
using ll = long long;

int main() {
  ll n;
  cin >> n;
  vector <int> cnt;
  for (ll i = 2; i * i <= n; i++) {
	  if (n % i != 0) {
		  continue;
		}
	  int c = 0;
	  while (n % i == 0) {
		  n /= i;
		  c++;
		}
	  cnt.push_back(c);
	}
  if (n != 1) {
	  cnt.push_back(1);
	}
  int ans = 0;
  REP(i, SZ(cnt)) {
	int e = 1;
	while (cnt[i] >= e) {
		cnt[i] -= e;
		e++;
		ans++;
	  }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3608
import math
n,m=map(int,input().split())
s=list(input())
t=list(input())
num=math.gcd(n,m)
ans=(n*m)//num
numn=n//num
numm=m//num
for i in range(num):
    if s[i*numn]!=t[i*numm]:
        ans=-1
        break
print(ans)


Measured memory_bytes: 10324
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        
        int x = stdIn.nextInt();
        int n = stdIn.nextInt();
        
        boolean flag[] = new boolean[501];
        
        for(int i = 0; i < 501; i++){
            flag[i] = true;
        }
        
        for(int i = 0; i < n; i++){
            flag[250 + stdIn.nextInt()] = false;
        }
        
        
        if(n != 0){
            if(flag[250 + x] != true){
                for(int i = 1; ; i++){
                    if(flag[250 + x - i] == true){
                        System.out.println(x - i);
                        break;
                    }
                    
                    if(flag[250 + x + i] == true){
                        System.out.println(x + i);
                        break;
                    }
                }
            }else{
                System.out.println(x);
            }
        }else{
            System.out.println(x);
        }
        
    }
}


Measured memory_bytes: 36032
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = ~(1<<31);
const int MOD = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);
 
const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main(){
	ll n;
	cin >> n;
	cout << (n*(n+1))/2-n << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a;
map<int,int> mp;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a;
		mp[a]++;
	}
	int cnt=0;
	for(__typeof(mp.begin()) it=mp.begin();it!=mp.end();it++){
		cnt+=it->second%2;
	}
	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<math.h>
using namespace std;

int main()
{
  // 入力                                                                                                              
  int X, A;
  cin >> X >> A;

  if (X < A)
    cout << (int)0 << endl;
  else
    cout << (int)10 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
char s[N];
int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	scanf("%s", s);
	int p = 0, f = 0;
	int fast1 = -1, fast2 = -1, fast3 = -1;
	bool flag = 0, debug = 0;
	for (int i = 0; i < k; ++ i) {
		bool c = (s[p] == 'A') ^ f;
		if (c) {
			s[p] = s[p] == 'A' ? 'B' : 'A';
		}
		else {
			f ^= 1;
			(++ p) %= n;
		}
		if (!debug) {
		if (fast1 == -1 && !c && i >= 5 * n) {
			fast1 = f;
			fast2 = i;
			fast3 = p;
		}
		else if (fast1 != -1 && !c && fast3 == p) {
			if (flag) continue;
			flag = 1;
			int change = f ^ fast1, need = i - fast2;
			while ((k - i) > need) {
				k -= need;
				f ^= change;
			}
		}
		}
	}
	for (int i = 0; i < n; ++ i) {
		bool c = (s[(i + p) % n] == 'A') ^ f;
		putchar(c ? 'A' : 'B');
	}
	puts("");
}



Measured memory_bytes: 640
n=int(input())
u=0
p=0
q=0
for _ in range(n):
  t,x,y=map(int,input().split())
  if abs(p-x)+abs(q-y)<=t-u and (t-u-abs(p-x)-abs(q-y))%2==0:
    u=t
    p=x
    q=y
  else:
    print('No')
    break
else:
  print('Yes')

Measured memory_bytes: 3188
#include<algorithm>
#include<cfloat>
using namespace std;

main(){
  double minv = FLT_MAX;
  double maxv = FLT_MIN;

  double x;
  while( cin >> x ){
    minv = min(minv, x );
    maxv = max(maxv, x );
  }

  printf("%.8lf\n", maxv - minv );
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#define INF 200001 
using namespace std;
  
int main(){
 int u,k,C,V,A[1000][1000],D[1000][1000],n;
  scanf("%d",&n);
   for(int i=0;i<n;i++)for(int j=0;j<n;j++)D[i][j] = INF;
   
  for(int i=0;i<n;i++){
      scanf("%d %d",&u,&k);    
      for(int j=0;j<k;j++){
    scanf("%d %d",&V,&C);
    D[u][V] = C;
      }    
  }
  for(int i=0;i<n;i++)D[i][i] = 0;
 
  for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++)D[i][j]= min(D[i][j],D[i][k] + D[k][j]);
 
  for(int i=0;i<n;i++)printf("%d %d\n",i,D[0][i]);
  
  return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
    int n;
    cin >> n;
    double sum = 0;
    rep(i,n){
        double a;
        cin >> a;
        sum += 1.0/a;
    }
    sP(1.0/sum);
}

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


Measured memory_bytes: 256
use std::io;

fn process_lines<T>(func: T, end: &str)
where
    T: Fn(&Vec<&str>),
{
    let mut line = String::new();
    let mut _num: u32 = 0;
    while let Ok(_) = io::stdin().read_line(&mut line) {
        _num += 1;
        {
            let data = line.trim();
            if data == end {
                break;
            }
            func(&data.split_whitespace().collect());
        }
        line.clear();
    }
}

fn cal(parms: &Vec<&str>) {
    let (a, op, b): (i32, &str, i32) = (
        parms[0].parse().unwrap(),
        parms[1],
        parms[2].parse().unwrap(),
    );
    match op {
        "+" => println!("{}", a + b),
        "-" => println!("{}", a - b),
        "*" => println!("{}", a * b),
        "/" => println!("{}", a / b),
        _ => std::process::exit(0),
    }
}

fn main() {
    process_lines(cal, "0 ? 0");
}



Measured memory_bytes: 5028
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(long long int i = 0; i < (n); i++)


int Len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}


int Sint(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int Svec(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}


int GCD(int a,int b){
  int r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return b;
}


int LCM(int a,int b){
  int c=a,d=b,r,tmp;
/*自然数 a > b を確認・入替*/
  if(a<b){
    tmp=a,a=b,b=tmp;
  }
/*ユークリッドの互除法*/
  r=a%b;
  while(r!=0){
    a=b,b=r,r=a%b;
  }
  return c/b*d;
}


int Factorial(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  string a,b;
  int k=0;//どこからがbの範囲か調べる
  bool flag=false;
  vector<string> v;
  cin>>a>>b;
  if(a.size()<b.size()){
    cout<<"UNRESTORABLE"<<endl;
    return 0;
    
    
    
  }else if(a.size()==b.size()){
    flag=true;
    rep(i,a.size()){
      if(a[i]==b[i] || a[i]=='?'){
      }else{
        flag=false;
      }
    }
    if(flag){
      cout<<b<<endl;
      return 0;
    }else{
      cout<<"UNRESTORABLE"<<endl;
      return 0;
    }
    
    
    
  }else if(a.size()>b.size()){
    flag=false;
    rep(i,a.size()-b.size()+1){
      bool can=true;
      for(int j=0;j<b.size();j++){
        if(a[i+j]==b[j] || a[i+j]=='?'){
          if(j==0){
            k=i;
          }
        }else{
          can=false;
        }
      }
      if(can){//出力処理
        flag=true;
        string d=a;
        int c=a.size();//値を変えるから保存
        string s;
        rep(i,c-b.size()+1){
          if(i==k){
            s+=b;
            d=d.erase(i,b.size()-1);
            k=-1;
          }else if(d[i]=='?'){
            s+='a';
          }else{
            s+=d[i];
          }
        }
        v.push_back(s);
      }
    }
  }
  
  
  
  if(flag){
    sort(v.begin(),v.end());
    cout<<v[0]<<endl;
  }else{
    cout<<"UNRESTORABLE"<<endl;
  }
  
  
  
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int long long
#define endl '\n'
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rep(i, l, r) for(int i=(int)(l);i<=(int)(r);i++)
#define repi(i, l, r) for(int i=(int)(l);i>=(int)(r);i--)
const int inf = 1e18;
 
using namespace std;
 
 
void solve() {
    int n;
    cin>>n;
    pair<int,int>p[n];
 
    rep(i,1,n){
        int x,y;
        cin>>x>>y;
        p[i].first = x;
        p[i].second = y;
    }
 
    int cnt = 0;
    bool flag = false;
    rep(i,1,n){
        if(p[i].first == p[i].second )
            cnt++;
        else
            cnt = 0;
        if(cnt >= 3){
            flag = true;
            break;
        }
    }
    if(flag)
        cout << "Yes\n";
    else
        cout << "No\n";
}
 
 
int32_t main() {
    fastIO
    int t = 1;
//    cin >> t;
    rep(i, 1, t) {
        solve();
    }
}

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

int main()
{

long long int i,n,arr[5]={0};

for(i=0;i<5;i++)
{
    cin>>arr[i];
    if(arr[i]==0)
    n=i;
}

cout<<(n+1);





return 0;
}

Measured memory_bytes: 3632
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    long x = nextLong();

    long money = 100;

    long cnt = 0;

    while(true){
      cnt++;
      money += money/100;

      if(money>=x){
        break;
      }


    }

    System.out.println(cnt);

  }

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

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

  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

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

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

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

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 35688
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for (ll i=0; i<(n); ++i)
#define rep1(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
const ll mod = 998244353;
const double e = 0.000000001;

int main(){
  ll a,b; cin >> a >> b;
  cout << a*b;
  return 0;
}

Measured memory_bytes: 3632
import sys


class Node:
    def __init__(self, x):
        self.x = x

    def set_prev(self, prev):
        self.prev = prev

    def set_next(self, next):
        self.next = next


class DoublelyLinkedList:
    def __init__(self):
        self.nil = Node(None)
        self.nil.set_next(self.nil)
        self.nil.set_prev(self.nil)

    def insert(self, x):
        new_elem = Node(x)
        new_elem.set_next(self.nil.next)
        new_elem.set_prev(self.nil)
        self.nil.next.set_prev(new_elem)
        self.nil.set_next(new_elem)

    def list_search(self, x):
        cur = self.nil.next
        while cur != self.nil and cur.x != x:
            cur = cur.next
        return cur

    def _delete(self, node):
        node.prev.set_next(node.next)
        node.next.set_prev(node.prev)

    def delete_first(self):
        self._delete(self.nil.next)

    def delete_last(self):
        self._delete(self.nil.prev)

    def delete(self, x):
        del_node = self.list_search(x)
        if del_node.x is not None:
            self._delete(del_node)


def main():
    d_linked_list = DoublelyLinkedList()
    for i in sys.stdin:
        if 'insert' in i:
            x = i[7:-1]
            d_linked_list.insert(x)
        elif 'deleteFirst' in i:
            d_linked_list.delete_first()
        elif 'deleteLast' in i:
            d_linked_list.delete_last()
        elif 'delete' in i:
            x = i[7:-1]
            d_linked_list.delete(x)
        else:
            pass

    results = []
    cur = d_linked_list.nil.next
    while cur.x is not None:
        results.append(cur.x)
        cur = cur.next

    print(*results)


if __name__ == "__main__":
    main()



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

int main() {
  int k;
  cin>>k;
  if(k<=3 || k==5 || k==7 || k==11 || k==13 || k==15 || k==17 ||k==19||k==23||k==29||k==31)
  cout<<1<<endl;
  else if(k==4||k==6||k==9||k==10||k==14||k==21||k==22||k==25||k==26)
  cout<<2<<endl;
  else if(k==8||k==12||k==18||k==20||k==27)
  cout<<5<<endl;
  else if(k==28||k==30)
  cout<<4<<endl;
  else if(k==16)
  cout<<14<<endl;
  else if(k==24)
  cout<<15<<endl;
  else cout<<51<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

int main(int argc, char* argv[])
{
    int W,H,x,y,r;
    scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);
    if(x-r<0 || x+r>W || y-r<0 || y+r>H) {
        printf("No\n");
    }
    else {
        printf("Yes\n");
    }

    return 0;
}



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

int main() {
  int N, M;
  
  cin >> N;
  vector<string> s(N);
  for (int i = 0; i < N; i++) cin >> s[i];
  
  cin >> M;
  vector<string> t(M);
  for (int i = 0; i < M; i++) cin >> t[i];
  
 int m = 0;
  for (int i = 0; i < N; i++) {
    int cnt_b = count(s.begin(), s.end(), s[i]);
    int cnt_r = count(t.begin(), t.end(), s[i]);
    int cnt = cnt_b - cnt_r;
    m = max(m, cnt);
  }
  cout << m << endl;
}

Measured memory_bytes: 3632
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M[] =new int[N];
    int L =M[0];
    int s =0;
    for(int i=0;i<N;i++){
      M[i]=sc.nextInt();
    L = Math.max(L,M[i]);
    if(L-1>M[i]){break;}
      s=s+1;}
    if(s==N){System.out.println("Yes");}
    else{System.out.println("No");
        }
  }
}

Measured memory_bytes: 50096
import sys
from collections import deque
import copy
import heapq
import math

from math import *

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [long(input_raw[0]), long(input_raw[1])]
    A_list = []
    B_list = [0]
    input_raw = read_func().strip().split()
    for i in range(N):
        [A] = [long(input_raw[i])]
        A_list.append(A)
        B_list.append(A + B_list[i])

    mod_dic = {}
    for i in range(N + 1):
        B_mod = B_list[i] % M
        if B_mod not in mod_dic:
            mod_dic[B_mod] = 1
        else:
            mod_dic[B_mod] += 1

    count = 0
    for B_mod in mod_dic:
        n = mod_dic[B_mod]
        count += n*(n-1)/2

    print count


if __name__ == '__main__':
    main()


Measured memory_bytes: 24560
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


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

		string a, b; cin >> a >> b;
		vector<int>v(101);
		for (int i = 0; i < a.size(); ++i) {
			v[101 - a.size() + i] = a[i] - '0';
		}
		for (int i = 0; i < b.size(); ++i) {
			v[101 - b.size() + i] += b[i] - '0';
		}
		for (int i = 100; i > 0; --i) {
			if (v[i] >= 10) {
				v[i - 1]++;
				v[i] -= 10;
			}
		}
		int num = 0;
		num = find_if(v.begin(), v.end(), [](const int a) {return a; })-v.begin();
		if (num <= 20)cout << "overflow" << endl;
		else {
			if (num == 101)cout << 0 << endl;
			else {

				for (int i = num; i < 101; ++i) {
					cout << v[i];
				}
				cout << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3156
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int n, total = 0;
    scanf("%d", &n);
    vector<int> a(n + 2);
    a[0] = 0;
    a[n + 1] = 0;
    for (int i = 1; i <= n; ++i)
    {
        scanf("%d", &a[i]);
        total += abs(a[i] - a[i - 1]);
    }
    total += abs(a[n + 1] - a[n]);
    for (int i = 1; i <= n; ++i)
    {
        printf("%d\n", total - abs(a[i] - a[i - 1]) - abs(a[i + 1] - a[i]) + abs(a[i + 1] - a[i - 1]));
    }
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1e9,MOD=1e9+7;

int v1[200010];
int v2[200010];

//初期化(n頂点バラバラ)
void init(int n){
	rep(i,n) v1[i]=v2[i]=i;
}

//頂点aが属するrootを求める
int root1(int a){
	if(v1[a]==a) return a; //aはroot
	return (v1[a]=root1(v1[a])); //aの親のroot
}
//頂点aとbを同一グループにまとめる
void unite1(int a,int b){
	v1[root1(a)]=root1(b);
}
//頂点aが属するrootを求める
int root2(int a){
	if(v2[a]==a) return a; //aはroot
	return (v2[a]=root2(v2[a])); //aの親のroot
}
//頂点aとbを同一グループにまとめる
void unite2(int a,int b){
	v2[root2(a)]=root2(b);
}

int main(){
	int n; cin>>n;
	init(++n);
    int k,l; cin>>k>>l;
    int p[k],q[k],s[l],t[l];
    rep(i,k){
        cin>>p[i]>>q[i];
        unite1(p[i],q[i]);
    }
    rep(i,l){
        cin>>s[i]>>t[i];
        unite2(s[i],t[i]);
    }
    rep(i,k){
        unite1(p[i],q[i]);
    }
    rep(i,l){
        unite2(s[i],t[i]);
    }
    map<pair<int,int>,int> m;
    pair<int,int> r[n+1];
    for(int i=1;i<n;i++){
        // cout<<v1[i]<<" "<<v2[i]<<endl;
        pair<int,int> x=make_pair(v1[i],v2[i]);
        r[i]=x;
        m[x]++;
    }
    for(int i=1;i<n;i++){
        cout<<m[r[i]]<<(i!=n-1?" ":"\n");
    }
	return 0;
}


Measured memory_bytes: 16640
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int c = sc.nextInt();
        int[] b = new int[m];
        for(int i=0; i<m; i++){
            b[i] = sc.nextInt();
        }
        int[][] a = new int[n][m];
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                a[i][j] = sc.nextInt();
            }
        }
        int ans = 0;
        for(int i=0; i<n; i++){
            int sum = c;
            for(int j=0; j<m; j++){
                sum += a[i][j] * b[j];
            }
            if(sum > 0){
                ans += 1;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 24276
def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)

def main():
    n = int(input())
    print(num2alpha(n).lower())

    
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 9164
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  string s;
  cin >> s;
  if (s == "SSS") {
    cout << 0 << endl;
  } else if (s == "RRR") {
    cout << 3 << endl;
  } else if (s == "SRR" || s == "RRS") {
    cout << 2 << endl;
  } else {
    cout << 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN
 main() {
 int r,g,b,n;
 cin >> r >> g >> b >> n;
 int ans =0 ;
 for(int i=0;i<=3000;i++){
   for(int j=0;j<=3000;j++){
      int che = i*r+j*g;
      if((n-che)%b==0&&n>=che)ans++;
   }
 }
 cout << ans << endl;
 }
 


Measured memory_bytes: 256
<?php
$input = array_map('intval', explode(' ', fgets(STDIN)));
$a = $input[0];
$b = $input[1];
$c = $input[2];

if (($a+$b)==$c){
    print 'Yes';
} elseif ($a==($b+$c)) {
    print 'Yes';
} elseif (($a+$c)==$b) {
    print 'Yes';
} else {
    print 'No';
}

Measured memory_bytes: 4856
#include <stdio.h>
int main(){
  int i,n,minj,j,key,b,c=0;
  int a[100];
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  for(i=0;i<n;i++){
    b=0;
    minj=i;
    for(j=i;j<n;j++){
      if(a[j]<a[minj]){
	minj = j;
	b++;
      }
    }
    
    key=a[i];
    a[i]=a[minj];
    a[minj]=key;
    if(b)c++;
  }

  for(i=0;i<n-1;i++){
    printf("%d ",a[i]);
  }
  printf("%d",a[n-1]);
  printf("\n%d\n",c);
  
  
  return 0;
}



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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e2 + 5);

int n;
int a[MAX_N];

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    scanf("%d", &(a[i]));
  }

  sort(a, a + n, greater<int>());

  int alice = 0;
  int bob = 0;

  for (int i = 0; i < n; ++i) {
    if (i % 2 == 0) {
      alice += a[i];
    }
    else {
      bob += a[i];
    }
  }

  printf("%d\n", alice - bob);

  return 0;
}


Measured memory_bytes: 256
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

type queue struct {
	name string
	time int
}

func main() {
	n, q := nextInt(), nextInt()
	processes := make([]queue, 0)
	for i := 0; i < n; i++ {
		n := nextLine()
		t := nextInt()
		processes = append(processes, queue{name: n, time: t})
	}
	var time int
	for len(processes) > 0 {
		if processes[0].time > q {
			processes[0].time -= q
			time += q
			processes = append(processes, processes[0])
			processes = processes[1:]
		} else {
			time += processes[0].time
			fmt.Println(processes[0].name, time)
			processes = processes[1:]
		}
	}
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}

// ここから拝借
// https://shoman.hatenablog.com/entry/2020/02/25/185456
// Stackは[]intのエイリアス
type Stack []int

// Push adds an element
func (s *Stack) Push(v int) {
	*s = append(*s, v)
}

// Pop removes the top element and return it
func (s *Stack) Pop() (int, error) {
	if s.Empty() {
		return 0, fmt.Errorf("stack is empty")
	}

	v := (*s)[len(*s)-1]
	*s = (*s)[:len(*s)-1]
	return v, nil
}

// Peek returns the top value
func (s *Stack) Peek() (int, error) {
	if s.Empty() {
		return 0, fmt.Errorf("stack is empty")
	}

	return (*s)[len(*s)-1], nil
}

// Size returns the length of stack
func (s *Stack) Size() int {
	return len(*s)
}

// Empty returns true when stack is empty
func (s *Stack) Empty() bool {
	return s.Size() == 0
}

// NewStack generates stack
func NewStack() *Stack {
	s := new(Stack)
	return s
}



Measured memory_bytes: 8224
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main(){
    int N, X;
    string D;
    int card[4] [13] = {0};//0,S 1,H 2,C 3,D
    cin >> X;
    for (int i = 0; i < X; i++){
        cin >> D >> N;
        if(D == "S")card[0][N-1] = 1;
        if(D == "H")card[1][N-1] = 1;
        if(D == "C")card[2][N-1] = 1;
        if(D == "D")card[3][N-1] = 1;
    }
    for (int i = 0; i < 13; i++){
        if (card[0][i] == 0)
        cout << "S" << " " << i+1 << endl;
    }
    for (int i = 0; i < 13; i++){
        if (card[1][i] == 0)
        cout << "H" << " " << i+1 << endl;
    }
    for (int i = 0; i < 13; i++){
        if (card[2][i] == 0)
        cout << "C" << " " << i+1 << endl;
    }
    for (int i = 0; i < 13; i++){
        if (card[3][i] == 0)
        cout << "D" << " " << i+1 << endl;
    }
}


Measured memory_bytes: 3152
def maximum():
    A,B,C,K = map(int,input().split())
    num = 0
    max = 0
    if A <= K:
        max = A
        num = K - A
        if B <= num:
            num = num - B
            max -= num
            print(max)
            return
        else:
            print(max)
            return
    else:
        print(K)
        return
maximum()


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

d = {}
for i in range(1, 10):
    for j in range(1, 10):
        d[str(i)+str(j)] = 0

for i in range(1, n+1):
    if i % 10 == 0:
        continue
    i = str(i)
    d[i[0]+i[-1]] += 1

ans = 0

for i in range(1, 10):
    for j in range(1, 10):
        ans += d[str(i)+str(j)] * d[str(j)+str(i)]
print(ans)


Measured memory_bytes: 3064
#!/usr/bin/env ruby
DEBUG = false
n, a, b = STDIN.readline().split(' ').map(&:to_i)
def sum(array)
  array.inject(0){|sum, i| sum += i}
end
count = 0
for i in 1..n do
  sum = sum(i.to_s.split('').map(&:to_i))
  puts "i:#{i}, array: #{i.to_s.split('')}, sum:#{sum}" if DEBUG
  count += i if sum >= a and sum <= b
end
puts count

Measured memory_bytes: 2044
n, k = map(int, input().split())
p = [int(x) for x in input().split()]
a = [0]*k
for i in range(k):
  a[i] = min(p) + a[i-1]
  b = p.index(min(p))
  p[b] = 1001
print(a[k-1])

Measured memory_bytes: 9224
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



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

	int n;
	cin >> n;
	int a[n];
	rep(i, n) cin >> a[i];

	int cmax = a[0], ans = 0;

	rep(i, n) {
		chmin(cmax, a[i]);
		if(a[i] <= cmax) ans++;
		//cout << cmax << endl;
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;

struct team{
  int tid;
  int pen;
  int ans;
};


bool comp (const struct team x1,const struct team x2)
{
  if(x1.ans>x2.ans)
    return true;
  else if(x1.ans<x2.ans)
    return false;
  else
    {
      if(x1.pen<x2.pen)
	return true;
      else if(x1.pen>x2.pen)
	return false;
      else
	{
	  if(x1.tid<x2.tid)
	    return true;
	  else if(x1.tid>x2.tid)
	    return false;
	}
      
    }
}


int main()
{
  int t,p,r;
  while(true)
    {
      cin>>t;
      cin>>p;
      cin>>r;
      if(t==0)
	exit(0);

      vector<team> d;
      d.clear();
      for(int i=0;i<t;i++)
	{
	  struct team x;
	  x.tid=i+1;
	  x.pen=0;
	  x.ans=0;
	  d.push_back(x);
	}
      int miss[99][99]={0};

      for(int i=0;i<r;i++)
	{
	  int tt,p,time;
	  string mess;
	  cin>>tt;
	  cin>>p;
	  cin>>time;
	  cin>>mess;
	  if(mess=="WRONG")
	    {
	      miss[p][tt]+=1;
	    }
	  else
	    {
	      d[tt-1].ans+=1;
	      d[tt-1].pen+=(miss[p][tt]*1200)+time;	      
	    }
	}
      sort(d.begin(),d.end(),comp);
      for(int i=0;i<d.size();i++)
	{
	  cout<<d[i].tid<<" "<<d[i].ans<<" "<<d[i].pen<<endl;
	}
	  

    }
}

Measured memory_bytes: 964