akhauriyash/Code-Regression huggingface dataset:
let rec solve t1 t2 a1 a2 b1 b2 =
  let la, lb = a1*t1 + a2*t2, b1*t1 + b2*t2 in
  if la = lb then "infinity" 
  else if la > lb then solve t1 t2 b1 b2 a1 a2 
  else if a1 < b1 then "0"
  else
    let d = lb - la in
    let x = (a1-b1) * t1 in
    string_of_int @@ x / d * 2 + (x mod d + d - 1) / d
let () = Scanf.scanf "%d %d %d %d %d %d" solve |> print_endline
  


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod (1000000000+7)
int abs(int a,int b){
  int c=max(a,b)-min(a,b);
  return c;
}
int d[1000];
int c[1000];
signed main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b=1;
  cin>>a;
  for(int i=1;i<=a;i++){
    b=(b*i)%mod;
  }
  //cout<<mod<<"\n";
  cout<<b<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int a,b,c,d,e;
    cin >> a >> b >> c >> d >> e;
    if(a == 0) cout << 1 << endl;
    else if(b == 0) cout << 2 << endl;
    else if(c == 0) cout << 3 << endl;
    else if(d == 0) cout << 4 << endl;
    else if(e == 0) cout << 5 << endl;
}

Measured memory_bytes: 3680
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest
import collections
#import itertools
#import heapq
#from collections import deque
#d = deque()

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline
    cnt=collections.Counter()
    n,x,m=map(int, readline().rstrip().split())
    a=x
    if n==1:
        print(a)
        return
    t=-1
    i=2
    stock=0
    nnn=0
    ans=a
    gogo=False
    b=a
    f=-1
    while i <= n:
        a=(a*a)%m
        ans+=a
        cnt[a]+=1
        if gogo==False:
            if cnt[a] == 2:
                stock+=a
                if f<0:
                    f=i
            if cnt[a] == 3:
                ans-=a
                hani=i-f
                nokori=n-i+1
                ddd=nokori//hani
                ans+=stock*ddd
                i+=ddd*hani
                i-=1
                gogo=True
                a=b
        i+=1
        b=a
    print(ans)
    #arr=list(map(int, readline().rstrip().split()))
    #n=int(readline())
    #ss=readline().rstrip()
    #yn(1)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------


Measured memory_bytes: 21320
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);

        long x = sc.nextLong();
        long kouho1 = 1;
        long kouho2 = 1;
        double standard = Math.sqrt(x);

        for (long i = (long)standard; i >= 2; i--) {
            if (x % i == 0) { // 最小の因数を求める
                while (x % i == 0) {
                    x /= i; // 最小の因数で割った数を代入する
                    if (kouho1 * i > standard) {
                        kouho2 *= i;
                    } else {
                        kouho1 *= i;
                    }
                }
            }
        }

        if (x > kouho1 * kouho2) {
            kouho2 *= kouho1;
            kouho1 = x;
        } else if (kouho1 * x >= standard) {
            kouho2 *= x;
        }  else {
            kouho1 *= x;
        }

        System.out.println(Math.max(String.valueOf(kouho1).length(), String.valueOf(kouho2).length()));
    }
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define deb(x) cout << #x << "=" << x << endl

int main() {
	// your code goes here
	ll t;
	t=1;
	while(t--)
	{
	    ll n,w;
	    cin>>n>>w;
	    ll wt[n], val[n];
	    for(ll i=0;i<n;i++)
	    {
	        cin>>wt[i]>>val[i];
	    }
	    ll t[n+1][w+1];
	    for(ll i=0;i<n+1;i++)
	    {
	        for(ll j=0;j<w+1;j++)
	        {
	            if(i==0 ||j==0)
	            t[i][j]=0;
	        }
	    }
	    for(ll i=1;i<n+1;i++)
	    {
	        for(ll j=1;j<w+1;j++)
	        {
	            if(wt[i-1]<=j)
	            {
	                t[i][j]=max(val[i-1]+t[i-1][j-wt[i-1]],t[i-1][j]);
	            }
	            else
	            {
	                t[i][j]=t[i-1][j];
	            }
	        }
	    }
	    cout<<t[n][w];
	}
	return 0;
}


Measured memory_bytes: 82436
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;



int main()
{
	long long n;
	cin >> n;
	string first = "MARCH";
	vector<long long> name(5);
	for (int i = 0; i < 5; i++) {
		name[i] = 0;
	}
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < 5; j++) {
			if (s[0] == first[j]) {
				name[j]++;
			}
		}
	}

	long long  ans = 0;
	for (int i = 0; i < 5; i++) {
		for (int j = i + 1; j < 5; j++) {
			for (int k = j + 1; k < 5; k++) {
				ans += name[i] * name[j] * name[k];
			}
		}
	}
	cout << ans  << endl;
	return 0;
}

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

