akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define pii pair<int, int>
#define all(x) x.begin(),x.end()
#define f(i,j,l) for(i=j;i<l;i++)
ld const pi = 3.141592653589793238462;

int const mod = 1e9+7;
int power(int a,int b){
    int f=1;
    while(b>0){
        if(b&1){
            f=f*a;
            f%=mod;
        }

        a=a*a;
        a%=mod;
        b=b/2;
    }
    return f;
}



int32_t main(){
	IOS;
	int s;
	cin>>s;
	int i,j,l;
	int a1,a2,b1,b2;
	int m = 1e9;
	if(s < m){
		a1 = s;
		a2 = 0;
		b1 = 0;
		b2 = 1;
		
		cout<<"0 0 "<<a1<<" "<<a2<<" "<<b1<<" "<<b2<<endl;
	}
	else{
		a1 = m;
		a2 = 1;
		
		j = s/m;
		l = s%m;
		
		b2 = j+1;
		b1 = m - l;
		if(b2 <= m)
		cout<<"0 0 "<<a1<<" "<<a2<<" "<<b1<<" "<<b2<<endl;
		else{
			a1 = m;
			b2 = m;
			a2 = 0;
			b1 = 0;
			cout<<"0 0 "<<a1<<" "<<a2<<" "<<b1<<" "<<b2<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
from math import floor
A, B = map(int, input().split())
tax_A = 0.08
tax_B = 0.1
i = 1
A_list = []
while(floor(i*tax_A)<=A):
    if floor(i*tax_A)==A:
        A_list.append(i)
    i += 1
i = 1
B_list = []
while(floor(i*tax_B)<=B):
    if floor(i*tax_B)==B:
        B_list.append(i)
    i += 1
if max(min(A_list), min(B_list)) in A_list and max(min(A_list), min(B_list)) in B_list:
    print(max(min(A_list), min(B_list)))
else:
    print(-1)

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

int main() {
  int N, T, idx = N;
  double A;
  cin >> N >> T >> A;
  int H[N];
  double t[N], min = 100000;
  for(int i = 0; i < N; i++) {
    cin >> H[i];
    t[i] = T - H[i] * 0.006;
    if(min > abs(A - t[i])) {
      min = abs(A - t[i]);
      idx = i + 1;
    }
  }
  cout << idx;
  return 0;
}

Measured memory_bytes: 256
sx, sy, tx, ty = map(int, input().split())
mx = tx - sx
my = ty - sy
print("U"*my+"R"*mx+"D"*my+"L"*mx+"L"+"U"*(my+1)+"R"*(mx+1)+"DR"+"D"*(my+1)+"L"*(mx+1)+"U")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define llv vector< ll >
#define mp make_pair
#define endl "\n"
const int N = (int)1e5+10 ;
const int M = (int)1000000007;
ll n , W ;
ll w[102] , v[102] ;
ll dp[102][N] ;
ll calc(ll sum , ll idx){
    if(sum<=0)return 0 ;
    if(idx==n)return M ;
    if(dp[idx][sum]) return dp[idx][sum] ;
    //cout << idx << endl ;
    return dp[idx][sum] = min(w[idx] + calc(sum-v[idx] , idx+1) , calc(sum , idx+1) ) ;
}

    

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    ll  i , sum=0 ;
    cin >> n >> W ;
    //ll w[n] , v[n] ;
    for(i=0 ; i<n ; i++){
        cin >> w[i]  >> v[i] ;
        sum+=v[i];
    }
    
    for(i=sum ; i>=0 ; i--){
        if(calc(i , 0 )<=W){
            cout << i ; 
            break ;
        }
    }
    
    return 0 ;
}

Measured memory_bytes: 78080
R,G,B,N=map(int,input().split())
R,G,B=sorted([R,G,B],reverse=True)
ans=0

nr=int(N/R)+1
for r in range(nr):
    s=N-r*R
    if s<0:
        continue
    ng=int(s/G)+1
    for g in range(ng):
        if (s-g*G)%B==0:
            ans+=1

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const ll MOD=10000;
const ll INF=1000000010;
const int MAX=100001;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    int a[5];for(int i=0;i<5;i++){cin>>a[i];}sort(a,a+5,greater<int>());for(int i=0;i<5;i++){cout<<a[i];cout<<(i!=4?" ":"\n");}
    return 0;
}


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

public class Main {
	
	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		long n = in.nextLong();
		long a = in.nextLong();
		long b = in.nextLong();
		long count = n / (a+b) * a;
		long m = n % (a+b);
		long other = Math.min(m, a);
		System.out.print(count + other);
	}
}


Measured memory_bytes: 22996
#include<stdio.h>
int main(void)
{
	int a,b,max, min;
	scanf("%d", &a);
	int d[a];
	scanf("%d", &d[0]);
	min=d[0];
	max=-d[0];
	for(b=1; b<a; b++)
	{
		scanf("%d", &d[b]);
		if(max<d[b]-min){max=d[b]-min;}
		if(min>d[b]){min=d[b];}
		
	}
	printf("%d\n", max);
	return 0;
}



Measured memory_bytes: 2624
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	long long int n,d,i,ans=0;
	cin>>n>>d;
	double a;
	long long int x[n],y[n];
	for(i=0;i<n;i++){
		cin>>x[i]>>y[i];
		x[i]=x[i]*x[i];
		y[i]=y[i]*y[i];
	}
	for(i=0;i<n;i++){
		a=sqrt(x[i]+y[i]);
		if(a<=d)
		ans++;
	}
	cout<<ans;
	return 0;
}

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

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


