akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<stdio.h> //per fare input output con scanf and printf
#include<stdlib.h> //per fare qsort e bsearch
#include<string.h> // per fare strcpy(sarrivo, spartenza) strcat(str, aggiungo) strcmp(a,b) che da 0 se sono uguali
#include<math.h>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<map>
 
using namespace std;
 
#define ld long double
#define ll long long int
#define vi vector <ll> 
#define pi pair <int, int>
#define binary(v, el) binary_search((v).begin(), (v).end(), (el))
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define G(n, t) get<(n)>((t)) // get element of a tuple
#define F first
#define S second
#define input(type, n) type n; cin >> n
#define FORN(n) for (ll i=0;i<(n); i++)
#define print(x) cout << x << endl
#include <iomanip>      // std::setprecision
#define M 1000*1000*1000+7
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


int main(){
  IOS
  ll n,m; cin>>n>>m;
  vector <pair <ll,ll>> v;
  for (ll i=0;i<n;i++){
    ll a,b; cin>>a>>b;
    v.PB(MP(a,b));
  }
  sort(v.begin(), v.end());
  ll j =0, s=0;
  priority_queue <ll> q;
  for (ll i=1;i<=m;i++){
    while (v[j].F == i && j<n) {
      q.push(v[j].S);
      j++;
    }
    if (!q.empty()){
      s += q.top();
      q.pop();
    }
  }
  cout << s;
}

Measured memory_bytes: 3568
n = gets.chomp.to_i
nums = gets.chomp.split.map(&:to_i)
nums.unshift nil
count = 0
1.upto(n) do |i|
    if nums[i] == i
        nums[i] = nums[i + 1]
        nums[i + 1] = i
        count += 1
    end
end
puts count


Measured memory_bytes: 9092
# minimum_spanning_tree
def prim(adj_matrix, n):
    dist = [float("inf") for _ in range(n)]  # 訪問確定したノードからの最短距離
    visited = [False for _ in range(n)]  # ノードの訪問が確定したか
    parent = [-1 for _ in range(n)]  # start -> endを保存するためのstart？
    cost = 0
    inf = float("inf")

    start = 0
    visited[start] = True
    dist[start] = 0
    while True:
        # startから直接つながっている未訪問ノードをもとに、距離の最小値を更新する
        for end in range(n):
            if not visited[end] and adj_matrix[start][end] > -1 and adj_matrix[start][end] < dist[end]:
                dist[end] = adj_matrix[start][end]
                parent[end] = start

        min_cost = inf
        for nextnode in range(n):
            # dist_nodeの中から最もコストの短いノードを探す。そのノードは訪問確定。それを次回のstartとする。
            if not visited[nextnode] and dist[nextnode] < min_cost:
                min_cost = dist[nextnode]
                start = nextnode
        if min_cost == inf:
            break

        visited[start] = True
        cost += min_cost

    return parent, cost


def main():
    n = int(input())
    adj_matrix = []
    for _ in range(n):
        row = input().split()
        adj_matrix.append(list(map(int, row)))
    parent, cost = prim(adj_matrix, n)
    print(cost)


if __name__ == "__main__":
    main()



Measured memory_bytes: 5920
#include <cstdio>
#include <vector>
using namespace std;

vector<vector<int> > e;
int dep[100000];
int K,C;
int n;
int a[100000];

void dfs(int i)
{
  dep[i]=0;
  for(int x=0;x<e[i].size();x++){
    int j=e[i][x];
    dfs(j);
    dep[i]=max(dep[i],dep[j]+1);
  }
  if(i!=0&&dep[i]==K-1&&a[i]!=0){
    C++;
    dep[i]=-1;
  }
}


int main()
{
  scanf("%d%d",&n,&K);
  for(int i=0;i<n;i++){
    scanf("%d",a+i);
    a[i]--;
  }
  C=0;
  if(a[0]!=0){
    C++;
    a[0]=0;
  }
  e=vector<vector<int> >(n);
  for(int i=1;i<n;i++){
    e[a[i]].push_back(i);
  }
  dfs(0);
  printf("%d\n",C);
  return 0;
}


Measured memory_bytes: 11136
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

int main() {
  SS(int,n)
  set<string>test;
  SV(string,a,n)
  bool ok=true;
  rep(i,n)test.insert(a[i]);
  rep(i,n-1){
    if(a[i].at(a[i].size()-1)!=a[i+1].at(0))ok=false;
  }
  if(test.size()!=n)ok=false;
  Yes(ok);
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

// 品物の個数を全探索
func oneOOToOneOFive(x int) bool {
	for c := 1; c <= x; c++ {
		if 100*c <= x && x <= 105*c {
			return true
		}
	}
	return false
}

func main() {
	var x int
	fmt.Scan(&x)
	if oneOOToOneOFive(x) {
		fmt.Println(1)
	} else {
		fmt.Println(0)
	}
}


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

  return 0;
}


Measured memory_bytes: 256
using System;

namespace ITP1
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string p = Console.ReadLine();
            int t;
            int max = 0;
            for (int i = 0; i < s.Length; i++)
            {
                t = 0;
                if (p[0] == s[i])
                {
                    int k = i;
                    while (t < p.Length)
                    {                        
                        if (k >= s.Length) k -= s.Length;
                        if (p[t] != s[k])
                        {
                            break;
                        }
                        k++;
                        t++;
                    }
                    if (t > max)
                    {
                        max = t;
                    }                    
                }
            }

            if (max < p.Length)
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
         
        }
    }
}

