akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define repr(e,x) for(auto& e:x)
using namespace std;
typedef long long ll;

int N,M;
string A[50], B[50];

int main(){
    cin>>N>>M;
    rep(i,N) cin>>A[i];
    rep(i,M) cin>>B[i];

    string ans="No";
    rep(i,N-M+1){
        rep(j,N-M+1){
            int flag=true;
            rep(k,M){
                rep(l,M){
                    if(A[k+i][l+j]!=B[k][l]){
                        flag=false;
                        goto a;
                    }
                }
            }
            a:;
            if(flag){
                ans="Yes";
                goto b;
            }
        }
    }
    b:;

    cout<<ans<<endl;
}

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

using namespace std;

int main(void){
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    A--;
    B--;
    C--;
    D--;
    string S;
    cin >> S;
    for(int i = min(A, B); i < max(C, D); i++){
        if(S[i] == '#' && S[i + 1] == '#'){
            cout << "No" << endl;
            return 0;
        }
    }
    if((A < B) && (C < D) || (A > B) && (C > D)){
        cout << "Yes" << endl;
        return 0;
    }
    for(int i = max(A, B) - 1; i < min(C, D); i++){
        if(S[i] == '.' && S[i + 1] == '.' && S[i + 2] == '.'){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

#define int				long long
#define FOR( i, m, n )	for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )		FOR( i, 0, n )
#define REPR( i, m )	for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )	FOR( i, 1, n + 1 )
#define ALL( a )		(a).begin(), (a).end()
#define MP				make_pair

typedef pair<int, int> P;

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( a > b ) { a = b; return 1; } return 0; }

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
	int n, cnt;
	char ch1, ch2;
	char number[10][6] = {
		{},
		{ 5, '.', ',', '!', '?', ' ' },
		{ 3, 'a', 'b', 'c' },
		{ 3, 'd', 'e', 'f' },
		{ 3, 'g', 'h', 'i' },
		{ 3, 'j', 'k', 'l' },
		{ 3, 'm', 'n', 'o' },
		{ 4, 'p', 'q', 'r', 's' },
		{ 3, 't', 'u', 'v' },
		{ 4, 'w', 'x', 'y', 'z' }
	};

	cin >> n; cin.get( ch1 );
  REP( i, n ){
    while( cin.get( ch1 ), ch1 != '\n' ){
      cnt = 0;
      while( cin.get( ch2 ), ch2 == ch1 ) cnt++;

      if( ch2 == '0' ){
        cout << number[ch1 - '0'][cnt % number[ch1 - '0'][0] + 1];
      }else{
        cin.putback( ch2 );
      }
    }
    cout << endl;
  }

}


Measured memory_bytes: 3004
import collections
N = int(input())
# = map(int, input().split())
# = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]
count = 0

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

c = collections.Counter(prime_factorize(N))
C = list(c.items())

if len(list(c.keys()))==1:
    for j in range(1, C[0][1]+1):
        if N%(C[0][0]**j) == 0:
            count += 1
            N /= C[0][0]**j

else:
    for i in range(len(C)):
        for j in range(1, C[i][1]+1):
            if N%(C[i][0]**j) == 0:
                count += 1
                N /= (C[i][0]**j)

print(count)


Measured memory_bytes: 9544
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

string s;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> s;
    if (s[1] == 'B') cout << "ARC\n";
    else cout << "ABC\n";
    //system("pause");
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,LL> PL;

const int MOD=1000000007;
int INF=100100100;
int main(){
  int a,b;cin>>a>>b;
  cout<<a*b<<endl;
  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,i,ans=1;
    vector<long int>v;
    long int t,s=0;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>t;
        v.push_back(t);
    }
    sort(v.begin(),v.end());
    for(i=0;i<n-1;i++){
        s=s+v[i];
        if(2*s>=v[i+1])ans++;
        else ans=1;
    }
    cout<<ans;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define forr(i,a,n)     for(long long int i=a; i<n; i++)
#define loop(i,a,n)     for(long long int i=a; i>=n; i--) 

long long int mod=1e9+7;

long long int mul(long long int x,long long int y)
{
    return (x * 1ll * y) % mod;
}
long long int add(long long int x, long long int y)
{
	while(y<0)
		y+=mod;
	while(x<0)
		x+=mod;
	long long int z=x%mod+y%mod;
	while(z>=mod)
		z-=mod;
	while(z<0)
		z+=mod;
	return z;
}
long long int fastpow(long long int x, long long int y)
{
	long long int z=1;
	while(y)
	{
		if(y&1)
			z=mul(x,z);
		x=mul(x,x);
		y/=2;
	}
	return z;
}
long long int inverse(long long int x)
{
	return fastpow(x, mod-2);
}
long long int findProductSum(long long int A[],long long int n) 
{ 
    // calculating array sum (a1 + a2  ... + an) 
   long long int array_sum = 0; 
    for (int i = 0; i < n; i++) 
        array_sum = add(array_sum, A[i]);
  	array_sum%=mod;
    // calcualting square of array sum 
    // (a1 + a2 + ... + an)^2 
   long long int array_sum_square = mul(array_sum, array_sum);
  
    // calcualting a1^2 + a2^2 + ... + an^2 
   long long int individual_square_sum = 0; 
    for (int i = 0; i < n; i++) 
        individual_square_sum =  add(individual_square_sum, mul(A[i], A[i])); 
  
    // required sum is (array_sum_square - 
    // individual_square_sum) / 2 
  long long int ans=mul(inverse(2), add(array_sum_square, -individual_square_sum));
  while(ans<0)
  	ans+=mod;
  	return ans;
} 

int main()
{
	ios_base :: sync_with_stdio(false),cin.tie(NULL);
	
	long long int a;
	cin>>a;
	long long int b[a];
	forr(i, 0, a)
		cin>>b[i];
	cout<<findProductSum(b, a);
	
	return 0;
}

Measured memory_bytes: 5184
import * as fs from 'fs';

namespace AtCoder.abc108 {

    class ProgramA {
        args: string[];

        // in 6
        // out 9
        // 1,2
        // 1,4
        // 1,6
        // 2,3
        // 2,5
        // 3,4
        // 3,6
        // 4,5
        // 5,6
        constructor(args: string[]) {
            this.args = args;
        }

        main(): void {
            const k: number = parseInt(args[0]);
            let ans: number = 0;
            for (let i = 1; i < k; i++) {
                for (let j = i; j <= k; j++) {
                    if (i % 2 === 0) { // 偶数
                        if (j > i && j % 2 === 1) {
                            ans++;
                        }
                    }
                    if (i % 2 === 1) { // 奇数
                        if (j > i && j % 2 === 0) {
                            ans++;
                        }
                    }
                }
            }
            console.log(ans);
        }
    }

    const args: string[] = fs.readFileSync('/dev/stdin', 'utf-8').trim().split('\n');
    const func = new ProgramA(args);
    func.main();
}


Measured memory_bytes: 7372
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int n;
vector<pair<int,ll> > A , B;

int main(){
    scanf("%d",&n);
    A.pb(mp(0 , 1));
    rep(i,0,3) {
        rep(i,1,sz(A)) A[i].se += A[i-1].se;
        B.assign(n,mp(0,0));
        rep(i,0,n) scanf("%d",&B[i].fi);
        sort(all(B));
        rep(i,0,n) {
            auto e = lower_bound(all(A),mp(B[i].fi,0ll));
            if(e!=A.begin()){
                --e;
                B[i].se=e->se;
            }
        }
        swap(A , B);
    }
    ll ans=0;
    rep(i,0,n) ans+=A[i].se;
    printf("%lld\n",ans);
    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define MOD 1000000007
#define el endl
#define INF 1e15
typedef long long ll;
typedef long double ld;
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

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

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    vector<ll> dp(n+1, INF);
    dp[0] = 0;
    for(int i = 1; i < n; i++){
        for(int j = 1; j <= k && j <= i; j++){
            chmin(dp[i], dp[i-j] + abs(h[i] - h[i - j]));
        }
    }
    cout << dp[n-1] << endl;
}




Measured memory_bytes: 1792
package main
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
    "strings"
)

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*1)

