akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
int digit(ll n) {
  int res = 0;
  while(n) {
    n /= 10;
    res++;
  }
  return res;
}
void update(ll a, ll b, ll p, ll val, vector<ll> &v, vector<ll> &su) {
  int d = digit(val);
  int mad = digit(b);
  ll l = val, r = 1;
  for(int i=0;i<d;++i) {
    r *= 10;
  }
  for(int i=d;i<=mad;++i) {
    if(i == d) {
      ll tmpl = min(b+3, l+1);
      ll tmpr = min(b+3, r);
      v[val-a] += su[tmpl-a] + p - su[tmpr-a];
      v[val-a] %= p;
    } else {
      ll tmpl = min(b+3, l);
      ll tmpr = min(b+3, r);
      v[val-a] += su[tmpl-a] + p - su[tmpr-a];
      v[val-a] %= p;
    }
    l *= 10;
    r *= 10;
  }
  v[val-a]++;
  su[val-a] = (su[val-a+1] + v[val-a]) % p;
}
bool solve() {
  ll a, b, p; cin >> a >> b >> p;
  if(a == 0) return false;
  vector<ll> v(b-a+10);
  vector<ll> su(b-a+10);
  su[b-a] = 1;
  for(ll val=b-1;val>=a;--val) {
    update(a, b, p, val, v, su);
  }
  cout << su[0] % p << endl;
  return true;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    if(!solve()) break;
  }
}



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

using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a>b)
    {
        if(a>c) cout<<b+c<<endl;
        else    cout<<b+a<<endl;
    }
    else
    {
        if(b>c) cout<<a+c<<endl;
        else    cout<<b+a<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* 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 */
vector<ll> sieve_of_eratosthenes(ll n) {
    vector<ll> primes(n, 2);
    primes[1] = 1;
    for (ll i = 2; i+i < n; ++i)
        for (ll j = i+i; j < n; j+=i)
            primes[j]++;
    return primes;
}
/* main */
int main(){
    ll N;
    cin >> N;
    vector<ll> p = sieve_of_eratosthenes(N + 1);
    ll ans = 0;
    for (int i = 1; i <= N; i++) ans += i * p[i];
    cout << ans << '\n';
}


Measured memory_bytes: 81396
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 2e5 + 5;

int n;
ll k;
ll a[N], f[N];

bool valid(ll t) {
	ll need = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] * f[i] > t) {
			ll dif = a[i] * f[i] - t;
			need += (dif + f[i] - 1) / f[i];
		}
	}
	return need <= k;
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	for (int i = 0; i < n; i++)
		cin >> f[i];
	sort(a, a + n);
	sort(f, f + n, [&](int x, int y) {
		return x > y;
	});
	ll st = 0, en = 1e12;
	while (st < en) {
		ll mid = st + (en - st) / 2;
		if (valid(mid))
			en = mid;
		else
			st = mid + 1;
	}
	cout << st << endl;
	return 0;
}


Measured memory_bytes: 3456
package main

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

var sc = bufio.NewScanner(os.Stdin)

func rcv() []byte {
	sc.Scan()
	return sc.Bytes()
}

func b2i(a []byte) (n int) {
	for _, v := range a {
		n = n*10 + int(v-48)
	}
	return
}

func max(a []int) (x int) {
	x = -int(^uint(0)>>1) - 1
	for _, i := range a {
		if i > x {
			x = i
		}
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n, s := b2i(rcv()), rcv()

	dup := make(map[byte][]int, 26)
	for i, v := range s {
		dup[v] = append(dup[v], i)
	}

	bk := make([]int, n)
	var x, y int
	for _, v := range dup {
		if len(v) == 1 {
			continue
		}
		x, y = 101, 0
		for _, w := range v {
			if x > w {
				x = w
			} else if y < w {
				y = w
			}
		}
		for i := x; i <= y; i++ {
			bk[i]++
		}
	}
	fmt.Println(max(bk))
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //e
  string s;
  cin >> s;
  int k;
  cin >> k;
  int n = (int) s.size();
  long long dp[110][2][5] = {};
  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    int x = s[i] - '0';
    for (int j = 0; j <= k; j++) for (int d = 0; d < 10; d++) {
      if (d < x) {
        if (d == 0) {
          dp[i + 1][1][j] += dp[i][1][j];
          dp[i + 1][1][j] += dp[i][0][j];
        } else if (j < k) {
          dp[i + 1][1][j + 1] += dp[i][1][j];
          dp[i + 1][1][j + 1] += dp[i][0][j];
        }
      } else if (d == x) {
        if (d == 0) {
          dp[i + 1][1][j] += dp[i][1][j];
          dp[i + 1][0][j] += dp[i][0][j];
        } else if (j < k) {
          dp[i + 1][1][j + 1] += dp[i][1][j];
          dp[i + 1][0][j + 1] += dp[i][0][j];
        }
      } else {
        if (d == 0) {
          dp[i + 1][1][j] += dp[i + 1][1][j];
        } else if (j < k) {
          dp[i + 1][1][j + 1] += dp[i][1][j];
        }
      }
    }
  }
  cout << dp[n][0][k] + dp[n][1][k] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
   int main()
{
    string s;
    cin>>s;
    bool t=true;
    int n=s.size()-2;
    while(true){
            t=true;
        for(int i=0,j=n/2;i<n/2,j<n;i++,j++)
            if(s[i]!=s[j])
            t=false;
    if(t==false)
        n-=2;
    else {cout<<n;
        break;
    }
    }
    return 0;
   }

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

int main(){
  int a, b, c, k, max;
  cin >> a >> b >> c >> k;
  if(k<=a){
    max=k;
  }
  else{
    if(k<=b){
      max=a;
    }
    else{
      max=a-(k-a-b);
    }
  }

  cout << max << endl;

  return 0;
}

Measured memory_bytes: 3556
#include <iostream>
using namespace std;
  
int main() {
   int m, f, b;
   cin >> m >> f >> b;

   if ( m >= b ) {
   cout << 0 << endl;
  
   }else if ( m + f >= b ) {
   cout << b - m << endl;
  }
   else 
   cout << "NA" << endl;
}



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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> v(n);
    for (auto &a : v) {
        cin >> a;
    }
    for (auto it = v.rbegin(); it != v.rend(); ++it) {
        cout << *it << ((it + 1 == v.rend())? '\n': ' ');
    }
    
    return 0;
}



