akhauriyash/Code-Regression huggingface dataset:
input()
D = {}
for a in [int(a) for a in input().split()]:
    if a not in D: D[a] = 0
    D[a] += 1

input()
for a in [int(a) for a in input().split()]:
    if a not in D: D[a] = 0
    D[a] -= 1

for a in D:
    if D[a] < 0:
        print("NO")
        break
else:
    print("YES")


Measured memory_bytes: 45908
#include<stdio.h>

int main(void){
	long long int n,a,b,ans,rem;
	scanf("%lld %lld %lld",&n,&a,&b);

	ans=n/(a+b)*a;
	rem=n%(a+b);
	if(a>rem)ans+=rem;
	else ans+=a;

	printf("%lld",ans);
	
  return 0;
}



Measured memory_bytes: 128
N, K = map(int, input().split())
lis = []
for i in range(N):
    a, b = map(int, input().split())
    lis.append([a,b])
lis = sorted(lis)
cnt = 0
for x, y in lis:
    if cnt <= K <= cnt + y: 
        print(x)
        break
    else:
        cnt += y

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

//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) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) 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(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const LL INF = 1e9 + 7;
//-------------------------------------------


LL n;
LL b,c;
vector<LL> a(MAX);


//LL dp[100000][100000];
vector<LL> dp(100010, INF);


int main(){

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

    b = 6;
    c = 9;

    cin >> n;
    a[0] = 1;
    a[1] = 6;
    a[2] = 9;


    FOR(i,1,n){
        b = b*6;
        if( b > n) break;
        a.push_back(b);
    }

    FOR(i,1,n){
        c = c*9;
        if( c > n) break;
        a.push_back(c);

    }

    dp[0] = 0;

    for(LL i = 0; i < a.size(); i++){
        for(LL j = a[i]; j <= n; j++){   // 範囲外アクセス c[i] - j >= 0
                dp[j] = min( dp[j], dp[j - a[i]] + 1);
        }
    }

    cout << dp[n] << endl;

    return 0;
}


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

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

    int a, b;
    cin >> a >> b;

    cout << (a+b)%24 << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
int a[110];
int cmp(int a,int b){
	return a>b;
}
int main(){
	int n,m,i,b=0,c;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++)scanf("%d",&a[i]),b+=a[i];
	sort(a+1,a+1+n,cmp);
	c=4*m;
	if(b%c==0)b/=c;
	else b=b/c+1;
	if(a[m]>=b)printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

/*高速化*/
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

/* define */
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V))
#define REV(V) reverse(ALL(V))
#define RSORT(V) SORT(V);REV(V)
#define SZ(x) ((int)(x).size())
#define rep(i,n) for(int i = 0;i < (int)(n);++i)
#define Rep(i,n) for(int i = 1;i <= (int)(n);++i)
#define REP(i,n,m) for(int i = (int)(n);i < (int)(m);++i)
#define Mod(n,m) n % m
#define Mod7(n) Mod(n,7)
#define Mod9(n) Mod(n,9)

/* 最大値と最小値に置き換える */
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;}


/* 型定義 */
typedef vector<long long> vi;
typedef long long ll;
using Graph = vector<vi>;


/* 定数 */
const double PI = 3.141592;
const double e = 2.6;
const long long Inf = 1LL << 60;
const long long mInf = -Inf;

void calc()
{
    int N;
    cin >> N;
    string s;
    cin >> s;
    int res = 0;
    for(int i = 1;i < N;i++)
    {
        int tmpres = 0;
        string front = s.substr(0,i);
        string back = s.substr(i);
        int front_num = SZ(front);
        int back_num = SZ(back);        
        set<char> front_item;
        set<char> back_item;
        rep(i,front_num)
        {
            front_item.insert(front[i]);
        }

        rep(i,back_num)
        {
            auto x = back_item.insert(back[i]);
            auto l = front_item.insert(back[i]);
            if(x.second and not l.second)
            {
                tmpres++;
            }
        }

        chmax(res,tmpres);
    }
    cout << res << '\n';
}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    calc();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n);(i)>=0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;
  int main(){
    lint a,b,c,d,g;
    cin>>a>>b>>c>>d;
    g=c*d/__gcd(c,d);
    lint h=b-(lint)b/c-(lint)b/d+(lint)b/g;
    lint i=(a-1)-(lint)(a-1)/c-(lint)(a-1)/d+(lint)(a-1)/g;
    cout<<h-i;

  }

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int n,k;
	ll ans = 1;
	cin>> n >> k;
	for(int i = 0; i < n; i++){
		if( i == 0 ) ans *= k;
		else ans *= k-1;
	}
	cout<< ans << endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = {0, 1, 0, -1};

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  string S; cin >> S;
  int L = S.size();
  int r, c; cin >> r >> c;
  vector<vector<int>> f_count(2);
  int d = 0, cnt = 0;
  for (auto s : S) {
    if (s == 'F') {
      cnt++;
    } else {
      f_count[d].emplace_back(cnt);
      cnt = 0;
      d ^= 1;
    }
  }
  f_count[d].emplace_back(cnt);

  int geta = 2 * L;
  if (abs(r) > geta or abs(c) > geta) {
    cout << "No" << endl;
    return 0;
  }
  vector<vector<bool>> dp(2, vector<bool>(2 * geta + 1, false));
  dp[0][geta] = dp[1][geta] = true;
  REP(i, 2) {
    REP(k, f_count[i].size()) {
      vector<bool> _dp(2 * geta + 1, false);
      int fc = f_count[i][k];
      for (int j = -geta; j <= geta; j++) {
        if (dp[i][j + geta]) {
          if (i == 0 and k == 0) {
            _dp[j + geta + fc] = true;
          } else {
            _dp[j + geta - fc] = _dp[j + geta + fc] = true;
          }
        }
      }
      dp[i] = _dp;
    }
  }

  cout << (dp[0][r + geta] and dp[1][c + geta] ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    cout << (7 + (s[0] == 'o') + (s[1] == 'o') + (s[2] == 'o')) * 100;
}


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