func main() {
    list := getStdinintArr()
    A := list[0]
    B := list[1]

    fmt.Println(A*B)
}

func getStdin() string {
    return readLine()
}
func getStdinInt() int {
    str := getStdin()
    res, _ := strconv.Atoi(str)
    return res
}
func getStdinintArr() []int {
    str := getStdin()
    list := strings.Split(str, " ")
    res := make([]int, len(list))
    for idx, v := range list {
        res[idx], _ = strconv.Atoi(v)
    }
    return res
}
func getStdinIntArr64() []int64 {
    str := getStdin()
    list := strings.Split(str, " ")
    res := make([]int64, len(list))
    for idx, v := range list {
        res[idx], _ = strconv.ParseInt(v, 10, 64)
    }
    return res
}
func readLine() string {
    buf := make([]byte, 0, 0)
    for {
        l, p, e := sc.ReadLine()
        if e != nil {
            panic(e)
        }
        buf = append(buf, l...)
        if !p {
            break
        }
    }
    return string(buf)
}

Measured memory_bytes: 1792
#include<cstdio>
#include <algorithm>
#include <iostream>
#include <functional>
#include<cmath>
#include<string.h>
#include<vector>

int main(){
	int dig[5],n,m,c,s;
	bool bl=true;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++){
		dig[i]=-1;
	}
	for(int i=0;i<m;i++){
		scanf("%d %d",&s,&c);
		if(dig[s]==-1||dig[s]==c)dig[s]=c;
		else bl=false;
	}
	if(dig[1]==0&&n!=1)bl=false;
	
	
	if(bl){
		for(int i=1;i<=n;i++){
			if(dig[i]==-1){
				if(i==1&&n!=1)printf("1");
				else printf("0");
			}
			else printf("%d",dig[i]);
		}
		printf("\n");
	}
	else printf("-1\n");
	return 0;
}

Measured memory_bytes: 256
s_orig = gets.chomp
t_orig = gets.chomp

s = s_orig.codepoints
t = t_orig.codepoints

s_size = s.size
t_size = t.size

dp = Array.new(s_size+1) { Array.new(t_size+1,0) }