Measured memory_bytes: 8904
def main():
    MAX_ = 10 ** 6

    N = int(input())
    A = map(int, input().split())

    mi = MAX_
    mii = -1

    ma = -MAX_
    mai = -1

    for i, x in enumerate(A):
        if mi > x:
            mi = x
            mii = i + 1
        if ma < x:
            ma = x
            mai = i + 1

    if mi >= 0:
        print(N - 1)
        for i in range(1, N):
            print(i, i + 1)
        return

    if ma <= 0:
        print(N - 1)
        for i in range(N - 1, 0, -1):
            print(i + 1, i)
        return

    print((N - 1) * 2)
    if ma + mi >= 0:
        for i in range(1, N + 1):
            if i == mai: continue
            print(mai, i)
        for i in range(1, N):
            print(i, i + 1)
        return
    else:
        for i in range(1, N + 1):
            if i == mii: continue
            print(mii, i)
        for i in range(N - 1, 0, -1):
            print(i + 1, i)
        return


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
#define REP(i,x,n) for (int i=x; i<n; i++)
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;

int main(){
  int n, m, x;
  cin >> n >> m >> x;
  m++;
  vvi vec(n, vi(m));
  rep(i,n){
    rep(j,m){
      cin >> vec.at(i).at(j);
      //printf("%d ", vec.at(i).at(j));
  }
  //cout << endl;
}

  int ans = 0;
  rep(i,n){
    ans += vec.at(i).at(0);
    //printf("ans:%d\n", ans);
  }

  bool never = false;
  rep(tmp,(1<<n)){
    int index = 0;
    bitset<12> s(tmp);
    vi X(m,x);
    vi Y(m);
    rep(i,n){
      if (s.test(i)){
        index +=vec.at(i).at(0);
        REP(j,1,m){
          Y.at(j) += vec.at(i).at(j);
        }
      }
    }

    bool flag = true;
    REP(i,1,m){
      if (Y.at(i) < X.at(i)) flag = false;
    }
    //printf("index:%d, ans:%d\n", index, ans);
    if (flag){
      ans = min(ans, index);
      never = true;
    }
  }
  //cout << endl;
  if (never) cout << ans << endl;
  else cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <cmath>
#include <numeric>
#include <iomanip>


#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;


// <<fixed<<setprecision(6)<<


int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}


int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}


