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

int main(void){
	int a,b,c,s,t;
	scanf("%d %d %d",&a,&b,&c);
	
	if(a>b){
		t = a;
		a = b;
		b = t;
	}
	if(b>c){
		s = b;
		b = c;
		c = s;
	}
	if(a>b){
		t = a;
		a = b;
		b = t;
	}
	printf("%d %d %d\n",a,b,c);
	
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll n,i,j;
	cin>>n;
	ll arr[n][3];
	for(i=0;i<n;i++)
	{
		for(j=0;j<3;j++)
		{
			cin>>arr[i][j];
		}
	}
	ll dp[3][n];
	dp[0][0]=arr[0][0];
	dp[1][0]=arr[0][1];
	dp[2][0]=arr[0][2];
	for(i=1;i<n;i++)
	{
		for(j=0;j<3;j++)
		{
			if(j==0)
			dp[j][i]=max(dp[1][i-1]+arr[i][0],dp[2][i-1]+arr[i][0]);
			else if(j==1)
			dp[j][i]=max(dp[0][i-1]+arr[i][1],dp[2][i-1]+arr[i][1]);
			else
			dp[j][i]=max(dp[0][i-1]+arr[i][2],dp[1][i-1]+arr[i][2]);
		}
	}
	ll ans=max(dp[0][n-1],dp[1][n-1]);
	cout<<max(ans,dp[2][n-1]);
}

Measured memory_bytes: 4992
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;


public static class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int last = -100;
        for (int i = 0; i < h.Length; i++)
        {
            var item = h[i];
            if (last > item)
            {
                item++;
            }
            if (last > item)
            {
                Console.WriteLine("No");
                return;
            }
            last = item;
        }
        Console.WriteLine("Yes");
    }
}


Measured memory_bytes: 26204
#include<vector>
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<limits.h>
#include<cmath>
using namespace std;

int main(){
  
  int L,R; cin >> L >> R;
  
  int ans = 2018;
  
  for (int i=L; i<R; i++){
    for (int j=i+1; j<=R; j++){
      ans = min(ans, (i % 2019)*(j % 2019)%2019);
      if (ans == 0) break;
    }
    if (ans == 0) break;
  }
  
  cout << ans;
 
  return 0;
}


Measured memory_bytes: 256
#include        <map>
#include      <cmath>
#include      <queue>
#include     <string>
#include     <cstdio>
#include     <vector>
#include    <cstring>
#include   <iostream>
#include  <algorithm>
using namespace std;
#define ll long long
const ll inf = 0x3f3f3f3f3f3f3f3f;
const int maxn = 500+5;
const ll mod = 1e9+7;