0.upto(s_size-1).each do |i|
  dpi = dp[i]
  dpi1 = dp[i+1]
  0.upto(t_size-1).each do |j|
    if s[i] == t[j]
      dpi1[j+1] = dpi[j] + 1
    else
      dpi1[j+1] = dpi1[j] > dpi[j+1] ? dpi1[j] : dpi[j+1]
    end
  end
end

ans = ''
y = s_size
x = t_size

while y>0
  if dp[y-1][x] == dp[y][x]
    y-=1
  elsif dp[y][x-1] == dp[y][x]
    x-=1
  else
    y-=1
    x-=1
    ans << s_orig[y]
  end
end

# dp.each{|l| p l}

puts ans.reverse


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

int main() {
  string N ;
  cin >> N ;
  char a = N.at(0);
  char b = N.at(1);
  char c = N.at(2);
  
  if(a=='7' || b=='7' || c=='7'){
    cout <<"Yes"<< endl;
  }
  else {
    cout <<"No"<< endl;
  }
}


Measured memory_bytes: 3624
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_number(A, B) :-
    get_number(A),
    get_number(B).

get_number(A, B, C) :-
    get_number(A, B),
    get_number(C).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n\r\t', '', _, String).

get_chars(Xs) :-
    get_string(S),
    string_chars(S, Xs).

get_numbers(0, []).
get_numbers(N, [X|Xs]) :- 
    get_number(X), 
    N2 is N - 1, 
    get_numbers(N2, Xs).

put_numbers([]).
put_numbers([X|Xs]) :-
    writeln(X),
    put_numbers(Xs).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
    string_chars(S, S2) (S: string, S2: [char])
    to_lower(C, C2) (C: char? C2: code?)
    length(S, L),
    sub_string

    f(0, [], []).
    f(Z, [X|Xs], [Y|Ys]) :- X = Y, f(Z1, Xs, Ys), Z is Z1 + 1.
    f(Z, [_|Xs], [_|Ys]) :- f(Z, Xs, Ys).

    match: =, \=

    numeric: <,=<, >, >= (eval)
    lexicographically: @<. @=<, @>, @>=
    value?: =:=, =\= (eval)
    identical: ==, \==

    between(L,U,X): L <= X <= U
    nth0(I, Xs, Y), nth1(I, Xs, Y): (Xs,Y) -> I, (I, Xs) -> Y 

    sort(Key, Order, List, Sorted): Keyは通常0?, Orderは=なしが重複削除，=は重複保持
    \+ P(X) : not P(X)

    sum_list(Xs, Sum)
*/

f([]).
f([X|Xs]) :- X mod 2 =:= 1, !, f(Xs). 
f([X|Xs]) :- X mod 3 =:= 0, !, f(Xs). 
f([X|Xs]) :- X mod 5 =:= 0, !, f(Xs). 

main :-
    get_number(N),
    get_numbers(N, Xs),
    (f(Xs) -> writeln("APPROVED") ; writeln("DENIED")).

    % statistics(inferences, IC), writeln(IC).


Measured memory_bytes: 8036
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
s = int(input())
mod = 10 **9 + 7
N = s
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )


l = s//3
ans = 0
if s <= 2:
    print(0)
else:
    for i in range(l):
        ans += cmb(s%3 + 3 * i +(l-i)-1, (l-i)-1,mod)
    print(ans%mod)

Measured memory_bytes: 9208
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

//f(x in [MIN, l]) = false, f(x in [r, MAX]) = true
long long binsearch(long long l, long long r, std::function<bool(long long)> f){
    if(f(l)) return l;
    while(r - l > 1){
        long long m = (l + r) / 2;
        if(f(m)) r = m;
        else l = m;
    }
    return r;
}

ll N, K, A[200010];

bool f(ll x){
    ll cnt = 0;
    REP(i, N){
        if(A[i] >= 0){
            ll j;
            if(A[i] * A[N - 1] < x) j = N;
            else j = binsearch(0, N - 1, [&](ll k) -> bool{return A[i] * A[k] >= x;});
            cnt += j - (i < j);
        }else{
            ll j;
            if(A[i] * A[N - 1] >= x) j = N;
            else j = binsearch(0, N - 1, [&](ll k) -> bool{return A[i] * A[k] < x;});
            cnt += N - j - (i >= j);
        }
    }
    cnt /= 2;
    return cnt >= K;
}

signed main(){
    cin >> N >> K;
    REP(i, N) cin >> A[i];
    sort(A, A + N);
    PRINT(binsearch(-(ll)1e18, (ll)1e18, f) - 1);
    return 0;
}

Measured memory_bytes: 5136
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  ll a;
  string b;
  cin >> a >> b;
  string bb = "";
  rep(i, 0, b.size()) {
    if (b[i] == '.')
      continue;
    bb += b[i];
  }
  
  ll bl = stol(bb);
  cout << (a * bl) / 100 << endl;
}


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

int main() {
  char c;
  cin >> c;
  
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }

  
  
}

Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    h, w = list(map(int, input().rstrip('\n').split()))
    print("#" * (w + 2))
    for i in range(h):
        print("#" + str(input().rstrip('\n')) + "#")
    print("#" * (w + 2))


if __name__ == '__main__':
    slove()


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
template<typename T> bool chmax(T &a, T b) {if(a <= b){a = b; return true;}return false;}
template<typename T> bool chmin(T &a, T b) {if(a >= b){a = b; return true;}return false;}


