akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 20
#define off 2
#define sq(x) ((x)*(x))

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define maxn 200005

i64 f(i64 a, i64 b)
{
    if( b==a ) return a ;

    if( a<b )
    {
        if( b%a==0 ) return 2*b-a ;
        return (b/a)*2*a + f( a  , b%a ) ;
    }
    else{
        if( a%b==0 ) return 2*a - b ;
        return ( a/b )*2*b + f(a%b , b) ;
    }
}

int main()
{
    i64 i , j , k , l , m ,n ;

    i64 x ;

    scanf("%lld %lld",&n,&x) ;

    printf("%lld\n", n+f(x,n-x) ) ;

    return 0 ;
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

typedef long long ll;
typedef long double R;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

int main() {
  int N, K; cin >> N >> K;
  string S; cin >> S;
  vector<int> nums;
  int now = 1;
  int cnt = 0;
  for(int i = 0; i < N; ++i) {
    if(S[i] == (char)('0' + now)) cnt++;
    else {
      nums.push_back(cnt);
      now = 1 - now;
      cnt = 1;
    }
  }
  if(cnt  != 0) nums.push_back(cnt);
  if(nums.size() % 2 == 0)  nums.push_back(0);

  int add = 2 * K + 1;
  int ans = 0;
  int left = 0;
  int right = 0;
  int tmp = 0;
  for(int i = 0; i < nums.size(); i += 2) {
    int nextLeft = i;
    int nextRight = min(i + add, (int)nums.size());

    while(nextLeft > left) {
      tmp -= nums[left];
      left++;
    }

    while(nextRight > right) {
      tmp += nums[right];
      right++;
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1020
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
int main(){
	ll n,k;
	scanf("%lld%lld",&n,&k);
	ll mod = n % k;
	ll yu = abs(mod - k);
	if(mod <= yu) printf("%lld\n",mod);
	else printf("%lld\n",yu);
	return 0;
}

Measured memory_bytes: 888
while True:
	n, m = map(int, input().split())
	if (n, m) == (0, 0):
		break
	res = None
	taro = [int(input()) for i in range(n)]
	hana = [int(input()) for i in range(m)]
	taros = sum(taro)
	hanas = sum(hana)
	diff = (hanas-taros)

	for i in range(n):
		for j in range(m):
			if diff == ((hana[j] - taro[i])*2):
				if res == None or sum(res) > (taro[i] + hana[j]):
					res = (taro[i], hana[j])

	if res == None:
		print(-1)
	else:
		print(' '.join(map(str, res)))

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

ll a[5000000],j,n;
int num;
void Prod(ll cur,int a,int b,int c)
{
    if(cur>n)return ;
    if(a && b && c)num++;

   Prod(cur*10+3,a+1,b,c);
   Prod(cur*10+5,a,b+1,c);
   Prod(cur*10+7,a,b,c+1);


}


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

    cin >> n;

    Prod(0,0,0,0);
    cout << num;
    return 0;
}

Measured memory_bytes: 256
X = list(map(int, input().split()))
X.sort()
ba = X[1] - X[0]
ca = X[2] - X[0]
cb = X[2] - X[1]
if ba % 2 == 0 and ca % 2 == 0:
    print((ca + cb) // 2)
elif ba % 2 == 0:
    print(1 + (ca - 1 + cb - 1) // 2)
else:
    print((cb + ca + 1) // 2 + 1)


Measured memory_bytes: 9108
import math
k=input()
k=int(k)

ans=0
for i in range(1,k+1):
  for j in range(1,k+1):
    gcd=math.gcd(i,j)
    for k in range(1,k+1):
      ans+= math.gcd(gcd,k) 

print(ans)


Measured memory_bytes: 9180
n = int(input())
A =[int(i) for i in input().split()]
count=0
for i in range(n):
	for j in range(n-1,i,-1):
		if A[j]<A[j-1]:
			A[j],A[j-1]=A[j-1],A[j]
			count+=1
print(' '.join(list(map(str,A))))
print(count)


Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
vector<vector<pair<int, int>>> V;
vector<int> ans;
int inf=1<<30;


void dfs(int prev, int now, int dist) {
  for (auto i: V[now]) {
    if(ans[i.first]!=inf) continue;
    else {
      ans[i.first] = (i.second+dist)%2;
      dfs(now, i.first, ans[i.first]);
    }
  }
  return;
}

int main() {
  int N; cin >> N;
  V = vector<vector<pair<int, int>>> (N, vector<pair<int, int>>(0));
  ans = vector<int> (N, inf);
  
  for (int i=0; i<N; i++) {
    int u, v, w; cin >> u >> v >> w;
    V[u-1].push_back({v-1,w%2});
    V[v-1].push_back({u-1,w%2});
  }
  dfs(-1,1,0);

  for (int i=0; i<N; i++) cout << ans[i] << "\n";
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
template<typename T>
T gcd(T m, T n){
    return n == 0 ? abs(m) : gcd(n, m % n);
}
template<typename T>
T lcm(T m, T n){
    return abs(m / gcd(m, n) * n);
}
int main()
{
    int x, y;
    cin >> x >> y;   

    cout << gcd(x, y) << '\n';
  
    return 0;
}


Measured memory_bytes: 3088
n = int(input())
p = list(map(int, input().split()))

ans = 0
for i, _ in enumerate(p[:-1]):
    #print(p_, i+1)
    p_ = p[i]
    if p_ == i + 1:
        ans += 1
        p[i], p[i+1] = p[i+1], p[i]

if p[-1] == n:
  ans += 1
        
print(ans)



Measured memory_bytes: 52908
// practice with Dukkha
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 100000, M = 100000;

int pp[N + 1], qq[M + 1];

int main() {
	string s, t; cin >> s >> t;
	int n = s.length(), m = t.length();
	for (int i = 0; i < n; i++)
		pp[i + 1] = pp[i] + s[i] - 'A' + 1;
	for (int j = 0; j < m; j++)
		qq[j + 1] = qq[j] + t[j] - 'A' + 1;
	int q; cin >> q;
	while (q--) {
		int l1, r1, l2, r2; cin >> l1 >> r1 >> l2 >> r2;
		int x = pp[r1] - pp[l1 - 1];
		int y = qq[r2] - qq[l2 - 1];
		cout << (x % 3 == y % 3 ? "YES" : "NO") << '\n';
	}
	return 0;
}


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

int main() {
    int cnt = 0;
    while (1) {
        int n, x;
        cin >> n >> x;
        if (n == 0 && x == 0) break;
        cnt = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = i + 1; j <= n; j++) {
                for (int k = j + 1; k <= n; k++) {
                    int sum = i + j + k;
                    if (sum == x) {
                        cnt++;
                    }
                }
            }
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define maxn 200010
using namespace std;
char s[maxn];
int main()
{
	scanf("%s", s + 1);
	long long res = 0;
	int n = strlen(s + 1), cur = 0;
	for (int i = 1; i <= n; i++)
		if (s[i] == 'W')
		{
			cur++;
			res += i - cur;
		}
	printf("%lld\n", res);
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main() {

	/*input*/
	int n;
	int X;	//粉の量
	cin >> n >> X;

	int m[1001];
	for (int i = 0; i < n; ++i) 
		cin >> m[i];
	
	
	/*calculate*/
	int total = 0;
	for (int i = 0; i < n; ++i) {
		total += m[i];
	}
	int Y = X - total;//最小一個作った後残りの粉の量


	int min = 1000000;
	for (int i = 0; i < n; ++i) {
		if (min > m[i])
			min = m[i];
	}

	int number;
	number = int(Y / min);
	number += n;


	cout << number << endl;


}


Measured memory_bytes: 256
N, W = map(int, input().split())
dp = [[0] * (W+1) for _ in range(N+1)]
for i in range(N):
    w, v = map(int, input().split())
    for w_lim in range(W+1):
        if w <= w_lim:
            dp[i+1][w_lim] = max(dp[i][w_lim-w]+v, dp[i][w_lim])
        else:
            dp[i+1][w_lim] = dp[i][w_lim]
print(dp[N][W])


Measured memory_bytes: 146956
#include<iostream>
#include<stack>
using namespace std;
int main(){
  stack<int> s;
  int n;
  while(cin>>n){
    
    if(n==0){
      cout<<s.top()<<endl;
      s.pop();
    }
    else{
      s.push(n);
    }
  } 
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
char a[6],b[6],c[12];
int main(){
	int i = 0,j = 0,a1,b1,k = 0,m = 0,n = 0;
	cin>>a1>>b1;
	cin>>c;
	if(c[a1] != '-'){
		cout<<"No"<<endl;
		return 0;
	}
	for(i = 0;i <= a1 - 1;i++){
		a[i] = c[i];
	} 
	for(j = a1 + 1;j <= a1 + b1 ;j++){
		b[k] = c[j];
		k++;
	}
	for(k = 0;k < 6;k++){
		if(a[k] == '-'||b[k] == '-'){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
/**
 * @author: shashankchdhry
 * @made:   2020-04-05 11:35:19 
**/
#include <bits/stdc++.h>

using namespace std;

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

    int n, m;
    cin >> n >> m;
    vector<string> a(n), b(m);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < m; i++)
        cin >> b[i];
    
    for (int i = 0; i < n-m+1; i++)
    {
        for (int j = 0; j < n-m+1; j++)
        {
            bool flag = true;
            for (int k = 0; k < m; k++)
                for (int l = 0; l < m; l++)
                    if (a[i+k][j+l] != b[k][l])
                    {
                        flag = false;
                        break;
                    }
            if (flag == true)
            {
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int parttition(int*,int,int);
int main(){
  int i,n,*a,k;
  scanf("%d",&n);
  a=(int *)malloc(n *sizeof(int));
  for(i=0;i<n;i++)scanf("%d",&a[i]);
  k=parttition(a,0,n-1);
  printf("%d",a[0]);
  for(i=1;i<n;i++){
    if(i==k)printf(" [%d]",a[i]);
    else printf(" %d",a[i]);
  }
  printf("\n");
  return 0;
}
int parttition(int a[],int p,int r){
  int i,j,x,key;
  x=a[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(a[j]<=x){
      i++;
      key=a[i];
      a[i]=a[j];
      a[j]=key;
    }
  }
    key=a[i+1];
    a[i+1]=a[r];
    a[r]=key;

  return i+1;
}



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

int main() {
	int N, K;
	cin >> N >> K;
	int ans = 1;
	if (N%K == 0){
		ans = 0;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <stack>
#include <queue>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
using ll = long long;
using ld = long double;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll N, i, j, k, a[100010][3], dp[100010][3]={0}, ans=0;

    cin >> N;

    for(i=0; i<N; i++){
        for(j=0; j<3; j++){
            cin >> a[i][j];
        }
    }

    for(i=0; i<N; i++){
        for(j=0; j<3; j++){
            for(k=0; k<3; k++){
                if(j!=k){
                    chmax(dp[i+1][k], dp[i][j]+a[i][k]);
                }
            }
        }
    }

    for(i=0; i<3; i++){
        chmax(ans, dp[N][i]);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P; 
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char>> cs(h, vector<char>(w));
    rep(i, h)rep(j, w) cin >> cs[i][j];

    ll ans = 0;
    for(int bit=0; bit<1<<h+w; bit++){
        vector<vector<char>> tmp(h, vector<char>(w));
        rep(i, h)rep(j, w) tmp[i][j] = cs[i][j];
        rep(i, h+w){
            if (bit & 1<<i){
                if (i<h){
                    rep(j, w){
                        tmp[i][j] = '.';
                    }
                }else{
                    rep(j, h){
                        tmp[j][i-h] = '.';
                    }
                }
            }
        }
        ll tmp_a = 0;
        rep(i, h){
            rep(j, w){
                if (tmp[i][j]=='#'){
                    tmp_a++;
                }
            }
        }
        if (tmp_a==k) ans++;
    }

    cout << ans << endl;
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  int r,n;cin>>n>>r;

  if(n>=10){
    cout<<r<<endl;
  }else{
    cout<<r+100*(10-n)<<endl;
  }

  
  return 0;
}


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

struct UnionFind {
  UnionFind(int n) : data(n, -1) {}

  int root(int ver) { return data[ver] < 0 ? ver : data[ver] = root(data[ver]); }

  bool unite(int u, int v) {
    u = root(u);
    v = root(v);
    if (u == v) return false;
    if (data[u] > data[v]) swap(u, v);
    data[u] += data[v];
    data[v] = u;
    return true;
  }

  bool same(int u, int v) { return root(u) == root(v); }

  int size(int ver) { return -data[root(ver)]; }

private:
  vector<int> data;
};

int main() {
  int n, q; cin >> n >> q;
  UnionFind uf(n);
  while (q--) {
    int t, u, v; cin >> t >> u >> v;
    if (t == 0) {
      uf.unite(u, v);
    } else {
      cout << uf.same(u, v) << '\n';
    }
  }
  return 0;
}


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

using namespace std;

#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define mmp make_pair
#define st first
#define nd second
#define rd third
#define ll long long
#define pii pair <int, int>
#define tri pair <pii, int>
#define itr pair <int, pii>
#define PQ priority_queue
#define all(v) (v).begin(), (v).end()
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++)
#define FOR(i, a, n) for (int (i) = (a); (i) < (int)(n); i++)
#define FORN(i, a, n) for (int (i) = (a); (i) > (int)(n); i--)
#define Rep(i, n) for (int (i) = 0; (i) <= (int)(n); i++)
#define For(i, a, n) for (int (i) = (a); (i) <= (int)(n); i++)
#define Forn(i, a, n) for (int (i) = (a); (i) >= (int)(n); i--)
#define FORD(i, n) for (int (i) = (int)(n) - 1; i>= 0; i--)
#define rep(i, n) for (int (i) = 1; (i) <= (int)(n); i++)
#define EACH(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)

#define DEBUG(x) cout << #x << " = " << (x) << endl;
#define PR(a, n) {cout << #a << " = "; FOR(_, 1, n) cout << a[_] << ' '; puts(""); }
#define PRO(a, n) { cout << #a << " = "; REP(_, n) cout << a[_] << ' '; puts(""); }
#define pi 3.1415926535897932384626433832795028841971
//#define LOCAL

const int INF = 1 << 30;
const int N = 1005;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};

inline ll read()
{
	ll x = 0; int f = 1, c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c ^ 48);
	return x * f;
}

int a, b, c; 

int main()
{
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	
	a = read(); b = read(); c = read(); 
	if ((a == b && a != c) || (a == c && a != b) || (b == c && a != b)) puts("Yes"); 
	else puts("No"); 
	
	return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import time

from collections import deque

def main():
    t1 = time.time()

    n = int(input())
    
    a = [[int(i) for i in input().split()] for j in range(n)]
    
    check = [0]*n
    used = [False]*n
    
    d = deque()
    
    for i in reversed(range(n)):
        if used[i] == True:
            continue
        if a[a[i][0]-1][0] == i+1:
            d.appendleft([i+1,a[i][0]])
            used[i] = True
            used[a[i][0]-1] = True
            check[i] = 1
            check[a[i][0]-1] = 1
            
    ans = 0
    
    if len(d) == 0:
        print(-1)
        exit()
    
    #print(d)
    
    while len(d) > 0:
        if time.time() - t1 >= 1.95:
            print(n*(n-1)//2)
            exit()
        used = [False]*n
        ans += 1
        num = len(d)
        for i in range(num):
            tmp = d.popleft()
            for j in range(2):
                if check[tmp[j]-1] == n-1:
                    continue
                psn = a[tmp[j]-1][check[tmp[j]-1]]-1
                mys = tmp[j]-1
                
                if check[mys] == n-1 or check[psn] == n-1:
                    continue
                #print(tmp,psn,a[psn][check[psn]])
                #print(i,j,tmp,psn,check[mys],check[psn])
                if used[mys] == True or used[psn] == True:
                    continue
    
                if a[psn][check[psn]] == mys+1:
                    d.append([psn+1,mys+1])
                    used[mys] = True
                    used[psn] = True
                    check[mys] += 1
                    check[psn] += 1
        #print(d)
        
    for i in range(n):
        if check[i] != n-1:
            print(-1)
            exit()
    
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 35980
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<algorithm>
#include<queue>
#include<math.h>
#include<vector>
#include<map>
using namespace std;
#define ll long long
int mod=1e9+7;
int main()
{
    int n,m;
    while(~scanf("%d%d",&n,&m))
    {
        int a[100005];
        memset(a,0,sizeof(a));
        for(int i=0; i<m; i++)
        {
            int x;
            scanf("%d",&x);
            a[x]=-1;
        }
        a[0]=1;
        for(int i=1; i<=n; i++)
        {
            if(a[i]==-1)
                a[i]=0;
            else
            {
                if(i>=2)
                {
                    a[i]=a[i-1]%mod+a[i-2]%mod;
                }
                else
                {
                    a[i]=a[i-1]%mod;
                }
                a[i]%=mod;
            }
        }
        printf("%d\n",a[n]);
    }
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,d,count1=0,i;
    cin>>n>>k>>d;
   for(i=n;i<=k;i++)
   {
       if(i%d==0)
        count1++;
   }
    cout<<count1<<endl;
}


Measured memory_bytes: 3628
k = gets.chomp.to_i

 
if k % 2 == 0 || k % 5 == 0
  puts -1
  exit
end
 
count = 0
i = 0
k /= 7 if k % 7 == 0
while true do
  i = i * 10 + 1
  i %= k
  count += 1
  if i == 0
    break
  end
end
 
puts count

Measured memory_bytes: 14312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    ll a,b,k;
    cin >> a >> b >> k;
    ll aa;
    aa=max((ll)0,a-k);
    k-=a-aa;
    b=max((ll)0,b-k);
    cout << aa << ' ' << b;


    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  cin >> s;
  cout << s[0] << s[1] << s[2] << endl;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> Divisor(int n)
{
  vector<int> ret;
  for (int i = 1; i*i <= n; ++i)
  {
    if (n%i == 0)
    {
      ret.push_back(i);
      if (i*i != n) ret.push_back(n / i);
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
}

void C_109()
{
  int N, X;
  cin >> N >> X;

  vector<int> city_dis(N);
  for (int i = 0; i < N; ++i)
  {
    int city;
    cin >> city;
    city_dis[i] = abs(city - X);
  }

  //座標の差の最小値の約数を求める
  int min_dis = *min_element(city_dis.begin(), city_dis.end());
  vector<int> divisors = Divisor(min_dis);
  /*for (int i = 1; i*i <= min_dis; ++i)
  {
    if (min_dis%i == 0)
    {
      divisors.push_back(i);
      if (i*i != min_dis) divisors.push_back(min_dis / i);
    }
  }*/

  for (int i = divisors.size() - 1; i >= 0; --i)
  {
    //min_disの約数が他の約数となるか？
    for (int j = 0; j < N; ++j)
    {
      //if (city_dis[j] == min_dis) continue;
      if (city_dis[j] % divisors[i] != 0) break;
      if (j == N - 1)
      {
        cout << divisors[i] << endl;
        return;
      }
    }
  }
  cout << "1" << endl;
}

int main()
{
  C_109();
}


Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a[250][5]={{0}};
    int n;
    int sc[250]={0};
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
    }
    for(int kai=0;kai<3;kai++)
    {
        for(int i=0;i<n;i++)
        {
            int flg=0;
            for(int k=0;k<n;k++)
            {
                if(i!=k)
                {
                    if(a[i][kai]==a[k][kai])flg=1;
                }
            }
            if(flg==0)sc[i]+=a[i][kai];
        }
    }
    for(int i=0;i<n;i++)
    {
        cout<<sc[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1164
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long K = sc.nextLong();
		int a[] = new int[N];
		int b[] = new int[N];
		for (int i=0;i<N;i++) {
			a[i] = sc.nextInt();
		}
		List<Integer> list  = new ArrayList<Integer> ();
		int count =0;
		int now =1;
		int breakKey=0;
		for (;count<N;count++) {
			if (b[a[now-1]-1]!=0) {
				breakKey =  a[now-1];
				break;
			}
			b[a[now-1]-1]= 1;
			list.add(a[now-1]);
			now = a[now-1];
		}
		if (count<N&&breakKey !=1) {
			int start =0;;
			for (int i=0;i<list.size();i++) {
				if (list.get(i)==breakKey) {
					start= i;
					break;
				}
			}
			if (K<start+1) {
				System.out.println(list.get((int)(K-1)));
			} else {
				K= K-start-1;
				int index = (int)(K%(list.size()-start));
				System.out.println(list.get(index+start));
			}
		} else {
			int index = (int) (K%(count));
			if (index==0) {
				System.out.println(1);
			} else {
				System.out.println(list.get(index-1));
			}
		}

	}
}

Measured memory_bytes: 61636
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    n, m = map(int, input().split())
    ans = 0
    for i in range(n):
        ans += n-(i+1)
    for i in range(m):
        ans += m-(i+1)
    print(ans)


main()


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

int main()
{
    int N;
    cin >> N;
    vector<int> H(N);
    int max = 0;
    rep(0, i, N)
    {
        cin >> H.at(i);
        if (H.at(i) < max - 1)
        {
            cout << "No" << endl;
            return 0;
        }
        else if (H.at(i) > max)
        {
            max = H.at(i);
        }
    }
    cout << "Yes" << endl;
}

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

int main(void){

	int a = 0;
	int b = 0;
	int c = 0;
  	int d = 0;
  	int e = 0;
  	int f = 0;
    int i = 0;
    int j = 0;

	scanf("%d", &a);
	scanf("%d", &b);
  
  	for(i = 1; i <= a; i++){
      for(j = 1; j <= b; j++){
        d = j % 10;
        e = j / 10;
        f = d * e;
        if(d >= 2 && e >= 2 && f == i){
          c++;
        }
      }
    }
	printf("%d", c);

	return 0;
}


Measured memory_bytes: 128
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    S = input()
    K = int(input())

    all1flg = True
    for i in range(min(len(S), K-1)):
        if S[i]!='1':
            ans = S[i]
            all1flg = False
            break
    if all1flg:
        print(S[K-1])
    else:
        print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 2940
n, m = gets.split.map(&:to_i)
a = Array.new(n) { Array.new(n) { false } }

m.times do
  ai, bi = gets.split.map {|x| x.to_i - 1}
  a[ai][bi], a[bi][ai] = true, true
end

c = 0
(1...n).to_a.permutation.each do |r|
  rr = [0, *r]
  c += 1 if rr.each_cons(2).map {|(f, t)| a[f][t]}.all?
end

puts c

Measured memory_bytes: 3964
#include <stdio.h>
int main(){
  int i,flag=1,times=0,temp,N;

  scanf("%d",&N);

  int A[N];

  for(i=0;i<N;i++)
    scanf("%d",&A[i]);

  while(flag){
    flag=0;
    for(i=N-1;i>=0;i--){
      if(A[i]<A[i-1]){
	temp=A[i];
	A[i]=A[i-1];
	A[i-1]=temp;

	times++;
	flag=1;
      }
    }
  }

  for(i=0;i<N-1;i++)
    printf("%d ",A[i]);
  printf("%d\n",A[N-1]);
  
  printf("%d\n",times);
  
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(ll i=(x);i<(y);i++)
#define disp(a) cout << a << endl;
typedef long long ll;
using namespace std;
int main()
{
	int N;
	cin >> N;
	cout << N/3 <<endl;
}

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

class dice {
private:
	int n[7];

public:
	dice(int, int, int, int, int, int);
	int getcur() { return n[1]; }
	int getnum(int i) { return n[i]; }
	void rotate(char);
};

dice::dice(int n1, int n2, int n3, int n4, int n5, int n6) {
	n[1] = n1;
	n[2] = n2;
	n[3] = n3;
	n[4] = n4;
	n[5] = n5;
	n[6] = n6;
}

void dice::rotate(char op) {
	dice copy(n[1], n[2], n[3], n[4], n[5], n[6]);
	switch (op) {
	case'W':
		n[1] = copy.n[3];
		n[3] = copy.n[6];
		n[6] = copy.n[4];
		n[4] = copy.n[1];
		break;
	case'E':
		n[1] = copy.n[4];
		n[3] = copy.n[1];
		n[6] = copy.n[3];
		n[4] = copy.n[6];
		break;
	case'S':
		n[1] = copy.n[5];
		n[2] = copy.n[1];
		n[6] = copy.n[2];
		n[5] = copy.n[6];
		break;
	case'N':
		n[1] = copy.n[2];
		n[2] = copy.n[6];
		n[6] = copy.n[5];
		n[5] = copy.n[1];
		break;
	case'C':
		n[2] = copy.n[3];
		n[3] = copy.n[5];
		n[5] = copy.n[4];
		n[4] = copy.n[2];
		break;
	}
}

bool check(dice,dice);
bool ok = false;

int main() {
	int na[7],nb[7];
	for (int i = 1; i <= 6; i++) {
		cin >> na[i];
	}
	for (int i = 1; i <= 6; i++) {
		cin >> nb[i];
	}
	dice a(na[1], na[2], na[3], na[4], na[5], na[6]);
	dice b(nb[1], nb[2], nb[3], nb[4], nb[5], nb[6]);

	for (int i = 0; i < 4; i++) {
		//check
		for (int j = 0; j < 4; j++) {
			if (check(a, b)) {
				ok = true;
				break;
			}
			b.rotate('C');
		}
		b.rotate('N');
	}

	if (!ok) {
		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 4; j++) {
				if (check(a, b)) {
					ok = true;
					break;
				}
				b.rotate('C');
			}
			b.rotate('E');
		}
	}

	if (ok) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

bool check(dice a, dice b) {
	bool isequal = true;
	for (int i = 1; i <= 6; i++) {
		if (a.getnum(i) != b.getnum(i)) isequal = false;
	}
	return isequal;
}

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

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

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

#define MAX 100005
#define INF 1001001001

vector< vector<ull> > mask;
void init(void)
{
    int n = 8;
    mask.assign(n, vector<ull>(n));
    ull t = 1;
    rep(i,n) rep(j,n) {
        mask[i][j] = t;
        t <<= 1;
    }
}

void setQueen(ull& stage, ull& queen, int x, int y)
{
    int n = 8;
    int dx[8] = { 0,  1,  1,  1,  0, -1, -1, -1 };
    int dy[8] = { 1,  1,  0, -1, -1, -1,  0,  1 };
    queen |= mask[x][y];
    stage |= mask[x][y];
    rep(i,8) {
        int nx = x+dx[i];
        int ny = y+dy[i];
        while (0 <= nx && nx < n && 0 <= ny && ny < n) {
            stage |= mask[nx][ny];
            nx += dx[i];
            ny += dy[i];
        }
    }
}

bool dfs(ull& stage, ull& queen, int count)
{
    if (!count) return true;

    int n = 8;
    rep(i,n) rep(j,n) {
        if (stage & mask[i][j]) continue;
        ull ns = stage, nq = queen;
        setQueen(ns, nq, i, j);
        if (dfs(ns, nq, count-1)) {
            stage = ns; queen = nq;
            return true;
        }
    }
    return false;
}

int main(int, char**)
{
    init();

    int k, n=8;
    cin >> k;

    ull stage = 0, queen = 0;
    int r, c;
    rep(i,k) {
        cin >> r >> c;
        setQueen(stage, queen, r, c);
    }
    dfs(stage, queen, 8-k);
    rep(i,n) {
        rep(j,n) {
            if (queen & mask[i][j]) cout << "Q"; else cout << ".";
        }
        cout << endl;
    }

    return 0;
}



Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    while(true){
        ll H, W;
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        string s, t;
        rep(i,W){
            if (i % 2 == 0)
                s += '#', t += '.';
            else
                s += '.', t += '#';
        }

        rep(i,H){
            if(i%2==0)
                cout << s << '\n';
            else
                cout << t << '\n';
        }
        cout << '\n';
    }
}


Measured memory_bytes: 3220
#include <iostream>
#include <map>
#include <set>
#include <utility>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

bool isStrongPal(string s){
    int sz;
    int flag1 = 0, flag2 = 0, flag3 = 0;
    bool ret = false;
    sz = s.size();
    
    for(int i = 0 ; i < sz; i++){
        if(s[i] != s[sz-i-1]){
            flag1 = 1;
            break;
            
        }
    }
    string str2 = s.substr(0, (sz-1)/2);
    for(int i = 0 ; i < str2.size(); i++){
        if(str2[i] != str2[str2.size()-i-1]){
            flag2 = 1;
            break;
            
        }
    }
    string str3 = s.substr((sz+3)/2-1,sz);
    for(int i = 0; i < str3.size(); i++){
        if(str3[i] != str3[str3.size()-i-1]){
            flag3 = 1;
            break;
            
        }
    }
    if(flag1 == false && flag2 == false && flag3 == false) ret = true;
    return ret;
}

int main() {
    string s; cin >> s;
    bool ans = isStrongPal(s);
    if(ans == true) cout<< "Yes" << endl;
    else cout << "No" << endl;
    
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 *
 * @author bhatti
 */
public class Main {

    
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] p = new int[N];
        for (int i = 0; i < N; ++i) {
            p[i] = sc.nextInt();
        }
       int count = 0;

        for (int i = 0; i < N; i++) {
            if (p[i] == i + 1){
                count++;
                i++;
            }

        }
        System.out.println(count);
    }

   
}

Measured memory_bytes: 52212
def money(n):
  if n==1:
    return 300000
  elif n==2:
    return 200000
  elif n==3:
    return 100000
  else:
    return 0

a,b=map(int,input().split())

ans=money(a)+money(b)+400000 if a==b==1 else money(a)+money(b)
print(ans)

Measured memory_bytes: 9100
#include <iostream>
#include <vector>
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;

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

  int n; cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];

  int ans = 0, now = 0;
  while(now <= n) {
    int i;
    for(i = now; i < n && h[i]!=0; ++i) --h[i];
    // i が遷移できなかった場合は now を進める
    if(now==i) {
      ++now;
    } else {
      ++ans;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pii pair<long long,long long>
#define endl '\n'
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    while(test--)
    {
        string s; cin>>s;
        if(s[2]==s[3] && s[4]==s[5])
        cout<<"Yes"<<endl;
        else
        {
            cout<<"No"<<endl;
        }
        
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n,k;
  scanf("%d%d",&n,&k);
  int p[n];
  double data[n];
  for(int i=0;i<n;i++){
	scanf("%d",&p[i]);
    data[i]=(1.0+p[i])/2.0;           
  }
  double calc=0;
  for(int i=0;i<k;i++){
	calc+=data[i];			//左端からkこの期待値の合計
  }
//printf("%lf\n",calc);
  double max=calc;
  for(int i=0;i+k<=n-1;i++){
	 calc=calc-data[i]+data[k+i];
    //printf("%lf\n",calc);
    if(calc>max)max=calc;
  }
  printf("%.12lf",max);
  return 0;
}

Measured memory_bytes: 2560
CARD = []
3.times do
  CARD << gets.chomp.split
end

N = gets.chomp.to_i

HITS = {}
N.times do 
    hit = gets.chomp
    HITS[hit] = true
end

def hit?(x, y)
    HITS[CARD[y][x]]
end

3.times do |y|
    if hit?(0, y) && hit?(1, y) && hit?(2, y)
        puts 'Yes'
        exit 0
    end
end

3.times do |x|
    if hit?(x, 0) && hit?(x, 1) && hit?(x, 2)
        puts 'Yes'
        exit 0
    end
end

if hit?(0, 0) && hit?(1, 1) && hit?(2, 2)
    puts 'Yes'
    exit 0
end

if hit?(2, 0) && hit?(1, 1) && hit?(0, 2)
    puts 'Yes'
    exit 0
end

puts 'No'

Measured memory_bytes: 1788
import math
a, b, x = map(int, input().split())

if x < a ** 2 * b / 2:
    theta = math.atan2(b, 2 * x / b / a)
else:
    theta = math.atan2(2 * b - 2 * x / a / a, a)
deg = math.degrees(theta)
print(deg)



Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=a;i<n;i++)
typedef struct{
	int num,p;
}A;
A ary[100000];
int comp(const void* a,const void* b){
	return ((A*)a)->num - ((A*)b)->num;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
int main(void)
{
	int n,i;
	ll k;
	scanf("%d%lld",&n,&k);
	FOR(i,0,n) scanf("%d%d",&ary[i].num,&ary[i].p);
	qsort(ary,n,sizeof(A),comp);
	for(i=0;k>0;i++) k-=ary[i].p;
	printf("%d\n",ary[i-1].num);
	return 0;
}
    

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;


int main() {
    
    ll n;
    string s;
    cin >> n >> s;
    ll ans = 0;
    char pre = 'A';
    for (ll i=0;i<n;i++){
        if(s[i] != pre){
            ans++;
        }
        pre = s[i];
    }
    cout << ans << endl;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long

int32_t main() {
	IOS;
	int k;
	string s;
	cin>>k>>s;
	int n=(int)s.size();
	if(n<=k) cout<<s;
	else{
		cout<<s.substr(0,k);
		cout<<"...";
	}
	return 0;
}


Measured memory_bytes: 3644
#pragma GCC optimize("Ofast")

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

#define M 1000000007
#define MM 998244353 
#define ll long long 
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=a;i<b;i++)
#define F first
#define S second
#define PI 3.1415926536
#define INF 2e9
#define endl "\n"

ll power(ll b,ll e,ll m)
{
	if(e==0)
		return 1;
	if(e%2)
		return b*power(b*b%m,(e-1)/2,m)%m;
	else
		return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0)
		return 1;
	if(e%2)
		return b*power(b*b,(e-1)/2);
	else
		return power(b*b,e/2);
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll n,k,s,i;
	cin>>n>>k>>s;
	for(i=0;i<k;i++)cout<<s<<" ";
	for(i=k;i<n;i++)
	{
		if(s==1e9)cout<<1<<" ";
		else cout<<s+1<<" ";
	}
	return 0;
}


Measured memory_bytes: 1280
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  vector<long> foo(3);
  rep (i, 3) cin >> foo[i];
  sort(foo.begin(), foo.end());
  long ans = 0;
  long a = (foo[2] - foo[0]) / 2;
  ans += a;
  foo[0] += a * 2;
  long b = (foo[2] - foo[1]) / 2;
  ans += b;
  foo[1] += b * 2;
  sort(foo.begin(), foo.end());
  foo[2] -= foo[0];
  foo[1] -= foo[0];
  foo[0] -= foo[0];
  sort(foo.begin(), foo.end());
  if (foo[2] == 0);
  else if (foo[1] == 1) ans += 2;
  else ans += 1;
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
# dpC - Vacation
# 貰うDP
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    A = tuple(tuple(map(int, input().rstrip().split())) for _ in range(n))
    dp = [[0] * 3 for _ in range(n)]
    dp[0] = A[0]
    for i in range(1, n):  # i-th day
        for j in range(3):  # yesterday
            for k in range(3):  # today
                if j != k:
                    dp[i][k] = max(dp[i][k], dp[i - 1][j] + A[i][k])
    print(max(dp[-1]))


if __name__ == "__main__":
    main()

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

int main() {
    int n;
    cin >> n;
    rep(i, 10) {
        rep(j, 10) {
            if(i * j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int n,m,p,q,r,x,y;
	vector<int>::iterator itx,ity,it;
	for(;cin>>n>>m>>p>>q>>r;cout<<x<<endl){
		vector<int> v1,v2;
		v1.push_back(0);
		v1.push_back(r);
		
		for(;m--;v2.clear()){
			cin>>x>>y;
			itx=upper_bound(v1.begin(),v1.end(),x);
			ity=upper_bound(v1.begin(),v1.end(),y);
			
			if( ity-v1.begin()+1 & 1 )v2.push_back(0);
			v2.push_back(0);
			for(it=ity;it!=v1.end();++it)
				v2.push_back(*it - y);
			
			if(v1.end()-itx & 1)v2.push_back(n-y);
			for(it=itx;it!=ity;++it)
				v2.push_back(*it-x+n-y);
			
			it = v1.begin();
			if(ity-v1.begin() & 1)++it;
			if(!it[1])it+=2;	//d¡r
			if(*it+n-x==v2.back()){++it;v2.pop_back();}	//d¡r
			for(;it!=itx;++it)
				v2.push_back(*it+n-x);
			
			v1.swap(v2);
		}
		v1.insert( upper_bound(v1.begin(),v1.end(),p-1), 2, p-1);
		v1.insert( lower_bound(v1.begin(),v1.end(),q), q );
		v1.push_back(n);
		it = upper_bound(v1.begin(),v1.end(),p-1);
		if(it-v1.begin() & 1) --it;
		for(x=0;*it<q;++it){
			m=*it;
			++it;
			x+=*it-m;
		}
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-9;
long double pi = acos(-1);



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

    ll a;
    double b;
    cin>>a>>b;
    cout << a* (ll)(b*100+eps)/100 << endl;

}


Measured memory_bytes: 3740
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() (int, error) {
	sc.Scan()
	s := sc.Text()
	return strconv.Atoi(s)
}

func main() {
	sc.Split(bufio.ScanWords)

	for {
		a, _ := nextInt()
		sc.Scan()
		op := sc.Text()
		b, _ := nextInt()

		switch op {
		case "?":
			return
		case "+":
			fmt.Println(a + b)
		case "-":
			fmt.Println(a - b)
		case "*":
			fmt.Println(a * b)
		case "/":
			fmt.Println(a / b)
		}
	}
}



Measured memory_bytes: 1120
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  if(s.size() == 1){
    cout << "-1 -1\n";
    return 0;
  }
  for(int i = 0; i < s.size() - 1; i++){
    if(s[i] == s[i + 1]){
      cout << i + 1 << " " << i + 2 << endl;
      return 0;
    }
  }
    for(int i = 0; i < s.size() - 2; i++){
    if(s[i] == s[i + 2]){
      cout << i + 1 << " " << i + 3 << endl;
      return 0;
    }
  }

  cout << "-1 -1\n";
  return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
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<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

// a^b mod を計算する
ll mod_pow(ll a, ll b, ll p) {
    if (b == 0) return 1;
    if (b & 1) return (a * mod_pow(a, b - 1, p)) % p;
    ll t = mod_pow(a, b / 2, p);
    return (t * t) % p;
}
signed main()
{   
    gearup;
    ll n,k; cin >> n >> k;
    ll d[100010] = {0};
    for(int i=k;i>=1;i--){
        d[i] = mod_pow((k/i),n,MOD);
        for(int j=2*i;j<=k;j+=i){
            d[i] = (d[i] - d[j] + MOD)%MOD;
            
        }
    }
    ll res = 0;
    rep1(i,k+1)res = (res + i*d[i])%MOD;
    out(res);
}


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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void vprint(vector<ll> A){
    ll L = A.size();
    FOR(i, 0, L){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

ll ll_pow(ll a, ll n){
    ll ans = 1;
    FOR(i, 0, n){
        ans *= a;
        ans %= 13;
    }
    return ans;
}

// https://www.khanacademy.org/computing/computer-science/cryptography/modarithmetic/a/fast-modular-exponentiation
ll memo[20];
void make_memo(ll base, ll mo){
    memo[0] = 1;
    memo[1] = base % mo;
    FOR(i, 2, 20){
        memo[i] = (memo[i-1]*memo[i-1])%mo;
    }
}

// 2進数にする
vector<ll> to_binary(ll a){
    vector<ll> A;
    if(a==0){
        A.push_back(0);
        return A;
    }
    while(a){
        ll r = a%2;
        a/=2;
        A.push_back(r);
    }
    return A;
}

ll my_pow(ll a, ll n, ll mo){ // ll_powと引数を似せておく
    auto binary = to_binary(n);
    ll L = binary.size();
    ll mul = 1;
    FOR(i, 0, L){
        if(binary[i]){
            mul *= memo[i+1];
            mul %= mo;
        }
    }
    return mul;
}

ll my_pow2(ll a, ll n, ll mo){ // ll_powと引数を似せておく
    bitset<20> bi(n);
    ll mul = 1;
    FOR(i, 0, 20){
        if(bi[i]){
            mul *= memo[i+1];
            mul %= mo;
        }
    }
    return mul;
}

ll dp[100010][13];

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

    // input
    string s; cin >> s;
    ll L = s.size();

    make_memo(10, 13);

    // 0桁目
    char c = s[L-1];
    if(c=='?'){
        FOR(i, 0, 10){
            dp[0][i] = 1;
        }
    }else{
        ll v = c - '0';
        dp[0][v] = 1;
    }

    // i桁目
    FOR(i, 1, L){
        char c = s[L-1-i];
        ll v;
        if(c=='?'){
            v = -1;
        }else{
            v = c - '0';
        }

        if(c=='?'){
            FOR(r, 0, 13){
                FOR(v, 0, 10){
                    // v
                    ll j = (v * my_pow2(10, i, 13) + r) % 13;
                    dp[i][j] += dp[i-1][r];
                    dp[i][j] %= mod;
                }
            }
        }
        else{
            FOR(r, 0, 13){
                // v
                ll j = (v * my_pow2(10, i, 13) + r) % 13;
                dp[i][j] += dp[i-1][r];
                dp[i][j] %= mod;
            }
        }
    }

    ll ans = dp[L-1][5];
    p(ans);
    
    return 0;
}


Measured memory_bytes: 10704