akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

struct Card{
  char suit;
  char value;
};

void bubble(struct Card A[], int n){
  int i, j;
  struct Card t;
  for ( i = 0; i < n; i++ ){
    for ( j = n-1; j >= i+1; j-- ){
      if ( A[j].value < A[j-1].value ){
	t = A[j]; A[j] = A[j-1]; A[j-1] = t;
      }
    }
  }
}

void selection(struct Card A[], int n){
  int i, j, mini;
  struct Card t;
  for ( i = 0; i < n; i++ ){
    mini = i;
    for ( j = i; j < n; j++ ){
      if ( A[j].value < A[mini].value ) mini = j;
    }
    t = A[i]; A[i] = A[mini]; A[mini] = t;
  }
}

void print(struct Card A[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( i ) printf(" ");
    printf("%c%c", A[i].suit, A[i].value);
  }
  printf("\n");
}

int isStable(struct Card C1[], struct Card C2[], int n){
  int i;
  for ( i = 0; i < n; i++ ){
    if ( C1[i].suit != C2[i].suit ) return 0;
  }
  return 1;
}

int main(){
  struct Card C1[101], C2[101];
  int n, i;
  char ch;

  scanf("%d\n", &n);
  for ( i = 0; i < n; i++ ){
    scanf("%c%c ", &C1[i].suit, &C1[i].value);
  }

  for ( i = 0; i < n; i++ ) C2[i] = C1[i];

  bubble(C1, n);
  selection(C2, n);

  print(C1, n);
  printf("Stable\n");
  print(C2, n);
  if ( isStable(C1, C2, n) ){
    printf("Stable\n");
  } else {
    printf("Not stable\n");
  }

  return 0;
}


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

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

int main(){
  ll n;
  cin >>n;
  int ans = 0;
  for(int i = 1; i<=n; i++){
    int x = i*1.08;
    if(x==n) {
      ans = i;
      break;
    }
  }
  if(ans == 0) cout << ":(" << endl;
  else cout << ans << endl;
  return 0;
}

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

#define dforsn(i,s,n) for(int i=int(n-1);i>=int(s);i--)
#define forsn(i,s,n) for(int i=int(s);i<int(n);i++)
#define forn(i,n) for(int i=0;i<int(n);i++)
#define D(a) cerr << #a << " = " << a << endl
#define all(a) a.begin(),a.end()
#define si(a) int((a).size())
typedef pair<int,int> pii;
typedef long long int ll;
typedef vector<int> vi;
#define pb emplace_back
#define mp make_pair
#define snd second
#define fst first

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    
    int a,b; cin >> a >> b;
    cout << max(0,a-2*b) << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
//using System.Numerics;
class Program
{  
    public void Slove()
    {
        var inputs = Console.ReadLine().Split();
        int n = int.Parse(inputs[0]);
        int m = int.Parse(inputs[1]);
        var shops=
            Enumerable.Range(0, n)
            .Select(x => Console.ReadLine().Split())
            .Select(x => new {value = int.Parse(x[0]), count = int.Parse(x[1])})
            .ToArray();
        long total = 0;
        foreach(var shop in shops.OrderBy(x => x.value))
        {
            int buyCount = Math.Min(m, shop.count);
            total += buyCount * (long)shop.value;
            m -= buyCount;
            if(m == 0)
                break;
        }
        System.Console.WriteLine(total);
    }
    
    static void Main(string[] args)
    {
        new Program().Slove();
    }
}


Measured memory_bytes: 25928
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

LL S;

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);

  cin >> S;
  LL sq = sqrt(S);
  while (sq*sq < S) sq++;

  LL d = sq*sq - S;
  cout << "0 0 ";
  cout << sq << " " << 1 << " ";
  cout << d << " " << sq << endl;
}


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

