akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
#include <stack>
#include <cctype>
#include <cmath>
#include <bitset>
#include <cassert>
using namespace std;
/* typedef */
typedef long long ll;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
ll combination2(ll n) {
    return n * (n - 1) / 2;
}
/* main */
int main(){
    int N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    vector<ll> cnt(N + 1, 0);
    for (int i = 0; i < N; i++) cnt[A[i]]++;
    ll tot = 0;
    for (int i = 0; i < N + 1; i++) tot += combination2(cnt[i]);
    for (int i = 0; i < N; i++) {
        ll ans = tot;
        ans -= combination2(cnt[A[i]]);
        ans += combination2(cnt[A[i]] - 1);
        cout << ans << '\n';
    }
}


Measured memory_bytes: 5760
N = int(input())
A = list(map(int, input().split()))

x = [0 for _ in range(N)]
for i in range(N):
    if i % 2 == 0:
        x[0] += A[i]
    else:
        x[0] -= A[i]
x[0] //= 2
for i in range(1, N):
    x[i] = A[i - 1] - x[i - 1]
ans = ' '.join(str(2 * X) for X in x)

print(ans)


Measured memory_bytes: 84708
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 10;
int a[maxn];
int main()
{
	int n, num = 0, maxx = 0;
	cin >> n;
	for(int i = 1; i <= n; i++){
		scanf("%d", &a[i]);
	}
	for(int i = 2; i <= n; i++){
		if(a[i] <= a[i - 1]){
			num++;
		}else{
			num = 0;
		}
		if(num > maxx){
			maxx = num;
		}
	}
	cout << maxx << endl;
	return 0;
}

Measured memory_bytes: 640
n, a, b, c = map(int, input().split())
L = [int(input()) for _ in range(n)]
INF = 10**4

def search(cou, x, y, z):
    if cou == n:
        return abs(x-a) + abs(y-b) + abs(z-c) - 30 if min(x, y, z) > 0 else INF
    ret0 = search(cou+1, x, y, z)    
    ret1 = search(cou+1, x+L[cou], y, z) + 10
    ret2 = search(cou+1, x, y+L[cou], z) + 10
    ret3 = search(cou+1, x, y, z+L[cou]) + 10
    return min(ret0, ret1, ret2, ret3)

print(search(0, 0, 0, 0))

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