Measured memory_bytes: 3088
fn read<T: std::str::FromStr>() -> T {
    let mut s  = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main(){
    let a : i32 = read();
    println!("{}", a*a*a 
    );
}


Measured memory_bytes: 5020
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
const int inf = 1001001001;

int main(){
  int n,m;
  cin >> n >> m;
  vector<ll> a(n), b(m), c(m);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());

  rep(i,m) cin >> b[i] >> c[i];

  vector<int> id(m);
  iota(id.begin(), id.end(),0);
  sort(id.begin(),id.end(),[&](int i, int j){
                             return c[i]>c[j];});

  ll sum = 0;
  ll k = 0;
  for(auto i : id){
    for(int j = 0; j < b[i]; j++){
      if(k >= n) break;
      sum += max(a[k++], c[i]);
    }
  }
  for(int i = k; i < n; i++) sum += a[i];
  cout << sum << endl;
}


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

int main()
{
    int order[5];
    int r[5];
    int min_r = 10;
    int min_index = 0;
    
    for(int i = 0; i < 5; i++)
    {
        cin >> order[i];
        r[i] = order[i] % 10;
        if (r[i] < min_r && r[i] != 0)
        {
            min_r = r[i];
            min_index = i;
        }
    }
    
    int ans = 0;
    for(int i = 0; i < 5; i++)
    {
        if (i == min_index || r[i] == 0) {
            ans += order[i];
        } else {
            ans += order[i] + 10 - r[i];
        }
    }

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

Measured memory_bytes: 256
import sys
from math import gcd


def osa_k(sieve, MAXN):
    p = 2
    while p * p <= MAXN:
        # まだチェックされていないなら
        if sieve[p] == p:
            # 次のqの倍数からp刻みでチェック入れていく
            for q in range(2 * p, MAXN + 1, p):
                if sieve[q] == q:
                    sieve[q] = p
        p += 1


input = lambda: sys.stdin.readline().rstrip()
n = int(input())
A = list(map(int, input().split()))
nowgcd = A[0]
# 全体のGCDを取る
for i in A:
    nowgcd = gcd(nowgcd, i)
if nowgcd != 1:
    print('not coprime')
    exit()

MAXN = 10**6 + 5
sieve = [i for i in range(MAXN + 1)]
p = 2
osa_k(sieve, MAXN)

check = set()
for a in A:
    tmp = set()
    while (a > 1):
        tmp.add(sieve[a])
        a //= sieve[a]
    for p in tmp:
        if p in check:
            print('setwise coprime')
            exit()
        check.add(p)
print('pairwise coprime')


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

int main(){
    ll N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    ll M = min({A,B,C,D,E});
    cout << (ll)ceil(1.0*N/M) + 4 << endl;
}


Measured memory_bytes: 256
import sys
N,K=map(int,input().split())
nums = {}
for _ in range(N):
  a,b = map(int,sys.stdin.readline().split())
  if a in nums:
    nums[a] += b
  else:
    nums[a] = b

cnt = 0
for key in sorted(nums.keys()):
  cnt += nums[key]
  if cnt >= K:
    print(key)
    exit()

Measured memory_bytes: 46556
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int k = int.Parse(input[1]);

    if(n <= k) Console.WriteLine(1);
    else Console.WriteLine(0);
	}
}


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


int A[100];