int main(){
    int n;
    cin >> n;
    if(n % 10 == 3) cout << "bon" << endl;
    else if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8)
        cout << "pon" << endl;
    else cout << "hon" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.20f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

int main() {
	double a, v, b, w, t;
	cin >> a >> v >> b >> w >> t;

	double kyo = abs(a-b);
	double sok = v - w;
	if (v - w < 0) {
		cout << "NO" << endl;
		return 0;
	}
	if (kyo / sok <= t) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 3776
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node {int p,l,r;};

Node T[MAX];
int n,D[MAX];

void print(int u){
  int i,c;
  cout<<"node "<<u<<": ";
  cout<<"parent = "<<T[u].p<<", ";
  cout<<"depth = "<<D[u]<<", ";

  
  if(T[u].p==NIL) cout<<"root, ";
  else if(T[u].l==NIL) cout<<"leaf, ";
  else cout<<"internal node, ";

  cout<<"[";

  for(i=0,c=T[u].l;c!=NIL;i++,c=T[c].r){
    if(i) cout<<", ";
    cout<<c;
  }
  cout<<"]"<<endl;
}

int rec(int u, int p){
  D[u]=p;
  if(T[u].r!=NIL) rec(T[u].r,p);
  if(T[u].l!=NIL) rec(T[u].l,p+1);
}

int main(){
  int i,j,d,v,c,l,r;
  cin>>n;
  for(i=0;i<n;i++) T[i].p=T[i].l=T[i].r=NIL;

  for(i=0;i<n;i++){
    cin>>v>>d;
    for(j=0;j<d;j++){
      cin>>c;
      if(j==0) T[v].l=c;
      else T[l].r=c;
      l=c;
      T[c].p=v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].p==NIL) r=i;
  }

  rec(r,0);

  for(i=0;i<n;i++) print(i);

  return 0;
}



Measured memory_bytes: 7812
// By ksun48

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
 
LL dp[110][11000];
 
#define MOD 1000000007
LL powmod(LL a, LL n){
    if(n == 0) return 1;
    if(n % 2) return (a*powmod(a,n-1)) % MOD;
    LL c = powmod(a, n/2);
    return (c*c) % MOD;
}
LL inv(LL a){
    return powmod(a, MOD-2);
}
 
 
int main(){
    LL n, k;
    cin >> n >> k;
    for(LL N = 0; N <= n; N++){
        for(LL a = 0; a <= k*(n-N); a++){
            dp[N][a] = 0;
            if(N == 0) continue;
            for(LL val = 0; val <= k; val++){
                LL numadd = 0;
                LL newval = val + a;
                if(val <= N){
                    numadd = (val + a) / N;
                    newval = (val + a) % N;
                }
                dp[N][a] += dp[N-1][a + numadd];
                dp[N][a] %= MOD;
                dp[N][a] += newval * powmod(k+1, N-1);
                dp[N][a] %= MOD;
            }
        }
    }
    cout << dp[n][0] << endl;
}

Measured memory_bytes: 8192
# -*- coding: utf-8 -*-
"""
Created on Thu May 14 12:49:47 2020

@author: shinba
"""
import itertools

n = int(input())
a = list(map(int,input().split()))

b = list(itertools.accumulate(a))

ans = float("inf")
for i in range(n-1):
    ans = min(ans,abs(2*b[i]-b[-1]))
    
print(ans)

Measured memory_bytes: 24168
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define Inf 1000000000
#define nmax_def 110000
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;

int main() {
	int K, X;
	cin >> K >> X;
	if (K * 500 >= X)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;


	return 0;
}

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

MOD = 10 ** 9 + 7

dp = [0] * (n+1)
OK = [1] * (n+1)
dp[0] = 1

for i in range(m):
    a = int(input())
    OK[a] = 0

for i in range(1, n+1):
    if OK[i] == 1:
        if i == 1:
            dp[i] = dp[i-1]
        else:
            dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= MOD

print(dp[n])

