akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;
 
int main()
{
    while(true){
        int x, y, s;
        cin >> x >> y >> s;
 
        if(x==0 && y==0 && s==0)
            break;
 
        int tmax = -1;
 
        for(int a=1; a<=s-1; a++){
            int ax = a*(100+x)/100;
            int ay = a*(100+y)/100;
 
            for(int b=1; b<=s-1; b++){
                int bx = b*(100+x)/100;
                int by = b*(100+y)/100;
 
                if(ax+bx==s){
                    tmax = max(tmax, ay+by);
                }
                else if(ax+bx>s){
                    break;
                }
            }
        }
 
        cout << tmax << endl;
    }
 
    return 0;
}


Measured memory_bytes: 3092
S = input()
N = len(S)
ans = 0
cnt = 0
i = 0
while i < N:
  if S[i] == "A":
    cnt += 1
    i += 1
  elif "".join(S[i:i+2]) == "BC":
    ans += cnt
    i += 2
  else:
    cnt = 0
    i += 1
print(ans)

Measured memory_bytes: 41564
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int cnt[200010];

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  int n = s.size();
  int cu = 0;
  int dg = 1;
  ll ans = 0;
  REPR(i,n-1){
    cu = (cu + dg * (s[i]-'0')) % 2019;
    dg = (dg * 10) % 2019;
    ans += cnt[cu];
    if(cu==0) ans++;
    cnt[cu]++;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3792
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 200010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,c,k;
    cin >> n >> c >> k;
    vector<ll> t(n);
    cins(all(t));
    SORT(t);
    ll cnt = 0,l = t[0],ans = 1;
    rep(i,n){
        if (cnt < c && l <= t[i] && t[i] <= l+k){
            cnt++;
        }
        else{
            cnt = 1;
            l = t[i];
            ans++;
        }
    }
    PRINT(ans);
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-

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

a_list, b_list, c_list, d_list = [], [], [], []

#student
for i in range(N):
	a, b = map(int, input().split())
	a_list.append(a)
	b_list.append(b)

#checkpoint
for i in range(M):
	c, d = map(int, input().split())
	c_list.append(c)
	d_list.append(d)

for j in range(N):
	dist = []
	for k in range(M):
		dist.append(abs(a_list[j] - c_list[k]) + abs(b_list[j] - d_list[k]))
	print(dist.index(min(dist))+1)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b,k;
  cin>>a>>b>>k;
  cout<<max(0ll,a-k)<<" "<<max(0ll,min(b,a+b-k))<<endl;

  return 0;

}


Measured memory_bytes: 256
n=int(input())
a=[int(input()) for _ in [0]*n]
temp=[]
cnt=0
import bisect
for i in range(n):
    b=bisect.bisect(temp,-a[i])
    if b==cnt:
        temp.append(-a[i])
        cnt+=1
    else:
        temp[b]=-a[i]
print(len(temp))

Measured memory_bytes: 10892
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef pair<LL, LL> PII;
typedef vector<string> VS;
inline LL toInt(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(x,c) for(auto x: (c))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define ALL(c) (c).begin(), (c).end()
#define REVERSE(c) reverse(ALL(c))
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define STABLE_SORT(c) stable_sort(ALL(c))
#define STABLE_RSORT(c) stable_sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)), (c).end());
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x)  cerr << #x << " = " << (x) << endl;