void Main()
{
    int n;
    cin >> n;
    int ans = 0;
    int m = 1000000;
    for (int i = 0; i < n; i++)
    {
        int p;
        cin >> p;
        if (p<=m) {
            ans++;
            m = p;
        }
    }
    
    cout << ans << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


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

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define mitr map<int,int>:: iterator

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int32_t main()
{
    fast;
    int n;cin>>n;
    cout<<(n-1)*n/2;
}

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

int main() {
  char s[4], p = '-';
  int f = 1;
  for(int i = 0; i < 4; i++) {
    cin >> s[i];
    if(s[i] == p)
      f = 0;
    p = s[i];
  }
  cout << (f ? "Good" : "Bad") << endl;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<stack>
#include<sstream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=500+10;
int main()
{
    int n,s[N],t[N],T[N];
    while(~scanf("%d",&n)){
        n--;
        for(int i=1;i<=n;i++){
            scanf("%d%d%d",&s[i],&t[i],&T[i]);
        }
        for(int i=1;i<=n;i++){
            ll sum=s[i]+t[i];
            for(int j=i+1;j<=n;j++){
                if(sum>t[j]){
                    while(sum%T[j]!=0){
                        sum++;
                    }


                }
                else sum=t[j];
                sum+=s[j];
            }
            printf("%lld\n",sum);
        }
        printf("0\n");
    }


    return 0;
}


Measured memory_bytes: 256
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto n = lread();
    auto a = aryread();
    // writeln(a);
    long cnt;
    foreach (i; 0 .. n)
    {
        if (a[a[i] - 1] == i + 1)
        {
            // writeln(a[a[i] - 1]);
            cnt += 1;
        }
    }
    writeln(cnt / 2);
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 6744
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste

// #include "UnionFind.hpp"
// #include "power.hpp"

int value = INF;
int A[5];


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    vector<int> temp = {0, 1, 2, 3, 4};
    for (int i = 0; i < 5; i++) cin >> A[i];
    do {
        int ans = 0;
        for (int j = 0; j < 5; j++) {
            int i = temp[j];
            if (j == 4) {
                ans += A[i];
            } else {
                if (A[i] % 10 != 0) ans += A[i] + (10 - (A[i] % 10));
                else ans += A[i];
            }
        }
        value = min(value, ans);
    } while (next_permutation(temp.begin(), temp.end()));
    cout << value<< endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;//自动取模2^64 
const double pi=acos(-1.0);
const int mod = 1e9+7; // 998244353;
const int inf = 0x7fffffff;//2^31-1	
const ll INF = 0x7fffffffffffffff;
const int dx[]={-1,0,1,0},dy[]={0,1,0,-1};
//ll begin_time=clock();    ll end_time=clock();  cout<<"time = "<<end_time-begin_time<<" ms!"<<endl;
//bool operator < (const mmp &a) const{return x<a.x||x==a.x&&y<a.y;}       //map<int,map<int,int> >z;
//map<int,int>::iterator it;for(it=z.begin();it!=z.end();it++)printf("%d %d\n",it->first,it->second);
//ll poww(ll a,ll b){ll s=1;while(b){if(b&1)s=(s*a)%mod;a=(a*a)%mod;b>>=1;}return s%mod;}  //快速幂取模 
//lower_bound(begin,end,num); 第一个>=num的数字 upper_bound(begin,end,num); 第一个>num的数字,返回地址
//freopen("input.in","r",stdin);     freopen("output.out","w",stdout);      //文件读写提交 
//reverse(s.begin(),s.end());   //翻转字符串        floor(); 向下取整  ceil(); 向上取整
//数轴上的n个点移动到同一位置，移动到该组数字的中位数的总距离最短
bool isPrime(int n){if(n==2||n==3)return 1;if(n%6!=1&&n%6!=5)return 0;
int t=sqrt(n);for(int i=5;i<=t;i+=6)if(n%i==0||n%(i+2)==0)return 0;return 1;}//判断素数   


int main()
{
	ios::sync_with_stdio(false);cin.tie(0);
	ll a,b,c,d,e,f,T;
	ll z[64];
	z[0]=0;
	for(ll i=1;i<60;i++)z[i]=z[i-1]+i;
//	cin>>T;
//	while(T--)
	{
		cin>>a;
		b=sqrt(a);d=0;
		for(int i=2;i<=b;i++)
		{
			if(a%i==0)
			{
				c=0;
				while(a%i==0)
				{
					a/=i;
					c++;
				}
				
			
				for(int j=1;j<60;j++)
				{
					if(c<z[j])
					{
						d+=j-1;
						break;
					}
				}
			}
		}
		if(a!=1)d++;
		cout<<d<<endl;
		
		
	}
 
}


	

Measured memory_bytes: 3720
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

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

	private void solve() throws IOException {
		try {
			solveA();
			//			 solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int numN = nextInt();
		int numK = nextInt();

		long res = 0;

		for (int i = 1; i <= numN - numK + 1; i++) {
			long k = numK - 1;
			long n = i + numK - 1;
			long up = 1;
			for (long j = n; j > n - k; j--) {
				up *= i;
			}
			long down = 1;
			for (long j = k; j > 0; j--) {
				down *= i;
			}
			if (down == 0) {
				down = 1;
			}
			res += up / down;
		}

		out.println(res);
	}

	private void solveB() {
		int numN = nextInt();

		out.println("");
	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

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

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 21204
#!/usr/bin/env python3
#ABC114 C

n = int(input())

def dfs(s):
    if int(s) > n:
        return 0
    for c in '753':
        if s.count(c) > 0:
            continue
        else:#sが753数でないなら
            ret = 0
            break
    else:#sが753数なら
        ret = 1
    for c in '753':
        ret += dfs(s+c)#sに7,5,3を追加
    return ret

print(dfs('0'))


Measured memory_bytes: 43612
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
#define FAST_IO {ios::sync_with_stdio(0);cin.tie(0);}
using namespace std;
signed main() {
  int N; cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) cin >> d[i];
  int ans = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      ans += d[i]*d[j];
    }
  }
  cout << ans << endl;
}



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

int main(){
    string str;
    std::cin >> str;

    int N = str.size();
    int n = (str.size() - str.size()%2)/2;
    int count = 0;

    for(int i = 0; i < n; i++){
        if(str[i] != str[N-1-i]){
            count++;
        }
    }
    std::cout << count; 
}

Measured memory_bytes: 3632
N = int(input())
D = [list(map(int, input().split())) for i in range(N)]

seq = 0

for i in range(N):
  if D[i][0] == D[i][1]:
    seq += 1
    if seq == 3:
      print('Yes')
      break
  else:
    seq = 0
else:
  print('No')
    

Measured memory_bytes: 9184
n = gets.to_i
ps = gets.split.map(&:to_i)
qs = gets.split.map(&:to_i)

p_i = nil
q_i = nil

permutation = (1..n).to_a.permutation.to_a
permutation.each.with_index(1) do |array, i|
  p_i = i if array == ps
  q_i = i if array == qs
end

puts (p_i - q_i).abs

Measured memory_bytes: 6780
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
#define mod 1000000007
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int gcd(int a, int b){
    if (a == 0)  return b;
    return gcd(b % a, a);
}
void  solve(){
  ll n;
  cin>>n;
  string s="";
  while(n>0){
    int x=(n)%26;
    if(x==0) s+="z";
    else s+= getString('a'+x-1);
    n=(n-1)/26;
  }
  reverse(all(s));
  cout<<s<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 3668
r=->i{i=P[i]while P[i];i};
$<.map{|l|a,b=l.split.map &:to_i;
$m?
[a,b,N+a,N+b].map{|i|Z[j=r[N+a+b-i]]>Z[i=r[i]]||i!=j&&Z[i]+=N+P[j]=i}:Z=(
$m,*P=b;
[1]*3*N=a
)};
a=(1..N).count{|i|r[i]!=r[1]};
p (N-a)*a+~-N*N/2*1[a]-$m


Measured memory_bytes: 18684
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<numeric>
#include<map>
using namespace std;

#define R(i,s,n) for(int i=s;i<n;i++)
#define D(i,n,s) for(int i=n-1;i>=s;i--)
typedef pair<int,int> P;

const int MAX_N = 3e+2;
const int MAX_W = 1e+3;

int N,W[MAX_N];
int dp[MAX_N][MAX_N];

void solve();

int main() {

  while(cin>>N && N) {
    R(i,0,N) cin>>W[i];
    solve();
  }

  return 0;
}

void solve() {
  memset(dp,0,sizeof(dp));

  //幅ループ
  R(i,1,N){

    //縦軸
    for(int j=0; j+i<N; j++){
      int mx=0;

      //切るとこ
      for(int k=0; k<i; k++){
        //j~j+k,j+k+1~j+i
        mx=max(mx,dp[j][j+k]+dp[j+k+1][j+i]);
      }
      if(i-1 == dp[j+1][j+i-1] && abs(W[j]-W[j+i]) <= 1){
          mx = i+1;
      }
      dp[j][j+i]=mx;
    }
  }

  cout << dp[0][N-1] << endl;
}



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

int a[100001],b[100001],c[100001];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) scanf("%d",&b[i]);
	for(int i=1;i<=n;i++) scanf("%d",&c[i]);
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	sort(c+1,c+n+1);
	long long ans=0;
	for(int i=1;i<=n;i++)
		ans+=(lower_bound(a+1,a+n+1,b[i])-a-1)*(n-(upper_bound(c+1,c+n+1,b[i])-c-1));
	printf("%lld",ans);
}