int main(void){
    string s;
    cin >> s;
    int year = stoi(s.substr(0,4));
    int month = stoi(s.substr(5,2));
    int day = stoi(s.substr(8,2));
    if(year < 2019 || year == 2019 && month <= 4){
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }
}

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

const double pi = 3.14159265358979323846;
const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n, k; cin >> n >> k;
	vector<int> a(n);
	rep(i,n){
		cin >> a.at(i);
	}
	sort(a.begin(), a.end());
	int ans = 0;
	rep(i,k){
		ans += a.at(i);
	}
	cout << ans << endl;
} 

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

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

int main() {
    int k;cin>>k;
    string str;cin>>str;
    if(str.size()<=k)cout<<str<<endl;
    else{
        rep(i,k)cout<<str[i];
        cout<<"..."<<endl;
    }
    
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string.h>
using namespace std;

int main(void) {
	int a, b, sum = 0;
	scanf("%d %d", &a, &b);
	for (int i = 0; i < 2; i++) {
		if (a >= b) {
			sum += a;
			a--;
		}
		else {
			sum += b;
			b--;
		}
	}
	printf("%d\n", sum);
	return 0;
}

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

int main (){
  int N, K ;
  cin >> N >> K ;
  int x[110] ;
  for(int i=0;i<N;i++)
    cin >> x[i] ;
  int ans=0 ;
  for(int i=0;i<N;i++){
    if(x[i] < K - x[i])
      ans += 2*x[i] ;
    else
      ans += 2*(K-x[i]) ;
  }
  cout << ans << endl;
}

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

namespace ITP1_2_D_Circle_in_a_Rectangle
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split( ' ' ).Select( int.Parse ).ToArray();
            var r = input[ 4 ];
            var xMin = r;
            var yMin = r;
            var xMax = input[ 0 ] - r;
            var yMax = input[ 1 ] - r;
            var x = input[2];
            var y = input[3];
            string output;
            if ( xMin <= x && x <= xMax && yMin <= y && y <= yMax )
                output = "Yes";
            else
                output = "No";
            Console.WriteLine( output );
        }
    }
}

Measured memory_bytes: 19992
#include<stdio.h>

int main(void) {
	int i, j, k;
	int n, x;
	int cnt = 0;
	int a[10000];
	int flag = 1;
	
	
	
	do {
		scanf("%d %d", &n, &x);
		
		a[cnt] = 0;
		
		for(i = 0; i < n-2; i++) {
			for(j = i+1; j < n-1; j++) {
				for(k = j+1; k < n; k++) {
					if(i + j + k + 3== x) {
						a[cnt]++;
					}
				}
			}
		}
		
		if(n == 0 && x == 0) {
			flag = 0;
		}
		
		cnt++;
		
	} while(flag);
	
	for(i = 0; i < cnt-1; i++) {
		printf("%d\n", a[i]);
	}
	
	return 0;
}
	

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
using P=pair<int,int>;
int main(){
int N,K;
  string S;
cin>>N>>K;
  cin>>S;
 if(S.at(K-1)=='A'){
 S.at(K-1)='a';
 }
   else if(S.at(K-1)=='B'){
 S.at(K-1)='b';
 }
   if(S.at(K-1)=='C'){
 S.at(K-1)='c';
 }
  cout<<S;
}
  

Measured memory_bytes: 3560
<?php
/**
 * ABC128
 * A - Apple Pie
 */

// $s = trim(fgets(STDIN));
// fscanf(STDIN, "%d %d", $a, $b);
// $n = array_map('intval', explode(' ', trim(fgets(STDIN))));

fscanf(STDIN, "%d %d", $a, $p);

$p = $p + $a * 3;

echo intdiv($p, 2), PHP_EOL;


Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;
#include <iostream>
using namespace std;

const double pi = 3.14159265358979;

double findAngle(double hour, double min) {
	double h = (hour * 360) / 12 + (min * 360) / (12 * 60);

	double m = (min * 360) / (60);

	double angle = abs(h - m);

	if (angle > 180)
		angle = 360 - angle;

	return angle;
}

int main() {
    double A, B, H, M; cin >> A >> B >> H >> M;

    double angle = findAngle(H, M);

    cout << fixed << setprecision(15);
    cout << sqrt(A * A + B * B - 2 * A * B * cos(angle * pi / 180)) << endl;
    return 0;
}

Measured memory_bytes: 4212
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func contains(arr []string, str string) bool {
	for _, v := range arr {
		if str == v {
			return true
		}
	}
	return false
}

func main() {
	line := nextLine()
	arr := []string{"A", "C", "G", "T"}

	num := 0
	lastNum := 0
	for _, s := range line {
		if contains(arr, string(s)) {
			num++
		} else {
			if num > lastNum {
				lastNum = num
			}
			num = 0
		}
	}
	if num > lastNum {
		lastNum = num
	}

	fmt.Println(lastNum)
}


Measured memory_bytes: 640
n,k=map(int,input().split())
a=[0 for i in range(n+1)] #要素ｎこのリスト
for t in range(k):
	K=int(input()) #どっから持ってきた dか？
	b=list(map(int,input().split())) #aかもしや
	for i in b: #bの要素を取り出す
		a[i]+=1
