akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main(){
    ll n, k, ans=0;
    cin >> n >> k;
    vector<P> a(n);
    rep(i, n)cin >> a.at(i).first >> a.at(i).second;
    sort(all(a));
    rep(i, n){
        k -= a.at(i).second;
        if(k <= 0){
            ans = a.at(i).first;
            break;
        }
    }
    cout << ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
int main()
{
    int W, H, N;
    int x, y, a;
    cin >> W >> H >> N;

    int minx = 0, maxx=W;
    int miny = 0, maxy=H;
    
    rep(i, N){
        cin >> x >> y >> a;
        if(a==1){
            minx = max(minx, x);
        }else if(a==2){
            maxx = min(maxx, x);
        }else if(a==3){
            miny = max(miny, y);
        }else if(a==4){
            maxy = min(maxy, y);
        }
    }
    // cout << maxy << endl;
    // cout << miny << endl;
    // cout << maxx << endl;
    // cout << minx << endl;

    if(maxy < miny || maxx < minx){
        cout << 0 << endl;
    }else{
        cout << (maxy-miny)*(maxx-minx) << endl;
    }

    return 0;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define WMAX 10000
#define HMAX 10000

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

int A,B,C,N,W,ans,dp[HMAX][WMAX];
char H,D;
string S;
static const int dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){
	if(A+W < B){
		ans = B-A-W;
	}else if(B+W < A){
		ans = A-B-W;
	}else{
		ans = 0;
	}
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> W >> A >> B;
	
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

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

using namespace std;

int main()
{
    int n,m;
    cin >> n >> m;

    int check=0;
    for(int i=0;i<=m;i++) check|=(1<<i);

    for(int i=0;i<n;i++){
        int k;
        cin >> k;

        int check_now=0;
        for(int j=0;j<k;j++){
            int a;
            cin >> a;
            check_now|=(1<<a);
        }
        check&=check_now;
    }

    int cnt=0;
    for(int i=0;i<=m;i++){
        if((check>>i)&0x01) cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;

int main() {
#ifdef HIRO
  string file_path(QUIZ);
  ifstream cin(file_path + "/input.txt");
  std::cin.rdbuf(cin.rdbuf());
#endif
  int n;
  // int m;
  cin >> n;
  // cin >> m;
  int arr[n];
  for(int i = 0; i < n; ++i)
    cin >> arr[i];
  int stop = 0;
  int ans = 0;
  while(1) {
    for(int i = 0; i < n; ++i) {
      if(arr[i] % 2) {
        stop = 1;
        break;
      }
      else {
        arr[i] /= 2;
      }
    }
    if(stop) break;
    ++ans;
  }

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



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1e17
#define ninf -1e17
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
ll dp[200005][5];
ll a[200005];
ll l;
ll compute(int i, int cur)
{
    if(cur>4) return inf;
    if(i==l+1)
    {
        if(cur==4)
            return 0;
        return inf;
    }
    if(dp[i][cur]!=-1) return dp[i][cur];
    ll ans = inf;
    ll par = a[i+1]%2;
    ll off = 0;
    if(cur==0||cur==4)
        off = a[i+1];
    else if((cur==1&&par)||(cur==2&&!par)||(cur==3&&par))
        off = 1;
    else if((cur==1&&!a[i+1])||(cur==3&&!a[i+1]))
        off = 2;
    ans = MIN2(ans , compute(i, cur+1));
    ans = MIN2(ans, off + compute(i+1, cur));
    return dp[i][cur] = ans;
}
int main()
{
    she_told_me_dont_worry
    memset(dp, -1, sizeof dp);
    cin>>l;
    int i;
    FOR(i, 1, l+1)
    {
        cin>>a[i];
    }
    ll ans = compute(0, 0);
    cout<<ans;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}


Measured memory_bytes: 19072
N, X = gets.split.map(&:to_i)
towns = gets.split.map(&:to_i).sort
first_point = nil
diff_array = []


diff = (towns[-1] - X).abs

towns.each_with_index{|i, idx|
  if diff > (X-i).abs
    first_point = i
    diff = (X-i).abs
  end
  unless idx == 0
    diff_array << (towns[idx]-towns[idx-1])
  end
}

diff_array << diff
if diff_array.length == 1
  diff_array << diff
end

diff_array.sort!

def gcd(x, y)
  if y == 0
    return y
  end
 
  if y > x
    gcd(y, x)
  end
 
  r = x % y
  if r.zero?
    return y
  end
 
  gcd(y, r)
end

result = diff_array.reduce{|memo, item|
  gcd(memo, item)
}
puts result

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

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    
    auto itmax=max_element(a.begin(),a.end());
    auto itmin=min_element(a.begin(),a.end());
    int idx,ini,diff;
    if(*itmax<-*itmin){
        idx=itmin-a.begin(),ini=n-1,diff=-1;
    }
    else{
        idx=itmax-a.begin(),ini=0,diff=1;
    }
    cout<<2*(n-1)<<endl;
    for(int i=0;i<n;i++){
        if(idx!=i) cout<<idx+1<<" "<<i+1<<endl;
    }
    for(int i=0;i<n-1;i++){
        cout<<ini+1<<" "<<ini+diff+1<<endl;
        ini+=diff;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

 class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int parent[] = new int[n + 1];
		int size[] = new int[n + 1];
		for (int i = 0; i < n; i++) {
			parent[i] = i;
			size[i] = 1;
		}
		for (int i = 0; i < m; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();
			union(parent, size, x, y);
		}
		int ans = 0;
		for (int i = 0; i < n; i++) {
			ans = Math.max(ans, size[i]);
		}
		System.out.println(ans);
	}
	
	static void union(int parent[], int size[], int i, int j) {
		int root1 = root(parent, i);
		int root2 = root(parent, j);
		if (root1 == root2) return;
		
		if (size[root1] > size[root2]) {
			size[root1] += size[root2];
			parent[root2] = root1;
		}
		else {
			size[root2] += size[root1];
			parent[root1] = root2;
		}
	}
	
	static int root(int parent[], int i) {
		while (parent[i] != i) {
			i = parent[i];
		}
		
		return i;
	}
}

Measured memory_bytes: 61592
n  = int(input())
xs = [int(x) for x in input().split(" ")]
ys = [int(x) for x in input().split(" ")]
r  = 0
c  = 0

for i in range(0, n):
	a  = min(xs[i], r)
	b  = min(xs[i] - a, ys[i])
	r  = ys[i] - b
	c += a + b

c += min(xs[n], r)

print(c)


Measured memory_bytes: 18624
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
//#include <math.h>
signed main(void) 
{
    ll n, r;
    r = 0;
    string s;
    cin >> n >> s;
    
    rep(i, n-2) {
        if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') {
            r++;
        }
    }
    
    cout <<r;
    return 0;
}

Measured memory_bytes: 3516
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <algorithm>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
#include <cmath>
#include <stack>
#include <limits>
#include <ctime>

using namespace std;

#define ll long long
#define sc(n) static_cast<ll>(n)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {
	IO;
#ifdef _DEBUG
	ifstream cin("In.txt");
#endif	
	ll a, b, m, mx=1000007,mx2=1000007;
	cin >> a >> b >> m;
	vector<ll>va(a),vb(b);
	for (auto& i : va) {
		cin >> i;
		mx2 = min(i, mx2);
	}
	for (auto& i : vb) {
		cin >> i;
		mx = min(i, mx);
	}
	ll tans = mx + mx2;
	ll x, y, c;
	for (int i = 0; i < m; i++) {
		cin >> x >> y >> c;
		x--;
		y--;
		tans = min(tans, va[x] + vb[y] - c );
	}
	cout << tans << endl;
	return 0;
}

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

int main(){
    ll N;
    cin >> N;

    ll L = 0, R = N;
    string sL, sR, sM;
    cout << 0 << endl;
    cin >> sL;
    if(sL == "Vacant"){
        cout << L << endl;
        return 0;
    }
    sR = sL;
    while(true){
        ll M = (L+R)/2;
        cout << M << endl;
        cin >> sM;
        if(sM == "Vacant"){
            cout << M << endl;
            break;
        }

        if((M-L-1)%2 == 1){
            if(sL == sM){
                //探索に不適
                L = M;
                sL = sM;
            }else{
                //確実に空席あり
                R = M;
                sR = sM;
            }
        }else{
            if(sL == sM){
                //確実に空席あり
                R = M;
                sR = sR;
            }else{
                //探索に不適
                L = M;
                sL = sM;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 852
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        if((x * 2 <= y) && (y <= x * 4) && (y % 2 == 0)) {
		System.out.println("Yes");
		}else{
		System.out.println("No");
		}
    }
}

Measured memory_bytes: 35584
import numpy as np

def main():
    n, k = map(int, input().split())
    A = np.array(list(map(int, input().split())))
    MOD = 10 ** 9 + 7
    #転倒数、Aの中で
    C1 = np.array([0] * n)
    C2 = np.array([0] * n)
    for i in range(n):
        C1[i] = np.count_nonzero(A[i:] < A[i])
        C2[i] = np.count_nonzero(A < A[i])
    c1,c2 = C1.sum(),C2.sum()
    ans = 0
	
    ans += c1 * k % MOD
    ans += c2 * (k * (k - 1) // 2 % MOD)

    print(ans % MOD)

if __name__ == "__main__":
    main()


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

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

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

struct union_find {
    vi P, R, S;

    union_find(int N) {
        P.resize(N), R.resize(N, 0), S.resize(N, 1);
        for (int i = 0; i < N; i++)
            P[i] = i;
    }

    int rep(int i) {
        if(P[i] != i) P[i] = rep(P[i]);
        return P[i];
    }

    bool unio(int a, int b) {
        a = rep(a), b = rep(b);
        if(a == b) return false;
        if(R[a] < R[b]) swap(a, b);
        P[b] = a;
        S[a] += S[b];
        if(R[a] == R[b]) R[a]++;
        return true;
    }
};

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

    int N, M;
    cin >> N >> M;

    int ans = N;
    union_find uf(N);
    for (int e = 0, x, y, z; e < M; e++) {
        cin >> x >> y >> z;
        ans -= uf.unio(x-1, y-1);
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 1408
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <queue>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

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

	string s, t;
	cin >> s >> t;

	vector<vector<int>> dp(s.length() + 1, vector<int>(t.length() + 1));

	for (int i = 1; i <= s.length(); i++) {
		for (int j = 1; j <= t.length(); j++) {

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

		}
	}
	
	string ans;
	int x = s.length(), y = t.length();
	while (x > 0 && y > 0) {

		if (dp[x][y] == dp[x - 1][y]) x--;
		else if (dp[x][y] == dp[x][y - 1]) y--;
		else {
			ans = s[x - 1] + ans;
			x--, y--;
		}
	}

	cout << ans << "\n";

	return 0;

}

Measured memory_bytes: 35584
#include<iostream>
#include<utility>
#include<tuple>
#include<set>
#include<list>
#include<vector>
#include<map>
#include<algorithm>

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FUNCTION__ << endl;
#define int long long

const long long MAXN = 1e6;
const long long MOD = 1e9+7;
const long long INF = __LONG_LONG_MAX__ / 2;

using namespace std;

int a[MAXN];

signed main(){
    int N;
    cin >> N;
    for(int i =0;i<N;i++) cin >> a[i];
    list<int> b;
    for (int i = 0; i < N/2*2; i+=2){
      b.push_back(a[i]);
      b.push_front(a[i+1]);
    }
    if (N%2==0){
      for(auto bi:b){
        cout << bi << " ";
      }
    }else{
      cout << a[N-1] << " ";
      reverse(b.begin(),b.end());
      for(auto bi:b){
        cout << bi << " ";
      }
    }
    return 0;
}


Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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(){
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll four=0, two=0, one=0;
    rep(i,n){
        if(a[i]%4==0) four++;
        else if(a[i]%2==0) two++;
        else one++;
    }
    if(one>four+1) cout<<"No"<<endl;
    else if(one==four+1){
        if(two==0) cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
 

int main()
{
  int n, t;
  cin >> n >> t;

  int m = 1000000000;
  int count = 0;

  while(count < n)
  {
      int c, tn;
      cin >> c >> tn;
      if(t >= tn && m > c)
      {
          m = c;
      }

      count++;
  }

  if(m == 1000000000)
  {
      cout << "TLE";
      
  }
  else
  {
      cout << m;
  }

  return 0;
}

Measured memory_bytes: 256
N,M = map(int, input().split())
g = {}
for v in range(1,N*3+1):
    g[v] = []

for _ in range(M):
    u,v = map(int, input().split())
    g[u + N*0].append(v + N*1)
    g[u + N*1].append(v + N*2)
    g[u + N*2].append(v + N*0)

S,T = map(int, input().split())

visiting = [S]
visited = {S:0}
while visiting:
    v = visiting.pop(0)
    if v == T:
        break

    for v2 in g[v]:
        if v2 not in visited:
            visiting.append(v2)
            visited[v2] = visited[v]+1

if T in visited:
    print(visited[T] // 3)
else:
    print(-1)


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


int main()
{

    string t;
    cin >> t;

    rep(i, t.length()) if (t[i] == '?') t[i] = 'D';

    cout << t << endl;

    return 0;
}

Measured memory_bytes: 3756
# ABC167b


def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    # 再帰関数を使わない限りPypyで出すこと

    def dump(*args):
        sys.stderr.write(str(args))

    a, b, c, k = map(int, input().split())
    at = min(a, k)
    nk = k-at
    bt = min(b, nk)
    nk = nk-bt
    ct = min(c, nk)
    print(at - ct)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
n, a, b = (int(x) for x in input().split())
s = input()
dom = abr = 0
for i in range(n):
  if s[i] == 'a':
    if dom + abr < a + b:
      print('Yes')
      dom += 1
    else:
      print('No')
  elif s[i] == 'b':
    if dom + abr < a + b and abr < b:
      print('Yes')
      abr += 1
    else:
      print('No')
  else:
    print('No')


Measured memory_bytes: 4016
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<stdio.h>
using namespace std;



void solve() {

	string s;
	double A , B , X;
	cin >> A >> B >> X;
	double theta;
	double pi = acos(-1);
	if (A*A*B / 2 < X) {
		
		theta = atan((2/(A*A*A))*(A*A*B-X))*180/pi;
	}
	else {
		
		theta = atan(A*B*B/(2*X))*180/pi;
	}

	
	printf("%0.7f\n", theta);
	

}


int main() {
	solve();

}

Measured memory_bytes: 512
n,x,y = map(int,input().split())
l = [0]*(n-1)
for i in range(1,n):
    for j in range(i+1,n+1):
        #print(i,j)
        '''
        1 2,1 3,1 4
        2 3,2 4
        3 4
        '''
        if i<=x and j>=y:
            dis = min(j-i,x-i +1+ j-y)
            l[dis-1] += 1
            #print(i,j,dis-1)
        elif i>=x and j<=y:
            dis = min(j-i,i-x+y-j+1)
            l[dis-1] += 1
        elif i<=x and x<=j<=y:
            dis = min(j-i,x-i+y-j+1)
            l[dis-1] += 1
        elif x<=i<=y and j>=y:
            dis = min(j-i,i-x+j-y+1)
            l[dis-1] += 1
        elif i<=x and j<=x:
            dis = j-i
            l[dis-1] += 1
        elif i>=y and j>=y:
            dis = j-i
            l[dis-1] += 1
for kkk in l:
    print(kkk)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
#define pi  acos(-1)
const int w=2e5+5;
const ll mod=1e9+7;
char a[w];
ll dp[2][w];
int c[w];
map<int,int> ma;
int main()
{
    int i,j;
    int n,m;
    cin>>n>>m;
    scanf("%s",a+1);
    if(m==2||m==5)
    {
        ll ans=0;
        for(i=1;i<=n;i++)
        {
            for(j=0;j<m;j++)
                dp[0][j]=dp[1][j],dp[1][j]=0;
            int x=(a[i]-'0')%m;
            dp[1][x]++;
            for(j=0;j<m;j++)
                dp[1][(j*10+x)%m]+=dp[0][j];
            ans+=dp[1][0];
        }
        cout<<ans<<endl;
    }
    else
    {
        ll ans=0;
        int x=0,u=1;
        ma[0]++;
        for(i=n;i>=1;i--)
        {
            int aa=a[i]-'0';
            x=(x+aa*u%m)%m;
            ans+=ma[x];
            ma[x]++;
            u=u*10%m;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 2816
n=int(input())
al={keys:[0 for i in range(n)] for keys in [chr(ord('a') + j) for j in range(26)]}
for i in range(n):
    s=input()
    for j in s:
        al[j][i]+=1
x=""
for i in [chr(ord('a') + j) for j in range(26)]:
    x+=i*min(al[i])
print(x)

Measured memory_bytes: 3060
import sys
n = int(input())
ls = [int(input()) for _ in range(n)]
ls.sort()
y = lambda x : x%10
mx = sum(ls)
new = list(map(y,ls))
if sum(new) == 0:
    print(0)
    sys.exit()
if mx%10 != 0:
    print(mx)
else:
    for i in range(n):
        nx = mx - ls[i]
        if nx%10 != 0:
            print(nx)
            sys.exit()

Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
    int n;
    int i;
    int x;
    char mark;
    int S[13] = {0};
    int H[13] = {0};
    int C[13] = {0};
    int D[13] = {0};

    scanf("%d", &n);

    for (i = 1; i <= n; i++)
    {
        scanf(" %c%d", &mark, &x);

        if ('S' == mark)
        {
            S[x - 1] = 1;
        }
        else if ('H' == mark)
        {
            H[x - 1] = 1;
        }
        else if ('C' == mark)
        {
            C[x - 1] = 1;
        }
        else if ('D' == mark)
        {
            D[x - 1] = 1;
        }
    }
    for (i = 0; i <= 12; i++)
    {
        if (S[i] == 0)
        {
            printf("S %d\n", i + 1);
        }
    }
    for (i = 0; i <= 12; i++)
    {
        if (H[i] == 0)
        {
            printf("H %d\n", i + 1);
        }
    }
    for (i = 0; i <= 12; i++)
    {
        if (C[i] == 0)
        {
            printf("C %d\n", i + 1);
        }
    }
    for (i = 0; i <= 12; i++)
    {
        if (D[i] == 0)
        {
            printf("D %d\n", i + 1);
        }
    }
    return 0;
}


Measured memory_bytes: 2744
#include<iostream>
#include<cctype>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<cctype>
#include<cstring>
#include<utility>
#include<cmath>
using namespace std;


int main() {
    int r, g;
    cin >> r >> g;

    cout << g * 2 - r << endl;

    return 0;
}

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

int main()
{
    using namespace std;
    int32_t n;
    cin >> n;
    
    vector<int32_t> a(n+1, 0);
    for (auto iter = a.begin()+1; iter != a.end(); ++iter) {
        cin >> *iter;
    }
    
    int32_t count = 0, light = 1;
    while (count <= n && light != 2) {
        light = a[light];
        count++;
    }
    
    if (count > n) {
        count = -1;
    }
    
    cout << count << endl;
}

Measured memory_bytes: 640
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e9+7;
const llint big=1e18+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
int main(void){
	//bitsetで行くか?
	int n,i,all=0;cin>>n;
	bitset<2005000> bi;bi[0]=true;
	for(i=0;i<n;i++){
		int a;cin>>a;all+=a;
		bi|=(bi<<a);
	}
	for(int i=(all+1)/2;i<=all;i++){
		if(bi[i]){cout<<i<<endl;RE;}
	}RE;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
using namespace std;

int l[110];

int N,X;
int main (){
    cin >> N >> X;
    for(int i=0; i<N; i++) cin >> l[i];
    int r = 0;
    int cnt = 0;
    while( r <= X && cnt <= N) {
        r += l[cnt];
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
main = do
  line <- getLine
  let [a,b]       = ((map read $ words line) :: [Int])
      rel [a,b] 
        | a < b   = "a < b"
        | a > b   = "a > b"
        | a == b  = "a == b" in
    putStrLn $ rel [a,b]



Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int n, sum = 0;
int a[N], f[N];

int32_t main()
{
	IOS;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		f[a[i]]++;
		sum += a[i];
	}
	int q;
	cin >> q;
	while(q--)
	{
		int b, c;
		cin >> b >> c;
		sum -= f[b] * b;
		sum += f[b] * c;
		f[c] += f[b];
		f[b] = 0;
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 5200
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N;
  cin>>N;
  vector<ll>B(N-1);
  for(ll i=0;i<N-1;i++)cin>>B[i];
  ll ans=0;
  ans=B[0]+B[N-2];
  for(ll i=0;i<N-2;i++){
    ans+=min(B[i],B[i+1]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mex 100005
long long dp[101][mex];

int main(){
  int n,w;
  cin>>n>>w;
  vector<pair<int,int> > v(n);
  for(int i=0;i<n;i++)
     cin>>v[i].first>>v[i].second;
  
  
  for(int i=0;i<=n;i++){
    for(int j=0;j<100001;j++){
       dp[i][j]=INT_MAX;
    }
  }
  dp[0][0]=0;
  for(int i=1;i<=n;i++){
    for(int j=0;j<100001;j++){
      if(j==0)
        dp[i][j]=0;
      else if(j>=v[i-1].se){
		  //if(dp[i-1][j-v[i-1].se]!=INT_MAX)
           dp[i][j]=min(dp[i-1][j],v[i-1].fi+dp[i-1][j-v[i-1].se]);
	   }
      else
       dp[i][j]=dp[i-1][j];
    }
  }
  
  for(int i=100000;i>=0;i--){
    if(dp[n][i]<=w){
      cout<<i;
      break;
    }
  }
}
    


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

#define limit 3500

int main() {

    long long int N;
    cin >> N;

    for (long long int h = 1; h <= limit; h++) {
        for (long long int n = 1; n <= limit; n++) {
            if (4*h*n - n*N - h*N <= 0) {continue;}
            long long int w = (N*h*n) / (4*h*n - n*N - h*N);
            if (4.0/N == 1.0/h + 1.0/n + 1.0/w) {
                cout << h << " " << n << " " << w << endl;
                return 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 256
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで
//vector<vector<ll>> piyo(tate,vector<ll> (yoko));

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1000000000
#define ll long long
#define ln cout<<endl;
#define Yes cout<<"Yes"<<endl;
#define No cout<<"No"<<endl;
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str1,str2;
    cin>>n;
    vector<ll> v(n);
    rep(i,n)cin>>v[i];
    sort(v.begin(),v.end());
    cout<<v[n/2]-v[n/2-1]<<endl;

}


Measured memory_bytes: 1024
S = input()
N = len(S)
divs = [0]
for i in range(N - 1):
    if S[i] == "L" and S[i + 1] == "R":
        divs.append(i + 1)
divs.append(N)
ans = [0] * N
for start, end in zip(divs, divs[1:]):
    sub = S[start:end]
    M = end - start
    for j in range(M - 1):
        if sub[j] == "R" and sub[j + 1] == "L":
            if j % 2:
                ans[start + j] = M // 2
            else:
                ans[start + j] = (M + 1) // 2
            ans[start + j + 1] = M - ans[start + j]
print(" ".join(map(str, ans)))


Measured memory_bytes: 19148
#include<bits/stdc++.h>
using namespace std;
int a[105];
int main()
{
    for(int i=1;i<=5;i++)
    cin>>a[i];
    for(int i=1;i<=5;i++)
    {
        if(a[i]!=i)
        {
            cout<<i;
            return 0;
        }
    }
}

Measured memory_bytes: 3592
n, m = map(int, input().split())

a = 1
b = m + 1
while a < b:
  print(a, b)
  a += 1
  b -= 1

a = m + 2
b = 2 * m + 1
while a < b:
  print(a, b)
  a += 1
  b -= 1

Measured memory_bytes: 70352
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;
const int mod = 1e9+7;

int main() {
    int sx, sy, tx, ty; 
    cin >> sx >> sy >> tx >> ty;
    int m_x = tx-sx;
    int m_y = ty-sy;
    rep(i,m_x) cout << 'R';
    rep(i,m_y) cout << 'U';
    rep(i,m_x) cout << 'L';
    rep(i,m_y) cout << 'D';
    cout << 'D';
    rep(i,m_x+1) cout << 'R';
    rep(i,m_y+1) cout << 'U';
    cout << 'L';
    cout << 'U';
    rep(i,m_x+1) cout << 'L';
    rep(i,m_y+1) cout << 'D';
    cout << 'R';
    cout << endl;
}

Measured memory_bytes: 256
N,Q = map(int,input().split())
S = input()
cumulative = []
value = 0
flagA = False
for c in S:
    if flagA:
        if c=="C":
            value += 1
        if c=="A":
            flagA = True
        else:
            flagA = False
    else:
        if c=="A":
            flagA = True
        else:
            flagA = False
    cumulative.append(value)
for _ in range(Q):
    a,b=map(int,input().split())
    x=a-1
    y=b-1
    print(cumulative[y]-cumulative[x])

Measured memory_bytes: 6152
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define inf 1000000000000000001
#define mod 1000000007
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define pb push_back
#define f first
#define s second
#define fast_cin ios_base::sync_with_stdio(false);cin.tie(NULL);
#define precise fixed(cout);cout<<setprecision(16);
#define Set(N,p) N=((N)|((1LL)<<(p)))
#define Reset(N,p) N=((N)&(~((1LL)<<(p))))
#define Check(N,p) (!(((N)&((1LL)<<(p)))==(0)))
#define POPCOUNT __builtin_popcountll
#define RIGHTMOST __builtin_ctzll
#define LEFTMOST(x) (63-__builtin_clzll((x)))
#define NUMDIGIT(x,y) (((vlong)(log10((x))/log10((y))))+1)
#define OUT(x) for(auto a:x) cout << a << " "; cout << endl;
#define OK cout << "@===================ok===================@" <<endl;
#define WTF cout <<"< "<<lo<<" | "<< hi <<" >" << endl;

using namespace std;

int main()
{
    string s,t;
    cin >> s >> t;
    int n=s.size();
    int res=0;
    for(int i=0;i<n;i++){
        if(s[i]!=t[i]) res++;

    }
    cout << res <<"\n";
}


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

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

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

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

int main() {
  int s;
  cin >> s;
  if (s <= 2) {
    cout << 0 << endl;
    return 0;
  }

  int max_div = s / 3;
  mint ans;
  ans.x = 0;
  for (int i = 1; i <= max_div; i++) {
    ans += comb(s - 2 * i - 1, i - 1);
    // ans += (s - 2 * i - 1)comb(i - 1);
  }

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


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

bool check_right_triangle(int a, int b, int c)
{
    if(a * a == b * b + c * c || b * b == c * c + a * a || c * c == a * a + b * b)
        return true;
    else return false;
}

int main()
{
    const int max_num_of_data = 1000;
    const int min = 1;
    const int max = 1000;
    
    int num_of_data;
    //std::cout << "データ数の入力" << std::endl;
    std::cin >> num_of_data;
    if(num_of_data > max_num_of_data){
        std::cout << "データ数<=" << max_num_of_data << std::endl;
        return 1;
    }
    
    int a, b, c;
    //std::cout << num_of_data << "個の整数データa b cの入力" << std::endl;
    for(int i = 0; i < num_of_data; ++i){
        std::cin >> a >> b >> c;
        if(min <= a && a <= max && min <= b && b <= max && min <= c && c <= max){
            if(check_right_triangle(a, b, c))
                std::cout << "YES" << std::endl;
            else
                std::cout << "NO" << std::endl;
        }else{
            --i;
            std::cout << "整数は" << min <<"以上" << max << "以下に設定" << std::endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1160
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

a,b,x=MAP()

def f(n):
    return (a*n)//b-a*(n//b)

if b<=x:
    print(f(b-1))
else:
    print(f(x))


Measured memory_bytes: 9188
from functools import reduce

# 入力
N, Q = map(int, input().split())
s = input()
t, d = zip(*(input().split() for _ in range(Q)))


# めぐる式二分法
def bis(p, ok=-1, ng=10**18):
    mid = (ok + ng) // 2
    return (
        ok if abs(ok - ng) == 1 else
        bis(p, mid, ng) if p(mid) else
        bis(p, ok, mid)
    )


# Q回の呪文詠唱後、マスiにいたゴーレムが移動したマス。ただし、
# 0の場合、マス1から左に移動しようとして消滅したことを、
# N + 1の場合、マスNから右に移動しようとして消滅したことを表す。
def f(i):
    return reduce(
        lambda j, q: (
            0 if j == 0 else
            j - 1 if 1 <= j <= N and s[j - 1] == q[0] and q[1] == 'L' else
            j if 1 <= j <= N and s[j - 1] != q[0] else
            j + 1 if 1 <= j <= N and s[j - 1] == q[0] and q[1] == 'R' else
            N + 1
        ),
        zip(t, d),
        i
    )


# 二分法により、マス1から左に移動しようとして消滅したゴーレムの数と
# マスNから右に移動しようとして消滅したゴーレムの数の和を求める
ans = (
    bis(lambda i: f(i) == N + 1, ok=N + 1, ng=0) -
    bis(lambda i: f(i) == 0, ok=0, ng=N + 1) -
    1
)
print(ans)


Measured memory_bytes: 118704
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr(i, n) for (int i = 0; i < (int)n; i++)
#define frab(i, a, b) for (int i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef long double ld;

const ll INF = 2e8 + 10;
const ld PI = acos(-1);
const ld EPS = 1e-9;
const ll MOD = 1e9 + 7;
const int M = 1003;
const int N = 1e6 + 10;



int main() {
    //freopen("a.in", "r", stdin);
    int n;
    cin >> n;
    if (n % 10 == 9 || n / 10 == 9)
        cout << "Yes";
    else
        cout << "No";
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#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,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	int n, k; cin >> n >> k;
    if(2 * k - 1 > n) {
        cout << -1 << endl;
        return;
    }
    int a = k + n / 2, b = k + 2 * n - 1, c = k + 3 * n - 1;
    rep(i, (n + 1) / 2) {
        cout << a << " " << b << " " << c << endl;
        a ++;
        b -= 2;
        c --;
    }
    a = k, b = k + 2 * n - 2;
    rep(i, (n / 2)) {
        cout << a << " " << b << " " << c << endl;
        a ++;
        b -= 2;
        c--; 
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 2304
#include<stdio.h>
int main(void){
  long int n,k,t;
  scanf("%ld%ld", &n, &k);
  t=n%k;
  if(2*t<k){
    printf("%ld", t);
  }
  else{
    printf("%ld", k-t);
  }
  return 0;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    int min_num_index = 0;
    int ans = 0;

    vector<int> A(N);
    for(int i=0; i < N; i++) {
        cin >> A.at(i);
        if (A.at(i) == 1) {
            min_num_index = A.at(i);
        }
    }

    // 最初だけ考慮が必要
    if(min_num_index <= K || (N - min_num_index - 1) <= K) {
        ans++;
        ans += (N - K + (K-2)) / (K-1);
    } else {
        ans += (N + (K-2)) / (K-1) ;
    }


    cout << ans << endl;

    return 0;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> cnt(N);
    rep(i, 0, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        cnt[a]++;
        cnt[b]++;
    }
    bool ok = true;
    rep(i, 0, N) if(cnt[i] % 2) ok = false;
    cout << (ok ? "YES" : "NO") << '\n';
    return 0;
}


Measured memory_bytes: 640
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

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

    bool isOddOk = true;
    bool isEvenOk = true;
    rep(i, S.size()) {
        if((i + 1) % 2 == 1) { // odd
            if(S.at(i) != 'R' && S.at(i) != 'U' && S.at(i) != 'D') {
                isOddOk = false;
            }
        } else { // even
            if(S.at(i) != 'L' && S.at(i) != 'U' && S.at(i) != 'D') {
                isEvenOk = false;
            }
        }
    }

    string ans = (isOddOk && isEvenOk) ? "Yes" : "No";

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  int sum=0;
  int pos=0;
  for(int i=0; i<N; i++){
    sum += abs(A[i]-pos);
    pos = A[i];
  }
  sum += abs(pos);
  pos = 0;
  for(int i=0; i<N-1; i++){
    int ans;
    ans = sum;
    ans -= abs(pos-A[i]);
    ans -= abs(A[i+1]-A[i]);
    ans += abs(pos-A[i+1]);
    cout << ans << endl;
    pos = A[i];
  }
  int ans = sum;
  ans -= abs(pos-A[N-1]);
  ans -= abs(A[N-1]);
  ans += abs(pos);
  cout << ans << endl;
  return 0;
}


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

int main()
{
	long long n; cin >> n;

	int transNum = 5;
	long long minC = 9223372036854775807LL;

	vector<long long > c(transNum); for (int i = 0; i < transNum; i++) { cin >> c[i];
		minC = min(minC, c[i]);
	}

	cout << (n + minC - 1) / minC + 4 << endl;

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>
	
#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
#define INF 1000000000000000000
//static const long double pi = 3.1415926535897932;
	
using namespace std;
using ll = long long int;
using ull = unsigned long long;
	
char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}
	
char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}
	
float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}
	
ll combination(ll n, ll r) { // nCr の計算
	if (n < 0 || r < 0 || r > n) return -1;
	
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;
	
	vector<ll> num(r);
	vector<ll> den(r);
	
	for (ll i = 0; i < r; i++) {
		num[i] = n - r + i + 1;
		den[i] = i + 1;
	}
	
	for (ll p = 2; p <= r; p++) {
		ll pivot = den[p - 1];
		if (pivot > 1) {
			ll offset = (n - r) % p;
			for (ll k = p - 1; k < r; k += p) {
				num[k - offset] /= pivot;
				den[k] /= pivot;
			}
		}
	}
	ll result = 1;
	for (ll k = 0; k < r; k++) {
		if (num[k] > 1) result *= num[k];
	}
	return result;
}
	
vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();
	
	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}
	
	return vec;
}
	
bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}
	
struct rest {
	string s;
	int p;
	int num;
	
	/* -------------------------------------
	sort関数を使用したときのソートの定義をする。
	まずは文字列sでソートする。
	文字列sが同じだった場合、pでソートする。
	この条件を参考演算子で表現(ifでもOK)
	-------------------------------------*/
	bool operator<(const rest& right) const {
		return s == right.s ? p > right.p : s < right.s;
	}
};
	
int main() {
	int n;
	cin >> n;
	ll sum = 1;
	for (int i = 0; i < n; i++) {
		ll a;
		cin >> a;
		if (a == 0) {
			cout << 0 << endl;
			return 0;
		}
		sum *= a;
	}
	if (0 < sum && sum <= INF) {
		cout << sum << endl;
	} else {
		cout << -1 << endl;
	}
	return 0;
}

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

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

int main() {
  ll n;
  cin >> n;
  ll ans = n / 2;
  if (n % 2 == 1) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

ll gcd(ll a, ll b) {
  ll t;
  while(b) t = a % b, a = b, b = t;
  return a;
}

int main(void) {
  ll x;
  scanf("%lld", &x);
  printf("%lld", 360 / gcd(360, x));
  return 0;
}

Measured memory_bytes: 1708
// 2011Í[à\I B. uCuEtH[XEXg[[

#include <iostream>
#include <queue>
#include <cstring>

using namespace std;

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

int main(){
	int t, n;
	int visit[200][200];
	while(cin >> t >> n, t){
		int x, y;
		memset(visit, -1, sizeof(visit));
		for(int i=0;i<n;i++){
			cin >> x >> y;
			visit[x+100][y+100] = 1;
		}
		cin >> x >> y;
		int res = 0;
		queue< pair<int, int> > qu; qu.push(make_pair(x+100,y+100));
		visit[x+100][y+100] = 0;
		while(!qu.empty()){
			pair<int,int> pr = qu.front(); qu.pop();
			int cx = pr.first, cy = pr.second;
			res++;
			if(visit[cx][cy] == t) continue;
			for(int i=0;i<6;i++){
				int nx = cx+dx[i], ny = cy+dy[i];
				if(visit[nx][ny]!=-1) continue;
				visit[nx][ny] = visit[cx][cy]+1;
				qu.push(make_pair(nx,ny));
			}
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 1080