akhauriyash/Code-Regression huggingface dataset:
from sys import stdin, stdout, setrecursionlimit
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from functools import lru_cache
import math

#setrecursionlimit(10**6)
rl = lambda: stdin.readline()
rll = lambda: stdin.readline().split()
rli = lambda: map(int, stdin.readline().split())
rlf = lambda: map(float, stdin.readline().split())

INF, NINF = float('inf'), float('-inf')
MOD = 10**9 + 7

def main():
	n, d = rli()
	ds = pow(d, 2)
	dist_sqrd = lambda x, y: x**2 + y**2
	ans = 0
	for _ in range(n):
		x, y = rli()
		if dist_sqrd(x, y) <= ds:
			ans += 1
	print(ans)
	stdout.close()

if __name__ == "__main__":
	main()

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

typedef long long ll;

#define PI M_PI

struct Point {
    double x;
    double y;

    void prt(){
        printf("%.8f %.8f\n",x,y);
    }
};

void koch(int n,Point p1,Point p2){
    if(n==0) return ;
    Point s,t,u;
    s.x = (2*p1.x + p2.x) / 3;
    s.y = (2*p1.y + p2.y) / 3;
    t.x = (p1.x + 2*p2.x) / 3;
    t.y = (p1.y + 2*p2.y) / 3;
    u.x = (t.x - s.x)*cos(PI/3) - (t.y - s.y)*sin(PI/3) + s.x;
    u.y = (t.x - s.x)*sin(PI/3) + (t.y - s.y)*cos(PI/3) + s.y;

    koch(n-1, p1, s);
    s.prt();
    koch(n-1, s, u);
    u.prt();
    koch(n-1, u, t);
    t.prt();
    koch(n-1, t , p2);
}

int main(){
    int n;
    cin >> n;
    Point s,g;
    s.x=s.y=g.y=0;
    g.x=100;
    s.prt();
    koch(n,s,g);
    g.prt();
}



Measured memory_bytes: 3152
#include<bits/stdc++.h>
    using namespace std;
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define endl "\n"
    #define int long long

    const int N=1e5+5; 
    

    // int32_t main(){
    //     IOS;
    //     cin>>n>>s;
    //     int val[n],w[n];
    //     for(int i=0;i<n;i++){
    //         cin>>w[i]>>val[i];
    //     }
    //     int dp[n+1][s+1];
    //     for(int i=0;i<=n;i++)
    //         dp[i][0]=0;
    //     for(int i=1;i<=s;i++)
    //         dp[0][i]=0;
    //     for(int i=1;i<=n;i++){
    //         for(int j=1;j<=s;j++){
    //             if(j<w[i-1])
    //                 dp[i][j]=dp[i-1][j];
    //             else
    //             {
    //                 dp[i][j]=max(dp[i-1][j],val[i-1]+dp[i-1][j-w[i-1]]);
    //             }
                
    //         }
    //     }
    //     cout<<dp[n][s]<<endl;
    // return 0;

    // }

    // int knapsack(int w[],int val[],int s,int i,int*dp[]){
    //     if(i<0)
    //         return 0;
    //     if(dp[i][s]!=-1)
    //         return dp[i][s];
        
    //     if(w[i]>s){
    //         dp[i][s]=knapsack(w,val,s,i-1,dp);
    //         return dp[i][s];
    //     }
    //     else
    //     {
    //         dp[i][s]=max(val[i]+knapsack(w,val,s-w[i],i-1,dp),knapsack(w,val,s,i-1,dp));
    //         return dp[i][s];
    //     }
            
                
        
    // }

    
    int32_t main(){
        IOS;
        int s,n;
        cin>>n>>s;
        int val[n],w[n];
        int sum=0;
        for(int i=0;i<n;i++){
            cin>>w[i]>>val[i];
            sum+=val[i];
        }
        // int** dp;
        // dp=new int*[n];
        // for(int i=0;i<n;i++)
        //     dp[i]=new int[s+1];
        // for(int i=0;i<n;i++){
        //     for(int j=0;j<=s;j++)
        //         dp[i][j]=-1;
        // }
        // memset(dp,-1,sizeof(dp)*sizeof(int));
        int dp[n+1][sum+1];
        for(int i=0;i<=n;i++){
            for(int j=0;j<=sum;j++)
                dp[i][j]=INT_MAX;
        }
        for(int i=0;i<=n;i++)
            dp[i][0]=0;
        for(int i=1;i<=n;i++){
            for(int  j=1;j<=sum;j++){
                dp[i][j]=min(dp[i-1][j],(val[i-1]<=j?w[i-1]+dp[i-1][j-val[i-1]]:INT_MAX));
            }
        }
        int ans=0;
        for(int i=sum;i>0;i--){
            if(dp[n][i]!=INT_MAX && dp[n][i]<=s){
                ans=i;
                break;
            }
        }
        cout<<ans<<endl;
        // cout<<knapsack(w,val,s,n-1)<<endl;
    return 0;

    }

Measured memory_bytes: 82424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
const int Nmax=200010;
 
int main() {
	int K;
 	bool flag=true;
	ll A[Nmax];
	cin >> K;
	for(int i=0;i < K;i++) cin >> A[i];
	if(A[K-1] != 2){
		cout << "-1" << endl;
		return 0;
	}
	ll mina=2,mac=3; //最少人数
	for(int i=K-2;i >= 0;i--){
      	//ll a = A[i] % mina;
      	//ll b = mina;
	  	if(mina > mac) flag=false;
		if(A[i] >= mina) mina = A[i];
		else mina = ceil((double)mina/A[i]) * A[i];
      	//if(mina-b > a) flag = false; //あり得ない人数離脱したらfalse
	  	mac = (mac/A[i]+1) * A[i] -1;
	}
 	if(mina > mac) flag = false;
	if(flag) cout << mina << " " << mac << endl;
  	else cout << "-1" <<endl;
	return 0;
}


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