print(a.count(0)-1)
	

Measured memory_bytes: 9132
#include <bits/stdc++.h>
#define PI 3.1415926535900
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define rrep(i, n) for (long long i = 0; (long long)(n) < i; i--)
#define Int long long
using namespace std;

int main() {
    Int a;
    cin >>a;



    std::cout << a*2*PI << std::endl;
    return 0;
}

Measured memory_bytes: 3780
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main{
	public static void main(String[] args) throws IOException{
		Scanner stdIn=new Scanner(System.in);
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String in=br.readLine();
			String[] s=in.split(" ");
			int a=Integer.parseInt(s[0]);
			String op=s[1];
			int b=Integer.parseInt(s[2]);
			switch(op){
			case "+":System.out.println(a+b);break;
			case "-":System.out.println(a-b);break;
			case "*":System.out.println(a*b);break;
			case "/":System.out.println(a/b);break;
			case "?":return;
			}
		}
	}
}

Measured memory_bytes: 26168
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    string o, e;
    cin >> o >> e;
    if (o.size() == e.size()) {
        for (int i = 0; i < o.size(); i++) {
            cout << o.at(i) << e.at(i);
        }
    } else {
        for (int i = 0; i < e.size(); i++) {
            cout << o.at(i) << e.at(i);
        }
        cout << o.at(o.size()-1);
    }
    cout << endl;
    return 0;
}

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

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var k = int.Parse(Console.ReadLine().Trim());
        var a = Array.ConvertAll(line, int.Parse);
        Console.WriteLine(a.Sum() + a.Max() * (Math.Pow(2, k) -1));
    }
}


Measured memory_bytes: 13268
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define ll  long long 
const ll INF=1LL<<60;
//const ll MOD=1000000007;
int MOD=998244353;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
using mint=modint1000000007;
int main(){
  ll a,b,ans=0;cin>>a>>b;
  dsu c(a+1);
  rep(i,b){
    ll x,y;cin>>x>>y;
    x--;
    y--;
    c.merge(x,y);
  }
  map<ll,ll>e;
  rep(i,a){
    ll t=c.leader(i);
    e[t]++;
  }
  cout<<e.size()-1;
}

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

typedef long long ll;
const int NMAX = 2e5 + 10;
const int MOD = 1e9 + 7;
int main(int argc, char const *argv[])
{
	int x,y;
	scanf("%d%d",&x,&y);
	for(register int i = 0;i <= x;i++)
		if(2*i + 4*(x - i) == y)
			return 0*puts("Yes");
	puts("No");
	return 0;
}

Measured memory_bytes: 3760
#include <iostream>

using namespace std;