Measured memory_bytes: 7668
#include<stdio.h>
int main(void)
{
	int n, ans[100000], i, j, a;

	scanf("%d", &n);
	for (i = 1; i <= n; i++)
	{
		scanf("%d", &a);
		ans[a] = i;
	}

	for (i = 1; i <= n; i++) {
		printf("%d ", ans[i]);
	}

}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <stdio.h>
#include <numeric>
#include <algorithm>
using namespace std;
int main(){
    while(true){
        int n,cnt=0;
        cin>>n;
        if(n==0){
            return 0;
        }
        n=1000-n;
        if(n>=500){
            cnt+=n/500;
            n%=500;
        }
        if(n>=100){
            cnt+=n/100;
            n%=100;
        }
        if(n>=50){
            cnt+=n/50;
            n%=50;
        }
        if(n>=10){
            cnt+=n/10;
            n%=10;
        }
        if(n>=5){
            cnt+=n/5;
            n%=5;
        }
        if(n>=1){
            cnt+=n/1;
            n%=1;
        }
        cout<<cnt<<endl;
    }
}


Measured memory_bytes: 3016
import collections

def cin():  return list(map(int,input().split()))

N = cin()[0]
A = cin()

def gcd_(a, b):
    if a < b:  a, b = b, a
    if b == 0:  return a
    return gcd_(b, a % b)

def gcd(l):
    ans = l[0]
    for i in l:  ans = gcd_(ans, i)
    return ans

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

flg = 0

s = [0 for _ in range(10 ** 6 + 5)]
for i in range(N):
    res = collections.Counter(prime_factorize(A[i])) # Counter({2: 4, 3: 1})
    keys = list(res.keys()) # [2, 3]
    length = len(keys)
    
    for i in range(length):
        num = keys[i] # 因数
        if s[num] == 1:
            flg = 1
            break
        s[num] += 1
        
if flg == 0:
    print("pairwise coprime")
else:
    if gcd(A) == 1:  print("setwise coprime")
    else:  print("not coprime")

Measured memory_bytes: 209024
import sys

N, K = list(map(int, input().split()))
P = list(map(int, input().split()))
P = [i for i in P if 1 <= i and i <= 10**3]
Q = [] # 期待値リスト
S = [] # 累積和
T = [] # 隣接するK個の期待値
s=0

if not 1 <= K <= N <= 2*10**5:
    sys.exit()

for i in range(N):
    # q = sum(range(1, P[i]+1)) / P[i]
    q = (1 + P[i]) / 2
    Q.append(q)
    s += q
    S.append(s)
    if i == K-1:
        T.append(S[i])
    if i > K-1:
        T.append(S[i]-S[i-K])
print(max(T))

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