int main() {

    // input from txt （提出時にこの箇所は削除すること）
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    
    int64_t A, B, N;
    cin >> A >> B >> N;
    int64_t ans = 0;
    if(B == 1){
        ans = 0;
    }
    else if(N < B-1){
        int64_t a = A*N;
        a /= B;
        ans = a;
    }
    else{
        int64_t a = A*(B-1);
        a /= B;
        ans = a;
    }
    cout << ans << endl;
}



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

int main() {
  int X, N, a;
  int u, l;
  cin >> X >> N;
  vector<int> vec(102);
  for (int i = 0; i < 102; i++) {
    vec.at(i)=0;
  }
  for (int i = 1; i < N+1; i++) {
    cin >> a;
    vec.at(a)=1;
  }
  if (vec.at(X)==0){
    cout << X << endl;
  }
  else{
    for (int i=X+1; i < 102; i++){
      if (vec.at(i)==0){
        u=i;
        break;
      }
    }
    for (int i=X-1; i >= 0; i--){
      if (vec.at(i)==0){
        l=i;
        break;
      }
    }
    if (u-X < X-l)
      cout << u << endl;
    else
      cout << l << endl;
  }
}

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

int main(){
  int a,a1,a10,a100;
  
  cin >> a;
  
  a100 = a/100;
  a10 = a/10 - a100*10;
  a1 = a - a10*10 - a100*100;  
  
  cout << a1+a10+a100 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>

inline int read() {
	int x = 0, f = 1; char ch = getchar();
	while(ch > '9' || ch < '0') { if(ch == '-') f = -1; ch = getchar(); }
	do x = x * 10 + ch - 48, ch = getchar(); while(ch >= '0' && ch <= '9');
	return x * f;
}

typedef long long ll;
const int MAXN = 200001;
const int MOD = 1000000007;

int n,k;

int main() {
	n = read(), k = read();
	ll res = 0;
	for(ll i = k;i <= n + 1;i++) {
		ll l = ((i - 1ll) * i / 2) % MOD;
		ll r = ((n + n - i + 1ll) * i / 2) % MOD;
		res = ((res + r - l + 1ll) % MOD + MOD) % MOD;
	}
	std::printf("%lld\n",res);
	return 0;
}


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

int main( void )
{
    int N;
    cin >> N;
    ll Y;
    cin >> Y;
    
    int x = -1,y = -1,z = -1;
    for ( int yukichis = 0; yukichis <= N; yukichis++ )
    {
        for ( int higuchis = 0; yukichis + higuchis <= N; higuchis++ )
        {
            int noguchis = N - yukichis - higuchis;
            ll totalOtoshidama = yukichis*10000 + higuchis*5000 + noguchis*1000;
            if ( totalOtoshidama == Y )
            {
                x = yukichis;
                y = higuchis;
                z = noguchis;
            }
        }
    }
    
    cout << x << ' ' << y << ' ' << z << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int i = 1, x;
    while (cin >> x && x){
        printf("Case %d: %d\n", i++, x);
    }
    return 0;
}

Measured memory_bytes: 3108
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
    String str=sc.next();
    if(str.equals("Sunny")){
      System.out.println("Cloudy");
    }
    if(str.equals("Cloudy")){
      System.out.println("Rainy");
    }
    if(str.equals("Rainy")){
      System.out.println("Sunny");
    }
  }
}

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

int main(){
	string str ,com ,p ;
	int q ,a ,b ;

	cin >> str >> q;
	for(int t = 0 ; t < q; t++){
		cin >> com >> a >> b;
		if( com == "print"){
			cout << str.substr(a, b-a+1) << endl;
		}else if( com == "reverse"){
			string tmp = str.substr(a, b-a+1);
			int n = tmp.size();
			for( int i = 0; i < n; i++) str[i+a] = tmp[n-i-1];
		}else if( com == "replace"){
			cin >> p;
			str = str.replace(a, b-a+1, p);
		}
	}
	return 0;
}

Measured memory_bytes: 3156
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		@SuppressWarnings("resource")
		Scanner scanner = new Scanner(System.in);

//		int N = scanner.nextInt();
//
//		int K = scanner.nextInt();

		int A = scanner.nextInt();

		int B = scanner.nextInt();

		int dengen = 1;
		int ans = 0;

		while(dengen < B) {
			dengen--;
			dengen = dengen + A;
			ans++;
		}

		log(ans);

//		int[] scannerArray = new int[N];
//
//		for (int index = 0; index < N; index++) {
//			scannerArray[index] = scanner.nextInt();
//		}
//
//		int tmp = countSwapBabbleSort(scannerArray);
//
//		log((
//				(BigInteger.valueOf((long)tmp)
//				.multiply(BigInteger.valueOf((long)K)
//						))
//				.add((
//						BigInteger.valueOf((long)tmp)
//						.multiply(
//								BigInteger.valueOf((long)K)
//								.multiply(
//										BigInteger.valueOf((long)K)
//										.subtract(BigInteger.ONE)
//										)
//								.divide(BigInteger.valueOf((long)2)
//										)
//								)
//						)))
//				.remainder(
//						BigInteger.valueOf((long)1000000007)
//						)
//				.toString());
	}


	/**
	 * バブルソートの交換数を算出
	 * ※転倒数
	 * @param array
	 * @return
	 */
	private static int countSwapBabbleSort(int[] array) {
		int ans = 0;
		int[] binary = new int[array.length + 1];

		for (int index = 0; index < array.length; index++) {
			ans = ans + (index - sum(binary, array[index]));
			add(binary, array[index], 1);
		}
		return ans;
	}

    //add value at idx on bit O(logN)
	private static void add(int[] bit,int idx,int value) {
        for(int i=idx;i<bit.length;i=i+(i&-i)) {
        	bit[i] += value;
        }
    }

    //return sum [1,idx] O(logN)
	private static int sum(int[] bit,int idx) {
        int ret = 0;
        for(int i=idx;i>0;i-=(i&-i)) {
        	ret += bit[i];
        }
        return ret;
    }

	private static void log(String str) {
		System.out.println(str);
	}

	private static void log(int str) {
		System.out.println(str);
	}

	private static void log(double str) {
		System.out.println(str);
	}

}



