akhauriyash/Code-Regression huggingface dataset:
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
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()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;
    cin>>k;
    ll mod=7%k;
    if(mod==0)return cout<<1<<"\n",0;
    ll ans=2;
    rep(i,k){
        mod=(mod*10+7)%k;
        if(mod==0)return cout<<ans<<"\n",0;
        ans++;
    }
    cout<<-1<<"\n";
}


Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  int a[4];
  cin>>a[0]>>a[1]>>a[2];
  for(int i=0;i<3;i++){
    if(a[i]==a[(i+1)%3]+a[(i+2)%3]){
      cout<<"Yes";
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
// SeeAlso: https://atcoder.jp/contests/abc055/tasks/abc055_b

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define MAX 50
#define NIL -1
#define MOD 1000000007

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// 最大公約数
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
// 最小公倍数
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x){cout << setprecision(12) << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }

ll N;

int main() {
    cin >> N;
    ll ans = 1;
    REP(i, N) {
        ans = (ans*(i+1))%MOD;
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int main(void){
    int a,b;
    int d,r;
    double f;
    cin>>a>>b;
    d=a/b;
    r=a%b;
    f=(double)a/b;
    printf("%d %d %f\n",d,r,f);
    
  
    
}



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

int main(){
	int N, M, ans = 0;
	cin >> N >> M;
	vector<int> x(M);
	vector<int> dx(M-1);
	for(int i = 0; i < M; i++)
		cin >> x.at(i);
	sort(x.begin(),x.end());
	for(int i = 0; i < M-1; i++)
		dx.at(i) = x.at(i+1) - x.at(i);
	sort(dx.begin(),dx.end());
	for(int i = 0; i < M-N; i++)
		ans += dx.at(i);
	cout << ans << endl;
	return 0;
}

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

int main() {
  int N, K;
  cin >>N >> K;  
//1
  if(N<=K){cout<<0;}
//2   
  else if(K==0){
    long long sum1 = 0;
    long long a; 
    for  (int i = 0; i < N; i++) {
    cin >> a;
    sum1 += a ;
    }
    cout<<sum1;
  }
//3  
  else{
      vector<long long> vec(N);
      long long sum2 = 0;
      for  (int i = 0; i < N; i++) {
         cin >> vec.at(i);
      }
      sort(vec.begin(), vec.end()); 
      for  (int i = 0; i < N-K; i++) {
         sum2 += vec.at(i);
      }
        printf("%ld",sum2);
  } 


}


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    long n=gl();
	    int k =NsinKeta(n,10);

        long m=9*(k-1);
        long l=(long)Math.pow(10, k-1);
        m+=(Math.floorDiv(n-l+1, l));
        System.out.println(m);
	}

	// s進数で表した時の桁数
		public static int NsinKeta(long n, long s) {
			if(n==0) return 1;

			int i=0;
			while(n!=0) {
				n=Math.floorDiv(n, s);
				i++;
			}

			return i;
		}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35624
class Stack:
    def __init__(self):
        self.stack = []

    def push(self, v):
        self.stack.append(v)

    def top(self):
        if len(self.stack) == 0:
            return None
        else:
            return self.stack[-1]

    def pop(self):
        if len(self.stack) == 0:
            return None
        else:
            return self.stack.pop()


def run():
    n, q = [int(i) for i in input().split()]
    li = [Stack() for _ in range(n)]

    for _ in range(q):
        command = input()
        if command.startswith('0'):
            t, v = [int(i) for i in command[2:].split()]
            li[t].push(v)
        elif command.startswith('1'):
            t = int(command[2:])
            v = li[t].top()
            if v is not None:
                print(v)
        elif command.startswith('2'):
            t = int(command[2:])
            li[t].pop()
        else:
            raise ValueError('invalid command')


if __name__ == '__main__':
    run()



Measured memory_bytes: 13808
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <algorithm>

using namespace std;

int main(){
    int A,B;

    cin >> A >> B;

    int sum = (B-(A/100)*100)/100;

    int checkA = A/1000;
    checkA = (checkA%10)*10 + checkA/10;

    int checkB = B/1000;
    checkB = (checkB%10)*10 + checkB/10;

    if(checkA >= A%100){
        sum++;
    }
    if(checkB > B%100){
        sum--;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
h,w,d,*l=map(int,open(0).read().split())
s=h*w+1;x=[0]*s;y=[0]*s;k=[0]*s
for i,a in enumerate(l[:s-1]):x[a]=i//w;y[a]=i%w
for i in range(d+1,s):k[i]=k[i-d]+abs(x[i]-x[i-d])+abs(y[i]-y[i-d])
for l,r in zip(l[s::2],l[s+1::2]):print(k[r]-k[l])

Measured memory_bytes: 34396
v, e = map(int, input().split())
inf = 2**32
dp = [[inf for _ in range(v)] for _ in range(v)]

'''
ワーシャルフロイドのアルゴリズム
動的計画法
'''
for i in range(v):
    dp[i][i] = 0

for i in range(e):
    s, t, d = map(int, input().split())
    dp[s][t] = d

for k in range(v):
    for i in range(v):
        if dp[i][k] >= inf:
            continue
        for j in range(v):
            if dp[k][j] >= inf:
                continue
            dp[i][j] = min([dp[i][j], dp[i][k]+dp[k][j]])

negative = False
for i in range(v):
    if dp[i][i] < 0:
        negative = True
        break

if negative:
    print("NEGATIVE CYCLE")
else:
    for i in range(v):
        ans = []
        for j in range(v):
            if dp[i][j] >= inf:
                ans.append("INF")
            else:
                ans.append(str(dp[i][j]))
        print(" ".join(ans))



Measured memory_bytes: 6020
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n];
        int max = 0;
        int maxSecond = 0;
        int maxNum = 0;

        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
            if (a[i] > max) {
                maxSecond = max;
                max = a[i];
            }
            if (a[i] != max) {
                maxSecond = Math.max(maxSecond, a[i]);
            }
        }

        for (int i = 0; i < n; i++) {
            if (a[i] == max) {
                maxNum++;
            }
        }

        if (maxNum == 1) {
            for (int i = 0; i < n; i++) {
                if (a[i] == max) {
                    System.out.println(maxSecond);
                } else {
                    System.out.println(max);
                }
            }
        } else {
            for (int i = 0; i < n; i++) {
                System.out.println(max);
            }
        }
    }
}