int main(){

  long long A,B,C,D,E,ans=0,tmpC,tmpD;
  cin >> A >> B >> C >> D;
  tmpC = C;
  tmpD = D;

  E = D % C;
  while(E!=0){
    D = C;
    C = E;
    E = D % C;
  }
  E = tmpC*tmpD/C;

  ans = (B-A+1) - (B/tmpC) - (B/tmpD) + (B/E) + ((A-1)/tmpC) + ((A-1)/tmpD) - ((A-1)/E);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define int ll
typedef pair<int, int> pii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
constexpr int INF = 1e9;
constexpr int MOD = 1e9+7;

signed main() {
    ios::sync_with_stdio(false);cin.tie(0);
    int X;
    cin >> X;
    if (X == 3 || X == 5 || X == 7) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll)(a.size())
#define pll pair<ll,ll>
set<ll>::iterator it;
ll m = 1000000007;
ll power(ll a,ll b)
{
	ll p = 1;
	a = a%m;
	while(b>0)
	{
		if(b%2==1)
			p=((p%m)*(a%m))%m;
		b=b>>1;
		a=((a%m)*(a%m))%m;
	}
	return p;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll i,j,k,n, a, b;
	cin>>a>>b>>k;
	if(k<=a)
		cout<<a-k<<" "<<b<<endl;
	else if(k-a<=b)
		cout<<0<<" "<<a+b-k<<endl;
	else
		cout<<0<<" "<<0<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <functional>
 
using namespace std;
 
int main(void) {
    unsigned long int s[5], c[5], N = 0, M = 0, count = 0;
    bool isZeroIn = false;
    cin >> N >> M;

    for(int i = 0 ; i < M ; i++){
        cin >> s[i] >> c[i];
        s[i]--;
    }
    unsigned long int out[N];
    for(int i = 0 ; i < N ; i++){
        out[i] = 0;
    }
    for(int i = 0 ; i < M ; i++){
        if(N > 1){
            if((out[s[i]] == 0 || out[s[i]] == c[i]) && (s[i] != 0 || c[i] != 0)){
                out[s[i]] = c[i];
            }else{
                cout << -1 << endl;
                return 0;
            }
        }else if(!isZeroIn){
            out[0] = c[i];
            isZeroIn = true;
        }else if(out[0] != c[i]){
            cout << -1 << endl;
            return 0;
        }
    }
    if(out[0] == 0 && N != 1){
        out[0] = 1;
    }
    for(int i = 0; i < N ; i++){
        cout << out[i];   
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    for (int i = 0; i < s.size(); i++) {
        if ((i % 2 == 0 && s[i] == 'L') || (i % 2 == 1 && s[i] == 'R')) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 256
a=input().split(" ")
sum1=int(a[0])+int(a[1])
sum2=int(a[0])+int(a[2])
sum3=int(a[1])+int(a[2])

if sum1==int(a[2]) or sum2==int(a[1]) or sum3==int(a[0]):
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3060
//AnkitCode99
#include<bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define all(v) (v.begin(),v.end())
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(long long int i=a;i<b;i++)
#define nrep(i,a,b) for(long long int i=a;i>=b;i--)
using namespace std;
bool isprime(ll n)
{
	rep(i,2,(ll)sqrt(n)+1)
	{
		if(n%i==0)
			return false;
	}
	return true;
}
int main()
{
	fast;
 //   #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	ll n;
	cin>>n;
	while(!isprime(n))
	{
		n++;
	}
	cout<<n<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
void fast() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
}
// #define endl '\n'
// #define double long double
// #define int long long
// int MOD = 1000 * 1000 * 1000 + 7;
// int MOD = 998244353;

void solve() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int sum = 0;
	for(int x=0 ;x<k; x++){
		if(a > 0){
			sum++;
			a--;
		}
		else if (b>0){
			b--;
		}
		else{
			sum--;
			c--;
		}
	}
	cout << sum;
    
}

signed main() {
    
    fast();
    int t = 1;
    while (t--) {
        solve();
    }
    
    
}


Measured memory_bytes: 3640
import std.algorithm;
import std.range;
import std.stdio;
import std.math;
import std.array;
import std.string;
import std.conv;

/// 数列の読み込み
auto readNums(T = int)() {
	return readln().chomp.split.map!(to!T).array;
}

/// 数の読み込み
auto readNum(T = int)() {
	return readNums!T.front;
}

/// 指定行数読み込み
auto readRows(size_t rows) {
	return generate(() => readln().chomp).take(rows).array;
}

void main() {
	const nums = readNums!ulong();
	immutable a = nums[0];
	immutable b = nums[1];
	immutable x = nums[2];
	immutable n = (b / x) - (a / x);
	
	writefln("%s", a % x == 0 ? n + 1 : n);
}

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

using namespace std;

namespace {

	int cnt;
	void InsertionSort(vector<int>& A, int n, int g)
	{
		for (int i = g; i < n; ++i)
		{
			int v = A[i];
			int j = i - g;

			while (j >= 0 && A[j] > v) {
				A[j + g] = A[j];
				j -= g;
				cnt++;
			}

			A[j + g] = v;
		}
	}

	void ShellSort(vector<int>& A, int n)
	{
		int m;
		cnt = 0;
		vector<int> G;
		G.push_back(1);
		for (int i = 1; i <= n; ++i)
		{
			int g = pow(4, i) + 3 * pow(2, i - 1) + 1;
			if (g <= n) G.push_back(g);
			else { m = i; break; }
		}

		for (int i = m - 1; i >= 0; --i)
			InsertionSort(A, n, G[i]);

		cout << m << endl;
		for (int i = m - 1; i >= 0; --i) {
			cout << G[i];
			i != 0 ? cout << " " : cout << endl;
		}
		cout << cnt << endl;
		for (int i = 0; i < n; ++i)
			cout << A[i] << endl;
	}
}

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

	int n;
	cin >> n;

	vector<int> A(n, 0);
	for (int i = 0; i < n; ++i)
		cin >> A[i];

	ShellSort(A, n);

	return 0;
}

Measured memory_bytes: 5160
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //b
  string s, t;
  cin >> s >> t;
  int n = s.size();
  int m = t.size();
  int ans = 1 << 30;
  for (int i = 0; i <= n - m; i++) {
    int cur = 0;
    for (int j = 0; j < m; j++) {
      cur += (s[i + j] != t[j]);
    }
    ans = min(ans, cur);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
import sys
input=sys.stdin.readline
n=int(input())
a0,b0,c0=0,0,0
for i in range(n):
    a,b,c=map(int,input().split())
    a1,b1,c1=a0,b0,c0
    a0=a+(b1 if b1>c1 else c1)
    b0=b+(a1 if a1>c1 else c1)
    c0=c+(b1 if b1>a1 else a1)
print(max(a0,b0,c0))

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

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

int main()
{
    int h, w;
    cin >> h >> w;
    char s[h][w];
    rep(i, h) rep(j, w) cin >> s[i][j];

    int ans = 0;

    vector<pii> ind;
    rep(i, h) rep(j, w) ind.push_back(pii(i, j));

    rep(i, ind.size())
    {
        rep(j, ind.size())
        {
            int sx = ind[i].first, sy = ind[i].second;
            int gx = ind[j].first, gy = ind[j].second;
            if (s[sx][sy] == '#' || s[gx][gy] == '#')
                continue;

            int d[h][w];
            rep(i, h) rep(j, w) d[i][j] = 0;

            queue<pii> q;
            q.push(pii(sx, sy));
            bool flag = 0;

            while (!q.empty())
            {

                pii u = q.front();
                q.pop();
                if (u.first == gx && u.second == gy)
                {
                    flag = 1;
                    break;
                }
                rep(k, 4)
                {
                    int x = u.first + dx[k], y = u.second + dy[k];
                    if (!((0 <= x && x < h) && (0 <= y && y < w)))
                        continue;
                    if (s[x][y] == '#' || d[x][y] > 0)
                        continue;
                    d[x][y] = d[u.first][u.second] + 1;
                    q.push(pii(x, y));
                }
            }
            if (flag == 1)
                ans = max(ans, d[gx][gy]);
        }
    }

    OP(ans);

    return 0;
}

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    string S,T; cin>>S>>T;
    int s = S.size(), t = T.size();
    int res = s;
    for(int i = 0; i <= s - t; i++){
        int tmp = 0;
        for(int j = 0; j < t; j++){
            if(T[j]!=S[i+j])tmp++;
        }
        res = min(res,tmp);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 3592
#include <iostream>
#include <cmath>
#include <iomanip>
class Point{
  public:
    Point(){x=0,y=0;}
    Point(double x,double y){this->x=x,this->y=y;}
    double getX(){return x;}
    double getY(){return y;}
  private:
    double x,y;
};
int main(int argc, char const *argv[]) {
  double x1,x2,y1,y2;
  std::cin >> x1 >> y1 >> x2 >> y2;
  Point(x1,y1);
  Point(x2,y2);
  double horizon,vertical,distance;
  horizon = (x2-x1);
  if(horizon < 0)horizon*=(-1);
  vertical = (y2-y1);
  if(vertical < 0)vertical*=(-1);

  distance = sqrt(horizon*horizon+vertical*vertical);
  std::cout << std::fixed << std::setprecision(8) <<distance << std::endl;
  return 0;
}

Measured memory_bytes: 3264
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>
#include <iomanip>
#include <iterator>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
 
#define FOR(i,n) for(int i = 0; i < (n); i++)

typedef unsigned long long ull;

int main(){
	string s[8]; FOR(i,8) cin>>s[i];
	cout << 90 << endl;
	FOR(i,8){ FOR(j,8) putchar(s[7-j][i]); putchar('\n'); }  
	cout << 180 << endl;
	FOR(i,8){ FOR(j,8) putchar(s[7-i][7-j]); putchar('\n'); }  
	cout << 270 << endl;
	FOR(i,8){ FOR(j,8) putchar(s[j][7-i]); putchar('\n'); }  

	return 0;
}

Measured memory_bytes: 1188
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	int n;
	while(cin>>n,n){
		int mi=inf;
		rep(i,110)rep(j,1010)mi=min(mi,(n<i*i*i+j*j?inf:i+j+n-i*i*i-j*j));
		cout<<mi<<endl;
	}
}

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

long long binpow(long long a, long long b, long long k) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2, k);
    if (b % 2)
        return ((res%k) * (res%k) * (a%k))%k;
    else
        return ((res)%k * (res)%k)%k;
}



int main(){
    
    int k;
    cin >> k;
    
    long long result = 0;
    bool found = false;
    for(int j = 0; j < 1000000; j++){
        long long current_result = 7 * binpow(10, j, k);
        current_result = current_result;
        
        result += current_result;
        if(result%k == 0){
            cout << j + 1 << endl;
            found = true;
            break;
        }
    }
    
    if(!found)cout << -1 << endl;
    
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a, b, c;
    int count5 = 0;
    int count7 = 0;


    cin >> a >> b >> c;
    
    if (a == 5) {
        count5++;
    }
    else if (a == 7) {
        count7++;
    }
    
    if (b == 5) {
        count5++;
    }
    else if (b == 7) {
        count7++;
    }

    if (c == 5) {
        count5++;
    }
    else if (c == 7) {
        count7++;
    }

    if (count5 == 2 && count7 == 1) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }

}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int x, a;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> x >> a;
	if(x < a) cout << "0\n";
	else cout << "10\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a;
    string s;
    cin>>a;
    cin>>s;
    long long b=0;
    int cnt=s.length()-2;
    for(int i=0;i<s.length();i++){
        if(s[i]=='.')continue;
        b+=(long long)(pow(10,cnt)+0.5)*(s[i]-48);
        cnt--;
    }
    long long ans=(long long)a*b;
    ans/=100;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
#define MAX 100010
#define inf 1<<29
#define linf 1e18
#define eps (1e-10)
#define mod 1000000007
#define pi M_PI
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int n;
ll s,a[MAX];

int main()
{
  cin>>n>>s;
  FOR(i,0,n)cin>>a[i];
  ll sum=0;
  int j=0,ans=inf;
  FOR(i,0,n){
    sum+=a[i];
    while(s<=sum-a[j]){
      sum-=a[j];
      j++;
    }
    if(s<=sum)ans=min(ans,i-j+1);
  }
  if(ans==inf)cout<<0<<endl;
  else cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3872
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)

signed main() {
    int N, A, B;
    cin >> N >> A >> B;
    cout << max(0LL, A + (N - 1) * B - (A * (N - 1) + B - 1)) << endl;
}




Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#define N 1000
using namespace std;
int n,m;
int a[N][N];
int main(){
	scanf("%d %d",&n,&m);
	int t;
	scanf("%d",&t);
	int x=1,y=1;
	for (int i=1;i<=t;i++){
		int z;
		scanf("%d",&z);
		while (z--){
			a[x][y]=i;
			if (x&1)y++;
			else
				y--;
			if (y>m)y=m,x++;
			else
				if (!y)y=1,x++;
		}
	}
	for (int i=1;i<=n;i++){
		for (int j=1;j<m;j++)
			printf("%d ",a[i][j]);
		printf("%d",a[i][m]);
		if (i!=n)printf("\n");
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007


string a, b;
char x[4] = { 'b','d','p','q' }, y[4] = { 'd','b','q','p' };
int main() {
	cin >> a;
	b = a;
	reverse(ALL(b));
	REP(i, b.size()) {
		REP(j, 4) {
			if (b[i] == x[j]) {
				b[i] = y[j];
				break;
			}
		}
	}
	cout << (a == b ? "Yes" : "No") << endl;
}

Measured memory_bytes: 512
fun main(args: Array<String>) {
    readLine()?.let {
        val r = it.last().toString().toInt()
        when (r) {
            2, 4, 5, 7, 9 -> {
                println("hon")
            }
            3 -> {
                println("bon")
            }
            else -> {
                println("pon")
            }
        }
    }
}

Measured memory_bytes: 35672
#include<iostream>
#include<string>


void max(int &,int &,int &);
void swap(int &,int &);
//std::string triangle(int&,int &,int &);

int main(){

  int N;

  std::cin >> N;

  for(int i=0;i<N;i++){
      int a,b,c,d,e;
      std::cin >> a >> b >> c;
      max(a,b,c);
     // std::string y;
        
      d = b*b;
      e = a*a;

     if(c*c ==d+e) std::cout << "YES" << std::endl;
     else std::cout << "NO" << std::endl;


  }
 return 0;
}

void max(int &a,int &b,int &c){
  if(a>b){
       swap(a,b);
  }
  if(b>c){
       swap(b,c);
  }
  if(a<b){
       swap(a,b);
  }

  //std::cout << a << b << c;
}

void swap(int& i, int& j){
  int k;
  k = i;
  i = j;
  j = k;
}

//std::string triangle(int &c,int &d,int &e){
//    std::string y;
//   if(c*c == d+e)
//        y= "YES";
//   else y="NO";
//}

Measured memory_bytes: 3036
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <functional>
#define SIZE 25
#define BT 1<<20
#define MOD 1000000007
#define MX 205

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

ll dp[BT],way[BT];
ll fac[MX][MX];
ll C[MX][MX];
vector <P> vec[SIZE];
int cnt[BT],cnt2[BT];
int memo[SIZE][BT];

void make()
{
	for(int i=0;i<MX;i++)
	{
		C[i][0]=C[i][i]=1;
		for(int j=1;j<i;j++)
		{
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;
		}
	}
	for(int i=1;i<MX;i++)
	{
		fac[i][i-1]=1;
		for(int j=i;j<MX;j++) fac[i][j]=fac[i][j-1]*(ll) j%MOD;
	}
}
int dfs(int v,int p,int goal)
{
	if(v==goal) return 0;
	for(int i=0;i<vec[v].size();i++)
	{
		int to=vec[v][i].first;
		if(to!=p)
		{
			int ret=dfs(to,v,goal);
			if(ret!=-1) return ret|(1<<vec[v][i].second);
		}
	}
	return -1;
}
int main()
{
	make();
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);a--,b--;
		vec[a].push_back(P(b,i));
		vec[b].push_back(P(a,i));
	}
	for(int i=n-1;i<m;i++)
	{
		int a,b;
		scanf("%d %d",&a,&b);a--,b--;
		int S=dfs(a,-1,b);
		cnt[S]++;
	}
	int sz=n-1;
	for(int i=0;i<sz;i++)
	{
		for(int S=0;S<1<<sz;S++) memo[i][S]=cnt[S];
		for(int j=0;j<sz;j++)
		{
			if(j==i) continue;
			for(int S=0;S<1<<sz;S++) if(S>>j&1) memo[i][S]+=memo[i][S-(1<<j)];
		}
	}
	memset(dp,0,sizeof(dp));
	memset(way,0,sizeof(way));
	way[(1<<sz)-1]=1;
	for(int S=(1<<sz)-1;S>=0;S--)
	{
		int nm=0;
		for(int i=0;i<sz;i++) if(!(S>>i&1)) nm++;
		for(int i=0;i<sz;i++)
		{
			if(S>>i&1)
			{
				//printf("%d %d : %d\n",i,S,memo[i][S]);
				ll w=way[S],d=dp[S],c=cnt2[S];
				w=w*fac[c+1][c+memo[i][S]]%MOD;
				d=d*fac[c+2][c+memo[i][S]+1]%MOD;/*
				for(int j=0;j<memo[i][S];j++)
				{
					ll c2=c+1;
					ll w2=w*(c+1)%MOD;
					ll d2=d*(c+2)%MOD;
					c=c2,w=w2,d=d2%MOD;
				}*/
				int T=S-(1<<i);
				cnt2[T]=cnt2[S]+memo[i][S]+1;
				dp[T]+=(d+w*(ll) (nm+1))%MOD;
				if(dp[T]>=MOD) dp[T]-=MOD;
				way[T]+=w;
				if(way[T]>=MOD) way[T]-=MOD;
			}
		}
		//printf("%d : %lld %lld\n",S,way[S],dp[S]);
	}
	printf("%lld\n",dp[0]);
	return 0;
}


Measured memory_bytes: 103296
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
vector<pair<ll,ll>> V;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    int W,H,x;
    cin >> W >> H;
    rep(i,W)cin >> x,V.push_back({x,0});
    rep(i,H)cin >> x,V.push_back({x,1});
    sort(ALL(V));
    ll ans = 0;
    W++;
    H++;
    for(auto r:V){
        if(r.second==1)ans += W*r.first,H--;
        else ans += H*r.first,W--;
    }
    cout << ans << endl;
}

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