int main(){
    int n;
    string s;
    map<string,ll>m;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        cin>>s;
        sort(s.begin(),s.end());
        m[s] ++;
    }
    ll ans = 0;
    for(auto t : m){
        ans += t.second * (t.second-1)/2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 11136
#include <stdio.h>

int main()
{
	long long S;
	scanf("%lld", &S);

	long long X[3] = {}, Y[3] = {};
	X[1] = 1;
	Y[1] = 1000000000;
	X[2] = (S - 1) / 1000000000 + 1;
	Y[2] = 999999999 - (S + 999999999) % 1000000000;

	int i;
	for (i = 0; i < 3; i++) printf("%lld %lld ", X[i], Y[i]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
typedef long long ll;
using namespace std;
int N, W;
ll v[103], w[103];
ll Values[103][100003]; // nこ目が重さiの時の最大価値

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

  cin >> N >> W;
  rep(i, N) {
    cin >> w[i] >> v[i];
  }

  rep(i, N+1) {
    if (i==0) continue;
    rep(j, W+1) { // 0からWまでの重さ
      Values[i][j] = max(Values[i][j], Values[i-1][j]); // Nコめは使わない。その前のものを引き継ぐ。
      if (j + w[i-1] <= W) Values[i][j+w[i-1]] = max(Values[i][j+w[i-1]], Values[i-1][j] + v[i-1]); // Nコめを使う。
    }
  }

  ll ans = 0ll;
  rep(i, W+1) {
    ans = max(ans, Values[N][i]);
  }
  cout << ans << "\n";
  return 0;
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k,s=0,ans=0,w;
	cin>>n>>k;
	vector<pair<int,int>>v(2000001);
	for(int i=0;i<n;i++){
		cin>>w;
		if(v.at(w).first>0)s++;
		v.at(w).first++;
		v.at(w).second=w;
	}
	s=n-s;
	sort(v.begin(),v.end());
	if(s>k){
		for(int i=0;i<2000001;i++){
			if(v.at(i).first==0){
				continue;
			}
			ans+=v.at(i).first;
			v.at(i).first=0;
			s--;
			if(s<=k){
				cout<<ans<<endl;
				return 0;
			}
		}
	}else{
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 15872
/*
the top of the losers
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(v)   ((int)(v).size())
#define  all(v)    ((v).begin()),((v).end())
#define  allr(v)    ((v).rbegin()),((v).rend())
#define   pb         push_back
#define   mp         make_pair
#define    Lcm(a,b)  ((a*b)/(__gcd(a,b)))
#define    X            real()
#define    Y            imag()
#define    clr(v,d)      memset( v, d ,sizeof(v))
#define   angle(n)      atan2((n.imag()),(n.real()))
#define   vec(a,b)       ((b)-(a))
#define   length(a)      hypot( (a.imag()),(a.real()) )
#define   normalize(a)      (a)/(length(a))
#define    dp(a,b)          (((conj(a))*(b)).real())
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    lengthsqrt(a)       dp(a,a)
#define    rotate0( a,ang)    ((a)*exp( point(0,ang) ))
#define    rotateA(about,p,ang)   (rotate0(vec(about,p),ang)+about)
#define    lcm(a,b)                ((a*b)/(__gcd(a,b)))
#define    reflection0(m,v)         (conj((v)/(m))*(m))
#define     reflectionA(m,v,p0)     (conj( (vec(p0,v))/(vec(p0,m)) ) * (vec(p0,m)) ) + p0
#define     same(p1,p2)               ( dp(  vec(p1,p2),vec(p1,p2)) < eps )
#define     point                    complex<double>
#define     point        complex<double>
#define    cp(a,b)          (((conj(a))*(b)).imag())
#define    PI  acos(-1)
typedef  long long     ll ;
typedef  unsigned long long     ull ;
const double eps= (1e-9);
using namespace std;
using namespace __gnu_pbds;
int dcmp(long double a,long double b){   return fabsl(a-b)<=eps ? 0: (a>b)? 1:-1  ;}
int getBit(ll num, int idx) {return ((num >> idx) & 1ll) == 1;}
int setBit1(int num, int idx) {return num | (1<<idx);}
ll setBit0(ll num, int idx) {return num & ~(1ll<<idx);}
ll flipBit(ll num, int idx) {return num ^ (1ll<<idx);}
int countNumBit1(int mask) {int ret=0; while (mask) 	{mask &= (mask-1);++ret;	}return ret;}
void GO(){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
const int N=100000+9;
int a[N],b[N];
vector< pair<int,int> > v;
set< pair<int,int> > s1;
set<int> hv;
int main(){
    GO();
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<n;i++){
        v.pb(mp(b[i],a[i]));
    }
    sort(all(v));
    for(int i=0;i<n;i++){
        s1.insert(mp(v[i].second,i));
        a[i]=v[i].second;
        b[i]=v[i].first;
    }
    int cnt=0;
    for(int i=0;i<n;i++){

        while(sz(s1)>0&&(*s1.begin()).first<=b[i]){
            hv.insert((*s1.begin()).second);
            s1.erase(s1.begin());
        }

        if(a[i]<=b[i]){
            hv.erase(hv.find(i));
            continue;
        }

        if(sz(hv)==0){
            cout<<"No\n";
            return 0;
        }

        cnt++;
        set<int> ::iterator it=hv.end();
        it--;
        int id=(*it);
        hv.erase(it);
        s1.erase(mp(a[i],i));
        s1.insert(mp(a[i],id));
        swap(a[i],a[id]);

    }

    if(cnt<=n-2) cout<<"Yes\n";
    else cout<<"No\n";
}









Measured memory_bytes: 6516
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int n = sc.nextInt();
        long sum = 0;
        for(int i = 0; i <=n; i++){
            if(!(i%3==0||i%5==0)){
                //System.out.print(i+"\t");
                sum+=i;
            }
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 35892
//{{{
#include <bits/stdc++.h>
using namespace std;
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x
#define foreach(x,a) for(auto &x:a)
typedef long long ll;
const ll MOD = 998244353;
//}}}

int main(){
  int N;
  cin >> N;
  int ans = N;
  rep(i, N + 1){
    int n6 = i;
    int n9 = N - i;
    int cnt = 0;
    while(n6){
      cnt += n6 % 6;
      n6 /= 6;
    }
    while(n9){
      cnt += n9 % 9;
      n9 /= 9;
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main()
{
 int n;
 cin>>n;
 int fg=0;
 long long int cnt=0;
 for(int i=0;i<=n;i++)
 if(!(i%3==0 || i%5==0))
     cnt+=i;
     cout<<cnt;
    
 

return 0;   
}

Measured memory_bytes: 3624
s = input()
n = len(s)
k = int(input())
dp = [[[0 for _ in range(2)] for _ in range(k + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1
for a in range(n):
    for b in range(k + 1):
        for c in range(2):
            nd = int(s[a])
            for d in range(10):
                na, nb, nc = a + 1, b, c
                if 0 != d:
                    nb += 1
                if nb > k:
                    break
                if nc == 0:
                    if nd > d:
                        nc = 1
                    if nd < d:
                        break
                dp[na][nb][nc] += dp[a][b][c]
print(sum(dp[-1][-1]))


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

int main() {
  int h, w; cin >> h >> w;
  vector<string> data(0);
  string empty = "";
  for (int i = 0; i < w; i++) {
    empty += ".";
  }

  for (int i = 0; i < h; i++) {
    string input; cin >> input;
    if (input != empty) {
      data.push_back(input);
    }
  }
  
  vector<int> delete_idx_list(0);
  for (int j = 0; j < w; j++) {
    int cnt = 0;
    for (int i = 0; i < data.size(); i++) {
      cnt += (data.at(i).at(j) == '.');
    }
    if (cnt == data.size()) {
      delete_idx_list.push_back(j);
    }
  }
  
  reverse(delete_idx_list.begin(), delete_idx_list.end());

  for (int k = 0; k < delete_idx_list.size(); k++) {
    int delete_idx = delete_idx_list.at(k);
    for (int i = 0; i < data.size(); i++) {
      data.at(i).erase(delete_idx, 1);
    }
  }
  
  for (int i = 0; i < data.size(); i++) {
    cout << data.at(i) << endl;
  } 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(), (a).end()
#define forn(i,a,b) for (int i = a; i <= b; i++)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define rc(s) return cout<<s,0
#define rcc(s) cout<<s,exit(0)
#define er erase
#define in insert
#define pi pair <int, int>
# define sz(x) (int)((x).size())
#define int long long

const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};

const ll inf = 0x3f3f3f3f3f3f3f;
const ll mod = 1999999973;
const int N = 1e7 + 11;

int dp[N],v,w,n,k,x;
//vector<int>v[N];

int32_t main(){
ios_base::sync_with_stdio(0); cin.tie(0); cerr.tie(0); cout.tie(0);

    cin >> n >> k;

    dp[0] = 0;

    forn(i,1,n){
        cin >> w >> v;
        for(int j = 1e7 + 5; j >= w; j--){
            dp[j] = max(dp[j] , dp[j-w] + v);
        }
    }

    int ans = 0;
    for(int i = 1; i <= k; i++){
        ans = max(ans , dp[i]);
    }

    rc(ans);
return 0;
}


Measured memory_bytes: 78336
N, L = map(int, input().split())
min_apple = L
max_apple = L + N - 1
eat_apple = 0
if min_apple > 0 :
    eat_apple = min_apple
elif max_apple < 0 :
    eat_apple = max_apple
print(int((min_apple + max_apple) * (max_apple - min_apple + 1) / 2) - eat_apple)


Measured memory_bytes: 2940
#include <algorithm>
#include <cstring>
#include <cstdio>

#define REDIRECT(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)
#define CLOSEALL() fclose(stdin), fclose(stdout)

using namespace std;
typedef long long i64;

i64 N, K;

i64 simulate(i64 x, i64 y)
{
	if(y == 0)
		return (-x);
	return simulate(y, x % y) + 2 * (x / y) * y;
}

int main()
{
	//REDIRECT("light");

	scanf("%lld%lld", &N, &K);
	printf("%lld\n", simulate(max(K, N - K), min(K, N - K)) + N);

	CLOSEALL();
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(void){
  int a,b,c,d,train,bus;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  if(a<b)
    train=a;
  else
    train=b;
  if(c<d)
    bus=c;
  else
    bus=d;
  printf("%d",train+bus);
  return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int x = max(max(a, b), c);
  int y = (a + b + c) - max(max(a, b), c);
  if(x == y){
    cout << "Yes" <<endl;
  }
  else{
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 256
/*#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <random>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
#define mod 1e9 + 7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout.setf(ios::fixed);
	cout.precision(20);

	vs v;
	string s1, s2;
	vs cs1, cs2;
	while (true) {
		cin >> s1;
		if (s1 == ".") break;
		cin >> s2;
		ll sum = 0;
		if (s1 == s2) v.pb("IDENTICAL");
		else {
			rep(i, s1.size()) {
				rep(j, s1.size()) {
					if (i != j && s1[i] == '"' && s1[j] == '"') {
						cs1.pb(s1.substr(i + 1, j - 1));
						s1[i] = '0'; s1[j] = '0';
					}

				}
			}
			rep(i, s2.size()) {
				rep(j, s2.size()) {
					if (i != j && s2[i] == '"' && s2[j] == '"') {
						cs2.pb(s2.substr(i + 1, j - 1));
						s2[i] = '0'; s2[j] = '0';
					}

				}
			}
			rep(i, cs1.size()) {
				cout << cs1[i] << " " << cs2[i] << endl;
				if (cs1[i] != cs2[i]) sum++;
				if (sum == 2) break;
			}
			if (sum == 1) v.pb("CLOSE");
			else v.pb("DIFFERENT");
		}
	}
	rep(i, v.size()) cout << v[i] << endl;
	return 0;
}*/
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef deque<ll> dll;
#define mod 1e9 + 7;

int main()
{
	ios_base::sync_with_stdio(false);

	ll n, m;
	vll w;
	cin >> n;
	vll v;
	v.pb(2);
	v.pb(1);
	REP(i,1, n) {
		ll a;
		a = v[i] + v[i - 1];
		v.pb(a);
	}
	cout << v[n] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
  int n, w;
  while(cin >> n >> w, n){
    int h[11], m = 0, v;
    double ans = 0.01;
    for(int i = 0; i < 11; ++i) h[i] = 0;
    for(int i = 0; i < n; ++i){
      cin >> v;
      ++h[v/w];
    }
    int t = 0;
    for(int i = 0; i < 11; ++i){
      if(h[i]) t = i;
      m = max(m, h[i]);
    }

    for(int i = 0; i < t; ++i){
      ans += (double)h[i]/m*(t-i)/t;
    }
    printf("%lf\n",ans);
  }
  return 0;
}

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


int main() {
  int K, X;
  cin >> K >> X;
  int min = -1000000;
  int max = 1000000;
  for (int i=K-1; 0<i; --i) {
    int cand = X - i;
    if (min <= cand) {
      cout << cand << " ";
    }
  }
  cout << X << " ";
  for (int i=1; i<K; ++i) {
    int cand = X + i;
    if (cand < max) {
      cout << cand << " ";
    } else if (cand == max) {
      cout << cand;
    }
  }
}

Measured memory_bytes: 256
# coding: utf-8
import sys
from math import sin, cos, radians

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 2点間の距離、x座標とy座標
A, B, H, M = lr()
d1 = radians((30 * H + 30 * M / 60) - 90)
d2 = radians((360 * M / 60) - 90)
x1, y1 = A * cos(d1), A * sin(d1)
x2, y2 = B * cos(d2), B * sin(d2)
dis = ((x1-x2) ** 2 + (y1-y2) ** 2) ** .5
print(dis)


Measured memory_bytes: 9592
N,A,B=map(int,input().split())
p=10**9+7
def cmb(n,k):
    x,y = 1,1
    for i in range(k):
        x=x*(n-i)%p
        y=y*(i+1)%p
    return x*pow(y,p-2,p)%p
print((pow(2,N,p)-cmb(N,A)-cmb(N,B)-1)%p)

Measured memory_bytes: 38512
package main

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

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func min(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func loadints(n int) []int {
	xs := make([]int, n)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < n; i++ {
		sc.Scan()
		xs[i], _ = strconv.Atoi(sc.Text())
	}
	return xs
}

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	x := loadints(n)
	result := 100000000000
	for i := 0; i < n-k+1; i++ {
		d := x[i+k-1] - x[i]
		m := min(abs(x[i+k-1]), abs(x[i]))
		r := d + m
		result = min(r, result)
	}
	fmt.Println(result)
}


Measured memory_bytes: 2944
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{

    internal class Solution
    {
        public int N, K;
        public int[] A;

        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                N = line[0];
                K = line[1];
            }

            A = Input.ReadIntArray();

            int gcd = A[0];
            for (int i = 1; i < A.Length; i++)
                gcd = Util.GCD(gcd, A[i]);

            bool success = (K % gcd == 0) && (A.Max() >= K);
            Console.WriteLine(success ? "POSSIBLE" : "IMPOSSIBLE");

        }
    }

    // libs ----------
    class Util
    {
        // validation: AOJ 0005
        public static int GCD(int a, int b)
        {
            return b == 0 ? a : GCD(b, a % b);
        }

    }

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 20576
N=int(input())
A=int(input())
B=int(input())
C=int(input())
D=int(input())
E=int(input())
s=[A,B,C,D,E]
x=0
if N%min(s)==0:
  x=N//min(s)
else:x=(N//min(s))+1
print(x+4)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
struct edge { ll s, t, x; };
typedef pair<int, int> P;
typedef pair<ll,P> event;
const ll MAX = 510000;
const ll MOD = 1000000007;
#define INF (ll)1000000000000

ll ans=1ll;
ll N,K;
vector<vector<int>>Ki(100000);

void dfs(int now,int par){
  ll g=K;
  if(par==0&&now==0){ans*=K;}
  else{g--;}
  for(auto t:Ki[now]){
    if(t==par){continue;}
    g--;
    ans*=g;
    ans%=MOD;
    dfs(t,now);
  }
  return;
}

int main() {
  cin>>N>>K;
  rep(i,N-1){
    int a,b;cin>>a>>b;a--;b--;
    Ki[a].push_back(b);
    Ki[b].push_back(a);
  }
  dfs(0,0);
  cout<<ans;
}


Measured memory_bytes: 13188
#include<stdio.h>
int main(){
  int n,i,j;
  scanf("%d",&n);
  for(i=1;i<10;i++){
    for(j=1;j<10;j++){
      if(i*j==n){
	printf("Yes\n");
	return 0;
      }
    }
  }
  printf("No\n");
  return 0;
}
		 


Measured memory_bytes: 128
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;
struct Direction {
    int y, x;
};

vector<Direction> directions = {
        {0,  1},
        {1,  1},
        {1,  0},
        {1,  -1},
        {0,  -1},
        {-1, -1},
        {-1, 0},
        {-1, 1},
        {0,  0},
};

int main() {
    ll h, w;
    int n;
    cin >> h >> w >> n;

    vector<P> v(n);
    for (P &p: v) cin >> p.first >> p.second;

    set<P> black;
    for (P p : v) black.insert(p);

    set<P> candidate;

    for (P p : v) {


        for (Direction d : directions) {
            ll y = p.first + d.y;
            ll x = p.second + d.x;

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

            candidate.insert({y, x});
        }

    }


    map<P, int> m;

    for (P p: candidate) {
        int count = 0;
        for (Direction d : directions) {
            ll y = p.first + d.y;
            ll x = p.second + d.x;
            P q(y, x);
            if (black.find(q) != black.end()) count++;
        }
        m[p] = count;
    }

    {
        ll all = (h - 2) * (w - 2);
        all -= candidate.size();
        cout << all << endl;
    }

    for (int i = 1; i <= 9; i++) {
        ll ans = 0;
        for (auto e : m) {
            if (e.second == i) ans++;
        }
        cout << ans << endl;
    }


}


Measured memory_bytes: 123624
from bisect import *
from collections import *
from fractions import gcd
from math import factorial
from itertools import *
from heapq import *
import copy

X,Y,Z,K=map(int,input().split())
A=sorted(list(map(int,input().split())),reverse=True)
B=sorted(list(map(int,input().split())),reverse=True)
C=sorted(list(map(int,input().split())),reverse=True)
dic={A[0]+B[0]+C[0]:["0_0_0"]}
usedlst=set(["0_0_0"])
lst=[]
D=[-(A[0]+B[0]+C[0])]
heapify(D)

def strmode(a,b,c):
    return(str(a)+"_"+str(b)+"_"+str(c),A[a]+B[b]+C[c])
while len(lst)<K:

    value=heappop(D)
    lst.append(-value)
    a,b,c=map(int,dic[-value].pop().split("_"))
    for x,y,z in ([[a+1,b,c],[a,b+1,c],[a,b,c+1]]):

        if x<X and y<Y and z<Z:
            name,value=strmode(x,y,z)
            if not name in usedlst:
                usedlst.add(name)
                heappush(D,-value)
                if not value in dic:
                    dic.update({value:[name]})
                else:
                    dic[value].append(name)
for i in lst:
    print(i)


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

long long int memo[111][11][1111];

long long int solve(int p, int n, int s){
  
  if(n == 1 && s >= p && s < 101) return memo[p][n][s] = 1;
  if(n == 1 || s*100 < s) memo[p][n][s] = 0;
  if(s < 0) return 0;
  if(~memo[p][n][s]) return memo[p][n][s];
  
  long long int ans = 0;
  for(int i=p;i<101;i++) ans += solve(i+1, n-1, s-i);
  
  return memo[p][n][s] = ans;
}

int main(){

  memset(memo, -1, sizeof(memo));
  /*for(int i=1;i<10;i++)
    for(int j=0;j<1001;j++) 
      solve(0, i, j);
  */

  int n, s;
  while(cin >> n >> s, n+s) cout << solve(0, n, s) << endl;
  
}

Measured memory_bytes: 11760
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long a;
	cin>>a;
  long long mini=a-1;
  for(long long i=1;i*i<=a;i++){
  if(a%i==0){
  	mini=min(mini, a/i+i-2);
  }
  }
  cout<<mini;
}

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



Measured memory_bytes: 2140
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

dd = defaultdict(set)
sa = list(input())
sb = list(input())
sc = list(input())
na = nb = nc = 0
pl = 'a'

while True:
	if pl == 'a':
		if na == len(sa):
			print('A')
			break
		pl = sa[na]
		na += 1
	elif pl == 'b':
		if nb == len(sb):
			print('B')
			break
		pl = sb[nb]
		nb += 1
	elif pl == 'c':
		if nc == len(sc):
			print('C')
			break
		pl = sc[nc]
		nc += 1


Measured memory_bytes: 4456
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
int main() {
  
  int k,s,ans=0; cin>>k>>s;
  for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
      if(0<=s-i-j and s-i-j<=k) ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import bisect

n, m, k = list(map(int, input().split()))
book_a = list(map(int, input().split()))
book_b = list(map(int, input().split()))

a_time_sum = [0]
b_time_sum = []
for i in range(n):
    if i == 0:
        a_time_sum.append(book_a[0])
    else:
        a_time_sum.append(a_time_sum[i]+book_a[i])

for i in range(m):
    if i == 0:
        b_time_sum.append(book_b[0])
    else:
        b_time_sum.append(b_time_sum[i-1]+book_b[i])

ans = 0

# Aから何冊か読む
for i in range(n+1):
    read = i
    a_time = a_time_sum[i]
    time_remain = k - a_time
    if time_remain < 0:
        break
    # このときBから何冊よめる？
    b_read = bisect.bisect_right(b_time_sum, time_remain)
    read += b_read
    ans = max(ans, read)

print(ans)


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

int main() {
	int a, b, degc;
	double s, l, h, c, theta, pi = 3.141592653589793;
	cin >> a >> b >> degc;
	theta = (degc / 360.0) * 2.0 * pi;
	s = a*b*sin(theta) / 2.0;
	c = sqrt(a*a + b*b - 2.0 * a*b*cos(theta));
	l = a + b + c;
	h = b * sin(theta);
	cout << fixed << setprecision(6) << s << endl << l << endl << h << endl;
	return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) (v).begin(), (v).end()
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();

signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
  //  freopen("input.txt", "r", stdin);
    #endif 
    int t = 1; 
    // cin >> t;    
    int tt = t;
    while (t--) {
        // cout << "Case #" << tt - t << ": "; 
        solve();
    }
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}
int n;
void solve() {
    cin >> n;
    int cur = 0;
    for (int i = 1; ; i += 1) {
        cur += n;
        cur %= 360;
        if (!cur) {
            cout << i << '\n';
            return;
        }
    }
}       

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		String[] lines = line.split("");
		boolean flag7 = false;

		for(int i = 0; i < lines.length; i++) {
			int N = Integer.parseInt(lines[i]);
			if(N == 7) {
				flag7 = true;
				break;
			}else {
				flag7 = false;
			}
		}

		if(flag7) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}

	}

}


