akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n,k;
	cin>>n>>k;
	vector<ll> a(n),f(n);
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
		cin>>f[i];
	
	sort(a.begin(),a.end());
	sort(f.rbegin(),f.rend());
	// for(auto t: a)
	// 	cout<<t<<" ";
	// cout<<endl;
	// for(auto t:f)
	// 	cout<<t<<" ";
	// cout<<endl;
	ll low=0,high=1e18;
	while(low<high)
	{
		ll mid=(low+high)>>1;
		ll cnt=0;
		for(int i=0;i<n;i++)
		{
			if(mid<a[i]*f[i])
				cnt+=a[i]-mid/f[i];
		}
		// cout<<mid<<" "<<cnt<<endl;
		if(cnt<=k)
			high=mid;
		else
			low=mid+1;
	}
	cout<<low<<endl;
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <stdlib.h>//random,NULL
#include <string.h>
#include <time.h>
#include <unistd.h>//sleep()
#include <math.h>
#include <stdbool.h>

#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;

int main(){
  char buf[1024];
  char s[4];

  fgets(buf,sizeof(buf),stdin);
  sscanf(buf, "%s", s);

  int count[26];
  rep(i,26){
    count[i]=0;
  }

  rep(i,4){
    count[s[i]-'A']++;
  }

  int flag=0;
  rep(i,26){
    if(count[i]!=0 && count[i]!=2){
      flag=1;
    }
  }

  if(flag==0){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }

  return 0;

}


Measured memory_bytes: 128
#pragma warning(disable:4996)

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

typedef long long ll;
#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 pb push_back
#define mp make_pair
#define fill(x,y) memset(x,y,sizeof(x))

const ll INF = (ll)1e10;
const int INF_CONST = (int)1e9;
const ll MOD_CONST = (ll)(1e9 + 7);

