akhauriyash/Code-Regression huggingface dataset:
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define out(ans) cout << ans << endl;

int main()
{
  ll n, q;cin>>n>>q;
  ll a[n + 10], x[q + 10];
  rep(i, n) cin >> a[i];
  vector<ll> s(n + 1, 0);
  rep(i, n) s[i + 1] = s[i] + a[i];
  rep(i, q)
  {
    ll x;cin>>x;
    ll count = 0;

    ll sum = 0;
    ll right = 0;
    rep(left,n){
      while(right<n&&sum+a[right]<=x){
        sum += a[right];
        right++;
      }

      count += (right - left);
      if(right==left)right++;
      else sum-=a[left];
    }
    out(count);
  }



  return 0;
}



Measured memory_bytes: 4416
#include<iostream>
#include<vector>
#include<cstring>
#define endl "\n"
#define eb emplace_back
typedef long long ll;
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a;
    cin >> a;
    cout << a + a * a + a * a * a << endl;
}

Measured memory_bytes: 3604
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
using namespace::std;
int main(){
  int N;
  int A;
  int B;
  cin>>N>>A>>B;
  if(N*A<B){
    cout<<N*A;
  }else{
    cout<<B;
  }
 
  
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>

using namespace std;
int main()
{
	int a;
	cin >> a;
	int b;
	cin >> b;
	int c;
	cin >> c;
	
	if (abs(a - b) < abs(a - c))
		cout << "A" << endl;

	else
		cout << "B" << endl;


	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#include <string>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;

#define rep(i, n) for(int i = 0; i < n ; i++ )
#define For(i, a, b) for(int i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

int main(void){
    int A, B, T;

    cin >> A >> B >> T;
    
    cout << T / A * B << endl;

    return 0;
}

Measured memory_bytes: 256
/* Author:bhagatsunny96
         JGEC
	   template__
	lets_code_it_ */
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long int 
#define ld long double
#define fi first
#define se second
#define mod 1000000007
#define test long long int t; cin>>t; while(t-->0)
#define fIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define loop(n) for(long long int i=0;i<n;i++)
#define loopr(n) for(long long int i=n-1;i>=0;i--)
#define lrp(a,b) for(long long int i=a;i<=b;i++)
#define lrn(a,b) for(long long int i=b;i>=a;i--)
#define endl '\n'
#define ivec vector<ll>
#define ivecp vector<pair<ll,ll>>
#define imap map<ll,ll>
#define uimap unordered_map<ll,ll>
#define iset set<ll>
#define cvec vector<char>
#define civecp vector<pair<char,ll>>
#define cimap map<char,ll>
#define ucimap unordered_map<char,ll>
#define cset set<char>
using namespace std;
ll gcd(ll a, ll b)
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);
}
ll lcm(ll a, ll b)  
 {  
    return (a*b)/__gcd(a, b);  
 }
 ll power(ll x, unsigned ll y) 
 { 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2); 
    if (y%2 == 0) 
        return temp*temp; 
    else
        return x*temp*temp; 
 }
 bool isPrime(ll num)
 {
    bool flag=true;
    for(ll i =2;i<=num/2;i++) 
    {
       if(num%i==0) 
       {
          flag=false;
          break;
       }
    }
    return flag;
}
bool isPalin(ll num)
{
    bool flag=false;
    ll digit,rev=0,n=num;
    do
     {
         digit = num % 10;
         rev = (rev * 10) + digit;
         num = num / 10;
     } while (num != 0);
     if(rev==n)
     flag=true;
     return flag;
}
ll sumofdigits(ll n)
{
    ll c=0;
    while(n>0)
    {
        c++;
        n/=10;
    }
    return c;
}
bool sortinrev(const pair<int,int>&a,const pair<int,int>&b) 
{ 
    return (a.first > b.first); 
}
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}
string sortString(string &str) 
{ 
   sort(str.begin(), str.end()); 
   return str;
} 
void countSort(ll arr[], ll n, ll exp) 
{ 
	ll output[n];
	ll i, count[10] = {0}; 
	for (i = 0; i < n; i++) 
		count[ (arr[i]/exp)%10 ]++; 
	for (i = 1; i < 10; i++) 
		count[i] += count[i - 1]; 
	for (i = n - 1; i >= 0; i--) 
	{ 
		output[count[ (arr[i]/exp)%10 ] - 1] = arr[i]; 
		count[ (arr[i]/exp)%10 ]--; 
	} 
	for (i = 0; i < n; i++) 
		arr[i] = output[i]; 
} 
void radixsort(ll arr[], ll n) 
{
    ll mx = arr[0]; 
	for (ll i = 1; i < n; i++) 
		if (arr[i] > mx) 
			mx = arr[i];
	ll m =mx;
	for (ll exp = 1; m/exp > 0; exp *= 10) 
		countSort(arr, n, exp); 
} 
void print(ll arr[], ll n) 
{ 
    for (ll i = 0; i < n; i++) 
        cout << arr[i] << " "; 
} 
int main() 
{
    fIO
    ll n,k;
    cin>>n>>k;
    ll x=n-((n/k)*k);
    if(abs(-k+x)<x)
    {
        x=abs(-k+x);
    }
    cout<<x<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P std::pair<int,int>
#define PiP std::pair<int,std::pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp std::make_pair
#define prique(T) std::priority_queue<T,vector<T>,greater<T>>
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = std::max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = std::min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int get_rand(int MIN, int MAX) {
	std::random_device rnd;
	std::mt19937 mt32(rnd());
	std::uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt32);
}
/*--------Library Zone!--------*/