int main(){
  int N;
  cin >> N;
  vector<int> A;
  A.push_back(0);
  for(int i=0; i<N; i++){
    int a; cin >> a;
    A.push_back(a);
  }
  A.push_back(0);
  long dist=0;
  for(int i=1; i<=N+1; i++){
    dist+=abs(A[i]-A[i-1]);
  }
  for(int i=1; i<=N; i++){
    long ans;
    ans=dist+abs(A[i+1]-A[i-1])-abs(A[i]-A[i-1])-abs(A[i+1]-A[i]);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
using namespace std;
int mod = 1000000007;
const int N = 1e5 + 5;
int ans[N];
int h[N];
char grid[1009][1009];
int ans2[1009][1009];
int hap[N][3];
int ans3[N][3];
int main(){
//    int n,k;
//    cin>>n>>k;
//    for(int i = 0 ; i < n ; i++)cin>>h[i];
//    ans[0]=0;
//
//    for(int i = 1; i < n ; i++){
//        ans[i] = 1e9;
//        for(int j = i-1;j>=max(i-k,0);j--){
//            ans[i] = min(ans[i],abs(h[i]-h[j])+ans[j]);
//        }
//    }
//    cout<<ans[n-1];
//    int n;
//    cin>>n;
//    for(int i = 0 ; i < n ; i++)cin>>h[i];
//
//    for(int i = 0 ; i < n ; i++){
//        ans[i] = 1;
//        for(int j = 0 ; j < i ; j++){
//            if(h[i]>h[j])ans[i] = max(ans[j]+1,ans[i]);
//        }
//    }
//    int mx = 0;
//    for(int i = 0 ; i < n ; i++)if(ans[i]>mx)mx=ans[i];
//    cout<<mx;
    int h,w;
    cin>>h>>w;
    for(int i = 0 ; i < h ; i++){
        for(int j = 0 ; j < w ; j++)cin>>grid[i][j];
    }
    ans2[0][0]=1;
    for(int i = 0 ; i < h ; i++){
        for(int j = 0 ; j < w ; j++){

            if(grid[i][j]=='#'){
                ans2[i][j]=0;
                continue;
            }
            if(j)ans2[i][j] =  ((ans2[i][j]%mod) + (ans2[i][j-1]%mod))%mod;
            if(i)ans2[i][j] =  ((ans2[i][j]%mod) + (ans2[i-1][j]%mod))%mod;
        }
    }
    cout<<ans2[h-1][w-1];
//    int n;
//    cin>>n;
//    for(int i = 0 ; i < n ; i++){
//        for(int j = 0 ; j < 3 ; j++)cin>>hap[i][j];
//    }
//    ans3[0][0] = hap[0][0]; ans3[0][1] = hap[0][1]; ans3[0][2] = hap[0][2];
//    for(int i = 1 ; i < n ; i++){
//        ans3[i][0] = max(ans3[i-1][1],ans3[i-1][2])+hap[i][0];
//        ans3[i][1] = max(ans3[i-1][0],ans3[i-1][2])+hap[i][1];
//        ans3[i][2] = max(ans3[i-1][0],ans3[i-1][1])+hap[i][2];
//    }
//    cout<<max(ans3[n-1][0],max(ans3[n-1][1],ans3[n-1][2]));
}

Measured memory_bytes: 5504
#coding: utf-8

N = int(input())
A = []
B = []
SUM = []
for i in range(N):
    a, b = (int(n) for n in input().split())
    A.append(a)
    B.append(b)
    SUM.append((a+b, i))


SUM.sort(reverse=True)

sumA = 0
sumB = 0
for i in range(N):
    idx = SUM[i][1]
    if i % 2 == 0:
        sumA += A[idx]
    else:
        sumB += B[idx]

print(sumA - sumB)



Measured memory_bytes: 30900
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int main()
{
    int n,k;
    cin >> n >> k;
    string s;
    cin >> s;
    vector<int> nums;
    
    int flag = s[0] == '1'?1:0;
    if(!flag)nums.push_back(0);
    vector<int> a = {'0','1'};
    int cnt = 1;
    rep(i,n-1){
        if(s[i+1] == a[flag])cnt++;
        else{
            nums.push_back(cnt);
            cnt = 1;
            flag = 1-flag;
        }
    }
    nums.push_back(cnt);
    if(!nums.size()%2)nums.push_back(0);
    int add = 2*k+1;
    int ans = 0;
    vector<int> sum(nums.size()+1);
    rep(i,nums.size())sum[i+1] = sum[i] + nums[i];

    for(int i = 0;i< nums.size();i+=2){
        
        int left = i;
        int right = min(i+ add,(int)nums.size());
        int res = sum[right] - sum[left];

        
        ans = max(ans,res);


    }
    cout << ans  << endl;
    
    
    return 0;
}

Measured memory_bytes: 1272
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  string s;
  cin >> s;
  s.erase(unique(s.begin(), s.end()), s.end());
  cout << s.size() - 1 << endl;
  return 0;
}

Measured memory_bytes: 512
import java.util.*;class Main{public static void main(String[]z){Scanner s = new Scanner(System.in);String x;for(int n,m,i;(n=s.nextInt())>0;System.out.println(x.replaceAll(" $",""))){List<int[]>l=new ArrayList<int[]>();for(x="",i=0,m=s.nextInt();i++<m;)l.add(new int[]{i,0});for(;n-->0;)for(i=0;i++<m;)l.get(i-1)[1]+=s.nextInt()>0?1:0;Collections.sort(l,new Comparator<int[]>(){public int compare(int[]a,int[]b){return b[1]-a[1];}});for(int[]a:l)x+=a[0]+" ";}}}

Measured memory_bytes: 12000
#include <cstdio>
#include <cmath>
#define MAX_N 1000000

int main(){
    bool p[MAX_N+1];    // p[NUM] : NUM is Prime?
    int n;

    for(int i = 0; i <= MAX_N; i++) p[i] = true;

    for(int i = 1; i <= MAX_N; i++){
        if(i == 1) p[i] = false;
        else{
            if(p[i]){
                for(int j = 2; i * j <= MAX_N; j++){
                   p[i*j] = false;
                }
            }
        }
    }
 
    // for(int i = 0; i <= MAX_N; i++) if(p[i]) printf("%d\n",i);
    
    while(scanf("%d", &n) == 1){
        int count = 0;
        for(int i = 1; i <= n; i++){
            if(p[i])count++;
        }
        printf("%d\n", count);
    }
    return 0;
}

Measured memory_bytes: 2000
#include <bits/stdc++.h>
#define ll long long
#define PI 2 * acos(0)
#define FAST ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define MAX 200000
#define MOD 1e7
#define print(a, b) printf("Case %d: %.0f\n", a, b)
#define all(x) (x).begin(), (x).end()
using namespace std;
/*................OMI.................*/

bool isPrime(ll n)
{
   if (n <= 1)
      return false;
   if (n <= 3)
      return true;

   if (n % 2 == 0 || n % 3 == 0)
      return false;

   for (ll i = 5; i * i <= n; i = i + 2)
      if (n % i == 0)
         return false;

   return true;
}
ll gcd(ll a, ll b)
{
   if (a == 0)
      return b;
   return gcd(b % a, a);
}

ll lcm(ll a, ll b)
{
   ll g = gcd(a, b);
   ll ans = (a * b) / g;
   return ans;
}

///palindrome check!
bool palindrome(string s)
{
   for (ll i = 0; i < s.length() / 2; i++)
   {
      if (s[i] != s[s.length() - i - 1])
         return 0;
   }
   return 1;
}
/// divisors->>
void printDivisors(int n)
{
   for (int i = 1; i <= sqrt(n); i++)
   {
      if (n % i == 0)
      {
         if (n / i == i)
            printf("%d ", i);

         else
            printf("%d %d ", i, n / i);
      }
   }
}

///prime storage>>>

vector<ll> prime;

void primes(ll m)
{

   bool isprime[m];
   for (int i = 0; i <= m; i++)
      isprime[i] = true;

   for (int i = 3; i * i <= m; i++)
   {
      if (isprime[i])
      {

         for (int j = i * i; j <= m; j += i)
            isprime[j] = false;
      }
   }
   prime.push_back(2);
   for (int i = 3; i <= m; i += 2)
      if (isprime[i])
         prime.push_back(i);
}

/************MAIN_FUNCTION***********/

int main(int argc, char *argv[])
{
   FAST;

   int n, k;
   cin >> n >> k;

   int ara[n + 2];
   for (int i = 1; i <= n; i++)
      cin >> ara[i];
   int position[MAX] = {0};

   for (int i = 1; i <= k; i++)
   {
      int a, b;
      cin >> a >> b;

      if (ara[a] < ara[b]) /// if obs a is lower than obs b
         position[a] = 1;
      else if (ara[a] > ara[b]) // if obs b is lower than obs a
         position[b] = 1;
      else if (ara[a] == ara[b]) /// if obs a and obs b bith are equal than they both are uncounted
                                 /// because ob1 is said to be good when all the other obs are lower than it
                                 // which  can be accesed by this ob with one road
      {
         position[a] = 1;
         position[b] = 1;
      }
   }

   /// if any obs is not connected to any other obs than it is also good which is not -1
  /// for (int i = 1; i <= n; i++)
    ///  cout << ara[i] << " ";

  /// cout << endl;
   int count = 0;
   for (int i = 1; i <= n; i++)
      if (position[i] == 0)
         count++;

   cout << count << endl;

   return 0;
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> len(n);
  for (int i = 0; i < n; i++) {
    cin >> len.at(i);
  }
  int cnt = 0;
  for (int x = 0; x < n; x++) {
    for (int y = x+1; y < n; y++) {
      for (int z = y+1; z < n; z++) {
        if (len.at(x) + len.at(y) <= len.at(z) ||
            len.at(y) + len.at(z) <= len.at(x) ||
            len.at(z) + len.at(x) <= len.at(y) ||
            len.at(x) == len.at(y) ||
            len.at(y) == len.at(z) ||
            len.at(z) == len.at(x)) {
          continue;
        }
        cnt++;
      }
    }
  }
  cout << cnt << '\n';
  return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<vector>
#include<map>
#include<cmath>
#include<algorithm>
using namespace std;

int N;
vector<int>p,q;
int main(){
    cin>>N;
    vector<int>p(N),q(N);
    for(int i=0;i<N;i++)cin>>p[i],p[i]--;
    for(int i=0;i<N;i++)cin>>q[i],q[i]--;

    map<vector<int>,int>ord;
    int iter=0;
    vector<int> v(N);
    for(int i=0;i<N;i++)v[i]=i;

    do{
        ord[v]=iter++;   
    } while(next_permutation(v.begin(),v.end()));
    
    cout<<abs(ord[p]-ord[q])<<endl;
}


Measured memory_bytes: 5248
#include<stdio.h>
#include <string.h>
int main(void)
{
	char blood_type[2];
	int number,A=0,B=0,O=0,AB=0;

	while (scanf("%d,%s", &number, blood_type) != EOF) {
		if (!(strcmp(blood_type, "A"))) A++;
		if (!(strcmp(blood_type, "B"))) B++;
		if (!(strcmp(blood_type, "O"))) O++;
		if (!(strcmp(blood_type, "AB"))) AB++;
	}

	printf("%d\n",A);
	printf("%d\n", B);
	printf("%d\n", AB);
	printf("%d\n",O);


	return 0;
}

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

int main(){
  int n,p;

  for(;;){
    cin >> n >> p;
    if(n==0 && p==0)break;
    
    int mayor[50] = {0}, id = 0, num = p;

    for(;;){
      if(num){
	mayor[id]++;
	num--;
      }else{
	num += mayor[id];
	mayor[id] = 0;
      }

      if(num==0 && mayor[id] == p){
	cout << id << endl;
	break;
      }
      id = (id+1) % n;
    }
  }
}

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

using State = string::const_iterator;

bool expr(State &itr);
bool clause(State &itr);
int literal(State &itr);

bool expr(State &itr){
    bool res = false;
    while(1){
        itr++;  // '('
        res |= clause(itr);
        itr++;  // ')'
        if(*itr == '|') itr++;
        else break;
    }
    return res;
}

bool clause(State &itr){
    bool exsist[55][2]{};
    while(1){
        int id = literal(itr);
        if(id > 0) exsist[id][0] = true;
        else exsist[-id][1] = true;

        if(*itr == '&') itr++;
        else break;
    }
    bool ok = true;
    for(int i=0;i<55;i++){
        if(exsist[i][0] && exsist[i][1]){
            ok = false;
        }
    }
    return ok;
}

int literal(State &itr){
    bool comp = false;
    if(*itr == '~'){
        comp = true;
        itr++;
    }
    int id;
    if(isupper(*itr)) id = *itr - 'A' +1;
    if(islower(*itr)) id = *itr - 'a' +1+26;
    itr++;
    return id * (comp ? -1 : 1);
}

int main(){
    string s;
    while(cin >> s, s!="#"){
        State begin = s.begin();
        cout << (expr(begin) ? "yes" : "no") << endl;
    }
    return 0;
}



Measured memory_bytes: 3072
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
ll a[N];
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, m, v, p;
    cin >> n >> m >> v >> p;
    for (ll i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a + n, greater<ll>());
    ll ans = p, i, s = a[p - 1], c = 1;
    for (i = p; i < n; i++, c++)
    {
        if (a[i] + m >= a[p - 1] && (a[i] + m) * c - s >= m * max(0L, (c - n + v)))
            ans++, s += a[i];
        else
            break;
    }
    for (; i < n; i++)
        if (a[i] == a[i - 1])
            ans++;
        else
            break;
    cout << ans;
    return 0;
}

Measured memory_bytes: 1024
#include<bits//stdc++.h>
using namespace std;
int main(){
    int a;
    cin>>a;
    int sum=0;
    int b[a];
    for(int i=0;i<a;i++){
        cin>>b[i];
    }
    sort(b,b+a);
    for(int l=0;l<a;l++){
        sum+=b[l];
    }
    cout<<sum-b[a-1]/2<<endl;
}


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

ans = []


l = [i for i in range(1, 10)]
ans.extend(l)

while len(ans) <= 110000:
    n = []
    cnt = 0
    for x in l:
        y = x * 10
        b = x % 10
        if b == 0:
            n.append(y)
            n.append(y+1)
        elif b == 9:
            n.append(y+b-1)
            n.append(y+b)
        else:
            n.append(y+b-1)
            n.append(y+b)
            n.append(y+b+1)
    l = n[:]
    ans.extend(l)

print(ans[k-1])


Measured memory_bytes: 14332
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    String str = sc.nextLine();
    char[] c = str.toCharArray();
    for(int i = 0; i < str.length(); i++){
      c[i] += N;
      if(c[i] > 'Z'){
        c[i] -= 26;
      }
    }
    System.out.println(new String(c));
  }
}
    
    

