akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <list>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

typedef vector<vvi> vvvi;

struct team {
	int n, q, t;
	team() : q(0), t(0) {};
	bool operator<(const team &o)const {
		return q!=o.q ? q<o.q : (t!=o.t ? o.t<t : n<o.n);
	}
};

int main() {
	int M, T, P, R;
	while(cin >> M >> T >> P >> R, M) {
		vvvi data(T, vvi(2, vi(P, 0)));
		REP(i, R) {
			int m, t, p, j;
			cin >> m >> t >> p >> j;
			if(j == 0) {
				data[t-1][0][p-1] = 1;
				data[t-1][1][p-1] += m;
			} else {
				data[t-1][1][p-1] += 20;
			}
		}
		vector<team> teams(T);
		REP(i, T) {
			teams[i].n = i+1;
			teams[i].q = teams[i].t = 0;
		}
		REP(i, T) {
			REP(j, P) {
				if(data[i][0][j]) {
					teams[i].q++;
					teams[i].t += data[i][1][j];
				}
			}
		}
		sort(RALL(teams));
		int curq = teams[0].q, curt = teams[0].t;
		cout << teams[0].n;
		FOR(i, 1, T-1) {
			if(curq == teams[i].q && curt == teams[i].t) {
				cout << "=";
			} else {
				cout << ",";
			}
			cout << teams[i].n;
			curq = teams[i].q;
			curt = teams[i].t;
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 1228
import sys
input = sys.stdin.readline

N, Y = map(int, input().split())
Y //= 1000
max_a = Y // 10

for a in range(max_a + 1):
    val = (Y - N - 9 * a)
    if (val >= 0) and (val % 4) == 0:
        b = val // 4
        c = N - a - b
        if c >= 0:
            print(a, b, c)
            break
else:
    print(-1, -1, -1)



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

int n, m, q;
vector<int>a, b, c, d;
int ans = 0;

void dfs(int cnt, vector<int> A,int now){
    if(cnt == n){
        int num = 0;
        for(int i = 0; i < q; i++){
            if(A[b[i]-1] - A[a[i]-1] == c[i]){
                num += d[i];
            }
        }
        ans = max(num, ans);
    }
    else{
        for(int i = now ; i <= m; i++){
            A[cnt] = i;
            dfs(cnt + 1, A, i);
        }
    }
}


int main(){
    cin >> n >> m >> q;
    for(int i = 0; i < q; i++){
        int aa, bb, cc, dd;
        cin >> aa >> bb >> cc >> dd;
        a.push_back(aa);
        b.push_back(bb);
        c.push_back(cc);
        d.push_back(dd);
    }

    vector<int> A(n,0);
    A[0] = 1;
    dfs(0,A,1);
    cout << ans << endl;
}

Measured memory_bytes: 3564
# AOJ 0196 Baseball Championship
# Python3 2018.6.21 bal4u

while 1:
	n = int(input())
	if n == 0: break
	team = []
	for i in range(n):
		r = list(input().split())
		t = r.pop(0)
		w = l = 0
		for p in r:
			if int(p) == 0: w += 1      # 勝ち数
			elif int(p) == 1: l += 1    # 負け数
		team.append((t, i, w, l))
	for i in sorted(team, key=lambda x:(-x[2],x[3],x[1])): print(*i[0])



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

using namespace std;

int main() {
   

   int x1, x2, x3, x4, x5;
   cin>>x1>>x2>>x3>>x4>>x5;
   
   if(x1==0)cout<<"1";
  else if(x2==0)cout<<"2";
   else if(x3==0)cout<<"3";
   else if(x4==0)cout<<"4";
   else cout<<"5";
   
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    string S;
    cin >> S;
    int ans = 0;
   vector<int> ntm(2019,0);
   for(const auto c: S){
       vector<int> stm(2019,0);
       REP(j,2019) stm[(j*10 + (c-'0'))%2019]+=ntm[j];
       stm[c-'0']++;
       ans+=stm[0];
       ntm = stm;
   }
   cout << ans << endl;
}

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


Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,w,x,sum=0;
	cin>>n>>m;
	bool a[n+1];
	for(int i=1;i<=n;i++)
	a[i]=true;
	for(int i=1;i<=m;i++){
		cin>>x;
		for(int i=1;i<=x;i++){
		cin>>w;
		a[w]=false;
		}
	}
	for(int i=1;i<=n;i++)
	if(a[i]) sum++;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3624
require 'matrix'
loop do
  s = gets.chomp.chop
  break if s == ''
  
  s.gsub!(/([A-Z\)])(?![a-z\d])/, '\11')
  s.gsub!(/([A-Z][a-z])(?!\d)/, '\11')
  s.gsub!(/\((.+?)\)(\d*)/){
    as, n = $1, $2
    as.gsub(/([a-zA-Z])(\d+)/){"#{$1}#{$2.to_i * n.to_i}"}
  }
  atoms = s.scan(/[A-Z][a-z]?/).uniq
  l = s.split('->')[0].count('+') + 1
  molecules = s.split(/\->|\+/)
  m = molecules.size - 1
  n = atoms.size
  
  a = Matrix.build(n, m){|y, x|
    molecules[x].scan(/#{atoms[y]}(\d+)/).map{ |d|
      x < l ? d[0].to_i : -d[0].to_i
    }.reduce(:+).to_r
  }
  
  b = [0] * n
  atoms.each do |atom|
    molecules[-1].scan(/(#{atom})(\d+)/).each{ |a, k|
      b[atoms.index(a)] = k.to_r
    }
  end

  ans = a.lup.solve(b).to_a[0,m] + [1.to_r]
  lcm = ans.map(&:denominator).reduce(&:lcm)
  puts ans.map{|x| (x * lcm).to_i} * ' '
end

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }



typedef pair<ll, pair<ll, ll>> prr;
int main() {
    int a,b; cin >> a >> b;

    int ans = 0;
    ans = max(ans, a-2*b);

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<iterator>
#include<string>
#include<sstream>
#include <unordered_map>
#include<cmath>
using namespace std;
#define ll long long
int __gcd(int a,int b){return b==0 ? a : __gcd(b,a%b);}
ll __gcd(ll a,ll b){return b==0 ? a : __gcd(b,a%b);}

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    int _=1; 
    while(_--){
        int a; cin>>a;
        cout<<a+a*a+a*a*a<<"\n";
    }
}

Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
  public static void main(String args[]) throws IOException{
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));



   while(true){

	  String cards =  br.readLine();
	  if( cards.equals("-") )  break;

      int m = Integer.parseInt(br.readLine());

      for(int i = 0;i < m; i++){
    	  int h = Integer.parseInt(br.readLine());
    	  String left = cards.substring(0, h);	  
    	  String right = cards.substring(h, cards.length());	
          cards = right + left;

      }
      System.out.println(cards);

   }



  }
}