int main(){
  lint k,r;
  cin>>k;
  queue<lint> q;
  for(int i=1;i<10;i++){
    q.push(i);
  }
  for (int i = 0; i < k; i++)
  {
    lint x;
    x=q.front();
    r=x;
    q.pop();
    if(x%10!=0){
      q.push(10*x+(x%10)-1);
    }
    q.push(10*x+(x%10));
    if(x%10!=9){
      q.push(10*x+(x%10)+1);
    }
  }
  cout<<r;
  
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
 
////////////// Prewritten code follows. Look down for solution. ////////////////

//#define int long long
#define endl '\n'
#define fs first
#define sc second
#define pb push_back
#define len(x) ((int)(x).size())     
#define all(x) (x).begin(), (x).end()
#define test int _; cin >> _; while(_--)
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;

const ll LINF = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MOD = 1e9+7;

ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
inline ll mod(ll a, ll b){return ((a%b)+b)%b;}
inline ll expo(ll b, ll p, ll m = MOD){
  ll ans = 1; 
  while(p > 0){
    if(p&1LL) ans = mod(ans*b, m); 
    b = mod(b*b, m); 
    p >>= 1LL;
  } 
  return ans;
}
 
////////////////////////// Solution starts below. //////////////////////////////

ll dp[3005][3005];
ll v[3005];

int32_t main(){
  fastio;
  int n;
  cin >> n;
  for(int i = 1; i <= n; i++){
    cin >> v[i];
    dp[i][i] = v[i];
  }
  for(int l = n; l >= 1; l--){
    for(int r = l; r <= n; r++){
      if((r-l+1)%2 == n%2){
        dp[l][r] = max(v[l] + dp[l+1][r], dp[l][r-1] + v[r]);
      }else{
        dp[l][r] = min(dp[l+1][r] - v[l], dp[l][r-1] - v[r]);
      }
    }
  }
  cout << dp[1][n] << endl;
  return 0;
}

Measured memory_bytes: 70016
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<31;
const ll LINF=1LL<<60;
const double eps=1e-9;
const ll MOD=1000000007LL;
template<typename T>void chmin(T &a,T b){a=min(a,b);};
template<typename T>void chmax(T &a,T b){a=max(a,b);};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
vector<ll>f(ll x){
    vector<ll> s(45);
    for(ll i=40;i>=1;i--){
        ll m=x%(1LL<<(i+1LL));
        if(m<(1LL<<i)||m%2){
            s[i]=0;
        }else{
            s[i]=1;
        }
    }
    if(x%4LL==2LL||x%4LL==1LL)s[0]=1;
    return s;
} 
int main(){
    ll a,b;cin>>a>>b;  
    vector<ll> v1=f(a-1),v2=f(b);
    ll ans=0;
    for(ll i=40;i>=0;i--){
        if((v2[i]-v1[i]+2)%2){
            ans|=(1LL<<i);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#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)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

// auto mod int
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
  int n,m;
  cin>>n>>m;
  vector<int>a(n);
  vector<int>b(m);
  rep(i,n)cin>>a[i];
  rep(i,m)cin>>b[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  vector<int>na=a;
  vector<int>nb=b;
  na.erase(unique(na.begin(),na.end()),na.end());
  nb.erase(unique(nb.begin(),nb.end()),nb.end());
  if(na.size()!=n||nb.size()!=m){
    cout<<0<<endl;
    return(0);
  }
  mint ans=1;
  for(int i=n*m;i>0;i--){
    bool fa=binary_search(a.begin(),a.end(),i);
    bool fb=binary_search(b.begin(),b.end(),i);
    int x=upper_bound(a.begin(),a.end(),i)-a.begin();
    int y=upper_bound(b.begin(),b.end(),i)-b.begin();
    x=n-x;
    y=m-y;
    if(fa&&!fb){
      ans*=y;
    }
    else if(!fa&&fb){
      ans*=x;
    }
    else if(!fa&&!fb){
      ans*=x*y-(n*m-i);
    }
  }
  cout<<ans.x<<endl;
  return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#define gc(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
#define ms(a,b) memset(a,b,sizeof(a));
char _;
using namespace std;

int main()
{
    int n,K; gc(n); gc(K);
    int arr[100];
    for(int i = 0; i < n; ++i){
        int a; gc(a);
        arr[i]=a;
    }
    bool dp[100001];
    ms(dp,0);
    for(int i = 1; i <= K; ++i){
        for(int j = 0; j < n; ++j){
            if(i-arr[j]<0){
                dp[i]=max((int)dp[i],0);
            }
            else{
                dp[i]=max((int)dp[i],abs(dp[i-arr[j]]-1));
            }
        }
    }
    printf(dp[K] ? "First\n" : "Second\n");

    return 0;
}


Measured memory_bytes: 384
import math
N = int(input())
List = [list(map(int,input().split(" "))) for i in range(N)]

def fa(n):
  num = 1
  for i in range(1, n+1):
    num = num * i
  return num

dist = 0
for i in range(N):
  for j in range(i, N):
    dist += math.sqrt((List[i][0] - List[j][0])**2 + (List[i][1] - List[j][1])**2) * 2 * fa(N - 1)
print(dist / fa(N))

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





typedef long long ll;
const ll mod = 998244353;
const int maxn = 3030;

int n; ll s;
ll a[maxn];
ll dp[maxn][maxn][5];

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

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


    dp[0][0][0] = 1;
    //dp[i][j][k] = using first i elem, # ways to achieve sum j
    //k=0: interval didn't start
    //k=1: interval in progress
    //k=2: interval closed

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

	    //don't start the interval
	    dp[i+1][j][0] += dp[i][j][0];
	    dp[i+1][j][0] %= mod;

	    //continue the interval, or start it now
	    dp[i+1][j][1] += dp[i][j][0] + dp[i][j][1];
	    dp[i+1][j][1] %= mod;

	    //end the interval
	    dp[i+1][j][2] += dp[i][j][0] + dp[i][j][1] + dp[i][j][2];
	    dp[i+1][j][2] %= mod;

	    //using element a[i]
	    if (j+a[i]<=s) {
		dp[i+1][j+a[i]][1] += dp[i][j][0] + dp[i][j][1];
		dp[i+1][j+a[i]][1] %= mod;

		dp[i+1][j+a[i]][2] += dp[i][j][0] + dp[i][j][1];
		dp[i+1][j+a[i]][2] %= mod;
	    }
	    
	}
    }
    
   
    ll ans = dp[n][s][2];
    ans %= mod;
    ans += mod;
    ans %= mod;

    out(ans);

    return 0;
}


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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

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

int main() {
  ll a;
  string b;
  cin >> a >> b;
  int bb = stoi(b.erase(1, 1));
  ll res = (a * bb) / 100;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>


int main(void){
	
	int k,s;
	int count=0;
	
	
	scanf("%d  %d ",&k,&s);
	for(int x=0;x<=k;x++){
						
			for(int y=0;y<=k;y++){
				int z=s-x-y;
								if(0<=z &&  z<=k)
									count++;
			}
	}
	printf("%d  \n",count);
	
	return 0;
}

Measured memory_bytes: 128
pub 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()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn pow(n: i64, r: i64) -> i64 {
    let hoge = 1000000007;

    let mut ret = 1;

    if r != 0 {
        ret = pow(n, r / 2);
        ret = ret * ret % hoge;
        if r % 2 == 1 {
            ret = ret * n % hoge;
        }
    }

    ret
}

fn div(m: i64, n: i64, r: i64) -> i64 {
    m * pow(n, r - 2) % r
}

fn main() {
    let hoge = 1000000007;

    let nk: Vec<usize> = read_vec();
    let n = nk[0];
    let k = nk[1];

    let mut a: Vec<i64> = read_vec();
    a.sort();

    let mut ans = 0;

    let mut cnt = 1;
    ans = (ans + cnt * a[k - 1] % hoge) % hoge;
    for i in k..n {
        cnt = cnt * i as i64 % hoge;
        cnt = div(cnt, (i + 1 - k) as i64, hoge);
        ans = (ans + cnt * a[i]) % hoge;
    }

    cnt = 1;
    ans = (ans + hoge - cnt * a[n - k]) % hoge;
    for i in k..n {
        cnt = cnt * i as i64 % hoge;
        cnt = div(cnt, (i + 1 - k) as i64, hoge);
        ans = (ans + hoge - cnt * a[n - 1 - i]) % hoge;
    }

    println!("{}", ans);
}


Measured memory_bytes: 8444
#ifdef __APPLE__
#include <iostream>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#else
#include <bits/stdc++.h>
#endif

using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define tc(t) for (int tc=1; tc<=t; tc++)
typedef vector<int> VI;
typedef vector<long long int> VLLI;
typedef vector<pair<int, int> > VPI;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll, ll> PLL;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll modInverse (ll a) {ll p = mod - 2; return powmod(a, p);}
// head

int main() {
    ll x;
    cin >> x;
    ll p = 100, c = 0;

    while (p < x) {
        p += p/100;
        c++;
    }
    cout << c << "\n";
}



Measured memory_bytes: 3616
#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 floop(i,a,n) for (int i=a;i<n;i++)
#define rfloop(i,a,n) for (int i=n-1;i>=a;i--)
#define mloop(it,x) for(it=x.begin();it!=x.end();it++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((ll)(x).size())
#define cases ll t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef unsigned long long int ull;
typedef vector<ll> vec;
typedef pair<ll,ll> pll;
typedef double db;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ll mod=1000000007;
ll pm(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=((result%mod)*(x%mod))%mod; x=((x%mod)*(x%mod))%mod; n/=2;} return result;}
ll p(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=result*x; x=x*x; n/=2;} return result;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ncr(ll n,ll r) { ll p=1,k=1; if(n-r<r) r=n-r; if(r!=0) {while(r!=0) {p*=n; k*=r; ll temp=gcd(p,k); p/=temp; k/=temp; n--; r--;} } else p=1; return p;}
ll factorial[300000+1];
void fact(ll n) { factorial[0]=1; factorial[1]=1; floop(i,2,n+1) factorial[i] = (i * factorial[i-1]%mod) % mod; }
ll d,coeff1,coeff2; 
void euclid(ll a, ll b) { if(b==0) { d=a; coeff1=1; coeff2=0; } else { euclid(b,a%b); ll temp=coeff1; coeff1=coeff2; coeff2=temp-(a/b)*(coeff2); } }
ll modinv(ll a) { euclid(a,mod); return (coeff1%mod+mod)%mod; }
int prime[1000001]={};
int spf[1000001]={};
void sieve(ll n)
{
	prime[0]=1;
	prime[1]=1;
	for(ll i=2;i*i<=n;i++)
	{
		if(prime[i]==0)
		{
			for(ll j=i*i;j<=n;j+=i)
			{
				prime[j]=1;	
				if(spf[j]==j)
				spf[j]=i;	
			}		
		}
	}
}
/*
vec s(300000,0);
vec si(300000,1);
ll root(ll a)
{
	while(s[a]!=a)
	a=s[a];
	return a;
}
void uni(ll a,ll b)
{
	ll r1=root(a);
	ll r2=root(b);
	if(si[r1]<si[r2])
	{
		s[r1]=s[r2];
		si[r2]+=si[r1];
	}
	else
	{
		s[r2]=s[r1];
		si[r1]+=si[r2];
	}
}
vector<vec > adj(300000);
vec vis(300000,0);
vec dist(300000,0);
void dfs(ll t,ll n)
{
	vis[t]=1;
	floop(i,0,sz(adj[t]))
	{
		if(vis[adj[t][i]]==0)
		{
			dist[adj[t][i]]=dist[t]+1;
			vis[adj[t][i]]=1;
		//	sum[adj[t][i]]=sum[t]+c[t][adj[t][i]];
			dfs(adj[t][i],n);
		}
	}
}*/
struct my_comp
{
	bool operator()(pair<ll,pll> p1, pair<ll,pll> p2)
	{
		if(p1.fi!=p2.fi)
		return p1.fi>p2.fi;
		return p1.se.fi<p2.se.fi;
	}
};
int main()
{
	ll n,k;
	cin>>n>>k;
	vec p(n);
	floop(i,0,n)
	cin>>p[i];
	sort(all(p));
	ll ans=0;
	floop(i,0,k)
	ans+=p[i];
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3604
N=int(input())
s=[input() for i in range (N)]

s.sort()
count=1
maximum=0

for j in range (N-1):
  if s[j]==s[j+1]:
    count+=1
    if j==N-2:
      if count>maximum:
        a=[]
        a.clear()
        a.append(s[j])
        maximum=count
        number=1
      elif count==maximum:
        a.append(s[j])
        number+=1
  else:
    if count>maximum:
      a=[]
      a.clear()
      a.append(s[j])
      maximum=count
      number=1
    elif count==maximum:
      a.append(s[j])
      number+=1
    count=1   
  if maximum==1 and j==N-2:
    a.append(s[N-1])
    number+=1
for p in range (number):
  print(a[p])

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

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

	int a = -1, b = -1;
	s += "00";
	for (size_t i = 0, end = s.size() - 2; i < end; ++i) {
		if (s[i] == s[i + 1]) {
			a = i + 1;
			b = i + 2;
			break;
		}

		if (s[i] == s[i + 2] && s[i] != s[i + 1]) {
			a = i + 1;
			b = i + 3;
			break;
		}
	}

	std::cout << a << " " << b << std::endl;
	return 0;
}


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

const long long N = 1e3 + 17;
ll cnt, ans, lnt, sum, n, l1, x, y, a[N], mx, b[N];
pair<ll,ll>pr[N];
vector<ll>v,v2,v3;
map<ll,ll>mp;
bool used[N], t1, t2;
vector<string>sv;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n >> x >> y;
    for(ll i = 0; i < x; i ++)
    {
        cin >> a[i];
    }
    for(ll i = 0; i < n; i ++)
    {
        for(ll j = 0; j < x; j ++)
        {
            cin >> b[j];
            sum += a[j] * b[j];
            v.pb(sum);
        }
        sum = 0;
    }
    for(ll i = 0; i < v.size(); i ++)
    {
        if(i + 1 >= x and (i + 1) % x == 0)
        {
            if(v[i] + y > 0)
            {
                cnt ++;
            }
        }
    }
    cout << cnt << endl;
    //cout << "\nTime Elapsed : " << clock () * 1.0 / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 256
import scala.io.{StdIn => in}

object Main extends App {
  val Array(n, m, c) = in.readLine.split(" ").map(_.toInt)
  val b = in.readLine.split(" ").map(_.toInt)
  val a = Iterator.continually(in.readLine)
    .take(n)
    .map(_.split(" ").map(_.toInt))
    .toArray

  var ans = 0
  for(i <- 0 until n) {
    var res = 0
    for(j <- 0 until m) {
      res += a(i)(j) * b(j)
    }
    res += c
    if(res > 0) ans += 1
  }
  println(ans)
}

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

using namespace std;
typedef long long ll;
typedef long int li;
typedef long double lb;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define repr(i,j,n) for(ll i = j; i >= (n); i--)
#define all(x) (x).begin(),(x).end()
#define CLR(mat,f) memset(mat, f, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1LL<<60;

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

int main(){

  ll n;cin>>n;
  string s[n];ll t[n];
  rep(i,0,n)cin>>s[i]>>t[i];
  string x;cin>>x;

  bool e=false;
  ll ans=0;
  rep(i,0,n){
    if(e)ans+=t[i];
    if(x==s[i])e=true;

  }

  out(ans);

  return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))

flag = True

for i in range(N-1, 0, -1):
    if H[i] >= H[i-1]:
        continue
    elif H[i] == H[i-1] - 1:
        H[i-1] -= 1
    elif H[i] < H[i-1] - 1:
        flag = False
        break
        
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14396
N = int(input())
X = input()

n1 = X.count("1")
Xn = int(X, 2)

Xms = (Xn % (n1 - 1)) if n1 > 1 else 0
Xml = Xn % (n1 + 1)


def f(n):
    if n == 0:
        return 0
    return f(n % bin(n).count("1")) + 1


dp = [0] * ((10 ** 5) * 2 + 1)
for i in range(1, len(dp)):
    dp[i] = f(i)


for i in range(N):
    cnt = 0
    Xim = 0

    if X[i] == "1" and n1 == 1:
        print(cnt)
    elif X[i] == "1":
        print(dp[(Xms - pow(2, N - i - 1, n1 - 1)) % (n1 - 1)] + 1)
    else:
        print(dp[(Xml + pow(2, N - i - 1, n1 + 1)) % (n1 + 1)] + 1)



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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
const int N = 1e5+5;

ll n , m;
vector<ll> a;
vector< pair<ll,ll> > b;

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

    cin >> n >> m;
    for(int i=1; i<=n; i++)
    {
        int x;
        cin >> x;
        a.push_back(x);
    }

    for(int i=1; i<=m; i++)
    {
        int x,y;
        cin >> x >> y;
        b.push_back({y,x});
    }

    sort(b.begin() , b.end()) , sort(a.begin() , a.end() , greater<ll>() );

    ll ans = 0;
    while(b.size())
    {
        ll cnt = b.back().s , tmp = b.back().f;
        while(cnt > 0 && a.size() && a.back() < tmp)
        {
            cnt--;
            ans += tmp;
            a.pop_back();
        }
        b.pop_back();
    }
    while(a.size())
    {
        ans += a.back();
        a.pop_back();
    }
    cout << ans << '\n';

    return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << (#var) << " = " << (var) << endl;
#else
#define debug(var)
#endif

void init() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
}

const int N = 2e5+23;

int a[N], b[N];

void solve() {
  int n; scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", a+i, b+i);
  }
  sort(a, a+n);
  sort(b, b+n);
  int lo = a[n/2], hi = b[n/2];
  if (n%2 == 0) {
    lo = a[n/2]+a[n/2-1];
    hi = b[n/2]+b[n/2-1];
  }
  printf("%d", hi-lo+1);
}

