akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;


constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
	template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
	template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
	template<typename T> void chadd(T& a, T b) { a = a + b; }

	void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
	template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
	template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }


	// 標準入出力
	struct inp {
		std::size_t sz;
		inp(std::size_t _sz = 1) : sz(_sz) {}
		template <typename T> operator T () const { T a; std::cin >> a; return a; }
		template <typename T> operator std::vector<T>() const { vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
		template <typename T, typename U> operator std::pair<T, U>() const { T f; U s; std::cin >> f >> s; return std::pair<T, U>(f, s); }
	};

	inp inp1; // input one
}

int main() {

	ll n = inp1;

	// n - 2 * n - 4 * n - 6 という風に続いていく

	if (n % 2) Cout(0);
	else {
		ll ans = 0;
		ll num = 0;

		ll cnt = 10;
		while (n / cnt) {
			num += n / cnt;
			cnt *= 5;
		}
		ans = num;

		Cout(ans);
	}

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#define INF 1e9
#define eps 1e-6
#define MOD 1000000007
#define N 1000010
typedef long long ll;
using namespace std;

int n, t, m[N];
int a[N], sum[N << 5], L[N << 5], R[N << 5], ss, ans, k, kk, s;
int id[N];

inline int read(){
	int num = 0, b = 1;
	char c = getchar();
	while(c < '0' || c > '9')
		c == '-' ? b = -1 : 0, c = getchar();
	while(c >= '0' && c <= '9')
		num = num * 10 + c - '0', c = getchar();
	return num * b;
}

int build(int l, int r){
	int pos = ++ss;
	sum[pos] = L[pos] = R[pos] = 0;
	if(l < r){
		int mid = (l + r) >> 1;
		L[pos] = build(l, mid);
		R[pos] = build(mid + 1, r);
	}
	return pos;
}

int modify(int las, int l, int r, int x, int v){
	int pos = ++ss;
	L[pos] = L[las], R[pos] = R[las];
	sum[pos] = sum[las] + v;
	if(l < r){
		int mid = (l + r) >> 1;
		if(x <= mid) L[pos] = modify(L[las], l, mid, x, v);
		else R[pos] = modify(R[las], mid + 1, r, x, v);
	}
	return pos;
}

int query(int las, int l, int r, int x){
	if(l == r) return sum[las];
	int mid = (l + r) >> 1;
	if(x <= mid) return query(L[las], l, mid, x) + sum[R[las]];
	else return query(R[las], mid + 1, r, x);
}

int main(){
	
	n = read(), t = read();
	for(int i = 1; i <= n; i++)
		a[i] = read();
	
	id[0] = build(1, n);	
	for(int i = 1; i <= n; i++){
		k = a[i];
		if(m[k] == 0)
			id[i] = modify(id[i - 1], 1, n, i, 1);
		else{
			kk = modify(id[i - 1], 1, n, m[k], -1);
			id[i] = modify(kk, 1, n, i, 1);
		}
		m[k] = i;
	}
	for(int i = 1, u, v; i <= t; i++){
		u = read(), v = read();
		printf("%d\n", query(id[v], 1, n, u));
	}
	
	return 0;
}

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

#define mainspring cout<<"mainspring\n";
#define barrel cout<<"barrel\n";
#define escapement cout<<"escapement\n";

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define INF INT_MAX
#define NINF INT_MIN
#define fs first
#define sd second
#define tik(i,a,b) for(int i = a; i < b; i++)
#define tok(i,a,b) for(int i = a; i >= b; i--)
#define error(args...) {string _s = #args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}

typedef long long ll;
typedef unsigned long long ull;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << "\n";
    err(++it, args...);
}

int main() {

	int n, k;
	cin >> n >> k;
	int h[n];

	tik(i,0,n)
		cin >> h[i];

	int dp[n];
	dp[n-1] = 0;
	tok(i,n-2,0) {
		dp[i] = INF;
		tik(j,1,k+1) {
			if(i+j > n-1)
				break;
			dp[i] = min(dp[i], dp[i+j]+abs(h[i]-h[i+j]));
		}
		//error(i,dp[i]);
	}

	cout << dp[0];
}



Measured memory_bytes: 1024
using System;
using System.Linq;

namespace ALDS1_2_C
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			var a1 = Console.ReadLine().Split();
			var a2 = new string[a1.Length];
			a1.CopyTo(a2, 0);

			var bc = Bubble(a1);
			Console.WriteLine(string.Join(" ", a1));
			Console.WriteLine("Stable");
			Selection(a2);
			Console.WriteLine(string.Join(" ", a2));
			Console.WriteLine(a1.SequenceEqual(a2) ? "Stable" : "Not stable");

		}

		static int Bubble(string[] a)
		{
			var counter = 0;
			var n = a.Length;
			for(var i = 1; i < n; i++)
			{
				for(var j = n - 1; i <= j; j--)
				{
					if(a[j][1] < a[j - 1][1])
					{
						var tmp = a[j];
						a[j] = a[j - 1];
						a[j - 1] = tmp;
						counter++;
					}
				}
			}

			return counter;
		}

		static void Selection(string[] a)
		{
			var n = a.Length;
			for(var i = 0; i < n; i++)
			{
				var min = i;
				for(var j = i+1; j < n; j++)
				{
					if(a[j][1] < a[min][1])
					{
						min = j;
					}
				}
				var tmp = a[i];
				a[i] = a[min];
				a[min] = tmp;
			}
		}
	}
}



Measured memory_bytes: 18060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5 + 5;

int a ,b ,c ;
int main()
{
    cin >> a >> b >> c;
    if (a + b + c >= 22)cout <<"bust";
    else
        cout <<"win";


    return 0;
}


Measured memory_bytes: 256
s = int(input())

if s <= 599:
  print("8")