Measured memory_bytes: 85064
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <iomanip>
#include <string>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <map>
#include <set>

using namespace std;
using P = pair<int, int>;
using T = tuple<int, int, int>;

long long MOD = 1000000007;
long long dp[100005][4];

int A[1000][999];
bool todayState[1000][1000*999/2];
queue<int>que;
vector<int>shintyoku(1000, 0);
int endCount = 0;
int N;

bool compare_by_second(pair<int, int> a, pair<int, int> b) {
	if (a.second != b.second) {
		return a.second < b.second;
	}
	else {
		return a.first < b.first;
	}
}

bool IsSuccess(int day, int currentP) {
	bool isSuccess = false;
	if (todayState[currentP][day])return isSuccess;
	int aite = A[currentP][shintyoku[currentP]] - 1;
	if (A[aite][shintyoku[aite]] - 1 == currentP && !todayState[aite][day]) {
		todayState[currentP][day] = true;
		todayState[aite][day] = true;
		que.push(currentP);
		que.push(aite);
		shintyoku[currentP]++;
		shintyoku[aite]++;
		isSuccess = true;
		if (shintyoku[currentP] == N - 1)endCount++;
		if (shintyoku[aite] == N - 1)endCount++;
	}
	return isSuccess;
}

int main() {

	cin >> N;

	for (int i = 0; i < N;++i) {
		for (int j = 0; j < N - 1;++j) {
			cin >> A[i][j];
		}
	}

	int days = N * (N - 1) / 2;
	int ans = 0;
	for (int i = 0; i < days;++i) {
		bool isShiai = false;
		if (i == 0) {
			for (int j = 0; j < N;++j) {
				if (IsSuccess(i, j))isShiai = true;
			}
		}
		else {
			int todayP = que.size();
			for (int j = 0; j < todayP;++j) {
				int current = que.front(); que.pop();
				if (IsSuccess(i, current))isShiai = true;
			}
		}
		if (endCount == N) {
			ans = i + 1;
			break;
		}
		if (!isShiai) {
			cout << -1 << endl;
			return 0;
		}
	}

	cout << ans << endl;
}


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

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

	vector<int> vec(N);
	for( int i = 0 ; i<N ; i++){
		cin >> vec[i];

	}
	sort(vec.begin(),vec.end());
	reverse(vec.begin(),vec.end());


    int Alice = 0;
    int Bob = 0;
    for (int i = 0; i<N ; i++){
    	if(i%2 == 0){
    		Alice += vec[i];

    	}



    	else{
    		Bob += vec[i];
    	}
}

cout << Alice - Bob <<endl;
}

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

int main() {
	int n;
	while(cin >> n && n != EOF) {
		int count = 0;
		for(int a = 0; a < 10; ++a) {
			for(int b = 0; b < 10; ++b) {
				for(int c = 0; c < 10; ++c) {
					for(int d = 0; d < 10; ++d) {
						if(a + b + c + d == n) {
							count++;
						}
					}
				}
			}
		}
		
		cout << count << endl;
	}
}

Measured memory_bytes: 0
#include<iostream>
using namespace std;
long long h,n,dp[21468],a[21468],b[21468];
int main()
{
	cin>>h>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i]>>b[i];
	}
	for(int i=1;i<=20001;i++) dp[i]=0x7f7f7f7f;
	for(int i=1;i<=n;i++)
	{
		for(int j=a[i];j<=20001;j++)
		{
			dp[j]=min(dp[j],dp[j-a[i]]+b[i]);
		}
	}
	for(int i=h;i<=20001;i++) dp[h]=min(dp[h],dp[i]);
	cout<<dp[h]<<endl;
	return 0;
}


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

const long long inf = LLONG_MAX;
int n, W, res, maxv;
long long dp[100002], w[102], v[102];

int main()
{
    cin>>n>>W;
    for(int i=1; i<=n; i++)
    {
        cin>>w[i]>>v[i];
        maxv=maxv+v[i];
    }
    for(int i=1; i<=maxv; i++)
    {
        dp[i]=inf;
    }
    for(int i=1; i<=n; i++)
    {
        for(int j=maxv; j>=v[i]; j--)
        {
            if(dp[j-v[i]]!=inf)
            {
                dp[j]=min(dp[j],dp[j-v[i]]+w[i]);
            }
        }
    }
    for(int j=maxv; j>=0; j--)
    {
        if(dp[j]<=W)
        {
            cout<<j;
            return 0;
        }
    }
    return 0;
}


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