int main() {
  int t = 1; //scanf("%d", &t);
  while (t--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 5248
using System;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			var s = Console.ReadLine().Split();
			int a = int.Parse(s[0]);
			int b = int.Parse(s[1]);

			if (a > b * 2)
			{
				Console.WriteLine(a - b * 2);
			} else
			{
				Console.WriteLine(0);
			}
		}
	}
}


Measured memory_bytes: 13140
S = input()
alphabets = set(chr(ord("a") + x) for x in range(26))

def F_short(S):
  se = alphabets - set(S)
  x = min(se)
  return S + x

def F_long(S):
  if S == "".join(sorted(alphabets, reverse=True)):
    return "-1"
  
  cand = []
  S = list(S)
  while True:
    x = S[-1]
    if not cand or (x > max(cand)):
      cand.append(S.pop())
      continue
    y = min(ch for ch in cand if ch > x)
    return "".join(S[:-1]) + y

L = len(S)
ans = F_short(S) if L < 26 else F_long(S)
print(ans)

Measured memory_bytes: 9096
#include<bits/stdc++.h>
#define ll long long 
#define hell 1000000007
#define F first
#define re 15000000
#define S second
#define pb push_back
#define all(a)  (a).begin(),(a).end()
#define rep(i,a,b) for(ll int i = a;i<b;i++)
#define pi 3.1415926536
#define Mod 998244353
//char a[2000][2000];
using namespace std;
bool check(ll m,ll k,ll n,ll a ,ll b){
  ll rem = n-m;
  if( k > rem*b + a*m)
      return 1;
  else
    return 0;

}
int binomialCoeff(ll n, ll k ,ll p) 
{ 
    ll C[n + 1][k + 1],D[p][k]; 
    ll i, j; 
   // cout<<n;
  
    // Caculate value of Binomial Coefficient 
    // in bottom up manner 
    for (i = 0; i <= n; i++) 
    { 
        for (j = 0; j <= min(i, k); j++) 
        { 
            // Base Cases 
            if (j == 0 || j == i) 
                C[i][j] = 1%hell; 
  
            // Calculate value using previously 
            // stored values 
            else
                C[i][j] = (C[i - 1][j - 1]%hell + 
                          C[i - 1][j]%hell)%hell; 
        } 
    } 
    for (i = 0; i <= p; i++) 
    { 
        for (j = 0; j <= min(i, k); j++) 
        { 
            // Base Cases 
            if (j == 0 || j == i) 
                D[i][j] = 1; 
    
            // Calculate value using previously 
            // stored values 
            else
                D[i][j] = (D[i - 1][j - 1] + 
                          D[i - 1][j])%hell; 
        } 
    } 

    for(int i = 1;i<=k;i++){
     // cout<<C[n][i]<<" ";
       cout<<(C[n][i]*D[p-1][i-1])%hell<<endl;
    }

  
   // return C[n][k]; 
}
int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);            
    //std::setprecision(20);    
    int tests=1;
      //freopen("input.txt", "r", stdin);   
    //cin>>tests;
  while(tests--)
    { 
       ll n,k;
       cin>>n>>k;
       binomialCoeff(n-k+1,min(k,n-k+1),k);
       if(n-k < k){
        for(int i = n-k+1;i<k;i++)
            cout<<0<<endl;
       }
    }
    
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
using  namespace std;
 