Measured memory_bytes: 23120
#include <bits/stdc++.h>
using namespace std;
 
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
using ll = long long;
const ll MOD = 998244353;
 
ll mpow(ll a, ll b) {
    a %= MOD;
    ll res = 1;
    while (b > 0) {
        if (b & 1) res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res;
}
 
ll minv(ll a) {
    return mpow(a, MOD - 2);
}

int n, s;
ll val[3005];
 
int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    ll speed = minv(2);

    cin >> n >> s;
    vector<int> a(n);
    for (auto& i : a) {
        cin >> i;
        
        for (int j = s - i; j >= 0; --j) {
            val[j + i] += val[j] * speed % MOD;
            val[j + i] %= MOD;
        }

        val[i] += mpow(2, n - 1);
        val[i] %= MOD;
    }
    cout << val[s] % MOD;
}


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

int main(){
    int n;
    cin >> n;
    int A[n];
    for(int i=0;i<n;i++) cin >> A[i];
  	int c = 0;
    
    for (int k=0;k<n-1;k++){
    	cout << A[k] << " ";
    }
    cout << A[n-1] << endl;
  
  	for (int i=1;i<n;i++){
    	for (int j=0;j<i;j++){
        	if (A[j] > A[i]){
            	c = A[j];
              	A[j] = A[i];
                A[i] = c;
            }
        }
    	for (int k=0;k<n-1;k++){
    		cout << A[k] << " ";
    	}
      	cout << A[n-1] << endl;
    }
    
}


Measured memory_bytes: 3068
//If you are reading this then you are at wrong place.
#include<bits/stdc++.h>
#define mod 1000000007
#define lli long long int
using namespace std;
bool prime [1000001];
void debug(lli a){cout<<a<<endl;}
lli sieve(lli a){memset(prime,true,sizeof(prime));lli p,i;for(p=2;p*p<=a;p++){if(prime[p]==true){for(i=p*2;i<=a;i+=p)prime[i]=false;}}return 0;}
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli find_max(lli __a,lli __b){return __a^((__a^__b) & -(__a<__b));}
lli add(lli __a,lli __b,lli MOD){lli x = (__a+__b)%MOD; return x; }
lli mul(lli a,lli b,lli MOD){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b,lli MOD){lli x = (a-b+MOD)%MOD; return x; }
lli div(lli a,lli b,lli MOD){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}
int main()
{
	//ifstream cin("testcase.txt");
	//ofstream cout("output.txt");	
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);	
	cout.precision(20);
	lli t,i,j;
	//cin>>t;
	//memset(dp, -1, sizeof dp);
	t=1;
	lli counter1=0;
	while(t--)
	{
		counter1++;
		lli n;
		cin>>n;
		lli a[n];
		vector<lli>answer,answer1;
		for(i=0;i<n;i++)
		{
			cin>>a[i];
			if(i%2==0)
				answer.push_back(a[i]);
			else
				answer1.push_back(a[i]);
		}
		if(n%2==0)
		{
			reverse(answer1.begin(),answer1.end());
			for(i=0;i<answer1.size();i++)
				cout<<answer1.at(i)<<" ";
			for(i=0;i<answer.size();i++)
				cout<<answer.at(i)<<" ";
			cout<<endl;
		}
		else
		{
			reverse(answer.begin(),answer.end());
			for(i=0;i<answer.size();i++)
				cout<<answer.at(i)<<" ";
			for(i=0;i<answer1.size();i++)
				cout<<answer1.at(i)<<" ";
			cout<<endl;
		}
		//cout<<"Case #"<<counter1<<" ";
		//cout<<endl;	
	}	
}


Measured memory_bytes: 5484
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    string s;
    int cnt = 0;
    cin>>s;
    cout<<s[0]<<s.size()-2<<s[s.size()-1]<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

box=[]
#リストの中の１つを入れ替えたら123456・・・になるようにする
for i in range(n):
  if i+1 == a[i]:
    pass
  else:
    box.append(i)
if len(box) == 0 or len(box) == 2:
  print('YES')
else:
  print('NO')

Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define vi vector<int>

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