int main()
{
  int N, i, key, j, k = 0, minj;
  int *data;

  scanf("%d", &N);
  data = (int *)malloc(N * sizeof(int));
  for(i = 0; i < N; i++) scanf("%d", &data[i]);
  for(i = 0; i < N; i++){
    minj = i;
    for(j = i; j < N; j++){
      if(data[j] < data[minj]){
	minj = j;
      }
    }
     key = data[minj];
    data[minj] = data[i];
    data[i] = key;
    if(data[i] != data[minj]) k++; 
  }
  for(i = 0; i < N - 1; i++) printf("%d ", data[i]);
  printf("%d\n", data[i]);
  printf("%d\n", k);

  free(data);
  
  return 0;
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
// typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

const double EPS = 1e-10;

struct P {
    double x, y, z;
    P(){}
    P(double _x, double _y, double _z) : x(_x), y(_y), z(_z) {}
    const P operator+ (const P& p) {
        return P(this->x + p.x, this->y + p.y , this->z + p.z);
    }
    const P operator- (const P &p) {
        return P(this->x - p.x, this->y - p.y , this->z - p.z);
    }
    void print() {
        printf("%.1f %.1f %.1f\n", x, y, z);
    }
};

double dot(const P& p, const P& q) {
    return p.x * q.x + p.y * q.y + p.z * q.z;
}

P cross(P p, P q) {
    return P(p.y * q.z - p.z * q.y, p.z * q.x - p.x * q.z, p.x * q.y - p.y * q.x);
}

struct C {
    P c;
    double r;
    C(){}
    C(P _c, double _r) : c(_c), r(_r) {}
};

struct L {
    P a, b, v;
    L(){}
    L(P _a, P _b) : a(_a), b(_b), v(b - a) {}
};

double distance(P p) {
    return sqrt(p.x * p.x + p.y * p.y + p.z * p.z);
}

double distanceLP(L l, P p) {
    return distance(cross(l.v, p - l.a)) / distance(l.v);
}

double distanceSP(L l, P p) {
    if (dot(l.b - l.a, p - l.a) < 0) return distance(p - l.a);
    if (dot(l.a - l.b, p - l.b) < 0) return distance(p - l.b);
    return distanceLP(l, p);
}

bool intersectSC(L s, C c) {
    return distanceSP(s, c.c) < c.r + EPS;
}

C readC() {
    double x, y, z, r;
    cin >> x >> y >> z >> r;
    return C(P(x, y, z), r);
}

L readL() {
    double x1, y1, z1, x2, y2, z2;
    cin >> x1 >> y1 >> z1 >> x2 >> y2 >> z2;
    return L(P(x1, y1, z1), P(x2, y2, z2));
}

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

    int N, Q;
    cin >> N >> Q;

    vector<C> circles(N);
    V l(N);
    rep(i, N) {
        circles[i] = readC();
        cin >> l[i];
    }

    while (Q--) {
        L s = readL();
        int ans = 0;
        rep(i, N) {
            if (intersectSC(s, circles[i])) {
                ans += l[i];
            }
        }
        cout << ans << endl;
    }

}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	int res1 = 10 * a + b + c;
	int res2 = 10 * b + a + c;
	int res3 = 10 * c + b + a;
	cout << max({ res1,res2,res3 }) << endl;
	return 0;
}

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


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

  if(n%2 == 0)
    cout << n/2 << endl;
  else
    cout << n/2 +1 << endl;
  return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