#define endl '\n'
#define ll long long
#define int long long
#define re register
#define pb(x) push_back(x)
#define ce(x) cout << x << '\n';
 
#define db  long double;
#define pll pair < ll, ll >;
#define scan(a, n) 		for(int i = 0; i < n; i++)cin >> a[i];
 
#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
 
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
#define infl LLONG_MAX
 
#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision
 
#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 
 
int32_t main() {
	ios::sync_with_stdio(0); 		cin.tie(0); cout.tie(0);
 
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
 
	ll t, i, x, j, y, 	z, k, n;
	cin >> n;
	cout_p((44 * n) / 7.0, 6);
}

Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string ss,s;
    while(cin>>ss)
    {
        s="AC";
        if(ss.find(s)!=std::string::npos)
            printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 256
a,b,k=map(int,input().split())
aa=a
l=[]
while a<(min(aa+k,b+1)):
  l.append(a)
  a+=1  
for i in range(max(b-k+1,a),b+1):
  l.append(i)
x=list(set(l))
x.sort()
for i in range(len(x)):
  print(x[i])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef long double ld;

using namespace std;

void zarr(string str, ll Z[]) 
{ 
    ll n = str.length(); 
    ll L, R, k; 
    L = R = 0; 
    for (ll i = 1; i < n; ++i) 
    { 
        if (i > R) 
        { 
            L = R = i; 
            while (R<n && str[R-L] == str[R]) 
                R++; 
            Z[i] = R-L; 
            R--; 
        } 
        else
        { 
            k = i-L; 
            if (Z[k] < R-i+1) 
                Z[i] = Z[k]; 
            else
            { 
                L = i; 
                while (R<n && str[R-L] == str[R]) 
                    R++; 
                Z[i] = R-L; 
                R--; 
            } 
        } 
    } 
} 



int main()
{
   FAST/**/
   
   ll n;
   cin>>n;
   
   string s;
   cin>>s;
   
   ll maxi = 0;
   
   for(ll i=0;i<n;i++)
   {
       string s1 = s.substr(i,n-i);
       ll z[s1.length()];
       zarr(s1,z);
       for(ll j=1;j<s1.length();j++)
       {
           ll i1 = i;
           ll i2 = j+i;
           
           ll temp = z[j];
           if(temp+i1-1>=i2)
                continue;
           maxi = max(temp,maxi);        
       }
   }
   
   cout<<maxi;
   
   return 0;
}

Measured memory_bytes: 384
package main

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

func main() {
	list := getStdinIntArr()
	A := list[0]
	B := list[1]
	H := list[2]
	M := list[3]

	aPosM := 60*H + M          // max 720
	bPosM := M % 60            // max 60
	bPosM = bPosM * (720 / 60) // to max 720

	if aPosM == bPosM {
		ans := math.Abs(float64(A) - float64(B))
		fmt.Printf("%.19f\n", ans)
	} else {
		AFloat := float64(A)
		BFloat := float64(B)
		aPosRad := 2.0 * math.Pi * float64(aPosM) / 720.0
		bPosRad := 2.0 * math.Pi * float64(bPosM) / 720.0
		rad := math.Abs(aPosRad - bPosRad)
		var ans float64 = 0
		ans += AFloat * AFloat
		ans += BFloat * BFloat
		ans -= 2.0 * AFloat * BFloat * math.Cos(rad)
		ans = math.Sqrt(ans)
		fmt.Printf("%.19f\n", ans)
	}
}

var sc = bufio.NewScanner(os.Stdin)

func getStdin() string {
	sc.Scan()
	return sc.Text()
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}


Measured memory_bytes: 1744
use std::io::{Read, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    let mut iter = input.split_whitespace();

    let _n: i32 = iter.next().unwrap().parse().unwrap();
    let a: Vec<&str> = iter.rev().collect();
    out.write(a.join(" ").as_bytes()).unwrap();
    out.write(b"\n").unwrap();

}



Measured memory_bytes: 5020
n,m = list(map(int, input().split()))
h = list(map(int, input().split())) 
ab =  [[int(_) for _ in input().split()] for __ in range(m)]

n_list =[x for x in range(1,n+1)]
ze = dict(zip(n_list, [0 for i in range(len(n_list))]))

for i in ab:
    if (h[i[0]-1]  > h[i[1]-1]):
        ze[i[1]] += 1
    elif (h[i[0]-1]  < h[i[1]-1]) :
        ze[i[0]] += 1
    elif h[i[0]-1]  == h[i[1]-1]:
        ze[i[0]] += 1
        ze[i[1]] += 1

res = 0
for k, v in ze.items():
    if v == 0:
        res += 1
print(res)

Measured memory_bytes: 43252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please



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

	string S;
	cin >> S;

	if (S[0] == S[1] || S[1] == S[2] || S[2] == S[3]) co("Bad");
	else co("Good");

	Would you please return 0;
}