int main() {
	long long n;
	long long one, two;
	long long sum;
	cin >> n;
	one = n / 500;

	two = (n % 1000);
	if (two >= 500) {
		two -= 500;
		two /= 5;
	}else{
		two /= 5;
	}

	sum = one * 1000 + two * 5;

	cout << sum << endl;



}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication
{
    class Program
    {
        static void Main()
        {
            new Solution().process();
        }




    }

    class Solution 
    {
        int a, b, c;

        
        public Solution(){
            string[] input = Console.ReadLine().Split(' ');
            a = Convert.ToInt32(input[0]);
            b = Convert.ToInt32(input[1]);
            c = Convert.ToInt32(input[2]);
                       
            
        }

        public void process(){
            int d,e,f;

            if (a >= b) 
            { 
                d = b;

                if (a >= c)
                {
                    e = c;
                }
                else {
                    e = a;
                }
            } 
            else 
            { 
                d = a;
                if (b >= c)
                {
                    e = c;
                }
                else {
                    e = b;
                }
            }

   

            f = d + e;
            Console.WriteLine(f);

        }

    
    }
}

Measured memory_bytes: 11220
#include<iostream>
#include<algorithm>

using namespace std;

typedef long long ll;

int main(){
    ll N,A,B,C,D,E,buff,ans=0;

    cin>>N>>A>>B>>C>>D>>E;
    buff = min({A,B,C,D,E});
    if(N%buff==0)  ans = N/buff + 4;
    else ans= N/buff + 5;
    cout<<ans;
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
    int a,b,c;
    scanf("%d %d %d", &a, &b, &c);
    if (a == b and a != c)
    {
        printf("%d", c);
    }
    
    else if (a == c and a != b)
    {
        printf("%d", b);
    }
    
    else if (b == c and b != a)
    {
        printf("%d", a);
    }
    
}


Measured memory_bytes: 1736
inp = int(input())
li = [inp]
i = 0
while True:
  if inp % 2 == 0:
    te = inp/2
    te = int(te)
    pass
  else:
    te = int(inp * 3 + 1)
  if te in li:
    print(int(len(li)+1))
    break
  else:
    li.append(te)
    inp = te

Measured memory_bytes: 3060
from sys import stdin
mod = 1000000007
n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()
t = stdin.readline().rstrip()
now = 0
pazzle = ""#横に2個か縦に1個かを確認
while now < n:
    if s[now] == t[now]:
        now += 1
        pazzle += "T"
    else:
        now += 2
        pazzle += "Y"
#初期の可能性
if pazzle[0] == "T":
    point = 3
else:
    point = 6
for i in range(1,len(pazzle)):
    if pazzle[i-1] == "T" and pazzle[i] == "T":
        point *= 2
        point %= mod
    elif pazzle[i-1] == "T" and pazzle[i] == "Y":
        point *= 2
        point %= mod
    elif pazzle[i-1] == "Y" and pazzle[i] == "Y":
        point *= 3
        point %= mod
print(point)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
inline int read()
{
    int x=0,t=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-') t=-1,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return x*t;
}
int n;
double ans;
int main ()
{
	n=read();
	printf("%.10lf",double((n+2-1)/2)/n);
	return 0;
}


Measured memory_bytes: 256
A=[int(input()) for _ in range(5)]

ans=0
first=10