signed main(){
  int n, m; cin >> n >> m;
  priority_queue<int> Q;
  for(int i=0; i<n; i++){
    int a; cin >> a;
    Q.push(a);
  }
  
  while(m--){
    int a = Q.top(); Q.pop();
    Q.push(a/2);
  }
  
  long long res = 0;
  while(!Q.empty()){
    res += Q.top(); Q.pop();
  }
  cout << res << endl;
  
  return 0;
}

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

using namespace std;

struct priority{
	char name;
	int price;
};

int main(){
	long long int q,h,s,d;
	long long int n;
	long long int ans=0;

	priority tmp;
	vector<priority> pr;

	cin>> q>> h>> s>> d;
	cin>> n;
	n *=4;

	tmp.name= 'q';
	tmp.price= 8*q;
	pr.push_back(tmp);

	tmp.name= 'h';
	tmp.price= 4*h;
	pr.push_back(tmp);

	tmp.name= 's';
	tmp.price= 2*s;
	pr.push_back(tmp);

	tmp.name= 'd';
	tmp.price= d;
	pr.push_back(tmp);

	sort(pr.begin(), pr.end(), [](const priority& x, const priority& y){return x.price < y.price;});

	long long int iter= 0;
	while(n!=0){
		long long int price;
		long long int num;
		char item;
		item= pr.at(iter).name;

		switch(item){
			case 'q':
			price= pr.at(iter).price/8;
			num= n;
			n-=1*num;
			ans+= num*price;
			break;

			case 'h':
			price= pr.at(iter).price/4;
			num= n/2;
			n-=2*num;
			ans+= num*price;
			break;

			case 's':
			price= pr.at(iter).price/2;
			num= n/4;
			n-=4*num;
			ans+= num*price;
			break;

			case 'd':
			price= pr.at(iter).price;
			num=n/8;
			n-=8*num;
			ans+= num*price;

			break;
		}
		iter++;


	}

	cout<< ans<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<stdio.h>
#include<algorithm>
using namespace std;
int num[10005];
int main(){
	int i,n,m,sum=0;
	scanf("%d%d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d",&num[i]);
		sum+=num[i];
	}
	if(sum>n)
		puts("-1");
	else
		printf("%d\n",n-sum);
}


Measured memory_bytes: 1712
use std::env;
use std::io::*;
use std::str::*;
use std::mem;
use std::collections::HashMap;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let s = stdin.bytes().map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect::<String>();
    s.parse::<T>().ok().unwrap()
}
fn read_char() -> char {
    let c = read::<String>();
    let c = c.chars().collect::<Vec<char>>();
    c[0]
}
fn read_String_Vec() -> Vec<char> {
    let S = read::<String>();
    S.chars().collect::<Vec<char>>()
}

fn vecchar_to_String(Vs: Vec<char>) -> String {
    let mut S = String::new();
    for i in 0..Vs.len() {
        S.push(Vs[i]);
    }
    S
}

/*
A : 65
Z : 90
a : 97
z : 122
*/

/*
let N = read::<i32>();
let S = read::<String>();
let S = read_String_Vec();
let C = read_char();
*/

/*
 .to_string() : * -> String
 &*S          : String -> &str
*/

fn main() {
    // main の引数
    /*
        引数なしのときargs.len() = 1;
    */
    let args: Vec<String> = env::args().collect();

    //let mut S = ["", "", ""];
    let S0 = read_String_Vec(); // 0
    let S1 = read_String_Vec(); // 1
    let S2 = read_String_Vec(); // 2
    let mut S = [S0, S1, S2];
    let mut field: usize = 0;

    loop {
        // fiels のターン
        if S[field].len() == 0 {
            // winner
            println!("{}", (field + 65) as u8 as char);
            break;
        } else {
            field = S[field].remove(0) as usize - 97;
        }
    }

}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = 1; i <= (int)(n); i++)
#define drep(i, n) for(int i = (n)-1; i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

// Mod int
const int mod = 1000000007;
// const int mod = 998244353;
struct mint {
  ll x;
  mint():x(0){}
  mint(ll x):x((x%mod+mod)%mod){}
  // mint(ll x):x(x){}
  mint& fix() { x = (x%mod+mod)%mod; return *this;}
  mint operator-() const { return mint(0) - *this;}
  mint& operator+=(const mint& a){ if((x+=a.x)>=mod) x-=mod; return *this;}
  mint& operator-=(const mint& a){ if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint& operator*=(const mint& a){ (x*=a.x)%=mod; return *this;}
  mint operator+(const mint& a)const{ return mint(*this) += a;}
  mint operator-(const mint& a)const{ return mint(*this) -= a;}
  mint operator*(const mint& a)const{ return mint(*this) *= a;}
  bool operator<(const mint& a)const{ return x < a.x;}
  bool operator==(const mint& a)const{ return x == a.x;}
};
istream& operator>>(istream&i,mint&a){i>>a.x;return i;}
ostream& operator<<(ostream&o,const mint&a){o<<a.x;return o;}
//



int main() {
  int x, y, z, k;
  cin >> x >> y >> z >> k;
  vector<ll> a(x), b(y), c(z);
  rep(i, x) cin >> a[i];
  rep(i, y) cin >> b[i];
  rep(i, z) cin >> c[i];

  vector<ll> ab;
  rep(i, x) rep(j, y) ab.push_back(a[i] + b[j]);
  sort(ALL(ab), greater<ll>());
  ab.resize(k);

  vector<ll> abc;
  rep(i, ab.size()) rep(j, z) abc.push_back(ab[i] + c[j]);
  sort(ALL(abc), greater<ll>());
  
  rep(i, k) cout << abc[i] << endl;
}

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

int main(){
  int n;
  std::cin>>n;
  std::vector<int> ary(n);
  for(auto &&a:ary) std::cin>>a;

  int i=1;
  int num=0;
  while(i<n){
    int a = ary[i-1];
    while( i<n && ary[i]==a ){
      a = ary[i];
      i++;
    }
    bool pos = (ary[i]-ary[i-1])>0;
    while( i<n && (ary[i]==a||((ary[i]-a)>0)==pos) ){
      a = ary[i];
      i++;
    }
    if(i==n-1) num++;
    i++;
    num++;
  }

  std::cout<<((n==1)?1:num)<<std::endl;

  return 0;
}


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

typedef long long ll;

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