Measured memory_bytes: 1408
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int C = scan.nextInt();
		int K = scan.nextInt();
		int tempT = 0;
		int tempC = 0;
		int tempB = 0;
		int Ti = 0;
		ArrayList<Integer> array = new ArrayList<Integer>();
		while (scan.hasNext()){
			array.add(scan.nextInt());
		}
		Collections.sort(array);
		Ti = array.get(0);
		tempT = Ti + K;
		tempC = 1;
		tempB = 1;
		for (int i = 1; i < array.size(); i++) {
			Ti = array.get(i);
			if (tempC < C && Ti <= tempT){
				tempC++;
			} else {
				tempB++;
				tempC = 1;
				tempT = Ti + K;
			}
		}
		System.out.println(tempB);
	}
}


Measured memory_bytes: 63752
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

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

	static void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	void run() {
		for (;sc.hasNext(); ){
		int n = sc.nextInt();

		int[] count = new int[2001];
		for (int i = 0; i <= 1000; i++) {
			for (int j = 0; j <= 1000; j++) {
				count[i + j]++;
			}
		}

		int ans = 0;
		for (int i = 0; i <= 1000; i++) {
			for (int j = 0; j <= 1000; j++) {
				if (n - i - j >= 0 && n - i - j <= 2000) {
					ans += count[n - i - j];
				}
			}
		}
		System.out.println(ans);


	}
	}

}