elif s <= 799:
  print("7")
elif s <= 999:
  print("6")
elif s <= 1199:
  print("5")
elif s <= 1399:
  print("4")
elif s <= 1599:
  print("3")
elif s <= 1799:
  print("2")
else:
  print("1")

Measured memory_bytes: 9176
package main
import "fmt"
func main() {
  var n int
  var s string
  fmt.Scan(&n,&s)
  m1 := enum(s[0:n],true)
  m2 := enum(s[n:2*n],false)
  var x int64
  for i:=0;i<n+1;i++ {
    for k,v := range m1[i] {
      x += int64(v)*int64(m2[i][k])
    }
  }
  fmt.Println(x)
}
func enum(s string,f bool) []map[string]int {
  n := len(s)
  m := make([]map[string]int,n+1)
  for i:=0;i<n+1;i++ { m[i] = map[string]int{} }
  u := 1<<uint(n)
  for i:=0;i<u;i++ {
    x,y := "",""
    for j:=0;j<n;j++ {
      if (i>>uint(j))&1 == 1 {
        x = x+s[j:j+1]
      } else {
        y = y+s[j:j+1]
      }
    }
    if f {
      m[len(x)][x+reverse(y)]++
    } else {
      m[len(y)][reverse(y)+x]++
    }
  }
  return m
}
func reverse(s string) string {
  n,r := len(s),[]rune(s)
  for i:=0;i<n-i;i++ { r[i],r[n-i-1] = r[n-i-1],r[i] }
  return string(r)
}

Measured memory_bytes: 60928
#include <iostream>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int sum = min(b,c);
    b = b-sum;
    c = c-sum;
    sum = sum*2;
    if(!c) sum+=b;
    else{
        int t = min(c,a);
        sum += t;
        c -= t;
        a -= t;
        if(c) sum+=1;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int a[100],i,j,temp;
    for(i=1;i<=10;i++){
        cin>>a[i];
    }
        temp = a[0];
        for(i=1;i<=10;i++){
        for(j=i;j<=10;j++){
            if(a[i]<a[j]){
                temp = a[i];
                a[i]=a[j];
                a[j]= temp;
            }
        }
    }
    for(i=1;i<=3;i++){
        cout<<a[i]<<endl;
    }
    return 0;

}

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

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

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

  int ans=1;
  for(int i=1;i<N;i++){
    int singi=1;
    for(int j=0;j<i;j++){
      if(H[i]<H[j]){
        singi=0;
        break ;
      }
    }
    if(singi==1) ans++;
  }

  cout<<ans;
}


Measured memory_bytes: 888
from bisect import bisect_left
n=int(input())
a=list(map(int,input().split()))
a.sort()

ans=0
for i in range(1,n-1):
  for j in range(0,i):
    k=bisect_left(a,a[i]+a[j])-i-1
    ans=ans+k
print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <cstdlib>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Graph= vector<vector<ll>>;
struct edge{ll to ; ll cost ;} ;
using graph =vector<vector<edge>> ;
#define rep(i,n) for (ll i=0; i < (n); ++i)
#define rep2(i,n,m) for(ll i=n;i<=m;i++)
#define rep3(i,n,m) for(ll i=n;i>=m;i--)
#define pb push_back
#define eb emplace_back
#define ppb pop_back
#define mpa make_pair
#define fi first
#define se second 
#define set20 cout<<fixed<<setprecision(20) ;
const ll INF=1e18 ;
inline void chmax(ll& a,ll b){a=max(a,b);}
inline void chmin(ll& a,ll b){a=min(a,b);}
double pi=acos(-1) ;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
 
 
 int main(){
  while(1){
    int a,b ;
    cin>>a>>b ;
    if(a==0&&b==0) break ;

    map<ll,ll> mp ;
    mp[a]=1;
    int kai=1 ;
   while(1){
      kai++ ;
   
    vector<ll> A(b) ;
    int i=0 ;
    while(a>0){
      A[i]=a%10 ;
      a/=10 ;
      i++ ;
    }
    sort(A.begin(),A.end()) ;
    int x =0 ;
    rep(j,b){
      x*=10 ;
      x+= A[j] ;
    }
    sort(A.rbegin(),A.rend()) ;
    int y=0 ;
    rep(j,b){
      y*=10 ;
      y+=A[j] ;
    }
    int ans= y-x ;
    int u= mp[ans] ;
    if(u!=0){
      cout<<mp[ans]-1<<" "<<ans<<" "<<kai-mp[ans]<<endl ;
      break ;
    }
    else mp[ans]=kai ;
    a= ans;
    }

  }
   return 0 ;
 }




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

int main(){
    ll n,m;
    cin>>n>>m;
    vector<int> s1;
    vector<int> s2;
    bool f=false;
    rep(i,m){
        int a,b;
        cin>>a>>b;
        if(a==1){
            s1.push_back(b);
        }
        if(b==n){
            s2.push_back(a);
        }
    }
    sort(s1.begin(),s1.end());
    sort(s2.begin(),s2.end());
    int k=0,ss1=s1.size(),ss2=s2.size();
    rep(i,ss1){
        for(int j=k;j<ss2;j++){
            if(s1[i]==s2[j]){
                f=true;
                break;
            }else if(s1[i]<s2[j]){
                k=j;
                break;
            }else continue;
        }
        if(f==true) break;
    }
    if(f==true) cout<<"POSSIBLE"<<endl;
    else cout<<"IMPOSSIBLE"<<endl;
}