Measured memory_bytes: 23892
import java.util.*;

/**
 * Created on 2016/08/21.
 */
public class Main {

    final static int NUM = (int)(1e5 + 2);

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

        int N = sc.nextInt();
        HashMap<Integer, Integer> map = new HashMap<>();

        PriorityQueue<Integer> nums = new PriorityQueue<>();

        for(int i=0; i<N; i++){
            int tmp = sc.nextInt();
            nums.add(tmp);
            map.put(tmp, i);
        }

        int bin = 0;

        int diff = 0;

        while(!nums.isEmpty()){
            int num = nums.poll();
            int idx = map.get(num);

            if((bin%2) != (idx%2)){
                diff++;
            }

            //
            bin++;
            bin %= 2;
        }


        int ans = (diff / 2);

        System.out.println(ans);
    }
}


Measured memory_bytes: 35284
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var input = Console.ReadLine().Split(" ").Select(int.Parse).ToArray();
        var N = input[0];
        var Y = input[1];

        int x10000 = -1, y5000 = -1, z1000 = -1;
        for(var x = 0; x <= N; x++)
        {
            for (var y = 0; y + x <= N; y++)
            {
                var z = N - x - y;
                var total = 10000 * x + 5000 * y + 1000 * z;
                if (Y == total)
                {
                    x10000 = x;
                    y5000 = y;
                    z1000 = z;
                }
            }
        }
        
        Console.WriteLine($"{x10000} {y5000} {z1000}");
    }
}


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