int main() {
    LL N, C, K;
    cin >> N >> C >> K;
    VI T(N);
    REP(i, N) {
        cin >> T[i];
    }
    SORT(T);
    /*REP(i, N) {
        dump(T[i]);
        }*/
    LL ans = 0, index = 0, index_tmp = 0, capacity = 0;
    while (index < N) {
        if (capacity > 0 && T[index] <= T[index_tmp] + K) {
            capacity--;
            index++;
        } else {
            ans++;
            index_tmp = index;
            capacity = C;
        } 
        /*dump(index);
        dump(T[index]);
        dump(index_tmp);
        dump(T[index_tmp]);
        dump(capacity);
        dump(ans);*/
    }
    cout << ans << endl;
	
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#define L 100
#define MAX 1000000
typedef struct pp{
	char name[L];
	int time;
}p;
void enqueue(p);
p dequeue();
int calct(int,int);
int n,q,i,head=1,tail=0,max,ctime,stime;
p Q[MAX];
int main(){
  scanf("%d%d",&n,&q);
  tail = n+1;
  max = n;
  p nowq;
  for(i=1;i<=n;i++){
  	scanf("%s",Q[i].name);
  	scanf("%d",&Q[i].time);
  }
  while(head != tail){
  	nowq = dequeue();
  	ctime = calct(q,nowq.time);
  	stime += ctime;
  	nowq.time -= ctime;
  	if(nowq.time > 0)enqueue(nowq);
  	else printf("%s %d\n",nowq.name,stime);
  }
  return 0;
}
void enqueue(p now){
	Q[tail] = now;
	tail=(tail+1)%MAX;
}
p dequeue(){
	p temp=Q[head];
	head=(head+1)%MAX;
    return temp;
}
int calct(int q,int time){
  if(q < time) return q;
  return time;
}


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

vector<vector<int>> v(200010);
int ans[200020];
int cnt[3];
bool pos = true;

int dep[3][200020];
int t[200020];

void dfs(int p,int pre,int now){
    t[p] = now;
    for(auto i:v[p]){
        if(i!=pre){
            dfs(i,p,now+1);
        }
    }
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
    
    
    int n;
    cin>>n;
    for(int i=1;i<n;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    cnt[0] = n/3;
    cnt[1] = n/3;
    cnt[2] = n/3;
    if(n%3)cnt[1]++;
    if(n%3==2)cnt[2]++;
    int c = 0;
    dfs(0,-1,1);
    for(int i=0;i<n;i++)if(t[i]%2)c++;
    if(c <= n/3 || (n-c) <= n/3){
        int y = 1;
        if(c > n/3) y = 0;
        for(int i=0;i<n;i++){
            if(t[i]%2==y){
                ans[i] = 3;
            }
            else{
                if(cnt[1]){
                    ans[i] = 1;
                    cnt[1]--;
                }
                else if(cnt[2]){
                    cnt[2]--;
                    ans[i] = 2;
                }
                else{
                    ans[i] = 3;
                }
            }
        } 
    }else{
        for(int i=0;i<n;i++){
            if(t[i]%2){
                if(cnt[1]==0){
                    ans[i] = 3;
                    continue;
                }
                ans[i] = 1;
                cnt[1]--;
            }
            else{
                if(cnt[2]==0){
                    ans[i] = 3;
                    continue;
                }
                ans[i] = 2;
                cnt[2]--;
            }
        }
    }
    int now[3]={};
    now[0]=3,now[1]=1,now[2]=2;
    for(int i=0;i<n;i++){
        int p = ans[i] % 3;
        ans[i] = now[p];
        now[p] += 3;
        cout << ans[i] << " ";
    }
    cout << endl;

}

Measured memory_bytes: 19072
#include<cstdio>
#include<cmath>
#define RI register int
#define CI const int&
using namespace std;
const int N=3005;
const double pi=acos(-1);
int n,l,t[N],cur; double ansx,ansy;
int main()
{
	RI i,j; for (scanf("%d%d",&n,&l),i=1;i<=n;++i) scanf("%d",&t[i]);
	for (i=1;i<n;++i) for (cur=0,j=i+1;j<=n;++j,++cur)
	{
		ansx+=1.0*(n-2-cur)*cos(pi*(t[i]+t[j])/l)/(n-2);
		ansy+=1.0*(n-2-cur)*sin(pi*(t[i]+t[j])/l)/(n-2);
		ansx-=1.0*cur*cos(pi*(t[i]+t[j])/l)/(n-2);
		ansy-=1.0*cur*sin(pi*(t[i]+t[j])/l)/(n-2);
	}
	double ct=1.0*n*(n-1)/2.0; ansx/=ct; ansy/=ct;
	return printf("%.16lf %.16lf",3.0*ansx,3.0*ansy),0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
int i, j, n, a[100],v[100],l=0;
bool check(int,int);
int main() {
	int n;
	bool bo;
	cin >> n;
	for (int i = 3; i <= n; i++) {
		bo=check(n,i);
		if (bo == true) {
			cout <<" "<< i;
		}
		else if (bo == false) {
			continue;
		}
	}
	cout << endl;
	return 0;
}
bool check(int n,int i) {
	int count=0,amari,last;
	while (1) {
		if (count == 0) {
			amari = i % 3;
		}
		last = i % 10;
		if (amari == 0 || last==3 || i == 3) {
			return true;
		}
		else if (amari != 0 && count==5) {
			return false;
		}
		else if (i != 3 && count < 5) {
			count++;
		}
		i/=10;
		
	}
}

Measured memory_bytes: 3092
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<climits>
#include<string>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<algorithm>

#define ll long long
#define sz 205

using namespace std;

int main()
{
    char str[sz];

    scanf("%s",str);

    ll frq[sz],flag=0;
    memset(frq,0,sizeof(frq));

    for(ll i=0; i<strlen(str); i++)
    {
        frq[str[i]]++;

        if(frq[str[i]]>1)
        {
            flag=1;
            break;
        }
    }

    if(flag)
        printf("no\n");

    else
        printf("yes\n");

    return (0);
}




Measured memory_bytes: 256
#!/usr/bin/perl
use strict;
use warnings;
use feature qw(:5.10);
use utf8;
use List::Util qw/min/;

<STDIN>;
my @dr;
{
    my $dr = <STDIN>;
    @dr = split(/\s+/, $dr);
}
my @rz;
{
    my $rz = <STDIN>;
    @rz = split(/\s+/, $rz);
}
my @wari;
while(<STDIN>){
    my @w = split(/\s+/);
    push(@wari, \@w);
}

my @result;
push(@result, min(@dr) + min(@rz));

for (@wari){
    my @w = @{$_};
    push(@result, $dr[$w[0]-1] + $rz[$w[1]-1] - $w[2]);
}
say min(@result);


Measured memory_bytes: 64520
function Main(input) {
  input.trim();
  input = input.split(" ").map(Number);
  var arr = new Array(input[0]).fill(114514);
  for(var i=0;i<input[1];i++){
    arr[i] = input[2];
  }
  console.log(arr.join(" "));
}Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());
function arr1dto2d (arr){
	for(var i=0;i<arr.length;i++){
    arr[i]=arr[i].split(" ").map(Number);
    }
  return arr;
}

Measured memory_bytes: 22216
import math
N = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

def counter(p):
    c = 0
    used = [0 for _ in range(N)]
    for i in range(N):
        used[p[i] - 1] = 1
        for k in range(1, p[i]):
            if used[k - 1] != 1:
                c += math.factorial(N - (i + 1))
    
    return c

print(abs(counter(p) - counter(q)))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long int

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N; cin >> N;
	int T[N], A[N];
	rep(i, N) cin >> T[i];
	rep(i, N) cin >> A[i];

	int Tlow[N];
	int Alow[N];

	rep(i, N) {
		if (i == 0) {
			Tlow[i] = T[i];
		}
		else {
			if (T[i] - T[i - 1] != 0) {
				Tlow[i] = T[i];
			}
			else {
				Tlow[i] = 1;
			}
		}
	}
	rrep(i, N - 1) {
		if (i == N - 1) {
			Alow[i] = A[i];
		}
		else {
			if (A[i] - A[i + 1] != 0) {
				Alow[i] = A[i];
			}
			else {
				Alow[i] = 1;
			}
		}
	}
	int ans = 1;
	rep(i, N) {
		int m = max(Alow[i], Tlow[i]);
		int M = min(A[i], T[i]);
		if (m > M) {
			cout << 0 << endl;
			return 0;
		}
		else {
			ans *= (M - m) + 1;
			ans %= mod;
		}
	}
	/*
	rep(i, N) cout << Tlow[i] << " ";
	cout << endl;
	rep(i, N) cout << Alow[i] << " ";
	cout << endl;
	*/
	cout << ans << endl;
    return 0;
}


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

template<typename T>
vector<vector<T>> Make2DVector(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

// Vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  s << "[";
	for (int i = 0; i < len; i++) {
    if (i > 0) s << ", ";
		s << v[i];
  }
  s << "]";
  return s;
}

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

  string s;
  cin >> s;
  vector<int> xs;
  for (char c : s) xs.push_back(c - 'a');

  int n = xs.size();
  auto dp = Make2DVector(n, 26, n);
  dp[n - 1][xs[n - 1]] = n - 1;
  for (int i = n - 2; i >= 0; i--) {
    for (int j = 0; j < 26; j++) {
      dp[i][j] = dp[i + 1][j];
    }
    dp[i][xs[i]] = i;
  }

  auto get_ans_fn = [&]() -> vector<int> {
    vector<int> prevs(n, -2);
    deque<int> q;
    q.push_back(-1);
    vector<int> visited(n);

    auto dump_path_fn = [&](int k) -> vector<int> {
      vector<int> path;
      while (k >= 0) {
        // cout << "k: " << k << endl;
        path.push_back(xs[k]);
        k = prevs[k];
      }
      reverse(path.begin(), path.end());
      return path;
    };

    while (!q.empty()) {
      int i = q.front();
      q.pop_front();
      if (i + 1 >= n) {
        auto path = dump_path_fn(i);
        path.push_back(0);
        return path;
      }
      for (int j = 0; j < 26; j++) {
        int k = dp[i + 1][j];
        if (k >= n) {
          auto path = dump_path_fn(i);
          path.push_back(j);
          return path;
        }

        if (visited[k]) continue;
        prevs[k] = i;
        q.push_back(k);
        visited[k] = 1;
      }
    }
    cerr << "Unexpected!" << endl;
    exit(1);
  };

  auto ans = get_ans_fn();
  for (int x : ans) {
    cout << static_cast<char>('a' + x);
  }
  cout << endl;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int a[4], b[4] = { 1, 4, 7, 9 };

int main() {
	inc(i, 4) { cin >> a[i]; }
	
	sort(a, a + 4);
	
	bool f = true;
	inc(i, 4) { f &= (a[i] == b[i]); }
	
	cout << (f ? "YES" : "NO") << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <deque>
#include <stack>
#include <queue>
#define ll long long
#define start() ll z;scanf("%d",&z);while(z--)
#define fo(var, start, end) for(int var = start; var < end; var++)
#define foo(var, start, end) for(int var = start; var < = end; var++)
#define fi(var, end, start) for(var = end; var >=start ; var--)
using namespace std;
void solve(){
}
int main() {
//    start(){
//        solve();
//    }
    map<string,int> c;
    int n;
    string s;
    scanf("%d",&n);
    fo(i,0,n){
        cin>>s;
        c[s]=1;
    }
    int ans=c.size();
    printf("%d",ans);

    return 0;
}

Measured memory_bytes: 18920
#pragma GCC optimize "03"
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif

const int N = 1e5 + 5;
const int mod = 1e9 + 7;

int dp[N], h[N];

signed main() {
	#ifdef LOCAL
		freopen("input.txt","r",stdin);
	#endif
	IOS;
	int n;	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> h[i];	
		dp[i] = mod;
		if(i == 1)
			dp[i] = 0;
		if(i > 1)
			dp[i] = min(dp[i], dp[i-1] + abs(h[i-1] - h[i]));
		if(i > 2)
			dp[i] = min(dp[i], dp[i-2] + abs(h[i-2] - h[i]));
	}
	cout << dp[n];
	return 0;
}

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

using namespace std;
typedef long long ll;

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

int main()
{
    int n, m, x;
    cin >> n >> m >> x;
    vector<int> a(m);
    rep(i, m) cin >> a[i];
    a.push_back(x);
    sort(all(a));

    int res;
    rep(i, m + 1) if (a[i] == x) res = i;

    cout << min(res, m - res) << '\n';
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n+1);
  for (int i = 1; i <= n; i++) cin >> a[i];

  vector<bool> t(n+1, false);
  vector<int> x(n+1);

  x[0] = 1;
  t[1] = true;
  int ans;
  for (int i = 1; i <= n+1; i++) {
    if (i == k) {
      ans = a[x[i-1]];
      break;
    }
    if (t[a[x[i-1]]]) {
      auto itr = find(x.begin(), x.end(), a[x[i-1]]);
      int index = distance(x.begin(), itr);
      //cout << index << endl;
      int num = (k-i)%(i-index);
      //cout << num << endl;
      ans = x[index+num];
      break;
    }
    x[i] = a[x[i-1]];
    t[x[i]] = true;
  }

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

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

int main() {
  int64_t N,r=0,g=0,b=0,sum=0;
  char c;
  cin >> N;
  vector<int64_t>R(N,0);
  vector<int64_t>G(N,0);
  vector<int64_t>B(N,0);
  vector<char>Color(N,' ');
  for(int i=0;i<N;i++){
    cin >> c;
    if(c=='R'){
      Color.at(i)='R';
      R.at(r)=i;
      r++;
    }
    if(c=='G'){
      Color.at(i)='G';
      G.at(g)=i;
      g++;
    }
    if(c=='B'){
      Color.at(i)='B';
      B.at(b)=i;
      b++;
    }
  }
  for(int i=0;i<r;i++){
    for(int j=0;j<g;j++){
      sum+=b;
      if(0<=2*G.at(j)-R.at(i)&&2*G.at(j)-R.at(i)<=N-1&&Color.at(max(N-N,min(N-1,2*G.at(j)-R.at(i))))=='B'){
        sum--;
      }
      if(0<=2*R.at(i)-G.at(j)&&2*R.at(i)-G.at(j)<=N-1&&Color.at(max(N-N,min(N-1,2*R.at(i)-G.at(j))))=='B'){
        sum--;
      }
      if((R.at(i)+G.at(j))%2==0&&Color.at(max(N-N,min(N-1,(R.at(i)+G.at(j))/2)))=='B'){
        sum--;
      }
    }
  }
  cout << sum << endl;
}

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

int main() {
    long n, k, temp = 0, ans = LONG_MAX;
    cin >> n >> k;
    vector<long> h(n);
    rep(i, n) cin >> h.at(i);
    sort(h.begin(), h.end());
    rep(i, n - k + 1) {
        temp = h.at(k + i - 1) - h.at(i);
        ans = min(ans, temp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define Test int t;cin>>t;while(t--)
#define PI acos(-1)
#define endl "\n"
#define fx(x) fixed<<setprecision(x)
#define sz(s) s.size()
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
const double eps=1e-9;
const int mod=1e9+7;
int dx[]={-1,-1,-1,0,0,1,1,1};
int dy[]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll x,ll y) {return(!y)?x:gcd(y,x%y);}
ll lcm(ll x,ll y) {return((x/gcd(x,y))*y);}
using namespace std;
void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
const int N=(int)1e5+10;
int dp[3][N];
int a[N],b[N],c[N],n;
int solve(int p,int idx){
    if(idx==n)return 0;
    int &ret=dp[p][idx];
    if(ret)return ret;
    if(p==0)ret=a[idx];
    else if(p==1)ret=b[idx];
    else ret=c[idx];
    idx++;
    if(p==0)ret+=max(solve(1,idx),solve(2,idx));
    else if(p==1)ret+=max(solve(0,idx),solve(2,idx));
    else if(p==2)ret+=max(solve(0,idx),solve(1,idx));
    return ret;
}
int main()
{
    fast();
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i]>>c[i];
    }
    int ans;
    ans=max({solve(0,0),solve(1,0),solve(2,0)});
    cout<<ans;
    return 0;
}


Measured memory_bytes: 10656
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}