int main(void){
    long long int a,b,c;

    cin >> a >> b >> c;


    if(c - a - b > 0 && (c - a - b) * (c - a - b) > 4 * a * b ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>                                                                                       
using namespace std;                                                                                     
                                                                                                         
void swap(int& x, int& y){                                                                               
  int tmp = x;                                                                                           
  x = y;                                                                                                 
  y = tmp;                                                                                               
}                                                                                                        
                                                                                                         
int main(){                                                                                              
  int a,b,c;                                                                                             
  cin >> a >> b >> c;                                                                                    
  if (a>b)                                                                                               
    swap(a,b);                                                                                           
  if (a>c)                                                                                               
    swap(a,c);                                                                                           
  if (b>c)                                                                                               
    swap(b,c);                                                                                           
  cout << a << " " << b << " " << c << endl;                                                             
}                                                                                                        
                              


Measured memory_bytes: 3092
import sys

def biser(lst,func):
    n=len(lst)
    nh=n//2
    if n==1:
        if func(lst[0]):
            return lst[0]
        else:
            return -1
    if func(lst[nh]):
        return biser(lst[nh:],func)
    else:
        return biser(lst[:nh],func)

def mkns(a,s,m):
    if a==0:
        return s
    else:
        return (((s+1)<<a)|s) & m

def main():
    N,K=map(int,sys.stdin.readline().strip().split())
    a=list(map(int,sys.stdin.readline().strip().split()))
    a.sort()
    ss=[0]*(N+1)
    pm=(1<<K)-1
    mask=lambda c:(1<<K)-(1<<c)
    nn=0
    def isunnec(i):
        if a[i]>=K:
            return False
        for j in range(i+1,N):
            if a[j]>=K:
                break
            ss[i]=(((ss[i]+1)<<a[j])|ss[i]) & pm
        # print(bin(ss[i]), bin(mask(K-c)),ss[i]&mask(K-c))
        if ss[i]&mask(K-a[i])==0:
            return True
        return False
    
    for i in range(N):
        if a[i]>=K:
            break
        ss[i+1]=(((ss[i]+1)<<a[i])|ss[i]) & pm
        #if isunnec(i):
        #     nn+=1
        #for j in range(i+1,N):
        #    if a[j]>=K:
        #        break
        #    ss[i]=mkns(a[j],ss[i],pm)
        ##print(bin(ss[i]), bin(mask(K-c)),ss[i]&mask(K-c))
        #if ss[i]&mask(K-a[i])==0:
        #    nn+=1
    #m=len(list(filter(lambda x:x<K, a)))
    nn=biser(list(range(N)),isunnec)+1
    #print(list(map(bin,ss)))
    print(nn)

if __name__=='__main__':
    main()


Measured memory_bytes: 12912
from statistics import mean, median,variance,stdev
n=int(input())
nn=n//2
x=[int(i) for i in input().split()]
y=x[:]
x.sort()

low_median=median(x[:n-1])
high_median=median(x[1:])

for i in range(n):
  if y[i]<high_median:
    print(high_median)
  else:
    print(low_median)

Measured memory_bytes: 27252
#include<iostream>
using namespace std;
int main(){
  int h,w;
  while(1){
    cin>>h>>w;
    if(h==0&&w==0)break;
    for(int i=0; i<h/2; i++){
  for(int i=0; i<w/2; i++){
    cout<<"#.";
  }
  if(w%2==1){
    cout<<"#";
  }
  cout<<"\n";
   for(int i=0; i<w/2; i++){
    cout<<".#";
  }
  if(w%2==1){
    cout<<".";
  }
  cout<<"\n";
   }
    if(h%2==1){
 for(int i=0; i<w/2; i++){
    cout<<"#.";
  }
  if(w%2==1){
    cout<<"#";
  }
  cout<<"\n";
    }
    cout<<"\n";
  }
}

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

struct Node{
    int val;
    Node* left;
    Node* right;
};
Node* nil;

class Tree{
    Node* root;
    void preorder(Node* p){
        if (p == nil) return;
        cout << " " << p->val;
        preorder(p->left);
        preorder(p->right);
    }
    void inorder(Node* p){
        if (p == nil) return;
        inorder(p->left);
        cout << " " << p->val;
        inorder(p->right);
    }
public:
    Tree(){
        root = nil;
    }
    void insert(int k){
        Node* n = new Node;
        n->val   = k;
        n->left  = nil;
        n->right = nil;
        if (root == nil) {
            root = n;
            return;
        }
        Node* pos = root;
        Node* pos_p;
        while (pos != nil) {
            pos_p = pos;
            if (k < pos->val) {
                pos = pos->left;
                continue;
            }
            pos = pos->right;
        }
        if (k < pos_p->val) {
            pos_p->left = n;
        } else {
            pos_p->right = n;
        }
    }
    void print(){
        inorder(root);
        cout << endl;
        preorder(root);
        cout << endl;
    }
    void find(int k){
        Node* p = root;
        while (p != nil) {
            if (k == p->val) {
                cout << "yes" << endl;
                return;
            }
            if (k < p->val) {
                p = p->left;
            } else {
                p = p->right;
            }
        }
        cout << "no" << endl;
    }
};

int main(){
    int n;
    cin >> n;
    Tree T;
    for (int i = 0; i < n; i++) {
        string str;
        cin >> str;
        if (str == "print") {
            T.print();
            continue;
        }
        int k;
        cin >> k;
        if (str == "insert") {
            T.insert(k);
            continue;
        }
        T.find(k);
    }
    return 0;
}

Measured memory_bytes: 15692
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {


  string s;
  string t;
  cin >> s;
  cin >> t;

  int ans = 0;
  for (int i = 0; i < s.length(); ++i) {
    if (s[i] != t[i]) {
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3916
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main() {
        string s;
        cin >> s;
        int bg = 0, ed = s.size() - 1;
        int ans = 0;
        while (bg < ed) {
                if (s[bg] == 'x' && s[ed] == 'x') bg ++, ed --;
                else if (s[bg] == 'x' && s[ed] != 'x') {
                        ans ++;
                        bg ++;
                } else if (s[bg] != 'x' && s[ed] == 'x') {
                        ans ++;
                        ed --;
                } else if (s[bg] != s[ed]) {
                        return !printf("-1\n");
                } else {
                        bg ++, ed --;
                }
        }
        printf("%d\n", ans);
        return 0;
}



Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct Edge {
  int u, v, w;
};

int main() {
  int L;
  cin >> L;
  int k = 0;
  while ((1 << k) <= L) {
    k++;
  }
  k--;
  vector<Edge> ans;
  for (int i = 0; i < k; i++) {
    ans.push_back((Edge){i, i + 1, 0});
    ans.push_back((Edge){i, i + 1, 1 << i});
  }
  int r = 1 << k;
  for (int i = k - 1; i >= 0; i--) {
    if (r + (1 << i) <= L) {
      ans.push_back((Edge){i, k, r});
      r += 1 << i;
    }
  }
  cout << k + 1 << ' ' << ans.size() << endl;
  for (Edge e : ans) {
    cout << e.u + 1 << ' ' << e.v + 1 << ' ' << e.w << endl;
  }
}


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

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)

        {
            var n = Input();
            var h = Input3();
            long ans = 0;
            long cnt = 0;
           
            
            for(long i = 0; i < n-1; i++)
            {
               if(h[i]<h[i+1])
                {
                    if (ans < cnt) ans = cnt;
                    cnt = 0;
                }
                else
                {
                    cnt++;
                }
              
            }
            if (ans < cnt) ans = cnt;

            ;

            Console.WriteLine(ans);
                
                





        }

       
        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }

        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }

        public static long Gcd(long a, long b)
        {
            long x = Math.Max(a, b);
            long y = Math.Min(a, b);
            if (x % y == 0) return y;
            else return Gcd(y, x % y);
        }

        
       
    }
}


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

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	int A, B;
	long long S = 0;

	cin >> N >> M;

	vector<vector<int>> v(M + 1);
	priority_queue<int> PQ;

	for (int i = 0; i < N; i++)
	{
		cin >> A >> B;
		if (A <= M)
		{
			v[A].push_back(B);
		}
	}

	int day;
	for (int i = 0; i < M; i++)
	{
		for (auto &&elem : v[i + 1])
		{
			PQ.push(elem);
		}
		if (!PQ.empty())
		{
			S += PQ.top();
			PQ.pop();
		}
	}
	cout << S << endl;

	return 0;
}


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

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

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

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