using namespace std;

int main()
{
   int a,b,c,k,sum=0;
   cin>>a>>b>>c>>k;
       if(k){
        sum+=min(a,k);
        k-=min(a,k);
       }
        if(k)
        k-=min(b,k);
       if(k)
           sum-=min(c,k);


   cout<<sum;
}


Measured memory_bytes: 3592
#include "bits/stdc++.h"
#include <fstream>

typedef long long int ll;
using namespace std;

int main()
{

    //freopen("14","r",stdin);
    //freopen("sparse.out","w",stdout);
    int n;
    scanf("%d",&n);
    char a[2][n];
    scanf("%s",a[0]);
    scanf("%s",a[1]);
    ll ans = 1;
    for(int i=0;i<n;i++){
        if(a[0][i]==a[1][i]){
            if(i==0)ans*=3;
            else if(a[0][i-1]==a[1][i-1]){
                ans*=2;
            }
        }else{
            if(i==0){
                ans*=6;
            }else{
                if(a[0][i-1]==a[1][i-1]){
                    ans*=2;
                }else{
                    ans*=3;
                }
            }
            i++;
        }
        ans%=1000000007;
    }
    printf("%lld",ans);
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  int a, b, c;
  a = n % 10;
  b = (n / 10) % 10;
  c = (n / 100) % 10;
  if(a == 7 || b == 7 || c == 7) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

vector<int> c;
vector<ll> ans,sz,chi;
vector<vector<int>> edges;

void dfs(int i,int p = -1) {
    ll x = sz[c[i]];
    for (int j : edges[i]) if (j != p) {
        ll y = sz[c[i]];
        dfs(j,i);
        y += chi[j]-sz[c[i]];
        ans[c[i]] -= y*(y+1)/2;
        chi[i] += chi[j];
    }
    sz[c[i]] = x+chi[i];
}

int main() {
    ll n;
    cin >> n;
    c.resize(n);
    ans.resize(n,n*(n+1)/2);
    sz.resize(n,0);
    chi.resize(n,1);
    edges.resize(n);
    for (int i = 0;i < n;++i) cin >> c[i],c[i]--;
    for (int i = 0;i < n-1;++i) {
        int u,v;
        scanf("%d%d",&u,&v);
        u--;v--;
        edges[u].push_back(v);
        edges[v].push_back(u);
    }
    dfs(0);
    for (int i = 0;i < n;++i) {
        ll x = n-sz[i];
        ans[i] -= x*(x+1)/2;
    }
    for (int i = 0;i < n;++i) cout << ans[i] << newl;
}

Measured memory_bytes: 38272
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int gcd(int a, int b)
{
	if (a == 0)return b;
	if (b == 0)return a;
	for (;;)
	{
		if (a < b)swap(a, b);
		a %= b;
		if (a == 0)return b;
	}
}
int main()
{
	int num, mok;
	scanf("%d%d", &num, &mok);
	int maxi = 0;
	int g = 0;
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		g = gcd(g, z);
		maxi = max(maxi, z);
	}
	if (mok%g != 0 || maxi < mok)printf("IM");
	printf("POSSIBLE\n");
}

Measured memory_bytes: 128
n,k = map(int,input().split())
a_list = list(map(int,input().split()))

used_dict = {}
used_list = []

current_node = 0

while True:
    if current_node not in used_dict:
        used_dict[current_node] = True
        used_list.append(current_node)
        current_node = a_list[current_node]-1
    else:
        break

repeat_index = used_list.index(current_node)
repeat_list = used_list[repeat_index:]
repeat_length = len(used_list) - repeat_index

if k > repeat_index:
    amari = (k-repeat_index) % repeat_length
    print(repeat_list[amari]+1)
else:
    print(used_list[k]+1)