int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	int n;
	cin>>n;
	int arr[n];
	for (int i = 0; i < n; i++){
		cin>>arr[i];
	}
	sort(arr,arr+n);
	int count=0;
	for (int i = 0; i < n; i++){
		for (int j = i+1; j < n; j++){
			for (int k = j+1; k < n; k++){
				if( arr[i] == arr[j] || arr[i] == arr[k] || arr[j] == arr[k])
					continue;
				if(arr [i] + arr [j] > arr[k] )
					count++;
			}
		}
	}
	cout<<count<<endl;
	
}

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

signed main() {
  int N, M; cin >> N >> M;
  priority_queue<int> A;
  int a = 0;
  rep(i, N) {
    cin >> a;
    A.push(a);
  }

  int ans = 0;

  rep(i, M) {
    a = A.top();
    a /= 2;
    A.pop();
    A.push(a);
  }
  
  //ans = accumulate(all(A), 0);
  rep(i, N) {
    ans += A.top();
    A.pop();
  }
  
  cout << ans << endl;

}

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

const int mod = 1000000007;
// const int mod = 998244353;

struct mint
{
    ll x;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint &operator+=(const mint m)
    {
        if((x += m.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator-=(const mint m)
    {
        if((x += mod - m.x) >= mod) x -= mod;
        return *this;
    }
    mint &operator*=(const mint m)
    {
        (x *= m.x) %= mod;
        return *this;
    }
    mint operator+(const mint m) const
    {
        return mint(*this) += m;
    }
    mint operator-(const mint m) const
    {
        return mint(*this) -= m;
    }
    mint operator*(const mint m) const
    {
        return mint(*this) *= m;
    }
    mint pow(ll n) const
    {
        if(!n) return 1;
        mint m = pow(n>>1);
        m *= m;
        if(n & 1) m *= *this;
        return m;
    }
    mint inv() const { return pow(mod-2);}
    mint &operator/=(const mint m) { return *this *= m.inv();}
    mint operator/(const mint m) const { return mint(*this) /= m;}
};
istream &operator>>(istream &is, mint &m) { return is >> m.x;}
ostream &operator<<(ostream &os, const mint &m) { return os << m.x;}

struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n+1), ifact(n+1)
    {
        assert(n < mod);
        fact.at(0) = 1;
        for(int i=1; i<=n; i++)
        {
            fact.at(i) = fact.at(i-1) * i;
        }
        ifact.at(n) = fact.at(n).inv();
        for(int i=n; i>=1; i--)
        {
            ifact.at(i-1) = ifact.at(i) * i;
        }
    }
    mint operator()(int n, int k)
    {
        if(k < 0 || k > n) return 0;
        return fact.at(n) * ifact.at(k) * ifact.at(n-k);
    }
};

struct permutation
{
    vector<mint> fact, ifact;
    permutation(int n) : fact(n+1), ifact(n+1)
    {
        assert(n < mod);
        fact.at(0) = 1;
        for(int i=1; i<=n; i++)
        {
            fact.at(i) = fact.at(i-1) * i;
        }
        ifact.at(n) = fact.at(n).inv();
        for(int i=n; i>=1; i--)
        {
            ifact.at(i-1) = ifact.at(i) * i;
        }
    }
    mint operator()(int n, int k)
    {
        if(k < 0 || k > n) return 0;
        return fact.at(n) * ifact.at(n-k);
    }
};

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    cin >> N >> M;