int main()
{
  int a, b;

  while (cin >> a, cin >> b, a or b) {
    for (int i=0; i<a; ++i) {
      for (int j=0; j<b; ++j)
        cout << ((!((i+j) % 2)) ? '#' : '.');
      cout << endl;
    }
    cout << endl;
  }
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define MOD 1000000007
const int INF = 1LL<<30;

ll c[5];

int main(){
   int n;
   cin>>n;
   rep(i,n){
       string s;
       cin>>s;
       if(s[0]=='M') c[0]++;
       else if(s[0]=='A') c[1]++;
       else if(s[0]=='R') c[2]++;
       else if(s[0]=='C') c[3]++;
       else if(s[0]=='H') c[4]++;
   } 

   ll ans=0;
   for(int i=0;i<5;i++){
       for(int j=i+1;j<5;j++){
           for(int k=j+1;k<5;k++){
               ans+=c[i]*c[j]*c[k];
           }
       }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
#include<array>
#include<algorithm>
#include<deque>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<list>

int main(void) {
	using namespace std;
	int a, b, c, d;
	cin >> a >> b >> c;
	d = (a * b) / 2;
	cout << d << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

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

    int ans =  0;
    if (1 < N) {
        ans += N * (N-1) / 2;
    }
    if (1 < M) {
        ans += M * (M-1) / 2;
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
  int n; cin >> n;
  int a[300000];
  for(int i = 0; i < 3*n; i++){
    cin >> a[i];
  }
  sort(a, a+3*n);
  long long ans = 0;
  for(int i = n; i < 3*n; i+=2){
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned int uint;
typedef unsigned char uchar;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define ALL(container) (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) ((int)container.size())
#define mp(a,b) make_pair(a, b)
#define pb push_back
#define eb emplace_back
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define __builtin_popcount __builtin_popcountll

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    while(cin >> n){
        int x = (n % 2) ? n : n + 1;
        vector<pii> ans;
        REPS(i, n) {
            for(int j = 1;j < i; j ++) {
                if (i + j != x) ans.emplace_back(i, j);
            }
        }
        cout << ans.size() << endl;
        REP(i, ans.size()) {
            cout << ans[i].first << " " << ans[i].second << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 384
import math

def bs(n, a, b, hp, min=0, max=10**9):
    left = min
    right = max
    def count(num):
        base = b * num
        attackcount = 0
        diff = a-b
        for i in range(n):
            tmp = math.ceil((hp[i] - base) / diff)
            if tmp <= 0:
                pass
            else:
                attackcount += tmp
        if attackcount <= num:
            return True
        else:
            return False
    while left != right:
        mid = (left + right) // 2
        if count(mid):
            right = mid
        else:
            left = mid + 1
    return left

if __name__ == '__main__':
    n, a, b = map(int, input().split())
    hp = [int(input()) for i in range(n)]
    print(bs(n, a, b, hp))


Measured memory_bytes: 7088
a = gets.chomp.chars
q = gets.to_i
rflag = false

q.times do
  u, f, c = gets.chomp.split
  if u.to_i == 1
    rflag = !rflag
  else
    if !rflag && f.to_i == 1 || rflag && f.to_i == 2
      a.unshift(c)
    else
      a.push(c)
    end
  end
end
puts rflag ? a.reverse.join : a.join


Measured memory_bytes: 30228
n,x = gets.split.map(&:to_i)
kids = gets.split.map(&:to_i).sort
sum = kids.inject(:+)
counter = 0

if x == kids.inject(:+)
  puts kids.size
elsif x > kids.inject(:+)
  puts kids.size - 1
else
  kids.each do |k|
    next if x < k
    x -= k if
    counter += 1
  end
  puts counter
end


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

int insertionSort(int *A,int n,int g){
  int v, i, j, cnt=0;
  for(i=g; i<=n-1; i++){
    v = A[i];
    j = i - g;
    while(j>=0 && A[j]>v){
      A[j+g] = A[j];
      j = j-g;
      cnt++;
    }
    A[j+g] = v;
  }
  return cnt;
}

int main(){

  int *A, N, i, *G, cnt, m, j;

  scanf("%d",&N);
  A = (int *)malloc(sizeof(int)*N);
  for(i=0; i<=N-1; i++){
    scanf("%d",&A[i]);
  }

  //shellSort(A, n)
  cnt = 0;
  m = N/2;
  if(m > 100) m = 100;
  else if(0 >= m) m = 1;
  G = (int *)malloc(sizeof(int)*m);
  j = N/2;
  for(i=0; i<=m-1; i++){
    if(j <1) j = 1;  
    G[i] = j;
    j = j / 2;
  }

  for(i=0; i<=m-1; i++){
    cnt += insertionSort(A, N, G[i]);
  }

  printf("%d\n",m);
  printf("%d",G[0]);
  for(i=1; i<=m-1; i++){
  printf(" %d",G[i]);
  }
  printf("\n");
  printf("%d\n",cnt);
  for(i=0; i<=N-1; i++){
    printf("%d\n",A[i]);
  }

  return 0;
}


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

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

int main() {
	int k; cin >> k;
	long long ans = 0;
	for (int i = 1; i <= k; i++) {
		for (int j = 1; j <= k; j++) {
			for (int l = 1; l <= k; l++) {
				ans += gcd(i, gcd(j, l));
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 3632
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)

int main(){
  int a,b;
  cin >> a >> b;
  if(b%a==0)cout<<a+b<<endl;
  else cout<<b-a<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
 
void solve();

signed main () {
	cout.precision(10);
	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int t = 1; 
	// cin >> t;
	int tt = t;
	while (t--) { 
		solve();
	}
	return 0;
}
int f (int n) {
	int ans = 0;
	int nn = n;
	for (int i = 2; i * i <= nn; i += 1) {
		if (n % i)
			continue;
		ans++;
		while (n % i == 0)
			n /= i;
	}
	if (n > 1)
		ans++;
	return ans;
}
void solve() {
	int a, b;
	cin >> a >> b;
	int g = __gcd(a, b);
	cout << f(g) + 1;
}		


Measured memory_bytes: 256
s=input()
from itertools import groupby as gb
l=[(a,len(list(b))) for a,b in gb(s)]
k=int(input())
if s[-1]==s[0]:
    ans=sum(v//2 for kf,v in l[1:-1])
    if len(l)!=1:print(ans*k+l[0][1]//2+l[-1][1]//2+(l[-1][1]+l[0][1])//2*(k-1))
    else:print(l[0][1]*k//2)
else:
    print(sum(v//2 for kf,v in l)*k)
    

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;

const ll MOD = 1e+9 + 7;
const ll MAX_N = 1001;

ll A_count[MAX_N * MAX_N], B_count[MAX_N * MAX_N];

int main() {
    int N, M;
    cin >> N >> M;
    map<int, bool> mp_A, mp_B;
    bool is_ok = true;
    ll A, B;
    for (int i = 0; i < N; i++) {
        cin >> A;
        if (mp_A[A]) is_ok = false;
        mp_A[A] = true;
        A_count[A] = 1;
    }
    for (int i = 0; i < M; i++) {
        cin >> B;
        if (mp_B[B]) is_ok = false;
        mp_B[B] = true;
        B_count[B] = 1;
    }
    if (!is_ok) {
        cout << 0 << endl;
        return 0;
    }
    for (ll i = N * M; i > 1; i--) {
        A_count[i - 1] += A_count[i];
        B_count[i - 1] += B_count[i];
    }
    ll ans = 1;
    for (ll now_num = N * M; now_num >= 1; now_num--) {
        if (mp_A[now_num] && mp_B[now_num]) continue;
        else if (mp_A[now_num]) ans = (ans * B_count[now_num]) % MOD;
        else if (mp_B[now_num]) ans = (ans * A_count[now_num]) % MOD;
        else ans = (ans * (((A_count[now_num] * B_count[now_num]) % MOD - (N * M - now_num) + MOD) % MOD)) % MOD;
    }
    cout << ans << endl;
    return 0;
}

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

int n;

void solve(double x1, double x2, double y1, double y2, int cnt){ //2点で結ばれた線分をn回分割する。
    if(cnt == n) return; //n回目終わったので終了
    double nx1, nx2, ny1, ny2; //線分上の新たな点の座標
    nx1 = (2 * x1 + x2) / 3; ny1 = (2 * y1 + y2) / 3;
    nx2 = (2 * x2 + x1) / 3; ny2 = (2 * y2 + y1) / 3;
    double mx = (x1+x2)/2 + (-1)*(y2-y1)*sqrt(3)/6, my = (y1+y2)/2 + (x2-x1)*sqrt(3)/6; //出っ張りはベクトルの足し算
    // カウンターを1増やしてに放り込む
    //
    solve(x1, nx1, y1, ny1, cnt + 1);
    cout << fixed << setprecision(8) << nx1 << " " << ny1 << endl;
    solve(nx1, mx, ny1, my, cnt + 1);
    cout << fixed << setprecision(8) << mx << " " << my << endl;
    solve(mx, nx2, my, ny2, cnt + 1);
    cout << fixed << setprecision(8) << nx2 << " " << ny2 << endl;
    solve(nx2, x2, ny2, y2, cnt + 1);
}

int main(){
    cin >> n;
    cout << fixed << setprecision(8) << 0.0 << " " << 0.0 << endl;
    solve(0, 100, 0, 0, 0);
    cout << fixed << setprecision(8) << 100.0 << " " << 0.0 << endl;
    return 0;
}


Measured memory_bytes: 3224
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>

using namespace std;

typedef long long int lli;

#define N_MAX 100000
#define MOD 1000000007

void solv()
{
	lli N, A, B; scanf("%lld%lld%lld", &N, &A, &B);

	if (0 == (B - A) % 2){
		printf("%lld", (B - A) / 2);
	}
	else{
		lli val1 = (N - B) + 1 + (B - A - 1) / 2;
		lli val2 = (A - 1) + 1 + (B - A - 1) / 2;
		printf("%lld", val1 < val2 ? val1 : val2);
	}


	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using Int = long long int;
template<typename T> void swap(T *t1, T *t2){ T* tmp=t1; t1=t2; t2=tmp;}
Int tmpi = 0;
double tmpd = 0.0;


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

    Int n, k;
    Int a[100001];
    Int marker;
    cin >> n >> k;
    for(Int i=0; i<n; i++){
        cin >> a[i];
        if(a[i]==1) marker=i;
    }

    // Int i = 0;
    // Int cnt = 0;
    // if(marker==0){
    //     cnt += (n-1 + k-2)/(k-1);
    // }else{
    //     while(i<n){
    //         if(i<=marker && marker<=i+k-1){
    //             cnt++;
    //             i=marker+1;
    //             continue;
    //         }
    //         i += k-1;
    //         cnt++;
    //     }
    // }

    cout << (n-1 + k-2)/(k-1) << endl;

    return 0;
}

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

void solve(long long X) {
    ll s = 0;
    ll e = 1e9;
    while (s < e) {
	ll mid = s + ((e-s)/2);
	ll sum = (mid*(mid+1))/2;
        if (sum < X) {
	    s = mid + 1;
        } else {
	    e = mid;
        }
    }
    cout << s << endl;
}

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

  long long X;
  scanf("%lld", &X);
  solve(X);
  return 0;
}


Measured memory_bytes: 256
// Problem : B - Easy Linear Programming
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

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


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

    long a, b, c, k;
    cin >> a >> b >> c >> k;
    if (k <= a + b) cout << min(k, a);
    else cout << a - (k - a - b);
    
    return 0;
}


Measured memory_bytes: 3652
s = list(input())
t = list(input())
ls = len(s)
lt = len(t)
if ls < lt:
    print("UNRESTORABLE")
else:
    res = []
    for i in range(ls-lt+1):
        res.append(s[i:i+lt])
    tmp = []
    for i in range(len(res)):
        flag = True
        for j in range(lt):
            if res[i][j] == t[j] or res[i][j] == '?':
                pass
            else:
                flag = False
                break
        if flag:
            tmp.append(i)
    ans = []
    for i in tmp:
        q = []
        for j in range(0, i):
            q.append(s[j])
        for j in range(0, lt):
            q.append(t[j])
        for j in range(i+lt, ls):
            q.append(s[j])
        for j in range(ls):
            if q[j] == '?':
                q[j] = 'a'
        ans.append(''.join(q))
    if ans:
        print(min(ans))
    else:
        print("UNRESTORABLE")

Measured memory_bytes: 39024
module aoj;
import std.algorithm;
import std.ascii;
import std.range;
import std.stdio;
import std.string;

void main() {
  string name, type;
  for (;;) {
    string[] line = split(readln());
    name = line[0];
    type = line[1];
    if (type == "X") { break; }
    string[] words;
    ulong prev = 0;
    foreach (i; 1 .. name.length) {
      if (name[i] == '_') {
        words ~= name[prev .. i];
        prev = i + 1;
      } else if (isUpper(name[i])) {
        words ~= name[prev .. i];
        prev = i;
      }
    }
    words ~= name[prev .. $];
    if (type == "U") {
      writeln(join(words.map!capitalize, ""));
    } else if (type == "L") {
      write(toLower(words[0]));
      writeln(join(words[1 .. $].map!capitalize, ""));
    } else if (type == "D") {
      writeln(join(words.map!toLower, "_"));
    } else {
      assert(false);
    }
  }
}

Measured memory_bytes: 1016
#include <iostream>
using namespace std;
int main(void){
    
    while(true){
        int h;
        int w;
        cin >> h;   //scanf("%d",&x);
        cin >> w;
    
        if(h == 0 && w == 0){
            break;
        }
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}



Measured memory_bytes: 3072
solve :: Int -> Int -> [Int] -> Int
solve current count history
  | next `elem` history = count + 1
  | otherwise = solve next (count + 1) (next:history)
    where next = if even current
                 then current `div` 2
                 else 3 * current + 1

main :: IO ()
main = do
  s <- readLn
  print $ solve s 1 [s]

Measured memory_bytes: 508
#include <iostream>
using namespace std;
int main(void){
    int S;
    cin >> S;
    int k = S / 3600;
    S = S % 3600; // S = S - k * 3600;
    int m = S / 60;
    int s = S % 60;
    cout << k << ":" << m << ":" << s << endl;
    return 0;
}



Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
int dp[1111][55][55][4],n,t,x0,y01,T,D[11111];
int A[55][55][4];
int dx[]={0,1,0,-1};
int dy[]={-1,0,1,0};
set<P>ST;
int main(){
    memset(D,-1,sizeof(D));
    cin>>n>>x0>>y01>>t;
    r(i,n){
        int x,y,gx,gy,d,tx,ty;
        cin>>x>>y>>gx>>gy;tx=x,ty=y;
        if(x==gx){
            if(y<gy)d=2;
            else d=0;
        }
        if(y==gy){
            if(x<gx)d=1;
            else d=3;
        }
        while(!(x==gx&&y==gy)){
            A[x][y][d]=1;
            x+=dx[d];
            y+=dy[d];
        }
        d=(d+2)%4;
        while(!(x==tx&&y==ty)){
            A[x][y][d]=1;
            x+=dx[d];
            y+=dy[d];
        }
    }
    r(i,4)dp[0][x0][y01][i]=1;
    r(i,t){
        int d;
        char c;
        cin>>d>>c;
        T+=d;
        if(c=='N')D[T]=2;
        if(c=='E')D[T]=1;
        if(c=='S')D[T]=0;
        if(c=='W')D[T]=3;
    }
    r(i,T){
        r(X,55){
            r(Y,55){
                r(k,4){
                    if(!dp[i][X][Y][k])continue;
                    r(l,4){
                        if(!A[X][Y][l])continue;
                        if(l==(k+2)%4)continue;
                        if(D[i]==-1){
                            dp[i+1][X+dx[l]][Y+dy[l]][l]=1;
                        }
                        else{
                            if(l!=D[i]&&k!=D[i])continue;
                            dp[i+1][X+dx[l]][Y+dy[l]][l]=1;
                        }
                    }
                }
            }
        }
        if(i==T-1){
            r(X,55){
                r(Y,55){
                    r(k,4){
                        //cout<<X<<' '<<Y<<' '<<k<<endl;
                        if(!dp[T][X][Y][k])continue;
                        //cout<<X<<' '<<Y<<' '<<k<<endl;
                        if(k==D[T]||(A[X][Y][D[T]]&&k!=(D[T]+2)%4)){
                            cout<<X<<' '<<Y<<endl;
                            break;
                        }
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 22668
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    a, b, c, d = map(int, readline().split())

    def judge():
        if abs(a - c) <= d:
            return True
        if abs(a - b) <= d:
            if abs(b - c) <= d:
                return True
        return False

    if judge():
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61892
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;
int main()
{
    ll l, n;
    cin >> l >> n;
    vector<ll> xl(n);
    vector<ll> xr(n);
    rep(i, n)
    {
        cin >> xl[i];
        xr[i] = (l - xl[i]);
    }
    reverse(xr.begin(), xr.end());
    vector<ll> dpl(n + 1, 0);
    vector<ll> dpr(n + 1, 0);
    rep(i, n)
    {
        dpl[i + 1] = dpl[i] + xl[i];
        dpr[i + 1] = dpr[i] + xr[i];
    }
    ll ans = 0;
    rep(i, n + 1)
    {
        int id = (n - i) / 2;
        ll t = (dpr[i + id] - dpr[max(0, i - 1)] + dpl[id]) * 2LL;
        if ((n - i) % 2)
        {
            t += xl[id];
        }
        else
        {
            t -= xr[i + id - 1];
        }
        ans = max(ans, t);
        t = (dpl[i + id] - dpl[max(0, i - 1)] + dpr[id]) * 2LL;
        if ((n - i) % 2)
        {
            t += xr[id];
        }
        else
        {
            t -= xl[i + id - 1];
        }
        ans = max(ans, t);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6528