Measured memory_bytes: 38916
#include <bits/stdc++.h>
#define REP(asd, fgh) for(int asd = 0; asd < fgh; asd++)
using namespace std;

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

  int N, M;
  cin >> N >> M;
  vector<int> white(N+1, 0), blue(N+1, 0), red(N+1, 0);
  REP(i, N){
    REP(j, M){
      char c; cin >> c;
      if(c != 'W'){
        white[i+1]++;
      }
      if(c != 'B'){
        blue[i+1]++;
      }
      if(c != 'R'){
        red[i+1]++;
      }
    }
  }
  for(int i = 1; i < N+1; i++){
    white[i] += white[i-1];
    blue[i] += blue[i-1];
    red[i] += red[i-1];
  }

  int ans = INT_MAX/2;
  for(int w = 1; w <= N-2; w++){
    for(int b = w+1; b <= N-1; b++){
      ans = min(ans, white[w] - white[0] +
                     blue[b] - blue[w] +
                     red[N] - red[b]
               );
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1196
package main

import(
	"os"
	"io"
	"bufio"
	"bytes"
	"fmt"
)

//  長い入力を読む
func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()
			// fmt.Printf("Reader.Read: %d\n", len(readBuf))
			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}
			// end of line
			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()
				// reader = bufio.NewReader(os.Stdin)
				break
			}
		}
	}
	// 先読みしてしまうようなので、戻しておく
	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}

func solve(change int64) int64 {
	n := int64(0)
	for {
		remained := change - 25
		if remained < 0 {
			break
		} else {
			n++
			change = remained
		}
	}
	for {
		remained := change - 10
		if remained < 0 {
			break
		} else {
			n++
			change = remained
		}
	}
	for {
		remained := change - 5
		if remained < 0 {
			break
		} else {
			n++
			change = remained
		}
	}
	for {
		remained := change - 1
		if remained < 0 {
			break
		} else {
			n++
			change = remained
		}
	}
	return n
}

func main() {
	var change int64
	fmt.Scanf("%d", &change)

	fmt.Printf("%d\n", solve(change))
}


Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
 
/* REPmacro */
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define REPR(i,n) for(int i=((int)(n)-1);i>=0;--i)
#define FOR(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
 
/*alias*/
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair 
 
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define itn int
 
/*using*/
using ll = long long;
using ull = unsigned long long;
using unsi = unsigned;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using db = double;
using plex = complex<double>;
using vs = vector<string>;
 
/*template*/
template<class T>inline bool amax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>inline bool amin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
 
/* func */
 
/*struct*/
struct aaa {
	aaa() {
		cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(20);
	};
}aaaaaaa;
 
/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7; //10^9
const db EPS = 1e-9;
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }, dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
//Counterclockwise from the 9o'clock direction
//Take the x-axis downward and the y-axis right
 
//#define int ll
//#define int long long
 
signed main()
{
  array<array<int,3>,3>  z{};
  
  REP(i,3){
    REP(j,3)cin >> z[i][j];
  }
  
  int a = z[0][0],b = z[0][1],c = z[0][2],
      d = z[1][0],e = z[1][1],f = z[1][2],
      g = z[2][0],h = z[2][1],i = z[2][2];
  
  if(a+e == b+d && b+f == c+e && d+h == e+g && e+i == f+h)
    cout << "Yes";
  else
    cout << "No";
  
  return 0;
}

/*
a+e = b+d;
b+f = c+e;
d+h = e+g;
e+i = f+h;
_____________
| a | b | c |
| d | e | f |
| g | h | i |
-------------
*/

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

namespace ABC085A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;

            s = Console.ReadLine();

            char[] cs = s.ToCharArray();

            cs[3] = '8';

            Console.WriteLine(cs);

            Console.ReadKey();


        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int N,S=0;cin>>N;
  long long int A[N],B[N],C[N];
  for(int i=0;i<N;i++){cin>>A[i];B[i]=0;}
  for(int i=0;i<N;i++)B[A[i]-1]++;
  for(int i=0;i<N;i++){C[i]=B[i]*(B[i]-1)/2;S+=C[i];}
  for(int i=0;i<N;i++)cout<<S-B[A[i]-1]+1<<endl;
}

Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
int main() {
    int R,G,B,N;
    cin >> R >> G >> B >> N;
    int v[3] = {R,G,B};
    vector<vector<int>> dp(3,vector<int>(N+1));
    dp[0][0] = 1;
    for (int k=0;k<3;k++) {
        for (int i=0;i<=N;i++) {
            if (k>0) dp[k][i] = dp[k-1][i];
            if (i-v[k]>=0) dp[k][i] += dp[k][i-v[k]];
        }
    }
    cout << dp[2][N] << '\n';
    return 0;
}

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

using namespace std;

int main()
{
	int card[2][200],n,m,k,c;
	bool swit;

	scanf("%d",&n);
	scanf("%d",&m);
	
	for(int i = 0; i < n*2; i++){
		card[0][i] = i+1;
	}
	
	swit = 0;
	for(int i = 0; i < m; i++){
		scanf("%d",&k);
		if(k == 0){
			c  = 0;
			for(int j = 0; j < 2*n; j+=2){
				card[!swit][j] = card[swit][c];
				c++;
			}
			for(int j = 1; j < 2*n; j+=2){
				card[!swit][j] = card[swit][c];
				c++;
			}
		}
		else{
			int j;
			c = k;
			for(j = 0; c < 2*n ; j++){
				card[!swit][j] = card[swit][c];
				c++;
			}
			c = 0;
			for(; j < 2*n ; j++){
				card[!swit][j] = card[swit][c];
				c++;
			}
		}
		swit = !swit;
	}

	for(int i = 0; i < 2*n; i++){
		printf("%d\n",card[swit][i]);
	}

	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
#include <map>
#include <queue>
#include <set>
#include <stack>
using namespace std;
#define rep(i, m, n) for (int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for (int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
using Edge = pair<int, long long>;
using Graph = vector<vector<Edge>>;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef vector<vector<vector<ll>>> mat3;
typedef vector<string> svec;
typedef vector<vector<string>> smat;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll)1e9 + 7;
// constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
template <class T> bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
// ~~~~~~~~~~~~~~memo~~~~~~~~~~~~~~
// for (int i = 0; i < n; ++i)
// vector<long long> v(n), c(n);
// cout << res << endl;
// cout << res << '\n';
// int型の2次元配列(h×w要素の)の宣言
// vector<vector<int>> data(h, vector<int>(w));
// rotate(s.begin(), s.begin() + 1, s.end());
// sort(all(a),greater<int>());
// s.substr(0,2) 先頭から2文字切り出す
// for (auto it = mp.rbegin();it != mp.rend(); ++it)