Measured memory_bytes: 1276
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            int n = sc.nextInt();
            if(n==0) break;

            long[][] dp = new long[2][1<<17];

            int idx = 0;
            long max = 0;
            for(int i=0; i<n; i++){
                int m = sc.nextInt();
                int L = sc.nextInt();
                int bit = 0;
                for(int j=0; j<m; j++){
                    int s = sc.nextInt()-6;
                    int e = sc.nextInt()-6;
                    for(int k=s+1; k<=e; k++) bit ^= (1<<k);
                }
                for(int j=0; j<(1<<17); j++){
                    dp[idx][j] = Math.max(dp[idx][j], dp[1-idx][j]);
                    if((j&bit)==bit){
                        dp[idx][j] = Math.max(dp[idx][j], L + dp[1-idx][j^bit]);
                        max = Math.max(max, dp[idx][j]);
                    }
                }

                idx = 1-idx;
                Arrays.fill(dp[idx], 0);
            }

            System.out.println(max);
        }
    }

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

Measured memory_bytes: 64452
#include<stdio.h>
int isPrime(int);
int main()
{
    int n,i,count,A[10000];
    scanf("%d",&n);
    for(i = 0; i < n; i++){
        scanf("%d",&A[i]);
    if(isPrime(A[i]) == 1)
    count++;
    }
    printf("%d\n",count);
return 0;
}
int isPrime(int a)
{
    int i=3;
if(a == 2) return 1;
if(a < 2 || a%2 == 0 ) return 0;
while(i*i <= a){
    if(a%i == 0){
        return 0;
    }
    i = i+2;
}
return 1;
}


Measured memory_bytes: 2104
function main (s) {
    s=s.split("\n");
	for(var i=0;i<3;i++){
		s[i]=parseInt(s[i]);
	}
	console.log((s[0]+s[1])*s[2]/2);
}
 
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
package main

import (
	"bufio"
	"fmt"
	"os"
)

const (
	None = iota
	Up
	Left
	UpLeft
)

func main() {
	s, t := ReadString(), ReadString()
	dp := make([][]int, len(s)+1)
	prev := make([][]int, len(s)+1)
	for i := 0; i < len(s)+1; i++ {
		dp[i] = make([]int, len(t)+1)
		prev[i] = make([]int, len(t)+1)
	}
	for i := 1; i <= len(s); i++ {
		for j := 1; j <= len(t); j++ {
			dp[i][j] = dp[i-1][j]
			prev[i][j] = Up
			if dp[i][j] < dp[i][j-1] {
				dp[i][j] = dp[i][j-1]
				prev[i][j] = Left
			}
			if s[i-1] == t[j-1] && dp[i][j] < dp[i-1][j-1]+1 {
				dp[i][j] = dp[i-1][j-1] + 1
				prev[i][j] = UpLeft
			}
		}
	}

	ans := ""
	i, j := len(s), len(t)
	for i > 0 && j > 0 {
		switch prev[i][j] {
		case UpLeft:
			i -= 1
			j -= 1
			ans = string([]byte{s[i]}) + ans
		case Up:
			i -= 1
		case Left:
			j -= 1
		}
	}
	fmt.Println(ans)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadString() (s string) { Scan(&s); return }


Measured memory_bytes: 156924
def main():
    ans = []
    s = input()
    count = 0
    for i in s:
        if i in "ATGC":
            count += 1
        else:
            ans.append(count)
            count = 0
    ans.append(count)
    print(max(ans))
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    string abc = "ABC";

    REP(i,n) {
        if (s.substr(i,3) == abc) ans++;
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	queue<pair<string,int> > a;
    //int a[100002];
    string s1;
    int x,n,q,head,tail,t,tot=0;
    pair<string,int> u;
    cin>>n>>q;
    for (int i=0; i<n; i++){
    	cin>>s1>>t;
    	a.push(make_pair(s1,t));
	}
	while (!a.empty()){
		  u=a.front();
		  if (u.second>q){
		  	 tot+=q;
		     x=u.second-q;
		     a.pop();
			 a.push(make_pair(u.first,x));
		  }
		  else{
		  	 cout<<u.first<<' '<<u.second+tot<<endl;
		  	 tot+=u.second;
		  	 a.pop();
		  }
	}
    return 0;
} 


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

int main() {
    long long n; cin >> n;

    map<long long, long long> amt;
    vector<long long> balls(n);

    for (long long& x : balls) {
        cin >> x;
        amt[x]++;
    }

    long long total = 0;
    for (auto it : amt) {
        total += (it.second * (it.second-1));
    }

    total = total/2;

    for (long long k = 0; k < n; k++) {
        long long sub = amt[balls[k]]-1;
        cout << min(total, total-sub) << endl;
    }
}

Measured memory_bytes: 11008
#include <iostream>
#include <algorithm>
#include <string>
#include <functional> 
#include <vector>
#include <numeric>
#include <stack>
#include <queue>
#include <utility>
//#include <cmath>
#include <cstdlib>

using namespace std;

int main(){

    int n;
    cin >> n;

    vector<int> s(0);
    int mod10 = 0;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        if(a%10 != 0) s.push_back(a);
        else mod10 += a;
    }

    int sum = accumulate(s.begin(),s.end(),0);
    if(sum == 0){
        cout << "0";
        return 0;
    }
    if(sum%10 != 0){
        cout << sum + mod10;
        return 0;
    }
    sort(s.begin(),s.end());

    cout << sum + mod10 - s[0];
    return 0;
}

Measured memory_bytes: 256
r, g, b, n = map(int, input().split())

count = 0
for i in range(n+1):
    rr = i * r
    for j in range(n+1):
        gg = g * j
        bb = (n - rr - gg)
        if bb >= 0 and bb % b == 0:
            count += 1

print(count)

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