int main() {
    string S,T;
    cin>>S>>T;
    ll ans = INF;
    ll p = S.size(),q = T.size();
    rep(i,p-q+1){
        ll cnt = 0;
        rep(j,q){
            if(S[i+j]!=T[j]) cnt++;
        }
        chmin(ans,cnt);
    }
    cout<<ans<<endl;
}

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

signed main(){
	int n,ans = INF,tatecnt[510] = {},tate = 0;
	bool flag = false;
	string s[510];
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> s[i];
		for(int j = 0;j < n;j++){
			if(s[i][j] == '#'){
				flag = true;
				tatecnt[j]++;
			}
		}
	}
	for(int i = 0;i < n;i++){
		if(tatecnt[i] == n) tate++;
	}
	if(!flag){
		cout << -1 << endl;
		return 0;
	}
	for(int i = 0;i < n;i++){
		int cnt = 0;
		for(int j = 0;j < n;j++){
			if(s[i][j] == '#') cnt++;
		}
		if(cnt == n) ans = n - tate;
		else if(tatecnt[i]) ans = min(ans,n - tate + n - cnt);
		else ans = min(ans,n - tate + n - cnt + 1);
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main()
{
  long long  n;
  cin >> n;
  long long  a = 1;
  long long  b = 1;
  long long  temp = 0;
  if(n < 10000){
    for(long long  i = 1; i < n; i++){
      if(n%i == 0){
        a = i;
        b = n/a;
        if(a > b){
           break;
        }
      }
    }
  }

  if(n >= 10000){
    for(long long  i = 1; i < n/100; i++){
      if(n%i == 0){
        a = i;
        b = n/a;
        if(a > b){
          break;
        }
      }
    }
  }

  long long  keta = 0;
  long long  larger;
  if(a > b) larger = a;
  else larger = b;
  while(larger > 0){
     keta++;
     larger /= 10;
  }
  cout << keta << endl;

  return 0;
}

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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 100000000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

ll dp[2010][2010];

int main(){
  int N;cin >> N;
  vector<int> A(N);
  int case1 = 0,case2 = 0;
  for(int i = 0;i < N;i++){
    cin >> A[i];
  }
  int ans = 0;
  for(int i = 0;i < N;i++){
    if(A[i] == i+1){
      swap(A[i],A[i+1]);
      ans++;
    }
  }
  cout << ans << endl;
}


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

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  vector<int> rev(n);
  rep(i,n){
    cin>>a[i];
  }
  rep(i,n){
    rev[a[i]-1]=i+1;
  }
  rep(i,n){
    cout<<rev[i]<<" ";
  }
}