Measured memory_bytes: 21012
#include<bits/stdc++.h>
using namespace std;
int f[100050];
int find(int x){
	if (f[x]==x)
		return f[x];
	return f[x]=find(f[x]);
}
int main()
{
	int n;
	int m;
	cin >> n >> m;
	for (int i=1;i<=n;i++)
		f[i]=i;
	int cnt=0;
	for (int i=1;i<=m;i++){
		int x, y, z;
		cin >> x >> y >> z;
		int fx=find(x);
		int fy=find(y);
		if (fx!=fy){
			f[fx]=fy;
			cnt++;
		}
	}
	cout << n-cnt;
	return 0;
}

Measured memory_bytes: 640
package main

import (
    "bufio"
    "os"
    "strconv"
    "fmt"
    "container/heap"
)

const INF = 100000000000000


/*********** PriorityQueue ***********/
type PriorityQueue struct {
    arr []interface{}
    comp CompFunc
}

type CompFunc func(p, q interface{}) bool

func NewPriorityQueue() *PriorityQueue {
    return new(PriorityQueue)
}

func (pq PriorityQueue) Len() int {
    return len(pq.arr)
}

func (pq PriorityQueue) Swap(i, j int) {
    pq.arr[i], pq.arr[j] = pq.arr[j], pq.arr[i]
}

func (pq PriorityQueue) Less(i, j int) bool{
    return pq.comp(pq.arr[i], pq.arr[j])
}

func (pq *PriorityQueue) Push(x interface{}) {
    pq.arr = append(pq.arr, x)
}

func (pq *PriorityQueue) Pop() interface{} {
    n := pq.Len()
    item := pq.arr[n - 1]
    pq.arr = pq.arr[:n - 1]
    return item
}

func (pq *PriorityQueue) IsEmpty() bool {
    return pq.Len() == 0
}

/* type for edge */
type Edge struct {
    to int
    cost int
}

/* type for dijkstra */
type State struct {
    time int
    node int
}

/* dijkstra */

func dijkstra(start int, edges [][]Edge, n int, comp CompFunc) []int {
    var dist []int
    for i := 0; i < n; i++ {
        dist = append(dist, INF)
    }
    dist[start] = 0
    que := new(PriorityQueue)
    que.comp = comp
    heap.Push(que, State{time: 0, node:start})
    for !que.IsEmpty() {
        state := heap.Pop(que).(State)
        for _, edge := range edges[state.node] {
            newTime := state.time + edge.cost
            if dist[edge.to] > newTime {
                dist[edge.to] = newTime
                heap.Push(que, State{time: newTime, node: edge.to})
            }
        }
    }
    return dist
}
/* input */
var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
    sc.Scan()
    n, _ := strconv.Atoi(sc.Text())
    return n
}

func main() {
    sc.Split(bufio.ScanWords)
    n := readInt()
    var edges [][]Edge
    for i := 0; i < n; i++ {
        edges = append(edges, make([]Edge, 0))
    }
    for i := 0; i < n - 1; i++ {
        a, b, c := readInt() - 1, readInt() - 1, readInt()
        edges[a] = append(edges[a], Edge{to: b, cost: c})
        edges[b] = append(edges[b], Edge{to: a, cost: c})
    }

    var comp CompFunc
    comp = func(p, q interface{}) bool {
        return p.(State).time < q.(State).time
    }
    
    q, k := readInt(), readInt() - 1
    dist := dijkstra(k, edges, n, comp)
    wtr := bufio.NewWriter(os.Stdout)
    for i := 0; i < q; i++ {
        x, y := readInt() - 1, readInt() - 1
        fmt.Fprintln(wtr, dist[x] + dist[y])
        wtr.Flush()
    }
    //wtr.Flush()
}


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