Measured memory_bytes: 24348
#include <iostream>

using namespace std;

int N;
int *A;

int Rec(int left, int right, int n, int &ans)
{

  int rval = right, mid = (left + right)/2;

  if(left >= right)
  {
      if(A[left] >= n)
        ans = left;
    return rval;
  }


  if(n <= A[mid])
    rval = Rec(left, mid, n, ans);
  else if( A[mid] < n)
    rval = Rec(mid+1, right, n, ans);

  return rval;

}

int main()
{

  cin >> N;
  A = new int[N];

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

  int M; cin >> M;

  for(int i = 0; i < M; ++i)
  {
    int Num; cin >> Num;
    int ans = N;

    Rec(0, N, Num, ans);

    cout << ans << endl;

  }

  delete[] A;

  return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <queue>
#include <string.h>
using namespace std;
int inf = 1e9;
struct edge{int to, cap, rev;};
vector<edge> G[10010];
int level[10010];
int iter[10010];
void add_edge(int from, int to, int cap){
	G[from].push_back((edge){to,cap,(int) G[to].size()});
	G[to].push_back((edge){from,0,(int) G[from].size()-1});
}

void bfs(int s){
	memset(level,-1,sizeof(level));
	queue<int> Q;
	level[s] = 0;
	Q.push(s);
	while(!Q.empty()){
		int v = Q.front(); Q.pop();
		for(int i=0;i<G[v].size();i++){
			edge &e = G[v][i];
			if(e.cap > 0 && level[e.to]<0){
				level[e.to] = level[v]+1;
				Q.push(e.to);
			}
		}
	}
}

int dfs(int v,int t,int f){
	if(v==t) return f;
	for(int &i=iter[v];i<G[v].size();i++){
		edge &e = G[v][i];
		if(level[v]<level[e.to] && e.cap>0){
			int d = dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s,int t){
	int flow = 0;
	for(;;){
		bfs(s);
		if(level[t]<0) return flow;
		memset(iter,0,sizeof(iter));
		int f;
		while((f=dfs(s,t,inf))>0) flow += f;
	}
}

int N,M;
char U[510];
int A[510];

int main(){
    cin >> N >> M;
    for(int i=1;i<=N;i++) cin >> U[i];
    for(int i=1;i<=N;i++){
        cin >> A[i];
        if(U[i]=='L'){
            add_edge(0,i,A[i]);
            add_edge(i,N+1,0);
        }else{
            add_edge(0,i,0);
            add_edge(i,N+1,A[i]);
        }
    }
    int x,y,b;
    for(int i=1;i<=M;i++){
        cin >> x >> y >> b;
        if(x>y) swap(x,y);
        add_edge(y,x,b);
    }
    cout << max_flow(0,N+1) << endl;
}


Measured memory_bytes: 3552
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

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

    if(s.size() <= k) {
        out(s);
    }
    else {
        string t = s.substr(0, k);
        cout << t << "..." << endl;
    }

    re0;
}

Measured memory_bytes: 3632
using System;
using System.Linq;
using System.Collections.Generic;

namespace IssueD
{
    class Program
    {
        class Leaf
        {
            public Leaf Parent;
            public int Counter;
        }

        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var vertCount = input[0];
            var controlCount = input[1];
            var leaves = new Leaf[vertCount];

            for (int i = 0; i < vertCount; i++)
            {
                leaves[i] = new Leaf();
            }

            for (int i = 0; i < vertCount - 1; i++)
            {
                var node = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                leaves[node[1] - 1].Parent = leaves[node[0] - 1];
            }

            for (int i = 0; i < controlCount; i++)
            {
                var control = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                leaves[control[0] - 1].Counter += control[1];
            }

            for(int i = 1; i < leaves.Length; i++){
                leaves[i].Counter += leaves[i].Parent.Counter;
            }

            Console.WriteLine(string.Join(" ", leaves.Select(x => x.Counter)));
        }
    }
}


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

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

using namespace std;

int main() {

    ll n,k; cin >> n >> k;
    cout << (ll)(k*pow(k-1,(n-1)));

    return 0;
}











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

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	while(1){
		int n,k;
		bool d[100001] = {false};
		int kyoyou = 0;
		cin >> n >> k;
		if(n == 0 && k == 0) break;
		REP(i,k){
			int t;
			cin >> t;
			if(t == 0){
				kyoyou = 1;
			}else{
				d[t] = true;
			}
		}
		int b,f;
		b = 1; f = 1;
		int space = 0;
		if(!d[b]) space++;
		int ans = 1;
		while ( b < n ){
			while (f <= n && space <= kyoyou){
				space += d[ ++f ] == false;
			}
			ans = max(ans, f-b);
			space -= d[ b++ ] == false;
		}
		cout << ans << endl;

	}	
}

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= m; i--)
#define ll long long
#define pb push_back
#define popb pop_back
using namespace std;
int main(){
  int n,h,w;
  cin >> n >> h >> w;
  cout << (n-h+1)*(n-w+1) << endl;
}

