akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int a[110];
int n,k;
int mem[110000][2];

int dp( int rem,int turn){
    if(rem == 0) return turn == 1;
    if(rem < 0) return -1;
    if(rem < a[0]) return turn == 1;;

    if(mem[rem][turn] != -1) return mem[rem][turn];
    int ret1=0, ret2 = 1;

    if(turn == 0){

        for(int i=0;i<n;i++){
                int z = dp(rem - a[i],1);
        if(z != -1)
            ret1 = ret1 || z;

        }

    }

    if(turn == 1){

    ret1 = 1;
        for(int i=0;i<n;i++){
                int z = dp(rem - a[i],0);
            if(z == 0){
                ret1 = 0;
            }
            }
        }



    return mem[rem][turn] = ret1;

}
int main()
{
    memset(mem,-1, sizeof(mem));
    cin>>n>>k;
    for(int i=0; i<n; i++) cin>>a[i];
    sort(a,a+n);
    int res = dp(k,0);

    if(res == 0) cout<<"Second";
    else cout<<"First";

}


Measured memory_bytes: 7296
n=int(input())
l=list(map(int,input().split()))
la=list(map(int,input().split()))

ans=0
for m,i in enumerate(la):
  ans+=min(i,l[m])+l[m+1]-max(0,l[m+1]-i+min(i,l[m]))
  l[m+1]=max(0,l[m+1]-i+min(i,l[m]))
print(ans)


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

#define pb push_back
#define mp make_pair

int main (){

    int n;
    cin >>n;
    vector<int> a;
    for (int i=0;i<n;i++){
        int b;
        cin >>b;
        a.pb(b);
    }

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

    for (int i=0;i<n;i++){
        cout <<sol[i]<<' ';
    }

    return 0;
}


Measured memory_bytes: 1656
#include<stdio.h>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<assert.h>
#include<set>
#include<cmath>
#include<queue>
#include<cstdlib>
#include<iostream>
#include<bitset>
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back
#define rep(i,j,k) for(int i=(int)(j);i<=(int)(k);i++)
#define per(i,j,k) for(int i=(int)(j);i>=(int)(k);i--)
using namespace std;
typedef long long LL;
//template
typedef double db;
const db eps=1e-10;
const db pi=acosl(-1.0);
int sign(db x){if(x<-eps)return -1;if(x>eps)return 1;return 0;}
int cmp(db x,db y){return sign(x-y);}
bool inmid(db x,db l,db r){return cmp(x,l)*cmp(x,r)<=0;}
struct po{
	db x,y;
	po(db _x=0,db _y=0):x(_x),y(_y){}
	void read(){scanf("%lf%lf",&x,&y);}
};
po operator +(const po &a,const po &b){return po(a.x+b.x,a.y+b.y);}
po operator -(const po &a,const po &b){return po(a.x-b.x,a.y-b.y);}
po operator *(const po &a,const db &b){return po(a.x*b,a.y*b);}
po operator /(const po &a,const db &b){return po(a.x/b,a.y/b);}
db operator *(const po &a,const po &b){return a.x*b.x+a.y*b.y;}
db operator ^(const po &a,const po &b){return a.x*b.y-a.y*b.x;}
db mo2(po a){return a*a;}
db mo(po a){return sqrt(a*a);}
po proj(po x,po y){//proj x to y
	return y*((x*y)/mo2(y));
}
po refl(po x,po y){//refl x from y
	return proj(x,y)*2-x;
}
bool onseg(po x,po l,po r){
	return (sign((x-l)^(r-l))==0)&&inmid(x.x,l.x,r.x)&&inmid(x.y,l.y,r.y);
}
bool inter(db l1,db r1,db l2,db r2){
	if(cmp(l1,r1)==1)swap(l1,r1);
	if(cmp(l2,r2)==1)swap(l2,r2);
	return cmp(min(r1,r2),max(l1,l2))>=0;
}
bool checkss(po a,po b,po c,po d){
	return sign((b-a)^(c-a))*sign((b-a)^(d-a))<=0&&sign((d-c)^(a-c))*sign((d-c)^(b-c))<=0&&inter(a.x,b.x,c.x,d.x)&&inter(a.y,b.y,c.y,d.y);
}
po getll(po a,po b,po c,po d){
	db u=((b-a)^(c-a));
	db v=((d-a)^(b-a));
	return (c*v+d*u)/(u+v);
}
db dispp(po x,po y){return sqrt((x-y)*(x-y));}
db disps(po x,po l,po r){
	po y=proj(x-l,r-l)+l;
	if(onseg(y,l,r))return dispp(x,y);
	else return min(dispp(x,l),dispp(x,r));
}
db disss(po x,po y,po l,po r){
	if(checkss(x,y,l,r))return 0;
	return min(min(disps(x,l,r),disps(y,l,r)),min(disps(l,x,y),disps(r,x,y)));
}
//template
int main(){
	int t;scanf("%d",&t);
	while(t--){
		po a,b,c,d;
		a.read();b.read();c.read();d.read();
		printf("%.10lf\n",disss(a,b,c,d));
	}
	return 0;
}