Measured memory_bytes: 1536
/*

*/
#include<bits/stdc++.h>

using namespace std;
using ll=long long;
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n;cin>>n;
  int ans=0;
  rep2(a,1,n){
    ans+=(n-1)/a;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3624
n, m = gets.chomp.split(" ").map(&:to_i)
x = gets.chomp.split(" ").map(&:to_i).sort

if n >= m then
    puts 0
    exit
end

y = []

(m-1).times do |i|
    y << x[i+1] - x[i]
end

y = y.sort
not_visit_interval = 0

(n-1).times do
    not_visit_interval += y.pop
end

puts (x[m-1] - x[0]) - not_visit_interval

Measured memory_bytes: 11888
o = str(input())
s = str(input())
n = ""

if not len(o) == len(s):
	for i in range(min(len(o),len(s))):
		n += o[i]
		n += s[i]

	if len(o) > len(s):
		n += o[len(o)-1]

else:
	for i in range(len(o)):
		n += o[i]
		n += s[i]
		
print(n)


Measured memory_bytes: 9044
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int n, m, lmax = 0, rmax = 0, lmin = 100001, rmin = 100001;

    cin >> n >> m;

    vector<int> l(m), r(m);

    for(int i = 0;i < m;i++){
        cin >> l[i] >> r[i];
        lmax = max(lmax,l[i]);
        lmin = min (lmin,l[i]);
        rmax = max(rmax,r[i]);
        rmin = min(rmin,r[i]);
    }

    if(lmax - rmin <= 0){
        cout << abs(lmax - rmin) + 1;
    }
    else{
        cout << 0;
    }
    return 0;
}

Measured memory_bytes: 1024
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]


def bi(x, a):
    mi = 0
    ma = len(x) - 1
    while mi != ma:
        m = (mi + ma) // 2+1
        if x[m] < a:
            mi = m
        else:
            ma = m - 1
    return mi


b = [0]
for i in a:
    b.append(b[-1] + i-1)

c = {}
for l, j in enumerate(b):
    i = j % k
    if i in c:
        c[i].append(l)
    else:
        c[i] = [l]
