akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
#include<cmath>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef  long long ll ;
const ll inf = 1e9+7;
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    vector<ll> a(n),d(n,inf);
    rep(i,n)cin>>a.at(i);
    d[0]=0;
    for(int i=1;i<n;i++)for(int j=1;j<=k;j++)if((i-j)>=0)d[i]=min(d[i],abs(a[i]-a[i-j])+d[i-j]);
    cout<<d[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 1792
#!/usr/bin/env python3
import sys
import math
import collections


def II(): return int(sys.stdin.readline())


def MI(): return map(int, sys.stdin.readline().split())


def LI(): return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()
    ans = 0
    list_counter = []

    for i in range(1, math.floor(N**(1/2))+1):
        for j in range(i,  math.floor(N**(1/2))+1):
            for k in range(j,  math.floor(N**(1/2))+1):
                n = str(i**2 + j**2 + k**2 + i*j + j*k + k*i)
                tmp = set([i, j, k])

                if len(tmp) == 3:
                    tmp_list = [n]*6
                if len(tmp) == 2:
                    tmp_list = [n]*3
                if len(tmp) == 1:
                    tmp_list = [n]*1
                list_counter.extend(tmp_list)

    counter = collections.Counter(list_counter)
    for n in range(1, N+1):
        print(counter[str(n)])



    # oj t -c "pypy3 main.py"
    # acc s main.py -- --guess-python-interpreter pypy
main()


Measured memory_bytes: 114284
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
double r;
int main()
{
	cin>>r;
printf("%f %f\n",r*r*M_PI,2*r*M_PI);
}

Measured memory_bytes: 1232
#include <iostream>
#include <string>
using namespace std;
int n, ans,j;
string s;
int main()
{
    ans = 1;
    cin >> n;
    cin >> s;
    for (int i = 0; i < n; i++)
    {
        if(s[j] != s[i]){
            ans += 1;
            j = i;
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define FOR(i,a,b) for(ll i=a; i<b; i++)
#define IN(a) cin>>a
#define OUT(a) cout<<a<<endl


int main(){
  
  long double a,b;
  long long int ans;
  IN(a); IN(b);
  ans = 1;

  ans = (a*b*10)/10;
    
  OUT(ans);
}

Measured memory_bytes: 3732
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#define int long long
#define endl '\n'
#define INF 1000000000000000000
#define EPS 1e-10
#define PI 3.141592653589793238
#define all(a) a.begin(),a.end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define pb push_back
#define double long double
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;
typedef complex<double> com;
template<class T, class S> bool chmax(T &a, const S &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T, class S> bool chmin(T &a, const S &b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll n, ll m) { return (m ? gcd(m, n%m) : n); }
ll lcm(ll n, ll m) { return n / gcd(n, m)*m; }


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	//modcalc();

	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) {
		char c;
		cin >> c;
		int d = c - '0';
		a[i] = d;
	}
	bool flag = true;
	rep(i, n) if (a[i] == 2) flag = false;
	if (flag) {
		int check = 0;
		rep(i, n - 1) {
			int d = max(a[i] - a[i + 1], a[i + 1] - a[i]);
			if (((n - 2)&i) == i && d == 2) check ^= 1;
		}
		cout << (check ? 2 : 0) << endl;
	}
	else {
		int check = 0;
		rep(i, n) {
			if (((n - 1)&i) == i && a[i] != 2) check ^= 1;
		}
		cout << (check ? 1 : 0) << endl;
	}
}

Measured memory_bytes: 8064
#define _DEBUG 1
#define _GLIBCXX_DEBUG

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

using ll = long long;

#ifdef _DEBUG
#define dump(x) cerr << #x << "=" << x << endl
#define dump2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define dump3(x, y, z)                                                         \
  cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z     \
       << endl
#define check(s) cerr << s << endl
#else
#define dump(x)
#define dump2(x, y)
#define dump3(x, y, z)
#define check(s)
#endif

#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define unique(v) v.erase(unique(v.begin(), v.end()), v.end());

void solve(ll R) {
  if (R < 1200) {
    cout << "ABC" << endl;
  } else if (R < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
  ll R;
  scanf("%lld", &R);
  solve(R);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SUM(x) accumulate(rng(x),0LL)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = 1<<30;
const ll INFLL = 1LL<<60;
//cout << fixed << setprecision(10);

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

int main () {
  int n;
  cin >> n;
  vll a(n);
  rep(i,n) cin >> a[i];

  ll a_sum = SUM(a);
  ll a_half = a_sum/2;

  ll ans = INFLL;
  
  ll l = 0, r = 0;
  rep(i,n) {
    if (l >= a_half) break;
    l += a[i];
  }
  for (int i = n-1; i >= 0; --i) { 
    if (r >= a_half) break;
    r += a[i];
  }
  ans = min(ans, l - (a_sum-l));
  ans = min(ans, r - (a_sum-r));

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

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

  int N,a=0,b=0,ans=1000000;
int sum(int x){
  int res=0;
  while(x > 0){
    res+=x%10;
    x/=10;
  }
  return res;
}

int main() {
  cin >> N;
  for(int i=1;i<N;++i){
    a=i;
    b=N-i;
    int c=sum(a)+sum(b);
    ans=min(c,ans);
  }
   cout << ans << endl; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int times(int x, int y){
  int cnt=0;
  while(x%y==0){
    cnt++;
    x /= y;
  }
  return cnt;
}
int64_t mult(int xx, int yy){
  int z = 1;
  while(yy>0){
    z *= xx;
    yy -= 1;
  }
  return z;
}
int xxx(int z){
  for(int i=2; i<z; i++){
    if(z%i==0) return 0;
  }
  return 1;
}
int main() {
  int a, b;
  cin >> a >> b;
  int aa[110000];
  int bb[110000];
  for(int i=1; i<=110000; i++){
    aa[i] = 0;
    bb[i] = 0;
  }
  for(int i=2; i<=100000; i++){
    aa[i] += times(a, i);
    bb[i] += times(b, i);
  }
  
  int64_t sum = 1;
  for(int i=2; i<=100000; i++){
    int maxx = 0;
    if(xxx(i)){
      if(aa[i]>=1 || bb[i]>=1){
        maxx = max(aa[i], bb[i]);
      }
      sum *= mult(i, maxx);
    }
  }
  cout << sum << endl;
  
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits>


int main(){
  long N;
  std::cin >> N;
  long D[100+1][2];
  
  for(long i=1; i<=N; i++){
    std::cin >> D[i][0] >> D[i][1];
  }

  long len=0;
  bool flag=0;
  for(long i=1; i<=N; i++){
    if(D[i][0]==D[i][1]){
      len++;
      if(len>=3){
        flag=1;
        break;
      }
    }else{
      len=0;
    }
  }
  if(flag){
    std::cout << "Yes" << std::endl;
  }else{
    std::cout << "No" << std::endl;
  }
  return 0;
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    int x;
    cin>>x;
    while(x!=0)
    {
        int a=x%10;
        if(a==7)
        {
            cout<<"Yes";
            exit(0);
        }
        x=x/10;
    }
    cout<<"No";
}


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

int main () {
  int n;
  cin >> n;
  
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  
  int counter=0;
  for (int i = 0; i < a.size(); i += 2) {
    if (a.at(i) % 2 == 1) counter++;
  }
  
  cout << counter << endl;
}


Measured memory_bytes: 3184
/*   ꧁༒☬महाकाल☬༒꧂ ꧁༒ঔमहाकालঔ༒꧂
                   
                   ঔৣ۝महाकालᴳᵒᵈ۝ঔৣ            
 
 */ 
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template <typename T, typename cmp=less<T>> using oset =tree<T, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
#define ll long long 
#define mod 1000000007
#define inf 100000000000000000
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define _it iterator
#define all(_x) _x.begin(),_x.end()
#define f first
#define s second
#define pb push_back
void mahakal(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);
	#endif
}
int main(){
	//mahakal(),fast;
	ll n ;
	cin>> n ;
	ll arr[n];
	for(ll i=0;i<n ;i++)cin>>arr[i];
	arr[0]--;
	for(ll i=1; i<n ; i++){
		if(arr[i]>arr[i-1])arr[i]--;
		else if(arr[i-1]>arr[i]){
			cout<<"No"<<endl;return 0;
		}
	}
	cout<<"Yes"<<endl;

	return 0;
}

Measured memory_bytes: 1024
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_MOD			2019									// 除数

// 内部変数
static FILE *szpFpI;											// 入力

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// 出力
int
fOut(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i, j;
	char lc1Buf[1024];

	// L, R - 取得
	int liL, liR;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d", &liL, &liR);

	// 最大値
	int liMax = liL + D_MOD;
	if (liR > liMax) {
		liR = liMax;
	}

	// 最小値 - 取得
	int liMin = INT_MAX;
	for (i = liL; i <= liR; i++) {
		for (j = i + 1; j <= liR; j++) {
			int liVal = (int)((long long)i * (long long)j % (long long)D_MOD);
			if (liMin > liVal) {
				liMin = liVal;
			}
		}
	}

	return liMin;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOut(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int n,a,b,c,e=0,r[200001]={0},d[200001]={0};
vector<set<int>> A(200001);
int search(int x){
  r[x]=1;
  for(auto i:A[x]) if(!r[i]) d[i]=d[x]+1,search(i);
}
int main(){
  cin>>n;
  rep(i,n-1) cin>>a>>b,A[a].insert(b),A[b].insert(a);
  search(1);
  rep(i,n) if(d[i+1]>e) e=d[i+1],c=i+1;
  rep(i,n) r[i+1]=0;
  d[c]=0,search(c);
  rep(i,n) if(d[i+1]>e) e=d[i+1],c=i+1;
  if(e%3==1) cout<<"Second";
  else cout<<"First";
}

Measured memory_bytes: 36224
#include "bits/stdc++.h"

int main() {

    int H, W;
    std::cin >> H >> W;
    std::vector<std::string> S(H);
    for (auto& v : S)std::cin >> v;
    std::vector<std::vector<int>> memo_w(H, std::vector<int>(W, 0));
    std::vector<std::vector<int>> memo_h(H, std::vector<int>(W, 0));
    for (int h = 0; h < H; ++h) {
        int count = 0;
        for (int w = 0; w < W; ++w) {
            if (S[h][w] == '#')count = 0;
            else ++count;
            memo_w[h][w] = count;
        }
        for (int w = W - 1; w >= 1; --w)
            if (memo_w[h][w - 1] * memo_w[h][w])memo_w[h][w - 1] = memo_w[h][w];
    }
    for (int w = 0; w < W; ++w) {
        int count = 0;
        for (int h = 0; h < H; ++h) {
            if (S[h][w] == '#')count = 0;
            else ++count;
            memo_h[h][w] = count;
        }
        for (int h = H - 1; h >= 1; --h)
            if (memo_h[h - 1][w] * memo_h[h][w])memo_h[h - 1][w] = memo_h[h][w];
    }
    int ans = 0;
    for (int h = 0; h < H; ++h)for (int w = 0; w < W; ++w)ans = std::max(ans, memo_w[h][w] + memo_h[h][w] - 1);
    std::cout << ans << std::endl;
}

Measured memory_bytes: 35712
//#define _GLIBCXX_DEBUG
#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 allr(v) v.rbegin(), v.rend()

int main() {
  int a, b;
  cin >> a >> b;
  string s = to_string(b);
  int n = a*pow(10, s.size()) + b;
  double m = sqrt(n);
  if (floor(m) == ceil(m)) puts("Yes");
  else puts("No");
  return 0;
}

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

int main(){
    string S;
    cin >> S;
    int sum=0;
    if(S[0]=='R'&&S[1]=='R'&&S[2]=='R'){
        sum = 3;
    }
    else if(S[0]=='R'&&S[1]=='R'||S[1]=='R'&&S[2]=='R'){
        sum = 2;
    }
    else if(S[0]=='R'||S[1]=='R'||S[2]=='R'){
        sum = 1;
    }

    cout << sum <<  endl;

}

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

int main(){
	// おまじない
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int N,M;
	// 出入力
	cin>>N>>M;

    string S;
    cin>>S;
    int ind = N;
    vector<int> ans_v;
    while(true){
        if(ind-M<=0){
            ans_v.emplace_back(ind);
            break;
        }
        for(int j=M;j>0;j--){
            if(S[ind-j]=='0'){
                ans_v.emplace_back(j);
                ind -=j;
                break;
            }
            if(j==1){
                cout << -1 << "\n";
                return 0;
            }
            
        }
    }

    for(int i=ans_v.size()-1;i>=0;i--){
        cout << (i == ans_v.size()-1 ? "":" " ) << ans_v[i];
    }
    cout << "\n";
    
	return 0;
}

Measured memory_bytes: 1096
import math
def sieve (n):
	prime = [0,0]
	prime += [1 for i in range(n-1)]
	ub = math.sqrt(n) + 1
	d = 2
	while d <= ub:
		if prime[d] == 0:
			d += 1
			continue
		prod = 2
		while d * prod <= n:
			prime[d*prod] = 0
			prod += 1
		d += 1
	return prime
prime = sieve(2*10**5)

while 1:
	N,P = map(int,raw_input().split())
	if (N,P) == (-1,-1):
		break
	prime_ub = P
	prime_list = []
	prime_num = 0
	inc = N + 1
	while prime_num < prime_ub :
		if prime[inc] == 1:
			prime_num += 1
			prime_list.append(inc)
		inc += 1
	sum_list = []
	for i in range(prime_num):
		sum_list += [prime_list[i] + p for p in prime_list[i:]]
	sum_list.sort()
	print sum_list[P-1]

Measured memory_bytes: 12416
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

bool func(string s){
  if (s.size() >= 9) return s == "AKIHABARA";
  for (int i = 0; i <= s.size(); i++) {
    if(func(s.substr(0, i) + 'A' + s.substr(i))) return true;
  }
  return false;
}

int main() {
  string s;
  cin >> s;
  if (func(s) == true) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 3596
//
//  main.cpp
//  BT
//
//  Created by h3037175 on 2017/07/27.
//  Copyright ?? 2017??´ h3037175. All rights reserved.
//

#include <iostream>
#include <stack>
using namespace std;
int main() {
    stack<int> st;int a;
    while(cin>>a){
        if(a==0){
            cout<<st.top()<<endl;
            st.pop();
        }
        else{
        st.push(a);
        }
    }
        return 0;
}

Measured memory_bytes: 3080
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
import numpy as np
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N = INT()
print(N*(N-1)//2)

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

string goal[32]={"11","12","13","14","15","16","17","","21","22","23","24","25","26","27","","31","32","33","34","35","36","37","","41","42","43","44","45","46","47",""};

bool check(vector<string> s){
  for(int i=0;i<32;i++)if(s[i]!=goal[i])return false;
  return true;
}

int main()
{
  int n;

  cin>>n;

  for(int k=0;k<n;k++){
    vector<string> f(32);
    for(int i=0;i<4;i++){
      for(int j=0;j<7;j++){
	cin>>f[i*8+j+1];
      }
    }
    for(int i=0;i<32;i++){
      if(f[i]=="11" || f[i]=="21" || f[i]=="31" || f[i]=="41")f[i]="";
    }
    f[0]="11";
    f[8]="21";
    f[16]="31";
    f[24]="41";

    int ans=-1;
    map<vector<string>,int> m;
    queue<vector<string> > q;
    m[f]=0;
    q.push(f);
    while(!q.empty()){
      vector<string> u=q.front();
      q.pop();
      if(check(u)){
	ans=m[u];
	break;
      }
      for(int i=0;i<32;i++){
	if(u[i]==""){
	  vector<string> t=u;
	  if(t[i-1]=="" || t[i-1][1]=='7')continue;
	  string s=t[i-1];
	  s[1]++;
	  for(int j=0;j<32;j++){
	    if(t[j]==s){
	      t[j]="";
	      break;
	    }
	  }
	  t[i]=s;
	  if(m.find(t)==m.end()){
	    m[t]=m[u]+1;
	    q.push(t);
	  }
	}
      }
    }
    cout<<ans<<endl;
  }
}

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

int main(){
    int a,b;
    cin >> a >> b;
    string atemp,btemp;
    atemp=to_string(a);
    btemp=to_string(b); 
    vector<string> a1,b1;
    int flag1=0,flag2=0;
    rep(i,a){a1.push_back(btemp);flag1++;}
    rep(i,b){b1.push_back(atemp);flag2++;}

    if(a1[0]<b1[0]){rep(i,flag1){cout << a1[i];}cout<<endl;}
    else {rep(i,flag2){cout << b1[i];}cout<<endl;}
        
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <map>
#include <utility>
#include <list>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

using namespace std;

#define LL long long

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

    vector<int> v;
    for (int i=0; i < m; i++){
        int t;
        cin >> t;
        v.push_back(t);
    }

    sort(v.begin(), v.end());
    int max = v.back();
    int min = v.front();

    vector<int> w;
    for (int i=0; i < m - 1; i++){
        w.push_back(v[i + 1] - v[i]);
    }

    sort(w.begin(), w.end());

    int max_dist = max - min;
    for (int i = n - 1; i > 0 && w.size() > 0; i--){
        max_dist -= w.back();
        w.pop_back();
    }

    cout << max_dist << endl;


    return 0;
}


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

string s;

int main()
{
	int i;
	char want = 'A';
	string az;
	
	cin >> s;
	for( i = 0; i < s.length(); i++ ){
		if( s[i] == want ){
			az += want;
			want = (want == 'A') ? 'Z': 'A';
		}
	}
	if( az.length() == 0 || (az.length() == 1 && az[az.length()-1] == 'A') ){
		cout << -1 << endl;
	}
	else{
		for( i = 0; i < az.length(); i++ ){
			if( i == az.length() - 1 && az[i] == 'A' )
				continue;
			cout << az[i];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1180
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

struct tree {
  ll p = -1, q = -1, r = -1, b = -1;
  tree() = default;
  tree(int p, int q, int r, int b) : p(p), q(q), r(r), b(b) {}
};

tree t[111];

ll dfs(int idx) {
  ll left = 0, right = 0;
  left  = (t[idx].r ? dfs(t[idx].r - 1) : 1) * t[idx].p;
  right = (t[idx].b ? dfs(t[idx].b - 1) : 1) * t[idx].q;
  ll k = left * right  / __gcd(left, right) / t[idx].p;
  ll l = left * right / __gcd(left, right) / t[idx].q;
  return k + l;
}

int main() {

  for(int N; cin >> N && N;) {
    rep(i, N) t[i] = tree(-1,-1,-1,-1);
    set<int> st;
    rep(i, N) {
      int p, q, r, b; cin >> p >> q >> r >> b;
      t[i] = {p, q, r, b};
      if(r > 0) st.insert(r-1);
      if(b > 0) st.insert(b-1);
    }
    rep(i, N) {
      if(!st.count(i)) {
        cout << dfs(i) << endl;
        break;
      }
    }
  }


  return 0;
}

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

void solve() {
    const i64 mod = 1'000'000'007;

    i64 N;
    cin >> N;

    vector<char> sym={'A','C','G','T'};

    vector<map<string,i64>> memo(N+1);
    vector<map<string,bool>> done(N+1);
    function<i64(i64,string)> rec=[&](i64 i,string s){
        auto& res=memo[i][s];
        if(done[i][s]) return res;
        done[i][s]=true;
        if(i==N){
            return res=i64(1);
        }

        for(auto c:sym){
            auto t=s+c;
            if(t.find("AGC")!=string::npos) continue;
            bool ok=true;
            rep(j,0,i64(t.size())-1){
                string u=t;
                swap(u[j],u[j+1]);
                if(u.find("AGC")!=string::npos){
                    ok=false;
                    break;
                }
            }
            if(ok){
                reverse(begin(t),end(t));
                while(t.length()>3) t.pop_back();
                reverse(begin(t),end(t));
                res+=rec(i+1,t);
                res%=mod;
            }
        }
        return res;
    };

    cout << rec(0,"") << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 1280
N = int(input())
ans = 1
A = list(map(int, input().split()))
A.sort(reverse=True)
if A[N-1] == 0:
  ans = 0
else:
  for a in A:
    ans *= a
    if ans > 10 ** 18:
      ans = -1
      break
print(ans)

Measured memory_bytes: 21580
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define elif else if
#define ffast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define filoop(n) for(ll i=0;i<(n);i++)
#define fjloop(n) for(ll j=0;j<(n);j++)


int dp[101][101];

int main()
{
    ffast;
    //freopen("0in.txt","r",stdin);
    //freopen("0out.txt","w",stdout);

        int n,x[101],mini=100,maxi=0;
        cin>>n;
        filoop(n) {
            cin>>x[i];
            if(mini>x[i]) mini = x[i];
            if(maxi<x[i]) maxi = x[i];
            }
        int avrg,ans=100000001;
        sort(x,x+n);

        for(int i=mini;i<=maxi;i++){
            fjloop(n)
            {
                int tmp = (x[j]-i);
                dp[i][j] = tmp*tmp;
            }
        }

        for(int i=mini; i<= maxi;i++){
        int cont=0;
        fjloop(n){
            cont+= dp[i][j];
        }
        if(cont<ans) ans = cont;
        }
        cout<<ans<<"\n";


    return 0;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll p[11];
ll d[11];
ll ct(ll x){
    ll ret = 0;
    while (x) {
        if (x&1) ret++;
        x >>= 1;
    }
    return ret&1;
}
int main(){
    IOS();
    ll n,m;
    cin >> n >> m;
    REP (i,m) {
        ll k;
        cin >> k;
        REP (j,k) {
            ll x;
            cin >> x;
            x--;
            d[i] |= (1<<x);
        }
    }
    pary(d,d+10);
    REP (i,m) cin >> p[i];

    ll ans = 0;
    REP (i,1<<n) {
        bool ok = true;
        REP (j,m) {
            ll tmp = d[j]&i;
            if (ct(tmp) != p[j]) ok = false;
        }
        if (ok) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <cmath>
using namespace std;

const double PI = acos(-1);

int main() {
    double a, b, x;
    cin >> a >> b >> x;

    if (x <= (a * a * b) / 2) {
        double z = (a * a * b -  2 * x) / (a * b);
        double y = a - z;
        double c = y * y + b * b;
        c = sqrt(1.0 * c);
        double cos = y / c;
        double deg = acos(cos);
        deg = 180.0 * deg / PI;

        cout << fixed << setprecision(10) << deg << endl;
    }
    else {
        double z = (2 * x - a * a * b) / (a * a);
        double y = b - z;
        double c = y * y + a * a;
        c = sqrt(1.0 * c);
        double cos = a / c;
        double deg = acos(cos);
        deg = 180.0 * deg / PI;

        cout << fixed << setprecision(10) << deg << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

int main()
{
	string s;

	int n;

	cin >> s;
	n=s.size();

	int ans=0;
	for(int k=1;k<=n;k++)
	{
		for(int l=0;l<=n-k;l++)
		{
			bool ok=true;
			for(int i=l;i<l+k;i++)
				if(!(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C'))
					ok=false;
			if(ok)ans=max(ans,k);
		}
	}
	cout << ans << endl;
	return 0;
}



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

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

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

int main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> v(n);
    fori(i, 0, n) {
        cin >> v[i];
    }
    int ans = 0;
    for(int i = 1; i < n; ) {
        if(v[i] == v[i - 1]) {
            ans++;
            i += 2;
        }
        else {
            i++;
        }
    }
    cout << ans << '\n';
    return 0;
}


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

int main() {
	vector <string> strs;
  	string curStr;
  	int total;
  	cin >> total;
  	for (int i = 0; i < total; ++i) {
    	cin >> curStr;
      	sort(curStr.begin(), curStr.end());
      	strs.push_back(curStr);
    }
  
  	sort(strs.begin(), strs.end());

  	long long answer = 0;
  	long long consecutive = 1;
  	for (int i = 1; i < strs.size(); ++i) {
    	if (strs[i] != strs[i - 1]) {
          	answer += consecutive * (consecutive - 1) / 2;
        	consecutive = 1;
        } else {
          	consecutive = consecutive + 1;
        }
    }
  
  	answer += consecutive * (consecutive - 1) / 2;
  	
  	cout << answer << endl;
  	
  	return 0;
}

Measured memory_bytes: 5748
#include <stdio.h>
#include <stdlib.h>
#define V 10000

int main(){
  int i, j, n, *A, *B, C[V+1];
  scanf("%d", &n);
  
  A=(int *)malloc(sizeof(int)*n+1);
  B=(int *)malloc(sizeof(int)*n+1);
  

  for(i=0; i<=V; i++){
    C[i]=0;
  }
  
  for(j=1; j<=n; j++){
    scanf("%d", &A[j]);
    C[A[j]]++;
  }
  
  for(i=1; i<=V; i++){
    C[i]=C[i]+C[i-1];
  }
  
  for(j=n; j>=1; j--){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  
  
  for(i=1; i<=n; i++){
    if(i>1) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");
  
  free(A);
  return 0;
}

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


using namespace std;
int main()
{

int n;
cin>>n;

long long int a[n],p=0;
for(int i=0; i<n; i++){
    cin>>a[i];
}
sort(a,a+n);
for(int i=0; i<n; i++){
        if(a[i]!=a[i+1]){
        p++;

        }



}
if(p==n){
             cout<<"YES"<<endl;
}
else{
       cout<<"NO"<<endl;
}





return 0;
}


Measured memory_bytes: 1792
///////////////////// author : TrEbLeCleF /////////////////////
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define For(i, a) for (int i=0; i<(a); i++)
#define FORR(i,a,b) for (int i = (b)-1; i >= a; i--)
#define Forr(i,a) for (int i = (a)-1; i >= 0; i--)
/////////////////////////// ..... ///////////////////////////
#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__) 
void DBG() { cerr << "]\n";}
template<typename T, typename ...Args> void DBG(T first, Args... args){
cerr << first; if(sizeof...(args))cerr<<", "; DBG(args...); }
/////////////////////////// ..... ///////////////////////////
#define int ll
#define pb(x) push_back(x)
#define print(v,s,e) for(int i = s; i < e; i++)cout << v[i]<<" ";cout<<"\n";
#define INF 1e17
#define PI 3.14159265358979323846 
int del_x[4] = {-1, 1, 0, 0};
int del_y[4] = {0, 0, 1, -1};
int XX[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
int YY[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
/////////////////////////// GLOBAL ///////////////////////////


/////////////////////////// GLOBAL ///////////////////////////
void solve(){
	int n; cin >> n;
	string s; cin >> s;
	int cnt1 = 0, cnt2 = 0;
	vi pos;
	For(i,n){
		if(s[i]=='R'){
			cnt1++;
			pos.pb(i);
		}
		else cnt2++;
	}
	int cor = 1;
	int ans = 0;
	For(i,pos.size()){
		if(pos[i]+1 <= cnt1){
			ans++;
		}
	}
	cout << min({cnt1-ans,cnt1,cnt2}) <<"\n";
	
}

int32_t main(){ 
	#ifndef ONLINE_JUDGE
		clock_t tStart = clock();
		freopen("TC", "r", stdin);
		//freopen("output.txt","w",stdout);
	#endif 
    ios_base:: sync_with_stdio(false); 
   	cin.tie(0); 
	int t=1;
	//cin >> t;
	for(int tt=1;tt<=t;tt++){
		//cout << "Case #"<<tt<<": ";
		solve();
	}
	#ifndef ONLINE_JUDGE
    	cerr << "\nRun Time -> "<<(double)(clock()-tStart)/CLOCKS_PER_SEC <<" sec\n";
    #endif
}

Measured memory_bytes: 4432
#include<iostream>
using namespace std;
typedef long long ll;
#define fr(i,n) for(int i=0;i<n;i++)

int main(){
  ll n,c=0;
  cin>>n;
  if(n==1 || n==2 || n==4){
    cout<<4<<endl;
    return 0;
  }
  for(;;){
    c++;
    if(n%2>0){
      n=3*n+1;
    }
    else{
      n/=2;
    }
    if(n==4){
      cout<<c+4<<endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll n,a[2000],s[1001],ans,A,B;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        s[a[i]]++;
    }
    for(int i=0;i<1000;i++){
        s[i+1]+=s[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j)continue;
            A=min(1000LL,a[i]+a[j]-1);
            B=max(a[i],a[j])-min(a[i],a[j])+1;
            ans+=s[A]-s[B-1];
            if(B<=a[i]&&a[i]<=A)ans--;
            if(B<=a[j]&&a[j]<=A)ans--;
        }
    }
    cout<<ans/6<<endl;
}


Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{

    int i_monsterHP;
    int i_attackNum;
    int i_attackCount = 0;

    scanf("%d%d", &i_monsterHP, &i_attackNum);

    while (i_monsterHP > 0) {
        i_monsterHP -= i_attackNum;
        i_attackCount++;
    }

    printf("%d", i_attackCount);

}

Measured memory_bytes: 128
open Batteries
(* charのカウント *)
let count_char target str =
  let rec count lst =
    match lst with
    | [] -> 0
    | first :: rest -> if first = target then 1 + count rest else count rest
  in let explode s = List.init (String.length s) (String.get s)
  in count @@ explode str

let _ = Printf.printf "%d\n" (count_char '1' (read_line ()))


Measured memory_bytes: 1024
#include <stdio.h>
int main(void) {
	long long n, h[100000];
	scanf("%lld", &n);
	for (int i = 0; i < n; i++)
		scanf("%lld", &h[i]);
	
	for (int i = 0; i < n - 1; i++) {
		if (i == 0) h[i] -= 1;
		if (h[i] > h[i + 1]) {
			printf("No\n");
			return 0;
		}
		if (h[i] < h[i + 1]) {
			h[i + 1] -= 1;
		}
	}

	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<numeric>
#include<algorithm>
#define int long long
const int inf=1145141919;
const int mod=1000000007;
using namespace std;
template<class T>void debug(T *a,int l,int r,const char *name){
	for(int i=l;i<r;i++)
		cout<<name<<"["<<i<<"]="<<a[i]<<endl;
}
int N;
signed main(){
	int i,j;
	cin>>N;
	int u=0;
	for(i=0;i<N;i++){
		int x;
		cin>>x;
		u+=(x&1)^1;
	}
	int v=1;
	for(i=0;i<N;i++)
		v*=3;
	cout<<v-(1ll<<u)<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int N,M,Q,i,D[100],t;main(){for(;scanf("%d%d",&N,&Q),N;){memset(D,0,sizeof(D));for(i=0;i<N;i++)for(scanf("%d",&M);M--;){scanf("%d",&t);D[t]++;}for(i=0,t=-1;i<100;i++)if((t==-1&&D[i]>=Q)||(t!=-1&&D[i]>D[t]))t=i;printf("%d\n",t==-1?0:t);}}

Measured memory_bytes: 1700
#include <stdio.h>
#include <math.h>

using namespace std;

int main(){
	int n;
	double students[1000] = {0},sum,m,div;

	while(true){
		scanf("%d",&n);
		if(n == 0) break;
		div = sum = 0;
		for(int i = 0; i < n; i++){
			scanf("%lf",&students[i]);
			sum += students[i];
		}
		m = sum/n;
		for(int i = 0; i < n;i++){
			div += (students[i] - m)*(students[i] - m);
			students[i] = 0;
		}
		printf("%.8lf\n",sqrt(div/n));
	}
}



Measured memory_bytes: 2716
l, n = [int(item) for item in input().split()]
right = []
left = []
for i in range(n):
    a = int(input())
    right.append(a)
    left.append(l - a)
left.reverse()

rsum = [0] * (n+1)
lsum = [0] * (n+1)
for i in range(n):
    rsum[i+1] += rsum[i] + right[i]
    lsum[i+1] += lsum[i] + left[i]

# Take all from left or right
ans = max(right[-1], left[-1])

# Take from left first, then ping pong
for i in range(n-1):
    val = left[i] * 2
    rest = n - (i + 1)
    val += rsum[(rest + 1) // 2] * 2
    val += (lsum[rest // 2 + i + 1] - lsum[i + 1]) * 2
    if rest % 2 == 0:
        val -= left[rest // 2 + i]
    else:
        val -= right[(rest + 1) // 2 - 1]
    ans = max(ans, val)

# Take from right first, then ping pong
for i in range(n-1):
    val = right[i] * 2
    rest = n - (i + 1)
    val += lsum[(rest + 1) // 2] * 2
    val += (rsum[rest // 2 + i + 1] - rsum[i + 1]) * 2
    if rest % 2 == 0:
        val -= right[rest // 2 + i]
    else:
        val -= left[(rest + 1) // 2 - 1]
    ans = max(ans, val)
print(ans)

Measured memory_bytes: 37952
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    int num = 0;
    for(int i = 0; i < n; i++){
        int d;
        cin >> d;
        if ((i+1) % 2 == 0){
            continue;
        }
        if (d % 2 == 0){
            continue;
        }
        num++;
    }
    cout << num << endl;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ll>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a)%mod;  a = (a * a)%mod;  b/=2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 100009;
ll i,j,n,m,x,cnt,a;
ll p[N];
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n>>m;
    rep(i,0,n){
        cin>>x;
        rep(j,0,x){
            cin>>a;
            p[a] += 1;
        }
    }
    rep(i,1,m + 1) if(p[i] == n) cnt += 1;
    cout<<cnt;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (ll i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 
const int mod = 1e9 + 7, mxn = 1e5 + 1;

int solve(){
	int x, n;
	cin>> x>> n;
	map<int, int> m;
	vi v;
	rep(i, 0, n){
		int k;
		cin>> k;
		m[k] = 1;
	}
	int diff = mod, ans = 0;
	rep(i, 0, 200){
		if(m[i])
			continue;
		int gg = abs(x - i);
		if(gg < diff){
			diff = gg;
			ans = i;
		}
	}
	cout<< ans<< "\n";
	return 0;
}
 
int main()
{
    fast;
    int t = 1;
    //cin>> t;
    while(t--){  
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);
 
/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/
        
// lower bound   >=  
// upper bound   >
// vector<int>().swap(vec); //free memory from vec


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define vpi vector<ppi>
#define ppl pair<ll,ll>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define imx INT_MAX
#define imn INT_MIN
#define inf LONG_MAX
#define minf LONG_MIN
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793

/*
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
#define si short int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/

int main()
{
    fast


        
    ll a,b,c;
    cin>>a>>b>>c;

    ll x = a+(a%c!=0)*c-a%c;    
    ll y = b - b%c;    

    cout<<(y-x)/c + 1;










    return 0;
}

Measured memory_bytes: 256
#include "iostream"
using namespace std;

#include <stdio.h>


int main(int argc, char const *argv[])
{
	int n = 0;
	int buf=0;
	long int min=1000000,max=-1000000,sum=0;

	cin >> n;

	for(int i=0;i<n;i++){
		cin >> buf;
		if(buf<=min)
		{
			min = buf;
		}
		if(buf>=max)
		{
			max = buf;
		}
		sum = sum + buf;
	}

	cout << min << " " << max << " " << sum << endl;

	return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,mod=1000000007LL;
  cin>>n;
  ll dp[64][4]={};
  dp[0][0]=1LL;
  for(int i=0;i<61;i++){
    for(int j=0;j<3;j++){
      for(int x=0;x<2;x++){
	for(int y=x;y<2;y++){
	  ll b=(n>>i)&1;
	  dp[i+1][(x+y+j+1-b)/2]=(dp[i+1][(x+y+j+1-b)/2]+dp[i][j])%mod;
	}
      }
    }
  }
  cout << dp[61][0] << endl;
  return 0;
}


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

int main(){
  int a,b; cin>>a>>b;
  if(a>=13) cout<<b;
  else if(a<=5) cout<<0;
  else cout<<b/2;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define bug(x) cerr << '\n' << (#x) << " = " << (x) << endl;
#define REP0(i, n) for(int i = 0, _n = (n); i < _n; ++i)
#define REP1(i, n) for(int i = 1, _n = (n); i <= _n; ++i)
#define REPB0(i, n) for(int i = (n) - 1; i >= 0; --i)
#define REPB1(i, n) for(int i = (n); i > 0; --i)
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define FORB(i, a, b) for(int i = (a), _b = (b); i >= _b; --i)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define X first
#define Y second

using namespace std;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef pair<double, double> dd;
typedef pair<float, float> ff;

int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int a, b;
	cin >> a >> b;
	cout << max(a + b, max(a - b, a * b));	
	return 0;
}

Measured memory_bytes: 256