    ll n, k;
    cin >> n >> k;
    int a[n + 1];
    
    int f[n + 1] = {0};

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

    if (k <= n)
    {
        int dest = 1;
        while (k--)
            dest = a[dest];
        cout << dest;
        return 0;
    }


    int loopLen = 0;
    int loopStart = 0;

    int x = 0;
    int curr = 1;
    while (!loopLen)
    {
        x++;
        f[curr] = 1;
        curr = a[curr];
        if (f[curr])
        {
            loopLen = x;
            loopStart = curr;
        }
    }  

    // cout << "Loop start: " << loopStart << "\n";

    curr = 1;
    while (curr != loopStart)
    {
        k--;
        loopLen--;
        curr = a[curr];
    }
    // cout << "Loop len: " << loopLen << "\n";
    k = k % loopLen;
    while (k--)
        curr = a[curr];

    cout << curr << endl;
    return 0;
}

Measured memory_bytes: 5152
import java.io.*;
import java.util.StringTokenizer;

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;
		boolean flag = false;

		try {
			while (!(buf = br.readLine()).equals("0 0")) {
				if (flag) System.out.println("");
				StringTokenizer st = new StringTokenizer(buf);
				int a = Integer.parseInt(st.nextToken());
				int b = Integer.parseInt(st.nextToken());
				boolean First = true;
				for (int i=a;i<=b;i++) {
					if (i%4==0) {
						if (i%100==0) {
							if (i%400==0) {
								if (First) First = false;
								System.out.println(i);
							}
						} else {
							if (First) First = false;
							System.out.println(i);
						}
					}
				}
				if (First) System.out.println("NA");
				flag = true;
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 19956
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
using namespace std;
 
typedef int ll;
 
#define int long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define endl '\n'
 
typedef pair<int,int>pii;
typedef pair<int,pair<int,int> > piii;
 
const int mod=1e9+7;
 
int POWER[65];
int power(int a, int b) {int ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=mod) ret%=mod;if(a>=mod) a%=mod;b>>=1;}return ret;}
int inv(int x) {return power(x,mod-2);}
 
void precompute() {
	POWER[0]=1;
	for(int i=1;i<63;i++) POWER[i]=POWER[i-1]<<1LL;
}
 
int gcd(int a, int b) {
   if (b == 0)
   return a;
   return gcd(b, a % b);
}
 