Measured memory_bytes: 35688
function main(input) {
  const args = input.split('\n');
  const K = parseInt(args[0], 10);
  const S = args[1];

  if (K >= S.length)
    console.log(S);
  else
    console.log(S.slice(0, K) + '...');
}

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


Measured memory_bytes: 29632
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}

};

int mod_pow(int x, int n, int mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % mod;
		x = 1LL * x * x % mod;
		n >>= 1;
	}
	return res;
}

typedef vector<vector<Edge>> Graph;

ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % mod;
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}
ll divmod(ll a, ll b, ll m) { // a/b(mod m)
								  // a/b (mod m)
								  // a*b^-1
								  // b^-1 * b = 1
								  // b^(m-1) = 1 
								  // b^(m-2) * b = 1
								  // b^-1 = b^(m-2)

								  // a/b = a * b^(m-2)

	return (a * 1LL * mod_pow(b, m - 2, m)) % m;
}

signed main(void) {

	int n, k;
	cin >> n >> k;
	vector<ll> a(n), ov(n);
	ll ans = 0, tan = 0;
	REP(i, n)
		cin >> a[i];

	REP(i, n) {
		REP(j, n) {
			if (a[i] > a[j])
				ov[i]++;
		}

		rep(j, i + 1, n) {
			if (a[i] > a[j])
				tan++;
		}
	}

	tan *= k;
	tan %= MODU;

	REP(i, n) {
		ans += ov[i] * ((k-1) * divmod(k,2,MODU) % MODU);
		ans %= MODU;
	}

	
	cout << (ans + tan) % MODU << endl;

	return 0;
}


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