for i in range(5):
    ans-=(-A[i]//10)*10
    if A[i]%10>0 and A[i]%10<first:
        first=A[i]%10

if first!=0:
    ans-=(10-first)

print(ans)

Measured memory_bytes: 3060
def binary_search(a,n,key):
  left = 0
  right = n
  while left < right:
    mid = (left + right) // 2
    if a[mid] == key:
      return 1
    elif key < a[mid]:
      right = mid
    else:
      left = mid + 1
  return 0

n1 = int(input())
s1 = list(map(int,input().split()))
n2 = int(input())
s2 = list(map(int,input().split()))
i = 0
cnt = 0
while i < n2:
  cnt += binary_search(s1,n1,s2[i])
  i += 1
print(cnt)


Measured memory_bytes: 16708
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DP
{
    class C
    {
        static void Main(string[] args)
        {

            int N = int.Parse(Console.ReadLine());
            int asum = 0, bsum = 0, csum = 0;
            for(int i = 0; i < N; i++)
            {
                int[] act = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

                int a = Math.Max(bsum, csum) + act[0];
                int b=Math.Max(asum,csum)+act[1];
                int c = Math.Max(asum, bsum) + act[2];
                asum = a; bsum = b; csum = c;
            }
            int max = Math.Max(Math.Max(asum, bsum), csum);
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 17448
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>
#include <random>

#define FOR_LT(i, beg, end) for (int i = (int)(beg); i < (int)(end); i++)
#define FOR_LE(i, beg, end) for (int i = (int)(beg); i <= (int)(end); i++)
#define FOR_DW(i, beg, end) for (int i = (int)(beg); (int)(end) <= i; i--)
#define REP(n)              for (int repeat_index = 0; repeat_index < (int)n; repeat_index++)


int64_t vals[2020];
using namespace std;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(20);

	string s; cin >> s;

	int64_t ans = 0;
	FOR_LT(i, 0, s.size()) {
		int v = s[i] - '0';
		int64_t ref[2020];
		memcpy(ref, vals, sizeof(ref));
		memset(vals, 0, sizeof(vals));
		FOR_LT(j, 0, 2020) {
			int k = (j * 10 + v) % 2019;
			vals[k] += ref[j];
		}
		vals[v]++;

		ans += vals[0];
	}

	cout << ans << endl;

	return 0;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	vector <ll> plus;
	vector <ll> minus;
	for (int ii = 0; ii < N; ++ii){
		ll val;
		cin >> val;
		if (val >= 0){
			plus.push_back(val);
		} else {
			minus.push_back(val);
		}
	}

	ll ans;
	vector <pair<ll, ll>> s;
	if (minus.size() == 0){
		sort(plus.begin(), plus.end());
		ll tmp = plus[0];
		for (int ii = 1; ii < plus.size()-1; ++ii){
			s.push_back(make_pair(tmp, plus[ii]));
			tmp -= plus[ii];
		}
		s.push_back(make_pair(plus.back(), tmp));
		ans = plus.back() - tmp;
	} else if (plus.size() == 0) {
		sort(minus.rbegin(), minus.rend());
		ll tmp = minus[0];
		for (int ii = 1; ii < minus.size(); ++ii){
			s.push_back(make_pair(tmp, minus[ii]));
			tmp -= minus[ii];
		}
		ans = tmp;
	} else {
		//plusの要素が残り1個になるまでの処理
		ll tmp = minus.back();
		for (int ii = 0; ii < plus.size()-1; ++ii){
			s.push_back(make_pair(tmp, plus[ii]));
			tmp -= plus[ii];
		}
		//そのあとの処理
		s.push_back(make_pair(plus.back(), tmp));
		tmp = plus.back() - tmp;
		for (int ii = 0; ii < minus.size()-1; ++ii){
			s.push_back(make_pair(tmp, minus[ii]));
			tmp -= minus[ii];
		}
		ans = tmp;
	}

	cout << ans << "\n";
	for (int ii = 0; ii < s.size(); ++ii){
		cout << s[ii].first << " " << s[ii].second << "\n";
	}

	return 0;
}


Measured memory_bytes: 5104
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static class FastScanner {
        BufferedReader br, br1;
        StringTokenizer st;
        public FastScanner() {br = new BufferedReader(new InputStreamReader(System.in));}
        public FastScanner(String fileName) throws FileNotFoundException{br = new BufferedReader(new FileReader(fileName));}
        String next() {while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException  e){e.printStackTrace();}}return st.nextToken();}
        int nextInt() {return Integer.parseInt(next());}
        long nextLong() {return Long.parseLong(next());}
        double nextDouble() {return Double.parseDouble(next());}
        char[][] readCharArray(int n, int m) {
        	String str;
        	char[][] arr = new char[n][m];
        	for(int i = 0; i < n; ++i) {
        		str=nextLine();
        		for(int j = 0;j < n; ++j) {
        			arr[i][j] = str.charAt(j);
        		}
        	}
        	return arr;
        }
        char[][] readCharArray(int n) {
        	return readCharArray(n,n);
        }
        int[] readArray(int n) {int[] a = new int[n]; for (int i = 0; i < n; ++i) a[i] = nextInt(); return a;}
        long[] readLongArray(int n) {long[] a=new long[n];for (int i = 0; i < n; ++i) a[i] = nextLong(); return a;}
        String nextLine() {String str = "";try{str = br.readLine();} catch (IOException e){e.printStackTrace();} return str;}
    }
    public static void main(String[] args) throws NumberFormatException, IOException {
        FastScanner fs = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int k = fs.nextInt(), n = fs.nextInt();
        int a[] = fs.readArray(n);
        int ans = 0;
        for (int i = 0; i < n - 1; ++i) {
            ans = Math.max(ans, a[i + 1] - a[i]);
        }
        ans = Math.max(ans, k - a[n - 1] + a[0]);
        out.println(k - ans);
        out.close();
    }
}

Measured memory_bytes: 54540
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
string S;
cin >> S;
for (int i = 0;i < 3;i++) {
    if (S.at(i) == '1') cout << 9;
    else if (S.at(i) == '9') cout << 1;
    else cout << S.at(i);
}
cout << endl;


return 0;
}


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

// --------------------------------------------------------------------------------
#define fast_IO	ios_base::sync_with_stio(false),cin.tie(NULL),cout.tie(NULL);
#define ll long long 
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define deb(name,value) cout <<"->>  "<<name<< "= " <<value<<" "
#define frepi(a,b,k) for(int i=a;i<=b;i+=k)
#define frepj(a,b,k) for(int j=a;j<=b;j+=k)
// --------------------------------------------------------------------------------


void solve()
{
    int n,k;cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;++i)
        cin>>arr[i];
    sort(arr,arr+n);
    long long ans = 0;
    for(int i=0;i<k;++i)
    {
        ans+=arr[i];
    }
    cout<<ans<<"\n";
}

int main()
{
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
    
}

Measured memory_bytes: 3636
package main

import (
	"fmt"
)