    combination comb(N);
    permutation perm(M);

    mint ans = 0;
    for(int i=0; i<=N; i++)
    {
        ans += comb(N, i) * perm(M, i) * perm(M-i, N-i) * perm(M-i, N-i) * (i%2==1 ? -1 : 1);
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main(void){
	int N,K,ans = 0;
	cin >> N >> K;
	vector<int> a(N);
	for(int i=0;i<N;i++)cin >> a[i];
	for(int l=0;l<=K;l++){
		for(int r=0;r<=K-l;r++){
			if( (l+r)>N)continue;
			int d = K - l - r;
			int now = 0;
			vector<int> s;
			for(int i=0;i<l;i++){
				now += a[i];
				s.push_back(a[i]);
			}
			for(int i=N-r;i<N;i++){
				now += a[i];
				s.push_back(a[i]);
			}
			sort(s.begin(),s.end());
			for(int i=0;i<d;i++){
				if(i>=s.size())break;
				if(s[i]>=0)break;
				else now -= s[i];
			}
			ans = max(ans,now);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int min(int a,int b){
	if(a<=b){return a;}
	else{return b;}
}

int main() {

	int A,B,C,D;

	scanf("%d",&A);
	scanf("%d",&B);
	scanf("%d",&C);
	scanf("%d",&D);

	printf("%d\n",min(A,B)+min(C,D));

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
const int INF = 1001001001;
bool isok(vector<int> c, int x){
  for(int i = 0; i < c.size(); ++i){
    if(c[i] < x) return false;
  }
  return true;
}
int main(){
  int n, m, x; cin >> n >> m >> x;
  vector<int> p(n);
  vector<vector<int>> v(n, vector<int>(m));
  for(int i = 0; i < n; ++i){
    cin >> p[i];
    for(int j = 0; j < m; ++j){
      cin >> v[i][j]; 
    }
  }
  int min_p = INF;
  int temp;
  for (int bit = 0; bit < (1<<n); ++bit){
    vector<int> check(m, 0);
    temp = 0;
    for (int i = 0; i < n; ++i) {
      if (bit & (1<<i)) {
        temp += p[i];
        for(int j = 0; j < m; ++j){ 
          check[j] += v[i][j];
        }
      }
    }
    if(isok(check, x)) min_p = min(min_p, temp); 
  }
  cout << (min_p == INF ? -1 : min_p) << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

vector<ll> fac(MAX), finv(MAX), inv(MAX);

int main(){
	ll a,b; cin >> a >> b;
	for(ll i=1; i<=50000; i++){
		ll u = i * 8 / 100;
		ll v = i * 10 / 100;
		if(u==a && v==b){
			cout << i << endl;
			return 0;
		}
	}
	cout << -1 << endl;
}

Measured memory_bytes: 12160
#define _USE_MATH_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using namespace std;

int main() {
    string S;
    cin >> S;
    for (char c = 'a'; c <= 'z'; c++) {
        if (find(S.begin(), S.end(), c) == S.end()) {
            cout << c << endl;
            return 0;
        }
    }

    cout << "None" << endl;

    return 0;
}

Measured memory_bytes: 512
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static class Move {
		int fx, fy, gx, gy;
		
		public Move(int fx, int fy, int gx, int gy) {
			this.fx = fx;
			this.fy = fy;
			this.gx = gx;
			this.gy = gy;
		}
		
		public String toString() {
			return this.fy + " " + this.fx + " " + this.gy + " " + this.gx;
		}
	}
	
	public static int[][] move_dirs = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
	public static boolean in_range(int x, int y, int W, int H) {
		return 0 <= x && x < W && 0 <= y && y < H;
	}
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			
			final int N = sc.nextInt();
			
			int[] array = new int[N];
			for(int i = 0; i < N; i++) {
				array[i] = sc.nextInt();
			}
			
			final int sum = Arrays.stream(array).sum();
			
			int idx = -1, diff = Integer.MAX_VALUE;
			for(int i = 0; i < N; i++) {
				if(Math.abs(N * array[i] - sum) < diff) {
					idx = i;
					diff = Math.abs(N * array[i] - sum);
				}
			}
			
			System.out.println(idx);
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 26964
A, B, M = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = []
for i in range(M):
    x, y, c = map(int,input().split())
    z = a[x - 1] + b[y - 1] - c
    ans.append(z)
z = min(a) + min(b)
ans.append(z)
ans = sorted(ans)
print(ans[0])

Measured memory_bytes: 24760
#include<bits/stdc++.h>
using namespace std;
int n;
int maxHappiness(int ind, int flag, vector<vector<int>> &dp, int *a, int *b, int *c) {
    if (ind == n) {
        return 0;
    }
    if (dp[ind][flag] != -1) {
        return dp[ind][flag];
    }
    if (flag == 0) {
        return dp[ind][flag] = max(max(a[ind]+maxHappiness(ind+1, 1, dp, a, b, c),
        b[ind]+maxHappiness(ind+1, 2, dp, a, b, c)), c[ind]+maxHappiness(ind+1, 3, dp, a, b, c));
    } else if (flag == 1) {
        return dp[ind][flag] = max(b[ind]+maxHappiness(ind+1, 2, dp, a, b, c), c[ind]+maxHappiness(ind+1, 3, dp, a, b, c));
    } else if (flag == 2) {
        return dp[ind][flag] = max(a[ind]+maxHappiness(ind+1, 1, dp, a, b, c), c[ind]+maxHappiness(ind+1, 3, dp, a, b, c));
    } else if (flag == 3) {
        return dp[ind][flag] = max(a[ind]+maxHappiness(ind+1, 1, dp, a, b, c), b[ind]+maxHappiness(ind+1, 2, dp, a, b, c));
    }
}
int main() {
    cin>>n;
    int a[n], b[n], c[n];
    vector<vector<int>> dp(n, vector<int>(4, -1));
    for (int i=0;i<n;i++) {
        cin>>a[i]>>b[i]>>c[i];
    }
    cout<<maxHappiness(0, 0, dp, a, b, c);
    return 0;
}


Measured memory_bytes: 19360
/*@shutoshsuman99*/
#include<bits/stdc++.h>
using namespace std;
#include<cstdio>
#define pi 3.141592653589
#define pb push_back
#define ld long double
#define rem 1000000007
#define rem1 998244353
#define inf 1e18+1e17
#define F first
#define S second
#define pii pair<long long,long long>
#define p_q priority_queue <ll, vector<ll>, greater<ll> >
#define m_sp multiset <pair <ll,ll> > 
#define el "\n"
#define sp " "
typedef long long ll;
ll Pow(ll x,ll y,ll m) 
{ if (y == 0) return 1; ll p = Pow(x, y/2, m) % m; 
p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m; }
int main()
{
	ll i,n,ans=0,cnt=0;
	string s;
	cin>>s;
	for(i=0;i<s.size()-1;i++)
	{
		if(s[i]=='A')
		cnt++;
		else if(s[i]=='B'&&s[i+1]=='C')
		ans+=cnt,i++;
		else
		cnt=0;
	}
	cout<<ans<<el;
}


Measured memory_bytes: 640
#define _CRT_SECURE_NO_DEPRECATE
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <bitset>
#include <cmath>
#include <ctime>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <sstream>
#include <chrono>
#include <functional>
#include <random>
#include <numeric>
#include <tuple>
#include <bitset>
using namespace std;
#define sz(v) ((int)((v).size()))
#define all(v) (v).begin(),(v).end()
typedef long long ll;
typedef pair<int, int> ii;
template<class T> string toString(T x) { ostringstream ss; ss << x; return ss.str(); }
void solve();
int main() {
#ifdef LOCAL_COMP
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);
	solve();
#ifdef LOCAL_COMP
	cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec" << endl;
#endif
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void solve() {
	string t = "keyence";
	string s;
	while (cin >> s) {
		for (int prefLen = 0; prefLen <= 7; prefLen++) {
			int suffLen = 7 - prefLen;
			bool ok = true;
			if (prefLen > 0) {
				if (s.substr(0, prefLen) != t.substr(0, prefLen)) {
					ok = false;
				}
			}
			if (suffLen > 0) {
				if (s.substr(sz(s) - suffLen, suffLen) != t.substr(sz(t) - suffLen, suffLen)) {
					ok = false;
				}
			}
			if (ok) {
				cout << "YES" << endl;
				goto end;
			}
		}
		cout << "NO" << endl;
		end:;
	}
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Collections;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] a = sc.next().toCharArray();
        for (int i = 0; i < a.length; i++) {
            if (a[i] == '7') {
                System.out.println("Yes");
                return;
            }
        }

        System.out.println("No");

    }
}


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

#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define FORR(i, m, n) for(int i = m; i >= n; --i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

#define INF 999999999

using namespace std;

typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){
    cin.tie(0); //cinとcoutの同期切り
    ios::sync_with_stdio(false); //iostreamとstdioの同期切り

    int X;
    cin >> X;

    int ans = 1;
    for(int b = 2; b <= sqrt(X); ++b){
        int a = 1;
        while(a <= X){
            a = a*b;
        }
        a = a/b;
        ans = max(ans, a);
    }

    cout << ans << endl;

    return 0;
}

/*****************************************************************************/
/*****   1秒間で処理できるfor文ループの回数                                 *****/
/*****   → 10^8 = 100,000,000 回程度                                      *****/
/*****                                                                   *****/
/*****   sort(a, a+N, greater<int>()); // a[0:N) を大きい順にソート        *****/
/*****                                                                   *****/
/*****                                                                   *****/
/*****   std::cout << std::setprecision(2) << 3.0; // "3"                *****/
/*****   std::cout << std::fixed;                                        *****/
/*****   std::cout << std::setprecision(2) << 3.0; // "3.00"             *****/
/*****                                                                   *****/
/*****************************************************************************/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

namespace templates{
  ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
      if(b&1)res = res * x % MOD;
      x = x * x % MOD;
      b>>=1;
    }
    return res;
  }

  ll modinv(ll x){
    return modpow(x, MOD-2);
  }

  bool was_output = false;
  template<class t>
  void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
  }
  void outendl(){
    was_output = false;
    cout << endl;
  }
  ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
  }