Measured memory_bytes: 764
#include <math.h>
#include <stdio.h>
#include <string.h>

#include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

constexpr long long INFLL = 1e18;
constexpr long long aPN = 1e9 + 7;

using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  int l = s.size();
  if (s.at(l - 1) == 's') {
    cout << s << "es" << endl;
  } else {
    cout << s << 's' << endl;
  }
  return 0;
}

Measured memory_bytes: 3128
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int A = sc.nextInt();
int B = sc.nextInt();
int C = sc.nextInt();
if(A+B >= C){System.out.println("Yes");}
else{System.out.println("No");}
}
}


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

int main(){
  int A,B,C ;
  cin >>A>>B>>C ;
  int ans=0 ;
  for(int i=0;i<C;i++){
    if(B >=A)
      B -=A ;
    else break;
    
    ans ++;
  }
  cout <<ans <<endl;
}


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

int main() {
    int64_t N;
    cin >> N;
    vector<int64_t> P(N);
    for (int64_t i = 0; i < N; i++) {
        cin >> P[i];
    }

    int64_t min_value = INT_MAX;
    int64_t ans = 0;
    for (int64_t i = 0; i < N; i++) {
        if (P[i] <= min_value) {
            ans++;
        }
        min_value = min(min_value, P[i]);
    }

    cout << ans << endl;
}

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

int main() {
	int a,b,c;
	while(cin>>a>>b){
		c=a+b;
			if(c<10){
				cout<<"1\n";
			}
			else if(c>9&&c<100){
				cout<<"2\n";
			}
			else if(c>99&&c<1000){
				cout<<"3\n";
			}
			else if(c>999&&c<10000){
				cout<<"4\n";
			}
			else if(c>9999&&c<100000){
				cout<<"5\n";
			}
			else if(c>99999&&c<1000000){
				cout<<"6\n";
			}
			else{
				cout<<"7\n";
			}
	}
}


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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// #include <cstdio>
// int a; ll B;
// scanf("%d %lld", &a, &B);
// printf("%d\n", a);
//
// for (int i=0; i<n; ++i)
// 	scanf("%d", &a[i]);
//
// char c;
// scanf(" %c", &c);
//
// cout << "\n";

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