j = 0
for i in c:
    i = c[i]
    i.sort()
    for m, l in enumerate(i):
        j += bi(i, l+k)-m
print(j)


Measured memory_bytes: 64936
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		Console.WriteLine( Map.Select(s => s.Count(c => c == '#')).Sum() == (H+W-1) ? "Possible":"Impossible");
		
	}
	int H,W;
	String[] Map;
	public Sol(){
		var d = ria();
		H = d[0]; W= d[1];
		Map = new String[H];
		for(int i=0;i<H;i++) Map[i] = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


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

using namespace std;

typedef long long ll;

int main() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k % 2) {
        cout << b - a;
    } else {
        cout << a - b;
    }
    return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main(){
    int N; cin >> N;
    VL A(N); REP(i,N) cin >> A[i]; SORT(A);
    ll ans = 1;
    REP(i,N){
        if(ans == 0) break;
        if(A[i] == 0) ans = 0;
        else if(ans <= 1000000000000000000/A[i]){
            ans *= A[i];
        }
        else{
            ans = -1;
            break;
        }
    }
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t){
        Main();
    }
    return 0;
}

Measured memory_bytes: 3976
import java.util.*;

public class Main {

    int INF = Integer.MAX_VALUE;

    public static void main(String[] args) {
        new Main().solve();
    }

    void solve() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String[] S = new String[N];
        char s, e;
        e = 'a';
        boolean ans = true;
        for (int i = 0; i < N; i++) {
            S[i] = sc.next();
            if (i > 0) {
                s = S[i].charAt(0);
                if (s != e) {
                    ans = false;
                }
            }
            e = S[i].charAt(S[i].length() - 1);
        }
        if (ans) {
            lavel:
            for (int i = 0; i < N; i++) {
                for (int j = 0; j < N; j++) {
                    if (i == j) {
                        continue;
                    }
                    if (S[i].equals(S[j])) {
                        ans = false;
                        break lavel;
                    }
                }
            }
        }
        System.out.println(ans ? "Yes" : "No");
    }
}

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


void solve(long long X, long long A){
	if (X < A) cout << 0 << "\n";
	else cout << 10 << "\n";
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
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 int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

using P = pair<int, int>;

void ask(int u, int v) { cout << "? " << u << " " << v << endl; }

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int n, s, t;
    cin >> n >> s >> t;
    vector<int> ds(n + 1), dt(n + 1);
    for(int i = 1; i <= n; i++) {
        if(s == i) {
            continue;
        }
        ask(s, i);
        cin >> ds[i];
    }
    for(int i = 1; i <= n; i++) {
        if(i == t) {
            continue;
        }
        ask(i, t);
        cin >> dt[i];
    }
    vector<P> kouho;
    for(int i = 1; i <= n; i++) {
        if(i == s || i == t) {
            continue;
        }
        if(ds[i] + dt[i] == ds[t]) {
            kouho.emplace_back(P(ds[i], i));
        }
    }
    sort(ALL(kouho));
    vector<int> ans;
    if(kouho.size()) {
        ans.emplace_back(kouho[0].second);
    }
    for(int i = 1; i < kouho.size(); i++) {
        ask(ans.back(), kouho[i].second);
        int tmp;
        cin >> tmp;
        if(ds[ans.back()] + tmp == ds[kouho[i].second]) {
            ans.emplace_back(kouho[i].second);
        }
    }
    cout << "! " << s << " ";
    for(int i = 0; i < ans.size(); i++) {
        cout << ans[i] << " ";
    }
    cout << t << endl;
}


Measured memory_bytes: 4672
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
typedef long long ll; 
using namespace std;
/*
time:
wa:
反省:
考察・解説:
*/
int main() {
    int n; cin >> n;
    vector<int>a(n);
    int sum = 0;
    int ans = 0;
    int mod_sum;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    cout << sum-n << endl;
    return 0;
}

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