Measured memory_bytes: 3236
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=998244353;
const int INF=1e9;
const double PI=acos(-1);


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

    int n,k;
    cin >> n >> k;
    int x=1;
    rep(i,n) x=(2*x<x+k)?2*x:x+k;
    cout << x << endl;

    return 0; 
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {
  long long int a,b,c[200100],d[210000],e,f,g[110],h[110];
  cin >>a;
  e=1,f =0,c[0]=0;
  for(int i=1;i<=a;i++){
    cin >> c[i];
  c[i] += c[i-1];
  }
    
  sort(c,c+a+1);
  for(int i=0;i<a;i++){
    
  if(c[i] == c[i+1]) e++;
    else {
      f += e*(e-1) / 2;
      e = 1;
    }
  }
  f += e*(e-1)/2;
  cout << f << endl;
  
 
}
 
 


Measured memory_bytes: 1792
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int n = Integer.parseInt(scan.next());
        int x = Integer.parseInt(scan.next());
        int y = Integer.parseInt(scan.next());

        scan.close();

        int[] k = new int[n];

        for (int i = 1; i <= n; i++) {
            for (int j = i + 1; j <= n; j++) {
                int direct = j - i;

                // 順に進んでワープ
                int warp;
                if (x < i || j < x) {
                    // ワープせずにたどり着くので考えない
                    warp = n;
                } else if (y <= j) {
                    // jがワープ先よりも後
                    warp = (x - i) + 1 + (j - y);
                } else {
                    // jがワープ先よりも前
                    warp = (x - i) + 1 + (y - j);
                }

                // 戻ってワープ
                int reverseWarp;
                if (i < x) {
                    // ワープできない
                    reverseWarp = n;
                } else if (y <= j) {
                    // jがワープ先よりも後
                    reverseWarp = (i - x) + 1 + (j - y);
                } else {
                    // jがワープ先よりも前
                    reverseWarp = (i - x) + 1 + (y - j);
                }

                int min = Math.min(Math.min(direct, warp), reverseWarp);
                k[min]++;
            }
        }

        for (int i = 1; i < n; i++) {
            System.out.println(k[i]);
        }
    }

}


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

using namespace std;

typedef long long llint;

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

  for (int i = 0; i < s.size(); i++) {
    if (i + 1 < s.size() && s[i] == 'h' && s[i + 1] == 'i') {
      i++;
    } else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

  return 0;
}

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

int main() {
  int n,a,b;
  cin >> n >> a >> b;
  cout << min(n*a,b) << endl;
  return 0;
}

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

using namespace std;

#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7

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

int main() {
	int L, A, B, C, D;
	scanf("%d %d %d %d %d", &L, &A, &B, &C, &D);
	int japa = (A % C == 0) ? A / C : A / C + 1;
	int math = (B % D == 0) ? B / D : B / D + 1;
	int ans = max(japa, math);
	printf("%d\n", L - ans);
	return 0;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++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; }