ll main() {
	// freopen("Task.in", "r", stdin);freopen("Task.out", "w", stdout);

	int n;
	cin>>n;
	vector<int>v;
	for(int i=0; i<n; i++) {
		int x;
		cin>>x;

		v.pb(x);
	}

	sort(all(v));
	int ret=0;

	for (int i=0; i<sz(v); i++) {
		for (int j=i+1; j<sz(v); j++) {
			for (int k=j+1; k<sz(v); k++) {
				if(v[i]==v[j] || v[k]==v[j] || v[k]==v[i])	continue;
				if(v[i]+v[j]>v[k]) {
					ret++;
				}
			}
		}
	}

	cout<<ret<<endl;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	void doIt() {
		int n = sc.nextInt();
		boolean[] prime = createPrime();
		int[] numPF = new int[101];
		Arrays.fill(numPF, 0);
		for(int i = 1; i <= n; i++) {
			int num = i;
			int j = 2;
			while(num > 1) {
				if(num % j == 0) {
					numPF[j]++;
					num /= j;
				}
				else {
					j++;
					while(!prime[j]) j++;
				}
			}
		}
		//System.out.println(Arrays.toString(numPF));
		int[] cntNumPF = new int[100];
		Arrays.fill(cntNumPF, 0);
		for(int i = 1; i <= 100; i++) cntNumPF[numPF[i]]++;
		for(int i = 98; i >= 1; i--) cntNumPF[i] += cntNumPF[i + 1];
		//System.out.println(Arrays.toString(cntNumPF));
		int cnt = 0;
		cnt += cntNumPF[74];//75
		cnt += cntNumPF[24] * (cntNumPF[2] - 1);//25 * 3
		cnt += cntNumPF[14] * (cntNumPF[4] - 1);//15 * 5
		cnt += c(cntNumPF[4], 2) * (cntNumPF[2] - 2);//5 * 5 * 3
		System.out.println(cnt);
	}
	int c(int n, int r) {
		int num = 1;
		for(int i = 1; i <= r; i++) {
			num *= n - r + i;
			num /= i;
		}
		return num;
	}
	boolean[] createPrime() {
		boolean[] b = new boolean[101];
		Arrays.fill(b, true);
		b[0] = false;
		b[1] = false;
		for(int i = 2; i <= 100; i++) {
			if(b[i]) {
				for(int j = i << 1; j <= 100; j += i) {
					b[j] = false;
				}
			}
		}
		return b;
	}
	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s, t;
  ll ans = INF;
  cin >> s >> t;
  REP(i,s.size()-t.size()+1){
    string tmp = s.substr(i,t.size());
    ll cnt =0;
    REP(j, t.size()) {
      if (tmp[j] != t[j]) cnt++;
    }
    if (cnt < ans) ans = cnt;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	tuple<int, int, string> a[10];
	for (int n, h = 0; cin >> n&&n; h++) {
		if (h > 0)cout << endl;
		rep(i, 0, n) {
			string name; cin >> name;
			int w, l, d; cin >> w >> l >> d;
			a[i] = make_tuple(w * 3 + d, -i, name);
		}
		sort(a, a + n);
		rrep(i, 0, n) {
			cout << get<2>(a[i]) << "," << get<0>(a[i]) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3052
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "vector"
#include "string"
#include "map"
#include "unordered_map"
#include "algorithm"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<vector<long long int>>dp(N + 1, vector<long long int>(N + 1));
	dp[0][0] = 1;
	for (int i = 1; i <= N; i++) {
		char c;
		cin >> c;
		if (c == '-') {
			for (int j = 0; j <= N; j++)dp[i][j] = dp[i - 1][j];
		}
		else if (c == 'D') {
			for (int j = 1; j <= N; j++) {
				dp[i][j - 1] += dp[i - 1][j] * j*j;
				dp[i][j - 1] %= MOD;
			}
			for (int j = 0; j <= N; j++) {
				dp[i][j] += dp[i - 1][j] * j;
				dp[i][j] %= MOD;
			}
		}
		else {
			for (int j = 0; j <= N; j++) {
				dp[i][j] += dp[i - 1][j] * j;
				dp[i][j] %= MOD;
			}
			for (int j = 0; j < N; j++) {
				dp[i][j + 1] += dp[i - 1][j];
				dp[i][j] %= MOD;
			}
		}
	}
	cout << dp[N][0] << endl;
	return 0;
}


Measured memory_bytes: 3292
package main

import (
	"fmt"
)

func main() {
	var a,b,c int
	fmt.Scan(&a,&b,&c)
	
	cnt := 1
	if a != b {
    	cnt++
	} 
	
	if a != c && b != c {
		cnt++
	}
	
	fmt.Println(cnt)
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long n; cin >> n;
    priority_queue<long long> pq;
    for(int i = 0; i < n; i++){
        long long a;
        cin >> a;
        pq.push(-a);
    }
    long ans = 0;
    while(pq.size() > 1){
        long long s = pq.top();
        pq.pop();
        long long l = pq.top();
        pq.pop();
        if(s*2 <= l) ans++;
        else ans = 0;
        pq.push(s+l);
    }
    cout << ans+1 << endl;
    return 0;
}

Measured memory_bytes: 1400
S = input()
pre = ""
count = 0
for i, s in enumerate(S): 
  if i == 0:
    pre = s
  else:
    if s == pre:
      if pre == "1":
        pre = "0"
        count += 1
      else:
        pre = "1"
        count += 1
    else:
      if pre == "1":
        pre = "0"
      else:
        pre = "1"
print(count)

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

const int MAX = 100010;

int N, t;
int x[MAX], y[MAX];

int main() {
	scanf("%d", &N);
	for(int i = 0; i < N; ++i) {
		scanf("%d", &t);
		scanf("%d %d", x + t, y + t);
	} 
	int a = 0, b = 0, prev = 0, can = 1;
	for(int i = 1; i < MAX; ++i) {
		if(N == 0) break;
		if(x[i] == 0 && y[i] == 0)
			continue;
		int dist = abs(x[i] - a) + abs(y[i] - b);
		if(dist > (i - prev) || (i - prev) - dist == 1 || (i - prev) - dist == 3)
			can = 0;
		prev = i, a = x[i], b = y[i];
		N--;
	}
	if(can == 1) puts("Yes");
	else puts("No");
}

Measured memory_bytes: 1024
from operator import itemgetter
N, T = [int(i) for i in input().split()]

data = []
for i in range(N):
    data.append([int(i) for i in input().split()])

data.sort(key=itemgetter(0))

dp = [[0]*(T) for i in range(N)]
ans = data[0][1]
for i in range(1, N):
    for j in range(T):
        if j >= data[i-1][0]:
            value1 = dp[i-1][j]
            value2 = dp[i-1][j-data[i-1][0]] + data[i-1][1]
            dp[i][j] = max(value1, value2)
        else:
            dp[i][j] = dp[i-1][j]
    value3 = dp[i][T-1] + data[i][1]
    ans = max(value3, ans)
print(ans)


Measured memory_bytes: 117072
def main():
 
    N, K = map(int, input().split())
    p = []
    for _ in range(N):
        x, y = map(int, input().split())
        p.append([x, y])
    p.sort(key = lambda x: x[0])
 
    min_area = float('inf')
    for i in range(N-1):
        for j in range(i+1, N):
            if j-i+1 >= K:
                x1 = p[i][0]
                x2 = p[j][0]
                ys = []
                for k in range(i, j+1):
                    ys.append(p[k][1])
                ys.sort()
                for k in range(len(ys)):
                    for l in range(k+K-1, len(ys)):
                        y1 = ys[k]
                        y2 = ys[l]
                        area = (x2-x1)*(y2-y1)
                        if area > 0:
                            min_area = min(min_area, area)
    return min_area
 
if __name__ == '__main__':
    print(main())

Measured memory_bytes: 41584
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin>>a;
  switch(a%10){
    case 3:
      cout<<"bon"<<endl;
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      cout<<"pon"<<endl;
      break;
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout<<"hon"<<endl;
      break;
  }
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N;
    Scd(N);

    vi a(N);
    vl c(N);
    ll ans = 0;
    Rep(i,N){
        Scd(a[i]);
        a[i]--;
        c[a[i]]++;
    }

    Rep(i,N){
        ans += (c[i]-1)*c[i]/2;
    }

    ll tmp = 0;
    Rep(i,N){
        tmp = (c[a[i]]-1)*c[a[i]]/2-(c[a[i]]-2)*(c[a[i]]-1)/2;
        printf ("%lld\n", ans-tmp );
    }

    return 0;
}



Measured memory_bytes: 4992
"use strict"

function Main(input) {
  const args = input.split(" ");

  const N = parseInt(args[0], 10);
  const A = parseInt(args[1], 10);
  const B = parseInt(args[2], 10);

  const nums = Array.from(new Array(N), (v, i) => ++i).filter((i) => {
    var n = i.toString().split('').reduce((p, c) => p + parseInt(c, 10), 0);
    return (A <= n && n <= B)
  })

  console.log(nums.reduce((p, c) => p + c));
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 10096
import sys
#import cython

def main():
    read = lambda: sys.stdin.readline().rstrip()
    import collections
    
    X = int(read())
    for A in range(-120, 120):
        flag = False
        for B in range(-120, 120):
            if X == A**5-B**5:
                print(A, B)
                flag = True
                break
        if flag: break
    


if __name__ == "__main__":
    main()

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

int main(){
    
    int n, ans = 0;
    cin >> n;
    
    vector<int> a(n), b(n), c(n);
    
    for( int i = 0; i < n; i++ )
        cin >> a[i] >> b[i] >> c[i];
        
    if ( n == 1 ){
        cout << max( a[0], max( b[0], c[0] ) ) << endl;
        return 0;
    }
    
    vector<vector<int>> tab(n, vector<int>(3));
    tab[0][0] = a[0];
    tab[0][1] = b[0];
    tab[0][2] = c[0];
    
    for ( int i = 1; i < n; i++ ){
        tab[i][0] = a[i] + max( tab[i - 1][1], tab[i - 1][2] );
        tab[i][1] = b[i] + max( tab[i - 1][0], tab[i - 1][2] );
        tab[i][2] = c[i] + max( tab[i - 1][0], tab[i - 1][1] );
        
        if ( i == n - 1 )
            ans = max( tab[i][0], max( tab[i][1], tab[i][2] ) );
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 6912
def main stdin
  n,t = stdin.split("\n")[0].split(' ').map(&:to_i)
  ts = stdin.split("\n")[1].split(' ').map(&:to_i)
  unless ts.length == n
    raise "invalid number #{t}, #{n}, #{ts}"
  end

  accum = 0
  ts.zip(ts.slice(1,ts.length-1)).each do |pair|
    break if pair[1].nil?
    d = pair[1] - pair[0]
    if d < t
      accum += d
    else
      accum += t
    end
  end
  accum += t
  puts accum
end

main $stdin.read


Measured memory_bytes: 27992
#include <stdio.h>

int main(){
	int i,d,s;
	while(scanf("%d",&d) != EOF){
		s = 0;
		for(i = 1;i < 600 / d;i++){
			s += i * i * d * d * d;
		}
		printf("%d\n",s);
	}
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
#define LINF 1e18
typedef long long ll;


int main() {
    int N,Q; cin >> N >> Q;
    fenwick_tree<ll> fw(N);
    REP(i,N){
        ll a; cin >> a;
        fw.add(i,a);
    }
    
    REP(i,Q){
        int a,b,c; cin >> a >> b >> c;
        if(a){
            cout << fw.sum(b,c) << endl;
        }else{
            fw.add(b,c);
        }
    }
    return 0;
}

Measured memory_bytes: 8208
import java.io.*;
import java.util.*;
import java.lang.*;

public class Main{

	public static void main(String[] args) {
		FastReader in = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt(), x = in.nextInt(),t = in.nextInt();
		int cnt = 0;
		int ans = 0;
		while(cnt<n) {
			ans+=t;
			cnt+=x;
		}
		out.println(ans);
		out.close();
	}

	static final Random random=new Random();
	//	static void ruffleSort(Pair[] a) {
	//		int n=a.length;//shuffle, then sort 
	//		for (int i=0; i<n; i++) {
	//			int oi=random.nextInt(n);
	//			Pair temp=a[oi];
	//			a[oi]=a[i]; a[i]=temp;
	//		}
	//		Arrays.sort(a);
	//	}
	static void ruffleSort(int[] a) {
		int n=a.length;//shuffle, then sort 
		for (int i=0; i<n; i++) {
			int oi=random.nextInt(n), temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}
	static void ruffleSort(char[] a) {
		int n=a.length;//shuffle, then sort 
		for (int i=0; i<n; i++) {
			int oi=random.nextInt(n);
			char temp=a[oi];
			a[oi]=a[i]; a[i]=temp;
		}
		Arrays.sort(a);
	}
	static class FastReader 
	{ 
		BufferedReader br; 
		StringTokenizer st; 

		public FastReader() 
		{ 
			br = new BufferedReader(new
					InputStreamReader(System.in)); 
		} 

		String next() 
		{ 
			while (st == null || !st.hasMoreElements()) 
			{ 
				try
				{ 
					st = new StringTokenizer(br.readLine()); 
				} 
				catch (IOException  e) 
				{ 
					e.printStackTrace(); 
				} 
			} 
			return st.nextToken(); 
		} 

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

		long nextLong() 
		{ 
			return Long.parseLong(next()); 
		} 

		double nextDouble() 
		{ 
			return Double.parseDouble(next()); 
		} 

		String nextLine() 
		{ 
			String str = ""; 
			try
			{ 
				str = br.readLine(); 
			} 
			catch (IOException e) 
			{ 
				e.printStackTrace(); 
			} 
			return str; 
		} 

		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
	}
}

//class Pair implements Comparable<Pair>{
//    int a;
//    int b;
//    public Pair(int a, int b) {
//        this.a = a;
//        this.b = b;
//    }
//    public int compareTo(Pair o) {
//        if(this.a==o.a)
//            return this.b - o.b;
//        return this.a - o.a;
//    }   
//}

Measured memory_bytes: 25472
n = int(input())

taro = 0
hanako = 0
for ni in range(n):
    t, h = input().split()

    if t < h:
        hanako += 3
    elif t > h:
        taro += 3
    else:
        hanako += 1
        taro += 1

print(taro, hanako)

Measured memory_bytes: 7632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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


	int N;
	cin >> N;

	int A[8] = {};
	int B = 0;

	rep(i, N) {
		int a;
		cin >> a;

		int b = a / 400;
		if (b < 8) A[b] = 1;
		else B++;
	}

	int C = 0;
	rep(i, 8) C += A[i];

	if (C) cosp(C);
	else cosp(1);
	co(C + B);

	Would you please return 0;
}

Measured memory_bytes: 256
var GET = (function(){
  function f(s){return new g(s);}
  function g(s){this._s=s.trim().split("\n");this._y=0;}
  g.prototype.a = function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y]=s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  }
  g.prototype.l = function(f){
    var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);
  }
  g.prototype.m = function(n,f){
    var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));
    return f?r:r.map(a=>a.map(a=>+a));
  }
  g.prototype.r = function(n,f){
    var r = this._s.slice(this._y,this._y+=n);
    return f?r:r.map(a=>+a);
  }
  return f;
})();
function MA(h,w){return Array(h).fill(0).map(a=>Array(w).fill(0));}
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
var mod = 1e9+7;

console.log(main());
function main(){
  var n = o.a();
  var s = o.a(1);
  var t = o.a(1);
  var ans = 3, l = 0, i = 1;
  if(s[0] !== t[0])ans = 6, l = 1, i = 2;
  for(; i < n; i++){
    if(s[i] === t[i]){
      if(!l) ans *= 2;
      l = 0;
    }else{
      i++;
      if(l)ans *= 3;
      else ans *= 2;
      l = 1;
    }
    ans %= mod;
  }
  return ans;
}

Measured memory_bytes: 7372
#include <bits/stdc++.h>
#include <cstdio>
 
using namespace std;
using ll = long;
#define int ll
 
#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);
 
#define MOD 1000000007
void init();
void solve();

signed main()
{
    init();
    solve();
}


int D, G;
vector<int> p;
vector<int> c;
vector<int> sum;


void init()
{
	cin >> D >> G;
	G /= 100;
	rep(i, D) {
		int a, b;
		cin >> a >> b;
		p.PB(a);
		c.PB(b / 100);
		sum.PB(a * (i + 1) + b / 100);
	}
}

int calc(int bit)
{
	int t = bit;
	int point = 0;
	int res = 0;
	for (int i = 0; t; i++) {
		if (t & 1) {
			point += sum[i];
			res += p[i];
		}
		t >>= 1;
	} 
	if (point >= G) return res;
	int b = 1 << (D - 1);
	int pos = D-1;
	while (b & bit) b >>= 1, pos--;
	int need = G - point;
	if (p[pos] * (pos+1) < need) return INT_MAX;
	return res + (need + pos) / (pos + 1);
}

void solve()
{
	int res = INT_MAX;
	rep(bit, 1 << D) {
		res = min(res, calc(bit));
	}
	cout << res << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator <<(std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator <<(std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< std::vector<T> > vv)
{
  for (auto& vec : vv){ os << vec << std::endl; }
  os << "--------" << std::endl;
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H&& head){ std::cout << head << std::endl; }
template<typename H, typename... T> void print(H&& head, T&&... tail){
  std::cout << head << " ", print(std::forward<T>(tail)...);
}

int main()
{
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  std::ios::sync_with_stdio(false);

  ll N;
  std::cin >> N;

  std::vector< std::vector<ll> > V[10];

  for (ll i = 3; i <= 7; i += 2) { V[1].push_back({i}); }
  for (ll k = 1; k < 9; k++) {
    for (auto v : V[k]) {
      for (ll i = 3; i <= 7; i += 2) {
        auto v2 = v;
        v2.push_back(i);
        V[k+1].push_back(v2);
      }
    }
  }

  ll cnt = 0LL;
  for (ll k = 1; k <= 9; k++) {
    for (auto v : V[k]) {
      std::map<ll, ll> mc;
      ll num = 0LL;
      for (auto x : v) num += x, num *= 10;
      num /= 10;
      if (num > N) continue;

      for (auto x : v) mc[x]++;
      if (mc.size() == 3) cnt++;
    }
  }

  print(cnt);
  return 0;
}


Measured memory_bytes: 3260
#!/usr/bin/env python3

import sys
import pprint
from collections import deque


sys.setrecursionlimit(10 ** 6)

class Logger:
	def __init__(self, debug):
		self.debug = debug
	def print(self, *args):
		if self.debug:
			pprint.pprint(args)


def main():
	log = Logger(0)
	n = int(sys.stdin.readline())
	a = list(map(int, sys.stdin.readline().split()))
	a = deque(sorted(a))
	if len(a) == 2:
		print(max(a))
		exit()
	if len(a) == 3:
		print(a[-1] + a[-2])
		exit()
	ans = 0
	a1 = a.pop()
	a2 = a.pop()
	a3 = a.pop()
	que = deque([[a1, a2], [a2, a3], [a3, a1]])
	ans += a1 + a2
	while len(a) != 0:
		log.print(que, ans)
		between = que.popleft()
		insert = a.pop()
		ans += min(between)
		que.append([between[0], insert])
		que.append([insert, between[1]])
	print(ans)




main()

Measured memory_bytes: 120120
using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.IO;
    using System.Text;
    using System.Text.RegularExpressions;

    class Program
    {
        static void Main()
        {

            string[] input = Console.ReadLine().Split(' ');
            var a = decimal.Parse(input[0]);
            var b = decimal.Parse(input[1]);

            decimal ans = Math.Floor(a * b);

            Console.WriteLine(ans.ToString());
        }

    }

Measured memory_bytes: 18076
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cmath>
using namespace std;
#define ld long double
const ld pi=3.1415926535898;
const ld p=180.000000000000;
int main(){
    ld a,b,x;
    cin>>a>>b>>x;
    // cout<<a<<b<<x<<endl;
    ld v=a*a*b;
    ld tanans;
    if(x>=(v/2)){
        ld s=a*a,k=v-x;
        ld y=k/s*2;
        tanans=a/y;
    }
    else{
        ld sc=a*b;
        ld y=x/sc*2;
        tanans=y/b;
    }
    ld ans=atan(tanans);
    ans=90-(ans/pi)*p;
    cout<<setiosflags(ios::fixed)<<setprecision(10)<<ans<<endl;
    return 0;
}
// 89.7834636934
// 89.7834636934

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

//D日目時点のスコアを計算
int score(int D, int c[], int s[][26], int t[]){
    int pen_day[26]={1};
    for(int i=0; i<26; i++){
        pen_day[i]=1;
    }
    int score=0;

    for(int i=0; i<D; i++){
        int type=t[i]-1;
        pen_day[type]=0;
        //満足度増加
        score+=s[i][type];
        //満足度低下
        for(int j=0; j<26; j++){
            int dec=c[j]*pen_day[j];
            score-=dec;
        }
        //日数追加
        for(int j=0; j<26; j++){
            pen_day[j]++;
        }
    }
    return score;
}

void Greedy(int D, int c[], int s[][26]){
    int t[D], max_type=0, max_score=0;

    for(int i=0; i<D; i++){
        max_score=0;
        for(int j=0; j<26; j++){
            t[i]=j+1;
            int S=score(i+1, c, s, t);
            if(max_score < S){
                max_score = S;
                max_type=j+1;
            }
        }
        t[i]=max_type;
    }

    //局所探索
    int new=0;
    int roop_num=0;
    int MAX=max_score;
    while(1){
        int a=rand()%D;
        int b=rand()%D;

        //a,bを入れ替え
        int tmp;
        tmp=t[a];
        t[a]=t[b];
        t[b]=tmp;

        //scoreを計算
        int now_score=score(D, c, s, t);
        if(MAX<now_score) MAX=now_score;
        else{
            tmp=t[a];
            t[a]=t[b];
            t[b]=tmp;
        }
        new++;
        roop_num++;
        if(roop_num==D*500) break;
    }

    for(int i=0; i<D; i++){
        printf("%d\n", t[i]);
    }
}

int main(void){
    int D, c[26], s[365][26];

    //入力
    scanf("%d", &D);
    for(int i=0; i<26; i++){
        scanf("%d", &c[i]);
    }
    for(int i=0; i<D; i++){
        for(int j=0; j<26; j++){
            scanf("%d", &s[i][j]);
        }
    }
    /*
    for(int i=0; i<D; i++){
        scanf("%d", &t[i]);
    }
    */

    /*ここから処理*/
    /*
    int num=1;
    for(int i=0; i<D; i++){
        printf("%d\n", num);
        num++;
        if(num>26) num=1;
    }
    */

    Greedy(D, c, s);


    return 0;
}

Measured memory_bytes: 1752