ll gcd(ll lhs, ll rhs)
{
  ll a = min(lhs, rhs);
  ll b = max(lhs, rhs);
  ll r = a % b;
  while (r != 0)
  {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

int main() {
  ll N, M;
  cin >> N >> M;

  string S, T;
  cin >> S >> T;

  ll g = gcd(N, M);
  ll h = N * M / g;

  bool ok = true;
  for (ll i = 0; i < g; ++i) {
    char lhs = S[i*h/M];
    char rhs = T[i*h/N];
    if (lhs != rhs)
      ok = false;
  }

  if (ok) cout << h << endl;
  else cout << "-1"s << endl;
  return 0;
}


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

const long long int MOD = 1e9+7;
#define pb push_back
typedef long long ll;
const long long int N = 1e5;



int main(){
    int n;
    cin>>n;
    vector<vector<ll>> dp(n+5,vector<ll>(n+5,0));
    vector<ll> pref(n+5 , 0);
    ll a[n+5];
    for(int i=1;i<=n;i++){
        cin>>a[i];
        pref[i]=pref[i-1]+a[i];
        dp[i][i]=0;
    }
    for(ll i=n;i>=1;i--){
        for(ll j=i+1;j<=n;j++){
            dp[i][j]=pref[j]-pref[i-1];
            ll temp=1e18;
            for(int k=i;k<j;k++){
                temp=min(temp,dp[i][k]+dp[k+1][j]);
            }
            if(j>i+1)
            dp[i][j]+=temp;
        }
    }
    // for(int i=1;i<=n;i++){
    //     for(int j=1;j<=n;j++){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<"\n";
    // }
    cout<<dp[1][n];
    return 0;
}

Measured memory_bytes: 4908
#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 - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll inf = 1e18;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    ll n;
    cin >> n;
    vll a(n);
    REP(i, n) {
        cin >> a[i];
    }
    VSORT(a);
    vll cnt(1e6 + 10);
    REP(i, n) cnt[a[i]]++;
    vll used(1e6 + 10);
    ll res = 0;
    REP(i, n) {
        if (used[a[i]]) continue;
        else if (cnt[a[i]] == 1) res++;
        REP(j, 1e6 + 10) {
            if (a[i] * (j + 1) > a[n - 1]) break;
            used[a[i] * (j + 1)] = 1;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 20360
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };


int main() {
	int N,D;
	scanf("%d%d", &N,&D);
	if (N % (2 * D + 1) == 0)printf("%d", N / (2 * D + 1));
	else printf("%d", N / (2 * D + 1) + 1);
	



}

/*         提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
*/

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

ll dp[100];

int main() {
  int n;
  while (cin >> n){
    dp[0] = 2;
    dp[1] = 1;
    for (int i = 2; i <= n; i++) {
      dp[i] = dp[i-1] + dp[i-2];
    }
    cout << dp[n] << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, m, n) for (int i = m; i < n; ++i)
const int MOD = 1000000007;

int main() {
  int A, B;
  cin >> A >> B;
  if(B%A) cout << B - A << endl;
  else cout << A + B << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
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;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int l,r,d;
    cin >> l >> r >> d;
    cout << (r/d) - (l-1)/d << endl;
}

Measured memory_bytes: 3180
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define REP(k, n) for (ll k = 0; k < (ll)(n); ++k)
#define REPREV(k, n) for (ll k = (ll)(n)-1; k >= 0; --k)
#define FOR(k, a, b) for (ll k = (ll)(a); k < (ll)(b); ++k)
#define FORREV(k, a, b) for (ll k = (ll)(b)-1; k >= (ll)(a); --k)
#define FOREACH(e, v) for (auto e : v)

#define TGET(t, i) get<i>(t)
#define TSET(t, i, a) get<i>(t) = a
// MinHeap - priority_queue<ll, vll, greater<ll>> pq;

#define EVEN(n) ((n)&1) == 0
#define ODD(n) ((n)&1) == 1
#define MOD(x, m) ((x) % (m) + (m)) % (m)

#define SORT(v) sort(v.begin(), v.end())
#define SORTREV(v) sort(v.rbegin(), v.rend())
#define SHUFFLE(v) random_shuffle(v.begin(), v.end())
//srand(unsigned(time(0)));

#define REMOVEAT(v, i) v.erase(v.begin() + i)
#define REVERSE(v) reverse(v.begin(), v.end())

template <typename T>
void join(vector<T>& arr, string sep) {
    bool first = true;
    for (auto t : arr) {
        if (first) {
            first = false;
            cout << t;
        } else {
            cout << sep << t;
        }
    }
    cout << "\n";
}

#define POS "POSSIBLE"
#define IMPOS "IMPOSSIBLE"

// #define INF LLONG_MAX
// #define MINF LLONG_MIN
#define INF 9e18
#define MINF -INF

void solve() {
    ll n;
    cin >> n;

    ll res = 0;

    // cout << fixed << setprecision(6);
    cout << res << "\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b;
    cin >> a >> b;
    cout << a*b << endl;

    return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //const ll p = 1e9 + 7;
    //const ll p = 998244353;
    
    clock_t start = clock();
    
    ll d;
    cin >> d;
    vector<ll> c(26);
    for (ll i = 0; i < 26; i++) cin >> c[i];
    vector<vector<ll>> s(d, vector<ll>(26));
    for (ll i = 0; i < d; i++) {
        for (ll j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    
    vector<ll> w(0);
    for (ll i = 0; i < 26; i++) {
        w.push_back(i);
        for (ll j = 0; j < c[i]; j++) {
            w.push_back(i);
        }
    }
    ll m = w.size();
    
    random_device rand;
    vector<ll> ans(d);
    for (ll i = 0; i < d; i++) ans[i] = w[rand() % m];
    
    auto calc_score = [&] () {
        vector<ll> v(26, -1);
        ll ret = 0;
        for (ll i = 0; i < d; i++) {
            v[ans[i]] = i;
            ret += s[i][ans[i]];
            for (ll j = 0; j < 26; j++) {
                ret -= c[j] * (i - v[j]);
            }
        }
        return ret;
    };
    
    ll score = calc_score();
    
    while (clock() - start <= 1.95 * CLOCKS_PER_SEC) {
        ll change_at1 = rand() % d, into1 = w[rand() % m];
        ll change_at2 = rand() % d, into2 = w[rand() % m];
        ll change_at3 = rand() % d, into3 = w[rand() % m];
        ll memo1 = ans[change_at1], memo2 = ans[change_at2], memo3 = ans[change_at3];
        ll memo_score = score;
        ans[change_at1] = into1; ans[change_at2] = into2; ans[change_at3] = into3;
        score = calc_score();
        if (score < memo_score) {
            ans[change_at1] = memo1; ans[change_at2] = memo2; ans[change_at3] = memo3;
            score = memo_score;
        }
    }
    
    for (ll i = 0; i < d; i++) cout << ans[i] + 1 << endl;
    xout << score << endl;
}

Measured memory_bytes: 3792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc142/tasks/abc142_e>
 問題文============================================================
 =================================================================
 解説=============================================================
 dp[i][j] := i番目の鍵を見たとき、現在の鍵で開けれる宝箱の状態をjとしたときの最小費用
 としてdpする
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N,M; cin >> N >> M;
    vector<vector<ll>> dp(M+1,vector<ll>(1<<N,LINF));
    dp[0][0] = 0;
    for(int i = 0; i < M;i++){
        ll a,b; cin >> a >> b;
        int B = 0;
        for(int i = 0; i < b;i++){
            int c; cin >> c;
            c--;
            B += (1<<c);
        }
        
        for(int j = 0; j < (1<<N);j++){
            if(dp[i][j] == LINF) continue;
            dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
            dp[i+1][j|B] = min(dp[i+1][j|B],dp[i][j]+a);
        }
    }
    
    res = dp[M][(1<<N)-1];
    if(res == LINF) res = -1;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

int main(){
    int n, i, j, point, k;
    string s;
    cin >> n;
    int no[n];
    pair<string, pair<int, int>> p[n];
    for(i=0; i<n; i++){
        cin >> p[i].first >> p[i].second.first;
        p[i].second.second = 1;
    }
    for(i=0; i<n; i++){
        s = p[i].first;
        point = p[i].second.first;
        for(j=0; j<i; j++){
            if(p[j].first == s){
                if(p[j].second.first > point){
                    p[i].second.second++;
                }else{
                    p[j].second.second++;
                }
            }else if(p[j].first < s){
                p[i].second.second++;
            }else{
                p[j].second.second++;
            }
        }
        
    }
    for(i=0; i<n; i++){
        no[i] = p[i].second.second;
    }
    for(i=0; i<n; i++){
        for(j=0; j<n; j++){
            if(no[j] == i+1){
                cout << j+1 << '\n';
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
data class Process(val name: String, var time: Int)

fun main(args: Array<String>) {
    val n: Int
    val q: Int
    val input = readLine()
        ?.split(" ".toRegex())
    if (input != null) {
        n = input[0].toInt()
        q = input[1].toInt()
    } else {
        n = 0
        q = 0
    }
    val queue = MyQueue()
    repeat(n) {
        readLine()
            ?.split(" ")
            ?.let {
                queue.enqueue(Process(it[0], it[1].toInt()))
            }
    }
    val finishList = mutableListOf<String>()
    var totalTime = 0
    while (true) {
        try {
            val process = queue.dequeue()
            if (process.time <= q) {
                finishList.add("${process.name} ${totalTime + process.time}")
                totalTime += process.time
            } else {
                process.time -= q
                queue.enqueue(process)
                totalTime += q
            }
        } catch (e: Exception) {
            break
        }
    }
    println(finishList.joinToString("\n"))

}

class MyQueue {
    private val array = arrayOfNulls<Process>(100000)
    private var head = 0
    private var tail = 0

    fun enqueue(value: Process) {
        array[tail] = value
        tail = (tail + 1) % array.size
    }

    fun dequeue(): Process {
        val retVal = array[head]!!
        array[head] = null
        head = (head + 1) % array.size
        return retVal
    }
}


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

#define vec                vector<int>
#define vecll              vector<ll>
#define vecst              vector<string>
#define vecb               vector<bool>
#define vec2(var, n, m)    vector<vector<int>> var(n, vector<int>(m, 0))
#define vecll2(var, n, m)  vector<vector<ll>> var(n, vector<ll>(m, 0))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mp(v1, v2)       make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt(ok ? "Yes" : "No");}
//----------------------------------------------------------------
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(void) {
  ll n;
  cin >> n;
  arrll(a,n);

  ll ans=1;
  rep(i,n){
    ans = lcm(ans, a[i]);
  }

  prt(ans);
}


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

int main(){
	int pattern[31];
	pattern[0] = 1;
	pattern[1] = 1;
	pattern[2] = 2;
	for(int i = 3; i <= 30; i++){
		pattern[i] = pattern[i-1] + pattern[i-2] + pattern[i-3];
	}
	int n;
	while(cin >> n){
		if(n == 0) break;
		cout << (pattern[n] + 3649) / 3650 << endl;
	}
	return 0;
}

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

using namespace std;

long long int a[200111];
long long int f[200111];
long long int ans = 0;
int main()
{
    long long int n;
    cin >> n;

    for (long long int i = 1; i <= n; i++)
        cin >> a[i];

    for (long long int i = 1; i <= n; i++)
        if (i + a[i] <= n)
            f[i + a[i]]++;

    for (long long int i = 1; i <= n; i++)
    {
        if ((i - a[i]) > 0)
            ans+=f[i - a[i]];

    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6748
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
int main(){
  int n;
  cin>>n;
  vector<int>x(n),y(n);
  rep(i,n)cin>>x[i]>>y[i];
  auto dist =[&](int i,int j){
    double dx=x[i]-x[j];
    double dy=y[i]-y[j];
    return sqrt(dx*dx+dy*dy);
  };
  vector<int>p(n);
  rep(i,n)p[i]=i;
  double dis=0;
  int cnt=0;
  do{
      rep(i,n-1){
        dis+=dist(p[i],p[i+1]);
  }
    cnt++;
}while(next_permutation(p.begin(),p.end()));
  double ans=dis/cnt;
  printf("%.6f\n",ans);
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool ip(long long n){
	if(n==1) return false;
	for(long long i=2;i*i<=n;i++)
	if(n%i==0)
	return false;
	return true;
}
int main(){
	int q;
	cin>>q;
	vector<int> l(q),r(q);
	for(int i=0;i<q;i++) cin>>l[i]>>r[i];
	vector<int> pv(100000);
	for(int i=3;i<=100000;i++)
		if(ip(i) && ip((i+1)/2)) ++pv[i];
	for(int i=3;i<=100000;i++)
	pv[i]+=pv[i-2];
	for(int i=0;i<q;i++)
	if(l[i]==1)
	cout<<pv[r[i]]<<endl;
	else
	cout<<pv[r[i]]-pv[l[i]-2]<<endl;
}

Measured memory_bytes: 4572