  template<class t>
  istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
  }

  template<class t, class u>
  istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
  }

  template<class t>
  void in(t&x){
    cin >> x;
  }

  template<class t>
  t in(){
    t res; cin >> res; return res;
  }

  template<class t>
  void out(t x){
    cout << x;
  }

  template<class t>
  vector<t> sorted(vector<t> line,function<bool(t,t)> comp=[](t a,t b){return a<b;}){
    sort(line.begin(),line.end(),comp);
    return line;
  }

  template<class t>
  vector<t> reversed(vector<t> line){
    reverse(line.begin(),line.end());
    return line;
  }
}

using namespace templates;

int main(){
  double d = in<double>();
  double ans = d * sqrt(2);
  for(int y=1;y<=d;++y){
    double x = sqrt(d*d-y*y);
    if(x<1)x=1;
    chmax(ans,y+x);
  }
  printf("%.20lf\n",ans);
  return 0;
}



Measured memory_bytes: 3208
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.function.Function;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        int n = Integer.parseInt(stdin.nextLine());
        Map<Integer, Long> d = Pattern.compile(" ")
                                      .splitAsStream(stdin.nextLine())
                                      .map(Integer::new)
                                      .collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
        List<Integer> keys = d.keySet().stream().sorted().collect(Collectors.toList());
        int m = 0;
        for (int i = 0; i < keys.size(); i++) {
            Integer key = keys.get(i);
            m += d.get(key);
            if (n / 2 == m) {
                System.out.println(keys.get(i + 1) - (key + 1) + 1);
                System.exit(0);
            }
        }
        System.out.println(0);
    }

}