int main(void)
{
	ll N, M; cin >> N >> M;
	ll ans;
	if (N == 1 and M == 1)
		ans = 1;
	else if (N == 1)
		ans = M - 2;
	else if (M == 1)
		ans = N - 2;
	else
		ans = (N - 2)*(M - 2);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define IO ios::sync_with_stdio(false);\
    cin.tie(0);\
    cout.tie(0);
using namespace std;
typedef long long LL;
const int maxn = 1e6+10;

int n;
LL a[maxn];
LL sum[maxn];
unordered_map<LL,int> sk;

int main()
{
#ifdef LOCAL_IM0QIANQIAN
//    freopen("test.in","r",stdin);
#else
    IO;
#endif // LOCAL_IM0QIANQIAN

    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    LL ans = 0;
    sum[0] = a[0];
    for(int i=1; i<n; i++)
        sum[i] = sum[i-1] + a[i];
    sk[a[0]]++;
    if(a[0]==0)++ans;
    for(int i=1; i<n; i++)
    {
        ans += sk[sum[i]];
        if(sum[i]==0)++ans;
        sk[sum[i]]++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 14152
from sys import stdin,setrecursionlimit
import math
setrecursionlimit(10**7)
a,b,c = map(int,stdin.readline().rstrip().split())
if c-a-b < 0:
    print("No")
    exit()
if 4*a*b < (c-a-b)**2:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
N, L = input().split()
N = int(N)
L = int(L)

total_taste_all = (N**2 + (2*L - 1)*N)/2
min_err = 10000
for i in range(N):
  apple_taste = L + i 
  taste_err = abs(apple_taste)
  if taste_err <= min_err:
    min_err = taste_err
    apple_pie_taste = total_taste_all - apple_taste
    
print(int(apple_pie_taste))

Measured memory_bytes: 3060
def main():
    # データ入力
    n, q = input().split()
    n = int( n )
    q = int( q )
    name = []
    time = []
    for i in range(n):
        tmp_n, tmp_t = input().split()
        name.append( tmp_n )
        time.append( int( tmp_t ) )

    # 処理
    count = 0
    while n > 0:
        if time[0] > q:
            time[0] -= q
            count += q
            time.append( time[0] )
            time.pop( 0 )
            name.append( name[0] )
            name.pop( 0 )
        else :
            count += time[0]
            print( name[0], end=" " )
            print( str( count ) )
            time.pop( 0 )
            name.pop( 0 )
            n -= 1

if __name__ == '__main__':
    main()



Measured memory_bytes: 9476
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long N,M;
	cin >> N >> M;
	vector<long long>A(N);
	long long num = 0;
	map<long long, long long>mp;
	long long ans = 0;
	mp[0] = 1;
	for (int i = 0;i<N;++i) {
		cin >> A[i];
		num += A[i];
		num %= M;
		mp[num]++;
	}
	for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
		ans += (itr->second)*(itr->second - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7964
#include <iostream>
#include <vector>

int main(){
    long long n, sum = 0, by = 1, abs_min = 1e9;
    std::cin >> n;
    std::vector<long long> a(n);
    for(int i = 0; i < n; i++){
        std::cin >> a.at(i);
        sum += abs(a.at(i));
        abs_min = std::min(abs_min, static_cast<long long>(abs(a.at(i))));
        if(a.at(i) != 0) by *= a.at(i) / abs(a.at(i));
        else by = 0;
    }
    if(by < 0) std::cout << sum - abs_min * 2;
    else std::cout << sum;
}

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,t;
	cin>>n>>t;
	int ans=t,ftmp,tmp;
	cin>>ftmp;
	for(int i=1;i<n;++i){
		cin>>tmp;
		ans+=min(tmp-ftmp,t);
		ftmp=tmp;
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int comp(char x[], char y[])
{
    for(int i = 0; i < 12; i++){
        if(x[i] > y[i]){
            return 1;
        }
        else if(x[i] < y[i]){
            return -1;
        }
    }
}

int main()
{
    int n;
    int p;
    char a[100][13] = {0};

    scanf("%d", &n);

    for(int i = 0; i < n; i++){
        scanf("%s%d", a[i], &p);
        a[i][11] = -p;
        a[i][12] = i;
    }

    for(int i = 0; i < n - 1; i++){
        for(int j = i + 1; j < n; j++){
            if(comp(a[i], a[j]) == 1){
                char t[13];
                memcpy(t, a[i], 13);
                memcpy(a[i], a[j], 13);
                memcpy(a[j], t, 13);
            }
        }
    }

    for(int i = 0; i < n; i++){
        printf("%d\n", a[i][12] + 1);
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forr(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define forin(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define debug(x) cerr<<#x<<" "<<x<<"\n";
#define yn {puts("YES");}else{puts("NO");}
#define maxs(x,y) (x = max(x,y))
#define sz(x) (int)(x).size()
#define mins(x,y) (x = min(x,y))
#define newline cout<<"\n"
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const int MX = 1001;
const int mod = 1e9+7;
// indexing is from 1;
int dp[MX][MX];

int main(){
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h,w;
    cin >> h >> w;
	vector <string> grid(h);
	forn(i,h) cin >> grid[i];
	dp[0][0] = 1;
	forn(i,h)forn(j,w){
		if(grid[i][j] == '#') dp[i][j] = 0;
		dp[i+1][j] = (dp[i+1][j]+dp[i][j])%mod;
		dp[i][j+1] = (dp[i][j+1]+dp[i][j])%mod;
	}
	cout << dp[h-1][w-1];
	return 0;
}




Measured memory_bytes: 5248
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
/*
         ########     ########   ########   #########   ##       #######   ##       #######
         #      #     #      #   #      #       #       # #      #     #   # #      #     #
         #      #     #      #   #      #       #       #  #     #     #   #  #     #     #
         ########     #      #   #      #       #       #   #    #     #   #   #    #     #
         ###          #      #   #      #       #       #    #   #######   #    #   #######
         #  #         #      #   #      #       #       #   #    #     #   #   #    #     #
         #   #        #      #   #      #       #       #  #     #     #   #  #     #     #
         #    #       #      #   #      #       #       # #      #     #   # #      #     #
         #     #      ########   ########       #       ##       #     #   ##       #     #     
*/

#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define bitcount __builtin_popcount //count no's of ones in a set bit
#define prq priority_queue
#define mp make_pair
#define mem(x, val) memset((x), (val), sizeof(x));
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define debug(a)          \
    cerr << #a << ": ";   \
    for (auto i : a)      \
        cerr << i << " "; \
    cerr << '\n';
#define trace(a) cerr << #a << ": " << a << "\n"
#define print(ar, n)            \
    for (int u = 0; u < n; u++) \
    {                           \
        cout << ar[u] << " ";   \
    }                           \
    cout << endl;
#define ll unsigned long long int
#define M 1000000007
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
signed main()
{
    rootdada;

    long long int A;
    long double B;
    cin >> A >> B;
    printf("%lld", (long long int)(A * B));
}

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

int n,w;
int ans;
int t[222222];

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

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <numeric>
using namespace std;

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

    if( s == "ARC")
        cout << "ABC" << endl;
    else
        cout << "ARC" << endl;
    return 0;
}

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

lint n, m;
vector<lint> p;

int main(){
    while(cin >> n >> m, n){
        p.resize(n);
        rep(i, n){
            cin >> p[i];
        }
        p.push_back(0);
        vector<lint> pts;
        rep(i, n+1){
            rep(j, n+1){
                if(p[i] + p[j] <= m){
                    pts.push_back(p[i] + p[j]);
                }
            }
        }
        SORT(pts);
        lint ans = 0;
        rep(i, pts.size()){
            int k = (upper_bound(pts.begin(), pts.end(), m - pts[i]) - pts.begin());
            k--;
            ans = max(ans, pts[i] + pts[k]);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 18944
#include<bits/stdc++.h>
#define maxn 100005
using namespace std;
typedef long long LL;
int read()
{
    char c=getchar();int f=1,sum=0;
    while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0' && c<='9'){sum=sum*10+c-'0';c=getchar();}
    return sum*f;
}
int n;
int head[maxn],to[maxn<<1],nex[maxn<<1],cnt;
void add(int u,int v){to[++cnt]=v;nex[cnt]=head[u];head[u]=cnt;}
int dfs(int x,int fa)
{
	int sg=0;
	for(int i=head[x];i;i=nex[i])
	if(to[i]!=fa) sg^=(dfs(to[i],x)+1);
	return sg;
}
int main()
{
	n=read();
	for(int i=1;i<n;i++)
	{
		int u=read(),v=read();
		add(u,v);add(v,u);
	}
	if(dfs(1,0)) puts("Alice");
	else puts("Bob");
	return 0;
}


Measured memory_bytes: 6912
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long ll;

int main() {
    int n, d[100010];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> d[i];

    if (d[0] != 0) {
        cout << 0 << endl;
        return 0;
    }

    sort(d, d + n);
    ll ans = 1, idx = 0, bef = -1, bef_v = 1, mod = 998244353;
    while (idx < n) {
        int sub = 0;
        while (idx + sub < n && d[idx] == d[idx + sub]) sub++;
        if (d[idx] == 0 && sub != 1) {
            cout << 0 << endl;
            return 0;
        }
        if (d[idx] - bef != 1) {
            cout << 0 << endl;
            return 0;
        }
        for (int i = 0; i < sub; i++) {
            ans = ans * bef_v % mod;
        }
        bef = d[idx];
        bef_v = sub;
        idx += sub;
    }

    cout << ans << endl;

}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <functional>
#include <stdio.h>
#include <vector>
#include <string>
#include <map>
#define rep(i, n) for(int (i) = (0); (i) < (n); (i)++)
//#define int long long
#define asort(v, n) sort((v), (v + n)) //Using array
#define vsort(v) sort((v).begin(), (v).end()) // Using vector
#define vint vector<int>

using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  if(a > b){
    rep(i, a){
      cout << b;
      //cout << endl;
    }
  }
  if(a <= b){
    rep(i, b){
      cout << a;
      //cout << endl;
    }
  }
  cout << endl;

}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(300000)


def solve(N: int, M: int):
    if N * 2 >= M:
        ret = M // 2
    else:
        left = M - N * 2
        ret = N + left // 4
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    solve(N, M)

if __name__ == '__main__':
    main()


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

int main(){
	long long int n,d;
	int i,count=0;
	cin >>n>>d;

	vector<long long int> x(n+2),y(n+2);
	for(i=1;i<=n;i++)
		cin >>x.at(i) >> y.at(i);

	for(i=1;i<=n;i++)
		if(x.at(i)*x.at(i)+y.at(i)*y.at(i)<=d*d)count++;
	
	cout <<count<<endl;
	return 0;
}

Measured memory_bytes: 6420
package main

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

func main() {
	N := nextInt()
	M := nextInt()
	Q := nextInt()

	a := make([]int, Q)
	b := make([]int, Q)
	c := make([]int, Q)
	d := make([]int, Q)

	for i := 0; i < Q; i++ {
		a[i] = nextInt() - 1
		b[i] = nextInt() - 1
		c[i] = nextInt()
		d[i] = nextInt()
	}
	candidates := increasing(M, N)

	ans := 0

	for j := 0; j < len(candidates); j++ {
		A := candidates[j]
		// printarr(A)
		s := 0
		for i := 0; i < Q; i++ {
			if A[b[i]]-A[a[i]] == c[i] {
				s += d[i]
			}
		}
		ans = max(ans, s)
	}

	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

// 1からnまでのm項からなる単調増加列
func increasing(n, m int) [][]int {
	return increasing1(1, 0, n, m, []int{1})
}

//
func increasing1(n, m, N, M int, arr []int) [][]int {
	if m == M {
		ret := []int{}
		s := 0
		for i := 0; i < len(arr); i++ {
			if arr[i] == 1 {
				s++
			} else {
				ret = append(ret, s)
			}
		}
		// len(ret) == M
		return [][]int{ret}
	}
	ret := [][]int{}
	if n < N {
		arr1 := append([]int{}, arr...)
		arr1 = append(arr1, 1)
		ret = append(ret, increasing1(n+1, m, N, M, arr1)...)
	}
	if m < M {
		arr0 := append([]int{}, arr...)
		arr0 = append(arr0, 0)
		ret = append(ret, increasing1(n, m+1, N, M, arr0)...)
	}
	return ret
}

var stdin = initStdin()

func initStdin() *bufio.Scanner {
	bufsize := 1 * 1024 * 1024 // 1 MB
	var stdin = bufio.NewScanner(os.Stdin)
	stdin.Buffer(make([]byte, bufsize), bufsize)
	stdin.Split(bufio.ScanWords)
	return stdin
}

func nextString() string {
	stdin.Scan()
	return stdin.Text()
}

func nextBytes() []byte {
	stdin.Scan()
	return stdin.Bytes()
}

func nextInt() int {
	i, _ := strconv.Atoi(nextString())
	return i
}

func nextInt64() int64 {
	i, _ := strconv.ParseInt(nextString(), 10, 64)
	return i
}


Measured memory_bytes: 39488
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long x,y;
	cin>>x>>y;
	long long ans=x*y/2ll;
	if(x==1||y==1)
	{
		cout<<1;
		return 0;
	}
	if(x%2ll==0ll||y%2ll==0ll)
	{
		cout<<ans;
	}
	else
	{
		cout<<ans+1ll;
	}
}

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

int main(){
  int number;
  char  brad[2];
  int a=0;
  int b=0;
  int ab=0;
  int o=0;
  while(scanf("%d,%s",&number,brad)!=EOF){
      if(brad[0]=='A' && brad[1]=='B')ab++;
      else if(brad[0]=='A')a++;
      else if(brad[0]=='B')b++;
      else if(brad[0]=='O')o++;
  }
  cout<<a<<endl;
  cout<<b<<endl;
  cout<<ab<<endl;
  cout<<o<<endl;
}

Measured memory_bytes: 1208
#include <stdio.h>

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


    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>
#include <iomanip>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

struct Key {
	int p;
	int v;
};

int dp[(1 << 12)];

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

	int n, m; cin >> n >> m;
	vector<Key> keys(m);

	for (auto& k : keys) {
		int a, b; cin >> a >> b;
		int v = 0;
		FOR_LT(i, 0, b) {
			int c; cin >> c;
			v |= (1 << (c - 1));
			k.p = a;
			k.v = v;
		}
	}

	FOR_LT(i, 0, (1 << 12)) {
		dp[i] = INT_MAX / 2;
	}
	dp[0] = 0;

	FOR_LT(i, 0, 1 << 12) {
		FOR_LT(j, 0, m) {
			int n_s = i | keys[j].v;
			if (dp[i] + keys[j].p < dp[n_s]) {
				dp[n_s] = dp[i] + keys[j].p;
			}
		}
	}

	if (dp[(1 << n) - 1] == INT_MAX / 2) {
		cout << -1 << endl;
	}
	else {
		cout << dp[(1 << n) - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
int main()
{
	int a, b;
	cin >> a >> b;
	if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
		cout << "Possible";
	}
	else {
		cout << "Impossible";
	}
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))

for i in range(n):
    if a[i] == 1:
        min_idx = i
        break
ans = 10**9
for i in range(k):
    ans_cur = 1
    l = min_idx - i
    r = l + (k-1)
    if l > 0:
        ans_cur += l//(k-1)+1 if l%(k-1) > 0 else l//(k-1)
    if r < n-1:
        ans_cur += (n-1-r)//(k-1)+1 if (n-1-r)%(k-1) > 0 else (n-1-r)//(k-1)
    ans = min(ans, ans_cur)
print(ans)


Measured memory_bytes: 14008
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll mod = 1e9 +7;
const ll MAXN = 1e6 + 5;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n;cin>>n;
	ll res=n+1,cnt=0;
	for(int i=0;i<n;i++){
		ll x;
		cin>>x;
		if(res>=x){
			cnt++;
		}
		res=min(res,x);
	}
	cout<<cnt;
	return 0;
}


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

int main() {
	
	//vector<int> a(n);  (a.begin(),a.end())
	//cout << "test" << endl;

	cin.tie(0);
	ios::sync_with_stdio(false);
	
	//string ans="YES";


	int n;
	cin >> n;
	
	int ans=0;
	
	
	vector<int> a(n);
	
	rep(i,n) cin >> a[i];
	
	sort(a.begin(),a.end());
		
	for(int s=0;s<n-2;s++){//short
		for(int m=s+1;m<n-1;m++){//middle
			
			int longer=n-1-m;//longの本数
			int ng=distance(lower_bound(a.begin(),a.end(),a[s]+a[m]),a.end());
			//long && 条件満たさない の本数
			
			
			ans+=(longer-ng);
		}
	}
		
	
	cout << ans << "\n";
	
	
	return 0;

    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> p(13, 0);
  vector<int> v;
  p.at(0) = 1;
  rep(i, n){
    int in;
    cin >> in;
    p.at(in)++;
    v.push_back(in);
    if(in == 0 || in == 12){
      if(p.at(in) > 1){
        cout << 0 << endl;
        return 0;
      }
    }else if(p.at(in) > 2){
      cout << 0 << endl;
      return 0;
    }
  }
  int ans = 0;
  rep(bit, 1 << n){
    vector<bool> d(24, false);
    d.at(0) = true;
    bool f = false;
    rep(i, n){
      int nx = v.at(i);
      if((bit & (1 << i)) == 0) nx = 24 - nx;
      if(nx == 24) nx = 0;
      if(d.at(nx) != false){
        f = true;
        break;
      }
      d.at(nx) = true;
    }
    if(f == true) continue;
    int add = 1001001, bf = 0;
    rep2(i, 1, 24){
      if(d.at(i) == true){
        int an = i - bf;
        add = min(add, an);
        bf = i;
      }
    }
    add = min(add, (24 - bf));
    ans = max(ans, add);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<map>
#include<vector>

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if(a >= 10){
        cout << -1 << endl;
    }
    else if(b >= 10){
        cout << -1 << endl;
    }
    else{
        cout << a * b << endl;
    }
    return 0;
}

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


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

#ifndef ONLINE_JUDGE
    freopen("input.txt" , "r" , stdin);
    freopen("output.txt" , "w" , stdout);
#endif

    string s, t;
    cin >> s >> t;
    int n = s.length();
    int m = t.length();

    int dp[n + 1][m + 1];

    for (int i = 0; i <= n; i++)
    {
        for (int j = 0; j <= m; j++)
        {
            if (i == 0 || j == 0)
                dp[i][j] = 0;

            else if (s[i - 1] == t[j - 1])
                dp[i][j] = 1 + dp[i - 1][j - 1];
            else
                dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
        }
    }

    string a;
    int i = n, j = m;
    while (i > 0 && j > 0)
    {
        if (s[i - 1] == t[j - 1])
        {
            a.push_back(s[i - 1]);
            i--;
            j--;
        }
        else if (dp[i - 1][j] > dp[i][j - 1])
            i--;
        else
            j--;
    }
    reverse(a.begin(), a.end());
    cout << a << endl;

    return 0;

}

Measured memory_bytes: 38844
#if defined(__GNUC__)
#include <bits/stdc++.h>
#define __int32 __int32_t
// __GNUC__
#else
#include "bits/stdc++.h"
#endif
using namespace std;

#define int long long

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); ++(i))
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); ++(i))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) std::sort(ALL(x))
#define RSORT(x) std::sort(ALL(x), greater<decltype(x)::value_type>())
#define RSORT2(x, T) std::sort(ALL(x), greater<T>())
#define REVERCE(x) std::reverce(ALL(x))
#define ACM(x, y) std::accumulate(ALL(x), y)

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)
#define FCT(x) [](int a) -> int {int r = 1; REP(i, a){r *= i;} return r;}(x)

itn main() {
	std::ios::sync_with_stdio(false);

	int n;

	cin >> n;

	vector<int> a(n), b(n), c(n);

	REP(i, n) {
		cin >> a[i];
	}

	REP(i, n) {
		cin >> b[i];
	}

	REP(i, n) {
		cin >> c[i];
	}

	SORT(a);
	SORT(b);
	SORT(c);

	vector<int> ab(n + 1);
	ab[0] = 0;
	int point = 0;

	REP(i, n) {
		while (point != n && b[i] > a[point]) {
			++point;
		}

		if (point == n) {
			while (i != n) {
				ab[i + 1] = ab[i] + point;
				++i;
			}
			break;
		}

		ab[i + 1] = ab[i] + point;
	}

	int res = 0;
	point = 0;

	REP(i, n) {
		while (point != n && c[i] > b[point]) {
			++point;
		}

		if (point == n) {
			while (i != n) {
				res += ab[point];
				++i;
			}
			break;
		}

		res += ab[point];
	}

	cout << res;

	return 0;
}


Measured memory_bytes: 3456
n = int(input())
al = list(map(int,input().split()))

sum_a = sum(al)

potential = 1
ans = 0
for a in al:
    ans += min(sum_a, potential)
    sum_a -= a
    potential = 2 * (potential - a)
    if potential < 0:
        print(-1)
        exit()
print(ans)


Measured memory_bytes: 83444
#include <stdio.h>
#include <string.h>

void strrev2(char *out, char *in);

int main(void)
{
	int i;
	int a;
	char in[100];
	char out[100];
	
	scanf("%d", &a);
	
	while (a != 0){
		
		i = 0;

			while (a != 0){
				in[i] = a % 8 + '0';
				a /= 8;
				i++;
			}
			
			in[i] = '\0';
			strrev2(out, in);
			
			for(i = 0; i < strlen(out); i++){
				if(out[i] == '4'){
					out[i]++;
				}
				else if(out[i] > '4'){
					out[i] += 2;
				}
			}
			
		printf("%s\n", out);
		
		scanf("%d", &a);
	}
	return (0);
}

void strrev2(char *out, char *in)
{
	int a;
	int i;
	
	a = 0;
	while (in[a] != '\0'){
		a++;
	}
	out[a] = '\0';
	
	i = 0;
	while (in[i] != '\0'){
		out[i] = in[a - 1];
		i++;
		a--;
	}
}

Measured memory_bytes: 0
package main

import "fmt"

func main() {
	var a, b, k int
	fmt.Scan(&a, &b, &k)

	n := 0
	for i := min(a, b); ; i-- {
		if a%i == 0 && b%i == 0 {
			n++
			if n == k {
				fmt.Println(i)
				return
			}
		}
	}
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}


Measured memory_bytes: 512
import sys


for line in sys.stdin:
    xa1, ya1, xa2, ya2, xb1, yb1, xb2, yb2 = map(float, line.strip().split(' '))
    if ((xb1<=xa1 and xa1<=xb2) or (xa1<=xb1 and xb1<=xa2)) and ((yb1<=ya2 and ya2<=yb2) or (ya1<=yb2 and yb2<=ya2)):
        print 'YES'
    else:
        print 'NO'

Measured memory_bytes: 4232
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
string s;
vi a,S,b[3],g[2];

int main(){
	cin>>s;
	n=s.size();
	a=vi(n);S=vi(n+1);
	b[0]=b[1]=b[2]=g[0]=g[1]=vi(n+1,-1);
	for(int i=0;i<n;i++){
		if(s[i]=='a') a[i]=2;
		else a[i]=1;
	}
	for(int i=1;i<=n;i++) S[i]=S[i-1]+a[i-1];
	for(int i=n-1;i>=0;i--){
		b[a[i]][i]=i+1;
		for(int j=0;j<3;j++) if(j!=a[i]){
			b[j][i]=b[(j-a[j]+3)%3][i+1];
		}
	}
	int I=-1;
	for(int i=n-1;i>=0;i--){
		if(i!=n-1&&s[i]==s[i+1]) I=i+2;
//		cout<<I<<endl;
		if(s[i]=='a'){
			g[0][i]=i+1;
			if(I==-1) continue;
			int t=(4-S[I]+S[i])%3;
			if(!t) g[1][i]=I;
			else g[1][i]=b[(4-S[I]+S[i])%3][I];
		}
		else{
			g[1][i]=i+1;
			if(I==-1) continue;
			int t=(5-S[I]+S[i])%3;
			if(!t) g[0][i]=I;
			else g[0][i]=b[(5-S[I]+S[i])%3][I];
		}
	}
	int J=-1;
	for(int i=n-2;i>=0;i--) if(s[i]==s[i+1]){
		J=i+2;
		break;
	}
	if(J==-1){
		cout<<1<<endl;
		return 0;
	}
	vi dp(n+1);
	dp[0]++;
	int res=0;
	for(int i=0;i<n;i++) for(int j=0;j<2;j++) if(g[j][i]!=-1){
		I=g[j][i];
		(dp[I]+=dp[i])%=mod;
		if((S[n]-S[I]+3)%3==0&&(I!=i+1||i+1>=I))(res+=dp[i])%=mod;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
#define ALL(v) (v).begin(), (v).end()
const int mod = INF+7;
using namespace std;

//比較関数を作ってやれば良い。
bool compare_by_b(pair<int, pair<int, int> >a, pair<int, pair<int,int> > b){
  //a<bは昇順、a>bは降順
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return (a.second).first < (b.second).first;
    }
}

bool compare_by_second(pair<long, int> a, pair<long, int> b){
  return a.second < b.second;
}

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> P(M);
  vector<int> Y(M);
  rep(i,M){
    cin >> P[i] >> Y[i];
  }

  vector<pair<int, pair<int, int>>> p(M);
  rep(i,M){
    p[i]=make_pair(P[i], make_pair(Y[i], i));
  }
  sort(ALL(p), compare_by_b);

  // rep(i,M){
  //   cout << p[i].first << ", " << p[i].second.first << ", " << p[i].second.second <<endl;
  // }

  vector<pair<long, int>> num(M);
  num[0]=make_pair((long)p[0].first*1000000+1, p[0].second.second);
  int count=1;
  srep(i,1,M){
    if(p[i].first==p[i-1].first){
      count++;
    }
    else{
      count=1;
    }
    num[i]=make_pair((long)p[i].first*1000000+count, p[i].second.second);
  }

  sort(ALL(num), compare_by_second);

  rep(i,M){
    printf("%012ld\n", num[i].first);
  }

}


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

#define clr(i, j)     memset(i, j, sizeof(i))
#define pb            push_back
#define m            make_pair
typedef long long     ll;
map<char,int>mp;
int main()
{
string e;cin>>e;ll s=e.size();
for(int i=0;i<s;i++){mp[e[i]]++;}
ll ans=(s*(s-1))/2;
for(int i='a';i<='z';i++){
      ll l=mp[i];
      ans-=(l*(l-1))/2;
}
cout<<ans+1;




    }


Measured memory_bytes: 640
#include<stdio.h>

int main()
{
	int a,b,c,max=0,i,kari;
	scanf("%d %d %d",&a,&b,&c);
	for(i=0;i<3;i++)
	{
		if(i==0)kari=(a*10+b)+c;
		else if(i==1)kari=(b*10)+a+c;
		else kari=c*10+a+b;
		if(max<kari)max=kari;
	}
	
	printf("%d",max);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }


vector<vector<int>> V =
    {
        {0, 1, 2},
        {3, 4, 5},
        {6, 7, 8},
        {0, 4, 8},
        {2, 4, 6},
        {0, 3, 6},
        {1, 4, 7},
        {2, 5, 8}};

int main()
{
    vector<lint> A(9);
    cin >> A;
    int N;
    cin >> N;
    while (N--) {
        int b;
        cin >> b;
        for (auto &x : A) if (x == b) x = 0;
    }
    for (auto vec : V) {
        bool b = true;
        for (auto x : vec) if (A[x]) b = false;
        if (b) {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
}


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Table Tennis Training
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

int main() {
  ll n, a, b;
  scanf("%lld%lld%lld", &n, &a, &b);

  printf("%lld\n",
	 ((b - a) & 1) ? min(a, n - b + 1) + (b - a - 1) / 2 : (b - a) / 2);
  return 0;
}


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

int main() {
  std::string s1, s2;
  cin >> s1 >> s2;

  bool yes = false;
  for (int i = 0; i < s1.size(); i++) {
    if (s1 == s2) {
      yes = true;
      break;
    }
    // update
    std::rotate(s1.begin(), s1.begin()+1, s1.end());
  }

  if (yes) std::cout << "Yes" << std::endl;
  else std::cout << "No" << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007
 
const ll INF=LLONG_MAX/2;
 
int main(){
  int N;
  cin>>N;
  int a[3*N];
  for(int i=0;i<3*N;i++) cin>>a[i];
  priority_queue<int,vector<int>,greater<int>> q1;
  ll sum1[N+1];
  sum1[0]=0;
  for(int i=0;i<N;i++){
    q1.push(a[i]);
    sum1[0]+=a[i];
  }
  for(int i=N;i<2*N;i++){
    sum1[i-N+1]=sum1[i-N]+a[i];
    q1.push(a[i]);
    sum1[i-N+1]-=q1.top();
    q1.pop();
  }
  ll sum2[N+1];
  priority_queue<int> q2;
  sum2[0]=0;
  for(int i=2*N;i<3*N;i++){
    sum2[0]+=a[i];
    q2.push(a[i]);
  }
  for(int i=1;i<=N;i++){
    sum2[i]=sum2[i-1]+a[2*N-i];
    q2.push(a[2*N-i]);
    sum2[i]-=q2.top();
    q2.pop();
  }
  ll ans=-INF;
  for(int i=0;i<=N;i++){
    ans=max(ans,sum1[i]-sum2[N-i]);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3832
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int h, w, k; cin >> h >> w >> k;
  vector<string> s(h); REP(i, h) cin >> s[i];
  int ans = 0;
  REP(r, 1 << h) REP(c, 1 << w) {
    vector<string> tmp(s);
    REP(ii, h) {
      if (r >> ii & 1) {
        REP(j, w) tmp[ii][j] = '.';
      }
    }
    REP(jj, w) {
      if (c >> jj & 1) {
        REP(i, h) tmp[i][jj] = '.';
      }
    }
    int cnt = 0;
    REP(i, h) REP(j, w) cnt += tmp[i][j] == '#';
    ans += cnt == k;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3652
package main

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

var scanner *bufio.Scanner

func printIt() {
	word := strings.ToLower(nextString())
	sentence := strings.ToLower(readAllString())
	words := strings.Fields(sentence)
	ans := 0
	for _, item := range words {
		if item == word {
			ans++
		}
	}
	fmt.Println(ans)
}


func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func readAllString() string {
	var ans string
	for scanner.Scan() {
		if scanner.Text() == "END_OF_TEXT" {
			break
		}
		ans += scanner.Text() + " "
	}
	return ans
}

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanLines)
	printIt()
}



Measured memory_bytes: 1144
#include<bits/stdc++.h>
using namespace std;
#define ssd ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define debug_x(x) cout<< #x <<"---> : "<<x<<endl;
#define debug_ve(x) for(auto it: x) cout<<it<<" ";
#define rep(i,a,n) for (int i=a;i<n;i++)
#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 fi first
#define se second
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef double db;
//std::mt19937 mrand(random_device{}());
//int rnd(int x) { return mrand() % x ; }
const ll mod=1e7;
ll ksm(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;}

/***********************/

int main(){
    ssd;
    int n;cin>>n ;
    cout<<n*(n+1)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

//gcdをユークリッド互除法で求める。O(log n)
int euclid(int x, int y){
    if(min(x, y) ==  0) return max(x, y);
    else return euclid(max(x, y)% min(x, y) , min(x, y));
}
//

int main() {
	int ans = 0;
	int tmp;
	int n;
	cin >> n;
	vector<int> a(n);
	REP(i, n) cin >> a[i];
	ans = a[0];
	REP1(i, n-1){
		ans = euclid(ans, a[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define F first
#define S second
#define bitcnt(v) __builtin_popcount(v)
#define all(v) v.begin(), v.end()

void solution(){
	ll n; cin >> n;
	ll ans = 0;
	for(int num = 1; num < n; num++){
		for(int i = 1; i*i <= num; i++){
			if(num % i == 0){
				ans++;
				if(i*i != num) ans++;
			}
		}
	}
	cout << ans << endl;


	

}	


int main(){ 
	fio;
	int t;
	t = 1;
	// cin >> t;
	for(int i = 1; i <= t; i++){
		// cout << "Case #" << i << ": ";
		solution();
	} 
	return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
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(a) push_back(a);
#define sz(x) sizeof(x);
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;

// head
int main() {
	int n; cin >> n;
	printf("%d\n", n/3);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/math/tools/minima.hpp>
using namespace std;
using boost::math::tools::brent_find_minima;

# define REP(i,n) for (int i=0;i<(n);++i)
# define PER(i,n) for (int i=(N-1);i>=0;--i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

const int inf = 1e9+7;

int main(){
	string s;
    cin >> s;
	
    int n = s.size();
	int id = 0;
	ll ans = 0;
	int tmp = 0;
	for(int i = n - 1; i >= 0; i--) {
		if (s[i] == 'A') {
			if (id == 1) {
				id = 0;
                tmp = 0;
			}
			ans += tmp;
		} else if (id == 0) {
			if (s[i] == 'C') {
				id = 1;
			} else {
				tmp = 0;
			}
		} else {
			if (s[i] == 'B') {
				id = 0;
                tmp++;
			} else if(s[i]=='A'){
				id = tmp = 0;
			} else {
				id = 1;
                tmp = 0;
			}
		}
	}
	cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>

int main(void)
{
	int a, b, d;
	int count = 1;

	scanf("%d %d", &a, &b);

    if(b == 1)
    {
      printf("0");
      return 0;
    }
    
	d = a;

	while (d < b)
	{
		d = d - 1 + a;
		count++;
	}

	printf("%d\n", count);

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define gc getchar()
using namespace std;
typedef long long ll;
const int N=200009;
int n;
ll ans,sum;
map<ll,int> mp;
int read()
{
	int x=1;
	char ch;
	while (ch=gc,ch<'0'||ch>'9') if (ch=='-') x=-1;
	int s=ch-'0';
	while (ch=gc,ch>='0'&&ch<='9') s=s*10+ch-'0';
	return s*x;
}
int main()
{
	for (n=read(),mp[0]=1;n;n--) ans+=mp[sum+=read()]++;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 12800
#include <stdio.h>
int main() {
	int stack[11];
	int top = 0, n;
	while (scanf(" %d", &n) != EOF) {
		if (n > 0) {
			stack[top++] = n;
		} else if (n == 0) {
			printf("%d\n", stack[--top]);
		}
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,P> PP;
const long long int MOD = 1000000007;
const int INF = 1000000000;

int n, m, c;
int dp[101*100];
vector<P> e[101*100];
int debug;

void solve(){
    rep(i,101*100) e[i].clear();
    rep(i,m){
        int f, t, x;
        cin >> f >> t >> x;
        f--; t--;
        for(int j = 0; j < n; j++){
            e[j*n+f].push_back(P(j*n+t,x));
        }
        for(int j = 0; j < n-1; j++){
            e[j*n+f].push_back(P((j+1)*n+t,0));
        }
    }
    rep(i,101*100) dp[i] = INF;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,0));
    dp[0] = 0;
    while(!que.empty()){
        P p = que.top();
        que.pop();
        if(p.first > dp[p.second]) continue;
        rep(i,e[p.second].size()){
            P to = e[p.second][i];
            if(dp[to.first] > dp[p.second]+to.second && dp[p.second]+to.second <= c){
                dp[to.first] = dp[p.second]+to.second;
                que.push(P(dp[to.first],to.first));
            }
        }
    }
    for(int i = 0; i <= n; i++){
        if(dp[i*n+n-1] != INF){
            cout << i << endl;
            return;
        }
    }
}

int main(){
    while(cin >> n >> m >> c){
        debug++;
        if(n == 0 && m == 0 && c == 0) break;
        solve();
    }
}

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

using namespace std;

int cnt[1000005], oks[1000005];

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, x, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        cin >> x;
        cnt[x]++;
    }
    for (int i = 1; i <= 1000000; ++i) {
        if (oks[i] == 0 && cnt[i] == 1) ans += cnt[i];
        if (cnt[i] > 0) for (int j = 2 * i; j <= 1000000; j += i) oks[j] = 1;
    }
    cout << ans;
    return 0;
}



Measured memory_bytes: 11360
#include <stdio.h>

int main()
{
	int x,y,t;
	
	while(1){
	    scanf("%d %d",&x,&y);
		if(x==0 && y==0) break;
		if(x>y){
			t=x;
			x=y;
			y=t;
		}
	    printf("%d %d\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 596
# -*- coding: utf-8 -*-
import math

def main():
    """Function."""
    n = int(input())

    flag = 0
    check = set()
    temp = str(input())
    check.add(temp)
    for _ in range(n-1):
        dum = str(input())
        if temp[-1] == dum[0] and dum not in check:
            check.add(dum)
            temp = dum

        else:
            flag = 1

    if flag == 1:
        print("No")
    else:
        print("Yes")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

int main(void) {
	int n;
	int i, j;
	char a[3];
	int b;
	int cards[4][13];
	
	for(i = 0; i < 4; i++) {
		for(j = 0; j < 13; j++) {
			cards[i][j] = 0;
		}
	}
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++) {
		scanf("%s %d", a, &b);
		if(!strcmp(a, "S")) {
			cards[0][b-1] = 1;
		} else if (!strcmp(a, "H")) {
			cards[1][b-1] = 1;
		} else if (!strcmp(a, "C")) {
			cards[2][b-1] = 1;
		} else if (!strcmp(a, "D")) {
			cards[3][b-1] = 1;
		}
	}
	
	for(i = 0; i < 4; i++) {
		for(j = 0; j < 13; j++) {
			if(!cards[i][j]) {
				if(i == 0) {
					printf("S %d\n", j + 1);
				} else if(i == 1) {
					printf("H %d\n", j + 1);
				} else if(i == 2) {
					printf("C %d\n", j + 1);
				} else if(i == 3) {
					printf("D %d\n", j + 1);
				}
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<pair<ll,ll>> vep;
const ll mod=1000000007;
const ll INF=1e15;
const int BIG=1e7;

bool able=true;
vector<int> d[201];
int s[201];
int m[201][201];


int par[100001];
int rnk[100001];
int size[100001];
int N;

void shoki(){
    for(int i=0;i<=10000;i++) {par[i]=i; rnk[i]=0; size[i]=1;}
}

int sch(int x){
    if(par[x]==x) return x;
    else return par[x]=sch(par[x]);
}

void con(int A,int B){
    A=sch(A);
    B=sch(B);
    if(A==B) return;
    if(rnk[A]>rnk[B]) swap(A,B);
    par[A]=B;
    size[B]+=size[A];
    size[A]=size[B];
    if(rnk[A]==rnk[B]) rnk[B]++;

    return;
}

int main(){
    //cout<<able<<endl;
    cin>>N;
    shoki();
    //for(int i=0;i<N;i++) cout<<sch(i)<<' '<<sch(i+3000)<<endl;
    for(int i=0;i<N;i++){
        string S; cin>>S;
        for(int j=0;j<N;j++) if(S.at(j)=='1') {
            m[i][j]=1;
            d[i].push_back(j);
            con(i,j+3000);
            con(j,i+3000);
        }
    }
    //for(int i=0;i<N;i++) cout<<sch(i)<<' '<<sch(i+3000)<<endl;

    for(int i=0;i<N;i++) if(sch(i)==sch(i+3000)) able=false;

    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++) if(i!=j && m[i][j]==0) m[i][j]=BIG;
    }
    int ans=-1;

    if(able){
        for(int k=0;k<N;k++){
            for(int i=0;i<N;i++){
                for(int j=0;j<N;j++) m[i][j]=min(m[i][k]+m[k][j],m[i][j]);
            }
        }

        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++) ans=max(ans,m[i][j]+1); 
        }
    }
    cout<<ans<<endl;

    
    
    

}

Measured memory_bytes: 768
import queue
def resolve():
    n = int(input())
    q = queue.Queue()
    for i in range(1,10):
        q.put(i)
    for _ in range(n):
        x = q.get()
        if x%10!=0:
            q.put(10*x+(x%10)-1)
        q.put(10*x+(x%10))
        if x%10!=9:
            q.put(10*x+(x%10)+1)
    print(x)
resolve()

Measured memory_bytes: 18800