int main() {
  int n, s;
  cin>>n>>s;
  int a[n];
  for (int i=0; i<n; i++) cin>>a[i];
  long long mod = 998244353;
  long long dp[s+1];
  for (int i=0; i<=s; i++) dp[i] = 0;
  dp[0] = 1;
  long long size = 1;
  for (int i=0; i<n; i++) {
    for (int j=s; j>0; j--) {
      if (j != a[i]) {
        dp[j] *= 2;
        dp[j] %= mod;
        if (j - a[i] >= 0) {
          dp[j] += dp[j-a[i]];
          dp[j] %= mod;
        }
      } else {
        dp[a[i]] *= 2;
        dp[a[i]] %= mod;
        dp[a[i]] += size;
        dp[a[i]] %= mod;
      }
    }
    // for (int i=0; i<=s; i++) {
    //   cout<<dp[i]<<" ";
    // }
    // cout<<endl;
    size *= 2;
    size %= mod;
  }
  cout<<dp[s]<<endl;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define ALL(a) a.begin(),a.end()
#define INIT(a,b) memset(a,b,sizeof(a))
using lint = long long int;

string convert(string L, string R) {
    int n = min(L.size(), R.size()), m = L.size();
    for_(i,0,n) if (L[m - i - 1] != R[i]) return "#";
    if (L.size() < R.size()) return R.substr(L.size());
    return L.substr(0, L.size() - R.size());
}

int N;
string S[55];
lint C[55];

int main() {
    cin >> N;
    for_(i,0,N) cin >> S[i] >> C[i];

    struct State {
        int p;
        string T;
        lint cost;
        bool operator < (const State& o) const { return cost > o.cost; }
    };

    map<string, lint> memo[2];
    priority_queue<State> que;

    for_(i,0,N) {
        int m = S[i].size();
        string L = "";
        for_(j,0,m) {
            vector<string> cand = {S[i].substr(j), S[i].substr(j + 1)};
            for (const string& R : cand) {
                string T = convert(L, R);
                if (T != "#") {
                    int p = (L.size() < R.size() ? 1 : 0);
                    que.push(State{p, T, C[i]});
                    memo[p][T] = C[i];
                }
            }
            L += S[i][j];
        }
    }

    while (!que.empty()) {
        State s = que.top(); que.pop();
        if (memo[s.p][s.T] < s.cost) continue;

        if (s.T == "") {
            cout << s.cost << endl;
            return 0;
        }

        for_(i,0,N) {
            string L = (s.p == 0 ? s.T : S[i]);
            string R = (s.p == 1 ? s.T : S[i]);

            int p = (L.size() < R.size() ? 1 : 0);
            string T = convert(L, R);
            if (memo[p].count(T) == 0) memo[p][T] = 1LL << 60;
            if (memo[p][T] > s.cost + C[i]) {
                memo[p][T] = s.cost + C[i];
                que.push(State{p, T, s.cost + C[i]});
            }
        }
    }

    cout << -1 << endl;
}

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

using namespace std;

typedef long long ll;

int main(){
    string x;
    cin >> x;
    if((int)x.size() == 3){
        cout << x[2] << x[1] << x[0] << endl;
    }
    else cout << x << endl;
    return 0;
}

Measured memory_bytes: 256
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

int main()
{
#ifdef RAHUL
    freopen("input.txt","r",stdin);
#endif


ll a, b;
cin>>a>>b;

ll arr[b];
ll sum=0;
for (int i = 0; i < b; ++i)
{
	/* code */
	cin>>arr[i];
	sum+=arr[i];
}

if(a-sum<0){
	cout<<"-1"<<endl;
}
else{
	cout<<a-sum<<endl;
}

return 0;
}

Measured memory_bytes: 3672
c={
    'S':[0]*13,
    'H':[0]*13,
    'C':[0]*13,
    'D':[0]*13
}
n=int(input())
for i in range(n):
    s,num=input().split()
    c[s][int(num)-1]=1
for i in["S","H","C","D"]:
    for j in range(13):
        if c[i][j]==0:
            print(i,j+1)


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int h, w, n, i, j, a[10005], b = 0, c;
  scanf("%d%d%d", &h, &w, &n);
  
  for(i = 0; i < n; i++){
    scanf("%d", &c);
    for(j = b; j < b + c; j++) a[j] = i+1;
    b += c;
  }
  for(i = 0; i < h*w; i++)
    cout << a[i/w%2 ? i : (i/w+1)*w-i%w-1] << ((i+1)%w ? " " : "\n");
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <string>
using namespace std;
int N,M;
typedef long long ll;
typedef pair<int,int> p;
#define NMAX 1000
vector<p> data;
ll dp[NMAX][NMAX];

int main(){

    string S ;
    cin >> S;
    int flag=0;
    for(int i=0;i<S.length();i++){

        if(i%2 == 0 ){
            if(S[i]=='R' || S[i]=='U' || S[i]=='D') continue;
            else {
                cout << "No" <<endl;                
                return 0;
            }
        }else{
            if(S[i]=='L' || S[i]=='U' || S[i]=='D') continue;
            else {
                cout << "No" <<endl;                
                return 0;
            } 
        }
    }
cout << "Yes" << endl;
}

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

const int MAXN=100+10;
int pp[MAXN]={0};
int main(){
	int n;
	while(cin>>n){
		for(int i=0;i<n;i++) cin>>pp[i];
		for(int i=0;i<n;i++){
				if(i<n-1)cout<<pp[i]<<" ";
				else cout<<pp[i]<<endl;
			} 
		for(int i=1;i<n;i++){
			int t=pp[i],j=i-1;
			while(j>=0&&pp[j]>t){
				pp[j+1]=pp[j];
				j--;
			}
			pp[j+1]=t;
		
			for(int i=0;i<n;i++){
				if(i<n-1)cout<<pp[i]<<" ";
				else cout<<pp[i]<<endl;
			} 
		}
	}
	return 0;
} 


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

ll GCD(ll a, ll b)
{
	if (b == 0) return a;
	else return GCD(b, a%b);
}

ll LCM(ll a, ll b)
{
	return a / GCD(a, b) * b;
}

int main(int argc, char **argv)
{
	ll N; cin >> N;
	ll res{0};
	for (ll i = 0; i < N; ++i)
	{
		ll a;
		cin >> a;
		--a;
		res += a;
	}

	std::cout << res  << std::endl;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

int N;
vector<int> P;

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

    cin >> N;
    P.resize(N);
    REP(i, N) { cin >> P[i]; }

    int cnt = 0;
    for(int i = 1; i <= N; ++i) {
        if(P[i-1] != i) {
            cnt++;
        }
        if(cnt > 2) {
            printf("NO\n");
            return 0;
        }
    }
    printf("YES\n");

    return 0;
}


Measured memory_bytes: 256
N,M=gets.split.map(&:to_i)
a=[0]*N
a[0]=1 if N!=1
b=[]
M.times{
  s,c=gets.split.map(&:to_i)
  if b[s]&&b[s]!=c||s==1&&c==0&&N!=1
    puts "-1"
    exit
  end
  b[s]=c
  a[s-1]=c
}
puts a.map{|x|x.to_s}*""


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

int main(){
  int N;cin>>N;
  const long mod=1000000007;
  int i=0;
  long X=1,Y=1,Z=1;
  while(i<N){
    X*=10;
    X%=mod;
    i++;
  }
  i=0;
  while(i<N){
    Y*=9;
    Y%=mod;
    i++;
  }
  i=0;
  while(i<N){
    Z*=8;
    Z%=mod;
    i++;
  }
  long ans=X-2*Y+Z;
  if(ans<0){
    while(ans<0){
      ans+=mod;
    }
  }
  else if(ans>mod){
    ans%=mod;
  }
  cout<<ans<<endl;
}

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

int main(void)
{
    int n=0,m=0,p=0,correntNum=0,penaltyNum=0;
    int countAC[100000]={},countWA[100000]={},stockWA[100000]={};
    char judge[5]={};
    scanf("%d %d",&n,&m);
    for(int i=0;i<m;i++){
        scanf("%d %s",&p,judge);
        if(strcmp(judge,"AC")==0){
            if(countAC[p-1]==0){
                countWA[p-1]+=stockWA[p-1];
            }
            countAC[p-1]=1;
        } else {
            stockWA[p-1]+=1;
        }
    }
    for(int i=0;i<n;i++){
        if(countAC[i]==1) correntNum+=1;
        if(countWA[i]!=0) penaltyNum+=countWA[i];
    }

    printf("%d %d",correntNum,penaltyNum);
    return 0;
}


Measured memory_bytes: 2900
// Header {{{
#include <bits/stdc++.h>

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}