Measured memory_bytes: 48300
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, M;
  cin >> N >> M;
  vll dp((1 << 12), INF);
  dp.at(0) = 0LL;
  for(int i = 0; i < M; i++){
    int flag = 0;
    ll a, b;
    cin >> a >> b;
    for(int j = 0; j < b; j++){
      int c;
      cin >> c; c--;
      flag |= (1 << c);
    }
    for(int j = 0; j < (1 << 12); j++){
      chmin(dp.at(j|flag), dp.at(j) + a);
    }
  }
  if(dp.at((1<<N)-1) == INF) cout << -1 << endl;
  else cout  << dp.at((1<<N)-1) << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
const ll MOD=1e9+7;
const double PI=acos(-1.0);
//----------------------------------------------------------------------------------------------------------------------------------//

int main(){
        ll n;
        cin>>n;
        ll i=n/11;
        ll j=n%11;
        if(j==0) {
                cout<<2*i<<endl;
        }else if(j<=6) {
                cout<<2*i+1<<endl;
        }else{
                cout<<2*i+2<<endl;
        }
}


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

const int maxn = 100010;
int n;
long long a[maxn], b[maxn];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%lld %lld", &a[i], &b[i]);
    }
    long long ans = 0;
    for (int i = n; i; i--) {
        a[i] += ans;
        ans += (b[i] - a[i] % b[i]) % b[i];
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 5296
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

struct edge {
    ll from;
    ll to;
    ll cost;
};


typedef pair<int, int> P;  // first: 最短距離, second: 頂点番号

ll V, E;
ll d1[MAX];
ll d2[MAX];
edge es1[MAX];
edge es2[MAX];
vector<bool> v;

bool has_negative_loop1(ll s) {
    fill(d1, d1 + V, INF);
    d1[s] = 0;
    for (ll i = 0; i < 2 * V; i++) {
        for (ll j = 0; j < E; j++) {
            edge e = es1[j];
            if (d1[e.to] > d1[e.from] + e.cost and d1[e.from] != INF) {
                d1[e.to] = d1[e.from] + e.cost;
                if (i == V - 1) {
                  return true;
                }
            }
        }
    }
    return false;
}

bool has_negative_loop2(ll s) {
    fill(d2, d2 + V, INF);
    d2[s] = 0;
    for (ll i = 0; i < V; i++) {
        for (ll j = 0; j < E; j++) {
            edge e = es2[j];
            if (d2[e.to] > d2[e.from] + e.cost and d2[e.from] != INF and v[e.to] == true ){
                d2[e.to] = d2[e.from] + e.cost;
                if (i == V - 1) {
                  return true;
                }
            }
        }
    }
    return false;
}

int main(){
  cin>>V;
  int P;cin>>E>>P;
  int M = E;
  rep(i,M){
    int from, to, cost;
    cin>>from>>to>>cost;
    from--;to--;cost-=P;
    es1[i] = edge({to, from, -cost});
    es2[i] = edge({from, to, -cost});
  }

  has_negative_loop1(V-1);

  v.resize(V);
  rep(i,v.size()) v[i] = false;
  rep(i,V){
    if(d1[i] != INF){
      v[i] = true;
    }
  }

  if(has_negative_loop2(0)){
    cout<<-1<<endl;
    return 0;
  }
  else{
    if(d2[V-1] > 0) cout<<0<<endl;
    else cout<<-d2[V-1]<<endl;
  }
}


Measured memory_bytes: 6656