struct UnionFind {
    vector<int> par, w;

    UnionFind(int n) : par(n, -1), w(n, 0) {}
    void init(int n) {
        par.assign(n, -1);
        w.assign(n, 0);
    }

    int root(int x) {
        if (par[x] < 0)
            return x;
        else
            return par[x] = root(par[x]);
    }

    bool issame(int x, int y) { return root(x) == root(y); }

    bool merge(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) {
            ++w[x];
            return false;
        }
        if (par[x] > par[y]) swap(x, y);  // merge technique
        par[x] += par[y];
        par[y] = x;
        w[x] += w[y];
        ++w[x];
        return true;
    }

    int size(int x) { return -par[root(x)]; }

    int wei(int x) { return w[root(x)]; }
};

int main() {
    int N,M,K;
    cin >> N >> M >> K;
    UnionFind uf(N);
    vector<vector<int>> ab(N);
    rep(i,0,M) {
        int a,b;
        cin >> a >> b;
        a--;b--;
        ab[a].push_back(b);
        ab[b].push_back(a);
        uf.merge(a,b);
    }
    vector<vector<int>> cd(N);
    rep(i,0,K) {
        int c,d;
        cin >> c >> d;
        c--;d--;
        cd[c].push_back(d);
        cd[d].push_back(c);
    } 
    rep(i,0,N) {
        int res = uf.size(i);
        res -= ab[i].size();
        for (int nx: cd[i]) {
            if (uf.issame(nx,i)) {
                res--;
            }
        }
        res--;
        cout << res << (i != N-1 ? " " : "\n");
    }
    
    return 0;
}


Measured memory_bytes: 15044
#include <bits/stdc++.h>
#define sz(c)       int(c.size())
#define rep(i,a,b)  for (int i=a; i<(b); ++i)
#define per(i,a,b)  for (int i=(b)-1; i>=(a); --i)
#define fore(c,...) for (auto __VA_ARGS__:(c))
using namespace std;
typedef long long ll;



int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	double L;
	cin>>L;
	cout<<(L/3)*(L/3)*(L/3)<<'\n';
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    static final int MAX = 300000;
    boolean[] T;
    int[] L;

    void solve(){
        int N, Q, q, x;
        T = new boolean[MAX+1];
        L = new int[MAX+1];

        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        Q = sc.nextInt();

        for ( int i = 0; i < N; i++ ) {
            x = sc.nextInt();
            T[x] = true;
        }

        int m = 0;
        for ( int i = 1; i <= MAX; i++ ){
            L[i] = m;
            if ( T[i] ) m = i;
        }

        for ( int i = 0; i < Q; i++ ){
            q = sc.nextInt();
            int maxv = 0;
            int cur = m;
            while(cur > 0){
                int p = cur%q;
                maxv = Math.max(maxv, p);
                if ( cur - p < 0 ) break;
                cur = L[cur - p];
            }
            System.out.println(maxv);
        }
    }

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




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

constexpr int inf = 1e9;

struct edge {
    int to, cost;
};

using graph = vector<vector<edge>>;

void add_edge(graph& g, int from, int to, int w) {
    g[from].push_back(edge{to, w});
}

int read_number(string const& s, int& p) {
    int res = 0;
    while(p < (int)s.size() && isdigit(s[p])) {
        res = res * 10 + (s[p++] - '0');
    }
    return res;
}

int main() {
    int n, c; cin >> n >> c;
    vector<int> a(c), b(c), d(c), arbs;
    vector<char> o(c), s(c);
    for(int i = 0; i < c; ++i) {
        string cons; cin >> cons;
        int p = 0;
        a[i] = read_number(cons, p) - 1;
        if(cons[p] == '*') arbs.push_back(i);
        o[i] = cons[p];
        p += (cons[p] == '*' ? 1 : 2); // '*' or '<='
        b[i] = read_number(cons, p) - 1;
        s[i] = cons[p++];
        d[i] = read_number(cons, p);
    }

    int ans = -1;
    const int m = (int)arbs.size();
    for(int S = 0; S < (1 << m); ++S) {
        for(int i = 0; i < m; ++i) {
            o[arbs[i]] = (S & (1 << i)) ? '<' : '>';
        }
        graph g(n);
        for(int i = 0; i < c; ++i) {
            if(o[i] == '<') {
                if(s[i] == '+') {
                    add_edge(g, b[i], a[i], -d[i]);
                } else {
                    add_edge(g, a[i], b[i], d[i]);
                    add_edge(g, b[i], a[i], 0);
                }
            } else if(o[i] == '>') {
                if(s[i] == '+') {
                    add_edge(g, a[i], b[i], -d[i]);
                } else {
                    add_edge(g, b[i], a[i], d[i]);
                    add_edge(g, a[i], b[i], 0);
                }
            }
        }
        for(int i = 1; i < n; ++i) add_edge(g, i, 0, 0); // 0 is first

        int last_update = -1;
        vector<int> dist(n, inf);
        dist[0] = 0;
        for(int lp = 0; lp < n; ++lp) {
            for(int v = 0; v < n; ++v) {
                for(auto& e : g[v]) {
                    if(dist[e.to] > dist[v] + e.cost) {
                        last_update = lp;
                        dist[e.to] = dist[v] + e.cost;
                    }
                }
            }
        }
        if(last_update != n - 1) {
            ans = max(ans, *max_element(begin(dist), end(dist)));
        }
    }

    if(ans == inf) cout << "inf" << endl;
    else           cout << ans << endl;
}



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