#define print(x) cout << (x) << endl;
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};


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

    UnionFind(ll n) : par(n, -1) { }
    void init(ll n) { par.assign(n, -1); }

    ll root(ll x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    bool merge(ll x, ll y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    ll size(ll x) {
        return -par[root(x)];
    }
};

int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int n,m;
    cin >> n >> m;
    vector<ll> a(m);
    vector<ll> b(m);
    rep(i,m){
      cin >> a[i] >> b[i];
      --a[i], --b[i];
    }
    vector<ll> ans(m);
  	ans[m-1] = (ll)n * (n - 1) / 2;

    UnionFind Uni(n);

    for(ll i = m-1; i >= 1; i--){
      ans[i-1] = ans[i];
      if(Uni.root(a[i]) != Uni.root(b[i])){
        ans[i-1] -= (long long)Uni.size(a[i]) * Uni.size(b[i]);
        Uni.merge(a[i],b[i]);
      }
    }
    rep(i,m){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 4480
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<ll,ll> P;
//#include <boost/multiprecision/cpp_int.hpp>
//using bint = boost::multiprecision::cpp_int;


int main(){
    int a,b;
    cin >> a >> b;
    int ans = -1;
    vector<int> cand;
    rep(i,100000){
        if ((int) (i*0.08) == a && (int) (i*0.1) == b ){
            ans = i;
            cand.push_back(i);
        }
    }
    SORT(cand);
    if (cand.size()==0) cout << -1;
    else cout << cand[0];
}


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

int main() {
  int n;cin>>n;
  map<string,int> mp;
  int cnt=0;
  rep(i,n){
    string s;cin>>s;
    mp[s]++;
    cnt=max(cnt,mp[s]);
  }
  for(auto x:mp){
    if(cnt==get<1>(x))cout<<get<0>(x)<<endl;
  }
}

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

int main(){
  long long n,ans=1000000000;cin>>n;
  for(long long i=0;i<(n+1)/2;i++){
    long long temp=0,a=i,b=n-i;
    while(a!=0||b!=0){
      temp+=a%10+b%10;
      a/=10;
      b/=10;
    }
    ans=min(ans,temp);
  }
  if(ans==1)ans=10;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
let for_range s e step f =
  let rec loop i =
    if i <= e then begin f i;loop (i + step) end
  in loop s;;

let sieve num =
  let p = Array.make (num+1) 1 in
  let rec loop i =
    if i*i < num then
      begin
        if p.(i) = 1 then for_range (i*i) num (i*2) (fun x -> p.(x) <- 0);
        loop (i+2)
      end
  in
  p.(0) <- 0; p.(1)<-(0); for_range 4 num 2 (fun x -> p.(x) <- 0);loop 3;
  p
;;

let _ =
  let p = sieve 1000000 in
  let rec read () =
    let (a,d,n) = Scanf.scanf " %d %d %d\n" (fun x y z -> (x,y,z)) in
    if a <> 0 then
      begin
        let rec loop cnt i =
          if cnt = n then Printf.printf "%d\n" (a+(i-1)*d)
          else if p.(a+i*d) = 1 then loop (cnt+1) (i+1)
          else loop cnt (i+1)
        in loop 0 0;
           read ()
      end
  in read ()
;;

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

#define all(v) v.begin(), v.end()
#define mp make_pair
#define EPS (int)1e-9
#define PI acos(-1)
#define endl '\n'
#define pb push_back
#define fi first
#define se second

using namespace std;
using ld = long double;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;

const int mod = 1000000007;


int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	vi a(3);
	cin >> a[0] >> a[1] >> a[2];

	sort(all(a));

	cout << a[0] + a[1] << endl;
	return 0;	
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

template <class T>
inline istream& operator>> (istream &in, vector<T> &vec) {
    for (auto &e : vec) in >> e;
    return in;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail&... tail) { cin >> head; read(tail...); }

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);

    int N;
    read(N);
    vector<i64> x(N), y(N), h(N);
    rep(i, N) {
        read(x[i], y[i], h[i]);
    }

    const auto greaterH = [&](i64 H, i64 cx, i64 cy) {
        rep(i, N) {
            const i64 kk = max<i64>(0, H - abs(cx - x[i]) - abs(cy - y[i]));
            if (kk > h[i]) return true;
        }
        return false;
    };

    reps(cx, 0, 100) reps(cy, 0, 100) {
        i64 low = 0;
        i64 high = INF;
        while (high - low > 1) {
            const i64 mid = (low + high) / 2;
            if (greaterH(mid, cx, cy)) high = mid;
            else low = mid;
        }

        bool ok = true;
        rep(i, N) {
            ok &= max<i64>(0, low - abs(cx - x[i]) - abs(cy - y[i])) == h[i];
        }
        if (ok) {
            print(cx, cy, low);
            return 0;
        }
    }

    return 0;
}


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

int main(){

    int n,m;
    int ans=0;
    cin>>n>>m;
    vector<int> h(n),check(n);
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        if(h[a-1]<h[b-1]) check[a-1]=-1;
        else if(h[a-1]>h[b-1]) check[b-1]=-1;
        else if(h[a-1]==h[b-1]){
            check[a-1]=-1;
            check[b-1]=-1;
        }
    }

    for(int i=0;i<n;i++){
        if(check[i]==0) ans++;
    }
    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 4048
#include<cstdio>
const int MAXN=50+5;
int a[MAXN];
int main(){
    int N,M;scanf("%d%d",&N,&M);
    for(int i=0;i<M;++i){
        int x,y;scanf("%d%d",&x,&y);
        a[x]++;a[y]++;
    }
    for(int i=1;i<=N;++i)
        printf("%d\n",a[i]);
}


Measured memory_bytes: 128
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(double i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int const INF = 1000000;
int main(){
    int n,m;
    cin>>n>>m;
    if(abs(n-m)>1){
        cout<<0<<endl;return 0;
    }
    ll ans=1;
    ll mkai=1;
    ll nkai=1;
    for(int i=1;i<=n;i++){
        nkai*=i;
        nkai%=1000000007;
    }
    for(int i=1;i<=m;i++){
        mkai*=i;
        mkai%=1000000007;
    }
    if(m==n){
        ans=2*nkai*mkai%1000000007;
    }else{
        
        ans=mkai*nkai%1000000007;
        
    }
    cout<<ans<<endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n,x,i,a[105],b[105];
	while(~scanf("%d%d",&n,&x))
	{for(i=0;i<n;i++)
	 scanf("%d",&a[i]);
	 b[0]=0;
	 int sum=1;
	 for(i=1;i<=n;i++)
 {b[i]=a[i-1]+b[i-1];
	  if(b[i]<=x)sum++;
	 }
	 printf("%d\n",sum);
	}
} 

Measured memory_bytes: 128
//This code is solely the property of StarnyC
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define ld long double
#define hell 1000000007
#define hellx 998244353
#define pb push_back
#define mp make_pair
#define reset(a,b) memset(a,b,sizeof(a))
#define Go_Baby_Go  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cerr.tie(0);
#define deb(x)     cout << (#x) << " is " << (x) << endl;
#define F  first
#define S  second
#define pii pair<ll,ll>
#define all(c) (c).begin(),(c).end()

bool secsort(const pii &a,const pii &b){
    return a<b;}

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

ll binexp(ll x,ll n,ll m){
   if(!n)return 1;
else if(n&1)return (x%m)*binexp((x%m)*(x%m),n/2,m)%m;
else if(!(n&1))return binexp((x%m)*(x%m),n/2,m)%m; 
return 0;}

int val[105];
int weight[105];
int dp[105][100005];

int32_t solve(ll _,ll _t)
{  
   int n,W,v=0;
   cin>>n>>W;

   for (int i=0;i<n;++i){
    cin>>weight[i+1]>>val[i+1];
    v+=val[i+1];
   }

      for(int i=0;i<105;i++)
        for(int j=0;j<100005;j++) dp[0][j]=1e12;

      dp[0][0]=0;
      ll ans=0;

    // cout<<fun(n-1,0,W)<<endl;

      for(int i=1;i<=n;i++)
        for(int j=1;j<=v;j++){

          if(j-val[i]>=0)
          dp[i][j]=min(dp[i-1][j],dp[i-1][j-val[i]]+weight[i]);
          else dp[i][j]=dp[i-1][j];

          if(ans<j&&dp[i][j]<=W)ans=j;
        }

   // for(int i=0;i<n;i++)
   // { for(int j=0;j<20;j++)
   //    cout<<dp[i][j]<<" ";

   //    cout<<endl;}
        cout<<ans;

 








return 0;
}


int32_t main()
{
 Go_Baby_Go
//cerr<< '\n' << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" ;


ll _=1;
//cin>>_;
ll _t=_;
while(_--)
solve(_,_t);

}


Measured memory_bytes: 80128
#include <stdio.h>

int isprime(int x){
  if(x == 2){
    return(1);
  }

  if(x < 2 || (x%2) == 0){
    return(0);
  }

  int i=3;
  while((i*i) <= x){
    if((x % i) == 0){
      return(0);
    }
    i = i + 2;
  }
  return(1);
}

int main(void)
{
  int n;
  int x;
  int i;
  int count = 0;
  
  scanf("%d",&n);

  for(i=0; i<n; i++){
    scanf("%d",&x);
    if(isprime(x) == 1){
      count++;
    }
  }
  
  printf("%d\n",count);
  
  return(0);
}

Measured memory_bytes: 596
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        var red = new bool[201, 201];
        for (int i = 0; i < n; i++)
        {
            string[] cin = Console.ReadLine().Split();
            red[int.Parse(cin[0]), int.Parse(cin[1])] = true;
        }

        var blue = new bool[201, 201];
        for (int i = 0; i < n; i++)
        {
            string[] cin = Console.ReadLine().Split();
            blue[int.Parse(cin[0]), int.Parse(cin[1])] = true;
        }

        int ans = 0;
        for (int x = 0; x <= 200; x++)
        {
            for (int y = 0; y <= 200; y++)
            {
                if (blue[x, y])
                {
                    bool flag = false;
                    for (int t = y - 1; 0 <= t; t--)
                    {
                        for (int s = x - 1; 0 <= s; s--)
                        {
                            if (red[s, t])
                            {
                                red[s, t] = !red[s, t];
                                ans++;
                                flag = true;
                                break;
                            }
                        }
                        if (flag) break;
                    }
                }
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11132
n=int(input())
cnt=0
k=1
l=[]
for i in range(1,int(n**0.5)+1):
    if n%i==0:
        l.append(i)
        if n//i!=i:l.append(n//i)
for k in l:
    x=(n-k)/k
    intx=int(x)
    if x==intx and intx>k:cnt+=intx
print(cnt)

Measured memory_bytes: 3268
import sys
import numpy as np
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


N, C = mi()
time = [0 for i in range(10 ** 5 + 10)]
use = [[] for i in range(10 ** 5 + 10)]
F = []
for i in range(N):
    F.append(lmi())
F.sort(key=lambda x: x[0])
# print(F)
for s, t, c in F:
    use[t].append(c)
    if c in use[s]:
        time[s] += 1
    else:
        time[s-1] += 1
    time[t] -= 1
# print(time[0:100])
timesum = np.cumsum(np.array(time))
# print(use[0:100])
print(max(timesum))

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

using namespace std;

using ll = long long;
using Pii = pair<int, int>;

const ll INF = (ll)1e11;

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

    cout << ( ((s.length() % 2 == 0) ^ (s.front() == s.back())) ? "Second" : "First" ) << endl;

    return 0;
}


Measured memory_bytes: 512
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        new Main().compute();
    }
 
    void compute() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] A = new int[N + 1];
        int[] B = new int[N + 1];
        int[] C = new int[N + 1];
        for (int i = 0; i < N; i++) {
            A[i] = sc.nextInt();
        }
        for (int i = 0; i < N; i++) {
            B[i] = sc.nextInt();
        }
        for (int i = 0; i < N; i++) {
            C[i] = sc.nextInt();
        }
        A[N] = Integer.MAX_VALUE;
        B[N] = Integer.MAX_VALUE;
        C[N] = Integer.MAX_VALUE;
        Arrays.sort(A);
        Arrays.sort(B);
        Arrays.sort(C);
        long[] BTC = new long[N + 1];
        for (int i = 0, j = 0; i < N; i++) {
            for (;; j++) {
                if (B[i] < C[j]) {
                    break;
                }
            }
            BTC[i] = N - j;
        }
        BTC[N] = 0;
        for (int i = N - 1; i >= 0; i--) {
            BTC[i] += BTC[i + 1];
        }
        long[] ATB = new long[N];
        for (int i = 0, j = 0; i < N; i++) {
            for (;; j++) {
                if (A[i] < B[j]) {
                    break;
                }
            }
            ATB[i] = BTC[j];
        }
        long ans = 0;
        for (int i = 0; i < N; i++) {
            ans += ATB[i];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 95280
#include<iostream>
using namespace std;
   
struct Card { char suit, value; };
 
void bubble(struct Card A[], int N){
    for(int i=0;i<N;i++){
        for(int j=N-1;j>=i;j--){
            if ( A[j].value<A[j-1].value ){
                    Card t=A[j];A[j]=A[j-1];A[j-1]=t;
            }
        }
    }
}
   
void selection(struct Card A[],int N){
    for ( int i=0;i<N;i++){
        int minj=i;
        for(int j=i;j<N;j++){
            if(A[j].value<A[minj].value)minj=j;
        }
        Card t=A[i];A[i]=A[minj];A[minj]=t;
    }
}
 
void print(struct Card A[],int N){
    for(int i=0;i<N;i++){
        if(i>0)cout<<" ";
        cout<<A[i].suit<<A[i].value;
    }
    cout<<endl;
}
   
bool isStable(struct Card C1[],struct Card C2[],int N){
    for(int i=0;i<N;i++){
        if(C1[i].suit!=C2[i].suit)return false;
    }
    return true;
}
   
int main(){
    Card C1[100],C2[100];
    int N,A[100];
    char ch;
   
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>C1[i].suit>>C1[i].value;
    }
   
    for(int i=0;i<N;i++)C2[i]=C1[i];
   
    bubble(C1,N);
    selection(C2,N);
   
    print(C1,N);
    cout<<"Stable"<<endl;
    print(C2,N);
    if(isStable(C1,C2,N)){
        cout<<"Stable"<<endl;
    }else{
        cout<<"Not stable"<<endl;
    }
    return 0;
}

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

int main(){
  int N,K,A=1;
  cin>>N>>K;
  
  for(int i=0;i<N;i++){
  
  if(A<=K){
  A=A*2;
  }
  
  else if(A>K){
  A=A+K;
  }
  
  }
  
  cout<<A<<endl;
  
}

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

#define mainspring cout<<"mainspring\n";
#define barrel cout<<"barrel\n";
#define escapement cout<<"escapement\n";

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second
#define tik(i,a,b) for(int i = a; i < b; i++)
#define tok(i,a,b) for(int i = a; i >= b; i--)
#define error(args...) {string _s = #args; replace(_s.begin(), _s.end(), ',',' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it,args);}

typedef long long ll;
typedef unsigned long long ull;

#define int ll 

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << " ";
    err(++it, args...);
}