/*
ll	myPow(ll x, ll n) {
	if (0==n)
		return 1;
	if (0==n%2)
		return myPow(x*x%MOD, n/2);
	else
		return x*myPow(x, n-1)%MOD;
}
*/
ll	myPow(ll x, ll n) {
	ll r=1;
	while(n>0)
		if (0==n%2) {
			x *=x;
			x %=MOD;
			n /=2;
		} else {
			r *=x;
			r %=MOD;
			n--;
		}
	return r;
}

int	main() {
	int N;
	cin >>N;
	vector<int> C(N+1, 0);
	int A;
	for (int i=2; i<=N; i++) {
		cin >>A;
		C.at(A)++;
	}
	Rep1(i, N)
		cout <<C.at(i) <<endl;
	return 0;
}



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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};


int main()
{
  int n; cin >> n;
  map<string, set<P>> mp;
  rep(i, n) {
    string s;
    int p;
    cin >> s >> p;
    mp[s].insert(P(p, i+1));
  }
  for(auto x : mp) {
    for(auto it = x.second.rbegin(); it != x.second.rend(); ++it) cout << it->second << endl;
  }
}


Measured memory_bytes: 3520
import java.util.*;

class Main {
	public static void main (String[] args) throws java.lang.Exception {
		Scanner sc = new Scanner(System.in);
		int num, i = 0;
		while(true) {
			num = sc.nextInt();
			if(num == 0) break;
			System.out.println("Case " + (++i) + ": " + num);
		}
	}
}


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

using namespace std;

int main(void){
    unsigned long long N, min, tmp;
    
    std::cin >> N >> min;
    for(int i=0; i<4; i++) {
        std::cin >> tmp;
        if(tmp < min)
            min = tmp;
    }
    
    if (N <= min) {
        std::cout << 5 << std::endl;
        return 0;
    }
        

    unsigned long long ans = N / min;
    if(N % min != 0)
        ans++;
    
    std::cout << ans + 4 << std::endl;
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
def dfs(s):
    visited[s]=1
    for v in adj[s]:
        if v not in visited:
            if (s,v) in we:
                y[v]=y[s]+we[(s,v)]
            elif (v,s) in we:
                y[v]=y[s]+we[(v,s)]
            dfs(v)
n=int(input())
adj={}
we={}
visited={}
y=[0]*(n+1)
for q in range(n-1):
    a,b,w=map(int,input().split())
    if a not in adj:
        adj[a]=[b]
    else:
        adj[a].append(b)
    if b not in adj:
        adj[b]=[a]
    else:
        adj[b].append(a)
    we[(a,b)]=w
if n>1:
	dfs(1)
for i in range(1,n+1):
    if y[i]%2==0:
        print(0)
    else:
        print(1)

Measured memory_bytes: 99416
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=(a);i<(b);++i)

template<class T> inline void chmin(T& a, T b) {if (a > b) a = b;}
template<class T> inline void chmax(T& a, T b) {if (a < b) a = b;}

//vector出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){
  o<<"{";
  for(int i=0;i<(int)v.size();i++) o << (i>0?", ":"") << v[i];
  o<<"}";
  return o;
}

//約数列挙
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