int main(){
  
  int A,B;
  cin >> A >> B;
  
  int ans = 0;
  if (A == B) ans = A+B;
  else ans = max(2*A-1,2*B-1);
  cout << ans << endl;
  
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;

class Main {

	public static boolean[] sieve (int n) {

		boolean[] isPrime = new boolean[n];
		int lim = (int)Math.sqrt(n);
		Arrays.fill(isPrime, true);
		for (int i = 4; i < isPrime.length; i += 2)
			isPrime[i] = false;
		for (int i = 3; i <= lim; i += 2) {
			for (int j = 3; i * j < isPrime.length; j += 2) {
				isPrime[i * j] = false;
			}
		}
		return isPrime;
	}

	public static void main(String[] args) throws IOException {

		BufferedReader br =
			new BufferedReader(new InputStreamReader(System.in));

		ArrayList<String> ans = new ArrayList<String>();

		while (true) {

			String s = br.readLine();
			if (s == null) break;
			int n = Integer.parseInt(s);
			boolean[] isPrime = sieve(n);
			int res = 0;
			for (int i = isPrime.length - 1; i >= 2; i--) {
				if (isPrime[i]) {
					res = i;
					break;
				}
			}
			ans.add(String.valueOf(res) + " " + BigInteger.valueOf(n).nextProbablePrime().toString());
		}

		for (String p : ans) {
			System.out.println(p);
		}
	}

}

Measured memory_bytes: 10000
#include<stdio.h>
#include<string.h>

	char a[2000021];
	char s[1000010];
int main(){
	int i,j,k,n,m,cnt;
	char* p;

	/*
	a[0] = 'I';
	for(i = 1;i <= 1000001;i++){
		a[2*i-1] = 'O';
		a[2*i] = 'I':
	}
	*/

	while(scanf("%d",&n),n){
		scanf("%d%s",&m,s);

		a[0] = 'I';
		for(i = 1;i <= n;i++){
			a[2*i-1] = 'O';
			a[2*i] = 'I';
		}
		a[i*2-1] = '\0';

		cnt = 0;
		for(p = s;;p++){
			p = strstr(p,a);
			if(p == NULL)break;
			cnt++;
		}
		printf("%d\n",cnt);
	}
	return 0;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> ans(N + 1);
  for (int x = 1; x <= 100; x++) {
    for (int y = 1; y <= 100; y++) {
      for (int z = 1; z <= 100; z++) {
        const int tmp = x * x + y * y + z * z + x * y + y * z + z * x;
        if (tmp <= N) {
          ans[tmp]++;
        }
      }
    }
  }
  for (int i = 1; i <= N; i++) {
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3680
t,T,a,A,b,B=map(int,open(0).read().split())
x,y=(b-a)*t,(A-B)*T
if y-x==0:
 r="infinity"
else:
 s,t=divmod(x,y-x)
 r=max(0,s*2+(t!=0))
print(r)

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

int main(){
    int Q;
    cin >> Q;
    bool if_prime[100000];
    fill(if_prime, if_prime + 100000, true);
    if_prime[0] = false;
    if_prime[1] = false;
    for(int i = 2; i < 100000; i++){
        if(if_prime[i]){
            for(int j = i * 2; j < 100000; j += i){
                if_prime[j] = false;
            }
        }
    }
    bool if_similar_to_2017[100000];
    for(int i = 0; i < 100000; i++){
        if(i % 2){
            if_similar_to_2017[i] = (if_prime[i] && if_prime[(i + 1) / 2]);
        }else{
            if_similar_to_2017[i] = false;
        }
    }
    int cumulative_sums[100001];
    int cumulative_sum = 0;
    for(int i = 0; i < 100000; i++){
        cumulative_sums[i] = cumulative_sum;
        cumulative_sum += if_similar_to_2017[i];
    }
    cumulative_sums[100000] = cumulative_sum;
    for(int i = 0; i < Q; i++){
        int left, right;
        cin >> left >> right;
        cout << cumulative_sums[right + 1] - cumulative_sums[left] << endl;
    }
}

Measured memory_bytes: 1152
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author wnqmw
 */
public class Main {
    public static void main(String args[]) throws IOException {
        BufferedReader kb = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(kb.readLine());
        int numstones = Integer.parseInt(st.nextToken());
        int k = Integer.parseInt(st.nextToken());
        
        int[] stones = new int[numstones];
        
        st = new StringTokenizer(kb.readLine());
        for(int i = 0; i < numstones; i++){
            stones[i] = Integer.parseInt(st.nextToken());
        }
        System.out.println(dp(stones, numstones, k));
    }
    
    static int dp(int[] stones, int numstones, int k){
        int[] dp = new int[numstones];
        
        dp[0] = 0;
        for(int i = 1; i < numstones; i++){
            dp[i] = Integer.MAX_VALUE;
        }
        for(int i = 0; i < numstones; i++){
            for(int x = 1; x <= k && x+i < numstones; x++){
                
                dp[i+x] = Math.min(dp[i+x], Math.abs(stones[i]-stones[i+x])+dp[i]);
            }
        }
        return dp[numstones-1];
    }
}


Measured memory_bytes: 33292
#include <iostream>

using namespace std;
 
int main() {
    int h, w;
    
    cin >> h >> w;
    for(int j = 0 ; j < w + 2 ; j++) cout << "#";
    cout << "\n";
    for(int i = 0 ; i < h ; i++){
        string s;
        cin >> s;
        cout << "#" << s << "#" << endl;
    }
    for(int j = 0 ; j < w + 2 ; j++) cout << "#";
    cout << "\n";
}



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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> C(N), S(N), F(N);
  for (int i = 0; i < N - 1; i++) {
    cin >> C[i] >> S[i] >> F[i];
  }
  for (int i = 0; i < N - 1; i++) {
    int time = 0;
    for (int j = i; j < N - 1; j++) {
      int c = C[j], s = S[j], f = F[j];
      int k = 0;
      while (time > s + f * k) {
        k++;
      }
      time = s + f * k + c;
    }
    cout << time << '\n';
  }
  cout << 0 << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cassert>
#include <string>
#include <set>
#include <map>
#include <random>
#include <bitset>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()

using namespace std;
using ll = long long;
using ld = long double;

const int N = 100001;
ll w[N * 2], tw;
ll p[N * 2], sm[N * 2], fv[N * 2][2];
vector<int> g[N * 2], g2[N];
vector<ll> e1;
vector<vector<int>> e2;
int n, m, ans;
int c[N];
ll wq[N];

int getp(int v) {
	if (p[v] != v)
		p[v] = getp(p[v]);
	return p[v];
}

void dfs(int v) {
	if (v < n) {
		sm[v] = w[v];
		return;	
	}
	dfs(g[v][0]);
	dfs(g[v][1]);
	sm[v] = sm[g[v][0]] + sm[g[v][1]];
}

void dfs2(int v, int ps=0) {
	if (v < n)
		return;
	if (sm[v] < w[v] && !ps) {
		dfs2(g[v][0]);
		dfs2(g[v][1]);
	}
	else {
		ans++;
		g2[fv[v][0]].push_back(fv[v][1]);
		g2[fv[v][1]].push_back(fv[v][0]);
		dfs2(g[v][0], 1);
		dfs2(g[v][1], 1);
	}
}

void dfs3(int v, int cc) {
	c[v] = cc;
	wq[cc] += w[v];
	for (int u : g2[v])
		if (!c[u])
			dfs3(u, cc);
}

int main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> m;
	vector<vector<int>> e(m, vector<int>(3));
	rep(i, n) {
		cin >> w[i];
		tw += w[i];
	}
	rep(i, n * 2)
		p[i] = i;
	rep(i, m) {
		cin >> e[i][1] >> e[i][2] >> e[i][0];
		e[i][1]--; e[i][2]--;
	}
	sort(all(e));
	int en = n - 1;
	for (auto &pp : e) {
		int v1 = getp(pp[1]), v2 = getp(pp[2]);
		if (v1 == v2)
			e2.push_back(pp);
		else {
			en++;
			p[v1] = en;
			p[v2] = en;
			g[en].push_back(v1);
			g[en].push_back(v2);
			fv[en][0] = pp[1];
			fv[en][1] = pp[2];
			w[en] = pp[0];
		}
	}
	dfs(en);
	dfs2(en);
	int cc = 0;
	rep(i, n)
		if (!c[i])
			dfs3(i, ++cc);
	for (auto &pp : e2)
		if (c[pp[1]] == c[pp[2]] && wq[c[pp[1]]] >= pp[0])
			ans++;
	cout << m - ans;
}


Measured memory_bytes: 31872
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int,int>;

const long long INFLL = 1LL << 60;
const int INFI = 1000000000;


int main(){
    int N;cin >> N;
    vector<long long> A(N);
    long long s = 0;
    for(int i=0;i<N;i++) {cin >> A[i]; s+=A[i];}
    long long m=s;
    long long l = 0; long long r = s;
    for(int i=0;i<N;i++) {
        l += A[i]; r -= A[i];
        if(abs(l-r) < m) m = abs(l-r);
    }
    cout << m << endl;
}


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

cnt = 0
l_ext = []

for i in range(n-2):
  l_ext.clear()
  l_ext.append(l[i])
  l_ext.append(l[i+1])
  l_ext.append(l[i+2])
  if sorted(l_ext)[-2] == l_ext[1]:
    cnt += 1
  i += 1

print(cnt)

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

int main() {
  int N;
  cin >> N;
  vector<double> v(N);
  for (int i = 0; i < N; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  double ans = v[0];
  for (int i = 1; i < N; i++) {
    ans += v[i];
    ans /= 2.;
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;
ll n;

int main(){
	scanf("%lld",&n);
	ll b=1,m=1,ans=0,s=0;
	for(;b*10<=n;b*=10)++m;
	for(;b;b/=10){
		if(n/b)ans=max(ans,s+n/b-1+9*(m-1));
		s+=n/b;n%=b;--m;
	}
	ans=max(ans,s);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>

using namespace std;

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

const double INF = 1e40;
const double EPS = 1e-8;

int main() {
  int n;
  while (true) {
    cin >> n;
    if (n == 0) break;
    int ans = -1;
    double dif = INF;
    rep (i, n) {
      int k;
      double h, w;
      cin >> k >> h >> w;
      h /= 100;
      if (dif > abs(22 - w / h / h)) {
	ans = k;
	dif = abs(22 - w / h / h);
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1228
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    data=[]
    n = int(input())
    k = int(input())
    data=list(map(int,input().split()))
    length=0

    for ball in data:
        if ball < k-ball:
            length+=2*ball
        else:
            length+=2*(k-ball)
    print(length)

if __name__=="__main__":
    main()

Measured memory_bytes: 9184
// abc135c: City Savers
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;

#define upto(i,s,e,d) for(int i=(s);i<(e);i+=(d))
#define in(x) cin>>(x)
#define oute(x) cout<<(x)<<endl

int main(){
  int n;in(n);
  vi a(n+1);upto(i,0,n+1,1) in(a[i]);
  ll c = 0;
  upto(i,0,n,1){
    int m,bi; in(bi);
    m = min(a[i], bi); c += m;
    m = min(a[i+1], bi-m); c += m;
    a[i+1] -= m;
  }
  oute(c);
}

Measured memory_bytes: 640
N = int(input())
Ai = list(map(int,input().split()))
#N = 5
#Ai = [1, 1, 2, 2]
resulti = [0]*len(Ai)
for i in range(len(Ai)):
    resulti[Ai[i]-1]+=1

for i in range(len(resulti)):
    print (resulti[i])
print (0)
    

Measured memory_bytes: 32264
#include <bits/stdc++.h>
using namespace std;
#define make_pair(a, b) mp(a, b)
typedef pair<int, int> pii; 
typedef long long ll;
const int maxn = 2e5 + 10;
ll n, x, m, ans, cycle;
int cnt;
ll a[maxn];
int vis[maxn];
int main()
{
	scanf("%lld%lld%lld", &n, &x, &m);
	ll cur = x; 
	while(!vis[cur])
	{
		vis[cur] = ++cnt;
		a[cnt] = cur;
		cur = cur * cur % m;
	}
	if(n < vis[cur])
	{
		for(int i = 1; i <= n; ++i) ans += a[i];
		printf("%lld\n", ans);
		return 0;
	}
	for(int i = 1; i < vis[cur]; ++i) ans += a[i];
	n -= vis[cur] - 1;
	for(int i = vis[cur]; i <= cnt; ++i) cycle += a[i];
	ans += cycle * (n / (cnt - vis[cur] + 1));
	n %= (cnt - vis[cur] + 1);
	for(int i = vis[cur], j = 1; j <= n; ++i, ++j) ans += a[i];
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4576
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> p;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    for(int i = 0; i < s.length() - 1; i++) {
        if(s[i] == s[i + 1]) {
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
    }

    for(int i = 0; i < s.length() - 2; i++) {
        if(s[i] == s[i + 2]) {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }

    cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 3772
#include<iostream>
using namespace std;
int main()
{
	int W,H,x,y,r;
	cin>>W>>H>>x>>y>>r;
	if(x-r>=0&&x+r<=W&&y-r>=0&&y+r<=H)
	cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;
}


Measured memory_bytes: 3108
n = int(input())
array = list(map(int, input().split()))

count = 0
value = 1
for i in range(0, len(array)):
    if (value == array[i]):
        value += 1
    elif (value != array[i]):
        count += 1

if (value == 1):
    print(-1)
    exit()
print(count)


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


int A, B, C, X, Y;


int main() {
    scanf("%d %d %d %d %d", &A, &B, &C, &X, &Y);

    int cost = 0;
    int k = 2*min(X, Y);
    cost += C * k;
    cost += A * max(X - k/2, 0);
    cost += B * max(Y - k/2, 0);

    int cost2 = 0;
    k = 2*max(X, Y);
    cost2 += C * k;
    cost2 += A * max(X - k/2, 0);
    cost2 += B * max(Y - k/2, 0);
    if(cost2 < cost)
        cost = cost2;

    cost2 = 0;
    k = 0;
    cost2 += A * X;
    cost2 += B * Y;
    if(cost2 < cost)
        cost = cost2;

    printf("%d\n", cost);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
ll pow(ll a, ll n){
    ll res = 1LL;
    while(n){
        if(n%2==1){
            res *= a;
        }
        a *= a;
        n>>=1; 
    }
    return res;
}
signed main(){
    ll N; cin>>N;
    ll n = N;
    ll dig = 0;
    while(n){
        n/=10;
        dig++;
    }
    ll res = 0;
    for(int i=1; i<=dig; i++){
        if(i%2==0){
            continue;
        }
        else{
            if(i==dig) res += N - pow(10, i-1) + 1;
            else res += pow(10, i) - pow(10, i-1);
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<deque>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<algorithm>
#include<cmath>
#include<numeric>
using namespace std;

typedef long long LL;
const int MOD = 1e9+7;

void solve(){
	int n;
	cin>>n;
	vector<int> a(n);
	unordered_map<int,int> t;
	for(int i=0;i<n;i++){
		cin>>a[i];
		t[a[i]]++;
	}
	LL res = 0;
	for(auto item:t){
		res+=1ll * item.second*(item.second-1)/2;
	}
	for(int i=0;i<n;i++){
		int x = a[i];
		cout<<res-t[x]+1<<endl;
	}
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T = 1;
	// cin>>T;
	while(T--){
		solve();
	}
	return 0;
}


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

class Solution
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        var min = a.Min();
        var max = a.Max();

        Console.WriteLine(max - min);
    }
}

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

typedef long long ll;

int main() {
double W, H, x, y, a;
cin >> W >> H >> x >> y;
a = W * H / 2;

cout << setprecision(6) << a << ' ';
if (x == W/2 && y == H/2) cout << 1 << endl;
else cout << 0 << endl;

}

Measured memory_bytes: 256
H,W,A,B=map(int,input().split())

mod=10**9+7

n=H+W
INV=[None]*(n+1)#1/aのリストを予め作っておく.
for i in range(1,n+1):
    INV[i]=pow(i,mod-2,mod)

k=H+W-2
n=H-1
Combi1=[None]*(k+1)#Combi[i]=iCnを表す.kは必要な分だけ.
Combi1[n]=1
for i in range(n+1,k+1):
    Combi1[i]=Combi1[i-1]*i*INV[i-n] %mod

k=H+B-2
n=B-1
Combi2=[None]*(k+1)#Combi[i]=iCnを表す.kは必要な分だけ.
Combi2[n]=1
for i in range(n+1,k+1):
    Combi2[i]=Combi2[i-1]*i*INV[i-n] %mod

k=W-B-1+A
n=W-B-1
Combi3=[None]*(k+1)#Combi[i]=iCnを表す.kは必要な分だけ.
Combi3[n]=1
for i in range(n+1,k+1):
    Combi3[i]=Combi3[i-1]*i*INV[i-n] %mod




ANS=Combi1[H+W-2]
for x in range(H-A,H):
    ANS=(ANS-Combi2[x+B-1]*Combi3[(H-x-1)+W-B-1])%mod


print(ANS)

Measured memory_bytes: 22724
/**
 *	@file: A.cpp
 *	@author: Huy Le
 *	@created: 2020-08-29 19:18
**/

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define sz(x) (int)(x).size()
const char newl = '\n';

void DEBUGLOCAL() { cerr << ")" << newl; }
template<class A, class... B> 
void DEBUGLOCAL(A argc, B... argv) {
	cerr << argc;
	if(sizeof...(argv))
		cerr << ", ";
	DEBUGLOCAL(argv...);
}
#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") [" << __FUNCTION__ << "] -> (" << #__VA_ARGS__ << "): (",DEBUGLOCAL(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

int ts;
int t,d,s;

void solve() {
    cin >> d >> t >> s;
    cout << (d<=t*s?"Yes\n":"No\n");
}

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

		//++i,cout << "Case #" << i << ": ",
		solve();
}


Measured memory_bytes: 3652
#include <cmath>
#include <iostream>

using namespace std;

int main() {

	int n, a, b, c, d;

	while(1) {
		cin >> n;
		if(n==0)
			break;
		a=0;
		b=0;
		while(n!=0) {
			cin >> c >> d;
			if(c>d)
				a+=c+d;
			else if(c<d)
				b+=c+d;
			else {
				a+=c;
				b+=d;
			}
	
			n--;
		}
		cout << a << " " << b << endl;
	}


	return 0;

}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define um unordered_map
#define fi first
#define se second

int main()
{   
   fast;
    
    ll n, k; cin>>n>>k;
    ll arr[n], dp[n];
    
    for(ll i=0; i<n; i++)
    {
        cin>>arr[i];
        
        if(i==0)
            dp[i]=0;
        else if(i==1)
            dp[i]=abs(arr[i]-arr[i-1]);
        else
        {
            dp[i]=LONG_MAX;
            
            for(ll j=1; j<=k; j++)
                if(i-j>=0)
                dp[i]=min(dp[i], dp[i-j] + abs(arr[i]-arr[i-j]));
//             ll j=i-k;
//             while(j<0)
//                 j++;
//             
//             while(j<i)
//             {
//                 dp[i]=min(dp[i], dp[j] + abs(arr[i]-arr[j]));
//                 j++;
//             } 
//             
        }
    }
    
    cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 5128
package main

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

// Max min sum
func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	max := -1000000
	min := 1000000
	sum := int64(0)
	for i := 0; i < n; i++ {
		sc.Scan()
		num, _ := strconv.Atoi(sc.Text())
		if max < num {
			max = num
		}
		if num < min {
			min = num
		}
		sum += int64(num)
	}
	fmt.Printf("%v %v %v\n", min, max, sum)
}



Measured memory_bytes: 1164
N=int(input())
S=input()
MOD=10**9+7
count_char={}
for s in S:
    if s not in count_char:
        count_char[s]=1
    else:
        count_char[s]+=1
ans=1
for k,ct in count_char.items():
    ans*=ct+1
    ans%=MOD
ans+=MOD-1
ans%=MOD
print(ans)


Measured memory_bytes: 3188
#include<iostream>
#include<cstring> 
using namespace std;
int main()
{ 
    string b; 
    cin>>b;
    int k=b.size(); 
    if(b[0]==b[k-1]) 
    { 
        if(k%2==0) 
        cout<<"First"; 
        else cout<<"Second"; 
        return 0; 
        
    } 
    else
    {
        if(k%2==0) 
        cout<<"Second"; 
        else 
        cout<<"First"; 
        return 0; 
    }
    }

Measured memory_bytes: 512
import bisect
import sys

sys.setrecursionlimit(10000)
INF = float('inf')

N, Q = list(map(int, next(sys.stdin).split()))
STX = [list(map(int, next(sys.stdin).split())) for _ in range(N)]
D = [int(next(sys.stdin)) for _ in range(Q)]

ans = [-1] * Q
nexts = [-1] * Q

for s, t, x in sorted(STX, key=lambda stx: (stx[2], stx[1])):
    # [lo, hi) に出発した人は x で止まる
    # x の小さい順にソート済みなのでここで確定
    lo = max(0, bisect.bisect_left(D, s - x))
    hi = min(len(D), bisect.bisect_left(D, t - x))

    p = lo
    while p < hi:
        if nexts[p] == -1:
            ans[p] = x
            nexts[p] = hi
            p += 1
        else:
            prev = p
            p = nexts[p]
            nexts[prev] = hi

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


Measured memory_bytes: 127620
def print_num(index, a):
    print("Case " + str(index) + ": " + str(a))

if __name__ == "__main__":

    index = 1

    while(1):
        a = input()
        a = int(a)

        if a != 0:
            print_num(index, a)
            index += 1
        else:
            break



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

void insertionSort(int *A, int N){
  for(int i=1;i<N;i++){
    int v=A[i];
    int j=i-1;

    while(j>=0&&A[j]>v){
      A[j+1]=A[j];
      j--;
    }

    A[j+1]=v;

    for(int i=0;i<N;i++){
      cout<<(i?" ":"");
      cout<<A[i];
    }
    cout<<endl;
  }
}

int main(){

  int n;
  int a[110];

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    cout<<(i?" ":"");
    cout<<a[i];
  }
  cout<<endl;

  insertionSort(a, n);

  return 0;
}


Measured memory_bytes: 3096
using System;

public class p0019{
	p0019 ()
	{
		string str;
		decimal[] a = new decimal[21];
		a [0] = 1;
		for (int i = 1; i < 21; ++i)
			a [i] = a [i - 1] * i;
		
		while ((str=Console.ReadLine()) != null)
			Console.WriteLine ("{0}", a[int.Parse(str)]);
	}
	public static int Main (string[] args)
	{
		new p0019 ();
		return 0;
	}
}

Measured memory_bytes: 5608
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll N, M; cin >> N >> M;
    vvll a(1e5+1);
    rep(i, N) {
        ll b, c; cin >> b >> c;
        a[b].push_back(c);
    }

    ll ans = 0;
    priority_queue<ll> q;
    for (ll i = 1; i <= M; i++) {
        for (ll x : a[i]) q.push(x);
        if (q.size()) {
            ans += q.top(); q.pop();
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5632
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  vector<int> t(n + 1), x(n + 1), y(n + 1);
  t[0] = 0;
  x[0] = 0;
  y[0] = 0;
  for(int i = 1; i <= n; i++) {
    cin >> t[i] >> x[i] >> y[i];
  }
  for(int i = 0; i < n; i++){
    if(x[i + 1] == x[i] && y[i + 1] == y[i] && (t[i + 1] - t[i]) % 2 == 1){
      cout << "No\n";
      return 0;
    }
    int dis = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
    if(t[i + 1] - t[i] >=dis) {
      if((t[i + 1] - t[i]) % 2 == dis % 2){
        continue;
      }else{
        cout << "No\n";
        return 0;
      }
    }else{
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}

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

int h, w;
char c[1010][1010];
int tmp[1010][1010] = {};

int move_x[] = {1, -1, 0, 0};
int move_y[] = {0, 0, 1, -1};

int main(){
    cin >> h >> w;

    for(int i = 0;i < h;i++){
        cin >> c[i];
    }

    queue<pair<int, pair<int, int> > > que;

    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            if(c[i][j] == '#'){
                que.push(make_pair(0, make_pair(i, j)));
            }
        }
    }


    memset(tmp, -1, sizeof(tmp));
    while(!que.empty()){
        int y = que.front().second.first;
        int x = que.front().second.second;
        int cnt = que.front().first;

        que.pop();

        if(x < 0 || x >= w || y < 0 || y >= h) continue;

        if(tmp[y][x] == -1){
            tmp[y][x] = cnt;
            for(int i = 0;i < 4;i++){
                que.push(make_pair(cnt+1,make_pair(y+move_y[i], x+move_x[i])));
            }
        }
    }

    int ans = 0;
    for(int i = 0;i < h;i++){
        for(int j = 0;j < w;j++){
            ans = max(ans, tmp[i][j]);
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 53576
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int n;
struct node{
	string s;
	int p,id;
}r[101];
inline bool cmp(node x,node y){
	if(x.s!=y.s)return x.s<y.s;
	return x.p>y.p;
}
int main(){
	scanf("%d",&n);
	for(register int i=1;i<=n;i++){
		cin>>r[i].s>>r[i].p;
		r[i].id=i;
	}
	sort(r+1,r+1+n,cmp);
	for(register int i=1;i<=n;i++)printf("%d\n",r[i].id);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<tuple>
#include<string>
#define int long long
using namespace std;
typedef tuple<int, int, char, int, string> T;
signed main() {
	T a[123456]; int n; cin >> n;
	for (int i = 0; i < n; i++) {
		int v, w, d; char t; string s;
		cin >> v >> w >> t >> d >> s;
		a[i] = make_tuple(v, w, t, d, s);
	}
	sort(a, a + n);
	for (int i = 0; i < n; i++) cout << get<0>(a[i]) << ' ' << get<1>(a[i]) << ' ' << get<2>(a[i]) << ' ' << get<3>(a[i]) << ' ' << get<4>(a[i]) << '\n';
}


Measured memory_bytes: 14164
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func scanInt() int {
	scanner.Scan()
	a, err := strconv.Atoi(scanner.Text())
	if err != nil {
		fmt.Println(err)
	}
	return a
}

func main() {
	scanner.Split(bufio.ScanWords)

	n := scanInt()

	m := map[int]int{}
	for i := 0; i < n; i++ {
		m[scanInt()]++
	}

	for _, v := range m {
		if v > 1 {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}


Measured memory_bytes: 12672
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    int sum=0;
    for(int i=0;i<k;i++)
    {
        int m=1000;
        for(int j=0;j<n;j++)
        {
            if(a[j]<m)
                m=a[j];
        }
        sum+=m;
        for(int k=0;k<n;k++)
        {
            if(a[k]==m)
            {
                a[k]=1000;
                break;
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}


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

using namespace std;
//using namespace __gnu_pbds;

#define ss second
#define ff first
#define int long long
//#define double long double
#define pb push_back


const int N = 1e6 + 51 + 51, MOD = 1e9 + 7, mod = 998244353, INF = 3e18;

mt19937 Flash_new_51(51515);

using vi = vector <int>;
using vp = vector <pair <int, int>>;

//gp_hash_table<int, int> table;

int c[N], w[N], dp[101][100001];

signed main() {
    #ifdef Flash
     freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, W;
    cin >> n >> W;
    for (int i = 1; i <= n; i++) {
        cin >> w[i] >> c[i];
    }
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= 100000; j++) dp[i][j] = INF;
    }
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = 0; j <= 100000; j++) {
            dp[i][j] = dp[i - 1][j];
            if (j >= c[i]) {
                dp[i][j] = min(dp[i][j], dp[i - 1][j - c[i]] + w[i]);
            }
        }
    }
    int ans = 0;
    for (int i = 0; i <= 100000; i++) if (dp[n][i] <= W) ans = i;
    cout << ans;
}


Measured memory_bytes: 82176
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int main() {
    long long N;
    long long ans = 0;
    cin >> N;

    // for (int i = 1; i <= N; ++i) {
    //     ans += i * (N-i+1); // sigma (N+1)*i - i^2
    // }

    // (N+1) * N*(N+1) / 2 = 3*(N+1) * (N) * (N+1) / 6
    // - N(N+1)(2N+1) / 6

    // (3N+3 - 2N-1) * N * (N+1)/6
    // (N+2)*N*(N+1)/6
    ans = (N+2)*N*(N+1)/6;

    for (int i = 1; i < N; ++i) {
        int f;
        int t;
        cin >> f >> t;
        if (t < f) {
            swap(t, f);
        }
        ans -= f * (N-t+1);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636