int main(){
	int n,k;
	cin >> n >> k;
	for(int i=0;i<n;i++){
		cin >> A[i];
	}
	sort(A,A+n);
	reverse(A,A+n);
	
	int sum=0;
	for(int i=0;i<k;i++){
		sum+=A[i];
	}
	
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdio>
using namespace std;
int main(void){
    int m,f,r;
   
   
  
       cin>>m>>f>>r;
       if(m+f+r>=22){
           cout<<"bust"<<endl;
       }
       
       else{
           cout<<"win"<<endl;
       }
      
}
    
   

Measured memory_bytes: 256
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 100005
typedef long long ll;

int n,m; ll l,ans;
char s[maxn];

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

struct trie{
	int root,tot,ch[maxn][2];
	void insert(char *s,int n){
		int p=root;
		for (int i=1;i<=n;i++){
			int x=s[i]-'0';
			if (!ch[p][x]) ch[p][x]=++tot;
			p=ch[p][x];
		}
	}
	void dfs(int x,int dep){
		int cnt=(bool)ch[x][0]+(bool)ch[x][1];
		if (cnt==1) ans^=(l-dep)&(dep-l);
		if (ch[x][0]) dfs(ch[x][0],dep+1);
		if (ch[x][1]) dfs(ch[x][1],dep+1);
	}
}T;

int main(){
	n=read(); scanf("%lld",&l);
	for (int i=1;i<=n;i++){
		scanf("%s",s+1); int x=strlen(s+1);
		T.insert(s,x);
	}
	T.dfs(T.root,0); puts(ans?"Alice":"Bob");
	return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define debug freopen("input", "r", stdin);freopen("output", "w", stdout)
#define endl '\n'
#define all(var) var.begin(), var.end()
typedef long long ll;
ll const MOD = 1e9+7;
using namespace std;

ll genp(ll n){
    return n*(n-1)/2;
}


int main(){
    fast;
    ll n; cin >> n;
    map < ll ,pair<ll,ll> > dis;
    vector<ll> v(n);
    for(ll i = 0; i < n; i++){
        ll x;cin >> x;
        v[i] = x;
        dis[x].first++;
    }
    ll sum = 0;
    for(auto &itr: dis){
        itr.second.second = genp(itr.second.first);
        sum += itr.second.second;
    }
    for(ll i = 0; i < n; i++){
        ll ans = sum - dis[v[i]].second;
        ans += genp(dis[v[i]].first-1);
        cout << ans << endl;
    }
}


Measured memory_bytes: 11136
// ABC161A.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

//#include "pch.h"
#include <iostream>
using namespace std;
int main()
{
	int X, Y, Z;
	cin >> X >> Y >> Z;
	cout << Z <<" "<< X <<" "<< Y << endl;
}


Measured memory_bytes: 256
def bubbleSort(nums, length):
  count = 0
  flag = 1
  while flag:
    flag = 0
    for j in xrange(length - 1, 0, -1):
      if nums[j] < nums[j - 1]:
        nums[j], nums[j - 1] = nums[j - 1], nums[j]
        count += 1
        flag = 1
  return [nums, count]

length = int(raw_input())
nums = map(int, raw_input().split())
ans = bubbleSort(nums, length)
print " ".join(map(str, ans[0]))
print ans[1]

Measured memory_bytes: 6416
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

bool is_input[400000];

int main(){
  int n,q;
  cin>>n>>q;
  for(int i=0;i<n;i++){
    int tmp;
    cin>>tmp;
    is_input[tmp]=true;
  }
  for(int i=0;i<q;i++){
    int cnt=2;
    int query;
    cin>>query;
    int prev=query-1;
    while(is_input[prev]!=true){
      prev+=query;
      if(prev>300000){
	prev=query-cnt;
	cnt++;
      }
    }
    cout<<prev%query<<endl;
  }
  return 0;
}

Measured memory_bytes: 1452
#include<stdio.h>
#define N 100
#define INF 999999

int n;

void matrix(int p[]){
  int m[N][N];
  int i,j,k,l,q;

  for(i=1;i<=n;i++){
    m[i][i]=0;
  }

  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      m[i][j]=INF;
      for(k=i;k<=j-1;k++){
	q=m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j];
	if(m[i][j]>q)m[i][j]=q;
      }
    }
  }
  printf("%d\n",m[1][n]);
}

int main(){
  int a[N][2],p[N];
  int i;

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&a[i][0],&a[i][1]);
    p[i-1]=a[i][0];
    if(i==n)
      p[i]=a[i][1];
  }
  matrix(p);

  return 0;
}

Measured memory_bytes: 632
n = gets.chomp.reverse
cnt = 0
flag = false
n.size.times do |i|
  k = n[i].to_i
  if flag
    k += 1
    flag = false
  end
  if k < 5
    cnt += k
  elsif k == 5
    if i != n.size && n[i+1].to_i >= 5
      cnt += k
      flag = true
    else
      cnt += k
    end
  else
    cnt += 10 - k
    flag = true
  end
end
cnt += 1 if flag
puts cnt

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

int main(){
  int n; cin>>n;
  vector<int> a(n), b(n, 0);
  for (int i=0; i<n; ++i) cin>>a[i];
  b[1] = abs(a[1] - a[0]);
  for(int i=2; i<n; ++i){
      b[i] = min((abs(a[i] - a[i-1]) + b[i-1]), (abs(a[i] - a[i-2]) + b[i-2]));
  }
  cout<<b[n-1];
  return 0;
      
} 


Measured memory_bytes: 1024
#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define LOCAL 1

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define dbg(...) cout<<#__VA_ARGS__ ": ["; for(auto e: __VA_ARGS__){cout<<e<<", ";} cout<<"]\n"
#define dbg1(...) cout<<#__VA_ARGS__ " "<< __VA_ARGS__ 
#else
#define dbg(...) 1;
#define dbg1(...) 1;
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
constexpr ll R=2e5+69, INF=2e9+6969;

int qq;

int main()
{
	scanf("%d", &qq);
	puts(qq == 1? "0" : "1");
	return 0;
}


Measured memory_bytes: 3684
// itne me hi thakk gaye?
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize ("-O3")
#define ll long long 
#define ull unsigned long long
using ld = long double;
const ll mod = 1e9 + 7;
const ll inf = 1e18;
const ll rk = 256;
const ll mod2 = 998244353;
const ld PI = 3.141592653589793;
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define print(a) for(auto j:a) {cout<<j<<",";} cout << "\n";
#define endl '\n'
#define whatis(x) cout << "> "<<#x << " ==> " << x << endl;
#define lwi(x) cout << " your " << #x << " is ---> " << x << " ";
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
// // Printing pair
ostream & operator << (ostream & os, pair <ll, ll> const& x) {
    os << x.first << "," << x.second;
    return os;
}
 
// printing vector
template <class T>
ostream & operator << (ostream & os, vector <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
// printing set
template <class T>
ostream & operator << (ostream & os, set <T> const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) {
    os << "{ ";
    for(auto& y : x) os << y << " ";
    return os << "}";
}
 
template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) {
    return os << "[ " << p.first << ", " << p.second << "]" ;
}
const int mxn = 1e6+5;
ll repVal(ll n) {
    if (n%2 == 0 || n%5 == 0) return 0;
    int rem = 1;
    int p = 1;
    ll k = 1;
    while(rem % n != 0) {
        k++;
        p = p*10 % n;
        rem = (rem + p) % n;
    }
    return k;
}
int32_t main(){
    FastIO;
    ll n;
    cin >> n;
    ll a = repVal(n);
    ll b = INT_MAX;
    if (n%7 == 0) b = repVal(n/7);
    if (!a && b == INT_MAX) cout << "-1\n";
    else cout << min(a, b) << endl;
    return 0;
}


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

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