const int MAXN = 1E5 + 100;
int MOD, N, dp[MAXN], dp2[MAXN], up[MAXN];
vvi adj(MAXN);

void DFS(int u = 0, int p = -1) {
	dp[u] = 1;
	for(int v : adj[u]) {
		if(v == p)
			continue;
		DFS(v, u);
		dp[u] = (dp[u]*(dp[v] + 1))%MOD;
	}
}

ll pow(ll x, ll y) {
	if(y == 0)
	return 1;
	ll temp = pow(x, y/2);
	temp = (temp*temp)%MOD;
	if(y%2 == 1)
		temp *= x;
	return temp%MOD;
}

int egcd(int a, int b, int &x, int &y) {
	if(b == 0) {
		x = 1, y = 0;
		return a;
	}
	int g = egcd(b, a%b, x, y);
	int tmp = x;
	x = y;
	y = tmp - y*(a/b);
	return g;
}

void reroot(int u = 0, int p = -1) {
	vi children;
	for(int i = 0; i < sz(adj[u]); i++) {
		if(adj[u][i] == p)
			continue;
		children.pb(adj[u][i]); 
	}
	int pref[sz(children) + 1], suff[sz(children) + 1];
	pref[0] = suff[sz(children)] = 1;
	for(int i = 0; i < sz(children); i++) {
		pref[i + 1] = (pref[i]*(dp[children[i]] + 1))%MOD;
		//error(i, pref[i + 1]);
	}
	for(int i = sz(children) - 1; i >= 0; i--) {
		suff[i] = ((dp[children[i]] + 1)*suff[i + 1])%MOD;
		//error(i, suff[i]);
	}
	for(int i = 0; i < sz(children); i++)
		up[children[i]] = (1 + ((up[u]*pref[i])%MOD)*suff[i + 1])%MOD;
	for(int i = 0; i < sz(children); i++) {
		int v = children[i];
		int tmp = (pref[i]*suff[i + 1])%MOD;
		if(v == p)
			continue;
		dp2[v] = (tmp*dp[v])%MOD;
		dp2[v] = (dp2[v]*up[u])%MOD;
		dp2[v] = (dp2[v] + dp[v])%MOD;
		//error(u, up[u], up[v]);
		reroot(v, u);
	}
}

