akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        try(Scanner sc=new Scanner(System.in)){
            while(true){
                int n = sc.nextInt();
                if(n==0){
                    break;
                }
                int[] scores = new int[n];
                for(int i = 0; i<scores.length;i++){
                    scores[i]=sc.nextInt();
                }
                double average = 0;
                double variance = 0;
                int sum=0;
                for(int i=0; i<scores.length;i++){
                    sum+=scores[i];
                }
                average=(double)sum/(double)scores.length;
                double sum2=0.0;
                for(int i=0;i<scores.length;i++){
                    sum2+=(scores[i]-average)*(scores[i]-average);
                }
                variance=sum2/scores.length;
                System.out.println(Math.sqrt(variance));

            }
        }
    }
}


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

int main(){
  int a,b=0,c,d,e,g,f,h,i,j,k,array[100001];
  string s,array2[100001];
  cin>>a;
  c=a;
  while(c){
    b+=c%10;
    c/=10;
  }
  if(a%b){
    cout<<"No";
  }else{
    cout<<"Yes";
  }
  cout<<endl;
}
    

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, X;
    cin >> N >> X;
    vector<ll> m(N);
    rep(i, N) cin >> m[i];
    sort(m.begin(), m.end());
    ll ans = accumulate(m.begin(), m.begin() + N, 0LL);
    cout << N + (X - ans) / m.front() << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,ll,ll> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> P;
int prime[60000];
bool is_prime[556000];

int main(int argc,char const* argv[])
{
  ll n,ans=0;
  cin >> n;
  vector<ll> a(n);
  for(int i=0;i<n;i++)
    {
      cin >> a[i];
    }
  ll xsum=0,sum=0;
  int r=0;
  for(int l=0;l<n;l++)
    {
      while(r<n)
	{
	  if((xsum ^ a[r])!=(sum+a[r])) break;
	  xsum=(a[r]^xsum);
	  sum+=a[r];
	  r++;
	}
      ans+=(r-l);
      xsum^=a[l];
      sum-=a[l];
    }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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

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

int main(){
  int i,j;
  ll k,q;
  cin>>k>>q;
  ll d[k];
  ll sum=0;
  for(i=0;i<k;i++) {
    cin>>d[i];
  }
  while(q--){
    ll n,x,m;
    cin>>n>>x>>m;
    n--;
    ll dd[k];
    ll z=0;
    ll sum=0;
    for(i=0;i<k;i++) {
      dd[i]=d[i]%m;
      sum+=dd[i];
      if(dd[i]==0) z++;
    }
    ll nn=n%k;
    ll loop=(n-nn)/k;
    ll cnt=0;
    for(i=0;i<nn;i++){
      if(x%m>=(x+dd[i])%m) cnt++;
      x+=dd[i];
    }
    cnt+=z*loop;
    cnt+=(x+sum*loop)/m-(x/m);
    cout<<n-cnt<<endl; 
  }
  


}

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

#define rep(i,x) for(int i = 0; i < (int)(x); i++)
#define reps(i,x) for(int i = 1; i <= (int)(x); i++)
#define rrep(i,x) for(int i = ((int)(x) - 1); i >= 0; i--)
#define rreps(i,x) for(int i = ((int)(x)); i > 0; i--)

#define all(x) (x).begin(), (x).end()

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

int gcd(int a, int b){return b?gcd(b,a%b):a;}
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};

using ll = long long;


int main(){
    //入力、初期化
    int H,W;
    cin >> H >> W;
    vector<vector<int>> cnt(H,vector<int>(W)); 
    vector<string> s(H);
    rep(i,H){
        cin >> s[i];
    }

    rep(i,H){
        vector<int> done(W);
        rep(j,W){
            if(s[i][j] == '#') continue;
            if(done[j]) continue;

            int l = 0;
            while(j+l < W){
                if(s[i][j+l] == '#') break;
                l++;
            }

            rep(k,l){
                cnt[i][j+k] += l;
                done[j+k] = 1;
            }
        }
    }
    rep(j,W){
        vector<int> done(H);
        rep(i,H){
            if(s[i][j] == '#') continue;
            if(done[i]) continue;

            int l = 0;
            while(i+l < H){
                if(s[i+l][j] == '#') break;
                l++;
            }

            rep(k,l){
                cnt[i+k][j] += l;
                done[i+k] = 1;
            }
        }
    }

    int ans = 0;
    rep(i,H) rep(j,W) ans = max(ans,cnt[i][j]-1);
    cout << ans << endl;
    return 0;
}


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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001