using namespace std;

const int INF=1<<29;

int main(){
	int h,w; scanf("%d%d",&h,&w);
	char grid[50][51];
	rep(i,h) scanf("%s",grid[i]);

	int dp[50][50];
	dp[0][0]=0;
	rep(i,h) rep(j,w) if(i>0 || j>0) {
		dp[i][j]=INF;
		if(i>0) dp[i][j]=min(dp[i][j],dp[i-1][j]+grid[i][j]-'0');
		if(j>0) dp[i][j]=min(dp[i][j],dp[i][j-1]+grid[i][j]-'0');
	}
	printf("%d\n",dp[h-1][w-1]);

	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };

ll fact[200000], ifact[200000], dp[100000];
int h, w, a, b;

//二分累乗法
ll binpow(ll x, ll e) //
{
	ll a = 1;
	ll p = x;

	while (e > 0)
	{
		if (e % 2 == 0) { //指数が偶数
			p = (p * p) % MOD;
			e /= 2;
		}
		else {           //指数が奇数
			a = (a * p) % MOD;
			e--;
		}
	}

	return a;
}

int main(void)
{
	fact[0] = 1;
	ifact[0] = 1;
	cin >> h >> w >> a >> b;

	//逆元の列を計算
	for (int i = 1; i < h + w; i++)
	{
		fact[i] = fact[i - 1] * i % MOD;      //(i!) % MOD
		ifact[i] = binpow(fact[i], MOD - 2);  //(i!)^MOD-1 = 1 (% MOD), (i!)^-1 = (i!)^(MOD-2) //フェルマーの小定理
	}

	// (b-1, 0) から (b-1, h-a-1) までの経路数を計算
	for (int i = 0; i < h - a; i++)
		dp[i] = ((fact[b + i - 1] * ifact[b - 1] % MOD)*ifact[i] % MOD); //(b+i-1)!/((b-1)!(i)!)

	// (b-1, 0) から (b-1, h-a-1) から右下までの経路数を計算
	ll ans = 0LL;
	for (int i = 0; i < h - a; i++) {
		ans = (ans + ((dp[i] * fact[h + w - b - i - 2] % MOD) * ifact[h - i - 1] % MOD) * ifact[w - b - 1] % MOD) % MOD;
	}
	//(h+w-b-i-2)!/((h-i-1)!(w-b-1)!)
	cout << ans << "\n";
	return 0;
}

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


/// File input & output /////
#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>


#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////


//long long  Prime[3000000],nPrime;
//long long  mark[10000002];
//
//void seive(long long int n)
//{
//	long long int i,j,limit=sqrt(n*1.0)+2;
//	mark[1]=1;
//	for(i=4; i<=n ;i+=2)
//	mark[i]=1;
//	Prime[nPrime++]=2;
//	for(i=3; i<=n; i+=2)
//	{
//		if(!mark[i])
//		{
//			Prime[nPrime++]=i;
//			if(i<=limit)
//			{
//				for(j=i*i; j<=n ;j+=i*2)
//				{
//					mark[j]=1;
//				}
//			}
//		}
//	}
//}

int main()
{
    FASTIO;

    ll n;

    cin >> n;

    ll ans = ceil(n*1.00/1000);

    cout << ((ans*1000)-n) << endl;






    return 0;
}


Measured memory_bytes: 3760
while 1:
    n, x = map(int, input().split())
    if n == x == 0:
        break
    cnt = 0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1, n+1):
                if i+j+k == x:
                    cnt += 1
    print(cnt)


Measured memory_bytes: 5592
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, K;
	cin >> N >> K;

	if (N%K) {
		cout << 1 << "\n";
	}
	else {
		cout << 0 << "\n";
	}

}


Measured memory_bytes: 256
n,m=map(int,input().split())
data=list(range(n))
cnt=n-1
def find(x):
    if data[x]==x:
        return x
    else:
        data[x]=find(data[x])
        return data[x]
for i in range(m):
    a,b=map(int,input().split())
    a=find(a-1)
    b=find(b-1)
    if a!=b:
        data[a]=b
        cnt-=1
print(cnt)

Measured memory_bytes: 12824
n=int(input())

jpy=[]
btc=[]

for i in range(n):
    x,u=input().split()
    if u=="JPY":
        jpy.append(float(x))

    else:
        btc.append(float(x)*380000.0)

#print(jpy)
#print(btc)

print(sum(jpy)+sum(btc))


Measured memory_bytes: 2940
use std::io::stdin;
use std::collections::VecDeque;
use std::option::Option::Some;

fn input () -> (usize, usize) {
    let mut a = String::new();
    stdin().read_line(&mut a).unwrap();
    let a: Vec<usize> = a.trim().split_whitespace().flat_map(str::parse).collect();
    (a[0], a[1])
}

fn main(){
    let (n, q) = input();
    let mut verts = [0; 200001];
    let mut bidirectional_tree: Vec<_> = (0..n+1).map(|_| vec![]).collect();
    for _ in 0..n-1 {
        let (a, b) = input();
        bidirectional_tree[a].push(b);
        bidirectional_tree[b].push(a);
    };
    for _ in 0..q {
        let (p, x) = input();
        verts[p] += x;
    }
    let mut queue = VecDeque::from([1].to_vec());
    let mut visited = [false; 200001];
    while let Some(parent) = queue.pop_back() {
        for &child in bidirectional_tree[parent].iter().filter(| &&child| !visited[child]) {
            queue.push_front(child);
            verts[child] += verts[parent];
        }
        visited[parent] = true;
    }

    println!("{}", verts.iter().skip(1).take(n).map(|&c| format!("{}", c)).collect::<Vec<String>>().join(" "));
}