Measured memory_bytes: 256
i=(input().split())
j=(input().split())
k=(input())

A=int(i[0])
V=int(i[1])
B=int(j[0])
W=int(j[1])
T=int(k)

if abs(B-A)+W*T <= V*T:
    print("YES")
elif abs(B-A)+W*T > V*T:
    print("NO")


Measured memory_bytes: 9192
n = gets.to_i
uppers = gets.split.map(&:to_i).sort
middles = gets.split.map(&:to_i).sort
lowers = gets.split.map(&:to_i).sort

middles_options = middles.map { |middle| uppers.bsearch_index { |item| middle <= item } || n }

cumulative_middles_options = []
middles_options.each_with_index do |middles_option, index|
  cumulative_middles_options << middles_option + (cumulative_middles_options[index - 1] || 0)
end

lower_middle_options = lowers.map { |lower| middles.bsearch_index { |item| lower <= item } || n }
lower_options =
  lower_middle_options.map do |lower_middle_option|
    if lower_middle_option == 0
      0
    else
      cumulative_middles_options[lower_middle_option - 1]
    end
  end

puts lower_options.inject(:+)


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

int main() {
	int A1, A2, A3;
	int ans;
	cin >> A1 >> A2 >>A3;

	ans = max({ A1 , A2 , A3 }) - min({ A1, A2, A3 });

	cout << ans;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
    cin >> n >> m >> k;
    n -= m;
    cout << n%k << endl;
    
}