int main()
{
    int a, b;

    cin >> a >> b;
    cout << max({a + b, a - b, a * b}) << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main()
{
	int X, Y;
	cin >> X >> Y;
	if(4*X-Y<0 || (4*X-Y)%2!=0){
		cout << "No" << endl;
		return 0;
	}
	int x = 4*X-Y;
	x /= 2;
	if(x > X){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 3632
h,m,M=60;P(s){printf("0%d:%02d:%02d\n",s/M/M,s/M%M,s%M);}main(s){for(;scanf("%d%d%d",&h,&m,&s)*~h;P(s*3))P(s=(120-h*M-m)*M-s);}///////

Measured memory_bytes: 612
N=int(input())
L=['a','b','c','d','e','f','g','h','i','j']

Ans = [L[0]]
Backup = []

for k in range(N-1):
    Backup = Ans
    Ans = [i+L[j] for i in Backup for j in range(len(set(i))+1)]

for i in Ans:
    print(i)

Measured memory_bytes: 14168
#include <iostream>
#include <cstdio>
using namespace std;
int ans,a[100005],r;
string str;
int main()
{
	cin>>str;
	for(int i=0;str[i]!='\0';i++)
	{
		a[++r]=(str[i]-'0');
		while(r>1&&a[r]+a[r-1]==1)
		{
			ans+=2;
			r-=2;
		}
//		cout<<r<<' ';
	}
	cout<<ans;
	return 0;
}


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

string a,b;
int n;

int main()
{
	cin>>n;
	cin>>a>>b;
	for(int i = 1;i <= n * 2;i++)
	{
		if(i % 2 == 1) cout<<a[i / 2];
		else cout<<b[i / 2 - 1];
	} 
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        int[] PQR = ReadLineParseIntArray();
        int P = PQR[0];
        int Q = PQR[1];
        int R = PQR[2];

        int ans = int.MaxValue;
        ans = Min(P + Q, ans);
        ans = Min(P + R, ans);
        ans = Min(Q + R, ans);
        WriteLine(ans);
    }

    static int[] ReadLineParseIntArray() => ReadLine().Split(' ').Select(int.Parse).ToArray();
}

Measured memory_bytes: 11348
#include <stdio.h>

int main(){
    int N, array[100];
    scanf("%d\n",&N);
    for ( int ix = 0 ; ix < N ; ix++)
        scanf("%d ",&array[ix]);
    int counter = 0;
    for ( int ix = 0 ; ix < N ; ix++ ){
        int ixmin = ix;
        for ( int jx = ix ; jx < N ; jx++)
            if ( array[jx] < array[ixmin] ) ixmin = jx;
        if ( ixmin != ix ){
            int temp = array[ixmin];
            array[ixmin] = array[ix];
            array[ix] = temp;
            counter++;
        }
    }
    
    for ( int ix = 0; ix < N; ix++){
        if ( ix != N-1 ) printf("%d ",array[ix]);
        else printf("%d\n",array[ix]);
    }
    printf("%d\n",counter);
    return 0;
}


Measured memory_bytes: 2128
#include <iostream>
#include <utility>
#include <algorithm>
using namespace std;
typedef long long ll;
int n;
ll k;
pair<int,int> p[100000];

int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>p[i].first>>p[i].second;
    }sort(p,p+n);
    for(int i=0;;i++){
        if(k<=p[i].second){
            cout<<p[i].first;
            return 0;
        }
        k-=p[i].second;
    }
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)      x.begin(), x.end()
#define rep(i,n)    for (i64 i = 0; i < (n); ++i)
#define reps(i,s,t) for (i64 i = (s); i <= (t); ++i)
#define repr(i,s,t) for (i64 i = (s); i >= (t); --i)

#ifdef DBG
#define trace(...) _trace(#__VA_ARGS__, __VA_ARGS__);
#else
#define trace(...)
#endif