#define what_is(x)    cerr<<#x<<" is "<<x<<"\n";
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int solve(){
    cin>>n;
    rep(i,1,n){
        int t=0,x=i;
        while(x){
            t++;
            x/=10;
        }
        if(t%2) ans++;
    }
    cout<<ans;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define all(v) v.begin(),v.end()
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl 

const int N = 1e5+5;
const ll mod = 1e9+7;
int n , m;
ll dp[N];
set <int> s;

ll calc (int idx){

    if (idx > n)
        return 0;

    if (idx == n)
        return 1;

    if (~dp[idx])
        return dp[idx];

    dp[idx] = 0;
    if (!s.count(idx+1))
        dp[idx] += calc(idx+1);
    dp[idx] %= mod;
    if (!s.count(idx+2))
        dp[idx] += calc(idx+2);
    dp[idx] %= mod;

    return dp[idx];
}

void Suhaib_Sawalha (){

    cin >> n >> m;
    for (int i = 0 , a ; i < m ; ++i){
        cin >> a;
        s.insert(a);
    }

    memset(dp,-1,sizeof dp);
    cout << calc(0);

}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<'\n')
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}

Measured memory_bytes: 9008
n, k = map(int, input().split())
positions = [int(i) for i in input().split()]
scores = [int(i) for i in input().split()]
if max(scores) <= 0:
  print(max(scores))
else:
  positions = [0] + positions
  scores = [0] + scores
  max_point = -pow(10, 9)
  #print(max_point)
  for i in range(1, n + 1):
    s = []
    f_pos = positions[i]
    score = scores[f_pos]
    s.append(score)
    while f_pos != i:
      f_pos = positions[f_pos]
      score += scores[f_pos]
      s.append(score)
    loop = len(s)
    if loop >= k:
      point = max(s[:k])
    elif s[-1] <= 0:
      point = max(s)
    else:
      loop_c = k // loop
      r = k % loop
      point1 = s[-1] * loop_c
      if r != 0:
        point1 += max(s[:r])
      point2 = s[-1] * (loop_c - 1)
      point2 += max(0, max(s))
      point = max(point1, point2)
    max_point = max(max_point, point)
  print(max_point)


Measured memory_bytes: 81792
#include<iostream>
#include<vector>
#include<set>

using namespace std;

int n;
vector<int> a;
set<int> st;

int main(){
    cin >> n;

    a.resize(n);
    for(int i = 0 ; i < n ; ++i){
        cin >> a[i];
    }

    for(int bit = 0 ; bit < (1 << n) ; ++bit){
        int val = 0;
        for(int i = 0 ; i < n ; ++i){
            if(bit >> i & 1){
                val += a[i];
            }
        }
        st.insert(val);
    }

    int q;
    cin >> q;

    while(q--){
        int m;
        cin >> m;
        if(st.count(m)){
            cout << "yes\n";
        }else{
            cout << "no\n";
        }
    }

    return 0;
}


Measured memory_bytes: 3124
h,w=map(int,input().split())
if h==1 or w==1:
  print(1)
  exit()
w-=1
even=int(w/2)+1
odd=int((w+1)/2)
if h%2==0:
  print( (even+odd)*h//2 )
else:
  print( (even+odd)*(h-1)//2 + even )

Measured memory_bytes: 3060
n,m = map(int, input().split())
k_a  = [ [] for i in range(n)]
for i in range(n):
    k_a[i] = list(map(int, input().split()))
count = 0
for i in range(51):
    flag = True
    for j in range(n):
        if(i not in k_a[j][1:]):
            flag = False
    if(flag):
        count += 1
print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> w(1,1), dp(131072,n);
  for(int i = 1; i <= n; i *= 6) w.push_back(i);
  for(int i = 1; i <= n; i *= 9) w.push_back(i);
  dp[0]=0;
  for(auto x: w) for(int i = 0; i <= n-x; ++i) dp[i+x] = min(dp[i+x], dp[i]+1);
  cout << dp[n] << endl;
  return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define PI acos(-1)
#define EPS 1e-5
#define sz(v) ((int)(v).size())
#define all(v) v.begin(),v.end()
#define forn(i, n) for(ll i=0;i<(ll)n;i++)
#define fi first
#define se second

const int mod = 1e9+7;

void add_self(int& a, int b){
	a += b;
	if(a >= mod)
		a -= mod;
}

int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<char>> p(h, vector<char>(w));
	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j++)
			cin >> p[i][j];
	vector<vector<int>> dp(h, vector<int>(w, 0));
	dp[0][0] = 1;
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			for(int r2 : {i, i+1}){
				int c2 = j;
				if(r2 == i)
					c2 = j+1;
				if(r2 < h && c2 < w && p[r2][c2] == '.')
					add_self(dp[r2][c2],dp[i][j]);
			}
		}
	}
	cout << dp[h-1][w-1] << endl;
	return 0;

}



Measured memory_bytes: 5248
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        String res = a + b + c <= 21 ? "win" : "bust";
        System.out.println(res);
    }
}


Measured memory_bytes: 24916
open System

// input
let readStr () = stdin.ReadLine()

let readInt () = stdin.ReadLine() |> int
let readInts () = stdin.ReadLine().Split() |> Array.map int

// utils

let pair = function
| [|a; b|] -> (a, b)
| _ -> failwith "owatta"

let triple = function
| [|a; b; c|] -> (a, b, c)
| _ -> failwith "owatta"

let flip f a b = f b a  

module Option =
  let getOr defaultValue = function
  | Some x -> x
  | None -> defaultValue

let (A, B) = readInts () |> pair

let tax per yen = yen * per / 100