//inline int read(){int t = 0;int neg=1;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1;continue;}t=t*10+c-48;}return neg*t;}
//inline int readl(){long long t = 0;long long neg=1ll;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1ll;continue;}t=t*10+c-48;}return neg*t;}

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<pi> vpi;
typedef vector<plli> vplli;
const lli M=1000000007ll;

int main(){
	fast_io 
	int a,b,h,ans;
	cin>>a>>b>>h;
	ans=(2*a*h +(b-a)*h)/2;
	cout<<ans<<'\n';
	
	return 0;
}

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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    ll x;
    cin >> x;
    ll out = 1;
    while(out*(out+1) < x*2){
        out += 1;
    }
    cout << out << endl;
    return 0;
}

Measured memory_bytes: 256
(N, S), As = readlines.map{|l| l.split.map(&:to_i)}
M = 998244353

dp = Array.new(3001, 0)
ans = 0
As.each.with_index(1) do |a, i|
  (S - a).downto(1){|b| dp[a + b] = (dp[a + b] + dp[b])%M}
  dp[a] = (dp[a] + i)%M
  ans = (ans + dp[S])%M
end
puts ans

Measured memory_bytes: 1916
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>
#include<unordered_map>
#include<queue>

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; }

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int gcd(int a, int b){return b ? gcd(b, a%b) : a;}
int lcm(int a, int b){return a*b / gcd(a, b);}