func main() {
	var N, ans int
	fmt.Scan(&N)

	for i := 1; i <= N; i++ {
		if i < 10 || (100 <= i && i < 1000) || (10000 <= i && i < 100000) {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

int main() {
	int n;
	string str;
	cin >> n;
	cin.ignore();
	while(n--) {
		getline(cin, str);
		int num;
		while(num = str.find("Hoshino"), num != -1) {
			str[num + 6] = 'a';
		}
		cout << str << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  s <- T.getLine :: IO T.Text
  let
    n = T.length s :: Int
    (pf, sf') = T.splitAt (pred n `div` 2) s
    sf = T.tail sf'
  putStrLn $ if pf == T.reverse pf && sf == pf then "Yes" else "No"

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 508
import math
N = int(input())
As = list(map(int, input().split()))
As.sort(reverse = True)
ans = 0
if len(As) >=2:
    for n in range(1, N):
        m = math.floor(n/2)
        ans += As[m]
else:
    ans = 0
print(ans)

Measured memory_bytes: 33172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

int main(){
    int n, m, t;
    while(cin >> n >> m >> t && n){
        int a[110];
        a[0] = 0;
        rep(i, n) cin >> a[i+1];
        a[n+1] = t;
        int ans = 0;
        rep(i, n+1) ans += max(0, a[i+1] - a[i] - ((i==0 || i==n) ? m : 2*m));
        cout << ans << endl;
    }
}

Measured memory_bytes: 3088
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.08.19 01:54:54
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int m,k;cin >> m >> k;
    if ((1<<m)-1<k) {
        puts("-1");
        return 0;
    }
    if (m == 1 && k == 1) {
        puts("-1");
        return 0;
    }
    else if (m == 1 && k == 0) {
        cout << "1 1 0 0" << endl;
        return 0;
    }
    for (int i = 0; i < 1<<m; i++) {
        if (i == k)continue;
        cout << i << " ";
    }
    cout << k << " ";
    for (int i = (1<<m)-1; i >= 0; i--) {
        if (i == k) continue;
        cout << i << " ";
    }
    cout << k << endl;
    return 0;
}

Measured memory_bytes: 3628
def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]
n = int(input())
sosu = primes(55555)
ans = []
cou = 0
for i in sosu:
    if i % 5 == 2:
        ans.append(i)
        cou += 1
    if cou == n:
        print(*ans)
        exit()

Measured memory_bytes: 9892
import java.io.*;
import java.util.*;


public class Main {


    private void solve(InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int count = 0;
        int countMax = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= i; j++) {
                if (i % 2 != 0) {
                    if ((i % j) == 0) {
                        count++;
                    }
                }
            }
            if (count == 8) {
                countMax++;
            }
            count = 0;
        }
        out.println(countMax);
    }


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

    private void run() {
        try (
                InputReader in = new InputReader(System.in);
                PrintWriter out = new PrintWriter(System.out)) {
            solve(in, out);
        }
    }


    static class InputReader implements AutoCloseable {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }


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

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

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

        @Override
        public void close() {

        }
    }


}


Measured memory_bytes: 20948
from sys import stdin


def main():
    N, K = [int(x) for x in stdin.readline().rstrip().split()]
    As = [int(x) for x in stdin.readline().rstrip().split()]

    done = [0] * N
    step = -1
    start = 0
    current = 1
    between = 0

    while True:
        if done[current - 1] > 0:
            start = done[current - 1] - 1
            between = step - done[current - 1] + 1
            break
        step += 1
        done[current - 1] = step
        current = As[current - 1]

    if K <= step:
        print(done.index(K) + 1)
    else:
        res = (K - start) % between
        if res == 0:
            res = between
        print(done.index(res + start) + 1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 33572
cnt = 0
INF = pow(10, 18)

def merge(A, left, mid, right):
    L = A[left:mid] + [INF]
    R = A[mid:right] + [INF]
    i = 0
    j = 0
    for k in range(left, right):
        global cnt
        cnt += 1
        if L[i] <= R[j]:
            A[k] = L[i]
            i += 1
        else:
            A[k] = R[j]
            j += 1

def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)

n = int(input())
s = list(map(int, input().split()))
mergeSort(s, 0, n)
print(*s)
print(cnt)


Measured memory_bytes: 63696
n = int(input())
s = sorted([input() for i in range(n)])
m = int(input())
t = sorted([input() for i in range(m)])
for i in range(m):
    if t[i] in s:
        s.remove(t[i])

cnt = [0]
for i in range(len(s)):
    cnt.append(s.count(s[i]))
print(max(cnt))

Measured memory_bytes: 3064
///A drunk man will find his way home, but a drunk bird may get lost forever...
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef pair <int, int> pii;
#define pb push_back
#define f first
#define s second
#define sz(x) (int)x.size()
const int mx = 1000 * 100 + 5, M = 1e9 + 7;
int n, m, s, t, dis[2][mx], cnt[2][mx];
set < pii > ms;
vector < pii > ad[mx];
vector < pair < pii , int > > ed;
void dij(int a, int ind){
	memset(dis[ind], 127, sizeof dis[ind]);
	dis[ind][a] = 0;
	cnt[ind][a] = 1;
	for(int i = 0; i < n; i++)
		ms.insert({dis[ind][i], i});
	while(sz(ms)){
		auto v = ms.begin() -> s;
		ms.erase(ms.begin());
		for(auto u : ad[v]){
			if(dis[ind][v] + u.s < dis[ind][u.f]){
				ms.erase({dis[ind][u.f] , u.f});
				dis[ind][u.f] = dis[ind][v] + u.s;
				cnt[ind][u.f] = cnt[ind][v];
				ms.insert({dis[ind][u.f] , u.f});
			}
			else if(dis[ind][v] + u.s == dis[ind][u.f]){
				cnt[ind][u.f] += cnt[ind][v];
				cnt[ind][u.f] %= M;
			}
		}
	}
	return;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
 	cout.tie(0);
	cin >> n >> m >> s >> t;
	s--, t--;
	int u, v, w;
	for(int i = 0; i < m; i++){
		cin >> u >> v >> w;
		u--, v--;
		ad[u].pb({v , w});
		ad[v].pb({u , w});
		ed.pb({{u , v} , w});
	}
	dij(s , 0);
	dij(t , 1);
	int sum = cnt[0][t] * cnt[1][s] % M;
	for(int i = 0; i < n; i++){
		if(dis[0][i] == dis[1][i] && dis[0][i] + dis[1][i] == dis[0][t]){
			sum += M - cnt[0][i] * cnt[0][i] % M * cnt[1][i] % M * cnt[1][i] % M;
			sum %= M;
		}
	}
	for(auto u : ed){
		if (dis[0][u.f.f] > dis[0][u.f.s]) 
			swap(u.f.f , u.f.s);
		if(dis[0][u.f.f] + dis[1][u.f.s] + u.s == dis[1][s] && dis[0][u.f.f] < dis[1][s] / 2 && dis[1][u.f.s] < dis[1][s] / 2){
			sum += M - cnt[0][u.f.f] * cnt[0][u.f.f] % M * cnt[1][u.f.s] % M * cnt[1][u.f.s] % M;
			sum %= M;
		}
	}
	cout << sum << endl;
	return 0;
}



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

#define ll long long int

int main(){
    ll a[3][3];
    for (ll i = 0; i < 3; i++)
    {
        for (ll j = 0; j < 3; j++)
        {
            cin >> a[i][j];
        }
   }

ll n,c;
cin >> n;
for (ll k = 0;k<n;k++)
  {
      cin >> c;
      for (ll i = 0; i < 3; i++)
    {
        for (ll j = 0; j < 3; j++)
        {
           if(a[i][j]==c)
           {
               a[i][j] = 0;
           }
        }
   }
  }
if((a[0][0]==0 && a[1][1]==0 && a[2][2]==0)|| (a[0][2]==0 && a[1][1]==0 && a[2][0]==0))
    cout << "Yes";
else if(a[0][0]==0 && a[0][1]==0 && a[0][2]==0)
    cout << "Yes";
else if(a[1][0]==0 && a[1][1]==0 && a[1][2]==0)
    cout << "Yes";       
else if(a[2][0]==0 && a[2][1]==0 && a[2][2]==0)
    cout << "Yes";  
else if(a[0][0]==0 && a[1][0]==0 && a[2][0]==0)
    cout << "Yes"; 
else if(a[0][1]==0 && a[1][1]==0 && a[2][1]==0)
    cout << "Yes";
else if(a[0][2]==0 && a[1][2]==0 && a[2][2]==0)
    cout << "Yes";
else
    cout << "No";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int sum[200020] = { 0 }, sum1[200020] = { 0 };
int main() {
	int n;
	string s;
	cin >> n >> s;
	for (int i = 0; i < n; i++) {
		if (s[i] == '.') {
			sum[i]++;
		}
		else if (s[i] == '#') {
			sum1[i]++;
		}
		if (i != 0) {
			sum[i] += sum[i - 1];
			sum1[i] += sum1[i - 1];
		}
	}
	int ans = 1000000007;
	for (int i = 0; i < n; i++) {
		int ans1 = sum1[i] + sum[n - 1] - sum[i];
		if (ans1 < ans) {
			ans = ans1;
		}
	}
	if (sum[n - 1] < ans) {
		ans = sum[n - 1];
	}
	if (sum1[n - 1] < ans) {
		ans = sum1[n - 1];
	}
	cout << ans << endl;

}

Measured memory_bytes: 2180
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#include<math.h>
#define INFINI 100000001

int main(){
char s[4];
scanf ("%s",&s);
int a=s[0]-'0',b=s[1]-'0',c=s[2]-'0',d=s[3]-'0';
if(a-b-c-d==7) printf ("%d-%d-%d-%d=7\n",a,b,c,d);
else if(a-b-c+d==7) printf ("%d-%d-%d+%d=7\n ",a,b,c,d);
else if(a-b+c-d==7) printf ("%d-%d+%d-%d=7\n",a,b,c,d);
else if(a-b+c+d==7) printf ("%d-%d+%d+%d=7\n",a,b,c,d);
else if(a+b-c-d==7) printf ("%d+%d-%d-%d=7\n",a,b,c,d);
else if(a+b-c+d==7) printf ("%d+%d-%d+%d=7\n",a,b,c,d);
else if(a+b+c-d==7) printf ("%d+%d+%d-%d=7\n",a,b,c,d);
else if(a+b+c+d==7) printf ("%d+%d+%d+%d=7\n",a,b,c,d);

}


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

using namespace std;

template <typename T>
T distance(T ax, T ay, T bx, T by) {
  return sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by));
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<double> X(N), Y(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
  }
  vector<vector<double>> dist(N, vector<double>(N, 0));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      dist[i][j] = distance(X[i], Y[i], X[j], Y[j]);
    }
  }
  vector<int> idx(N);
  iota(idx.begin(), idx.end(), 0);
  double res = 0;
  do {
    for (int i = 0; i < N - 1; i++) {
      res += dist[idx[i]][idx[i + 1]];
    }
  } while (next_permutation(idx.begin(), idx.end()));
  for (int i = 1; i < N + 1; i++) {
    res /= i;
  }
  cout << fixed << setprecision(10) << res << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