int32_t main() {
	up[0] = 1;
	cin >> N >> MOD;
	for(int i = 0, u, v; i < N - 1; i++) {
		cin >> u >> v;
		--u, --v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	DFS();
	dp2[0] = dp[0];
	up[0] = 1;
	reroot();
	for(int i = 0; i < N; i++)
		cout << dp2[i] << '\n';
}


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

using namespace std;

int n;
set< string > s;
int main() {
    cin >> n;

    for (int i = 0; i < n; i++) {
        string a;
        cin >> a;
        s.insert(a);
    }
    cout << s.size();
    return 0;
}


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

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

int N, M, Q;
int field[505][505];
int sum[505][505];

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

	cin >> N >> M >> Q;

	for (int i = 0;i < M;i++){
		int l,r; cin >> l >> r;
		field[l][r]++;
	}

	for (int i = 1;i <= N;i++){
		for (int j = 1;j <= N;j++){
			sum[i][j] += sum[i-1][j];
			sum[i][j] += sum[i][j-1];
			sum[i][j] -= sum[i-1][j-1];
			sum[i][j] += field[i][j];
		}
	}

	for (int i = 0;i < Q;i++){
		int p,q; cin >> p >> q;
		p--;
		int ans = sum[q][q]-sum[p][q]-sum[q][p]+sum[p][p];
		cout << ans << endl;
	}

	return 0;

}


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

