akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h" // 提出時こちらで問題なし
//#include <iostream>
//#include <string>
//#include <typeinfo>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define REP2(i, s, n) for (int i=(int)(s); i<(int)(n); i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
#define SORT(c) sort((c).begin(),(c).end())
#define R_SORT(c) sort((c).begin(),(c).end(),greater<>())
using G = vector<vector<int>>;
using M = map<int, int>;
using P = pair<int, int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
using V = vector<int>;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using edge = struct { int to; int cost; };
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; }
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

// char -> int 変換
int ctoiii(const char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return -1;
	}
}

// D - 

// C - Step
int main()
{
	int n; cin >> n;
	vector<int> a(n);
	REP(i, n) { cin >> a.at(i); }

	int cur = a.at(0);
	long ans = 0;
	REP(i, n) {
		if (cur > a.at(i)) {
			ans += cur - a.at(i);
		}
		else if (cur < a.at(i)) {
			cur = a.at(i);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4044
import sys
def input():
    return sys.stdin.readline()[:-1]
m,d=map(int,input().split())
ans=0
for i in range(m):
    for j in range(d):
        done=(j+1)%10
        dtwo=(j+1)//10
        if done>=2 and dtwo>=2 and done*dtwo==(i+1):
            ans+=1
print(ans)

Measured memory_bytes: 39664
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        static int gcd(int a, int b)
        {
            if (a < b)
            {
                return gcd(b, a);
            }

            while (b != 0)
            {
                int rem = a % b;
                a = b;
                b = rem;
            }

            return a;
        }

        static void Main(string[] args)
        {
            string[] strs = Console.ReadLine().Split(' ');
            int N = int.Parse(strs[0]);
            int X = int.Parse(strs[1]);

            strs = Console.ReadLine().Split(' ');
            int[] h = new int[N+1];
            for (int i = 0; i < N; i++)
            {
                h[i] = int.Parse(strs[i]);
            }
            h[N] = X;

            Array.Sort(h);

            int ans = Math.Abs(h[1] - h[0]);
            for (int i = 2; i < N + 1; i++)
            {
                ans = gcd(ans, Math.Abs(h[i] - h[i - 1]));
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 18400
#include <bits/stdc++.h>
#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
#include <numeric>
#include <iomanip>
#include <cstring> 
using namespace std;
using ll=long long;

#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define LLONG_MAXs 9223372036854775800

#include <iostream>
#include <cmath>
using namespace std;
 

 
bool isPrimeNum( ll x ){ // 素数である場合 true を返す
  if( x <= 1 ){ // 1以下である場合は素数でないことがすぐにわかる
    return false;
  }
  // sqrt( double型 ) は引数の平方根を double型で返すので、int型でキャスト
  int n = (int)sqrt( (double)x );
  for( int i = 2; i <= n; i++ ){
    if( x % i == 0 ){ // 割り切る整数がある場合、即判定終了
      return false;
    }
  }
  return true; // 割り切る整数がない場合、素数である
}

constexpr ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
constexpr ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll abs(ll a,ll b){
if(a>=b)return a-b;
if(a<b)return b-a;
}
constexpr ll min(ll a,ll b){
if(a>=b)return b;
if(a<b)return a;
}

constexpr ll max(ll a,ll b){
if(a>=b)return a;
if(a<b)return b;
}

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

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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


  ll ans=(N-M)*100+1900*M;
  ll tmp=1900;
  if(M>0){
    FOR(i,0,M-1){
      ans=ans*2;
    }
  }

cout<<ans<<endl;
return 0;

}
 


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

int main() {
  string weather;
  cin >> weather;
  if(weather == "Sunny") cout << "Cloudy" << endl;
  if(weather == "Cloudy") cout << "Rainy" << endl;
  if(weather == "Rainy") cout << "Sunny" << endl;


}


Measured memory_bytes: 256
n,c=map(int,input().split())
stc=[[] for i in range(c+1)]
a=[]
t=0
for i in range(n):
    p=[int(j) for j in input().split()]
    stc[p[2]].append([p[0],p[1]])
    t=max(t,p[1])
ans=10**100
for i in range(c+1):
    p=10**10
    stc[i].sort()
    for j in range(len(stc[i])):
        if j+1<len(stc[i]):
            if stc[i][j][1]==stc[i][j+1][0]:
                if p==10**10:
                    p=stc[i][j][0]
            else:
                if p!=10**10:
                    a.append([p,stc[i][j][1]])
                else:
                    a.append([stc[i][j][0],stc[i][j][1]])
                p=10**10
        else:
            if p!=10**10:
                a.append([p,stc[i][j][1]])
            else:
                a.append([stc[i][j][0],stc[i][j][1]])

table=[0]*(t+1)
for i in range(len(a)):
    table[a[i][0]-1]+=1
    table[a[i][1]]-=1
for i in range(1,t+1):
    table[i]+=table[i-1]

print(max(table))




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

int main(){
	int n, a;
	cin >> n;
	int count =0;
	for(int i =0; i<n; i++){
		cin >> a;
		while(a%2==0) {
			a/=2;
			count++;
		}
	}
	cout << count;
 }


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

int main(){
    long long a, b, c;
    cin >> a >> b >> c;
    long long tmp;

    tmp = a;
    a = b;
    b = tmp;

    tmp = a;
    a = c;
    c = tmp;

    cout << a << " " << b << " " << c;
    return 0;
}

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

int n;
int a[100005];
int num1,num2,num4;

int main()
{
    scanf ("%d",&n);
    for (int i=1;i<=n;i++)
        scanf ("%d",&a[i]);
    for (int i=1;i<=n;i++)
        {
        if (a[i]%4==0) {num4++; continue;}
        if (a[i]%2==0) {num2++; continue;}
        num1++;
        }
    if (num2!=0)
        {
        if (num1>num4) printf ("No");
        else printf ("Yes");
        }
    else if (num1-1<=num4) printf ("Yes");
        else printf ("No");
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;
const LL N = 200005;

LL ec = 0,to[N << 1],nxt[N << 1],hed[N];
void add_edge(LL f,LL t){
	++ ec; to[ec] = t; nxt[ec] = hed[f]; hed[f] = ec;
}

LL sg[N];
void dfs(LL u,LL f){
	sg[u] = 0;
	for(LL i = hed[u];i;i = nxt[i]){
		LL v = to[i];
		if(v == f) continue;
		dfs(v,u);
		sg[u] ^= (sg[v] + 1);
	}
}

int main(){
	ios::sync_with_stdio(false);
	LL n,u,v;
	cin >> n;
	for(LL i = 1;i < n;i ++){
		cin >> u >> v;
		add_edge(u,v); add_edge(v,u);
	} dfs(1,0);
	cout << (sg[1] ? "Alice" : "Bob") << '\n';
	return 0;
}

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

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

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

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

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

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

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

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

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

    match: =, \=

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

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

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

    sum_list(Xs, Sum)

    orは!忘れに注意(末尾再帰なら直前)
*/

f([], [], []).
f([X|Xs], [Y|Ys], [X,Y|Zs]) :- f(Xs, Ys, Zs).

main :-
    get_number(N),
    get_chars(S),
    get_chars(T),
    f(S, T, U),
    string_chars(U2, U),
    writeln(U2).

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


Measured memory_bytes: 8036
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <string>
#define ll long long
using namespace std;

int main() {
	int n, bn;
	double ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> bn;
		ans += 1.0 / bn;
	}

	printf("%.12f", 1.0/ans);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=int (a);i<int (n);i++)
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define OUT  freopen("output.txt", "w", stdout)
#define IN  freopen("input.txt", "r", stdin)
#define mem(a,b) memset((a),(b),sizeof(a))
#define NumofDigits(n) ((int)log10(n)+1)
#define NumofBits(n) ((int)log2(n)+1)
#define PI 3.14159265358979323846264
#define vii vector<pair<int,int>>
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi  vector<ll>
#define nl  cout<<"\n"
#define pb  push_back
#define mp  make_pair
#define ll  long long 
#define ss  second 
#define ff  first
#define endl "\n"
#define sp  " "
using namespace std;
ll mod=1000000007;
int main(){
FAST;

int t=1;// cin>>t; 
while(t--){
  string s;cin>>s;
  ll a=0;
  rep(i,0,s.length())
  a+=int(s[i])-'0';
  
  if(a%9==0)cout<<"Yes";
  else cout <<"No";
	
}

}


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

using ll = long long;

int main() {
   ll X, Y;
   cin >> X >> Y;
   ll ans = 0;
   for (ll i = X; i <= Y; i*=2) {
      ans++;
   }
   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 256
N = int(input())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

div = make_divisors(N)
if len(div) % 2 == 0:
    print((div[len(div) // 2] - 1) + (div[len(div) // 2 - 1] - 1))
else:
    print((div[len(div) // 2] - 1)*2)

Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
#define f first
#define s second
#define ll long long
#define ld long double
#define pii pair <int,int>
#define pll pair <ll,ll>
#define pil pair <int,ll>
#define pli pair <ll,int>
#define ull unsigned long long
#define pdd pair <double,double>
#define pb push_back
#define mp make_pair
#define puu pair<ull,ull>
#define pvv pair<vector<int>, vector<int> >
#define _bp __builtin_popcount
#define ptt pair <Tree*,Tree*>
#define all(v) v.begin(),v.end()
const long double pi = acos(-1);
void boos()
{
     ios_base :: sync_with_stdio(false);
     cin.tie(0);
     cout.tie(0);
}
void file()
{
   freopen(".in","r",stdin);
   freopen(".out","w",stdout);
}
const ll INF = 1e9 + 7;
const ll INF1 = 998244353;
const ll LLINF = (ll)1e18;
const int  INTmx = (int)1e9;
const int N = 3100;
int dp[N][N];
pair <pii,bool> p[N][N];
int main()
{
    //file();
    boos();
    string s,t;
    cin >> s >> t;
    s = '0' + s;
    t = '0' + t;
    if(s.size() < t.size())swap(s,t);
    int n = (int)t.size() - 1,m = (int)s.size() - 1;
    for(int i = 1;i <= n;i++)
    {
        for(int j = 1;j <= m;j++)
        {
            if(dp[i - 1][j] > dp[i][j])
            {
                dp[i][j] = dp[i - 1][j];
                p[i][j]  = mp(mp(i - 1,j),0);
            }
            if(dp[i][j - 1] > dp[i][j])
            {
                dp[i][j] = dp[i][j - 1];
                p[i][j] = mp(mp(i,j - 1),0);
            }
            if(t[i] == s[j] && dp[i][j] < dp[i - 1][j - 1] + 1)
            {
                dp[i][j] = dp[i - 1][j - 1] + 1;
                p[i][j] = mp(mp(i - 1,j - 1),1);
            }
        }
    }
    ////cout << t << " " << s << endl;
    //cout << t[3] << " " << s[4] << endl;
    string vosk;
    //cout << dp[n][m] << endl;
    int i = n,j = m;
    while(i != 0 && j != 0)
    {
        if(p[i][j].s)vosk += t[i];
        pii k = p[i][j].f;
        i = k.f;
        j = k.s;
        //cout << i << " " << j << endl;
    }
    reverse(all(vosk));
    cout << vosk;
}

Measured memory_bytes: 149888
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<cmath>
using namespace std;
typedef long long ll;
const int Nmax = 100000;
int N, K;
ll A[Nmax];

int main(){
    ios_base::sync_with_stdio(false);

    cin >> N >> K;
    for(int i=0; i<N; i++) cin >> A[i];

    ll sum = 0;
    ll lpos = 0;
    ll rpos = 0;
    for(int i=0; i<K; i++){
        sum += A[i];
    }
    for(int i=K; i<N; i++){
        if(A[i] > 0){
            rpos += A[i];
        }
    }

    ll ans = 0;
    for(int i=0; i<N-K; i++){
        if(sum > 0){
            ans = max(ans, lpos+rpos+sum);
        }
        else{
            ans = max(ans, lpos+rpos);
        }
        sum += -A[i]+A[i+K];
        lpos += A[i] > 0 ? A[i] : 0;
        rpos -= A[i+K] > 0 ? A[i+K] : 0;
    }
    if(sum > 0){
        ans = max(ans, lpos+rpos+sum);
    }
    else{
        ans = max(ans, lpos+rpos);
    }

    cout << ans << endl;

    return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

vector<int> L,R;

int MergeSort(vector<int>& A,int left,int mid,int right){
	int n1 = mid-left;
	int n2 = right-mid;
	REP(i,n1){
		L[i] = A[i+left];
	}
	REP(i,n2){
		R[i] = A[i+mid];
	}
	L[n1] = 1<<30;
	R[n2] = 1<<30;

	int li=0,ri=0;
	for(int i=left;i<right;i++){
		if(L[li]<=R[ri]){
			A[i] = L[li++];
		}
		else{
			A[i] = R[ri++];
		}
	}
	return li+ri;
}

int MergeSort(vector<int>& A,int left,int right){
	int sum = 0;
	if(left+1<right){
		int mid = (left+right)/2;
		sum += MergeSort(A,left,mid);
		sum += MergeSort(A,mid,right);
		sum += MergeSort(A,left,mid,right);
	}
	return sum;
}

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

	int N=in();
	L.resize(N+1);
	R.resize(N+1);
	auto A=vecin(N);
	
	int sum = MergeSort(A,0,N);
	REP(i,N-1){
		cout << A[i] << ' ';
	}
	out(A[N-1]);
	out(sum);
	return 0;
}



Measured memory_bytes: 8500
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vl vector<ll>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define FOR(i, a, b) for (int i = a; i < (b); ++i)

const ll MOD = 1e9+7;

int* Eratosthenes(int N){
    int* arr = new int[N];

    for(int i = 0; i < N; i++){
        arr[i] = 1;
    }
    for(int i = 2; i < sqrt(N); i++){
        if(arr[i]){
            for(int j = 0; i * (j + 2) < N; j++){
                arr[i *(j + 2)] = 0;
            }
        }
    }
    return arr;
}

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

int main() {

    int N;
    cin >> N;

    vector<int> A(N);
    rep(i, N){
        cin >> A[i];
    }
    int g = A[0];
    FOR(i, 1, N) g = gcd(g, A[i]);
    if(g != 1) {
        cout << "not coprime" << endl;
        return 0;
    }

    int* v = Eratosthenes(1e3+9);
    v[0] = 0;
    v[1] = 0;
    vector<int> B(1e6+9, 0);
    vector<int> pl;
    rep(i, 1e3+2) {
        if (v[i] == 1) pl.push_back(i);
    }

    int max_s = 1;

    rep(i, N) {
        int tmp = A[i];
        for(int j : pl) {
            if (tmp == 1) break;
            if (tmp % j != 0) continue;
            B[j]++;
            while(tmp % j == 0) {
                tmp /= j;
            }
        }
        if (tmp > 1) B[tmp]++;
    }

    FOR(i, 2, 1e6+2) {
        max_s = max(max_s, B[i]);
    }

    if (max_s == 1) cout << "pairwise coprime" << endl;
    else cout << "setwise coprime" << endl;

    return 0;
}


Measured memory_bytes: 11132
#include<stdio.h>
int main(void)
{
	int a, b, c;

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

	int i;
	int count = 0;

	for (i = 0; b >= a; i++) {
		count++;
		b = b - a;
		if (count== c) {
			break;
		}
	}

	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
 
int main()
{
    int n;
    cin >> n;
    while (n > 0) {
        int p = n % 10;
        if (p == 7) {
            cout << "Yes" << endl; return 0;
        } else {
            n /= 10;
        }
    }
    cout << "No" << endl; 
    return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  ll n;
  cin >> n;
  vector <vector <pair <ll, ll>>> v(n, vector <pair <ll, ll>> ());
  rep(i, n-1) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    v.at(a).push_back(make_pair(b, c)); v.at(b).push_back(make_pair(a, c));
  }
  ll q, k;
  cin >> q >> k;
  k--;
  vector <ll> d(n, INF);
  queue <ll> s;
  d.at(k) = 0; s.push(k);
  while (s.size()) {
    ll p = s.front(); s.pop();
    rep(i, v.at(p).size()) {
      ll tmp = v.at(p).at(i).first, cost = v.at(p).at(i).second;
      if (d.at(tmp) == INF) {
        d.at(tmp) = d.at(p) + cost;
        s.push(tmp);
      }
    }
  }
  rep(i, q) {
    ll x, y;
    cin >> x >> y;
    x--; y--;
    cout << d.at(x) + d.at(y) << endl;
  }
}

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

int main() {
  int n;
  cin >> n;
  vector<int long> a(n+1);
  vector<int long> b(n);
  for(int i = 0; i < n+1; i++)
    cin >> a.at(i);
  for(int i = 0; i < n; i++)
    cin >> b.at(i);
  
  int long count = 0;
  
  for(int i = 0; i < n; i++){
    if(a.at(i) >= b.at(i))
      count += b.at(i);
    else if(a.at(i)+a.at(i+1) >= b.at(i)){
      count += b.at(i);
      a.at(i+1) -= (b.at(i)-a.at(i));
    }
    else {
      count += (a.at(i)+a.at(i+1));
      a.at(i+1) = 0;
    }
  }
  cout << count << endl;
      
}


Measured memory_bytes: 1792
// https://atcoder.jp/contests/abc156/tasks/abc156_d

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#if DEBUG
  #define DUMP(a) REP(_i, a.size()) cout << a[_i] << (_i + 1 == a.size() ? "\n" : " ")
  #define DUMP2D(b) REP(_j, b.size()) DUMP(b[_j]); cout << endl
#else
  #define DUMP(a)
  #define DUMP2D(b)
#endif

//------------------------------------------------------------------------------
ll mod_pow(ll x, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) {
      res = res * x % mod;
    }
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

ll mod_inverse(ll x, ll mod) {
  return mod_pow(x, mod - 2, mod);
}

ll mod_comb2(ll n, ll k, ll mod) {
  if (n < 0 || k < 0 || n < k) return 0;
  if (k > n - k) k = n - k;
  if (k == 0) return 1;
  ll a = 1, b = 1;
  while(k > 0) {
    a = a * n-- % mod;
    b = b * k-- % mod;
  }
  return a * mod_inverse(b, mod) % mod;
}

//------------------------------------------------------------------------------
const int N_MAX = 1e9;
const int MOD = 1e9+7;

int n, a, b;

int main() {
  cin >> n >> a >> b;

  ll ans = mod_pow(2, n, MOD);
  ans = (ans + MOD - 1) % MOD;
  ans = (ans + MOD - mod_comb2(n, a, MOD)) % MOD;
  ans = (ans + MOD - mod_comb2(n, b, MOD)) % MOD;

  cout << ans << endl;
}


Measured memory_bytes: 256
L,R = map(int,input().split())

if R-L >= 2019:
    print("0")
else:
    sL = L % 2019
    sR = R % 2019
    minjo = 2019

    for i in range(L,R):
        for j in range(i+1,R+1):
            tmp = i * j % 2019
            minjo = min(minjo,tmp)

    print(minjo)


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

/////////////////////////////////////////////////////////////
map<ll, ll> prime_factorization(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; ++i) {
    while (n % i == 0) {
      res[i] += 1;
      n /= i;
    }
  }
  if (n != 1) res[n] = 1;
  return res;
}
/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////
class CombinationModulo {
 public:
  static const ll MOD = (ll)(1e9 + 7);

  vector<ll> fact;
  vector<ll> inv;
  vector<ll> fact_inv;

  CombinationModulo(int n) {
    this->fact = vector<ll>(n + 1, 0LL);
    this->inv = vector<ll>(n + 1, 0LL);
    this->fact_inv = vector<ll>(n + 1, 0LL);
    init(n);
  }

  void init(int n) {
    inv[1] = fact[0] = fact_inv[0] = 1;
    for (int i = 2; i <= n; i++) {
      inv[i] = (MOD - (MOD / i) * inv[MOD % i] % MOD) % MOD;
    }
    for (int i = 1; i <= n; i++) {
      fact[i] = fact[i - 1] * i % MOD;
    }
    for (int i = 1; i <= n; i++) {
      fact_inv[i] = fact_inv[i - 1] * inv[i] % MOD;
    }
  }

  ll comb(int n, int r) {
    if (r > n) return 0;
    return fact[n] * fact_inv[r] % MOD * fact_inv[n - r] % MOD;
  }
};
/////////////////////////////////////////////////////////////

const ll MOD = (ll)(1e9 + 7);

int n;
ll m;

ll ans;

int main(void) {
  // Here your code !
  scanf("%d %lld", &n, &m);

  auto prime_map = prime_factorization(m);

  int max_sholder = -1;

  for (auto &e: prime_map) {
    max_sholder = max(max_sholder, (int)(e.second));
  }

  CombinationModulo cm(n + max_sholder + 3);

  ans = 1LL;

  for (auto &e: prime_map) {
    ll cur = cm.comb(n + (int)(e.second) - 1, (int)(e.second));
    ans *= cur;
    ans %= MOD;
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 2560
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_5_B&lang=ja

    #include <stdio.h>
    
    int main(void){
        int w,h,i,j;
        while(1){
            scanf("%d %d",&w,&h);
            if(w == 0 && h == 0){
                break;
            }else{
                for(i=0;i<w;i++){
                    for(j=0;j<h;j++){
                        if(i % 2 == 0){
                            if(j % 2 == 0){
                                    printf("#");
                            }else{
                                    printf(".");
                            }
                        }else{
                            if(j % 2 == 1){
                                    printf("#");
                            }else{
                                    printf(".");
                            }
                        }
                    }
                    printf("\n");
                }
                printf("\n");
            }
        }

        return 0;
    }


Measured memory_bytes: 2064
#!/usr/bin/env python3
import sys


def solve(X: int, Y: int):
    prise=0
    if X<=3:
        prise+=100000*(4-X)
    if Y<=3:
        prise+=100000*(4-Y)
    if X==1 and Y==1:
        prise+=400000
    print(prise)
    return


# 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)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(X, Y)

if __name__ == '__main__':
    main()


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

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

  vector<int> a(n + 2);
  for (int i = 1; i <= n; i++) cin >> a[i];
  a[n + 1] = 0;

  int sum = 0;
  for (int i = 1; i <= n + 1; i++) {
    sum += abs(a[i] - a[i - 1]);
  }

  for (int i = 1; i <= n; i++) {
    int ans = sum - abs(a[i] - a[i - 1]) - abs(a[i] - a[i + 1]) +
              abs(a[i - 1] - a[i + 1]);
    cout << ans << endl;
  }
}


Measured memory_bytes: 3704
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  ll n;
  string b = "";
  cin >> n;
  int e = 0;
  if (n == 0) {
    cout << 0 << endl;
    return 0;
  }
  while(n != 0) {
    char i = '0';
    if (n%2 != 0) {
      n -= 1;
      i = '1';
    }
    b = i + b;
    n /= -2;
    e++;
  }
  cout << b << endl;
  return 0;
}

Measured memory_bytes: 3620
N,K = map(int,input().split())
x = list(map(int,input().split()))
mi = 10 ** 18
for i in range(N-K+1):
    l = x[i]
    r = x[i+K-1]
    lr = abs(l)+abs(l-r)
    rl = abs(r)+abs(l-r)
    mi = min(mi,min(lr,rl))
print(mi)

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


int main() {
int N;
  cin >>N;
  for(int i=1;i<=N;i++){
   int k = i*54/50;
    if(k==N){
     cout << i<<endl;
      return 0;
      
    }
  }
  cout << ":("<<endl;
  return 0;
}
  


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class T, class U>
vector<T> make_v(U size, const T& init){ return vector<T>(static_cast<size_t>(size), init); }

template<class... Ts, class U>
auto make_v(U size, Ts... rest) { return vector<decltype(make_v(rest...))>(static_cast<size_t>(size), make_v(rest...)); }

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

template <ll M = MOD> struct modint {
public:
    ll val;
    explicit modint(const ll x = 0) : val(x) {}
    modint operator+(const modint a) const { return modint(*this) += a; }
    modint operator-(const modint a) const { return modint(*this) -= a; }
    modint operator*(const modint a) const { return modint(*this) *= a; }
    modint operator/(const modint a) const { return modint(*this) /= a; }
    modint operator-() const { return modint(M-val); }
    modint inv(){
        ll u = 1, v = 0, s = 0, t = 1, m = M, x = val;
        while (x) {ll q = m/x; swap(s -= q*u, u); swap(t -= q*v, v); swap(m -= q*x, x); }
        if(s < 0) s += M;
        return modint(s);
    }
    modint pow(ll n){
        ll u = 1, xx = val;
        while (n > 0){ if (n&1) u = u * xx % M; xx = xx * xx % M; n >>= 1; }
        return u;
    }
    modint &operator+=(const modint a){ val += a.val; if(val >= M) val -= M; return *this; }
    modint &operator-=(const modint a){ val += a.val; if(val < 0) val += M; return *this; }
    modint &operator*=(const modint a){ val = val * a.val % M; return *this; }
    modint &operator/=(const modint a){ val = (val*a.inv()) %M; return *this;}
};
using mint = modint<MOD>;


int main() {
    int n, m;
    cin >> n >> m;
    auto v = make_v(n+1, n+1, n+1, true);
    auto dp = make_v(n+1, n+1, n+1, mint(0));
    dp[0][0][0] = mint(1);

    for (int i = 0; i < m; ++i) {
        int l, r, x;
        scanf("%d%d%d", &l, &r, &x);
        for (int j = 0; j < r; ++j) {
            for (int k = 0; k < r; ++k) {
                if(((l <= j) + (l <= k) + 1) != x) v[r][j][k] = v[j][r][k] = v[j][k][r] = false;
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            for (int k = 0; k < n; ++k) {
                int to = max({i, j, k})+1;
                if(v[to][j][k]) dp[to][j][k] += dp[i][j][k];
                if(v[i][to][k]) dp[i][to][k] += dp[i][j][k];
                if(v[i][j][to]) dp[i][j][to] += dp[i][j][k];
            }
        }
    }
    mint ans(0);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            ans += dp[i][j][n];
            ans += dp[i][n][j];
            ans += dp[n][i][j];
        }
    }
    cout << ans.val << "\n";
    return 0;
}

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

using namespace std;

/**templates**/
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;

#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sf(x) scanf("%lf",&x)
#define ss(x) scanf(" %s",x)
#define sc(x) scanf(" %c",&x)
#define pi acos(-1.0)
#define pb push_back
#define mp make_pair
#define aa first
#define bb second
#define sz(x) (ll)(x).size()
#define cas printf("Case %lld: ",++t)
#define casline printf("Case %lld:\n",++t)
//#define cas cout<<"Case "<<++t<<": "
//#define casline cout<<"Case "<<++t<<":"<<endl;
#define distance(x1,y1,x2,y2)((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))
#define endl "\n"
#define bug cout<<"bugggggggggggg "<<endl;
#define fast ios_base::sync_with_stdio(0);cin.tie(nullptr); ///no printf/scanf

const ll mod = 1000000007;
const ll inf = 1LL<<62;
const ll mx = 100005;
const double eps = 1e-10;

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

ll power(ll a,ll b)
{
    if(b==0)return 1;
    ll x=power(a,b/2);
    x=x*x;
    if(b%2)x=x*a;
    return x;
}

ll Set(ll N,ll pos){return N=N | (1LL<<pos);}
ll reset(ll N,ll pos){return N= N & ~(1LL<<pos);}
bool check(ll N,ll pos){return (bool)(N & (1LL<<pos));}

/**
double cosine_rule(double a,double b,double c)
{
    double res=(a*a+b*b-c*c)/(2*a*b);
    res=acos(res);
    return res;
}
*/
ll arr[25],brr[25];
int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
//    fast; ///no printf/scanf
    ll tst,a,b,c,k,n,m,res=0,ans=0,t=0;
    sl(n);
    for(ll i=1;i<=n;i++)
    {
        sl(arr[i]);
    }
    for(ll i=1;i<=n;i++)
    {
        sl(brr[i]);
    }
    for(ll i=1;i<=n;i++)
    {
        a=arr[i]-brr[i];
        if(a>0)
        {
            res+=a;
        }
    }
    cout<<res<<endl;



    return 0;
}


Measured memory_bytes: 256
sN = (input())

nLen = len(sN)
nN = int(sN)
nAns = 0

for i in range(nLen):
  nChk = i
  nChk &= 1
  if nChk == 1:
    continue
    
  nTmp = 10 **(i)
  if  nLen== 1:
    nAns = nN
    break
  else:
  
    if i==(nLen-1):    
      nAns += nN - nTmp + 1
    else:
      nTmp2 = 10 **(i+1)
      nAns += nTmp2 - nTmp 
    
print(nAns)




Measured memory_bytes: 3060
import sys
input=sys.stdin.readline
t1,t2=map(int,input().split())
a1,a2=map(int,input().split())
b1,b2=map(int,input().split())
if a1*t1+a2*t2==b1*t1+b2*t2:
    print('infinity')
else:
    x=(b1-a1)*t1
    y=(b2-a2)*t2
    if x*y>0:
        print(0)
    else:
        if x<0:
            x=-x
            y=-y
        if x+y>0:
            print(0)
        else:
            z=-(x+y)
            if x%z==0:
                print(2*(x//z))
            else:
                print(1+2*(x//z))


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


int32_t main() {

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

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, m;
	cin >> n >> m;
	vector<int> gr[n + 1];
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		gr[x].push_back(y);
		gr[y].push_back(x);
	}

	// vector<int> dp(n+1,0);
	vector<int> vis(n + 1, 0);
	vector<int> ans(n + 1, -1);
	queue<int> q;
	q.push(1);
	while (!q.empty()) {
		int v = q.front();
		q.pop();
		if (!vis[v]) {
			vis[v] = 1;
			for (int j = 0; j < gr[v].size(); j++) {
				q.push(gr[v][j]);
				if (ans[gr[v][j]] == -1) {
					ans[gr[v][j]] = v;
				}
			}
		}
	}

	for (int i = 2; i <= n; i++) {
		if (ans[i] == -1) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes" << endl;
	for (int i = 2; i <= n; i++) {
		cout << ans[i] << endl;
	}


	return 0;
}

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

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

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

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

#define ll long long
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}


ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};


int main(){
    int N, K, X, Y; cin >> N >> K >> X >> Y;
    if(N <= K){
      cout << N * X << endl;
      return 0;
    }
    N -= K;
    cout << K * X + N * Y << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#include <string>
#include <vector>
#include <math.h>
#include <utility>
#include<set>
#include<tuple>
#define f first
#define sec second
using namespace std;
/*
12
13
*/

ll min(ll a, ll b)
{
    if(a<b)
    return a;
    return b;
}

ll DP(ll arr[], ll n)
{
   ll dp[n];
   memset(dp,0,sizeof(dp));
   dp[1]=abs(arr[1]-arr[0]);
   for(int i=2;i<n;i++)
   {
       dp[i]=min(dp[i-2]+abs(arr[i]-arr[i-2]),dp[i-1]+abs(arr[i-1]-arr[i]));
   }

   return dp[n-1];
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll n=0;
    cin>>n;
    ll arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }

    cout<<DP(arr,n);


}

Measured memory_bytes: 1792
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String args[])
	{
		Scanner input=new Scanner(System.in);
		int n,f=0;
		BigInteger a[]=new BigInteger[100005];
		n=input.nextInt();
		BigInteger b=new BigInteger("1");
		BigInteger c=new BigInteger("1000000000000000000");
		BigInteger d=new BigInteger("0");
		for(int i=1;i<=n;i++){
			a[i]=input.nextBigInteger();
			if(a[i].equals(d)){
				f=2;
				break;
			}
		}
		if(f==2){
			System.out.println("0");
		}
		else{
			for(int i=1;i<=n;i++){
				b=b.multiply(a[i]);
				if(b.compareTo(c)>0){
					f=1;
					break;
				}
			}
			if(f==1){
			System.out.println("-1");
		}
			else{
			System.out.println(b);
		}
		}
		
		
	}


}


Measured memory_bytes: 65296
import java.io.*;

public class Main{
        public static void main(String[] args)throws IOException{
                InputStreamReader isr = new InputStreamReader(System.in);
                BufferedReader br = new BufferedReader(isr);
                String line = br.readLine();
                String inf[] = line.split("/",0);
                if(inf[0].equals("2017")){
                        inf[0] = "2018";
                }   
                System.out.print(inf[0]+"/"+inf[1]+"/"+inf[2]);
                return;
        }   
}


Measured memory_bytes: 22484
import itertools
N,M=map(int,input().split())
ab=list(list(map(int,input().split())) for _ in range(M))
l=list(l for l in range(1,N+1))
numlist=list(itertools.permutations(l))
ans=0
for I in numlist:
    if I[0]==1 and all(sorted([I[j],I[j+1]]) in ab for j in range(N-1)):
        ans+=1
print(ans)

Measured memory_bytes: 8052
#include <cstdio>
#include <algorithm>
#include <set>

int main() {
    int N;
    scanf("%d", &N);

    std::set<int> set;
    int upper=0;
    for (int i=0; i<N; ++i) {
        int a;
        scanf("%d", &a);
        if (a < 3200) {
            set.insert(a/400);
        } else {
            ++upper;
        }
    }

    int lower=set.size();
    int min=std::max(lower, (upper? 1:0));
    int max=lower+upper;

    printf("%d %d\n", min, max);
    return 0;
}



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

using namespace std;

int main() {
	int W,H,C;
	cin >> W>>H>>C;
	
	int a, b, c;
	b = W;
	c = H;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}

	int ans = ((W/b)*(H/b))*C;

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


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

int main(void){
    int M,D,count=0;
    cin >> M >> D;
    for (int i=2;i<D/10;i++){
        for(int j=2;j<10;j++){
            for(int k = 4;k<=M;k++){
                if(k==i*j) count++;
            }
        }
    }
    if(D>20){
    for(int j=2;j<=D%10;j++){
        for(int k=4;k<=M;k++){
            if(k==(D/10)*j) count++;
        }
    }
    }

    cout << count << endl;


    return 0;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.buffer.readline()[:-1]
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

L, R, d = MAP()
print(R//d-(L-1)//d)


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

int x[100000];

int main()
{
	int a, b;
	cin>>a>>b;
	for(int i=0;i<a;i++)
	{
		cin>>x[i];
		if(i && x[i] + x[i-1] >= b)
		{
			cout<<"Possible"<<endl;
			for(int j=0;j<i-1;j++) cout<<j+1<<endl;
			for(int j=a-1;j>=i;j--) cout<<j<<endl;
			return 0;
		}
	}
	cout<<"Impossible"<<endl;
	return 0;
}


Measured memory_bytes: 1152
#include <stdio.h>          // printf(), scanf()

#define MAX_M 1400
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) > (b) ? (a) : (b))

int G[MAX_M][MAX_M];
int dp[MAX_M][MAX_M];
int H, W;

int
getLargestSquare()
{
	int i, j;

	int maxWidth = 0;
	for (i = 0; i < H; ++i)
	{
		for (j = 0; j < W; ++j)
		{
			dp[i][j] = (G[i][j] + 1) % 2;
			maxWidth |= dp[i][j];
		}
	}

	for (i = 1; i < H; ++i)
	{
		for (j = 1; j < W; ++j)
		{
			if (G[i][j])
				dp[i][j] = 0;
			else
			{
				dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
				maxWidth = max(maxWidth, dp[i][j]);
			}
		}
	}

	return maxWidth * maxWidth;
}

int
main(int argc, char** argv)
{
	int i, j;

	scanf("%d %d", &H, &W);
	for (i = 0; i < H; ++i)
	{
		for (j = 0; j < W; ++j)
			scanf("%d", &G[i][j]);
	}

	printf("%d\n", getLargestSquare());
	return 0;
}

Measured memory_bytes: 15912
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

LL dp[3005][3005][2] = {0};
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n;
    cin>>n;
    VL a(n);
    REP(i,n)cin>>a[i];
    LL sum = 0;
    REP(i,n)sum += a[i];

    REP(i,n)dp[i][i][0] = a[i];

    FOR(len, 2, n+1){
        REP(l,n-len+1){
            LL r = l + len - 1;
            LL vl = a[l] + dp[l+1][r][1];
            LL vr = a[r] + dp[l][r-1][1];
            if(vl > vr){
                dp[l][r][0] = vl;
                dp[l][r][1] = dp[l+1][r][0];
            }
            else {
                dp[l][r][0] = vr;
                dp[l][r][1] = dp[l][r-1][0];
            }
        }
    }
    PUTS(dp[0][n-1][0] - dp[0][n-1][1]);
}

Measured memory_bytes: 139776
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
#define inf 0x3f3f3f3f
const ll N = 300030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;

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

ll a,b,k;
cin>>a>>b>>k;
if(k<=a)
cout<<a-k<<" "<<b;
else
cout<<0<<" "<<max(0ll,b+a-k);


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m,lsg,x,sum,ans,dd;
int read(){
	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();
	int k=1,kk=0;if (c=='-')k=-1,c=getchar();
	while (c>='0'&&c<='9')kk=kk*10+c-'0',c=getchar();return k*kk;
}
signed main(){
	n=read();m=read();dd=min(n,m/2);n-=dd,m-=dd*2;ans+=dd;
	cout<<ans+m/4<<endl;
}


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

int main() {
	int n;
	cin>>n;
	int a,b,c,d;
	a=n/1000;
	b=(n-1000*a)/100;
	c=(n-1000*a-100*b)/10;
	d=n%10;
	int i1=-1,i2=-1,i3=-1;
	bool end=false;
	while(i1<2){
		i2=-1;
		while(i2<2){
			i3=-1;
			while(i3<2){
				if(a+b*i1+c*i2+d*i3==7){
					end=true;
					break;
				}
				i3+=2;
			}
			if(end){
				break;
			}
			i2+=2;
		}
		if(end){
			break;
		}
		i1+=2;
	}
	if(end){
		cout<<a;
		if(i1==-1){
			cout<<"-";
		}
		else{
			cout<<"+";
		}
		cout<<b;
		if(i2==-1){
			cout<<"-";
		}
		else{
			cout<<"+";
		}
		cout<<c;
		if(i3==-1){
			cout<<"-";
		}
		else{
			cout<<"+";
		}
		cout<<d<<"=7"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
   int N;
   cin>>N;
   int ans = 0;
   for(int i = 1;i<=N;i++){
       int A;
       cin>>A;
       ans += A;
    }
   if((ans)%2==0){
       cout<<"YES"<<endl;
   }else{
       cout<<"NO"<<endl;
   }
}
      

Measured memory_bytes: 3604
//#include <iostream>
#include <bits/stdc++.h>
#define max_n  100
using namespace std;
typedef long long ll;
const int inf = 0x3f3f3f3f;
int n,a=-1,b=-1,c,t=0;
int main(){
    scanf("%d",&n);
    while(n--){
        a=0,b=0;
        for(int i=0;i<10;i++){
            cin>>c;
            if(c>a){
                a=c;
            }else if(c>b){
                b=c;
            }else{
                t++;
            }
        }
        if(t){
            cout<<"NO"<<endl;
        }else cout<<"YES"<<endl;
    }
    return 0;
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

const int INF = 30010;

int main()
{   
    int N; string s;
    cin >> N >> s;
    int sum = 0;
    for(char i='0'; i<='9'; i++){
        for(char j='0'; j<='9'; j++){
            for(char k='0'; k<='9'; k++){
                int p1 = INF, p2 = INF;
                rep(l,s.size()){
                    if(s[l] == i && p1 == INF){ p1 = l; continue; }
                    if(s[l] == j && p1 < p2 && p2 == INF){ p2 = l; continue; }
                    if(s[l] == k && p2 < INF){
                        // cout << i << j << k << endl;
                        sum++;
                        break;
                    }
                }
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256