ll const mod =1e9+7;
int main() {
  ll n;
  cin >> n;
  auto l = divisor(n);
  int ans=100;
  for (auto i:l) {
    chmin(ans,max((int) to_string(i).size(),(int) to_string(n/i).size()));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
	int a[1000000];
	int i, j;
	int count;
	int n;

	for (i = 0; i < 1000000; i++){
		a[i] = 0;
	}

	a[2] = 1;
	for (i = 3; i < 1000000; i += 2){
		a[i] = 1;
	}

	while (scanf("%d", &n) != EOF){
		count = 0;

		for (i = 3; i < sqrt(n); i++){
			if (a[i] == 1){
				for (j = i * 2; j <= n; j += i){
					a[j] = 0;
				}
			}
		}

		for (i = 2; i <= n; i++){
			count += a[i];
		}

		printf("%d\n", count);
	}

	return (0);
}

Measured memory_bytes: 4500
#include <bits/stdc++.h>
using namespace std;
#define N 2000010
int p[N], a[N], b[N];
struct node {
    int l, r, mid, minn;
} s[N << 2];
void build(int di, int l, int r) {
    s[di].l = l, s[di].r = r, s[di].mid = l + r >> 1, s[di].minn = 1e9;
    if (l == r) return;
    build(di << 1, l, s[di].mid), build(di << 1 | 1, s[di].mid + 1, r);
}
void ins(int di, int x, int v) {
    if (s[di].l == s[di].r) {
        s[di].minn = v;
        return;
    }
    ins(x <= s[di].mid ? di << 1 : di << 1 | 1, x, v);
    s[di].minn = min(s[di << 1].minn, s[di << 1 | 1].minn);
}
int query(int di, int l, int r) {
    if (l <= s[di].l && s[di].r <= r) return s[di].minn;
    if (r <= s[di].mid) return query(di << 1, l, r);
    if (l > s[di].mid) return query(di << 1 | 1, l, r);
    return min(query(di << 1, l, r), query(di << 1 | 1, l, r));
}
int hd[N], nx[N << 1], e[N << 1], Num;
void adde(int x, int y) { nx[++Num] = hd[x], hd[x] = Num, e[Num] = y; }
priority_queue<int> q;
int n, k, In[N];
int main() {
    scanf("%d%d", &n, &k);
    for (int i = 1, x; i <= n; i++) {
        scanf("%d", &x);
        a[x] = i;
    }
    for (int i = 1; i <= n / 2; i++) swap(a[i], a[n - i + 1]);
    build(1, 1, n);
    for (int i = n; i >= 1; i--) {
        int x = query(1, max(1, a[i] - k + 1), a[i]);
        if (x > 0 && x <= n) adde(a[i], a[x]);
        x = query(1, a[i], min(n, a[i] + k - 1));
        if (x > 0 && x <= n) adde(a[i], a[x]);
        ins(1, a[i], i);
    }
    for (int i = 1; i <= n; i++)
        for (int j = hd[i]; j; j = nx[j]) In[e[j]]++;
    for (int i = 1; i <= n; i++)
        if (!In[i]) q.push(i);
    int num = 0;
    while (!q.empty()) {
        int u = q.top();
        q.pop();
        b[++num] = u;
        for (int i = hd[u]; i; i = nx[i])
            if (!(--In[e[i]])) q.push(e[i]);
    }
    for (int i = 1; i <= n / 2; i++) swap(b[i], b[n - i + 1]);
    for (int i = 1; i <= n; i++) p[b[i]] = i;
    for (int i = 1; i <= n; i++) printf("%d\n", p[i]);
}

Measured memory_bytes: 52864
#include <bits/stdc++.h>
#define br cout << "\n";
#define pb push_back
#define ll long long 
#define ff first 
#define ss second
#define all(x) x.begin(),x.end()
#define in(a , idx , n ) for (int i = idx ; i < n ; ++i)cin >>a[i];
#define fix() cout <<fixed <<  std::setprecision(10)
	
using namespace std;
const int MOD = 1000*1000*1000 + 7 ; 
const int MAXN = 1000*1000 +10 ;
const ll INF = 1e18 ;
int spf[MAXN];
void xxx()
{
	spf[1]= 1 ;
	for( int i =1 ; i < MAXN ; ++i )
	{
		for( int j = 1 ; i * j < MAXN ; ++j )
		{
				spf[i * j ]++ ;
		} 
	}
	
}


void solve(){
	ll n;
	cin >> n ;
		
		
	// cout << getFac( n ) ; 
	ll res = 0 ;
	for( int i = 1 ; i < n ; ++i )
	{
		ll newNum = n - i ;
		res += spf[newNum]; 
	}
	cout << res-1  , br 
}
	
int main (){
	xxx();
	int t = 1  ;
	// cin >> t ;
	while (t--){
		solve() ; 
	}
    
return 0 ; 
}


Measured memory_bytes: 7548
using System;

class Grade {
  static void Main() {
    while (true) {
      string scores = Console.ReadLine();
      int m = int.Parse(scores.Split()[0]);
      int f = int.Parse(scores.Split()[1]);
      int r = int.Parse(scores.Split()[2]);
      if (m==-1&&f==-1&&r==-1) break;
      if (m==-1||f==-1) Console.WriteLine("F");
      else if (m+f>=80) Console.WriteLine("A");
      else if (m+f>=65&&m+f<80) Console.WriteLine("B");
      else if (m+f>=50&&m+f<65) Console.WriteLine("C");
      else if (m+f>=30&&m+f<50) {
        if (r>=50) Console.WriteLine("C");
        else Console.WriteLine("D");
      } else Console.WriteLine("F");
    }
  }
}

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

#define INT_MAX 2147483647

int main(void){
    char S[11];
    scanf("%s", S);
    if(S[0] != 'A') {
        printf("WA\n");
        return 0;
    }

    int C = 0;
    int i;
    int Cindex = 0;
    for(i=2; i <= strlen(S) - 2; i++) {
        if(S[i] == 'C') {
            C++;
            Cindex = i;
        }
    }
    if(C != 1) {
        printf("WA\n");
        return 0;
    }

    for(i=1; S[i] != '\0'; i++) {
        if(i != Cindex) {
            if(S[i] < 'a' || S[i] > 'z') {
                printf("WA\n");
                return 0;
            }
        }
    }
    printf("AC\n");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define LL long long
const int maxn = 2e5+100;
int a[maxn],cnt1,cnt2,cnt4;
int n;
int main()
{
   scanf("%d",&n);
   for(int i=1;i<=n;i++){
    scanf("%d",&a[i]);
    if(a[i]%4==0) cnt4++;
    else if(a[i]%2==0) cnt2++;
    else cnt1++;
   }
   if(cnt1>cnt4+1 || (cnt2 && (cnt1==cnt4+1)))
    puts("No");
   else puts("Yes");

}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll suma = accumulate(all(a), 0LL);
    ll cnt = 0;
    rep(i, n) {
        if (suma <= (4 * m * a[i])) {
            cnt++;
        }
    }
    if (cnt >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

using namespace std;

int main()
{
	long N, M;
	cin >> N >> M;
	
	long A[M];
	for(long m = 0; m < M; m++){
		cin >> A[m];
		N -= A[m];
	}
	
	if(N < 0) cout << "-1" << endl;
	else cout << N << endl;
	
	return 0;

}

Measured memory_bytes: 3636
N = int(input())
A = []
B = []
for i in range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)

C = list(zip(B,A))
C.sort()
B,A = list(zip(*C))
B = list(B)
A = list(A)

flag = True
time = 0
for i in range(N):
    time += A[i]
    if time > B[i]:
        flag = False
        break
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 49144
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    assert_eq!(!0usize, std::usize::MAX); //🙊
    assert!(0 == 0); //😇

    let a = io.chars()[0];
    let b = io.chars()[0];

    let ans = (a == 'H') ^ (b != 'H');
    io.writeln(if ans { "H" } else { "D" });
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
		if(s.indexOf("RRR") != -1) {
			System.out.println("3");
		}else if(s.indexOf("RR") != -1){
			System.out.println("2");
		}else if(s.indexOf("R") != -1) {
			System.out.println("1");
		}else {
			System.out.println("0");
		}
	}

}