using namespace std;

int main()
{
  int N; cin >> N;
  vector<int> p(N);
  for_each(p.begin(), p.end(), [](int& e){ cin >> e; });
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      swap(p[i], p[j]);
      if (is_sorted(p.begin(), p.end())) {
        cout << "YES" << endl;
        return 0;
      }
      swap(p[i], p[j]);
    }
  }
  cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e10;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

int main(){
  ll N,K; cin>>N>>K;
  vector<bool> used(N,false);
  ll ans=0;
  rep(i,K){
    ll d; cin>>d;
    rep(j,d){
      ll x; cin>>x; x--;
      if(!used[x]) {
        used[x]=true;
        ans++;
      }
    }
  }
  cout<<N-ans<<endl;
}

Measured memory_bytes: 3632
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define debug(x)			{ cerr << #x << " = " << x << endl; }
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define vi					vector<int>
#define vii					vector<vi>
#define mid(s,e)			(s+(e-s)/2)

using namespace std;

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(a*n,b);
	return 0;
}



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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

void question(int i,int n,vector<int>& color) {
    cout << "?";
    for (int j = 0;j < n;++j) cout << " " << i+j+1;
    cout << endl;
    string s;
    cin >> s;
    color[i] = (s[0] == 'R');
    if (s == "-1") exit(0);
}