Measured memory_bytes: 34684
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<string> str(n);
	for(int i=0; i<n; i++){
    	cin >> str.at(i);
    }
	sort(str.begin(), str.end());
	int count = 1;
	vector<string> anser(0);
	vector<int> anserN(0);
	anser.push_back(str.at(0));
	for(int i=1; i<n; i++){
		if(str.at(i) == str.at(i-1)){
			count++;
		}else{
			anser.push_back(str.at(i));
			anserN.push_back(count);
			count = 1;
		}
	}
	anserN.push_back(count);
	int max = 0;
	for(int i=0; i<anserN.size(); i++){
		if(anserN.at(i) > max){
			max = anserN.at(i);
		}
	}
	vector<string> ans(0);
	for(int i=0; i<anserN.size(); i++){
		if(anserN.at(i) == max){
			ans.push_back(anser.at(i));
		}
	}
	for(int i=0; i<ans.size(); i++){
		cout << ans.at(i) << endl;
	}
}

Measured memory_bytes: 20212
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main() {
	int N, K;
	cin >> N >> K;

	if (N <= K) {
		cout << 0 << endl;
		return 0;
	}
	vector<int> H(N);

	for (int i = 0; i < N; i++) {
		cin >> H.at(i);
	}
	sort(H.begin(), H.end());

	for (int i = 0; i < K; i++) H.pop_back();

	long long sum = 0;
	for (auto x : H) {
		sum += x;
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<ll> a(n);
	int k = 0;
	rep(i, n) {
		cin >> a[i];
		a[i] -= k;
		k++;
	}
	if (n == 1) {
		cout << 0 << endl;
		return 0;
	}
	sort(a.begin(), a.end());
	ll ans = 0;
	ll x = a[n / 2];
	rep(i, n) {
		ans += abs(a[i] - x);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
int main()
{
    int n,i,j,k;
    int INF=0x3f3f3f3f;
    long long f[110][11],p[110][12],c[100];
    long long Max=-1*INF;
    scanf("%d",&n);
    for(i=0; i<n; i++)
        for(j=0; j<10; j++)
            scanf("%lld",&f[i][j]);
    for(i=0;i<n;i++)
        for(j=0;j<=10;j++)
            scanf("%lld",&p[i][j]);
    for(k=1;k<(1<<10);k++)
    {
        memset(c,0,sizeof c);
        for(i=0;i<n;i++)
        {
            for(j=0;j<10;j++)
            {
                if(f[i][j]&&((1<<j)&k))  //按位与 与
                    c[i]++;
            }
        }
        long long sum=0;
        for(i=0;i<n;i++)
            sum+=p[i][c[i]];
        if(sum>Max)Max=sum;
    }
    printf("%lld",Max);
    return 0;
}


Measured memory_bytes: 128
L = int(input())
a_list = [int(input()) for _ in range(L)]

dp = [[0] * 5 for _ in range(L+1)]

for i in range(L):
    a = a_list[i]

    if a > 0:
        even = a % 2
    else:
        even = 2
    odd = (a + 1) % 2

    # 0
    dp[i+1][0] = dp[i][0] + a
    # 0でない偶数
    dp[i + 1][1] = min(dp[i][0], dp[i][1]) + even
    # 奇数
    dp[i + 1][2] = min(dp[i][0], dp[i][1], dp[i][2]) + odd
    # 0でない偶数
    dp[i + 1][3] = min(dp[i][0], dp[i][1], dp[i][2], dp[i][3]) + even
    # 0
    dp[i + 1][4] = min(dp[i][0], dp[i][1], dp[i][2], dp[i][3], dp[i][4]) + a
print(min(dp[L]))


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	n = n%10;
	if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
		cout << "hon";
	}else if(n == 0 || n == 1 || n == 6 || n == 8) {
		cout << "pon";
	}else {
		cout << "bon";
	}
	return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,ans,a[5010],cnt,f[5010],p=1e9+7;
ll ksm(ll x,ll y){
	ll xlh=1;
	while(y){
		if(y%2==1)xlh=xlh*x%p;
		x=x*x%p;
		y/=2;
	}
	return xlh;
}
int main(){
	ll i,j;
	scanf("%lld%lld",&n,&m);
	for(i=1;i*i<=n;i++)if(n%i==0){
		a[++cnt]=i;
		if(n/i!=i)a[++cnt]=n/i;
	}
	sort(a+1,a+cnt+1);
	//puts("-1");
	for(i=1;i<=cnt;i++){
		//printf("%lld %lld\n",i,a[i]);
		f[i]=ksm(m,(a[i]+1)/2)%p;
	//	puts("-2");
		for(j=1;j<i;j++)if(a[i]%a[j]==0)f[i]=(f[i]-f[j]+p)%p;
		//puts("-3");
		if(a[i]%2==1)ans=(ans+a[i]*f[i]%p)%p;
		 else ans=(ans+a[i]*f[i]%p*ksm(2,p-2)%p)%p;
		//printf("%lld %lld %lld\n",i,f[i],ans);
	}
	printf("%lld",ans);
}
/*
一个串循环位移后能得到的不同的串的个数为该串的最短循环节
枚举循环节长度，算出该长度的方案（容斥） 
1e9以内最多质因子的数只有1000多 
*/

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

int main(){
  int x, n;
  cin >>  x >> n;
  
  vector<int> v(102);
  for(int i=0; i<=101; i++){
    v.at(i) = i;
  }
  
  for(int i=0; i<n; i++){
    int a;
    cin >> a;
    v.at(a) = -100;
  }
  
  vector<int> w;
  for(int i=0; i<102; i++){
    if(v.at(i) != -100)
      w.push_back(v.at(i));
  }
  
  int ans = x;
  for(int i=0; i<w.size(); i++){
    if(w.at(i) == x){
      break;
    }
    else if(w.at(i) > x){
      int prv = (i-1 < 0) ? 0 : i-1;
      int nxt = i;
      int prv_abs = x - w.at(prv);
      int nxt_abs = w.at(nxt) - x;
      
      if(prv_abs == nxt_abs || prv_abs < nxt_abs)
        ans = w.at(prv);
      else
        ans = w.at(nxt);
      break;
    }
  }

  cout << ans << endl;
}

  

Measured memory_bytes: 3600
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
func NextLine() string {
  var line, buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line, isPrefix, err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n, _ = strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}

func dijkstra(E *[][]int, s int) (D []int) {
  N := len((*E))
  D = make([]int, N)
  for i := 0; i < N; i++ {
    if i != s {
      D[i] = -1
    }
  }
  Q := make([]int, N)
  Q[0] = s
  var v int
  pos := 1
  for i := 0; i < N; i++ {
    v = Q[i]
    for _, adj := range (*E)[v] {
      if D[adj] >= 0 {
        continue
      }
      D[adj] = D[v] + 1
      Q[pos] = adj
      pos += 1
    }
  }
  return
}

func max(A *[]int) (i, a int) {
  i = 0
  a = (*A)[0]
  for _i, _a := range (*A) {
    if _a > a {
      a = _a
      i = _i
    }
  }
  return
}

func main() {
  var N int
  N = NextInt()
  E := make([][]int, N)
  for i := range E {
    E[i] = make([]int, 0)
  }
  var a, b int
  for i := 0; i < N - 1; i++ {
    ab := NextIntVec()
    a = ab[0]
    b = ab[1]
    E[a - 1] = append(E[a - 1], b - 1)
    E[b - 1] = append(E[b - 1], a - 1)
  }
  D0 := dijkstra(&E, 0)
  s, _ := max(&D0)
  D1 := dijkstra(&E, s)
  _, L := max(&D1)
  if L % 3 != 1 {
    fmt.Println("First")
  } else {
    fmt.Println("Second")
  }
}

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

int main() {
     int N; cin >> N;
     int a, b, c;
     vector<vector<int>> dp(N+1, vector<int> (3));
     for (int i = 0; i < 3; i++) dp[0][i] = 0;
     for (int i = 1; i <= N; i++) {
         cin >> a >> b >> c;
         dp[i][0] = max(dp[i-1][1] + b, dp[i-1][2] + c);
         dp[i][1] = max(dp[i-1][0] + a, dp[i-1][2] + c);
         dp[i][2] = max(dp[i-1][0] + a, dp[i-1][1] + b);
     }
     cout << max({dp[N][0], dp[N][1], dp[N][2]}) << endl;
}


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

c = 0
var = 0
t = -1
for k in range(N):
  i = k+1
  if i == t:
    if p[i-1] == s:
      c = c+1
    else:
      var = var+1
  elif p[i-1] == i:
    c = c+1
  else:
    var = var+1
    s = i
    t = p[i-1]

if var <= 1:
  print("YES")
else:
  print("NO")

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

ull cnt_two (ull N) {
  ull ans = 0, i = 2;
  while(1) {
    ans += N / i;
    i *= 2;
    if (i > N) break;
  }
  return ans;
}

ull cnt_ten (ull N) {
  ull ans = 0, i = 5;
  while(1) {
    ans += N / i / 2;
    i *= 5;
    if (i > N) break;
  }
  return ans;
}

int main(){
  ull N;
  cin >> N;
  
  if (N % 2 == 1) cout << 0;
  else {
    ull tw_n = cnt_two(N);
    ull tn_n = cnt_ten(N);
    cout << min(tw_n, tn_n);
    //cout << tn_n;
  }
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	// 108-B
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x1 = sc.nextInt();
		int y1 = sc.nextInt();
		int x2 = sc.nextInt();
		int y2 = sc.nextInt();
		// (x1,y1)から(x2,y2)への移動距離を求める
		int mx = x2 - x1;
		int my = y2 - y1;
		// x2,y2を移動距離分移動
		int tmpx = x2 + mx;
		int tmpy = y2 + my;
		// (x2,y2)を中心に90度回転
		int x3 = (int) ((tmpx - x2) * Math.cos(90 * Math.PI / 180)) - (int) ((tmpy - y2) * Math.sin(90 * Math.PI / 180)) + x2;
		int y3 = (int) ((tmpx - x2) * Math.sin(90 * Math.PI / 180)) + (int) ((tmpy - y2) * Math.cos(90 * Math.PI / 180)) + y2;

		// (x1,y1)から(x2,y2)への移動距離を求める
		mx = x3 - x2;
		my = y3 - y2;
		// x3,y3を移動距離分移動
		tmpx = x3 + mx;
		tmpy = y3 + my;
		// (x3,y3)を中心に90度回転
		int x4 = (int) ((tmpx - x3) * Math.cos(90 * Math.PI / 180)) - (int) ((tmpy - y3) * Math.sin(90 * Math.PI / 180)) + x3;
		int y4 = (int) ((tmpx - x3) * Math.sin(90 * Math.PI / 180)) + (int) ((tmpy - y3) * Math.cos(90 * Math.PI / 180)) + y3;

		System.out.println(String.format("%d %d %d %d", x3, y3, x4, y4));

		sc.close();
	}
}

Measured memory_bytes: 21712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const long long INF = 1e18;
# define len(x) ((int)(x).size())
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define foreps(i, m, n) for(int i = m;i < n;i++)
# define ALL(x) (x).begin(), (x).end()
# define rall(x) (x).rbegin(), (x).rend()
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; }

