akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int  N, Y;
    cin >> N >> Y;
    for(int man = 0; man*10000 <= Y && man <= N; man++){
        for(int gosen = 0; gosen*5000 <=  (Y - man*10000) && (man + gosen) <= N; gosen++){
            if((Y - gosen*5000 - man*10000) % 1000 == 0 && (Y - gosen*5000 - man*10000) / 1000 + man + gosen == N){
                cout << man << " " << gosen << " " << (Y - gosen*5000 - man*10000) / 1000 << endl;
                return 0;
            }  
        }
    }
    
    cout << "-1 -1 -1"<< endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#define FIN freopen("inputs.txt", "r", stdin)
using namespace std;
typedef pair<int, int> P;
#define MAX_N 200009
int perm[MAX_N];
int n;
int main(){
    cin>>n;
    for (int i = 0; i < n; i++)
    {
        cin>>perm[i];
    }
    int cnt = 1;
    int minimum = perm[0];
    for (int i = 1; i < n; i++)
    {
        minimum = min(minimum, perm[i-1]);
        if(perm[i] <= minimum) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>

int min(int a, int b) {
  if(a < b)
    return a;
  return b;
}

int main() {
  int q, h, s, d, n;
  scanf("%d%d%d%d%d", &q, &h, &s, &d, &n);
  h = min(2 * q, h);
  s = min(2 * h, s);
  d = min(2 * s, d);

  printf("%lld", (long long)n / 2 * d + n % 2 * s);
  return 0;
}


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

int cnt[100004], n, q, l, r;
string s;
int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>q>>s;
	memset(cnt, 0, sizeof(cnt));
	for(int i = 1;i<n;i++){
		if(s[i-1] == 'A' && s[i] == 'C')
			cnt[i]++;
		cnt[i] += cnt[i-1];
	}
	while(q--){
		cin>>l>>r;
		cout<<cnt[r-1]-cnt[l-1]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1488
#include <cstdio>
using namespace std;

int main()
{
  int n, m;
  scanf("%d %d", &n, &m);

  long l, r;
  long max_l, min_r;
  max_l = 1;
  min_r = 100000;
  for (int i = 0; i < m; i++)
  {
    scanf("%ld %ld", &l, &r);
    if (l > max_l)
      max_l = l;
    if (r < min_r)
      min_r = r;
  }
  long ans = min_r - max_l + 1;
  if (ans <= 0)
    ans = 0;
  printf("%ld\n", ans);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
using namespace std;
#define MAX 1000
#define VMAX 10000

int n, A[MAX], s;
int B[MAX], T[VMAX + 1];

int solve() {
  int ans = 0;

  bool V[MAX];
  for(int i = 0; i < n; i++) {
    B[i] = A[i];
    V[i] = false;
  }
  sort(B, B + n);
  for( int i = 0; i < n; i++) T[B[i]] = i;
  for(int i = 0; i < n; i++) {
    if(V[i]) continue;
    int cur = i;
    int S = 0;
    int m = VMAX;
    int an = 0;
    while(1) {
      V[cur] = true;
      an++;
      int v = A[cur];
      m = min(m, v);
      S += v;
      cur = T[v];
      if(V[cur]) break;
    }

    ans += min(S + (an - 2)*m, m + S +(an + 1)*s);
  }
  return ans;
}

int main() {
  cin >> n;
  s = VMAX;
  for(int i = 0; i < n; i++) {
    cin >> A[i];
    s = min(s, A[i]);
  }
  int ans = solve();
  cout<<ans<<endl;
  return 0;
}



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

vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}

void solve(long long N, long long M){
    // Mの約数で, M/約数 がN以上になる最大値を探す
    vector<long long> div = divisor(M);

    long long ans = 0;
    for(int i = div.size()-1; i >= 0; i--){
        if(M/div[i] >= N){
            ans = div[i];
            break;
        }
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;

class Solve
{
	const int mod = 1000000007;
	static void Main(string[] args)
	{
		var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int N = input[0];
		int M = input[1];

		int[] ans = new int[N];
        for(var i = 0; i < M; i++)
		{
			var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
			ans[ab[0] - 1]++;
			ans[ab[1] - 1]++;
		}
		for (int i = 0; i < N; i++)
		{

			Console.WriteLine(ans[i]);

		}
	}
}


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

int main() {
    string str;
    cin >> str;
    int count = 0;
    if(str == "RRR")
        cout << 3 << endl;

    else if(str == "RRS" || str == "SRR")
        cout << 2 << endl;

    else if(str == "SSS")
        cout << 0 << endl;

    else
        cout << 1 << endl;
        
    
}

Measured memory_bytes: 3624
x, y =  map(int, input().split())

a=[1,3,5,7,8,10,12]
b=[4,6,9,11]

if x == y:
    print('Yes')
elif x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")    
else:
    print("No")

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

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

#define INF 100000000

int main() {
  vector<int> q;
  rep(i,3){
    int a;
    cin >> a;q.push_back(a);
  }
  sort(q.begin(), q.end());
  rep(i,3){
    if(i < 2 && q.at(i) != 5){
      cout << "NO" << endl;
      return 0;
    }
    else if (i == 2 && q.at(i) != 7){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvl vector<vector<ll>>
#define print(n) cout<<n<<endl
const int M=100010;
const int MOD=1000000007;
const int inf=1000000007;
const long long INF=1000000000000000007;
using ll=long long;


int main(){
	int n;
	string s[110];
	pair<string,int> p[110],q[110];
	cin>>n;
	rep(i,0,n){
		cin>>p[i].first>>p[i].second;
		q[i].first=p[i].first;
		q[i].second=p[i].second;
	}
	sort(p,p+n);
	rep(i,0,n-1){
		if(p[i].first==p[i+1].first&&p[i].second<p[i+1].second){
			int tmp=p[i].second;
			p[i].second=p[i+1].second;
			p[i+1].second=tmp;
			i-=2;
		}
	}
	rep(i,0,n){
		rep(j,0,n){
			if(p[i]==q[j]){
				cout<<j+1<<endl;
				break;
			}
		}
	}

}


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

int main(){
    int t;
    int n;
    cin >> t >> n;
    int count = 0;

    while(t--){
        int x, y;
        cin >> x >> y;

        long long int temp = pow(x, 2) + pow(y, 2);
        long double ans = sqrtl(temp);
        if(ans <= n){
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

int main(){
  int N; cin >> N;
  if (N % 2 == 0){
    cout << N / 2 - 1 << endl;
  }else{
    cout << N / 2 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

vi d, was;
vvi g;
set<pii> e;

void print(int a, int b) {
  if (e.count(pii(a, b))) return;
  ++d[a];
  cout << a + 1 << ' ' << b + 1 << '\n';
  e.insert(pii(a, b));
  e.insert(pii(b, a));
}

void dfs(int v, int pr = -1) {
  was[v] = 1;
  for (int nv : g[v]) if (nv != pr) {
    if (was[nv]) {
      print(v, nv);
    } else {
      dfs(nv, v);
      if (d[nv] % 2) {
        print(nv, v);
      } else {
        print(v, nv);
      } 
    }
  }
}

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n, m;
  cin >> n >> m;
  d.assign(n, 0);
  was.assign(n, 0);
  g.resize(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  if (m % 2) {
    cout << -1 << endl;
    return 0;
  }
  dfs(0);
  return 0;
}


Measured memory_bytes: 23296
from sys  import stdin,stdout

import bisect

import math

def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")

def soe(limit):
    l=[1]*(limit+1)
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0

    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime

def segsoe(low,high):
    limit=int(high**0.5)+1
    prime=soe(limit)
    n=high-low+1
    l=[0]*(n+1)
    for i in range(len(prime)):
        lowlimit=(low//prime[i])*prime[i]
        if lowlimit<low:
            lowlimit+=prime[i]
        if lowlimit==prime[i]:
            lowlimit+=prime[i]
        for j in range(lowlimit,high+1,prime[i]):
            l[j-low]=1
    for i in range(low,high+1):
        if not l[i-low]:
            if i!=1:
                print(i)
                
def gcd(a,b):
    while b:
        a=a%b
        b,a=a,b
    return a

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r

def check(n,s):
    v=str(n)
    for i in v:
        if i in s:
            return False
    return True
    

    
def solve():
    l=[]
    s=input()
    for i in s:
        if i=='0' or i=='1':
            l.append(i)
        else:
            if len(l)>0:
                l.pop()
    print(''.join(l))
        
        
        

for _ in range(1):
    solve()
    


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

typedef long long ll;
const int MAX_N = 100000;

int main() {
  int N, M, L_max, R_min;
  std::cin >> N >> M;
  L_max = 1;
  R_min = N;
  for(int i = 0; i < M; ++i) {
    int L, R;
    std::cin >> L >> R;
    L_max = std::max(L_max, L);
    R_min = std::min(R_min, R);
  }
  int ans = std::max(0, R_min - L_max + 1);
  std::cout << ans << std::endl;
}


Measured memory_bytes: 256
<?php
/*
    Problem URL : http://abc043.contest.atcoder.jp/tasks/abc043_b

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

fscanf(STDIN, "%s", $s);
$arrS = str_split($s);
$lenS = count($arrS);
$ans = "";

for ($i = 0; $i < $lenS; $i++) {
    switch ($arrS[$i]) {
        case "0":
            $ans .= "0";
            break;

        case "1":
            $ans .= "1";
            break;

        case "B":
            $ans = substr($ans, 0, strlen($ans) - 1);
            break;
    }
}

echo $ans . PHP_EOL;


Measured memory_bytes: 3832
#include <iostream>
#include <string>
using namespace std;
int main(){
	string s;
	int k=0;
	cin>>s;
	if(s[0]!='C')k++;
	if(s[1]!='O')k++;
	if(s[2]!='D')k++;
	if(s[3]!='E')k++;
	if(s[4]!='F')k++;
	if(s[5]!='E')k++;
	if(s[6]!='S')k++;
	if(s[7]!='T')k++;
	if(s[8]!='I')k++;
	if(s[9]!='V')k++;
	if(s[10]!='A')k++;
	if(s[11]!='L')k++;
	if(s[12]!='2')k++;
	if(s[13]!='0')k++;
	if(s[14]!='1')k++;
	if(s[15]!='6')k++;
	cout<<k<<endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <stack>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	//入力
	long A[100001], B[100001], x[100001] = {};
	while (true){
		string S = {};
		char W[101] = {};
		bool f[101] = {};
		bool flag = true;
		//stack<pair<int, int>> dfs;
		long R_0 = 0, W_0 = 0, R = 0, C = 0, N = 0, K = 0, T = 0, M = 1000000000, ans = 0, l = 0, r = 0, sum = 0, a = 0, b = 0, c = 0;
		double L = 0;
		cin >> R_0 >> W_0 >> C >> R;
		if (R_0 == 0 && W_0 == 0 && C == 0 && R == 0)break;
		//処理
		if (C * W_0 == R_0) {
			ans = 0;
		}
		else if (C * W_0 < R_0) {
			ans = 0;
		}
		else {

			if ((C * W_0 - R_0) % R == 0) ans = (C * W_0 - R_0) / R;
			else ans = (C * W_0 - R_0) / R + 1;
		}
		//出力
		cout << ans << endl;
	}
}


Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {
	public static void main(String [] args) {
		Scanner stdIn = new Scanner(System.in);
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = stdIn.nextInt();
		
		while(a < 0 || c > 100) {
			a = stdIn.nextInt();
			b = stdIn.nextInt();
			c = stdIn.nextInt();
			
		}
		
		if( a < b && b < c) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 26336
#include <iostream>
using namespace std;
int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	if (a > b)
	{
		swap(a,b);
	}
	if ((a < c)&&(c < b))
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    string s;cin >> s;
    ll cnt=0;
    rep(i,10){
        char a='0'+i;
        rep(j,10){
            char b='0'+j;
            rep(k,10){
                char c='0'+k;
                ll x=0;
                while(s[x]!=a&&x<n)x++;
                x++;
                if(x>n)break;
                while(s[x]!=b&&x<n)x++;
                x++;
                if(x>n)break;
                while(s[x]!=c&&x<n)x++;
                if(x>n)break;
                if(s[x]==c)cnt++;
            }
        }
    }
    cout << cnt <<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
vector<int> node[100005];
int par[100005]={0};
int dfs(int pos){
  if(node[pos].size()==0) return 0;
  vector<int> v;
  for(int i=0;i<node[pos].size();i++) v.push_back(dfs(node[pos][i]));
  sort(v.begin(),v.end(),greater<int>());
  int ret=0;
  for(int i=0;i<v.size();i++) ret=max(ret,v[i]+i+1);
  return ret;
}
int main(){
  int n;
  cin>>n;
  for(int i=2;i<=n;i++) {
    cin>>par[i];
    node[par[i]].push_back(i);
  }
  cout<<dfs(1)<<endl;
}


Measured memory_bytes: 13952
import java.util.Scanner;

public class Main {

    private static final int r     = 0,
    		                 c     = 1,
    		                 EMPTY = -1;

    private static int[]   p;
    private static int[][] m;

    public static void main(String[] args) {

        //input
         Scanner sc = new Scanner(System.in).useDelimiter(System.getProperty("line.separator"));
         int N = sc.nextInt();
         p = new int[N+1];
         m = new int[N][N];
         String[] s = null;
       	 for(int i=0;i<N;i++){
       		 s = sc.next().split("\\s");
       		 p[i] = Integer.parseInt(s[r]);
       	 }
       	 p[N] = Integer.parseInt(s[c]);

         //calculation
       	 int i,j,k,l,q;
       	 for(l=1;l<N;l++){
       		 for(i=0;i<N-l;i++){
       			 j = i + l;
       			 m[i][j] = EMPTY;
       			 for(k=i;k<j;k++){
//       				 System.out.println("i:"+i+", k:"+k+", j:"+j);
       				 q = m[i][k] + m[k+1][j] + p[i]*p[k+1]*p[j+1];
//       				 System.out.println("m["+i+"]["+k+"]:"+m[i][k]+" + m["+(k+1)+"]["+j+"]:"+m[k+1][j]+" + p["+i+"]*p["+(k+1)+"]*p["+(j+1)+"]:"+p[i]*p[k+1]*p[j+1]);
       				 if(q < m[i][j] || m[i][j] == EMPTY){
       					 m[i][j] = q;
       				 }
       			 }
       		 }
       	 }

       	 for(i=0;i<N;i++){
       		 for(j=0;j<N;j++){
//       			 System.out.println("m["+i+"]["+j+"]:"+m[i][j]);
       		 }
       	 }

         //output
       	 System.out.println(m[0][N-1]);
    }
}

Measured memory_bytes: 19988
object Main {
  def main(args: Array[String]): Unit = {
    val s = new Main()
    s.solve()
    s.out.flush()
  }
}

class Main {
  import java.io._
  import java.util.StringTokenizer

  import scala.collection.mutable
  import scala.util.Sorting
  import math.{abs, max, min}
  import mutable.{ArrayBuffer, ListBuffer}
  import scala.reflect.ClassTag

  val MOD = 1000000007
  val out = new PrintWriter(System.out)

  def solve(): Unit = {
    val N = ni()
    var ms = 100

    def cnt(x: Int) = {
      x.toString.map(_ - '0').sum
    }

    1 until N foreach { a =>
      val b = N - a
      ms = min(ms, cnt(a) + cnt(b))
    }

    out.println(ms)
  }


  class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = _

    def next(): String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next().toInt
    def nextLong(): Long = next().toLong
    def nextChar(): Char = next().charAt(0)
  }
  val sc = new InputReader(System.in)
  def ni(): Int = sc.nextInt()
  def nl(): Long = sc.nextLong()
  def nc(): Char = sc.nextChar()
  def ns(): String = sc.next()
  def ns(n: Int): Array[Char] = ns().toCharArray
  def na(n: Int): Array[Int] = map(n)(_ => ni())
  def nal(n: Int): Array[Long] = map(n)(_ => nl())
  def nm(n: Int, m: Int): Array[Array[Char]] = map(n) (_ => ns(m))
  def rep(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = offset
    val N = n + offset
    while(i < N) { f(i); i += 1 }
  }
  def rep_r(n: Int, offset: Int = 0)(f: Int => Unit): Unit = {
    var i = n - 1 + offset
    while(i >= offset) { f(i); i -= 1 }
  }

  def map[@specialized A: ClassTag](n: Int)(f: Int => A): Array[A] = {
    val res = Array.ofDim[A](n)
    rep(n)(i => res(i) = f(i))
    res
  }

  def sumL(as: Array[Int]): Long = {
    var s = 0L
    rep(as.length)(i => s += as(i))
    s
  }
}

Measured memory_bytes: 55468
#include <vector>
#include <iostream>
#include <queue>

using namespace std;

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

    int n, m, k;
    cin >> n >> m >> k;
    
    int start_i, start_j;
    vector<string> mat(n);
    for (int i = 0; i < n; ++i) {
        cin >> mat[i];
        for (int j = 0; j < m; ++j)
            if (mat[i][j] == 'S')
                start_i = i,
                start_j = j,
                mat[i][j] = '.';
    }

    const int dx[] = {0, 1, 0, -1};
    const int dy[] = {1, 0, -1, 0};
    
    // Do BFS from start
    queue<pair<int, int>> q;
    q.emplace(start_i, start_j);
    vector<vector<int>> dist(n, vector<int>(m, -1));
    
    dist[start_i][start_j] = 0;
    while (!q.empty()) {
        int i = q.front().first;
        int j = q.front().second;
        q.pop();

        for (int d = 0; d < 4; ++d) {
            int newi = i + dx[d];
            int newj = j + dy[d];

            if (newi < 0 or newj < 0 or newi >= n or newj >= m) 
                continue;
            
            if (mat[newi][newj] != '#' and dist[newi][newj] == -1) {
                dist[newi][newj] = dist[i][j] + 1;
                q.emplace(newi, newj);
            }
        }
    }

    int ans = n * m;
    
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (dist[i][j] == -1 or dist[i][j] > k)
                continue;
            
            int dist_edge = min(min(i, j), min(n - i - 1, m - j - 1));
            ans = min(ans, 1 + (dist_edge + k - 1) / k);
        }
    }

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


Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; 
const int mod = 1e9 + 7;
int qp(int a, int b) {
	int ans = 1;
	while(b) {
		if(b & 1) ans = 1ll * ans * a % mod;
		a = 1ll * a * a % mod;
		b >>= 1; 
	}
	return ans;
}

int main()
{
	int n; scanf("%d", &n); 
	if(n == 1) puts("0");
	else if(n == 2) puts("2");
	else printf("%d\n", (((ll)qp(10, n) - 2 * qp(9, n) + qp(8, n)) % mod + mod) % mod);
	return 0;
}

Measured memory_bytes: 3764
// diverta2019_d
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

ll N;

void solve(){
    ll ans = 0;
    double sqrt_n = sqrt(N);
    for (int i = 1 ; i < sqrt_n; ++i) {
        if (N % i == 0) {
            ll m = N / (ll)i;
            if (m == 0) continue;

            if (N % (m-1) == N / (m-1)){
                ans += m - 1;
            }
        }
    }

    print(ans);
}

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt");
    cin.rdbuf(in.rdbuf());
#endif

    cin >> N;
    solve();

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define MAX 1e9
 
ll modpow(ll base, ll exp, ll modulus) {base %= modulus;ll result = 1;while (exp > 0) {if (exp & 1) result = (result * base) % modulus;base = (base * base) % modulus;exp >>= 1;}return result;}
const ld pi=acos(-1);


int main(){
    IOS;
    ld r;cin>>r;
    ld ans=2*pi*r;
    cout<<ans;
    return 0;  
} 





Measured memory_bytes: 3804
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define cool ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long
#define MAX 1000001
#define mod 1000000007
#define pie 3.14159265358979323846
void solve()
{
	ll int n,W,i,j;
	cin>>n>>W;
	ll int wt[n],val[n];
	for(i=0;i<n;i++)
	cin>>wt[i]>>val[i];
	ll int dp[n+1][W+1];
	for(i=0;i<=n;i++){
		for(j=0;j<=W;j++){
			if(i==0||j==0)
			dp[i][j]=0;
			else if(wt[i-1]<=j)
			dp[i][j]=max(val[i-1]+dp[i-1][j-wt[i-1]],dp[i-1][j]);
			else
			dp[i][j]=dp[i-1][j];
		}
	}
	cout<<dp[n][W];
}
int main()
{ 
    cool;
    int t;
    //cin>>t;
    t=1;
    while(t--){
    	solve();
	}
    return 0;
}


Measured memory_bytes: 79232
#include<iostream>
#include<string>

using namespace std;
string s[150];
int r,c;

int main()
{
    cin>>r>>c;
    for(int i=0;i<c+2;i++)
    {
        s[0]+='#';
        s[r+1]+='#';
    }
    for(int i=1;i<=r;i++)
    {
        cin>>s[i];
        s[i]='#'+s[i]+'#';
    }
    for(int i=0;i<r+2;i++)
        cout<<s[i]<<endl;


}


Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main() {
  ll N;

  cin >> N;

  ll ans[100];

  ans[0] = 2;
  ans[1] = 1;
  for (size_t i = 2; i < 100; i++) {
    ans[i] = ans[i - 1] + ans[i - 2];
  }

  cout << ans[N] << endl;

  return 0;
}


Measured memory_bytes: 256
#-*- coding: utf-8 -*-
"""
oj dl https://atcoder.jp/contests/abc116/tasks/abc116_d -d test-d
oj test -d test-d -c "python abc116d.py"
oj test -d test-d -c "python abc116d.py" test-d/sample-3.in
"""
from collections import defaultdict
import sys
import math
from datetime import datetime

def sol(S):
    base = datetime.strptime("2019/04/30", '%Y/%m/%d')
    target = datetime.strptime(S, '%Y/%m/%d')
    return "Heisei" if target <= base else "TBD"


do_submit = True


def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(int, line.split())) for line in lines]
    a, b, c = parsed_lines[0]
    return a, b, c


if not do_submit:
    a, b, c = input_parse("""
    45 28 53
    """)
    print(sol(a, b, c))
else:
    # a, b, c = list(map(int, input().split()))
    # print(sol(a, b, c))
    S = input().strip()
    print(sol(S))



Measured memory_bytes: 4684
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, a, n) for(int i = (a); i < (n); i++)
#define dep(i, a, n) for(int i = (a); i >= (n); i--)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}


signed main() {
  int n, w;
  cin >> n >> w;
  int o[100001] = {};

  rep(i, 0, n) {
    int ww, v;
    cin >> ww >> v;
    dep(j, w, 0) {
      if(j + ww <= w) {
        o[j + ww] = max(o[j + ww], o[j] + v);
      }
    }
  }
  int ans = 0;
  rep(i, 0, w + 1) {
    ans = max(ans, o[i]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;

ll INF = 1145141919454519;

ll mod = 1e9 + 7;

ll ruijo[61];

ll fast_pow(ll a, ll n){
    if(n == 0) return 1;
    //べき数nが奇数, aを前にだして, a^n-1の気持ちに
    if(n % 2 == 1){
        return a * fast_pow(a, n - 1) % mod;
    }else{
        //べき数nが偶数のとき，べき数を半分にして, aをまとめる. べき数を半分にする
        return fast_pow(a * a % mod, n / 2) % mod;
    }
}


int main() {

    ll N;
    cin >> N;

    for(ll i = 0; i < N; i++){
        ll t; cin >> t;
        vec.push_back(t);
    }

    for(ll i = 0; i <= 60; i++){
        ruijo[i] = fast_pow(2, i);
    }

    vector<vector<ll > > zero_sum(N + 19, vector<ll >(61, 0));
    vector<vector<ll > > one_sum(N + 19,  vector<ll >(61, 0));

    for(ll i = 0; i < N; i++){
        //cout << vec[i] << endl;
        for(ll j = 0; j <= 60; j++){
            if((vec[i]>>j) & 1 == 1){
                //cout << 1 ;
                zero_sum[i + 1][j] = zero_sum[i][j];
                one_sum[i + 1][j] = one_sum[i][j] + 1;
            }else{
                //cout << 0 ;
                one_sum[i + 1][j] = one_sum[i][j];
                zero_sum[i + 1][j] = zero_sum[i][j] + 1;
            }
        }
    }

    ll ans = 0;
    
    for(ll i = 0; i < N; i++){
        for(ll j = 0; j <= 60; j++){
            if((vec[i]>>j) & 1 == 1){
                ll num = zero_sum[N][j] - zero_sum[i+1][j];
                ans += ruijo[j] * num % mod;
                ans %= mod;
            }else{
                ll num = one_sum[N][j] - one_sum[i+1][j];
                ans += ruijo[j] * num % mod;
                ans %= mod;
            }
        }
    }

    cout << ans << endl;
    
}

Measured memory_bytes: 309356
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll>> PP;

const ll MOD = 1e9 + 7;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second


int main() {
	ll n, ans = 0, a[200010] = { 0 }, s[200010] = { 0 }, t;
	cin >> n;
	for (int i = 1;i <= n;i++) {
		cin >> t;
		s[i] = s[i - 1] + t;
		a[i] = a[i - 1] ^ t;
	}

	int l = 1;
	for (int r = 1;r <= n;r++) {
		for (;(s[r] - s[l - 1]) != (a[r] ^ a[l - 1]);l++) {}
			ans += r - l + 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // int64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_str(char *str, int size)
{
    char format[100];
    if (size == 0)
        return 0;
    snprintf(format, sizeof(format), "%%%ds", size);
    scanf(format, str);
    return strlen(str);
}
#define STR_MAX 100001
#define BUF_SIZE (STR_MAX+50)
#define DIVISOR 1000000007

int main(void) {
    static char str[BUF_SIZE];
    int snum = get_str(str, BUF_SIZE);
    if(snum == 1) {
        printf("3\n");
        return 0;
    }

    int i;
    // Case 1: considering the number which digits are all 1
    static int64_t dp[STR_MAX+2];
    dp[snum] = 1;
    for(i = snum-1; i >= 0; i--) {
        dp[i] = (dp[i+1] * 3)%DIVISOR;
    }

    int64_t ans = 0;
    int64_t prev = 1; // 0+0
    for(i = snum-1; i >= 0; i--) {
        // stay
        if(str[i] == '0') continue;
        ans = (dp[i+1] + prev * 2)%DIVISOR;
#ifdef DEBUG
        printf("%lld %lld\n", dp[i+1], prev);
#endif
        prev = ans;
    }
    printf("%d\n", (int)ans);
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<fstream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<string>
#include<cstring>
using namespace std;
int n,k,h=1;
int main()
{
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		if(h>k)
		h+=k;
		else h*=2;
	}
	cout<<h<<endl;
	return 0;
}


Measured memory_bytes: 256
import static java.lang.String.*;
import static java.lang.System.*;

import java.io.IOException;
import java.util.Scanner;
public class Main{
	public static void main(String[] args)throws IOException{
		Scanner scan = null;
		try{
			scan = new Scanner(System.in);
			for(int z = 0; z != 3; z++){
				int[][] time = new int[2][3];
				for(int i = 0 ; i < time.length;i++){
					for(int j = 0 ;j < time[i].length;j++){
						time[i][j] = scan.nextInt();
					}
				}
				int[] sec = new int[2];
				for(int i = 0; i < 2;i++){
					sec[0] += time[0][i];
					sec[1] += time[1][i];
					sec[0] *= 60;
					sec[1] *= 60;
				}
				sec[0] += time[0][2];
				sec[1] += time[1][2];
				int second = sec[1] - sec[0];
				int hour = second /3600;
				second %= 3600;
				int minute = second /60;
				second %= 60;
				out.println(valueOf(hour)+" "+valueOf(minute) +" "+valueOf(second));
			}
		}finally{
			if(scan !=null)scan.close();
		}
	}
}

Measured memory_bytes: 17176
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <bitset>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif


int main(int argc, char **argv){
	int q;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	while(ifs >> q){
#else
	while(std::cin >> q){
#endif
		if(q == -1){ break; }
		double pre_x = 0.5 * q;
		double cur_x = 0;
		double cr = 0.00001 * q;

		while(fabs(pow(cur_x, 3) - q) >= cr){
			double pre_x2 = pre_x * pre_x;
			double pre_x3 = pre_x2 * pre_x;

			cur_x = pre_x - (pre_x3 - q) / (3 * pre_x2);
			pre_x = cur_x;
		}
		printf("%.6lf\n", cur_x);
	}


 
#if INPUT_FROM_FILE
	//fclose(fp);
#endif
    return 0;
}


Measured memory_bytes: 3280
#include<iostream>
using namespace std;
int N, K;
int c(int a, int b)
{
	return a/b + 1 - (a%b==0);
}
int main()
{
	cin >> N >> K;
	int where_is_one;
	for(int i = 0; i < N; i++)
	{
		int x; cin >> x;
		if(x==1)
			where_is_one = i;
	}
	if(K == N)
		cout<<1<<endl;
	else
	{
		// 0 1 2 3 4 5 6 7
		// 4 2 3 1 5 6 7 8
		// 4 # 3 $ 5 6 7 8
		int my_min = 1000000000;
		for(int i = 0; i < K; i++)
		{
			int until_left = where_is_one+1-K+ i;
			int until_right = until_left+K-1;
			if(until_left < 0 || until_right >= N)
				continue;
			int left_size = until_left;
			int right_size = N-until_right-1;
			my_min = min(my_min, 1+ c(left_size,(K-1)) + c(right_size,(K-1)));
		}
		cout<<my_min<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int p = sc.nextInt();
        int odd = 0;
        int even = 0;
        for (int i = 0; i < n; i++) {
            int m = sc.nextInt();
            if (m % 2 == 1) {
                odd++;
            } else {
                even++;
            }
        }
        long ans = 1;
        if (odd == 0) {
            if (p == 0) {
                for (int i = 0; i < n; i++) {
                    ans *= 2;
                }
            } else {
                ans = 0;
            }
        } else {
            for (int i = 0; i < n - 1; i++) {
                ans *= 2;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23636
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<vector>
#include<algorithm>
#define mod 1000000007
using namespace std;
typedef long long ll;
const int maxn=105;
const int maxi=10005;
int main()
{
	int h,w,a[maxi],b[maxn][maxn],n,i,j,k;
	char now;
	while(scanf("%d%d",&h,&w)!=EOF)
	{
		scanf("%d",&n);
		for(i=1;i<=n;i++)
	    {
		    scanf("%d",&a[i]);
     	}
     	i=1;j=1;now='r';
     	for(k=1;k<=n;k++)
     	{
     		while(a[k])
     		{
     			if(now=='r')
     			{
     				while(j<=w&&a[k])
     				{
     					b[i][j]=k;
     					j++;
     					a[k]--;
					}
					if(a[k]&&j>w)
					{
						i++;
						j=w;
						now='l';
					}
				}
				else
				{
					while(j>=1&&a[k])
     				{
     					b[i][j]=k;
     					j--;
     					a[k]--;
					}
					if(a[k]&&j<1)
					{
						i++;
						j=1;
						now='r';
					}
				}
			}
		}
		for(i=1;i<=h;i++)
		{
			for(j=1;j<=w;j++)
			{
				printf("%d",b[i][j]);
				if(j!=w)
				printf(" ");
			}
			printf("\n");
	    }
	}
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << '\n';
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	string s;
	cin >> s;
	
	int ans=0;
	for(int i=0 ; i<s.size() ; ++i){
		if(s[i] == 'R'){
			int st=i;
			while(i<s.size() && s[i] == 'R')++i;
			--i;
			ans = max(ans, i-st+1);
		}
	}
	
	cout << ans;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cout << fixed << setprecision(10);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


Measured memory_bytes: 3636
/* HARDWORK IS THE KEY TO SUCCESS.
   RATING IS TEMPORARY , KNOWLEDGE IS PERMANENT.!!!*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define T int t = 1; cin>>t; while(t--)
#define ain ll n,k,i; cin>>n; ll a[n]; for(i=0; i<n; i++) cin>>a[i]
#define matin ll m,n; cin >> n >> m; ll a[n + 1][m + 1]; for(ll i=1;i<=n;i++) for(ll j=1;j<=m;j++) cin>>a[i][j];
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define I insert
#define pb push_back

const ll maxs = 1e5+3;
const ll maxs1 = 1e3+4;
const ll mod = 1e9 + 7;
inline ll add(ll a, ll b) { return (mod + a + b) % mod;}
inline ll sub(ll a, ll b) {return (a - b + mod) % mod;}
inline ll mul(ll a, ll b) {return (1ll * a * b) % mod;}
ll fastpow(ll x, ll y) {
    ll res = 1; x = x % mod; while (y > 0) { if(y & 1) res = (res * x) % mod; y = y >> 1;x = (x * x) % mod;}return res;}
ll inv(ll x) {
    return fastpow(x, mod - 2);
}


int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    unordered_set<int>s,S; 
    int x,n,i;
    cin >> n;// >> n;
    vector<int>a(n);
    for(i = 0;i < n;++i)
        cin >> a[i];
    
    int maxx = INT_MIN; 
    
    for(int e : a) 
    { 
        s.insert(e); 
        maxx = max(maxx,e); 
    } 
  
   
    for(i = 0;i < n;i++)
    { 
        if(a[i] != 0)
        { 
            for(int j = a[i] * 2;j <= maxx;j += a[i])
            { 
                if(s.find(j) != s.end()) 
                    S.insert(j); 
            } 
        } 
    } 
  
    unordered_map<int, int> mp; 
    for(int e : a) 
        mp[e]++; 
  
    vector<int>A; 
    
    for(auto it : mp)
    { 
  
        if (it.second >= 2)
        { 
            if(S.find(it.F) == S.end())
            { 
                int val = it.second; 
                while (val--) 
                    A.pb(it.F); 
            } 
        } 
  
        if(S.find(it.F) != S.end())
        { 
            int val = it.second; 
   
            while (val--) 
               A.pb(it.F); 
        } 
    }
    
    cout << n - A.size();
    
}



Measured memory_bytes: 30520
#include<iostream>
#include<vector>
#include<queue>
#include<map>
using namespace std;
struct data{
  int id;
  int team;
  int ans;
  int pena;
  data(int i,int t,int a,int p):id(i),team(t),ans(a),pena(p){}
  bool operator >(const data &e)const{
    if(ans!=e.ans)      
      return ans<e.ans;
    if(pena!=e.pena)
      return pena>e.pena;
    return id>e.id;
  }  
};

int main()
{
  int n;
  for(;cin>>n,n;)
    {
      priority_queue<data,vector<data>,greater<data> >qu;
      for(int i=0;i<n;i++)
	{
	  int l,u,a,p;
	  cin>>l>>u>>a>>p;
	  qu.push(data(l,u,a,p));
	}
      int cnt=0;
      map<int,int> teamcnt;
      for(;!qu.empty();)
	{
	  data tmp=qu.top();
	  qu.pop();
	  if(cnt<10)
	    {
	      if(teamcnt[tmp.team]<3)
		{
		  cout<<tmp.id<<endl;
		  cnt++;
		  teamcnt[tmp.team]++;
		}
	    }
	  else if(cnt<20)
	    {
	      if(teamcnt[tmp.team]<2)
		{
		  cout<<tmp.id<<endl;
		  cnt++;
		  teamcnt[tmp.team]++;
		}
	    }
	  else if(cnt<26)
	    {
	      if(teamcnt[tmp.team]<1)
		{
		  cout<<tmp.id<<endl;
		  cnt++;
		  teamcnt[tmp.team]++;
		}
	    }	  
	}
    }
}

Measured memory_bytes: 1204
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
		
		int a = s.nextInt();
		int b = s.nextInt();
		
		if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0)
			System.out.print("Possible");
			else
				System.out.print("Impossible");
	}
}

Measured memory_bytes: 20820
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll inf=1e18+7;

/*
ac
違う文字を選んだら必ず新たな文字列になる
*/

int main(void){
	ll c[30]={},ans;
	string s;
	cin>>s;
	rep(i,s.size()){
		c[s[i]-'a']++;
	}
	ans=s.size()*(s.size()-1)/2;
	rep(i,26){
		ans-=c[i]*(c[i]-1)/2;
	}
	cout<<ans+1<<endl;//何もしないのも１通り
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){

    vector<int> pnum(100010);
    for (int i = 0; i < 100010;i++){
        pnum[i] = i;
    }
    pnum[0] = pnum[1] = 0;
    for (int i = 2; i <sqrt(100010) ;i++){
        for (int j = i * i; j < 100010;j+=i){
            pnum[j] = 0;
        }
    }

        vector<int> a(100010, 0);
    for (int i = 0; i < 100010; ++i) {
    if (i % 2 == 0) continue;
    if (pnum[i] && pnum[(i+1)/2]) a[i] = 1;
    }

    vector<int> s(100010,0);
    for (int i = 0; i < 100010;i++){
        s[i + 1] = s[i] + a[i];
    }

    int Q; cin >> Q;
    for (int q = 0; q < Q; ++q) {
        int l, r;
        cin >> l >> r;
        ++r;
        cout << s[r] - s[l] << endl;
    }
}

Measured memory_bytes: 1792
using System;

namespace AtCoder
{
    class B_SumofThreeIntegers_051
    {
        public static void Main()
        {
            string[] input = Console.ReadLine().Split(' ');
            var K = int.Parse(input[0]);
            var S = int.Parse(input[1]);

            var count = 0;
            for (var x = 0; x <= K; ++x)
            {
                if (S < x) { break; }

                for (var y = 0; y <= K; ++y)
                {
                    if (S < x + y) { break; }

                    var z = S - x - y;
                    if (0 <= z && z <= K) { ++count; }
                }
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
#include<stdio.h>
#define MAXSIZE 100
#define PI 3.141592653589
using namespace std;
int main(){

  while (1) {
    int n,x;
    std::cin >> n>>x;
    if(0==n&&0==x){
      break;
    }
    int cnt=0;
    for(int i=1;i<=n;i++){
      for(int j=i+1;j<=n;j++){
        for(int k=j+1;k<=n;k++){
          if(x==i+j+k)cnt++;
        }
      }
    }
    std::cout << cnt << '\n';
  }
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n;i >= 0;i--)

int degitnum(long long num){
  return to_string(num).length();
}

int main(){
  long long N;
  cin >> N;
  int lam = degitnum(N);
  for (long long i = 1; i*i <= N; i++) {
    if (N % i) continue;
    long long ff = N/i;
    int lom = degitnum(ff);
    if (lom < lam) lam = lom;
  }
  cout << lam << endl;
  return 0;
}



Measured memory_bytes: 256
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val H, W = sc.nextInt(); sc.nextLine()
    val A = Array.fill(H)(sc.nextLine().toCharArray)

    val dp = Array.fill(H, W)(0)

    var i = 0
    while (i < H && A(i)(0) == '.') {
      dp(i)(0) = 1
      i += 1
    }
    i = 0
    while (i < W && A(0)(i) == '.') {
      dp(0)(i) = 1
      i += 1
    }

    val N = 1000000000 + 7

    i = 1
    while (i < H) {
      var j = 1
      while (j < W) {
        if (A(i)(j) == '.')
          dp(i)(j) = (dp(i-1)(j) + dp(i)(j-1)) % N
        j += 1
      }
      i += 1
    }

    println(dp(H-1)(W-1))
  }

}


Measured memory_bytes: 37448
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define DB double
#define PI 3.14159265358979
#define MOD 1000000007
#define ERR 0.00000000000001
#define NUM 200010

int main(){
    char s[11], t[12];
    int len;
    scanf("%s %s",s,t);
    len = strlen(s);
    if(strncmp(s,t,len)==0){ printf("Yes"); }
    else{ printf("No"); }
    return 0;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
typedef tuple<int,int,int>tint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}


signed main(){
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    if(n<=k)cout<<n*x<<endl;
    else cout<<k*x+(n-k)*y<<endl;
    return 0;
}


Measured memory_bytes: 256
import math
N=int(input())
ans=0
for i in range(N):
    for j in range(N):
        if math.gcd(i+1,j+1)==1:
            ans+=N
        else:
            for k in range(N):

                ans+=math.gcd(math.gcd(i+1,j+1),k+1)
                
print(ans)


Measured memory_bytes: 9120
function main(input) {
  const lines = input.trim().split("\n");
  const [N, M] = lines.shift().split(' ').map(Number);
  const h = lines.shift().split(' ').map(Number);

  const isGood = Array(N).fill(true);
  for (let i = 0; i < M; i++) {
    const [a, b] = lines[i].split(' ');
    if (h[a-1] > h[b-1]) {
      isGood[b-1] = false;
    } else if (h[a-1] < h[b-1]) {
      isGood[a-1] = false;
    } else {
      isGood[a-1] = false;
      isGood[b-1] = false;
    }
  }
  const res = isGood.filter(g => g).length;
  
  console.log(res);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 57840
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  int X = A+B;
  if (X >= C) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

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

	ll N, K;

	cin >> N >> K;

	vector<ll> h(N);
	for (ll i = 0; i < N; ++i) cin >> h[i];

	vector<ll> dp(N, numeric_limits<ll>::max());
	dp[0] = 0;

	for (ll i = 0; i < N; ++i)
	{
		for (ll k = 0; k <= K; ++k)
		{
			if (i + k >= N) break;
			chmin(dp[i + k], dp[i] + abs(h[i] - h[i + k]));
		}
	}

	cout << dp[N - 1] << endl;
	//system("pause");
}


Measured memory_bytes: 1792