seq { 1..10007 }
|> Seq.tryFind (fun y -> tax 8 y = A && tax 10 y = B)
|> Option.getOr -1
|> printfn "%d"

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

int main() {
  long long N, K, Q;
  cin >> N >> K >> Q;
  
  vector<string> result(N, "Yes");
  vector<long long> point(N);

  if (K - Q > 0) {
    for (int i = 0; i < N; i++) {
      result.at(i) = "Yes";
    }
  }
  else {
    int corr;
    for (int i = 0; i < Q; i++) {
      cin >> corr;
      point.at(corr - 1)++;
    }
    for (int i = 0; i < N; i++) {
      if (point.at(i) > Q - K)
	    result.at(i) = "Yes";
      else
        result.at(i) = "No";
    }    
  }
  
  for (int i = 0; i < N; i++) {
    cout << result.at(i) << endl;
  }
}

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

using namespace std;

typedef pair<int,int> P;
int depth[100005];
int ans[100005];
vector<int> pa[100005];


int dfs(int v) {
  if(depth[v] != -1) return depth[v];
  
  vector<P> tmp;

  for(int i = 0; i < pa[v].size(); i++) {
    tmp.push_back(P(dfs(pa[v][i]),pa[v][i]));   
  }
  sort(tmp.begin(),tmp.end());
  ans[v] = tmp.back().second;
  
  return depth[v] = tmp.back().first + 1;
}
  
  

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

  for(int i = 0; i < n+m-1; i++) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    pa[b].push_back(a);
  }
  for(int i = 0; i < n; i++) depth[i] = -1;

  for(int i = 0; i < n; i++) {
    if(pa[i].size() == 0) {
      ans[i] = -1;
      depth[i] = 0;
    }
    else if(pa[i].size() == 1) {
      if(depth[pa[i][0]] != -1) {
	depth[i] = depth[pa[i][0]] + 1;
	ans[i] = pa[i][0];
      }
    }
  }

  for(int i = 0; i < n; i++) {
    if(depth[i] == -1) {
      dfs(i);
    }
  }

  for(int i = 0; i < n; i++) cout << ans[i] + 1 << endl;
}


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

const int INF = 10000001;  

int N;
int A[210];        

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

  int res = INF;

  for (int i = 0; i < N; ++i) {
    int count = 0;  

    while (A[i] % 2 == 0) {
      A[i] /= 2;
      ++count;
    }

    if (res > count) res = count;
  }

  cout << res << endl;
}

Measured memory_bytes: 256
n, a, b, c = map(int,input().split())
l = []
for i in range(n):
    l.append(int(input()))
ans = 10**9    
for ci in range(4**n):
    ci_ = [-1] * n
    cnt = [0] * 3
    ca, cb, cc = 0, 0, 0
    for cj in range(n):
        cx = ci & 3
        if cx == 0:
            ca += l[cj]
            cnt[0] += 1 
        elif cx == 1:
            cb += l[cj]
            cnt[1] += 1 
        elif cx == 2:
            cc += l[cj]
            cnt[2] += 1 
        ci >>= 2
    if ca == 0 or cb == 0 or cc == 0:
        continue
    
    cost = 0
    for i in range(3):
        if cnt[i] > 1:
            cost += 10 * (cnt[i]-1)
    cost += abs(a-ca) + abs(b-cb) + abs(c-cc)
    ans = min(ans, cost)
print(ans)

Measured memory_bytes: 9260
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	string S, T; cin >> S >> T;
	sort(S.begin(), S.end());
	sort(T.begin(), T.end()); reverse(T.begin(), T.end());

	int i = 0;
	while(S[i] == T[i] and i < S.size() and i < T.size()) ++i, cerr << S[i] << ' ' << T[i] << endl;

	cout << (S[i] < T[i] ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
int W,H;
string c[80];
string dp[80][80]={};
string Num(int h,int w){
    if(dp[h][w]!=""){
        return dp[h][w];
    }
    if(isalpha(c[h][w])){
        return "";
    }
    if(h+1==H && w+1==W)
    {
        dp[h][w]=c[h][w];
        return dp[h][w];
    }
    string s1="",s2="";
    if(h+1<H){
        s1=Num(h+1,w);
    }
    if(w+1<W){
        s2=Num(h,w+1);
    }
    if(s1.length()<s2.length()){
        return dp[h][w]=c[h][w]+s2;
    }else if(s1.length()>s2.length()){
        return dp[h][w]=c[h][w]+s1;
    }else{
        return dp[h][w]=c[h][w]+max(s1,s2);
    }
}

int main(){
    while(cin>>W>>H,W!=0){
        for(int i=0;i<H;i++){
            cin>>c[i];
            for(int j=0;j<W;j++){
                dp[i][j]="";
            }
        }
        string ans="";
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                if(c[i][j]!='0'){
                    string tmp=Num(i,j);
                    if(ans.length()<tmp.length()){
                        ans=tmp;
                    }else if(ans.length()==tmp.length()){
                        ans=max(ans,tmp);
                    }
                }
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3324
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <numeric>
#include <climits>
#include <math.h>
#include <memory.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;
int N, M;
int cnt = 0;
int ans = 0;
int i_index;
int tmp;
int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};
string board[64];
int main(){
    int K;
    cin >> N >> K;
    cnt = N;
    int A[300000] = {0};
    int maxv = 0;
    rep(i, N){
        cin >> A[i];
        maxv = max(maxv, A[i]);
    }
    rep(i, N){
        if(A[i] == K){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    if(K > maxv)
        cout << "IMPOSSIBLE" << endl;
    else{
        sort(A, A + N);
        rep(i, N - 1){
            tmp = abs(A[i] - A[i + 1]);
            if(tmp != 0){
                if(tmp == 1 || K % tmp == 0){
                    cout << "POSSIBLE" << endl;
                    return 0;
                }
            }
        }
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 1408