int main() {
    int n;
    cin >> n;
    int l = 0,r = n;
    vector<int> color(2*n,-1);
    question(0,n,color);
    question(n,n,color);
    while (r-l > 1) {
        int mid = (l+r)/2;
        question(mid,n,color);
        (color[mid] == color[l] ? l : r) = mid;
    }
    vector<int> a,b;
    vector<bool> c(2*n,false);
    for (int i = 0;i < 2*n;++i) {
        if (i == l || i == r+n-1) continue;
        if (i < r || r+n-2 < i) a.push_back(i);
        else {
            b.push_back(i);
            c[i] = true;
        }
    }
    vector<char> ans(2*n);
    for (int i = 0;i < 2*n;++i) {
        cout << "?" << " " << i+1;
        if (c[i]) for (int j = 0;j < n-1;++j) cout << " " << a[j]+1;
        else for (int j = 0;j < n-1;++j) cout << " " << b[j]+1;
        cout << endl;
        string s;
        cin >> s;
        ans[i] = s[0];
    }
    cout << "!" << " ";
    for (int i = 0;i < 2*n;++i) cout << (char)ans[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 724
# include <bits/stdc++.h>
# define INF 1e9
using namespace std;

int main(){

  int N, D, X;
  cin >> N >> D >> X;
  int ans = X;
  for(int i=0; i<N; ++i){
    int v;
    cin >> v;
    ans += 1 + (D-1)/v;
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let s = read::<String>().chars().collect::<Vec<_>>();
    let _ = read::<String>().chars().collect::<Vec<_>>();
    let big_int = 1000_000_007;

    let mut desc = vec![0];
    let mut i = 0;
    while i < n {
        if i + 1 < n && s[i] == s[i + 1] {
            desc.push(2);
            i += 2;
        } else {
            desc.push(1);
            i += 1
        }
    }
    debug!(desc);
    let mut ans = 1u64;
    for i in 1..desc.len() {
        if desc[i - 1] == 0 {
            if desc[i] == 2 {
                ans *= 6;
            } else {
                ans *= 3;
            }
        } else if desc[i - 1] == 1 {
            if desc[i] == 2 {
                ans *= 2;
            } else {
                ans *= 2;
            }
        } else {
            if desc[i] == 2 {
                ans *= 3;
            } else {
                ans *= 1;
            }
        }
        ans %= big_int;
    }
    println!("{:?}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <vector>
#define f first
#define	s second
#define	int long long
using namespace	std;
signed main(){

  int w,h,r=0,t;
  vector <pair<int,int> > a;
  cin>>w>>h;
  for(int i=0;i<w&&cin>>t;i++) a.push_back(make_pair(t,0));
  for(int i=0;i<h&&cin>>t;i++) a.push_back(make_pair(t,1));
  sort(a.begin(),a.end());
  w++,h++;
  for(int i=0;i<(int)a.size();i++){
    if(a[i].s==0){
      r+=h*a[i].f;
      w--;
    }else {
      r+=w*a[i].f;
      h--;
    }
  }
  cout<<r<<endl;
  return 0;
}



Measured memory_bytes: 6512
import copy
H, W, K=map(int, input().split())
C=[]
for _ in range(H):
    c=list(input())
    C.append(c)
ans=0
for i in range(2**(H)):
    for k in range(2**(W)):
        copy_c=copy.deepcopy(C)
        for j in range(H):
            for l in range(W):
                if (i>>j)&1: #H行目を赤にする
                    for w in range(W):
                        copy_c[j][w]=0
                if (k>>l)&1: #W列目を赤にする
                    for h in range(H):
                        copy_c[h][l]=0
        count=0
        for h in range(H):
            for w in range(W):
                if copy_c[h][w]=="#":
                    count=count+1
        if count==K:
            # print(copy_c)
            ans=ans+1
print(ans)


Measured memory_bytes: 77952
/*Enter your code here. Read input from STDIN. Print your output to STDOUT*/
#include <bits/stdc++.h>
using namespace std;
#define endl "\n";
#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
const int mod = 1e9 + 7;

int32_t main()
{
    fastio;
    
    int n; cin >> n;
    vector<int> a(n); for(auto &x: a) cin >> x;

    int dp[n][n];
    for(int L=n-1; L>=0; L--){
        for(int R=L; R<n; R++){
            if(L == R){
                dp[L][R] = 0;
                continue;
            }

            int sum = 0;
            for(int i=L; i<=R; i++) sum += a[i];

            dp[L][R] = LLONG_MAX;
            for(int i=L; i<=R-1; i++){
                dp[L][R] = min(dp[L][R], dp[L][i] + dp[i+1][R] + sum);
            }
        }
    }

    cout << dp[0][n-1] << endl;
    return 0;   
}
    


Measured memory_bytes: 1536
N = int(input())
h = list(map(int,input().split()))

dp = [0]*N
dp[1] = abs(h[1]-h[0])
for i in range(2,N):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])

Measured memory_bytes: 13928
import java.util.*;
import java.io.*;
public class Main{
   public static void main(String[] main) throws Exception{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringTokenizer st = new StringTokenizer(br.readLine());
      PrintWriter out = new PrintWriter(System.out);
      long[] pow = new long[11];
      pow[0] = 26;
      for(int i = 1; i < 11; i++)
    	  pow[i] = 26*pow[i-1];
     long n = Long.parseLong(st.nextToken());
     int i = 0;
     while(n > pow[i]) {
    	 n -= pow[i];
    	 i++;
     }
     String ans = "";
     n--;
     while(i >= 0) {
    	 ans = (char)(97 + n%26) + ans;
    	 n /= 26;
    	 i--;
     }
     out.println(ans);
      out.close();
   }
}


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

int main() {
    int n;
    cin >> n;
    int a[20], b[50], c[50];
    int ans = 0;
    rep(i, n) cin >> a[i];
    rep(i, n) {
        cin >> b[i]; ans += b[i];
    }
    rep(i, n-1) cin >> c[i];
    rep(i, n-1) {
        if (a[i]+1 == a[i+1]) ans += c[a[i]-1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;


int main(){
    int a,b;
    while(cin>>a>>b){
        if(a==0 && b==0)break;
        if((a*b)%2==0)cout<<"yes"<<endl;
        else cout<<"no"<<endl;
    }
    return 0;
}

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

    using namespace std;
    typedef long long ll;
    typedef unsigned long long ull;
    # define M_PI  3.14159265358979323846


    const int M=1e9+7;
    long long mod(long long x){
        return ((x%M + M)%M);
    }
    long long add(long long a, long long b){
        return mod(mod(a)+mod(b));
    }
    void solve(){
        int k;
        cin>>k;
        int total=0;
        for(int i=1;i<=(1e7);i++){
            total=(total*10+7)%k;
            if(total==0){
                cout<<i;
                return;
        }
        }
        cout<<-1;
    }
    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
//        freopen("timber_input.txt", "r", stdin);
//        freopen("timber_output.txt", "w", stdout);
        int t=1;
//        cin>>t;
        for(int i=1;i<=t;i++){
//            cout<<"Case #"<<i<<": ";
            solve();
        }
        return 0;
    }


Measured memory_bytes: 3628
#include <stdio.h>
int main(void)
{
    int X,Y,Z,s;
    scanf("%d%d%d",&X,&Y,&Z);
    s=(X-2*Z)/(Y+Z);
    if((X-2*Z)%(Y+Z)>=Y)
        s++;
    printf("%d\n",s);
    return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {

	public static void main(String[] args) {
		
		Scanner stdIn = new Scanner(System.in);
		int A = stdIn.nextInt();
		int B = stdIn.nextInt();
		int C = stdIn.nextInt();
		
		int d = A*7+B;
		int day = C/d*7, r = C%d;
		int i=0;
		while (r>0 && i<7) {
			r-=A;
			i++;
		}
		
		day+=i;
		
		System.out.println(day);
	}

}



Measured memory_bytes: 26324
inp = input()
st = inp.split()
n = int(st[0])
m = int(st[1])

max_l = 0
min_r = n+10
for _ in range(m):
    i_inp = input()
    st_ino = i_inp.split()
    l = int(st_ino[0])
    r = int(st_ino[1])
    if l > max_l:
        max_l = l
    if r < min_r:
        min_r = r
ans = min_r - max_l + 1
if ans < 0:
    print(0)
else:
    print(ans)


Measured memory_bytes: 3064
K,S = map(int, input().split())
 
ans = 0
 
for X in range(K+1):
	S1 = S - X
	if S1 < 0:
		break
	else:
		if S1 <= K:
			ans += S1 + 1
		elif S1 <= 2 * K:
			ans += 2*K - S1 + 1
 
print(ans)

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

const int N = 1e5 + 5;

int n;
int a[N], b[N];

void work(int s, int& mx, int& mxc, int& sc) {
	memset(b, 0, sizeof(b));
	for (int i = s; i <= n; i += 2)
		b[a[i]]++;
	mx = 0, sc = 0;
	for (int i = 1; i <= 100000; i++) {
		if (b[i] > mx) {
			sc = mx;
			mx = b[i];
			mxc = i;
		} else if (b[i] > sc) {
			sc = b[i];
		}
	}
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", a + i);
	int mx1, mxc1, sc1;
	int mx2, mxc2, sc2;
	work(1, mx1, mxc1, sc1);
	work(2, mx2, mxc2, sc2);
	int ans = 1e9;
	if (mxc1 ^ mxc2) {
		ans = n - mx1 - mx2;
	} else {
		ans = min(n - mx1 - sc2, n - sc1 - mx2);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1024
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>N>>M>>K;
	if(M%2==K%2){
		cout<<(K-M)/2<<endl;
		return 0;
	}
	long long int ans=(K-M-1)/2+M;
	ans=min(ans,(K-M-1)/2+N-K+1);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+9;
int n,q,x,v,idx=1,in[N],out[N];
ll seg[4*N],lazy[4*N];
vector<int>g[N];
 
void dfs(int node,int p){
    in[node]=idx;
    idx++;
    for(int i=0;i<g[node].size();i++){ 
        if(p!=g[node][i]) dfs(g[node][i],node);
    } 
    out[node]=idx-1;
}

void push(int p,int l,int r){ 
    seg[p]+=(r-l+1)*lazy[p];
    if(l!=r){ 
        lazy[p*2]+=lazy[p];
        lazy[p*2+1]+=lazy[p];
    }
    lazy[p]=0;
}

 
void update(int p,int l,int r,int a,int b,int v){ 
    push(p,l,r);
   	if(r<a||l>b)return;
	if(a<=l&&r<=b){
	   lazy[p]=v;
	   push(p,l,r);
	   return;
	}
	int mid = (l+r)/2;
	update(p*2,l,mid,a,b,v);
	update(p*2+1,mid+1,r,a,b,v);
	seg[p]=seg[p*2]+seg[p*2+1];
}
 
ll get(int p,int l,int r,int a,int b){ 
     push(p,l,r);
	 if(r<a||l>b)return 0;
     if(l>=a&&r<=b)return seg[p];
     int mid=(l+r)/2;
    return get(p*2,l,mid,a,b)+get(p*2+1,mid+1,r,a,b);
}

int main()
{ 
    cin>>n>>q;
    for(int x,y,i=0;i<n-1;i++){ 
        cin>>x>>y;
        g[x].push_back(y);
        g[y].push_back(x);
    } 
    dfs(1,-1);
    while(q--){ 
        cin>>x>>v;
        update(1,1,n,in[x],out[x],v);
    } 
    for(int i=1;i<=n;i++){ 
        cout<<get(1,1,n,in[i],in[i])<<" ";
    }
    
    
    
    
    return 0;
}


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

long long int a,b,k,c,d;
int main(){
    cin>>a>>b>>k;
    c=min(k,a);
    a-=c;
    k-=c;
    c=min(b,k);
    b-=c;
    cout<<a<<' '<<b<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	char ar[n];
	int x = 0;
	int y = 0;
	for(int i = 0;i<n;++i) {
		cin >> ar[i];
		if(ar[i] == 'R')
			x++;
	}
	for(int i = 0;i<x;++i) {
		if(ar[i] == 'W')
			y++;
	}
	cout << y << '\n';
}



Measured memory_bytes: 3820
#include <stdio.h>
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int main(){
    int n,temp,now=1;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&temp);
        if(now%temp!=0)now=now*temp/gcd(now,temp);
    }
    printf("%d\n",now);
}

Measured memory_bytes: 2760
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(void) {
  string s;
  cin>>s;
  ll n;
  cin>>n;
  rep(i,0,s.sz){
    if(i%n==0){
      cout << s[i];
    }
  }
  cout << endl;
  return 0;
}

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

t = []
for i in range(n):
    x, l = map(int, input().split())
    t.append((x+l, x-l))
t.sort()

last = -10**10
count = 0
for e, s in t:
    if s >= last:
        last = e
        count += 1

print(count)

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

const long long MOD = 1000000007LL;
long long GCD(long long a, long long b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, d; cin >> n >> d;

    cout << (n + d + d) / (d + d + 1);

    return 0;
}


Measured memory_bytes: 256