Measured memory_bytes: 35556
#include<stdio.h>

int main(){
  int n,i,j,x;
  int a[100];
  int mat[10][7]={
    //g,f,e,d,c,b,a
    {0,1,1,1,1,1,1},  // 0
    {0,0,0,0,1,1,0},  // 1
    {1,0,1,1,0,1,1},  // 2
    {1,0,0,1,1,1,1},  // 3
    {1,1,0,0,1,1,0},  // 4
    {1,1,0,1,1,0,1},  // 5
    {1,1,1,1,1,0,1},  // 6
    {0,1,0,0,1,1,1},  // 7
    {1,1,1,1,1,1,1},  // 8
    {1,1,0,1,1,1,1}}; // 9
  
  for(;;){
    int tmp[7]={};

    scanf("%d",&n);

    if(n==-1)
      break;

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

    for(i=0;i<n;i++){
      x=a[i];
      for(j=0;j<7;j++){
	if(tmp[j]==mat[x][j])
	  printf("0");
	else{
	  printf("1");
	  if(tmp[j])
	    tmp[j]=0;
	  else
	    tmp[j]=1;
	}
      }
      puts("");
    }
  }
  return 0;
}

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

using namespace std;

int main() {
    int ans = 0;
    string s, rvs;
    while (cin >> s) {
        rvs = s;
        reverse(rvs.begin(), rvs.end());
        if (s == rvs) ans++;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3080
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size))scanf("%d",&(name)[i])

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    string w=get_str();
    map<char,int> list;
    FOR(i,w.size()){
        list[w[i]]++;
    }
    bool flag=1;
    for(pair<char,int> p:list){
        if(p.second%2==1)flag=0;
    }
    print(flag?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
fn main() {
    let a: i32 = read();
    let b: i32 = read();

    println!("{}", match (a, b) {
        (1, 1) => "Draw",
        (1, _) => "Alice",
        (_, 1) => "Bob",
        (a, b) => if a == b {
            "Draw"
        } else if a > b {
            "Alice"
        } else {
            "Bob"
        }
    })
}


#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    use std::io::prelude::*;

    let stdin = std::io::stdin();
    let s: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    s.parse().ok().unwrap()
}

Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }

const int dx[] = {-1, 0, 0, 1};
const int dy[] = {0, -1, 1, 0};
bool bio[1005][1005];


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

	int n, m;
	cin >> n >> m;
	string s[1005];
	queue <ii> q;
	for(int i = 0; i < n; i++){
		cin >> s[i];
		for(int j = 0; j < m; j++){
			if(s[i][j] == '#'){
				bio[i][j] = 1;
				q.emplace(i, j);
			}
		}
	}
	int res = 0;
	while(!q.empty()){
		int X = q.size();
		bool added = 0;
		for(int i = 0; i < X; i++){
			ii frt = q.front();
			q.pop();
			for(int k = 0; k < 4; k++){
				int nx = frt.first + dx[k], ny = frt.second + dy[k];
				if(nx < 0 || ny < 0 || nx >= n || ny >= m || bio[nx][ny])
					continue;
				bio[nx][ny] = 1;
				q.emplace(nx, ny);
				added = 1;
			}
		}
		res += added;
	}
	cout << res;
}

Measured memory_bytes: 10512
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds;  

#define pb push_back
#define ll long long int
#define db double
#define SORTA(v) sort(v.begin(),v.end())
#define SORTD(v) sort(v.begin(),v.end(),greater<>())
#define endl '\n'
#define nod(N) floor(log10(N)) + 1
#define LB(a) lower_bound(a)
#define UB(a) upper_bound(a)
#define F first
#define S second
#define FOR(i,n) for(long long int i = 0;i<n;i++)
#define FOR1(i,n) for(long long int i=1;i<=n;i++)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define REVERSE(s) reverse(s.begin(),s.end())
#define LBV(v,a) lower_bound(v.begin(),v.end(),a)
#define UBV(v,a) upper_bound(v.begin(),v.end(),a)
#define GCD(a,b) __gcd(a,b)
#define ITX(it,x1) for(auto it = x1.begin();it!=x1.end();it++)
#define I insert
#define VFIND(v1,val) find(v1.begin() , v1.end() , val )
#define VFILL(v1 , val)   std::fill(v1.begin(), v1.end(), val);
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define all(x) x.begin() , x.end() 

// typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ll mxm() {return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a, Args... args) { return max(a,mxm(args...)); }
ll mnm() {return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a, Args... args) { return min(a,mnm(args...)); }

const int MOD = 1e9 + 7;
long long int powxy(long long int x, long long int y) 
{
    if (y == 0) return 1;if (y%2 == 1) return (x*powxy(x, y-1))%MOD;
    long long int t = powxy(x, y/2);return (t*t)%MOD;
}
void DPM(map<ll,ll>m1)
{
    for(auto it = m1.begin();it!=m1.end();it++)
    {
        cout<<it->first<<" "<<it->second<<endl;
    }
    cout<<endl;
}
void DPV(vector<ll>v)
{
    FOR(i,v.size())cout<<v[i]<<" ";cout<<endl;
}
void DPS(set<ll>s1)
{
    for(auto it =s1.begin();it!=s1.end();it++)cout<<*it<<" ";cout<<endl;
}
void DPA(ll arr[],ll n){FOR(i,n)cout<<arr[i]<<" ";cout<<endl;}



ll dx[4] = { 0,0,1,-1 };
ll dy[4] = { 1,-1,0,0 };
string pos = "RLDU";


int main()
{
    FAST;
    ll i ,j , T = 1;
    // cin>>T;
    while(T--)
    {
        i=0;j=0;
        ll a,b;cin>>a>>b;
        cout<<a*b;
        
        
    }
}  



Measured memory_bytes: 3636
x, y, a, b, c = [int(e) for e in input().split()]
pa = sorted([int(e) for e in input().split()], reverse=True)
pb = sorted([int(e) for e in input().split()], reverse=True)
pr = sorted([int(e) for e in input().split()], reverse=True)

print(sum(sorted(pa[:x] + pb[:y] + pr, reverse=True)[:x+y]))


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

int main(){
  int n, k;
  cin >> n >> k;

  vector<int> h(n);
  for(int i=0; i<n; i++){
    cin >> h[i];
  }
  //降順ソート
  sort(h.begin(), h.end(),greater<int>());

  long long sum=0;
  if(k >= n) cout << 0 << endl;
  else{
    for(int i=k; i<n; i++){
      sum += h[i];
    }
    cout << sum << endl;
  }


  return 0;
}

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