int main(){
    int a; cin >> a;
    cout << a+a*a+a*a*a << endl;
    return 0;
}


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

int main() {
	int A, B, C;
	int stock;
	int ans = 0;
	cin >> A >> B >> C;
	if (A + B >= C) {
		ans = B + C;
	}
	else {
		stock = A + B + 1;
		ans += stock + B;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;



int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ///freopen("input.in", "r", stdin);
    ///freopen("output.out", "w", stdout);
    cout.precision(20);
    ll n;
    cin >> n;
    vector <ld> p(n + 1);
    for (ll i = 1; i <= n; ++i)
        cin >> p[i];
    vector <vector <ld>> dp(2, vector <ld>(n + 1, 0));
    dp[0][0] = 1;
    for (ll i = 1; i <= n; ++i)
        for (ll j = 0; j <= i; ++j)
                dp[i & 1][j] = (j ? dp[(i - 1) & 1][j - 1] : 0) * p[i] + dp[(i - 1) & 1][j] * (1.0 - p[i]);
    ld ans = 0;
    for (ll j = n / 2 + 1; j <= n; ++j)
        ans += dp[n & 1][j];
    cout << ans << endl;
    return 0;
}

/**


**/


Measured memory_bytes: 512
#include <iostream>
#include <unordered_set>
#include <unordered_map>

using namespace std;

// https://atcoder.jp/contests/abc075/tasks/abc075_c

bool closedGraph(const unordered_map<int, unordered_set<int>>& nodes, unordered_set<int>* visit, int startNode, int currentNode, int prevNode) {
  if (visit->find(currentNode) != visit->end()) {
    return currentNode == startNode;
  }
  visit->insert(currentNode);

  bool res = false;
  const auto iter = nodes.find(currentNode);
  for (const auto& node : iter->second) {
    if (node == prevNode) {
      continue;
    }
    res |= closedGraph(nodes, visit, startNode, node, currentNode);
  }
  return res;
}

int main() {
  int n, m;
  cin >> n >> m;
  unordered_map<int, unordered_set<int>> nodes;
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    nodes[a].insert(b);
    nodes[b].insert(a);
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    unordered_set<int> visit;
    if (!closedGraph(nodes, &visit, i, i, -1)) ++ans;
  }
  if (ans == n) --ans;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    cout << fixed << setprecision(10);
    int n,k;
    cin >> n >> k;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    int ans = 0;
    sort(v.begin(),v.end());
    rep(i,k) ans += v[i];
    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; 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; }