int ans[500005];
signed main() {
	string s; cin >> s;
	int cnt = 0;
	rep(i, s.size()) {
		if (s[i] == '<')cnt++;
		else cnt = 0;
		ans[i + 1] = cnt;
	}
	cnt = 0;
	for (int i = s.size() - 1; i >= 0; i--) {
		if (s[i] == '>')cnt++;
		else cnt = 0;
		chmax(ans[i], cnt);
	}
	int res = 0;
	rep(i, s.size() + 1)res += ans[i];
	cout << res << endl;
}


Measured memory_bytes: 4740
#include <cstdio>
#include <algorithm>

#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
ll K, A, B;

int main() {
  scanf("%lld %lld %lld", &K, &A, &B);

  if (B - A <= 1) printf("%lld", K+1);
  else {
    int d = K - (A-1);
    if (d % 2 == 0) {
      printf("%lld\n", A + d / 2 * (B - A));
    } else {
      printf("%lld\n", A + d / 2 * (B - A) + 1);
    }
  }


  return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

#define all(a) (a).begin(), (a).end()

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

vector<vector<ll>> dp(100010, vector<ll>(2, 1));

void dfs(int cv, int pv, vector<vector<int>> &G){
    vector<int> children;
    for(auto nv : G[cv]){
        if(nv == pv) continue;

        dfs(nv, cv, G);
        children.emplace_back(nv);
    }

    for(auto i : children){
        dp[cv][0] *= (dp[i][0] + dp[i][1]);
        dp[cv][0] %= MOD;
        dp[cv][1] *= dp[i][0];
        dp[cv][1] %= MOD;
    }
    return ;
}

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

    int n; cin>>n;
    vector<vector<int>> G(n);
    for(int i=0; i<n-1; i++){
        int x, y; cin>>x>>y;
        x--, y--;
        G[x].emplace_back(y);
        G[y].emplace_back(x);
    }

    dfs(0, -1, G);

    cout << (dp[0][0] + dp[0][1]) % MOD << endl;

    return 0;
}

Measured memory_bytes: 20992
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N = 107;
int D[N], L[N];
signed main() {
    int n, x;
    cin >> n >> x;
    for (int i = 1; i <= n; ++i) cin >> L[i];
    D[1] = 0;
    int ans = 1;
    for (int i = 2; i <= n + 1; ++i) {
        D[i] = D[i - 1] + L[i - 1];
        if (D[i] <= x) ++ans;
    }
    cout << ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        StringBuilder sb = new StringBuilder();
        int i = 1;
        while (i <= 11) {
            if (n > Math.pow(26, i)) {
                n -= Math.pow(26, i++);
                continue;
            }
            n -= 1;
            for (int j = 0; j < i; j++) {
                sb.append((char) (n % 26 + 'a'));
                n /= 26;
            }
            break;
        }
        System.out.println(sb.reverse());
    }

}


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

using namespace std;
typedef long long ll;
const int maxn = 5e5 + 10;
const int inf = 1e9;

pair<int, int> p[maxn];
int mr[maxn];

int cost(int L, int R){
	return max(0, R - L + 1);
}

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> p[i].first >> p[i].second;
	sort(p, p + n);
	mr[0] = p[0].second;
	for (int i = 1; i < n; i++)
		mr[i] = min(mr[i - 1], p[i].second);
	int L = p[n - 1].first, R = p[n - 1].second;
	int answer = 0;
	for (int i = n - 2; i >= 0; i--){
		int l = p[i].first, r = p[i].second;
		int minr = (i == 0 ? inf : mr[i - 1]);
		answer = max(answer, r - l + 1);
		answer = max(answer, max(cost(l, min(r, minr)) + cost(L, R), cost(l, r) + cost(L, min(R, minr))));
		R = min(R, r);
	}
	cout << answer << endl;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a;
    cin >> a;
    map<char, ll> m;
    ll al = a.length();
    rep(i, al) m[a[i]]++;
    ll ans = al * (al - 1) / 2 + 1;
    for(auto x : m) ans -= x.second * (x.second - 1) / 2;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 720
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <queue>
#include <math.h>
#include <cmath>
#include <unordered_map>

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