int main(int argc, const char * argv[]) {
    // insert code here...
    string s;
    cin >> s;
    
    s.at(5) = ' ';
    s.at(13) = ' ';
    
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
S = str(input())
H = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T',
     'U','V','W','X','Y','Z','A','B','C','D','E','F','G','H','I','J','K','L','M','N',
     'O','P','Q','R','S','T','U','V','W','X','Y','Z']
tmp = 0
ans = []

for i in range(0, len(S)):
  tmp = H.index(S[i])
  tmp = tmp + N
  ans.append(H[tmp])

print(''.join(map(str, ans)))

Measured memory_bytes: 3188
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

A, B = read_int()

# 約数列挙 return set
def divisor(n):
    res = []
    i = 1
    while i**2 <= n:
        if n % i == 0:
            res.append(i)
            if i != n // i:
                res.append(n // i)
        i += 1
    return res

def gcd(a, b):
    if a > b:
        a, b = b, a
    while b % a != 0:
        a, b = b % a, a
    return a

# 素数判定 return bool
def is_prime(n):
    i = 2
    while i**2 <= n:
        if n % i == 0: return False
        i += 1
    return True

def solve():
    ans = 0

    g = gcd(A, B)
    koubai = divisor(g)

    for n in koubai:
        if is_prime(n):
            ans += 1
    return ans

if __name__ == "__main__":
    print(solve())

Measured memory_bytes: 41324
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <math.h>
typedef long long ll;

using namespace std;

int main(){
    int n;
    cin >> n;
    ll a[100001]={0};
    for (int i=0;i<n;i++) cin >> a[i];

    bool sign=true;
    ll res=0,res2=0,sum=0;
    for (int x=0;x<2;x++){
	res=0;
	sum=0;
        for (int i=0;i<n;i++){
	    sum+=a[i];
	    if (sign){
		if (sum <= 0){
		    res+=1-sum;
		    sum=1;
		}
		sign=false;
	    } else {
		if (sum >= 0){
		    res+=1+sum;
		    sum=-1;
		}
		sign=true;
	    }
	}
	sign=false;
	if (x == 0) res2=res;
    }

    cout << min(res,res2) << endl;

    return 0;
}

Measured memory_bytes: 1024
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let mut graph = vec![vec![]; n];
    for _ in 1..n {
        let x = sc.read::<usize>() - 1;
        let y = sc.read::<usize>() - 1;
        graph[x].push(y);
        graph[y].push(x);
    }

    if grundy_dfs(0, 0, &graph) == 0 {
        println!("Bob");
    } else {
        println!("Alice");
    }
}

fn grundy_dfs(v: usize, p: usize, graph: &Vec<Vec<usize>>) -> usize {
    let mut xor = 0;
    for &next in graph[v].iter() {
        if p == next {
            continue;
        }
        xor ^= grundy_dfs(next, v, graph) + 1;
    }
    xor
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 16636
def knapsack(w,val,W,n,t):
    for i in range(1,n+1):
        for j in range(1,W+1):
            if w[i-1]<=j:
                t[i][j]=max(val[i-1]+t[i-1][j-w[i-1]],t[i-1][j])
            else:
                t[i][j]=t[i-1][j]
    return t[n][W]            
n,W=map(int,input().split())                
w=[]
val=[]
t=[[0 for x in range(W+1)] for x in range(n+1)] 
for i in range(0,n):
    a,b=map(int,input().split())
    w.append(a)
    val.append(b)
ans=knapsack(w,val,W,n,t)
print(ans)
    

Measured memory_bytes: 173448
#include <iostream>
#include <vector>
#include <random>
using namespace std;

int main(){
	mt19937 mt(12345);
	int n,k;
	cin >> n >> k;
	vector<vector<int> > card(k, vector<int>(n/2));
	for(int i=0; i<k; i++){
		for(int j=0; j<n/2; j++){
			cin >> card[i][j];
			card[i][j]--;
		}
	}
	string ans = "";
	while(1){
		bool success = true;
		vector<int> seq(n);
		for(int i=0; i<n; i++){
			seq[i] = mt()%2;
		}
		for(int i=0; i<k; i++){
			int sum = 0;
			for(int j=0; j<n/2; j++){
				sum += seq[card[i][j]];
			}
			if(sum < n/8 || n*3/8 < sum){
				success = false;
				break;
			}
		}
		if(success){
			for(int i=0; i<n; i++){
				ans += seq[i] +'0';
			}
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
int main(){
    ll n,z,w;cin>>n>>z>>w;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    if(n==1)cout<<abs(a[0]-w)<<endl;
    else cout<<max(abs(a[n-2]-a[n-1]),abs(a[n-1]-w));
}

Measured memory_bytes: 256