a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(a[k-1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) ((int)(x).size())
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{   
    string s; cin>>s;
    int K; cin>>K; 
    vector<string> vs;
    for(int len=1;len<=K;len++){
        for(int i=0;i+len<=SZ(s);i++){
            vs.push_back(s.substr(i,len));
        }
    }
    sort(ALL(vs));
    vs.erase(unique(ALL(vs)),vs.end());
    cout<<vs[K-1]<<endl;
}


Measured memory_bytes: 1660
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(int i=0;i<N;++i)
typedef long long int LL;

std::string s;
int ans;

int main()
{
	in>>s;
	if(s[0]=='1')++ans;
	if(s[1]=='1')++ans;
	if(s[2]=='1')++ans;
	out<<ans<<std::endl;
	return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;
const ll INF = 1LL << 60;


int main() {
    string s; cin >> s;
    ll k; cin >> k;
    for(int i = 0; i < (int)s.size(); i++){
        if(s[i] == '1' && i == k - 1){
            cout << 1 << endl;
            return 0;
        }
        if(s[i] != '1'){
            cout << s[i] << endl;
            return 0;
        }
    }

    return 0;
}


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

#define endl '\n';
using namespace std;

typedef long long int ll;

class SegmentTree {
private:
    vector<ll> st, lazy;
    int n;


    void build(int p, int l, int r) {
        if (l == r)
            st[p] = l + 1;
        else {
            int lc = p * 2, rc = p * 2 + 1;
            int mid = (l + r) / 2;
            build(lc, l, mid);
            build(rc, mid + 1, r);
            st[p] = st[lc] + st[rc];
        }
    }

    inline void upd(int id, int l, int r, ll x) {
        lazy[id] += x;
        st[id] += (r - l + 1) * x;
    }

    inline void shift(int id, int l, int r) {
        int mid = (l + r) / 2;
        upd(id * 2, l, mid, lazy[id]);
        upd(id * 2 + 1, mid + 1, r, lazy[id]);
        lazy[id] = 0;
    }

    void update(int i, int j, int x, int id, int l, int r) {
        if (l > j || r < i) return;
        if (l >= i && r <= j) {
            upd(id, l, r, x);
            return;
        }
        shift(id, l, r);
        int mid = (l + r) / 2;
        update(i, j, x, id * 2, l, mid);
        update(i, j, x, id * 2 + 1, mid + 1, r);
        st[id] = st[id * 2] + st[id * 2 + 1];
    }

    ll sum(int i, int j, int id, int l, int r) {
        if (l > j || r < i) return 0;
        if (l >= i && r <= j) return st[id];
        shift(id, l, r);
        int mid = (l + r) / 2;
        return sum(i, j, id * 2, l, mid) + sum(i, j, id * 2 + 1, mid + 1, r);
    }

public:
    SegmentTree(int _n) {
        n = _n;
        st.assign(4 * n, 0);
        lazy.assign(4 * n, 0);
        //build(1, 0, n - 1);
    }

    void update(int i, int j, int x) {
        update(i - 1, j - 1, x, 1, 0, n - 1);
    }

    ll query(int i, int j) {
        return sum(i - 1, j - 1, 1, 0, n - 1);
    }
};


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

    int n, q, s, t, x, qt;
    cin >> n >> q;
    SegmentTree st(n);
    while (q--) {
        cin >> qt >> s >> t;
        if (qt == 0) {
            cin >> x;
            st.update(s , t , x);
        } else {
            cout << st.query(s , t) << endl;
        }
    }

    return 0;
}


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

int main( void ) {
	char str[ 21 ];
	int i;

	scanf( "%s", str );

	for ( i = strlen( str ) - 1; i >= 0; i-- )
		putchar( str[ i ] );
	putchar( '\n' );

	return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
 
typedef long long   ll;
typedef long double ld;
const int N  = 5e5+10;
const ll mod = 1e9+7;
const ll inf = 1e18;
 
#define fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb              push_back
#define mp              make_pair
#define ub              upper_bound                 // first element >  val(itr)
#define lb              lower_bound                 // first element >= val(itr) 
#define all(x)          (x).begin(),(x).end()
#define reset(a,x)      memset(a,x,sizeof(a))       // x can be 0 or -1
#define leadzero(a)     __builtin_clz(a)            // count leading zeroes
#define trailzero(a)    __builtin_ctz(a)            // count trailing zeroes
#define bitcount(a)     __builtin_popcount(a)       // count set bits
#define iceil(n,x)      ((n)+(x)-1)/(x)
#define test            int t; cin>>t; while(t--)
#define forn(i,a,e)     for(ll i = a; i < e; i++)
#define pll             pair<ll,ll>
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;   }
ll lcm(ll a, ll b) { ll r=((a*b)/gcd(a,b)); return r;}
ll isOnBit(ll n, ll b) {return (n >> b) & 1;         }
ll powm(ll base,ll exp){ll ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
ll add(ll a,ll b)  { return (a%mod+b%mod)%mod;        }
ll sub(ll a, ll b) { return (a%mod+mod-b%mod)%mod;    }
ll mult(ll a,ll b) { return ((a%mod)*(b%mod))%mod;    }
ll choose2(ll n)   { ll ans=(n*(n-1))/2; return ans;  }
ll digsum(ll n)    { ll cnt=0; while(n){cnt+=(n%10); n/=10;} return cnt;}
ll dist2(ll x1,ll y1,ll x2,ll y2){ ll ans=(x2-x1)*(x2-x1)+(y2-y1)*(y2-y1); return ans;}

ll fact[N];
ll inv[N];

void init(ll n)
{
    forn(i,0,n+1)
    {
        if(i==0)
            fact[i]=1;
        else
            fact[i]=mult(fact[i-1],i);
    }
    inv[n] = powm(fact[n],mod-2);
    for(ll i=n;i>=1;i--)
    {
        inv[i-1] = mult(inv[i],i);
    }
}

ll ncr(ll n,ll r)
{
    if(n<r || n<0 || r<0)
        return 0;

    ll ans = 1;
    ans = mult(ans,fact[n]);
    ans = mult(ans,inv[r]);
    ans = mult(ans,inv[n-r]);

    return ans;
}

int main()
{
    fast
    ll n,k;
    ll ans=0;
    cin>>n>>k;
    
    init(n);
    ll blue = k,red = n-k;
    forn(i,1,k+1)
    {
        ll x = red-(i-1);
        ll r = i+1;
        ans = 1;
        ans = ncr(blue-1,i-1);
        ans = mult(ans,ncr(x+r-1,x));
        cout<<ans<<endl;
        continue; 
        if(blue-1 < i-1)
            ans = 0;
        ans = mult(fact[blue-1],powm(fact[blue-i],mod-2));
        ans = mult(ans,powm(fact[i-1],mod-2));
        
        ans = mult(ans,fact[x+r-1]);
        ans = mult(ans,powm(fact[x],mod-2));
        ans = mult(ans,powm(fact[r-1],mod-2));
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		/*
		UL Q; cin >> Q;
		rep(i, Q) {
			ULL A, B; cin >> A >> B;
			ULL S = A * B - 1;
			ULL l = 1, r = S + 1;
			while (l < r - 1) {
				ULL m = (l + r) / 2;
				if (m * m <= S) l = m;
				else r = m;
			}
			ULL ans = l * 2;
			if (l * (l + 1) > S) ans--;
			if (S / A != S / (A + 1)) ans--;
			if (S / B != S / (B + 1)) ans--;
			cout << ans << endl;
		}*/
		UL N; cin >> N;
		ULL ans = 0;
		UL d = 1000000001;
		rep(i, N) {
			UL a, b; cin >> a >> b;
			ans += a;
			if (a > b) d = min(d, b);
		}
		if (d == 1000000001) ans = 0;
		else ans -= d;
		cout << ans << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> a(N+1);
  int cnt = 0;
  for(int i=1; i<=N; i++) cin >> a[i];
  vector<int> b(N+1);
  for(int i=0; i<=N; i++) b[i] = 0;
  for(int i=N;i>=1;i--){
    int tmp = 0;
    int x = 2;
    while(i*x<=N){
      tmp += b[i*x];
      x++;
    }
    if(tmp%2 != a[i]) {b[i]++; cnt++;}
  }
  cout << cnt << endl;
  for(int i=1;i<=N;i++){
    if(b[i]) cout << i << endl;
  }

  return 0;
}


Measured memory_bytes: 2432
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
int main()
{
  int a, b, c, x;
  cin >> a >> b >> c >> x;

  int count=0;

  for (int i = 0; i < a+1; i++) {
    for (int j = 0; j < b+1; j++) {
      for(int l = 0; l < c+1; l++){
        if(x==(500*i+100*j+50*l))
          ++count;
      }
    }
  }
  cout << count << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <climits>
#include <ctime>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <deque>
#include <complex>
#include <string>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <valarray>
#include <iterator>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) container.begin(), container.end()
#define RALL(container) container.rbegin(), container.rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int n, m, r;

int g[2][201][201];
int dp[1001][201];
main(){
	ios::sync_with_stdio(false);
	while(cin >> n >> m, n){
		REP(i, n)REP(j, n) g[0][i][j] = g[1][i][j] = i==j ? 0 : INF;
		REP(i, m){
			int u,v,t;
			char c;
			cin >> u >> v >> t >> c;u--;v--;
			chmin(g[c=='S'][u][v], t);
			chmin(g[c=='S'][v][u], t);
		}
		REP(l, 2)REP(k, n)REP(i, n)REP(j, n) g[l][i][j] = min(g[l][i][j], g[l][i][k] + g[l][k][j]);
		memset(dp, 63, sizeof(dp));
		cin >> r;
		int p;
		cin >> p;p--;
		dp[0][p] = 0;
		REP(i, r-1){
			int x;
			cin >> x; x--;
			REP(j, n){
				// p->x
				chmin(dp[i+1][j], dp[i][j]+g[0][p][x]);
				REP(k, n){	// p->j->k->x
					chmin(dp[i+1][k], dp[i][j]+g[0][p][j]+g[1][j][k]+g[0][k][x]);
				}
			}
			p = x;
		}
		cout << *min_element(&dp[r-1][0], &dp[r][0]) << endl;
	}
	return 0;
}

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


using ll = long long;
const int MaxN = 2e5+10;
int N;
int A[MaxN];
int C[MaxN];


void solve()
{
    ll s = 0;
    for (int i = 1; i <= N; i++)
        s += (ll)C[i] * (C[i] - 1) / 2;
    for (int i = 1; i <= N; i++) {
        int x = C[A[i]];
        if (x == 0)
            printf("%lld\n", s);
        else
            printf("%lld\n", s - (ll)x * (x - 1) / 2 + (ll)(x - 1) * (x - 2) / 2);
    }
}


int main()
{
    scanf("%d", &N);
    for (int i = 1; i <= N; i++) {
        scanf("%d", &A[i]);
        C[A[i]]++;
    }
    solve();
    return 0;
}


Measured memory_bytes: 3712
import java.util.Scanner;

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

        String s = sc.next();

        System.out.println(solve(s));

        sc.close();
    }

    static int solve(String s) {
        return s.replaceAll("0", "").length();
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
 using namespace std;
 #define int long long
 #define endl "\n"
 const int mod=1e9+7;
 #define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 #define clr(a,x) memset(a,x,sizeof(a))
 #define T int t;cin>>t; while(t--)
 #define vll vector<int> 
 #define v22 vactor<vector<int>>
#define pb push_back
 #define sz size
 #define str to_string
 #define um unordered_map<int,int>
 #define intt stoll
 #define sv() sort(a.begin(),a.end())
 #define vp vector<pair<int, int>> b(n) 
 vector<int> adj[1000001];    
 int v[1000001]={0};
int32_t main()
{
 int n,x,y,z,b=0,c=0,d=0;
 cin>>n;
 vector<vector<int>> a(n);
 for(int i=0;i<n;i++)
 {
  cin>>x>>y>>z;
  a[i].pb(x);
  a[i].pb(y);
  a[i].pb(z);
 }
 int dp[n][3];
 dp[0][0]=a[0][0];
 dp[0][1]=a[0][1];
 dp[0][2]=a[0][2];
 for(int i=1;i<n;i++)
 {
   dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
   dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
   dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][0]);
 }
 cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

Measured memory_bytes: 36000