const string YES = "Yes";
const string NO = "No";

void solve(long long K, long long X){
    if(K*500>=X){
        cout<<YES<<endl;
    }else{
        cout<<NO<<endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long K;
    scanf("%lld",&K);
    long long X;
    scanf("%lld",&X);
    solve(K, X);
    return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)

points = [0] + a + [0]
distances = (0...(points.length - 1)).map do |i|
  (points[i] - points[i + 1]).abs
end
total_distances = distances.reduce(&:+)
remove_saves = (0...n).map do |i|
  before = distances[i] + distances[i + 1]
  after = (points[i] - points[i + 2]).abs
  before - after
end.each { |save| puts (total_distances - save) }


Measured memory_bytes: 14724
#include <bits/stdc++.h>
using namespace std;
#define int long long

bool isprime(int n){
    double rootn = sqrt(n);
    if (n < 2){
        return false;
    }
    else if (n == 2){
        return true;
    }
    else if (n % 2 == 0){
        return false;
    }
    else{
        for(int i = 3; i <= rootn; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }
}

// 空のベクトルを二つ渡す。N (>=2) 以下の素数を primes に順番に入れる。
void prime_vectors(int N, vector<int>& primes, vector<bool>& is_prime){
    primes = {};
    is_prime = {};
    for(int i=0; i<=N; i++){
        is_prime.push_back(true);
    }

    primes.push_back(2);
    for(int j=4; j<=N; j+=2){
        is_prime[j] = false;
    }

    int i;
    for(i=3; i*i<=N; i+=2){
        if(!is_prime[i]) continue;
        primes.push_back(i);
        for(int j=2*i; j<=N; j+=i){
            is_prime[j] = false;
        }
    }

    for(; i<=N; i+=2){
        if(is_prime[i]){
            primes.push_back(i);
        }
    }
}

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int K;
    cin >> K;
    set<int> st = {};

    int num = 7, cnt = 1;
    while(num % K != 0){
        num = (num * 10 + 7) % K;
        cnt++;
        if(st.find(num) != st.end()){
            cout << "-1" << endl;
            return 0;
        }
        else{
            st.insert(num);
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 50604
from collections import deque
from bisect import bisect_left
import sys
def input():return sys.stdin.readline().strip()

def main():
    N = int(input())
    A = tuple(map(int, input().split()))

    to = [[] for _ in range(N)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        to[a].append(b)
        to[b].append(a)
    
    # bfs
    INF = 10 ** 18
    dp = [INF] * N
    ans = [0] * N

    def dfs(s):
        stack = deque()
        pop = stack.pop
        push = stack.append

        push((s, -1, None))

        while stack:
            now, pre, old = pop()

            # 復元
            if now == -1:
                dp[pre] = old
                continue
            
            a = A[now]
            idx = bisect_left(dp, a)
            old = dp[idx]
            dp[idx] = a

            ans_idx = bisect_left(dp, INF)
            ans[now] = ans_idx

            # 復元用 頂点
            # (フラグ, 変更したidx, 前の値)
            push((-1, idx, old))
            
            for nv in to[now]:
                if nv != pre:
                    push((nv, now, None))
    
    dfs(0)
    print(*ans, sep="\n")

if __name__ == "__main__":
    main()

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

namespace AtCoder
{
    class Program
    {
        static int Solve(string s)
        {
            var c = new List<char>();
            var pos = new List<int>();
            for (int i = 0; i < s.Length; ++i)
            {
                if (s[i] != 'x')
                {
                    c.Add(s[i]);
                    pos.Add(i);
                }
            }
            string S = new string(c.ToArray());
            string T = new string(S.Reverse().ToArray());
            if (S == T)
            {
                int N = S.Length;
                int L = (N - 1) / 2;
                int R = (N - 0) / 2;
                int cnt = 0;
                for (int i = 0; i < (N + 1) / 2; ++i)
                {
                    int p = (L - i - 1 >= 0) ? pos[L - i - 1] : -1;
                    int q = (R + i + 1 < N)  ? pos[R + i + 1] : s.Length;
                    int a = pos[L - i] - p - 1;
                    int b = q - pos[R + i] - 1;
                    cnt += Math.Max(a, b) - Math.Min(a, b);
                }
                return cnt;
            }
            else
            {
                return -1;
            }
        }
        static void Main(string[] args)
        {
            Console.WriteLine(Solve(Console.ReadLine()));
        }
    }
}


Measured memory_bytes: 14816
#include<iostream>

using namespace std;
int main()
{
    long long int a,b,i;
    cin>>a>>b;

    for(i=1;i<=b;i++)
    {
        if((a*i)%b == 0)
        {
            cout<<a*i<<endl;
             break;
        }
    }
    return 0;
}


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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int j;
            bool flag=false;
            bool nflag=false;
            var x=new string[2];
            for (int i = 0; i < 2; i++)
            {
                x[i] = Console.ReadLine();
            }
            var y=new List<char>();
            var z=new List<char>();
            for (int i = 0; i < x[1].Length; i++)
            {
                z.Add(x[1][i]);
            }
            for (int i = 0; i < x[0].Length; i++)
            {
                y.Add(x[0][i]);
            }
            y.Sort();
            z.Sort();
            z.Reverse();
            for (j = 0; j < y.Count&& j < z.Count; j++)
            {
                 if (y[j] == z[j]) continue;
                 else if (y[j] < z[j])
                 {
                     flag = true;
                     break;
                 }
                    else { nflag = true; }
            }
            if (flag)
            {
                Console.WriteLine("Yes");
            }
            else if (nflag)
            {
                Console.WriteLine("No");
            }
            else
            {
                if (y.Count<z.Count) {
                    Console.WriteLine("Yes"); flag = true;
                }
                else  Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 11476
#include<bits/stdc++.h>
using namespace std;
string a,b;
int lena,lenb;
int main(){
    getline(cin,a),getline(cin,b);//getline是读入一整行的
    sort(a.begin(),a.end());
    sort(b.begin(),b.end(),greater<char>());//greater<char>就是把字符从大到小排序的函数
    if(a<b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
bool zero(double a,double b){
  double hako = (a-b) * (a-b);
  return (hako < 0.0001);
}
int main(){
  double w,h,x,y;
  cin >> w >> h >> x >> y;
  cout << (w*h/2)  << " " <<  (zero(w/2,x) and zero(h/2,y) ? 1 : 0) << endl;
	return 0;
}
  



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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;


int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    REP(i, n) {
        cin >> a[i];
        a[i]--;
    }

    if(k < 2000000) {
        int now = 0;
        REP(i, k) {
            now = a[now];
        }
        cout << now + 1  << endl;
        return 0;       
    }

    ll now = a[0];
    ll loop = 1;
    vector<bool> visited(n, false);
    visited[0] = true;
    while(1) {
        if(visited[now]) {
            break;
        } else {
            visited[now] = true;
        }
        loop++;
        //cout << now << endl;
        now = a[now];
    }
    //cout << loop << " " << now<< endl;
    ll now2 = a[0];
    ll tmp = loop;
    ll sentou = 1;
    while(1) {
        if(now2 == now) break;
        sentou++;
        now2 = a[now2];
    }
    //cout << sentou << " " << tmp << endl;
    if(tmp != sentou) tmp -= sentou;
    loop = (k-sentou) % tmp;
    //cout << loop << endl;

    now = 0;
    REP(i, loop + sentou) {
        now = a[now];
    }

    cout << now + 1 << endl;
    return 0;
}

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

int Fib(int i, vector<int>& fib)
{
	if (i == 0) return 1;
	if (i == 1) return 1;
	if (fib[i]) return fib[i];
	return fib[i] = Fib(i - 1, fib) + Fib(i - 2, fib);
}

int main()
{
	int n;
	cin >> n;
	vector<int> fib(n + 1);
	cout << Fib(n, fib) << endl;
}



Measured memory_bytes: 3100
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <limits>
#include <algorithm>
#include <queue>
#include <set>
#include <unordered_map>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <stack>
#include <string>
#include <functional>
using namespace std;

using i64 = long long int;
using ui64 = unsigned long long int;

using P = pair<int, int>;

constexpr int INF = (1 << 30);
constexpr i64 INF64 = (1LL << 60);
constexpr int MOD = 1000000000 + 7;

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

template <typename T, typename U>
static inline std::vector<U> makeNdVector(T n, U val) noexcept {
   static_assert(std::is_integral<T>::value, "[makeNdVector] 1st argument must be an integer type");
   return std::vector<U>(std::forward<T>(n), std::forward<U>(val));
}

template <typename T, typename ...Args>
static inline decltype(auto) makeNdVector(T n, Args... args) noexcept {
   static_assert(std::is_integral<T>::value, "[makeNdVector] 1st argument must be an integer type");
   return std::vector<decltype(makeNdVector(std::forward<Args>(args)...))>(std::forward<T>(n), makeNdVector(std::forward<Args>(args)...));
}

template <typename T>
void print(vector<T> vec)
{
   for (auto &e : vec)
      cout << e << " ";
   cout << endl;
}

template <typename T>
T gcd(T x, T y) {
   if (x == 0 || y == 0) return 0;
   T r;
   while ((r = x % y) != 0) {
      x = y;
      y = r;
   }
   return y;
}

template <typename T>
T lcm(T x, T y) {
   if (x == 0 || y == 0) return 0;
   return (x / gcd(x, y) * y);
}

int next_combination(int sub)
{
   int x = sub & -sub, y = sub + x;
   return (((sub & ~y) / x) >> 1) | y;
}

std::uint64_t combination(int n, int r) {
   if (n < 0 || r < 0) return 0;
   if (n < r) return 0;
   std::uint64_t k = 1;
   for (std::uint64_t d = 1; d <= r; ++d) {
      k *= n--;
      k /= d;
   }
   return k;
}

bool check(string str) {
	for (int i = 0; i < str.length() / 2; ++i) {
		if (str[i] != str[str.length() - 1 - i]) {
			return false;
		}
	}
	return true;
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	using P = pair<i64, i64>;

	int V, E; cin >> V >> E;
	auto G = makeNdVector(V, V, INF64);
	for (int i = 0; i < E; ++i) {
		int s, t, d; cin >> s >> t >> d;
		G[s][t] = d;
	}

	auto dp = makeNdVector((1 << V), V, (i64)INF64);
	dp[0][0] = 0;
	for (int i = 0; i < (1 << V); ++i) {
		for (int j = 0; j < V; ++j) {
			if (((1 << j)&i) == 0) {
				for (int k = 0; k < V; ++k) {
					dp[i | (1 << j)][j] = min(dp[i | (1 << j)][j], dp[i][k] + G[k][j]);
				}
			}
		}
	}

	if (dp[(1 << V) - 1][0] == INF64) cout << -1 << endl;
	else cout << dp[(1 << V) - 1][0] << endl;
}


Measured memory_bytes: 7740
n,m = map(int,input().split())

array = []
[array.append(list(map(int,input().split()))) for x in range(n)]

total = 0

array.sort()

for yen,num in array:
    if num < m:
        total += yen*num
        m -= num
    else:
        total += yen*m
        break
print(total)


Measured memory_bytes: 28156
import Data.List
main = do
  [k,x] <- map read . words <$> getLine :: IO [Int]
  let ss = delete x $ filter (\a -> (a < 2000002) && (a > -2000002)) ([(x-(k-1))..x] ++ [x..(x+k-1)])
  putStrLn $ init $ concatMap (\a -> show a ++ " ") ss

Measured memory_bytes: 636
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in) ;
    int S = scan.nextInt();
    if(S<60){
      System.out.println("0:0:"+ S);
    }else if(S>=60 && S<3600){
      int m = S/60;
      int s = S%60;
      System.out.println ("0:"+m+":"+s);
    }else if(S>=3600){
      int h = S/3600;
      S = S-h*3600;
      int m = S/60;
      int s = S%60;
      System.out.println(h+":"+m+":"+s);
    }
  }
}



Measured memory_bytes: 26208
#!/usr/bin/env python3
import sys


def solve(N: int):
    if N >= 64:
        print(64)
    elif N >= 32:
        print(32)
    elif N >= 16:
        print(16)
    elif N >= 8:
        print(8)
    elif N >= 4:
        print(4)
    elif N >= 2:
        print(2)
    else:
        print(1)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9192
s=input()
w=b=False
cnt=0
for i in s:
  if i=="B":
    if w==True:
      cnt+=1
      w=False
      b=True
    else:
      b=True
  else:
    if b==True:
      cnt+=1
      b=False
      w=True
    else:
      w=True
print(cnt)

Measured memory_bytes: 3188
n, x, m = gets.chomp!.split(" ").map(&:to_i)

if x == 0
    puts 0
    exit 0
elsif x == 1
    puts n
    exit 0
end

memo = {}

ans = x
sum = x
memo[ans] = 1

b_i = -1
2.upto(n) do |i|
    ans = (ans ** 2) % m
    sum += ans
    if memo[ans]
        b_i = i - 1
        sum -= ans
        break
    else
        memo[ans] = 1
    end
end

if b_i == -1
    puts sum
else
    # 残回数
    rem = n - memo.length

    j = -1
    found = false
    sub = 0
    memo.each.with_index(0) do |(k, _), i|
        if k == ans
            found = true
            j = i
        end

        if found
            sub += k
        end
    end

    # 1ループ数
    lp = memo.length - j

    sum += ((rem / lp) * sub)
    #pp sum
    rem2 = rem % lp
    #pp rem2
    x = memo.keys
    #pp x
    j.upto(rem2+j-1) do |i|
        sum += x[i]
    end

    puts sum
end
    


Measured memory_bytes: 16636
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>
#include <math.h>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

#define ll long long
#define ull unsigned long long

#define	max	1000000007

ll gcd(ll a, ll b) {
	if (a < b)
		swap(a, b);
	while (ll r = a % b)
		a = b, b = r;
	return b;
}

class mod
{
public:
	ll val;

	mod(ll v)
	{
		val = v % max;
	}

	mod()
	{
		val = 0;
	}

	void operator -=(const mod &v)
	{
		val -= v.val;

		if (val < 0)
			val += max;
	}

	void operator +=(const mod &v)
	{
		if (val + v.val >= max)
			val -= max;
		val += v.val;
	}

	void operator +=(ll &v)
	{
		if (val + v >= max)
			val -= max;
		val += v;
	}

	void operator *=(const mod &v)
	{
		val *= v.val;
		val %= max;
	}

	void operator *=(ll &v)
	{
		val *= v;
		val %= max;
	}

	ll modinv(ll a)
	{
		ll b = max, u = 1, v = 0;
		while (b)
		{
			ll t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		u %= max;
		if (u < 0)
			u += max;
		return u;
	}

	void operator /=(const mod &v)
	{
		val *= modinv(v.val);
		val %= max;
	}

	void operator /=(ll &v)
	{
		val *= modinv(v);
		val %= max;
	}
};

//	for priority queue
//	priority_queue<ipair, vector<ipair>, greater<ipair>>
using ipair = pair<int, pair<int, int>>;
bool operator>(const ipair a, const ipair b) { return a.first > b.first; };
bool operator<(const ipair a, const ipair b) { return a.first < b.first; };

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

	printf("%c%c%c", s[0], s[1], s[2]);
	return 0;
}


Measured memory_bytes: 3256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
int main()
{
    ll n,m;
    cin>>n>>m;
    ll i,j,a[m],b[m],c[m][n];
    for(i=0;i<m;i++)
    {
        cin>>a[i]>>b[i];
        for(j=0;j<b[i];j++)
        {
            cin>>c[i][j];
        }
    }
    vector<ll> dp(5000, 1e10);
    dp[0]=0;
    for(i=0;i<m;i++)
    {
        ll now = 0;
        for(j=0;j<b[i];j++)
        {
            now|=(1<<(c[i][j]-1));
        }
        for(ll k = 0;k<(1<<n);k++)
        {
            if(dp[k]+ a[i] < dp[k|now])
            {
                dp[k|now] = dp[k] + a[i];
            }
        }
    }

    if(dp[(1<<n)-1] == 1e10) dp[(1<<n)-1] = -1;
    cout<<dp[(1<<n)-1];
    
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'e' || c == 'i' ||c == 'o' || c == 'u') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
  }


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

#define REP(i, a, b) for (int i = (a); i <= (b); ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define FORV(a, A) for (auto &a : A)

using ll = long long;

using namespace std;

void Main()
{
   int N;
   cin >> N;
   multiset<int> V;
   int v;
   REP(i,0,N-1)
   {
      cin >> v;
      V.insert(v);
   }
   double ans = 0;
   int i=1;
   for(auto v=V.begin();v!=V.end();v++)
   {
      if(i)
      {
         ans += *v;
         i = 0;
         continue;
      }
      ans += *v;
      ans/=2.0;
   }
   cout << ans << endl;
   return;
}

int main()
{
   std::cin.tie(nullptr);
   std::ios_base::sync_with_stdio(false);
   std::cout << std::fixed << std::setprecision(15);
   Main();
   return 0;
}

Measured memory_bytes: 256
import sys
from itertools import starmap
readline = sys.stdin.readline
class Segment(object):
    __slots__ = ('fi', 'se')
    def __init__(self, fi, se):
        self.fi = fi
        self.se = se
def cross(a, b):
    return a.real * b.imag - a.imag * b.real
def dot(a, b):
    return a.real * b.real + a.imag * b.imag
def norm(base):
    return abs(base) ** 2
def project(s, p2):
    base = s.fi - s.se
    r = dot(p2 - s.fi, base) / norm(base)
    return s.fi + base * r
s = Segment(*starmap(complex, zip(*[map(int, readline().split())] * 2)))
n = int(readline())
for _ in [0] * n:
    p2 = complex(*map(float, readline().split()))
    ap = project(s, p2)
    print(ap.real, ap.imag)

Measured memory_bytes: 8004
def main():
    n = int(input())
    S = [input() for _ in [0]*n]
    s2 = []
    s3 = []
    for s in S:
        temp = [0, 0]
        m = 0
        now = 0
        for i in s:
            if i == "(":
                now += 1
            else:
                now -= 1
            m = min(m, now)
        temp[0] = -m
        temp[1] = (s.count("(")-s.count(")"))-m
        if temp[0] < temp[1]:
            s2.append(temp)
        else:
            s3.append(temp)
    s2.sort(key=lambda x: (x[0]))
    s3.sort(key=lambda x: (-x[1]))
    cnt = 0
    for i, j in s2:
        cnt -= i
        if cnt < 0:
            print("No")
            return
        cnt += j
    for i, j in s3:
        cnt -= i
        if cnt < 0:
            print("No")
            return
        cnt += j
    if cnt != 0:
        print("No")
        return
    print("Yes")


main()

Measured memory_bytes: 260180
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)


const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;



signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	VE a(n); rep(i, n)cin >> a[i];
	int b1 = 0, b2 = 0, b4 = 0;
	rep(i, n) {
		if (a[i] % 4 == 0)b4++;
		else if (a[i] % 2 == 0)b2++;
		else b1++;
	}
	if (b2 == 0) {
		if (b1 <= b4 + 1) {
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
	else {
		if (b1 <= b4) {
			cout << "Yes" << endl;
		}
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, K := sc.nextInt(), sc.nextInt()
	if N == 0 {
		fmt.Fprintln(wtr, 1)
		return
	}
	ans := 0
	for N > 0 {
		N /= K
		ans++
	}

	fmt.Fprintln(wtr, ans)
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
using namespace std;
typedef pair<long long,long long> Paint;
struct mpper{
  long long b;//begin
  long long c;//center -> 1,2の1側
  long long e;//end
};
int main(){
  long long n,t,q;cin>>n>>t>>q;
  vector<Paint> a(n);
  for(int i = 0; n > i; i++){
    cin>>a[i].first >> a[i].second;
  }
  // 222/1122/112222/1111222/11
  vector<mpper> lr;
  mpper tmp = {0,-100,-100};
  if(a[0].second == 2){
    tmp.b = -1;//none
    tmp.c = -1;//none
  }
  for(int i = 1; n > i; i++){
    if(a[i-1].second != a[i].second){
      if(a[i-1].second == 2){
        tmp.e = i-1;
        lr.push_back(tmp);
        tmp = {i,-100,-100};
      }else{
        tmp.c = i-1;
      }
    }
  }
  if(tmp.c == -100){// 1122/11
    tmp.c = n+1;//none
    tmp.e = n+1;//none
    lr.push_back(tmp);
  }else{ 
    tmp.e = n-1;
    lr.push_back(tmp);
  }

  //output
  for(int i = 0; q > i; i++){
    long long x;cin>>x;x--;
    int me = 0;
    for(; lr.size() > me; me++){
      if(lr[me].b <= x && x <= lr[me].e)break;
    }
    if(lr[me].b == -1){//永遠に西に歩け
      cout << a[x].first - t << endl;
    }else if(lr[me].e == n+1){//永遠に東に歩け
      cout << a[x].first + t << endl;
    }else{//ぶつかって歩き話をする可能性があるので
      long long seken = (a[lr[me].c].first + a[lr[me].c+1].first) / 2;
      if(x <= lr[me].c){//->
        cout << min(seken,a[x].first + t) << endl;
      }else{//<-
        cout << max(seken,a[x].first - t) << endl;
      }
    }

  }
}


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

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

  int cnt =0;

  if(s[0] ==a[0])cnt++;
  if(s[1] ==a[1])cnt++;
  if(s[2] ==a[2])cnt++;

  cout <<cnt<<endl;
  
}






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

int main( void )
{
  int N;
  cin >> N;
  int count = 0;

  for( int i  = 1; i <= N; i++ )
    for( int j = 1; i * j <= N; j++ )
	if( i * j < N ) {
	  count++;
	}
  cout << count << endl;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
 
#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
bool inLine(int x,int y,int mx,int my){return (x>=0&&y>=0&&x<mx&&y<my);}
const lol inf=(1LL<<62);
const lol MOD=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>n>>m>>k;
  string s[n];
  for(int i=0;i<n;i++) cin >>s[i];
  lol ans=0;
  lol t=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      if(s[i][j]=='#') t++;
    }
  }
  for(int i=0;i<(1LL<<n);i++){
    string tmp[n];
    for(int o=0;o<n;o++) tmp[o]=s[o];
    lol sum=t;
    for(int j=0;j<n;j++){
      if(i&(1LL<<j)){
        for(int jj=0;jj<m;jj++){
          if(tmp[j][jj]=='#'){
            tmp[j][jj]='.';
            sum--;
          }
        }
      }
    }
    if(sum<k) continue;
    lol ww=sum;
    for(int j=0;j<(1LL<<m);j++){
      sum=ww;
      for(int jj=0;jj<m;jj++){
        if(j&(1LL<<jj)){
          for(int p=0;p<n;p++){
            if(tmp[p][jj]=='#') sum--;
          }
        }
      }
      if(sum==k){
        ans++;
      }
    }
  }
  cout <<ans<<'\n';
  return (0);
}

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

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

    int k=2;
    while(k*(k-1)/2 < n) k++;
    if(k*(k-1)/2 != n){
        cout << "No" << endl;
        return 0;
    }

    int a[500][500];
    int b[500];
    for(int i=1; i<=k; i++)b[i]=0;
    int x=1;
    for(int i=1; i<=k; i++){
        for(int j=i+1; j<=k; j++){
            a[i][b[i]]=x;
            b[i]++;
            a[j][b[j]]=x;
            b[j]++;
            x++;
        }
    }

    cout << "Yes" << endl;
    cout << k << endl;

    for(int i=1; i<=k; i++){
        cout << k-1 << " ";
        for(int j=0; j<k-1; j++){
            cout << a[i][j];
            if(j==k-2) cout << endl;
            else cout << " ";
        }
    }

}

Measured memory_bytes: 2304
#


def main():
    a, b, c, d = map(int, input().split(" "))
    while a > 0 and c > 0:
        c -= b
        if c <= 0:
            print("Yes")
            return
        a -= d
        if a <= 0:
            print("No")
            return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9164
#include <bits/stdc++.h>
#define FASTIO ios::sync_with_stdio(false);cin.tie(0);
#define ADD +
#define SUBTRACT -
#define MULTIPLY *
#define DIVIDE /
#define MOD %
#define INCREMENT(x) ++x
#define DECREMENT(x) --x
#define in(a,b) cin>>a>>b;
#define out(a,b) cout<<a<<endl<<b<<endl;
#define scan(a) scanf("%d",&a);
#define print(a) printf("%d\n",a);
#define scanii(a,b) scanf("%d %d",&a,&b);
#define printii(a,b) printf("%d\n%d\n",a,b);
#define scaniii(a,b,c) scanf("%d %d %d",&a,&b,&c);
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define ll long long
#define ull unsigned long long
#define sll signed long long
#define f1(i,a) for(int i=0;i<a;++i)
#define f2(i,a) for(int i=a-1;i>=0;--i)
#define pi acos(-1)
#define mod 1000000007
#define TRUE 1
#define FALSE 0
#define ZERO 0
#define MP make_pair
#define F first
#define S second

#define END puts("");
#define elif else if
typedef ll int lli;
typedef sll int slli;
typedef ull int ulli;
const int sz=10000;
using namespace std;

int clue();
int result();
void show();
bool check();

int main() {
    clue();
    return 0;
}
int clue() {
    
    lli n,d;
    cin>>n>>d;
    // multimap<lli,lli>m;
    // multimap<lli,lli>::iterator it;
    // list<pair<lli,lli> >m;
    // list<pair<lli,lli> >::iterator it;

    lli count=0;
    while(n-->0) {
        lli x,y;
        cin>>x>>y;
        lli p=x*x;
        lli q=y*y;
        lli pp=p+q;
        double c=sqrt(pp);
        if(c<=d)++count;
        // m.insert(MP(x,y));
        // m.pub(MP(x,y));
    }
    // for(it=m.begin();it!=m.end();++it) {
    //     lli x,y;
    //     x=it->first MULTIPLY it->first;
    //     y=it->second MULTIPLY it->second;

    //     lli p=x+y;
    //     double dd=sqrt(p);
    //     if(dd<=d)++count;
    // }
    // for(it=m.begin();it!=m.end();++it) {
        // cout<<it->first<<" "<<it->second<<endl;
    // }

    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 3636
/* ex 3_3
  kt125 */

#include<stdio.h>

int main(void){
  int n, k;  //整数nをk進数で表す
  scanf("%d %d", &n, &k);
  
  int q, ans = 0; //quotient,answer
  while(1){ 
    q = n / k;
    if (n/k == 0){ //break if quotient is 0
      ans++;
      break;
    }
    n = q;
    ans ++;
  }
  printf("%d\n", ans);
  return 0;
}
    


Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	s := getString()

	e := ""
	for i, v := range s {
		if i%2 == 0 {
			e = e + string(v)
		}
	}
	out(e)
}


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

int main() {
    ll A, B, N;
    cin >> A >> B >> N;
    /*
    ll ans = 0;
    for (ll i = 1; i <= N; i++) {
        ans = max(ans, A*i/B - A*(i/B));
    }
    cout << ans << endl;
    */
    
    ll C = min(N, B-1);
    cout << A*C/B << endl;
    return 0;
}

Measured memory_bytes: 3596