using namespace std;
int N,M,mx;
string t,s[110];
map< string,int > mp;
int main(){
    cin >>N ;
    for (int i = 0; i < N;++i) cin >> s[i], mp[s[i]]++;
    cin >> M;
    while(M--) cin >> t, mp[t]--;
    for (int i = 0;i < N;++i) mx = max(mx,mp[s[i]]);
    cout << mx ;
}


Measured memory_bytes: 256
/*
    A - Biscuit Generator
    https://atcoder.jp/contests/abc125/tasks/abc125_a
*/
#include <bits/stdc++.h>
using namespace std;

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

    int a, b, t;
    cin >> a >> b >> t;
    cout << (t / a * b) << endl;
}

Measured memory_bytes: 256
#include <iostream>

#include<vector>

#include<string>

#include<algorithm>

#include<cmath>

#include<cstdlib>

#include<utility> 

#include<cstdio> 

#define vii vector< pair<int,int> >

#define vi vector<int>

#define INF 1000000007

#define ff first

#define ss second

#define lli long long int

#define ulli unsigned long long int

using namespace std;

int main() {

 ios_base::sync_with_stdio(false);

    cin.tie(NULL);

  int n;

  cin>>n;

  vi v(n);

  for(int i=0; i<n; i++)

  cin>>v[i];

  ulli sum=0, ans=0;

  for(int i=0; i<n; i++)

  ans+=v[i]%INF;

  for(int i=0; i<n; i++){

    ans-=v[i]%INF;   

    sum+=((v[i]%INF)*(ans%INF))%INF;

  }

  cout<<sum%INF<<endl;

 // cout<<12839201%INF;

}