Measured memory_bytes: 256
import copy

h, w = map(int, input().split())
dp = [list(map(int, input().split())) for _ in range(10)]

# ワーシャルフロイド法で更新がなくなるまで更新
while True:
    prev = copy.deepcopy(dp)
    for k in range(10):
        for i in range(10):
            for j in range(10):
                if i == j:
                    continue
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j])
    if prev == dp:
        break
    prev = dp

ans = 0
for i in range(h):
    arr = list(map(int, input().split()))
    ans += sum([dp[x][1] for x in arr if x != -1])

print(ans)

Measured memory_bytes: 3444
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <functional>
using namespace std;
const int num = 10000;
const int INF = 2000000000;
int c[num];
int pe[num];
int d[num];
typedef pair<int, int> p;
vector <p> v[num];
int main() {
	int n;
	cin >> n;
	fill(pe, pe + n, INF);
	fill(c, c + n, 0);
	fill(d, d + n, INF);
	d[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int w; cin >> w;
			if (w != -1) v[i].push_back(p(w, j));
		}
	}
	priority_queue <p, vector<p>, greater<p> > q;
	for (int i = 0; i < v[0].size(); i++) {
		q.push(p(v[0][i].first, v[0][i].second));
		d[v[0][i].second] = v[0][i].first;
		pe[v[0][i].second] = 0;
	}
	c[0] = 1;
	while (!q.empty()) {
		int f = q.top().first;
		int s = q.top().second;
		q.pop();
		c[s] = 1;
		if (d[s] < f) continue;
		for (int i = 0; i < v[s].size(); i++) {
			int fi = v[s][i].first;
			int se = v[s][i].second;
			if (c[se]) continue;
			if (pe[se] == INF || d[se] > fi) {
				d[se] = fi;
				pe[se] = s;
				q.push(p(fi, se));
			}
		}
	}
	int sum = 0;
	for (int i = 0; i < n; i++)
		sum += d[i];
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3340
#include <iostream>
#include <string>
using namespace std;
string s;
int k;
int main() 
{
	ios_base::sync_with_stdio(0);
	cin >> s >> k;
	for (int i=0; i<s.size(); i++)
	if (s[i]!='a')
	{
		if ('z'-s[i]+1<=k)
		{
			k-=('z'-s[i]+1);
			s[i]='a';
		}
	}
	s[s.size()-1]+=(k%26);
	if (s[s.size()-1]>'z') s[s.size()-1]-=26;
	cout << s;
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
string A, B;
ll ans = 1e18;

bool AllZero(string S) {
    for(auto c : S) {
        if(c != '0') return false;
    }
    return true;
}

int main() {
    cin >> A >> B;
    int N = A.size();
    if(AllZero(B) and !AllZero(A)) {
        cout << -1 << endl;
        return 0;
    }
    set<int> st;
    for(int i = 0; i < N; i++) {
        if(B[i] == '1') {
            for(int j = 0; j < 4; j++) {
                st.insert(j*N+i);
            }
        }
    }
    for(int shift = -N + 1; shift < N; shift++) {
        ll now = abs(shift);
        ll s = (shift + N) % N;
        //vector<l_l> v;
        vector<i_i> lv, rv;
        for(int i = 0; i < N; i++) {
            if(A[i] == B[(i+s)%N]) continue;
            now++;
            ll l, r;
            if(shift < 0) {
                l = i + 2 * N + shift;
                r = i + 2 * N + 1;
            } else {
                l = i + 2 * N;
                r = i + 2 * N + shift + 1;
            }
            //cerr << shift << " " << i << " " << l << " " << r << endl;
            auto itr = st.lower_bound(l);
            if(*itr < r) continue;
            //v.push_back({0, 0});
            itr--;
            lv.push_back({l - *itr, i});
            itr = st.lower_bound(r);
            //v.back().second = *itr - r + 1;
            rv.push_back({*itr - r + 1, i});
            //cerr << shift << " " << i << " " << lv.back() << " " << rv.back() << endl;
        }
        int num = lv.size();
        if(lv.empty()) {
            chmin(ans, now);
            continue;
        }
        map<int, int> mp;
        sort(lv.begin(), lv.end(), greater<i_i>());
        sort(rv.begin(), rv.end());
        for(auto tmp : lv) mp[tmp.second]++;
        ll nowans = now + lv[0].first * 2;
        chmin(ans, nowans);
        ll l = 0;
        ll r = 0;
        while(l < num) {
            mp[lv[l].second]--;
            if(mp[lv[l].second] == 0) mp.erase(lv[l].second);
            l++;
            while(mp.size() < num) {
                mp[rv[r].second]++;
                r++;
            }
            ll nowans = now;
            if(l < num) nowans += lv[l].first * 2;
            if(r > 0) nowans += rv[r-1].first * 2;
            chmin(ans, nowans);
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define ll long long
#define ull unsigned long long

#define	max	1000000007

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

class mod
{
public:
	ll val;

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

	mod()
	{
		val = 0;
	}

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

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

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

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

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

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

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

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

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

struct p
{
	ll a;
	int b;
	int c;
};

int main()
{
	string s;
	cin >> s;
	int n = s.length();
	int m = (n - 1) / 2 - 1;

	for (int i = 0; i < n; i++)
		if (s[i] != s[n - i - 1])
		{
			printf("No");
			return 0;

		}

	for (int i = 0; i <= m; i++)
		if (s[i] != s[m - i])
		{
			printf("No");
			return 0;
		}
	m = (n + 3) / 2 - 1;

	for (int i = n - 1, j = m; j < n; i--, j++)
		if (s[i] != s[j])
		{
			printf("No");
			return 0;
		}
	printf("Yes");
	return 0;
}


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

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

int gcd(int a,int b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}

int kaizyou(int N){
  int num=1;
  for(int i=1;i<=N;i++){
  num*=i;
  }
  return num;
}

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


signed main() {
  string n;
  cin >> n;
  bool ans=false;
  rep(i,3){
    if(n.at(i)=='7'){
      ans=true;
    }
  }
  if(ans){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
    
}

  
  
  

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	int h,c,j;
	h=a+b;
	c=a-b;
	j=a*b;
	if(h>=c&&h>=j)cout<<h<<endl;
	else if(c>=h&&c>=j)cout<<c<<endl;
	else if(j>=c&&j>=h)cout<<j<<endl;
	return 0;
}

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


Measured memory_bytes: 640