const ll MOD = 1e9+7;
    
ull A, B, C, D;

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

ull solve(ull X){
    if(X <= 0) return 0;
    ull c = X/C;
    ull d = X/D;

    ull g = gcd(C, D);
    ull gg = g * C/g * D/g;
    ull cd = X/gg;

    ull ret = c + d - cd;
    ret = X - ret;
    
    return ret;
}

int main(){
    cin >> A >> B >> C >> D;

    ull x = solve(B);
    ull y = solve(A-1);

    //cout << x << endl;
    //cout << y << endl;

    ull ans = x - y;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import Counter

n = int(input())
blue_ls = [input() for _ in range(n)]
m = int(input())
red_ls = [input() for _ in range(m)]

blue_counter = Counter(blue_ls)
red_counter = Counter(red_ls)
diff_counter = blue_counter - red_counter

if diff_counter:
    print(diff_counter.most_common(1)[0][1])
else:
    print("0")


Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int n;

int recur(int num, int dep) {
	int ret = 0;

	if (dep == 0) {
		if (num == 0) return 1;
		else return 0;
	}
	for (int i = 0; i < 10 && i <= num; i++) {
		ret += recur(num - i, dep - 1);
	}

	return ret;
}

int main() {
	n = -1;
	cin >> n;

	while (n != -1) {
		cout << recur(n, 4) << endl;
		
		n = -1;
		cin >> n;
	}

	return 0;
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@                       @*/
/*@ debug output erased ? @*/
/*@                       @*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/

Measured memory_bytes: 1160
n = int(input())
if n <= 599:
    print('8')
elif n <= 799:
    print('7')
elif n <= 999:
    print('6')
elif n <= 1199:
    print('5')
elif n <= 1399:
    print('4')
elif n <= 1599:
    print('3')
elif n <= 1799:
    print('2')
else:
    print('1')

Measured memory_bytes: 9180
/**
 *    author:  tourist
 *    created: 16.01.2020 23:13:10       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  sort(a.rbegin(), a.rend());
  int sum = 0;
  for (int i = 0; i < k; i++) {
    sum += a[i];
  }
  cout << sum << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
/* map_for : mapでfor文を回す */
/* gcd_lcm : 最大公倍数 & 最小公約数 */
int main()
{
    cout << fixed << setprecision(10);//小数点以下10桁出力
    string s;
    cin >> s;
    string h;

    h += s;//copy

    reverse(h.begin(),h.end());
    int ans = 0;
    rep(i,s.size()){
        if(s.at(i) != h.at(i)){
            ans++;
        }
    }
    cout << ans / 2<< endl;
    return 0;
}

Measured memory_bytes: 256