int main() {
    ll N; cin >> N;
    map<ll, ll> mp;
    rep(i, N) {
        ll a; cin >> a;
        mp[a]++;
    }

    ll ans = 0;
    for (auto itr = mp.begin(); itr != mp.end(); itr++) {
        if (itr->first != itr->second) {
            if (itr->first < itr->second) ans += abs(itr->first - itr->second);
            else ans += itr->second;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9496
#include <cmath>
#include <iostream>
#define PI 3.14159265358979L
using namespace std;
int n, a, s; long double p, q;
int main() {
	while(true) {
		cin >> n; s = 360, p = 0.0L;
		if(n == 0) break;
		for(int i = 0; i < n - 1; i++) {
			cin >> a; s -= a;
			p += sinl(PI / 2.0L - a * PI / 360.0L) * cosl(PI / 2.0L - a * PI / 360.0L);
		}
		p += sinl(PI / 2.0L - s * PI / 360.0L) * cosl(PI / 2.0L - s * PI / 360.0L);
		cin >> n; s = 360, q = 0.0L;
		for(int i = 0; i < n - 1; i++) {
			cin >> a; s -= a;
			q += sinl(PI / 2.0L - a * PI / 360.0L) * cosl(PI / 2.0L - a * PI / 360.0L);
		}
		q += sinl(PI / 2.0L - s * PI / 360.0L) * cosl(PI / 2.0L - s * PI / 360.0L);
		if(abs(p - q) < 0.0000000001L) printf("0\n");
		else if (p > q) printf("1\n");
		else printf("2\n");
	}
}

Measured memory_bytes: 3184
N = list(map(int, input().split()))
A = N[0]
B = N[1]
K = N[2]

# A = 5 # 高橋君
# B = 4 # 青木君
# K = 2 # 操作回数

def cookie(my_num, your_num):
    # my_num 自分のクッキー枚数
    if my_num % 2 == 0:
        # 偶数の場合
        # 自分の残りクッキー、相手の残りクッキー
        return int(my_num / 2), your_num + int(my_num / 2)
    else:
        # 奇数の場合
        # 自分の残りクッキー、相手の残りクッキー
        return my_num - 1 - int((my_num - 1) / 2), your_num + int((my_num - 1) / 2)

for i in range(K):
    if i % 2 == 0:
        # A君のターン
        A, B = cookie(A, B)
    else:
        # B君のターン
        B, A = cookie(B, A)
    i += 1

print(A, B)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

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

  int N, K;
  cin >> N >> K;

  set<int> have;

  int A;
  int d;
  rep(k, K) {
    cin >> d;
    rep(i, d) {
      cin >> A;
      have.emplace(A);
    }
  }
  cout << N - have.size() << endl;
  
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
const long long INF = 1LL << 60;

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;}

int main()
{   
    int n,m; cin >> n >> m;
    vector<vector<char> > a(n+1,vector<char>(m+1));
    for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin >> a[i][j];
    ll dp[1010][1010] = {0};
    dp[0][0] = 1;
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            if(a[i+1][j] != '#'){
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %= MOD;
            }
            if(a[i][j+1] != '#'){
                dp[i][j+1] += dp[i][j];
                dp[i][j+1] %= MOD;
            }
        }
    }
    cout << dp[n-1][m-1] << endl;
}
    

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
#define maxn 1000
#define ll long long
ll D;
ll ans=0;
ll pw10[20];
int num[20];
int num1[20];
void dfs(int l,int r,ll tmp,ll cnt,bool z)
{
    if(l>r)
    {
        if(tmp==D)
        {
            ans+=cnt;
        }
        return;
    }
    if(l==r)
    {
        if(tmp==D)
        {
            ans+=10*cnt;
        }
        return;
    }
    if(abs(tmp-D)>pw10[r+1]) return;
    int now=z?0:-9;
    for(int i=now;i<=9;++i)
    {
        dfs(l+1,r-1,tmp+(pw10[r]-pw10[l])*i,z?cnt*num1[i+10]:cnt*num[i+10],0);
    }
}
void deal(int pos)
{
    dfs(0,pos,0,1,1);
}
int main()
{
    cin>>D;
    pw10[0]=1;
    for(int i=1;i<=19;++i)
        pw10[i]=pw10[i-1]*10LL;
    ll tmp=D;
    int cnt=0;
    for(int i=0;i<10;++i)
        for(int j=0;j<10;++j)
            num[i-j+10]++;
    for(int i=1;i<10;++i)
        for(int j=1;j<=i;++j)
            num1[i-j+10]++;
    while(tmp>0)
    {
        cnt++;
        tmp/=10;
    }
    for(int i=cnt-1;i<=19;++i)
    {
        deal(i);
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
H, W, h, w = map(int, input().split())

def solve(H, W, h, w):
    if (W % w == 0 and H % h == 0):
        return False, []
    if (W % w == 0):
        return True, solve_vertical(H, W, h, w)
    return True, solve_horizontal(H, W, h, w)

def solve_horizontal(H, W, h, w):
    return [solve_horizontal_core(W, w)] * H

def solve_horizontal_core(W, w):
    m, r = divmod(W, w)
    row = [0] * W
    row[0] = m + 1
    row[w - 1] = - m - 2
    for i in range(w, W):
        row[i] = row[i - w]
    return row

def solve_vertical(H, W, h, w):
    col = solve_horizontal_core(H, h)
    m = []
    for c in col:
        m.append([c] * W)
    return m

yesno, mat = solve(H, W, h, w)
if yesno:
    print('Yes')
    for row in mat:
        print(*row)
else:
    print('No')


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

#define _USE_MATH_DEFINES
#define pb  push_back

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

const ll INF = 999999999;
const ll atcoder = 1000000007;
const int dx[4] = { 1 , 0 , -1 ,0 };
const int dy[4] = { 0 , 1 , 0 , -1 };

int main() {

	int n, m;
	vector<int> d, t;

	cin >> n;
	
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		d.pb(a);
	}
	sort(d.begin(),d.end());

	cin >> m;
	for (int i = 0; i < m; i++) {
		int a;
		cin >> a;
		t.pb(a);
	}

	sort(t.begin(),t.end());

	for (int i = 0; i < m; i++) {
		for (int j = i; j < n; j++) {
			if (t[i] == d[j]) {
				d[j] = 0;
				break;
			}
			else if (t[i] < d[j]) {
				cout << "NO" << endl;
				return 0;
			}
		}
	}

	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 2548
// Don't Lose Hope, Nor Be Sad -- Quran

#include <bits/stdc++.h>
using namespace std;

int main(){
    int n,temp,digits=0;
    cin >> n;
    temp = n;
    while(temp!=0){
       digits += temp%10;
       temp = temp/10;
    }
    if(n % digits == 0)cout <<"Yes\n";
    else cout << "No\n";
    return 0;
}

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

using namespace std;

int main(){
    int N,K,ans=0,RL=0;
    cin >> N >> K;
    string S;
    cin >> S;
    for(int i=0;i<N;i++){
        if(i!=0 && S[i]=='L' && S[i-1]=='L'){
            ans++;
        }
        if(i!=N-1 && S[i]=='R' && S[i+1]=='R'){
            ans++;
        }

        if(i!=N-1 && S[i]=='R' && S[i+1]=='L'){
            RL++;
        }
    }

    cout << min(ans+2*K,N-1) << endl;
}

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

void print(int node, int d, vector<vector<int> > adjlist, vector<string> name){

    for(int i = 0; i < d; i++) cout << '.';
    cout << name[node] << endl;
    for(int i = 0; i < adjlist[node].size(); i++){
        print(adjlist[node][i], d + 1, adjlist, name);
    }

}

int main(){

    int n; cin >> n;
    vector<string> name(n);
    vector<vector<int> > adjlist(n);

    for(int i = 0; i < n; i++){
        int a; string s; cin >> a >> s;
        
        a--;
        name[i] = s;
        if(a == -1) continue;
        adjlist[a].push_back(i);
    }

    print(0, 0, adjlist, name);
    return 0;
}


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

void solve() {
	int x, y, b, p;
	cin >> x >> y >> b >> p;

	int res = b * x + p * y;
	for (int i = b; i < 10; i++) {
		for (int j = p; j < 10; j++) {
			int v = i * x + j * y;
			if (i >= 5 && j >= 2) {
				v -= v / 5;
			}
			res = min(res, v);
		}
	}
	cout << res << endl;
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		solve();
	}
	return 0;
}

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

int main() {
  vector<int64_t> lucas(87);
  lucas.at(0) = 2;
  lucas.at(1) = 1;
  for (int i = 2; i < lucas.size(); i++) {
    lucas.at(i) = lucas.at(i-1) + lucas.at(i-2);
  }
  int N;
  cin >> N;
  cout << lucas.at(N) << endl;
}


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

#define ll long long
#define LL long long
#define ULL unsigned long long 
#define ull unsigned long long 
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define int(x) int x;scanf("%d",&x);
#define double(x) double x;scanf("%lf",&x);
#define string(x) double string;cin>>x;

using namespace std;

int main()
{
	int num;
	int data[100]={};
	int ans;
/*	for (int j = 0; j < 100; j++) {
		data[j] = j;
	}*/
	int i=0;
	
	while (cin >> num)
	{
		data[num]++;
		i++;
	}
	int tmp = 0;
	//sort(num, num + i);
	for (int j = 0; j < i; j++) {
		if (data[j] > tmp)
		{
			ans = j;
			tmp = data[j];
		}
	}

	cout << ans << endl;

	for (int j = 0; j < i; j++) {
		if (data[ans]==data[j]&&j!=ans)
		{
			cout << j << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;  
#define ordered_set tree<ll, null_type , less<ll> , rb_tree_tag , tree_order_statistics_node_update> 
#define ll long long
#define ull unsigned long long
#define pb push_back
#define inf 1e18
#define mk make_pair
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test ll t; cin>>t; while(t--)
#define setbits __builtin_popcount
#define endl '\n'
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
int main()
{
    fastIO;
    ll n;
    cin>>n;
    string str;
    cin>>str;
    vector<int>pre(n);
    vector<int>suf(n);
    for(int i=0;i<n;i++)
    {
        if(str[i]=='W')
        {
            pre[i]++;
        }
        if(i>0)
        {
            pre[i]+=pre[i-1];
        }
    }
    for(int i=n-1;i>=0;i--)
    {
        if(str[i]=='R')
        {
            suf[i]++;
        }
        if(i<n-1)
        {
            suf[i]+=suf[i+1];
        }
    }
    ll x,y,val,val1,ans=INT_MAX;
    //debug()<<pre;
    //debug()<<suf;
    val=suf[0];
    ans=min(ans,val);
    for(int i=0;i<n-1;i++)
    {
        val1=max(pre[i],suf[i+1]);
        val=pre[i]+suf[i+1];
        ans=min(ans,val1);
        ans=min(ans,val);
    }
    val=pre[n-1];
    ans=min(ans,val);
    cout<<ans<<endl;
}

Measured memory_bytes: 5124