Measured memory_bytes: 3968
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s1=br.readLine(), s2=br.readLine();
		int[]c1=new int[s1.length()], c2=new int[s2.length()];
		for(int i=0;i<s1.length();i++)c1[i]=s1.charAt(i);
		for(int i=0;i<s2.length();i++)c2[i]=s2.charAt(i);
		int[][]dp=new int[s1.length()][s2.length()];
		for(int i=0;i<s1.length();i++){
			for(int j=0;j<s2.length();j++){
				if(c1[i]==c2[j]){
					dp[i][j]=1;
					if(i*j!=0)dp[i][j]=dp[i-1][j-1]+dp[i][j];
				}else{
					if(i==0&&j==0)continue;
					else if(i!=0&&(j==0||dp[i-1][j]>dp[i][j-1]))dp[i][j]=dp[i-1][j];
					else dp[i][j]=dp[i][j-1];
				}
			}
		}
		String ans="";
		int cr=s1.length()-1, cc=s2.length()-1;
		while(cr>-1&&cc>-1){
			if(c1[cr]==c2[cc]){
				ans=(char)c1[cr]+ans;
				cr--;
				cc--;
			}else if(cr!=0&&(cc==0||dp[cr-1][cc]>dp[cr][cc-1]))cr--;
			else cc--;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 87764
// AOJ 1065 The House of Huge Family
// 2018.2.3 bal4u

#include <stdio.h>
#include <stdlib.h>

#define MAX 102

/* UNION-FIND library */
int id[MAX], size[MAX];
void init(int n) { int i; for (i = 0; i < n; i++) id[i] = i, size[i] = 1; }
int root(int i) { while (i != id[i]) id[i] = id[id[i]], i = id[i]; return i; }
int connected(int p, int q) { return root(p) == root(q); }
void unite(int p, int q)
{
    int i = root(p), j = root(q); if (i == j) return;
    if (size[i] < size[j]) id[i] = j, size[j] += size[i]; else id[j] = i, size[i] += size[j];
}
/* UNION-FIND library */

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	if (c == '-') {
		c = getchar_unlocked();
		do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
		while (c >= '0');
		return -n;
	}
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

typedef struct { int x, y, c; } T;
T tbl[MAX]; int sz;

int cmp(T *a, T *b) { return b->c - a->c; }

int main()
{
	int n, m, i, ans;

	while (n = in()) {
		m = in();
		init(n);

		ans = 0;
		sz = 0; while (m--) {
			tbl[sz].x = in(), tbl[sz].y = in(), tbl[sz].c = in();
			if (tbl[sz].c < 0) ans += tbl[sz].c;
			else sz++;
		}

		qsort(tbl, sz, sizeof(T), cmp);
		for (i = 0; i < sz; i++) {
			if (!connected(tbl[i].x, tbl[i].y)) {
				if (n > 2) unite(tbl[i].x, tbl[i].y), n--;
				else ans += tbl[i].c;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}



Measured memory_bytes: 2032
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
const lld MAXN = 1e5;

vector<lld> fact,inv;


lld f(lld a,lld b, lld p)  // a^b mod pを求める
{
	if (b == 0)
	{
		return 1;
	}else if (b % 2 == 0)
	{
		lld d = f(a,b/2,p);  //a^b = a^(2k) = (a^k)^2  k = b / 2
		return d * d % mod;
	}else
	{
		return a * f(a,b-1,p) % mod;
	}
}

void init(lld n)
{
	fact.resize(n+1,1);
	inv.resize(n+1,1);

	for(int i = 2; i <= n; i++)  //　nまでの階乗を求める
	{
		fact[i] = fact[i-1] * i % mod;
	}
	for(int i = 2; i <= n; i++)  //a^(-1) mod p = a^(p-2) mod p  ここをもう少し早くできるぽい
	{
		inv[i] = f(fact[i],mod-2,mod) % mod;
	}
}

lld comb(lld n,lld k)  //n_C_k
{
	if (n < k)
	{
		return 0;
	}
	return (fact[n] * inv[k] % mod) * inv[n-k] % mod;
}


int main()
{
	lld n,m;

	cin >> n >> m;

	if (n < m)  // n => m にする
	{
		lld temp = m;
		m = n;
		n = temp;
	}

	init(n);

	if (n > m + 1)
	{
		cout << 0 << endl;
	}else
	{
		if (n > m)
		{
			cout << (fact[n] * fact[m]) % mod << endl;
		}else
		{
			cout << (2 * fact[n] * fact[n]) % mod << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define int long long
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
signed main(){
	
	int n,m,x[111111],ans=0;;
	cin>>n>>m;
	for(int i=0;i<m;i++)cin>>x[i];
	sort(x,x+m);
	pair<int,int> v[111111];
	for(int i=0;i<m-1;i++){
	    v[i]=make_pair(x[i+1]-x[i],x[i+1]);
	}
	sort(v,v+m-1);
	
	/*for(int i=0;i<m-1;i++){
	    cout<<v[i].first<<" "<<v[i].second<<endl;
	}*/
	//cout<<endl;
	
	unordered_map<int,int> xf;
	for(int i=m-2;m-2-i!=n-1;i--){
	    xf[v[i].second]=1;
	    //cout<<v[i].second<<endl;
	}
	xf[x[0]]=1;
	int place=x[0],co=0;
	for(int i=0;i<m;i++){
	    if(xf[x[i]]==1 && i!=0){
	        ans+=x[i-1]-place;
	        //cout<<place<<" "<<x[i]<<endl;
	        place=x[i];
	        //co++;
	    }
	    //if(co==n)break;
	}
	ans+=x[m-1]-place;
	cout<<ans<<endl;
	
}

Measured memory_bytes: 6948
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def div(n):
    div = []
    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            div.append(i)
            if i != n // i:
                div.append(n // i)
    return set(div)


def main():
    A, B, K = map(int, input().split())

    result = sorted(div(A) & div(B))

    print(result[-K])


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include<stdio.h>

int main() {
	int a, b, c, d, e, k;
	scanf ("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &k);
	if ((e-a)>k)
		printf(":(\n");
	else printf("Yay!\n");
	return 0;
}

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

int main(){
  ll h,w;
  cin >> h >> w;
  vector<ll>alp(26);
  for(int i=0; i<h*w; i++){
    char a;
    cin >> a;
    alp[a-'a']++;
  }
  ll one=0,two=0,four=0;
  if(h%2 && w%2)one=1;
  if(h%2)two+=w/2;
  if(w%2)two+=h/2;
  four=(h*w-two*2-one)/4;

  for(int i=0; i<26; i++){
    while(alp[i]>=4){
      if(four==0) break;
      four--;
      alp[i]-=4;
    }
  }
  
  for(int i=0; i<26; i++){
    while(alp[i]>=2){
      if(two==0) break;
      two--;
      alp[i]-=2;
    }
  }
  
  for(int i=0; i<26; i++){
    while(alp[i]>=1){
      if(one==0) break;
      one--;
      alp[i]-=1;
    }
  }
  
  if(!four && !two && !one) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}
  
  
  


Measured memory_bytes: 256
//BISMILLAHIR RAHMANIR RAHIM
//RHYTHM_086_NS_01
//ALAN_IS_ON....

#include <bits/stdc++.h>

//define

#define                boost_                         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define                iter_(i,n)                     for (int i = 0; i < int(n); i++)
#define                for_n(i, n)                    for (int i = 1; i <= int(n); i++)
#define                pb                             push_back
#define                mp                             make_pair
#define                itr                            ::iterator
#define                s_sort(s)                      sort(s.begin(),s.end())
#define                n_sort(a)                      sort(a,a+n)
#define                thank_you                      return 0
#define                thanks                         return
#define                pii                            pair<int,int>
#define                precise_impact                 cout<<setprecision(10)<<fixed;

using namespace std;

//data type
typedef long long int ll;
typedef unsigned long long int ulli;
typedef double db;


//constants
#define PI acos(-1.00)
#define MOD 1000000007

ll bigmod(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll tm=bigmod(a,b/2);
    tm=(tm*tm)%MOD;
    if(b%2==1)
        tm=(tm*a)%MOD;
    return tm;

}
int egcd(int a,int b,int &x,int &y){
    if(a==0){
        x=0;
        y=1;
        return b;
    }
    int x1,y1;
    int d=egcd(b%a,a,x1,y1);
    x=y1-(b/a)*x1;
    y=x1;
    return d;
}
int cn[10][10];
void solve();


int main()
{
    boost_;
    precise_impact;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Here we go...
    int t=1;
    //cin>>t;
    while(t--)
        solve();

    thank_you;
}


void solve()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        int s,e,tm=i;
        e=tm%10;
        while(tm>9){
            tm/=10;
        }
        s=tm;
        cn[s][e]++;
    }
    int res=0;
    iter_(i,10){
        iter_(j,10){
            res+=cn[i][j]*cn[j][i];
        }
    }
    cout<<res<<endl;

}



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

// ------------------------- DEBUGGING -----------------------------------------------------------------
#ifdef DEBUG
#define debug(args...) { vector<string> _v = split(#args, ','); err( _v.begin(), args); cerr << endl; }
vector<string> split( const string& s, char c) {
	vector<string> v;
	stringstream ss( s);
	string x;
	while ( getline( ss, x, c))
		v.emplace_back( x);
	return move( v);
}
void err( vector<string>::iterator it) { }
template<typename T, typename... Args>
void err( vector<string>::iterator it, T a, Args... args) {
	cerr << it -> substr( ( *it)[0] == ' ', it -> length()) << " = " << a << '\t';
	err( ++it, args...);
}
#else
#define debug(...)
#endif
// -------------------------- MACROS -------------------------------------------------------------------

#define int long long
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define fr(i,j,k) for(i = j; i < (k); i++)
#define all(x) x.begin(), x.end()
#define el '\n'
#define remax(a,b) a = max(a, b)
#define remin(a,b) a = min(a, b)

typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
// ---------------------------  TEMPLATE ENDS  -------------------------------------------------------

const pii dxy[] = { {-1, 0}, {1, 0}, {0, 1}, {0, -1} };
const int mod = 1e9+7;
const int inf = 2e18;
const ld eps = 1e-9;
const int NN = 1e6 + 2;

vvi adj;
vi p(NN), p2(NN);
void solve(){
	int i = 0, j = 0, k = 0, n = 0, m = 0;
	p[0] =1; p2[0] = 1;
	fr(i, 1, NN) {
		p2[i] = p2[i-1]*2 % mod;
		p[i] = p[i-1]*3%mod;
	}      
	string s;
	cin>>s;
	n = s.size();
	int cnt = 0;
	k = 0;
	for(i = 0; i < n; i++){ 
		if(s[i] == '1') {
			k = (k + (p2[cnt] * p[n-i-1] % mod))%mod;
			cnt++;
		}
	}
	k = (k + p2[cnt])%mod;
	cout << k << el;
}

int32_t main(){
#ifndef DEBUG
	ios::sync_with_stdio(false); cin.tie(0); 
#endif
	int T = 1, tc;
      // cin >> T;
	for(tc = 1; tc <= T; tc++){
		solve();
	}
	return 0;
}


Measured memory_bytes: 16128
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
//using namespace __gnu_pbds;
#define rep(i,a,b) for(i=(a);i<=(b);i++)
#define ll long long
#define ld double
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define maxn 100005
#define inf 1e18
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define fr freopen("source.txt","r",stdin),freopen("output.txt","w",stdout)
#define SET(a,b) memset(a,b,sizeof(a))
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define ps(x,y) fixed<<setprecision(y)<<x
//template<typename T>
//using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
    return out <<  "(" << a.F << ", " << a.S << ")";
}
 
template<class A> ostream& operator << (ostream& out, const vector<A> &a) {
    out << "[";
    for (auto it = a.begin(); it != a.end(); ++it) {
        if (it != a.begin())
            out << ", ";
        out << *it;
    }
    return out << "]";
}
int main()
{
    boost;
    ll n,i,j,x,t,y;
    cin>>n;
    ld a[n+1];
    for(i=1;i<=n;i++) cin>>a[i];
    ld dp[n+1][n+1];
    dp[0][0]=1;
    for(i=1;i<=n;i++) dp[i][i]=a[i]*dp[i-1][i-1];
    for(i=1;i<=n;i++) dp[i][0]=(1-a[i])*dp[i-1][0];
    for(i=1;i<=n;i++){
        for(j=1;j<=i;j++){
            dp[i][j]=a[i]*dp[i-1][j-1];
            if(j<=i-1) dp[i][j]+=(1-a[i])*dp[i-1][j];
        }
    }
    ld ans=0;
    for(i=(n+1)/2;i<=n;i++) {
        ans+=dp[n][i];
        //cout<<dp[n][i]<<" ";
    }
    cout<<ps(ans,10);
}

Measured memory_bytes: 70528
n,k = map(int,input().split())
p = [input()[0] for i in range(n)]
from collections import Counter
c = Counter(p)
v = sorted(list(c.values()),reverse=True)
ans = 0
while len(v)>=k:
    for i in range(k):
        v[i] -= 1
        if v[i]<0:
            print(ans)
            exit()
    ans += 1
    v = sorted(v,reverse=True)
print(ans)

Measured memory_bytes: 44760
n=input()
s=len(n)
ans=0
def f(i,cur=""):
    global ans
    #print(i,cur)
    if(i==s):
        ans+=eval(cur)
        return
    f(i+1,cur+n[i])
    if(i!=s-1):f(i+1,cur+n[i]+'+')
f(0)
print(ans)


Measured memory_bytes: 9120
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int H, W;
const int dx[4] = {  1,  0, -1,  0};
const int dy[4] = {  0,  1,  0, -1};
#define WMAX 2001
#define HMAX WMAX
char s[HMAX][WMAX];
int dp[HMAX][WMAX][4]; // dp[i][j][k] (0:right 1:down 2:left 3:up)              

int dfs(int x, int y, int k)
{
  if( s[y][x] == '#' ) return 0;
  if( dp[y][x][k] != -1 ) return dp[y][x][k];
  int nx = x + dx[k];
  int ny = y + dy[k];
  if( 0 <= nx && nx < W && 0 <= ny && ny< H && s[ny][nx] != '#' ) {
    int num = dfs(nx, ny, k) + 1;
    dp[y][x][k] = num;
    return  num;
  }
  dp[y][x][k] = 0;
  return 0;
}

int main()
{
  int res = 0;
  cin >> H >> W;

  rep(i,H) cin >> s[i];
  memset(dp, -1, sizeof dp);

  rep(y, H) {
    rep(x, W) {
      int sum = 0;
      rep(k, 4) {
        sum += dfs(x, y, k);
      }
      if(s[y][x]!= '#') sum++;
      res = max(sum, res);
      //printf("%3d ", sum);                                                    
    }
    //cout << endl;                                                             
  }

  cout << res << endl;
}



Measured memory_bytes: 66816
/* imports all std modules {{{*/
import
  std.algorithm,
  std.array,
  std.ascii,
  std.base64,
  std.bigint,
  std.bitmanip,
  std.compiler,
  std.complex,
  std.concurrency,
  std.container,
  std.conv,
  std.csv,
  std.datetime,
  std.demangle,
  std.encoding,
  std.exception,
  std.file,
  std.format,
  std.functional,
  std.getopt,
  std.json,
  std.math,
  std.mathspecial,
  std.meta,
  std.mmfile,
  std.net.curl,
  std.net.isemail,
  std.numeric,
  std.parallelism,
  std.path,
  std.process,
  std.random,
  std.range,
  std.regex,
  std.signals,
  std.socket,
  std.stdint,
  std.stdio,
  std.string,
  std.system,
  std.traits,
  std.typecons,
  std.uni,
  std.uri,
  std.utf,
  std.uuid,
  std.variant,
  std.zip,
  std.zlib;
/*}}}*/

/+---test
a
---+/

void main(string[] args) {
  const c = readln.chomp;
  "%c".writefln((c[0]+1).to!char);
}


Measured memory_bytes: 256
//Md Fahad
// CSE 18

#include<bits/stdc++.h>

using  namespace  std;

#define PI              acos(-1.0)
#define lcm(a,b)        (a * (b / __gcd(a,b)))
#define en '\n'

#define READ_IN freopen("Input.txt","r",stdin);
#define READ_OUT freopen("Output.txt","w",stdout);
#define Infi                0x3f3f3f3f

const int dx[] = {+1,-1,+0,+0};                         // 4 X directions
const int dy[] = {+0,+0,+1,-1};                         // 4 Y directions
const int dx8[] = {+0,+0,+1,-1,-1,+1,-1,+1};            // King X Moves
const int dy8[] = {-1,+1,+0,+0,+1,+1,-1,-1};            // King Y Moves
const int kx[] = {-2, -2, -1, -1,  1,  1,  2,  2};      // Knight X Moves
const int ky[] = {-1,  1, -2,  2, -2,  2, -1,  1};      // Knight Y Moves



int  Set    (int N,int pos) {return N=N | (1<<pos);}    /// turn a bit on
int  reset  (int N,int pos) {return N= N & ~(1<<pos);}  /// turn a bit off
bool check  (int N,int pos) {return (bool)(N & (1<<pos));} /// check, if a bit is on or not

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define trace(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define trace(x...)
#endif

typedef long long int           ll;
typedef unsigned long long int  llu;




int main(void)
{
  // READ_IN;
    //READ_OUT;

    int n,k;
    cin >> n >> k;
    int cnt=0;
   while(n>0){
    int r=n%k;
    n=n/k;
    cnt++;
   }
   cout << cnt << endl;

    return 0;
}



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

///////////////////////////////////////////
const long long int INF = INT64_MAX;
//const long long int INF = 1000000;
const long long int Mod = 1000000007;
using ll = long long int;
using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<=former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
typedef vector<vector<ll> > matrix;
///////////////////////////////////////////////////////////////////////////////////


int main(){
    ll a,b,ans=0;
    cin>>a>>b;
    ans += a;
    ans += b/2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256