int main(){
    cin.sync_with_stdio(false);
    int n, x;
    cin >> n >> x;

    if (x == 1 || x == 2 * n - 1) {
        cout << "No" << endl;
    } else if (x == 2 && n == 2) {
        cout << "Yes" << endl;
        cout << "1\n2\n3" << endl;
    } else {
        int a[2 * n - 1] = {};
        bool used[2 * n] = {};

        a[n - 1] = x;
        used[x] = true;
        if (x < 2 * n - 2) {
            a[n] = x - 1;
            a[n - 2] = x + 1;
            a[n + 1] = x + 2;
            used[x - 1] = used[x + 1] = used[x + 2] = true;
        } else {
            a[n] = x + 1;
            a[n - 2] = x - 1;
            a[n + 1] = x - 2;
            used[x + 1] = used[x - 1] = used[x - 2] = true;
        }
        int j = 1;
        rep(i, 2 * n - 1) {
            if (a[i] != 0) continue;
            while(used[j]) j++;
            a[i] = j;
            j++;
        }

        cout << "Yes" << endl;
        rep(i, 2 * n - 1) cout << a[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 2432
s = list(input())
count1 = 0
s_copy = s.copy()
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        count1 += 1
        if s[i+1] == '0':
            s[i+1] = '1'
        else:
            s[i+1] = '0'
s = s_copy.copy()
s.reverse()
count2 = 0
for i in range(len(s)-1):
    if s[i] == s[i+1]:
        count2 += 1
        if s[i+1] == '0':
            s[i+1] = '1'
        else:
            s[i+1] = '0'
print(min(count1,count2))

Measured memory_bytes: 5544
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>

#define roop(i, n) for(int i=0;i<n;i++)

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ull mod = 1e9+7;
constexpr int N = 13;
ull dp[100010][N];

int myPower(int a, int n) { // aのn乗の計算
	int x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main() {
	int n, T, i, j;
	cin >> n >> T;
	int c[n];
	int t[n];
	roop(i, n) {
		cin >> c[i] >> t[i];
	}
	int min = 1001;
	roop(i, n) {
		if (t[i] <= T) {
			if (c[i] < min) {
				min = c[i];
			}
		}
	}
	if (min == 1001) {
		cout << "TLE" << endl;
	} else {
		cout << min << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;

public class Main{

	public static void main(String[] args) throws Exception
	{
		String[] strRing = {"24532453","64136413","56215621","51265126","63146314","54235423"};
		String strT,strS,strB;
		int nE=0,nW=0;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in) );
		String[] strValue = br.readLine().split(" ");

		HashMap<String,String> map = new HashMap<String,String>();

		for(int i=0; i<6; i++)
		{
//			if(!map.containsKey(strValue[i]) )

				map.put(strValue[i],Integer.toString(i+1) );

		}

		String[] str = br.readLine().split(" ");//get 2nd dice

		strT = map.get(str[0]);
		strS = map.get(str[1]);
		strB = Integer.toString(7 - Integer.parseInt(strT) );

		String strBST = strB + strS + strT;

		for(int i=0; i<6; i++)
		{
			if(-1 < strRing[i].indexOf(strBST) )
			{
				nE = i;
				nW = 5-i;
			}
		}

		if(strValue[nE].equals(str[2]) && strValue[nW].equals(str[3]) )
		{
			int nB = Integer.parseInt(strB);
			System.out.println(strValue[nB-1].equals(str[5]) ? "Yes" : "No");
		}
		else
		{
			System.out.println("No");
//			System.out.println(strT + strS + nE + ":" + nW);
		}

	}
}

Measured memory_bytes: 24448
#include "bits/stdc++.h"
#include <chrono>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vector<pair<double, double>> xy;
    for (int i = 0; i < n; ++i) {
        double x, y;
        cin >> x >> y;
        xy.emplace_back(x, y);
    };
    vector<double> pos(2, 0.0);
    vi state(n, 0);
    double ret = 0.0;
    double maxret = 0.0;
    chrono::system_clock::time_point startt, currt;
    startt = chrono::system_clock::now();
    while (true) {
        vi newstate = state;
        currt = chrono::system_clock::now();
        double time = static_cast<double>(chrono::duration_cast<chrono::microseconds>(currt - startt).count() / 1000.0);
        int idx = rand() % n;
        int sign = 1;
        if (state[idx] == 1)
            sign = -1;
        double score = sqrt((pos[0] + sign * xy[idx].first) * (pos[0] + sign * xy[idx].first) +
                            (pos[1] + sign * xy[idx].second) * (pos[1] + sign * xy[idx].second));
        bool force_next = 1800 - time > double(rand() % 1900);
        if (score > ret || force_next) {
            ret = score;
            pos[0] += sign * xy[idx].first;
            pos[1] += sign * xy[idx].second;
            state[idx] += sign;
        }
        chmax(maxret, score);
        if (time > 1900.0)
            break;
    }
    cout << fixed << setprecision(15) << maxret << "\n";
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

int main() {
  ll N;
  cin >> N;
  string S;
  cin >> S;

  ll ans = 0;
  ll i = 0;
  while (i < N) {
    ll j = i;
    while (j < N && S[i] == S[j]) j++;
    i = j;
    ans++;
  }

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


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

int dp[MAX] = {};
int n,q;
string s;

void make() {
	int i = 0;
	dp[0] = 0;
	while(1) {
		if (s[i]=='A'&&s[i+1]=='C') {
			dp[i+1] = dp[i] + 1;
		} else {
			dp[i+1] = dp[i];
		}
		if (i+1==n-1) {
			break;
		}
		i++;
	}

	// rep(i,n) {
	// 	cout << i << " " << dp[i] << endl;
	// }
}

int main(){
	cin >> n>>q>>s;
	make();
	rep(i,q) {
		int l,r;
		cin >> l>>r;
		cout << dp[r-1]-dp[l-1]<< endl;
	}
}



Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

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

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
int H, W, K;
vector<string> S;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    cin >> H >> W >> K;
    S.resize(H);
    rep(i,H)cin >> S[i];
    vvec<int> cum(H+1, vec<int>(W,0));
    rep(j,W){
        rep(i,H){
            cum[i+1][j] += cum[i][j] + S[i][j] - '0';
        }
    }
    //rep(i,H+1)print(cum[i]);
    ll ans = INFLL;
    //境界の状態を全探索
    rep(k,bit(H-1)){
    //rep(k,1){                    // 2^9
        // l個目の境界が分かれているか
        vector<int> v;
        v.push_back(0); 
        ll cnt = 0; // 境界の本数
        rep(l, H-1){                    
            if(k & bit(l)){
                v.push_back(l+1);
                cnt++;
            }
        }
        v.push_back(H);
        //print(v);
        vector<int> counts(int(v.size()-1),0);
        bool ok = true;
        map<int, int> map;
        rep(j,W){                           // 1000
            map[j]++;
            if(!ok)break;
            vector<int> nxt((int)v.size()-1, 0);
            int maxx = 0; //区間の中のmax
            rep(m, v.size()-1){             // 10 m番目の区間
                int l = v[m];
                int r = v[m+1];
                //cerr << l << " "  <<  r <<endl;
                //[l,r)行ごとに分ける
                nxt[m] = counts[m];
                //j行目の、[l,r)の足し算
                /*
                for(int i = l;i < r;i++){
                    nxt[m] += S[i][j] - '0';
                }*/
                nxt[m] +=  cum[r][j] - cum[l][j];
                chmax(maxx, nxt[m]);
            }
            //print(nxt);
            if(maxx <= K){
                swap(counts,nxt);
            }
            else{
                if(map[j] >= 2)ok = false;
                j--;
                counts.assign((int)v.size()-1,0);
                cnt++;
                continue;
            }
        }
        if(ok)chmin(ans, cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner stdIn = new Scanner(System.in);
        int n =stdIn.nextInt();
        int k = stdIn.nextInt();
        if((n%k)==0){
            System.out.println(0);
        }else{System.out.println(1);}
    }
}


Measured memory_bytes: 22868
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __
.' ____ \ [  |      (_)                [  |
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |,
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/

*/
/* }}} */

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

// #define int long long

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;
typedef double D;
typedef complex<D> P;

/* const */
const int INF = 999999999;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T> void print(T x) { std::cout << x << '\n'; }
template <typename T>
void print(std::vector<T>& v, string s = " ") {
  REP(i, v.size()) {
    if (i != 0) std::cout << s;
    std::cout << v[i];
  }
  std::cout << '\n';
}

/* }}} */

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n = in();
  int k = in();
  int x = in(), y = in();
  int ans = 0;
  REP(i, n) {
    if (i < k) {
      ans += x;
    } else {
      ans += y;
    }
  }
  print(ans);


  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}

int S[210000];
int T[210000];
int X[210000];
int z[410000];
int segtree[1<<20];
void update(int a,int b,int c,int d,int e,int f){
	if(d<a||b<c)return;
	if(c<=a&&b<=d){
		segtree[e]=min(segtree[e],f);return ;
	}
	update(a,(a+b)/2,c,d,e*2,f);
	update((a+b)/2+1,b,c,d,e*2+1,f);
}
int query(int a){
	a+=524288;
	int ret=mod;
	while(a){
		ret=min(segtree[a],ret);
		a/=2;
	}
	return ret;
}
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d%d%d",S+i,T+i,X+i);
		z[i*2]=S[i]-X[i];
		z[i*2+1]=T[i]-X[i];
	}
	z[a*2]=-mod;
	std::sort(z,z+a*2+1);
	for(int i=0;i<(1<<20);i++)segtree[i]=mod;

	for(int i=0;i<a;i++){
		int L=lower_bound(z,z+a*2+1,S[i]-X[i])-z;
		int R=lower_bound(z,z+a*2+1,T[i]-X[i])-z-1;
		update(0,524287,L,R,1,X[i]);
	//	printf("%d %d %d\n",L,R,X[i]);
	}
	for(int i=0;i<b;i++){
		int t;scanf("%d",&t);
		int at=upper_bound(z,z+a*2+1,t)-z-1;
	//	printf("%d\n",at);
		int ret=query(at);
		if(ret==mod)ret=-1;
		printf("%d\n",ret);
	}
}


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

int main() {
    ll n,k;
    cin>>n>>k;
    cout<<fixed<<setprecision(12);
    double sum=0;
    for(ll i=1;i<=n;i++) {
        ll number=i;
        double pownum=0;
        while(number<k){
            number*=2;
            pownum++;
        }
        sum+=pow(0.5,pownum);
    }
    cout<<sum/n<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=100005;
int n,t[N],x[N],y[N];
inline int Abs(int x){return x>0?x:-x;}
int main(){
	//freopen("aa.in","r",stdin);
	int i,j,k;
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d%d%d",&t[i],&x[i],&y[i]);
	for(i=0;i<n;++i){
		int dis=Abs(x[i]-x[i+1])+Abs(y[i]-y[i+1]);
		int tmp=t[i+1]-t[i];
		if(dis>tmp||(tmp-dis)%2)return puts("No"),0;
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 1408
def run(N):
    lists = [N-1]
    for i in range(2, int(N**(1/2))+1):
        if N % i == 0:
            lists.append(i + (N // i) - 2)
    return min(lists)


def main():
    N = int(input())
    print(run(N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vpii=vector<pii>;

#define PI 3.1415926535897932384626433832795

int main(void)
{
	char s[3+2];
	while(scanf("%3[AB]\n", s)==1)
	{
		bool ans=false;
		if(s[0]!=s[1] || s[1]!=s[2]) ans=true;
		printf("%s\n", ans?"Yes":"No");
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N,K;
    cin >> N >> K;
    if(K%2==1){
        ll num = N/K;
        cout << num*num*num << endl;
    }else{
        ll num = N/K;
        ll num2 = N/(K/2) - num;
        ll ans = num*num*num + num2*num2*num2;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;


int main (int argc, char const *argv[])
{
    int T,X;
    cin>>T>>X;

    double ans=double(T)/X;
    cout<<ans<<endl;
    return 0;
}

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

int main() {
  int A,N,C;
  cin >> N >> A;
  C = N % 500;
  
  if (C <= A){
    cout << "Yes" << endl;
  }else if (C > A){
    cout << "No" << endl;
  }return 0;
}


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

int main(){
  
  long long N, M;
  cin >> N >> M;
  
  if(M<N*2){
    cout << M/2 << endl;
  }else{
    M = M-2*N;
    cout << N+M/4 << endl;
  }
  return 0;
}

Measured memory_bytes: 3584
def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = float('inf')
    for a in A:
        cnt = 0
        if a%2 != 0:
            ans = 0
            break
        for _ in range(1, 31):
            a = a//2
            cnt += 1
            if a%2==1:
                break
        ans = min(ans, cnt)
    
    print(ans)

if __name__ == "__main__":
    main()


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

const int maxn = 2e5 + 10;
typedef long long int ll;
struct edge{
	int v,next;
	edge(){}
	edge(int a,int b):v(a),next(b){}
}e[maxn << 1];
int head[maxn << 1],tot;
int f[maxn];
bool vis[maxn << 1];
vector<int>G[maxn << 1];
void bfs(){
	queue<int>st;
	st.push(1);
	vis[1] = true;
	while(!st.empty()){
		int u = st.front();st.pop();
		for(int i = 0; i < G[u].size(); i++){
			int v = G[u][i];
			if(!vis[v]){
				f[v] = u;
				vis[v] = true;
				st.push(v);
			}
		}
	}
}
void solved(){
	int n,m;cin>>n>>m;
	for(int i = 1; i <= m ;i++) {
		int u,v;cin>>u>>v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	bfs();
	for(int i = 2; i <= n; i++){
		if(!vis[i]){
			cout<<"No"<<endl;return ;
		}
	}
	cout<<"Yes"<<endl;
	for(int i = 2; i <= n; i++){
		cout<<f[i]<<endl;
	}
}
int main(){
	solved();
	return 0;
}

Measured memory_bytes: 17496
#include <iostream>
using namespace std;
int W, H, x, y, r, No, Yes;
int main() {
	
	cin>> W >> H >> x >> y >> r;
	if(x + r <= W && x - r >= 0 && y + r <= H && y - r >= 0){
		cout<< "Yes" <<endl;
	}else{
		cout<< "No" <<endl; 
	}
}



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

typedef int in;
#define int long long
int MAX=1e9;
int MAXEST=1e18;
int MOD=1e9+7;

int n,w,sum;
int v[105],s[105];
int dp[105][100005];

int f(int idx,int rem)
{
    if(idx==n)
        return (rem==0?0:MAX);
    int &ret=dp[idx][rem];
    if(ret!=-1)
        return ret;
    ret=f(idx+1,rem);
    if(rem-v[idx]>=0){
        ret=min(ret,f(idx+1,rem-v[idx])+s[idx]);
    }
    return ret;
}

in main()
{
    int tc=1;
//    cin>>tc;
    while(tc--)
    {
        cin>>n>>w;
        sum=0;
        for(int i=0;i<n;i++){
            cin>>s[i]>>v[i];
            sum+=v[i];
        }
        memset(dp,-1,sizeof dp);
        for(int i=sum;i>=0;i--){
            if(~dp[0][i])
                continue;
            f(0,i);
        }
        for(int i=sum;i>=0;i--){
            if(dp[0][i]>w)
                continue;
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
vector<vector<pi > > G;
vector<bool > seen;
vector<ll > ans;
ll color_mx = -1;
//辺をデータとして持っておく
map<pi, ll> edge;

void dfs(ll idx, ll from = -1){
    seen[idx] = true;
    //始点の前には辺がない
    if(from == -1){
        edge[make_pair(from, idx)] = -1;
    }

    ll cn = 1;
    for(ll i = 0; i < G[idx].size(); i++){

        //次の行き先は？
        ll to = G[idx][i].first;
        //どっからきた？
        ll t_from = G[idx][i].second;
        //探査済み
        if(seen[to] == true){
            continue;
        }
        //前の辺が同じ色だったら同じ色には塗らない
        if(edge[make_pair(from, idx)] == cn){
            cn++;
        }
        //cout << cn << endl;
        edge[make_pair(idx, to)] = cn;
        //cout << t_from << " " << cn << endl;
        ans[t_from] = cn;
        cn++;
        dfs(to , idx);
    }

    color_mx = max(cn-1, color_mx);

}

int main(){
    ll N;
    cin >> N;
    //初期化
    G.assign(N, vector<pi >());
    seen.assign(N, false);
    ans.assign(N - 1, 0);
    
    //グラフ入力
    for(ll i = 0; i < N - 1; i++){
        ll u, v, w;
        w = 0;
        cin >> u >> v;
        u--;
        v--;
        //双方向に貼りましょうね
        G[u].push_back(make_pair(v, i));
        G[v].push_back(make_pair(u, i));
    }

    //根っこの色は1（初期値）
    dfs(0);

    cout << color_mx << endl;

    for(ll i = 0; i < N - 1; i++){
        cout << ans[i] << endl;
    }

}

Measured memory_bytes: 16128
ABC=input()
ABC=ABC.rstrip().split(" ")
A=int(ABC[0])
B=int(ABC[1])
C=int(ABC[2])

a1=abs(A-B)+abs(B-C)
a2=abs(A-C)+abs(C-B)
a3=abs(B-A)+abs(A-C)
a4=abs(B-C)+abs(C-A)
a5=abs(C-A)+abs(A-B)
a6=abs(C-B)+abs(B-A)

list1=[a1,a2,a3,a4,a5,a6]
list1.sort()
print(list1[0])

Measured memory_bytes: 3188
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
	long long n;
	cin >> n;
	if (n % 2){
		cout << 0 << endl;
		return 0;
	}
	long long a = 10;
	long long ans = 0;
	while (a <= n){
		ans += n / a;
		a *= 5;
	}
	cout << ans << endl;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

  int n, k;
  cin >> n >> k;

  ll ans = 0;
  if(k == 0){
    REP1(i, n+1){
      ans += n/i * max(0, i-k);
      if(n%i != 0)
        ans += max(n%i-k, 0);
    }
  }
  else{
  REP1(i, n+1)
    ans += n/i * max(0, i-k) + max(n%i-k+1, 0);
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i=0; i<(n); ++i)
inline void chmax(long long &a, long long b) {
    if (a < b) a = b;
}

int main() {
    int n, w;
    cin >> n >> w;
    vector<long long> we(n), va(n);
    rep(i, n) cin >> we[i] >> va[i];
    vector<vector<long long>> dp(n+1, vector<long long>(w+1));
    rep(i, n) {
        rep(j, w+1) {
            chmax(dp[i+1][j], dp[i][j]);
            if (j >= we[i]) {
                chmax(dp[i+1][j], dp[i][j-we[i]] + va[i]);
            }
        }
    }
    cout << dp[n][w] << endl;
}

Measured memory_bytes: 80256
#include<stdio.h>
int main(){
  int n,i;
  double p;
  double x[11];
  char u[11];
  
  scanf("%d\n",&n);
  for(i=1;i<=n;i++){
    scanf("%lf %s\n",&x[i],&u[i]);
    if(u[i]=='B'){
      p=p+(x[i]*380000.0);
    }
    else{
    p=p+x[i];
  }
  }
  printf("%f",p);
  
  return 0;
}

Measured memory_bytes: 128
//created by Ruchir Mehta
#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include<cmath>
#include<iomanip>
#define fast ios_base::sync_with_stdio(0)
#define fast_in cin.tie(0)
#define fast_out cout.tie(0)
#define ll long long
#define MAX 1000000
#define MAX_MAX 10000000000
#define pb push_back
#define ppbk pop_back
#define mp make_pair
#define precise(i) cout<<fixed<<setprecision(i)
#define f first
#define s second
#define in insert
#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,k,n) for(ll i=k;i<n;i++)
#define pll pair<ll,ll>
#define V vector<ll>
#define VV vector<V>
#define Mll map<ll,V>
#define Vpll vector<pll>
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define Sll set<ll>
#define MAXN 105
#define MOD 998244353
#define dg(x) cerr<<#x<<':'<<x<<endl;
#define dg2(x,y) cerr<<#x<<':'<<x<<' '<<#y<<':'<<y<<endl;
#define dg3(x,y,z) cerr<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<endl;
#define dg4(x,y,z,zz) cerr<<#x<<':'<<x<<' '<<#y<<':'<<y<<' '<<#z<<':'<<z<<' '<<#zz<<':'<<zz<<endl;
using namespace std;
template <class T> using vec = vector<T>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const double PI = 3.141592653589;
const char nl = '\n';
//ll random=uniform_int_distribution<int>(start,end)(rng);

/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     ListNode *next;
 *     ListNode(int x) : val(x), next(NULL) {}
 * };
 */
 


ll binpow(ll a, ll b, ll m) 
{
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

//void dfs(ll a,vector<ll> adj[])
//{
//static unordered_set<ll> bag;
//if(bag.find(a)==bag.end())
//{
//bag.insert(a);
//cout<<a<<"\n";
//for(auto it:adj[a])
//dfs(it,adj);
//}
//}

void solve()
{
//	   clock_t time_req;
//    time_req = clock();
	ll n; 
	cin >> n;
    V a(n);
	rep(i,n)
	cin>>a[i];
    sort(all(a));
    vec<bool> ok(1000005,true);
    rep(i,n)
	{
        if(ok[a[i]] == false)continue;
        
		if(i != n-1)
		if(a[i] == a[i+1])
		ok[a[i]] = false;
        
		for(ll j = 2*a[i] ; j < 1000005;j += a[i])
        ok[j] = false;
    }
    ll ans = 0;
    rep(i,n){
        if(ok[a[i]])
		ans++;
    }
    cout << ans << endl;
//	time_req = clock()-time_req;
//    cout<<"Time taken: "<<(float)time_req/CLOCKS_PER_SEC<<"s"<<endl;
}

int main()
{
fast;
fast_in;
fast_out;
ll no=1;

// cin>>no;
while(no--){
	solve();
}
return 0;
}

//Don’t keep debug print statements while submitting :stuck_out_tongue:

Measured memory_bytes: 5068
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int n,r,c,p;
		int[] card,card2;
		card=new int[51];
		card2=new int[51];
		while(1>0){
			n=sc.nextInt();
			r=sc.nextInt();
			if(n+r==0)break;
			for(int i=1;i<=n;i++)card[i]=n-i+1;
			for(int i=0;i<r;i++){
				p=sc.nextInt();
				c=sc.nextInt();
				for(int j=1;j<=c;j++)card2[j]=card[j+p-1];
				for(int j=c+1;j<=p+c-1;j++)card2[j]=card[j-c];
				for(int j=1;j<=p+c-1;j++)card[j]=card2[j];
			}
			System.out.println(card[1]);
		}
	}
}

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

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> l(n);
    for (int i = 0; i < n; i++) cin >> l[i];

    sort(l.begin(), l.end(), greater<int>());

    int snake = 0;
    for (int i = 0; i < k; i++) snake += l[i];

    cout << snake << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0; i<(n); ++i)
#define REPR(i,n,m) for (int i=(n); i>=(m); --i)
using namespace std;
using LL = long long;
using LD = long double;
using PLL = pair<long long, long long>;
using PLD = pair<long double, long double>;
using VLL = vector<long long>;
using VLD = vector<long double>;
using VPLD = vector<PLD>;

const int INF = numeric_limits<int>::max();

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

    LL n, y; cin >> n >> y;

    for (int i=0; i<=n; i++) {
        for (int j=0; j<=n-i; j++) {
            if (i*9000+j*4000==y-n*1000) {
                if (i*10000+j*5000+(n-i-j)*1000==y) {
                    cout << i << " " << j << " " << n-i-j << endl;
                    return 0;
                }
            }
        }
    }

    cout << "-1 -1 -1" << endl;

    return 0;
}

Measured memory_bytes: 3588
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author EDGE
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, FastReader in, PrintWriter out) {
            long ans = (long) Math.pow(in.nextInt(), 2);
            out.println(ans);
        }

    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader(InputStream inputStream) {
            br = new BufferedReader(new
                    InputStreamReader(inputStream));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
#define N 500010

// fenwick tree
int f[N];
void init(){for(int i=0;i<=N;i++)f[i]=0;}

void add(int i, int x){for(;i<=N;i+=i&-i)f[i]+=x;}

int sum(int i)
{
    int ret=0;
    for(;i>0;i-=i&-i)ret+=f[i];
    return ret;
}

int rangesum(int l, int r){return sum(r)-sum(l-1);}
// fenwick tree

int c[N];
vector<int> ql[N],qid[N];

int ans[N];

int a[N];

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

    for(int i=0;i<n;i++)cin>>c[i];

    for(int i=0;i<q;i++)
    {
        int l,r;
        cin>>l>>r;

        ql[r].push_back(l);
        qid[r].push_back(i);
    }

    for(int i=1;i<=n;i++)
    {
        if(a[c[i-1]]>0)add(a[c[i-1]],-1);
        add(i,1);
        a[c[i-1]]=i;

        for(int j=0;j<ql[i].size();j++)
        {
            ans[qid[i][j]]=rangesum(ql[i][j],i);
        }
    }

    for(int i=0;i<q;i++)cout<<ans[i]<<endl;

    return 0;
}



Measured memory_bytes: 52952
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007,M=1e5+5;
struct edge{
	int to,nxt;
}Edge[M<<2];
int head[M];
int tot,n,k;

long long ans=1;

void Add(int x, int y){
	Edge[++tot]=(edge)<%y,head[x]%>;
	head[x]=tot; 
}

void dfs(int x, int fa, int minus){
	int res=0;
	for(int i=head[x]; i; i=Edge[i].nxt){
		int y=Edge[i].to;
		if(y==fa) continue;
		ans=(ans*1ll*(k-minus-res))%mod; res++; dfs(y,x,min(minus+1,2));
	}
}

int main(){
	scanf("%d %d",&n,&k); ans=1ll*k;
	for(int i=1,x,y; i<n; i++) scanf("%d %d",&x,&y),Add(x,y),Add(y,x);
	dfs(1,0,1);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6912
n, m = map(int, input().split())
a = input().split()
for i in range(m):
	a[i] = int(a[i])
a = sorted(a)
b = []
for i in range(m - 1):
	b.append(a[m - 1 - i] - a[m - 2 - i])
b = sorted(b)
if n >= m:
	print(0)
else:
	b = b[:m - n]
	print(sum(b))

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

long long n,m,c,x,y,a,b,t,dt, hasil=0, tag, dist;
int arr[200001];
bool mulai[200001];
bool sel[200001];
bool valid = true;

int main() {
    cin >> m;
    a = 0;
    b = 0;
    for (int i = 1; i <= m; i++){
        cin >> t >> x >> y;
        dt = t-hasil;
        dist = (abs(x-a) + abs(y-b));
        if ( (dt-dist)% 2 == 0 && dt >= dist){
            a = x;
            b = y;
            hasil = t;
        }
        else {
            valid = false;
            break;
        }
        
    }
    if(valid == true){
        cout << "Yes" << endl;
    }
    else cout << "No" <<  endl;
   
}
    

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

#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define mp make_pair
typedef long long ll;
const ll INF = 1LL << 60;
const ll mod = 1e9 + 7;
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;
}

ll modpow(ll a, ll p)
{
    if (p == 0)
        return 1;
    if (!(p % 2))
    {
        ll halfP = p / 2;
        ll half = modpow(a, halfP);
        return half * half % mod;
    }
    else
    {
        return a * modpow(a, p - 1) % mod;
    }
}

ll comb(int a, int b)
{
    if (b > a - b)
        return comb(a, a - b);
    ll ansMul = 1;
    ll ansDiv = 1;
    for (int i = 0; i < b; i++)
    {
        ansMul *= a - i;
        ansDiv *= i + 1;
        ansMul %= mod;
        ansDiv %= mod;
    }
    ll ans = ansMul * modpow(ansDiv, mod - 2) % mod;
    return ans;
}

/*
int num = 200010;
vector<ll> fact(num), ifact(num);
fact[0] = 1;
fact[1] = 1;
for (int i = 2; i < num; i++) {
    fact[i] = fact[i-1] * i;
    fact[i] %= mod;
}
for (int i = 0; i < num; i++) {
    ifact[i] = modpow(ifact[i], mod-2);
    ifact[i] %= mod;
}
*/

int main() {
    int N; cin >> N;
    vector<int> a(N), b(N);
    rep(i, N) cin >> a[i];
    rep(i, N) cin >> b[i];
    ll cnt = 0;
    rep(i, N) {
        if (a[i] < b[i]) {
            cnt += (b[i] - a[i]) / 2;
        } else {
            cnt -= a[i] - b[i];
        }
    }
    if (cnt >= 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, a[N];
int main() {
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a, a + n, greater<int>());
	int lst1 = n, lst2 = n;
	for (int i = 0; i < n; i++) {
		if (a[i] < i + 1) {
			lst1 = i;
			break;
		}
	}
	for (int i = lst1 - 1; i < n; i++) {
		if (a[i] >= lst1)
			lst2 = i;
	}
//	cout << " : " << lst1 << " " << lst2 << " : " << a[lst1] << endl;
	if ((a[lst1 - 1] - lst1) % 2 == 1 || (lst2 - (lst1 - 1)) % 2 == 1)
		cout << "First";
	else
		cout << "Second";
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#define FORi(N) for(int i=0;i<N;++i)
using namespace std;
using ll = long long;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
int main(){
  ll N;
  cin>>N;
  ll ans=0;
  FORi(N){
    ll tmp;
    cin>>tmp;
    while(tmp%2==0){
      tmp/=2;
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

using namespace std;

typedef long long llint;

int main() {
  int n, a, b, c, x;
  while (cin >> n >> a >> b >> c >> x, n) {
    vector<int> y(n);
    for (int i = 0; i < n; i++) {
      cin >> y[i];
    }
    bool flag = true;
    int ans = 0;
    for (int i = 0; i < n; i++) {
      while (y[i] != x && ans < 10001) {
        ans++;
        x = (a * x + b) % c;
        // cout << x << endl;
      }
      if (i + 1 < n) ans++, x = (a * x + b) % c;
      // cout << ans << endl;
    }

    if (ans < 10001) {
      cout << ans << endl;
    } else {
      cout << -1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3032
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            long X = Long.parseLong(in.next());
            long Y = Long.parseLong(in.next());
            long ans = X;
            boolean ok = true;
            if (X % Y == 0) ok = false;
            if (ok) out.println(ans);
            else out.println(-1);
        }

    }
}



Measured memory_bytes: 22996
import java.util.Scanner;

/**
 * A - Study Scheduling
 *
 * https://atcoder.jp/contests/nomura2020/tasks/nomura2020_a
 *
 */
public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h1 = sc.nextInt();
    int m1 = sc.nextInt();
    int h2 = sc.nextInt();
    int m2 = sc.nextInt();
    int k = sc.nextInt();
    int tm1 = (h1 * 60) + m1;
    int tm2 = (h2 * 60) + m2;
    if(tm1 > tm2){
      tm1 += (24 * 60);
    }
    int answer = tm2 - tm1 - k;
    System.out.print(answer);
  }
}

Measured memory_bytes: 35776
def d(n):
    d=1
    while n>=10:
        d+=1
        n//=10
    return d

def top(n):
    return n//(10**(d(n)-1))

def isalmostall9(n):
    return n+1==(top(n)+1)*(10**(d(n)-1))

N=int(input())
if isalmostall9(N):
    ans=top(N)+9*(d(N)-1)
else:
    ans=top(N)-1+9*(d(N)-1)

print(ans)

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

int main()
{
	int d,n;
	scanf("%d %d",&d,&n);
	if(d==0)
	{
		if(n<100)
			printf("%d\n",n);
		else
			printf("101\n");
	}
	else if(d==1)
	{
		int ans=n*100;
		if(n==100)
			ans+=100;;
		printf("%d\n",ans);
	}
	else
	{
		int t2=n*100*100;
		if(n==100)
			t2+=(100*100);
		printf("%d\n",t2);
	}
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
MOD = 10**9 + 7
ans = 0

x = [0 for _ in range(k+1)]

for i in range(k, 0, -1):
    x[i] = pow(k//i, n, MOD)
    for j in range(2*i, k+1, i):
        x[i] -= x[j]
        x[i] %= MOD
    ans += i * x[i] % MOD
    ans %= MOD
print(ans)


Measured memory_bytes: 74000
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    long long n,ll=0;
    cin>>n;
    long long a,lis[n];
    f(i,0,n){
        cin>>a;
        if(i==0){
            lis[i]=a;
        }
        else{
            if(lis[ll]<a){
                ll++;
                lis[ll]=a;
            }
            else{
                f(j,0,ll+1){
                    if(lis[j]>=a){
                        lis[j]=a;
                        break;
                    }
                }
            }
        }
    }
    cout<<ll+1<<endl;
    return 0;
}


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

int main()
{
    ll n, max_weight;
    cin >> n >> max_weight;
    vector<ll> profit(n+1);
    vector<ll> weight(n+1);
    for(ll i = 1; i <= n; i++)
    {
        cin >> weight[i];
        cin >> profit[i];
    }
    vector<ll> dp(max_weight + 1);
    for(ll i = 1; i <= n; i++)
        for(ll j = max_weight - weight[i]; j >= 0; j--)
            dp[j + weight[i]] = max(dp[j + weight[i]], dp[j] + profit[i]);

    cout << *max_element(dp.begin(), dp.end());
    return 0;
}


Measured memory_bytes: 4032
// AtCoder Beginner Contest 155 A.cpp

#include <iostream>

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b || a == c || b == c) {
		if (a == b && b == c) {
			cout << "No" << endl;
		}
		else {
			cout << "Yes" << endl;
		}
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
using LL = long long;

class Solution {
public:
	LL modsum(LL n) {
		return (1 + (n - 1)) * (n - 1) / 2;
	}
};

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

	Solution sol;
	LL ans = sol.modsum(n);
	cout << fixed << ans << endl;
	return 0;
}


Measured memory_bytes: 256