const ll INF=1e10;
ll W,H,N;
// ll debug[100][100];
vector<ll> v(200010, INF); // x -> most left size block

signed main() {
    cin>>H>>W>>N;
    rep(i,0,N){
        ll x,y;
        cin>>x>>y;
        x--; y--;
        // debug[x][y]=1;
        v[x] = min(v[x], y);
    }

    // rep(x,0,H){
    //     rep(y,0,W){
    //         cout<<(debug[x][y]==1 ? '#' : '.');
    //     }
    //     cout<<endl;
    // }

    ll ans = 1;
    ll r = 0; // right boundary
    for (ll x = 1; x < H; x++){
        if (r >= v[x]){
            break;
        }
        ans++;
        if (r+1 < v[x]){
            r = r+1;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

#define pb push_back
#define f first
#define s second
#define mp make_pair
#define MOD 1000000007
typedef long long ll;
typedef vector<long long> vll;
typedef set<long long> sll;
typedef pair<long long, long long> pll;
typedef vector<pair<long long, long long> > vpll;
void solve(){
	int n,ans=0,a,b;
	cin>>n;
	vll v(2*n);
	for(int i=0;i<2*n;i++){
		cin>>v[i];
	}
	sort(v.begin(),v.end());
	for(int i=0;i<2*n;i+=2){
		ans+=min(v[i],v[i+1]);
	}
	cout<<ans<<"\n";
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=0,T;
	//cin>>T;
	T=1;
	for(t=0;t<T;t++){
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
    
int main(){
  int A, B;
  cin >> A >> B;
  
  int ans = 0;
  ans = max(ans, A + A - 1);
  ans = max(ans, A + B);
  ans = max(ans, B + B -1);
  
  cout << ans << endl;
}


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

int main(){
  int t,m,n;

  cin >> t;
  while(t--){
    cin >> m >> n;
    int s = m*m + n*n;
    if(s<=1){
      cout << "C\n"; continue;
    }
    int lim = ceil(sqrt(s));

    int cnt = 0;
    for(int i=-lim;i<=lim;i++){
      for(int j=-lim;j<=lim;j++){
	if(!i && !j)continue;
	int tmp = i*i+j*j;
	if((i*m+j*n)%tmp || (i*n-j*m)%tmp);
	else cnt++;
      }
    }
    cout << ((cnt==8)?"P":"C") << endl;
  }
}

Measured memory_bytes: 1156
#include <iostream>
#include <string>
#include <stack>
#include <stdlib.h>
#include <string.h>

int main(){
	std::stack<int> Stack;//スタック
	std::string lineloader;//行ローダー

	//ロード
	std::getline(std::cin, lineloader);
	char* line = new char[lineloader.size() + 1];
	strcpy(line, lineloader.c_str());
	char* tokenloader = strtok(line, " ");

	int x = 0, y = 0;//計算用変数
	while (tokenloader){
		//計算
		if (strcmp(tokenloader, "+") == 0){//演算子+
			y = Stack.top(); Stack.pop();
			x = Stack.top(); Stack.pop();
			x += y;
			Stack.push(x);
		} else if (strcmp(tokenloader, "-") == 0){//演算子-
			y = Stack.top(); Stack.pop();
			x = Stack.top(); Stack.pop();
			x -= y;
			Stack.push(x);
		} else if (strcmp(tokenloader, "*") == 0){//演算子*
			y = Stack.top(); Stack.pop();
			x = Stack.top(); Stack.pop();
			x *= y;
			Stack.push(x);
		} else {//数値
			Stack.push(atoi(tokenloader));
		}
		//順に読み込み
		tokenloader = strtok(NULL, " ");
	}

	std::cout << Stack.top() << std::endl;//出力

	return 0;
}

Measured memory_bytes: 1204
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main() { 
    int N, Q; cin >> N >> Q;
    string S; cin >> S;
    auto cter = vector<int>(N, 0);
    int ct = 0;
    for (int i=1; i<N; i++) {
        if (S[i-1] == 'A' && S[i]=='C') ct++;
        cter[i] = ct;
    }
    // for (auto v: cter) cout << v << endl;

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

Measured memory_bytes: 1472
#include <iostream>
#include <cstdio>

int main() {
    double btc;
    double jpy;
    int n;
    std::cin >> n;
    for (int i = 0; i < n; ++i) {
        double x;
        std::string y;
        std::cin >> x >> y;
        if (y == "JPY") {
            jpy += x;
        }
        else {
            btc += (x * 380000);
        }
    }
    double ans = jpy + btc;
    printf("%.5lf\n", ans);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    char c;
    int ans = 700;
    for(int i = 0; i < 3; i++){
        scanf("%c", &c);
        ans += (c == 'o' ? 100 : 0);
    }
    printf("%d", ans);
    return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<string>
#include<vector> 
#include<algorithm>
#include<map>
using namespace std;
 
 
int main() {
	long long  m, n;
	long long sum = 0, sumen = 0;
	cin >> n >> m;
	vector<pair<long long, long long>>x(n);
	for (long long i = 0; i < n; i++) {
		cin >> x[i].first >> x[i].second;
	}
	sort(x.begin(), x.end());
 
	for (long long i = 0; i < n;i++) {
		if (sum + x[i].second >= m) {
			sumen += x[i].first*(m - sum);
			break;
		}
		else {
			sumen += x[i].first*x[i].second;
			sum += x[i].second;
		}
		
	}
	cout << sumen << endl;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
bool is_hamming(int n){
	
}
int main(){
	while(1){
		int num=0,num1,num2;
		cin>>num1;
		if(num1==0)
			return 0;
		cin>>num2;
		for(int i=num2;num1<=i;i--){
			int j=i;
			while(j%5==0)
				j=j/5;
			while(j%3==0)
				j=j/3;
			while(j%2==0)
				j=j/2;
			if(j==1)
				++num;
			
		}
		cout<<num<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;
use std::f64::consts;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let R: f64 = sc.get();
    println!("{}", 2. * R * consts::PI);
}


Measured memory_bytes: 2220
#include <iostream>
 
using namespace std;
 
typedef long long ll;
 
ll pow(ll m, ll n, int M) {
  if (n == 0) return 1;
  if (n & 1) return pow(m * m % M, n >> 1, M) * m % M;
  return pow(m * m % M, n >> 1, M);
}
 
int main() {
  ll m, n;
  cin >> m >> n;
  cout << pow(m, n, 1000000007) << endl;
  return 0;
}

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

int main() {
	int n;
	while (cin >> n, n) {
		map<int, int>mp;
		rep(i, n) {
			int p, d1, d2; cin >> p >> d1 >> d2;
			mp[p] = d1 + d2;
		}
		int Max = -1, index;
		for (auto p : mp) {
			if (Max < p.second) {
				Max = p.second;
				index = p.first;
			}
		}
		cout << index << ' ' << Max << endl;
	}
}

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

int main() {
	int a, b;
	scanf("%d%d", &a, &b);
	int k = (a + b) / 2;
	if (abs(a - k) != abs(b - k)) 
		puts("IMPOSSIBLE");
	else printf("%d\n", k);
	return 0;
}

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

int main() {
	int n;
	double result = 0;
	cin >> n;
	vector<double> materials(n);
	
	for (int i = 0; i < n; i++) {
		cin >> materials.at(i);
	}
	sort(materials.begin(), materials.end());
	if (n == 1) {
		result = materials.at(0);
	}
	else if (n == 2) {
		result = (materials[0] + materials[1]) / 2;
	}
	else {
		result = (materials[0] + materials[1]) / 2;
		for (int i = 2; i < n; i++) {
			result = (result + materials[i]) / 2;
		}
	}
	
	cout << result << endl;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  string S, T;
  cin >> S >> T;

  vector< vector<int> > A(26);
  vector< vector<int> > B(26);

  REP(c, 26) REP(i, S.size()) A[S[i] - 'a'].push_back(i);
  REP(c, 26) REP(i, T.size()) B[T[i] - 'a'].push_back(i);
  sort(ALL(A));
  sort(ALL(B));
  bool ans = (A == B);
  cout << (ans ? "Yes":"No") << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

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

class Dice{
public:
  int t, s, e, n, w, b;
  Dice(){}
  Dice(int t, int s, int e, int n, int w, int b) :
    t(t), s(s), e(e), n(n), w(w), b(b) {}
  Dice moveEast()  { return Dice(w, s, t, n, b, e); }
  Dice moveNorth() { return Dice(s, b, e, t, w, n); }
  Dice moveRight() { return Dice(t, e, n, w, s, b); }
};

int main(){
  int n;

  while(cin >> n, n){
    Dice d(1, 2, 3, 5, 4, 6);
    int sum = 1;

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

      if(s == "North")      d = d.moveNorth();
      else if(s == "East")  d = d.moveEast();
      else if(s == "South") d = d.moveNorth().moveNorth().moveNorth();
      else if(s == "West")  d = d.moveEast().moveEast().moveEast();
      else if(s == "Right") d = d.moveRight();
      else                  d = d.moveRight().moveRight().moveRight();

      sum += d.t;
    }

    cout << sum << endl;
  }
}

Measured memory_bytes: 1212
n=1000
ab=Array.new(n*2+1,0)
(0..n).each do |a|
  (0..n).each do |b|
    ab[a+b]+=1
  end
end
while gets
  num,count=$_.to_i,0
  (0..num).each do |i|
    if i<=2000 and num-i<=2000 then
      count+=ab[i]*ab[num-i]
    end
  end
  p count
end

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

using namespace std;

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

  if (s[0]==s[1] && s[0]==s[2] && s[1]==s[2]){
    cout << "No" << endl;
  } else{
    cout << "Yes" << endl;
  }

  return 0;
}

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

int main() {
    ll n, k; cin >> n >> k;
    
    ll ans = k;
    REP(i, n-1) ans *= (k - 1);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    string s,t;
    cin >> s >> t;
    // sを最小に, tを最大にする
    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<>());
    cout << (s.compare(t)<0?"Yes":"No") << endl;
}


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

int main() {
    int n,m,c;
    int x;
    vector<int> b(201,0);

    cin >> n >> m >> c;
    int ans,solve=0;
    for (int i=0; i<m; i++)
        cin >> b[i];
    for (int i=0; i<n; i++) {
        ans = 0;
        for (int j=0; j<m; j++) {
            cin >> x;
            ans += x*b[j];
        }
        if (ans+c > 0)
            solve++;
    }
    cout << solve << '\n';
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i;
  int n;
  int l[100];
  int value;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&l[i]);
  }
  value=selection(l,n);
  for(i=0;i<n;i++){
    printf("%d",l[i]);
    if(i<n-1)printf(" ");
    else printf("\n");
  }
  printf("%d\n",value);
  return 0;
}
int selection(int l[],int n){
  int i;
  int j;
  int cnt=0;
  int mini;
  int temp;
  for(i=0;i<n;i++){
    mini=i;
    for(j=i;j<n;j++){
      if(l[j]<l[mini])mini=j;
    }
    if(mini!=i){
      temp=l[mini];
      l[mini]=l[i];
      l[i]=temp;
      cnt++;
    }
  }
  return cnt;
}



Measured memory_bytes: 2072
#include <iostream>

using namespace std;

#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INFTY 99999999

int color[MAX];
int M[MAX][MAX];
int d[MAX];
int p[MAX];
int n;

int dijkstra(int s)
{

	int mincost;
	int u;

	for (int i = 0; i < n; i++) {
		d[i] = INFTY;
		p[i] = -1;
	}
	d[s] = 0;

	while (true) {
		mincost = INFTY;

		for (int i = 0; i < n; i++) {
			if (color[i] != BLACK&&d[i] < mincost) {
				mincost = d[i];
				u = i;
			}
		}

		if (mincost == INFTY) {
			break;
		}

		color[u] = BLACK;

		for (int i = 0; i < n; i++) {
			if (color[i] != BLACK&&M[u][i] != INFTY) {
				if (d[u] + M[u][i] < d[i]) {
					d[i] = d[u] + M[u][i];
					p[i] = u;
					color[i] = GRAY;
				}
			}
		}


	}


	int sum = 0;

	for (int i = 0; i < n; i++) {
		sum += d[i];
	}

	return sum;


}

int main(void)
{

	cin >> n;

	int u;
	int k;
	int v;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			M[i][j] = INFTY;
		}
	}


	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v;
			cin >> M[u][v];
		}
	}

	dijkstra(0);

	for (int i = 0; i < n; i++) {
		cout << i << " " << d[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 3108