using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template<class T, class U>inline bool chmax(T &a, const U &b){return b>a ? (a=b,1) : 0;}
template<class T, class U>inline bool chmin(T &a, const U &b){return b<a ? (a=b,1) : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template<class T>
ostream& operator<< (ostream &os, const vector<T> &vec) {
    rep(i, vec.size()) os << vec[i] << (i+1 == vec.size() ? "" : " ");
    return os;
}

template<class T, class U>
ostream& operator<< (ostream &os, const pair<T, U> &p) {
    return os << p.first << ' ' << p.second;
}

template <class T>
void _trace(const char *s, T&& x)
{
    clog << '{';
    while(*s != '0' && *s != ',') clog << *(s++);
    clog << ":" << setw(3) << x << '}' << endl;
}

template <class Head, class... Tail>
void _trace(const char *s, Head&& head, Tail&&... tail)
{
    clog << '{';
    while(*s != ',') clog << *(s++);
    clog << ":" << setw(3) << head << "}, ";
    for (++s; !isgraph(*s); ++s);
    _trace(s, std::forward<Tail>(tail)...);
}
// }}} End Header

signed main()
{
    // ios::sync_with_stdio(false); cin.tie(nullptr);

    char a, b;
    cin >> a >> b;

    if (a == 'D') b = (b == 'H' ? 'D' : 'H');

    cout << b << endl;

    return 0;
}


Measured memory_bytes: 256
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;

string to_string(const string& s) { return '"' + s + '"'; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif
 
#define cin_exception cin.exceptions(cin.failbit);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using ll = int_fast64_t; using ld = long double;

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

void solve() {
    int n; cin >> n;
    map<string, int> m;
    for (int i = 0; i < n; ++i) {
        string s; cin >> s;
        ++m[s];
    }
    pair<int, string> a[n]; int a_id = 0;
    for (auto &p : m) {
        a[a_id++] = {p.second, p.first};
    }
    sort(a, a + a_id, [&](auto &l ,auto &r) -> bool {
        if (l.first != r.first) return l.first > r.first;
        return l.second < r.second;
    });
    for (int i = 0; i < a_id; ++i) {
        if (i > 0 && a[i].first != a[i - 1].first) break;
        cout << a[i].second << '\n';
    }
}


int main() {
    fast_io; cin_exception;
    int t = 1; // cin >> t;
    for (int i = 0; i < t; ++i) {
        solve();
    }
}


Measured memory_bytes: 27008
#include<stdio.h>
int main(void){
  int r,c;
  scanf("%d%d",&r,&c);
  if(r*c<1)
    return 0;
  int number[r][c],i,j;
  int Lsum[r];
  int Csum[c];
  int Sum=0;
  for(i=0;i<r;i++)
    Lsum[i]=0;
  for(j=0;j<c;j++)
    Csum[j]=0;

  for(i=0;i<r;i++){
    for(j=0;j<c;j++){
      scanf("%d",&number[i][j]);
      Csum[j]+=number[i][j];
      Lsum[i]+=number[i][j];
      Sum+=number[i][j];
    }
  }

  for(i=0;i<r;i++){
    for(j=0;j<c;j++){
      printf("%d ",number[i][j]);
    }
    printf("%d\n",Lsum[i]);
  }
  for(j=0;j<c;j++){
    printf("%d ",Csum[j]);
  }
  printf("%d\n",Sum);
  return 0;
}

Measured memory_bytes: 640
package main

import (
  "fmt"
)

func main() {
  var n int
  fmt.Scanf("%d", &n)
  
  ans := ""
  n = n % 10
  switch n {
    case 3:
    	ans = "bon"
    case 0:
    	fallthrough
    case 1:
    	fallthrough
    case 6:
    	fallthrough
    case 8:
    	ans = "pon"
    default:
    	ans = "hon"
  }
  
  fmt.Printf("%s\n", ans)
}

Measured memory_bytes: 1836
n, ww = gets.to_s.split.map{|i|i.to_i}

h = { 0 => 0 }

n.times{
	a, b = gets.to_s.split.map{|i|i.to_i}
	h.to_a.each{ | w, v |
		  h[ w + a ] = v + b if w + a <= ww && (h[ w + a ] || 0) < v + b
	}
}

puts h.values.max

Measured memory_bytes: 2428
#include <stdio.h>

int main(){
	int h,w;
	int i,t;
	while(1){
		scanf("%d %d", &h, &w);
		if(h==0 && w==0)break;
		for(i = 0;i < h;i++){
			for(t = 0;t < w;t++){
				printf("#");
			}
			puts("");
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 588
N = int(input())
A = list(map(int, input().split()))
A.sort()
sm = 0
p = -1
# print(A)
for i in range(N-1):
    sm += A[i]
    if 2*sm < A[i+1]:
        p = i
    # print(sm,2*A[i+1])
# print(p)
print(N-p-1)


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll Pow(ll A, ll N){
  if (N == 0) return 1;
  if (N % 2 == 0) return Pow(A*A%MOD, N/2);
  else return Pow(A*A%MOD, N/2) * A % MOD;
}

int N, K;
ll A[int(1e5+5)], nCr[int(1e5+5)];

int main(){
  cin >> N >> K;
  for (int i = 1; i <= N; i++) cin >> A[i];
  sort(A+1, A+N+1);

  nCr[K-1] = 1;
  for (ll i = K; i <= N; i++){
    nCr[i] = nCr[i-1] * i % MOD;
    nCr[i] *= Pow(i-(K-1), MOD-2);
    nCr[i] %= MOD;
  }

  ll ans = 0;
  for (int i = 1; i <= N; i++){
    ll now = (nCr[i-1] - nCr[N-i]) * A[i] % MOD;
    ans += now; ans %= MOD;
    if (ans < 0) ans += MOD;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4720
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';
int mod = 1e9 + 7;
ll inf = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << n * n * n << endl;
    return 0;
}

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

using namespace std;

//#define int long long
//#define double long double

int n;
vector<int> g[100];
int mt[100];
int rx[100], ry[100];
int bx[100], by[100];
char used[100];

bool dfs(int v){
    if(used[v]) return false;
    used[v] = true;
    for(auto to: g[v]){
        if(mt[to] == -1 || dfs(mt[to])){
            mt[to] = v;
            return true;
        }
    }
    return false;
}

main()
{
    ios_base::sync_with_stdio(0);
    cin >> n;
    for(int i = 0; i < n; i++) cin >> rx[i] >> ry[i];
    for(int i = 0; i < n; i++) cin >> bx[i] >> by[i];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            if(rx[i] < bx[j] && ry[i] < by[j]){
                g[i].push_back(j);
            }
        }
    }
    memset(mt, -1, sizeof(mt));
    int an = 0;
    for(int i = 0; i < n; i++){
        memset(used, 0, sizeof(used));
        an += dfs(i);
    }
    cout << an << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n,a,b,count=0;cin >> n>>a>>b;
  if (a==b || (a<b && n==2)) count++;
  else if (a<b && n>=3) {
    count+=(b-a)*(n-2)+1;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	char s[100];
	cin>>s;
	int d = strlen(s);
	if( d<=n ) cout<<s;
	else{
		for( int i=0; i<n ; i++ ) cout<<s[i];
		cout<<"...";
	}
}


Measured memory_bytes: 3548
#include "iostream"
#include "set"

using namespace std;

int main(){
	int N;
	set<set<int> >s;
	cin>>N;
	for(int i=0;i<N;i++){
		set<int>box;
		for(int j=0;j<3;j++){
			int a;
			cin>>a;
			box.insert(a);
		}
		s.insert(box);
	}
	cout<<N-s.size()<<endl;
	return 0;
}


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

int main(){
    ll N; cin>>N;
    ll count=1,ans=0,m=N;
    for(ll i=0;i<N;i++){
        ll a; cin>>a;
        m=min(m,a);
        if(a==count){
            count++;
        }else{
            ans++;
        }
    }
    if(m!=1){
        cout<<-1<<endl;
        return 0;
    }
    cout<<ans<<endl;
}
    

Measured memory_bytes: 256
import static java.lang.System.out;
import java.util.List;
import java.util.LinkedList;
import java.util.Scanner;

class PrintTestCases {
    private StringBuilder msg;

    PrintTestCases(List<Integer> data) {
        // create a message
        this.msg = new StringBuilder();
        for (int i = 0; i < data.size(); i++) {
            if (data.get(i) == 0) break;
            this.msg.append(String.format("Case %d: %d\n", i+1, data.get(i)));
        }
    }

    @Override
    public String toString() {
        return msg.toString().trim();
    }
}

public class Main {
    public static void main(String... args) {
        List<Integer> data = new LinkedList<>();

        // input
        Scanner scan = new Scanner(System.in);
        while (scan.hasNext()) {
            data.add(scan.nextInt());
        }

        // output
        out.println(new PrintTestCases(data));

        /*
        for (int i = 0; i < data.size(); i++) {
            if (data.get(i) == 0) break; // 0???????????????
            out.printf("Case %d: %d\n", i+1, data.get(i) );
        }
        */
    }
}

Measured memory_bytes: 62060
N, x = map(int, input().split())
a = list(map(int, input().split()))

count = 0

for i, c in enumerate(a):
	try:
		j = a[i + 1]
	except IndexError:
		break
	while (a[i + 1] + c) > x:
		if (a[i + 1] + c) == x:
			break
		count += abs(x - (a[i + 1] + c))
		a[i + 1] -= abs(x - (a[i + 1] + c))
		if a[i + 1] <= 0:
			a[i + 1] = 0
			break
	else:
		continue

print(count)


Measured memory_bytes: 14592
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    if (n >= m / 2)
    {
        ans = m / 2;
    }
    else
    {
        ans = n;
        m -= 2 * n;
        ans += m / 4;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
const Main = (input: string): void => {
	const num = parseInt(input)
	const ary = input.trim().split("")
	let sum = 0
	for (let i = 0; i < ary.length; i++) {
		sum += parseInt(ary[i])
	}
	const div: number = num % sum
	const ret: boolean = div === 0
	console.log(ret ? "Yes" : "No")
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t A,B,K;
  cin>>A>>B>>K;
  if(A>K){
    A=A-K;
    cout<<A<<" "<<B<<endl;
  }else{
    K=K-A;
    A=0;
    if(B<=K){
      cout<<0<<" "<<0<<endl;
    }else{
      B=B-K;
      cout<<A<<" "<<B<<endl;
    }
  }
}
  
      
      

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

ll N,C;
ll X[100000];
ll V[100000];
ll R[100000];
ll L[100000];

int main(){
    cin >> N >> C;
    for(int i=0;i<N;i++) cin >> X[i] >> V[i];
    ll c = 0;
    for(int i=0;i<N;i++){
        c += V[i];
        R[i] = max((ll)0, c-X[i]);
        if(i > 0) R[i] = max(R[i], R[i-1]);
    }
    c = 0;
    for(int i=N-1;i>=0;i--){
        c += V[i];
        L[i] = max((ll)0,c-(C-X[i]));
        if(i < N-1) L[i] = max(L[i], L[i+1]);
    }
    ll max_c = max(R[N-1],L[0]);
    for(int i=0;i<N-1;i++){
        ll m = R[i] + L[i+1] - min(X[i], C-X[i+1]);
        max_c = max(max_c, m);
    }
    cout << max_c << endl;
    return 0;
}

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

public class MainClass
{
	public const long Giri = 1000000007;
	
	public static void Main(string[] args)
	{
		string[] rt = Input();
		int n = int.Parse(rt[0]);
		int d = int.Parse(rt[1]);
		int[,] xs = new int[n, d];
		for(int i = 0; i < n; i++)
		{
			rt = Input();
			for(int j = 0; j < d; j++)
			{
				xs[i, j] = int.Parse(rt[j]);
			}
		}
		int r= 0;
		for(int i = 0; i < n; i++)
		{
			for(int k = i + 1; k < n; k++)
			{
				int b = 0;
				for(int j = 0; j < d; j++)
				{
					int p = Math.Abs(xs[i, j] - xs[k, j]);
					b += p*p;
				}
				double sqrt = Math.Sqrt(b);
				if((int)sqrt==sqrt)
				{
					r++;
				}
			}
		}
		Console.WriteLine(r);
	}

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

	
	public static int Clamp(int val, int max, int min = 0)
	{
		return Math.Min(max, Math.Max(min, val));
	}

	
}



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

int main()
{
    std::size_t X, Y, A, B, C;
    std::cin >> X >> Y >> A >> B >> C;

    std::vector<std::uint64_t> ps(A);
    std::vector<std::uint64_t> qs(B);
    std::vector<std::uint64_t> rs(C);

    for(auto& p : ps) {std::cin >> p;}
    for(auto& q : qs) {std::cin >> q;}
    for(auto& r : rs) {std::cin >> r;}

    const auto gt = [](const std::uint64_t lhs, const std::uint64_t rhs) noexcept -> bool {return lhs > rhs;};

    std::sort(ps.begin(), ps.end(), gt);
    std::sort(qs.begin(), qs.end(), gt);
    std::sort(rs.begin(), rs.end());

    ps.erase(ps.begin() + X, ps.end());
    qs.erase(qs.begin() + Y, qs.end());

    while(!rs.empty())
    {
        if(std::min(ps.back(), qs.back()) < rs.back())
        {
            if(ps.back() < qs.back())
            {
                ps.pop_back();
                ps.insert(std::lower_bound(ps.begin(), ps.end(), rs.back(), gt), rs.back());
            }
            else // qs.back() <= ps.back()
            {
                qs.pop_back();
                qs.insert(std::lower_bound(qs.begin(), qs.end(), rs.back(), gt), rs.back());
            }
            rs.pop_back();
        }
        else
        {
            break;
        }
    }

    std::size_t ans = 0;
    for(const auto& p : ps)
    {
        ans += p;
    }
    for(const auto& q : qs)
    {
        ans += q;
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 2560
N, H, D = map(int,input().split())
MOD = 10**9 + 7

fact = [1]
fact_cum = [0] # 1! to N!
for i in range(1,N+1):
  fact.append((fact[-1]*i)%MOD)
  fact_cum.append((fact_cum[-1] + fact[-1])%MOD)

dp = [0] * (H+1)
dp_cum = [0] * (H+1)
dp[0] = 1
dp_cum[0] = 1

for n in range(1,H+1):
  x = dp_cum[n-1]
  if n > D:
    x -= dp_cum[n-D-1]
  x *= fact_cum[N]
  x %= MOD
  dp[n] = x
  dp_cum[n] = (dp_cum[n-1] + x)%MOD


answer = dp[H]
answer *= fact[N]
answer %= MOD
answer *= pow(fact_cum[N],MOD-2,MOD)
answer %= MOD

print(answer)

Measured memory_bytes: 161360
#include <iostream>

using namespace std;

int main()
{
    int a[3];
    int k;
    int max = 0;
    int maxIdx = 0;

    cin >> a[0] >> a[1] >> a[2];
    cin >> k;

    max = a[0];
    maxIdx = 0;
    for (int i = 1; i < 3; i++) {
        if (a[i] > max) {
            max = a[i];
            maxIdx = i;
        }
    }

    for (int i = 0; i < k; i++) {
        a[maxIdx] *= 2;
    }

    int sum = 0;
    for (int i = 0; i < 3; i++) {
        sum += a[i];
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int largest = -999999;
        int add = a + b;
        int sub = a - b;
        int mul = a * b;

        largest = add > largest ? add : largest;
        largest = sub > largest ? sub : largest;
        largest = mul > largest ? mul : largest;

        System.out.println(largest);
    }
}

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

int main(void){
    ll k;
    cin >> k;
    
    ll alina = -1;
    if(k % 2 == 0 || k % 5 == 0)cout << alina << endl;
    else {
        ll gray = 7 % k;
        for(int i = 1;i <= 1e8;i++){
            if(gray == 0){
                alina = i;
                break;
            }
            gray = gray*10 + 7;
            gray %= k;
        }
        cout << alina << endl;
    }
}

Measured memory_bytes: 3632
use std::io::*;
use std::str::FromStr;

pub fn read<t: FromStr>() -> t {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp::max;

fn main() {
    let n: usize = read();
    let mut p: Vec<i64> = vec![];

    for i in 2..55555 + 1 {
        if (2..(i as f64).sqrt() as i64 + 1)
            .into_iter()
            .all(|x| i % x != 0)
        {
            if i % 5 == 1 {
                p.push(i);
            }
            if p.len() >= n {
                break;
            }
        }
    }

    for i in 0..p.len() {
        print!("{} ", p[i]);
    }
}


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

const long long mod = 1e9 + 7;

void contain(string a, string b){
        int al = a.length();
        int bl = b.length();
        if(al > bl) return;

        long long t = 1;
        for(int i = 0; i < al; i++) t *= mod;

        long long ah = 0, bh = 0;
        for(int i = 0; i < al; i++) ah = ah * mod + a[i];
        for(int i = 0; i < al; i++) bh = bh * mod + b[i];

        for(int i = 0; i + al <= bl; i++){
                if(ah == bh) cout << i << endl;
                if(i + al < bl) bh = bh * mod + b[i + al] - b[i] * t;
        }
        return ;
}

int main(){
        int q;
        string a,b;
        cin >> a >> b;
        contain(b,a);
        return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta (bas + (son-bas)/2)
#define coc g[node][i]
#define mod 1000000007
#define inf 1e18
#define N 1000005

using namespace std;
 
typedef long long ll;

int a,n;
double ans = 0;

int main()
{
    cin >> a;
    for (int i = 0; i < a; ++i)
    {
    	cin >> n;

    	ans += 1.0 / n;
    }

    ans = 1.0 / ans;

    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)(n);++i)
#define rep1(i, n) for (int i=1;i<=(int)(n);++i)
#define range(i, l, r) for (int i=l;i<(int)(r);++i)
#define rrange(i, l, r) for (int i=r-1;i>=(int)(l);--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;
using ll=long long;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

const int mod = 1e9 + 7;

bool path[10][10];

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

	rep(i, M) {
		int a, b; cin >> a >> b;
		--a, --b;
		path[a][b] = path[b][a] = true;
	}

	vi arr;
	rep(i, N) arr.PB(i);

	int ans = 0;

	do {
		if (arr[0] != 0) continue;
		bool f = true;

		rep(i, N - 1) {
			if (not path[arr[i]][arr[i + 1]]) {
				f = false;
			}
		}

		ans += f;
	} while (next_permutation(all(arr)));

	cout << ans << endl;
}



Measured memory_bytes: 256
<?php
fscanf(STDIN,"%d",$n);
$a_count = array();
for($i=0;$i<$n;$i++){
  fscanf(STDIN,"%d",$a);
  if($a_count[$a] == 0 || !isset($a_count[$a])){
      $a_count[$a]++;
  }else{
      $a_count[$a] = 0;
  }

}

sort($a_count);
$count = 0;
foreach($a_count as $a){
  if($a == 1){
      $count++;
  }
}

echo $count."\n";

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

int main(){
	long a, b, n;
	while(cin >> a >> b >> n){
		long s=0;
		long f=a;
		
		for(int i=1; i<=n; ++i){
			f=f%b*10;
			s+=f/b;
		}
		
		printf("%ld\n", s);
	}
}

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

#define FOR(i, a, b) for(int i = a; i < b; i ++)
#define FORS(i, a, b, c) for(int i = a; i < b; i += c)
#define FORN(i, a, b) for(int i = a; i <= b; i ++)
#define FORD(i, a, b) for(int i = a-1; i >= b; i --)
#define FORE(i, b) for(auto &i:b)
#define REP(i, b) FOR(i, 0, b)
#define REPN(i, b) FORN(i, 0, b)
#define SQ(i) (i*i)
#define ALL(a) a.begin(), a.end()
#define ALLA(a,n) a, a+n
#define SORT(a) sort(ALL(a))
#define SORTA(a, n) sort(ALLA(a, n))
#define REV(a) reverse(ALL(a))
#define REVA(a, n) reverse(ALLA(a, n))
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define IN(a, b) (a.find(b) != a.end())
#define BACK(a) a.back(); a.RB()
#define QBACK(a) a.top(); a.pop()
#define PRINT(a) FORE(i, a) cout << i << " "; cout << endl

#define PB  push_back
#define RB  pop_back
#define RF  pop_front
#define INS insert
#define F   first
#define S   second
#define UM  unordered_map
#define US  unordered_set
#define PQ  priority_queue

#define IO ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<ll,ll> pll;
typedef queue<int> qi;
typedef queue<double> qd;
typedef queue<ll> qll;
typedef US<int> si;
typedef US<double> sd;
typedef US<ll> sll;
typedef vector<vi> mi;
typedef vector<vd> md;
typedef vector<vll> mll;
typedef vector<pi> vpi;
typedef vector<pd> vpd;
typedef vector<pll> vpll;


int main(){
  IO; int N; cin >> N;
  vi H(N); REP(i, N) cin >> H[i];
  vi dp(N); dp[0] = 0;
  FOR(i, 1, N){
    dp[i] = dp[i-1] + abs(H[i] - H[i-1]);
    if(i > 1) MIN(dp[i], dp[i-2] + abs(H[i] - H[i-2]));
  }
  cout << dp[N-1] << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <set>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);

void solve() {
  int n; cin >> n;
  int ans = 0;
  for (int i=1;i <=n;i++) {
    if (i%2 != 0) ans++;
  }
  //ceil(a/b) = (a+b-1)/b 切り上げ
  double sum = (double)ans/(double)n;
  printf("%.10f\n", sum); // 小数点以下１０桁
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <utility>
#include <set>
#include <map>
#include <vector>
#include <queue>
#define LL long long
#define PII pair<int, int>
#define f first
#define s second
using namespace std;
const int MAXN = 15;

int n;
string cur;
vector<string> all;

void dfs(char id) {
    int ptr = 0;
    while (ptr < n && cur[ptr] != '\0') {
        ptr++;
    }
    if (ptr == n) {
        all.push_back(cur);
        return;
    }

    vector<int> pos;
    for (int i = ptr + 1; i < n; i++) {
        if (cur[i] == '\0') {
            pos.push_back(i);
        }
    }
    // cout << "At " << id << ' ' << ptr << ' ' << pos.size() << '\n';

    int cnt = pos.size();
    for (int i = 0; i < (1 << cnt); i++) {
        cur[ptr] = id;
        for (int j = 0; j < cnt; j++) {
            if (i >> j & 1) {
                cur[pos[j]] = id;
            }
        }
        dfs(id + 1);
        cur[ptr] = '\0';
        for (int j = 0; j < cnt; j++) {
            cur[pos[j]] = '\0';
        }
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);

    cin >> n;
    cur.resize(n, '\0');
    dfs('a');
    sort(all.begin(), all.end());
    for (string s : all) {
        cout << s << '\n';
    }
    // cout << all.size() << '\n';
}


Measured memory_bytes: 7796
//Name: Lion
//Level: 2
//Category: 全探索
//Note:

/**
 * 制約が小さいので、それぞれの檻に何頭のライオンがいるかを全探索し、条件に合うか試せば良い。
 * オーダーは O(MNX^N)。
 */
#include <iostream>
#include <string>
#include <vector>

using namespace std;

struct Constraint {
    int l, r, s;
};

int X;
int best_acc;
vector<int> best;
void dfs(int pos, const vector<Constraint> &cs, vector<int> &res, int acc) {
    if(pos == res.size()) {
        for(auto &c : cs) {
            int sum = 0;
            for(int i = c.l-1; i < c.r; ++i) {
                sum += res[i];
            }
            if(sum != c.s) return;
        }
        if(acc > best_acc) {
            best_acc = acc;
            best = res;
        }
    } else {
        if(acc + ((int)res.size() - pos) * X <= best_acc) return;
        for(int i = X; i >= 0; --i) {
            res[pos] = i;
            dfs(pos+1, cs, res, acc + i);
        }
    }
}

bool solve() {
    int N, M;
    if(!(cin >> N >> X >> M)) return false;

    vector<Constraint> constraints(M);
    for(int i = 0; i < M; ++i) {
        Constraint &c = constraints[i];
        cin >> c.l >> c.r >> c.s;
    }
    vector<int> res(N);
    best.clear();
    best.push_back(-1);
    best_acc = -1;
    dfs(0, constraints, res, 0);
    for(int i = 0; i < best.size(); ++i) {
        if(i != 0) cout << " ";
        cout << best[i];
    }
    cout << endl;
    return false;
}

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

    while(solve()) ;
    return 0;
}

Measured memory_bytes: 1212
from collections import Counter

s = input()
if len(set(list(s)))==1:
    print(0)
    exit()
    
c = dict(Counter(s))
res = []
for k,v in c.items():
    tmp_s = k + s + k
    idx_num = [e for e,w  in enumerate(list(tmp_s)) if w==k]
    lst = []
    for j in range(1, len(idx_num)):
        lst.append(idx_num[j] - idx_num[j-1])
    tmp = max(lst)
    res.append(tmp)
print(max(min(res)-1, 0))

Measured memory_bytes: 3316
N = int(input())
S = list(input().split())

PWGY = [0] * 4
for i in range(N):
  if S[i] == "P" and PWGY[0] == 0:
    PWGY[0] = 1
  elif S[i] == "W" and PWGY[1] == 0:
    PWGY[1] = 1
  elif S[i] == "G" and PWGY[2] == 0:
    PWGY[2] = 1
  elif S[i] == "Y" and PWGY[3] == 0:
    PWGY[3] = 1

print("Four" if sum(PWGY) == 4 else "Three")

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

using namespace std;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define ll long long

#define for(i,a,b) for (i=a; i<b; i++)
#define forb(i,a,b) for (i=a; i>b; i--)
#define all(S) S.begin(),S.end()
#define sort(S) sort(all(S))

const int inf = 1e9;
const ll INF = 1e18;

int gcd(int a, int b)
{
    if (a<b)
        swap(a,b);
    if (b==0)
        return a;
    return gcd(b,a%b);
}

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(false);
    int k,i,j,q;
    ll s = 0;
    cin >> k;
    for (i,1,k+1)
        for (j,1,k+1)
        for (q,1,k+1)
        s+=gcd(gcd(i,j),q);
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3656