akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
 
using namespace std;
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 
 
 

int main()
{
    ll n;
    cin>>n;
    vector <pair<ll,ll > > xyz(n);
    vector <ll> x(n+1);
    vector <ll> d(n+1);
    for(int i=1;i<=n;i++)
    {
        cin>>x[i]>>d[i];
        xyz[i-1]=make_pair(x[i],d[i]);
        //cout<<x[i]<<" "<<d[i]<<endl;
    }
    sort(xyz.begin(),xyz.end());
    for(int i=1;i<=n;i++)
    {
        x[i]=xyz[i-1].first;
        d[i]=xyz[i-1].second;
    }
    //for(int i=1;i<=n;i++)
        //cout<<x[i]<<" "<<d[i]<<endl;
    vector <ll> danger(n+1);
    stack <ll> s;
    for(int i=n;i>=1;i--)
    {
        while(s.size()>0&&x[s.top()]<x[i]+d[i])
        {
            danger[s.top()]=i;
            s.pop();
        }
        s.push(i);
    }
    while(s.size()>0)
    {
        danger[s.top()]=0;
        s.pop();
    }
    ll mod=998244353;
    vector <ll> prefix(n+1);
    prefix[0]=1;
    for(int i=1;i<=n;i++)
    {
        ll test;
        if(danger[i]==0)
            test=prefix[i-1];
        else
            test=(prefix[i-1]+mod-prefix[danger[i]-1])%mod;

        prefix[i]=(prefix[i-1]+test)%mod;
        //cout<<i<<" "<<danger[i]<<" "<<test<<" "<<prefix[i]<<endl;
    }

    cout<<prefix[n]<<endl;

    return 0;   
}
 
 


Measured memory_bytes: 10268
local mod=1000000007
local function powmod(x,n)
    local a=1
    for i=1,n do
        a=(a*x)%mod
    end
    return a
end

----------

local n=io.read("n")
local total=powmod(10,n)
local zorn=powmod(9,n)
local zandn=powmod(8,n)
print((total-zorn-zorn+zandn)%mod)

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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

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

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    int K = input() + 1;
    
    i64 sum = 0;
    range(a, 1, K) range(b, 1, K) range(c, 1, K) {
        sum += gcd(a, gcd(b, c));
    }
    
    cout << sum << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;
long long n,m,q;
long long ans=0;
//bool oget[15]={};

vector<pair<int,int>>query(55);
int diff[55];
long long value[55];
long long second[11];
//status unsolved

void check(vector<int>A){
    long long total=0;
    rep(k,q){
        int a=query[k].first;
            int b=query[k].second;
            if(A[b]-A[a]==diff[k]){
                total+=value[k];
        }
    }
    ans=max(ans,total);
    return;
}

void dfs(vector<int>A){
    if(A.size()==n){
        check(A);
        return;
    }
    else{
        int p=A.size();
        vector<int>v(p+1);
        int start=1;
        if(p>0){
            rep(k,p)v[k]=A[k];
            start=v[p-1];
        }
        

        
        for(int i=start;i<=m;i++){
            v[p]=i;
            dfs(v);
        }
        
        return;
    }
}
int main(){
    
    
    cin>>n>>m>>q;
    
    second[0]=1;

    rep(i,10)second[i+1]=second[i]*2;

    rep(i,q){
    int a,b;
    long long c,d;
    cin>>a>>b>>c>>d;
    a--,b--;
    query[i]=make_pair(a,b);
    diff[i]=c;
    value[i]=d;
    }
    
    
    vector<int>A;
    
    dfs(A);
    
    
    cout<<ans<<endl;
    //rep(i,n)cout<<p[i]<<" ";
    //cout<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    string tmp = "";
    rep(i, (int)s.size()/2) {
        tmp += s[i];
    }
    string tmp2 = "";
    for (int i=s.size()-1; i>=(int)s.size()/2; --i) {
        tmp2 += s[i];
    }
    int ans = 0;
    rep(i, tmp.size()) {
        if (tmp[i] != tmp2[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
  char ban[9];
  int hoge[9];
  int tmp[8][3]={{0,1,2},{3,4,5},{6,7,8},{0,3,6},{1,4,7},{2,5,8},{0,4,8},{2,4,6}};
  while(true){
    int hatena = -1;
    cin >> ban[0];
    if(ban[0]=='0') break;
    for(int i=1;i<9;i++) cin >> ban[i];
    for(int i=0;i<9;i++) hoge[i] = (ban[i]=='b'?1:(ban[i]=='w'?-1:0));
    for(int i=0;i<8;i++){
      bool ok=false;
      int bw = 0;
      for(int j=0;j<3;j++)bw += hoge[tmp[i][j]];
      if(bw==-3){
	hatena = 1;
	break;
      }	else if(bw==3){
	hatena = 2;
	break;
      }
    }
    cout << (hatena==1?"w":(hatena==2?"b":"NA")) << endl;
  }
}

Measured memory_bytes: 1132
//start of jonathanirvings' template v3.0.3 (BETA)

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

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)

inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}

inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}

inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  #ifndef TESTING
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
  #endif
}

//end of jonathanirvings' template v3.0.3 (BETA)

LL n,a,b;

int main()
{
  scanf("%lld %lld %lld",&n,&a,&b);
  if (abs(a-b) % 2 == 0) printf("%lld\n",abs(a-b)/2); else
  {
    if (a > b) swap(a,b);
    LL risan = INFF;
    {
      LL now = a;
      LL x = b - now;
      MIN(risan,now + (x - 1)/2);
    }
    {
      LL now = (n - b) + 1;
      LL x = a + now;
      MIN(risan,now + (n - x) / 2);
    }
    printf("%lld\n",risan);
  }
  return 0;
}











Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define M 1000000007
using namespace std;
int n,W;
int w[101],v[101];
ll dp[101][100001]={0};
ll recursion(int weight_left,int index)
{
    if(weight_left<=0 || index>=n)
    {
        return 0;
    }
    if(dp[index][weight_left]!=0)
    {
        return dp[index][weight_left];
    }
    if(weight_left<w[index])
    {
        return recursion(weight_left,index+1);
    }
    dp[index][weight_left]= max(v[index]+recursion(weight_left-w[index],index+1),recursion(weight_left,index+1));
    return dp[index][weight_left];
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);
    
    cin>>n>>W;
   
    for(int i=0;i<n;i++)
    {
        cin>>w[i]>>v[i];
    }
    cout<<recursion(W,0);
}


Measured memory_bytes: 76416
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print2(#a,a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}

const int maxn=105;
//i_am_noob
ld a,b;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cout << fixed << setprecision(12);
	cin >> a >> b;
	print1(a/b);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX (ll)(5e3 + 4)
#define MOD (ll)(1e9 + 7)
#define PI (double)(3.14159265)
#define IO ios_base :: sync_with_stdio (false), cin.tie (nullptr);

using namespace std;
using ll = long long;
using ld = long double;

int main () {
	string st;
	cin >> st;
	int co = 0;
	for (int i = 0; i < st.size (); i++) {
		if (st[i] != st[(int)st.size () - i - 1]) {
			co++;
		}
	}
	cout << co / 2 << "\n";
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll dp[405][405],mul[405][405];
int n,c,a[405],b[405];
ll modpow(ll x,ll n)
{
	ll res=1;
	while(n>0)
	{
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
int main(){
	cin >> n >> c;
	for(int i=1;i<=n;i++)cin >>a[i];
	for(int i=1;i<=n;i++)cin >>b[i];
	for(int i=0;i<=c;i++){
		for(int j=1;j<=n;j++){
			for(int k=a[j];k<=b[j];k++){
				mul[j][i] = mul[j][i]+modpow(1LL*k,1LL*i)%mod;
				mul[j][i] %= mod;
			}
		}
	}
	dp[0][0] = 1;
	for(int i=0;i<n;i++){
		for(int j=0;j<=c;j++){
			if(dp[i][j] == 0) continue;
			for(int x=0;x<=c-j;x++){
				dp[i+1][j+x] += dp[i][j]*mul[i+1][x]%mod;
				dp[i+1][j+x] %= mod;
			}
		}
	}
	cout << dp[n][c] << endl;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
typedef pair< int,int > pi;

double Distance(pi u,pi v){
    double ans = ((u.first-v.first)*(u.first-v.first) + (u.second-v.second)*(u.second-v.second))*1.0;
    ans = sqrt(ans*1.0);
    return ans;
}

int factorial(int n){
    if(n == 1)  return 1;
    return n*factorial(n-1);
}

int main()
{
    int n;
    double sum = 0;

    cin >> n;

    vector< pi > towns;

    for(int i = 0;i<n;i++){
        int a,b;
        cin >> a >> b;
        towns.push_back(make_pair(a,b));
    }

    int fact = 2*factorial(n-1);

    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            double ans = Distance(towns[i],towns[j]);
            sum += fact*ans;
        }
    }

    cout.precision(10);
    cout << fixed << sum/factorial(n) << endl;

    return 0;
}


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

using namespace std;

#define ll long long
#define rep(cnt,a,n) for(ll cnt=a;cnt<n+a;cnt++) //aから始めてn回ループ
#define vector2(type,name,a,b) vector<vector<type>> name(a, vector<type>(b))



int main()
{   
    ll k;
    ll a;
    ll b;
    cin >> k;
    cin >> a;
    cin >> b;
    for (ll i = a; i <= b; i++) {
        if (i % k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;

    return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define REP(i,n) rep(i,0,n);
const int MIN_INT = -9999999;

int main(int argc, char *argv[]) {
	int dataN;
	while (EOF != fscanf(stdin, "%d", &dataN)) {
		if (dataN == 0) break;
		const int c_N = dataN;
		int tmp, sums[c_N], max_v=MIN_INT;
		memset(sums, 0, sizeof(sums));
		for (int i = 0; i < c_N; i++) {
			fscanf(stdin, "%d", &tmp);
			sums[i] += tmp;
			max_v = max(max_v, sums[i]);
			for (int j = 0; j < i; j++) {
				sums[j] += tmp;
				max_v = max(max_v, sums[j]);
			}
		}
		printf("%d\n", max_v);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define int long long
#define fi first
#define se second
using namespace std;

const int maxN = 2e5 + 10;
const int inf = 1e18;

typedef pair<int, int> ii;

int n, m, sum, st[maxN * 4], lazy[maxN * 4];

vector <ii> a[maxN];

void push(int id){
    st[id * 2] += lazy[id];
    lazy[id * 2] += lazy[id];
    st[id * 2 + 1] += lazy[id];
    lazy[id * 2 + 1] += lazy[id];
    lazy[id] = 0;
}

void update(int x, int y, int d, int id = 1, int l = 0, int r = n){
    if(x > r || l > y)
        return;

    if(l >= x && r <= y){
        st[id] += d;
        lazy[id] += d;
        return;
    }

    int mid = (l + r) / 2;
    push(id);
    update(x, y, d, id * 2, l, mid);
    update(x, y, d, id * 2 + 1, mid + 1, r);
    st[id] = max(st[id * 2],st[id * 2 + 1]);
}

int get(int x, int y, int id = 1, int l = 0, int r = n){
    if(x > r || l > y)
        return -inf;

    if(l >= x && r <= y)
        return st[id];

    int mid = (l + r) / 2;
    push(id);
    return max(get(x, y, id * 2, l, mid), get(x, y, id * 2 + 1, mid + 1, r));
}

int32_t main()
{
    ios_base::sync_with_stdio(false); cin.tie(); cout.tie();
    cin >> n >> m;

    for(int i = 0; i < m; ++i){
        int l,r,x;
        cin >> l >> r >> x;
        a[r].push_back({l,x});
        sum += x;
    }

    update(0, n,sum);
    for(int i = 1; i <= n; ++i){
        update(i, i, get(0, i - 1) - sum);
        for(auto j : a[i])
            update(0, j.fi - 1, -j.se);
    }

    cout << st[1] << endl;
}


Measured memory_bytes: 22700
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N, L;
    cin >> N >> L;
    
    int t[200], sum = 0, min = INT_MAX;
    for(int i=0;i<N;i++){
        t[i] = L + i;
        sum += t[i];
        if(abs(t[i]) < min)
            min = abs(t[i]);
    }
        
    if(t[0] >= 0){   // 全て正
        cout << sum - t[0] << endl;
    }else if(t[N-1] <= 0){
        cout << sum - t[N-1] << endl;
    }else{
        cout << sum - min << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

vector<vector<int> > v(9);
int n,m,ans=0;
void solve(int,int,vector<int>);
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>m;
    int a,b;
    for(int i=0;i<m;i++){
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    vector<int> maki;
    maki.pb(1);
    solve(1,1,maki);
    cout << ans<<endl;
    return 0;
}

void solve(int a,int index,vector<int> s){
    if(index==n){
        ans++;
        return;
    }
    s.pb(a);
    index++;
    for(int i=0;i<v[a].size();i++){
        bool maki=true;
        for(int j=0;j<s.size();j++){
            if(v[a][i]==s[j]){
                maki=false;
            }
        }
        if(maki==true){
            solve(v[a][i],index,s);
        }
    }
    return;
}



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

p=0.0
for i in range(1,n+1):
    m=0
#    print(k,i,m,i*2**m)
    while k>i*2**m:
#        print(k,i,m,i*2**m)
        m=m+1
#    print(m)
    p=p+(0.5)**m/n
print(p)

Measured memory_bytes: 2940
import numpy as np

N = int(input())
xl = [int(x) for x in input().split()]

xlsorted = np.sort(xl)
m1 = xlsorted[int(N/2)-1]
m2 = xlsorted[int(N/2)]

for i in range(N):
    if xl[i] <= m1:
        print(m2)
    else:
        print(m1)


Measured memory_bytes: 50152
#include <stdio.h>

int main(){
    
    char c[100000];
    int i=0,j;
    while(1){
        scanf("%c",&c[i]);
        if(c[i]=='\n')
            break;
        i++;
    }
    
    for(j=0;j<i;j++){
        if(c[j]>='A'&&c[j]<='Z')c[j]+=32;
        else if(c[j]>='a'&&c[j]<='z')
            c[j]-=32;
        printf("%c",c[j]);
        if(j==i-1)
            printf("\n");
        
        
    }
    
}



Measured memory_bytes: 2124
# -*- coding: utf-8 -*-
"""
Created on Sun Feb  3 20:43:36 2019

@author: Owner
"""

# -*- coding: utf-8 -*-
"""
Created on Sun Jan 27 20:47:58 2019

@author: Owner
"""


import collections
import scipy.misc
import sys
import numpy as np
import math
from operator import itemgetter
import itertools
import copy

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

"""
N, X = map(int, input().split())

x = [0]*N
x[:] = map(int, input().split())

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())
    
all(nstr.count(c) for c in '753')

ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
#A, B, totAB = zip(*ABT)

"""

N, M = map(int, input().split())

X = [0]*M
X[:] = map(int, input().split())

if N >= M:
    print(0)
    sys.exit()
else:
    pass

X.sort()

if N == 1:
    print(X[M-1]-X[0])
    sys.exit()
else:
    pass

dX = [0]*(M-1)
for m in range(M-1):
    dX[m] = X[m+1] - X[m]
dX = np.array(dX)
dX_rank = dX.argsort()[::-1]

X_div = dX_rank[0:N-1]
X_div.sort()
result =0
cnt = 0
last_idx = 0

#print(X_div)
for nx in X_div:
    if cnt == 0:
        result = result + X[nx]-X[0]
        last_idx = nx
        cnt =+ 1         
    else:
        result = result + X[nx] - X[last_idx+1]
        last_idx = nx
    #print(result)
#print(X[-1], X[last_idx+1])
result = result + X[-1] - X[last_idx+1]

print(result)

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

int main(){
    int n,i;
    cin >> n;
    vector <ll> a(n),b(n),c(n),d(n+1);
    d[n]=0;
    
    rep(i,n){
        cin >> a[i] >> b[i];
    }
    
    
    for (int i=n-1; i>=0 ; --i){
        if ((a[i]+d[i+1])%b[i]==0){
            d[i]=d[i+1];
        }
        else{
        d[i]=b[i]-a[i];
        if (d[i+1]> d[i]){
            d[i]+=((a[i]+d[i+1])/b[i])*b[i];
            

        }
        }

    }

    cout << d[0] << endl;
    

    return 0;
}

Measured memory_bytes: 3328
T1, T2 = map(int, input().split())
A1, A2 = map(int, input().split())
B1, B2 = map(int, input().split())

SA = T1 * A1 + T2 * A2
SB = T1 * B1 + T2 * B2

if SA == SB or A1 == B1:
    print('infinity')
    exit()

if SA > SB and A1 < B1:
    M = (B1 - A1) * T1
    d = SA - SB
    cnt = M // d
    ans = cnt * 2
    if M % d != 0:
        ans += 1
    print(max(0, ans))
elif SB > SA and B1 < A1:
    M = (A1 - B1) * T1
    d = SB - SA
    cnt = M // d
    ans = cnt * 2
    if M % d != 0:
        ans += 1
    print(max(0, ans))
else:
    print(0)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main (String[] args) {
        int N; N = sc.nextInt();
        int K; K = sc.nextInt();
        
        int[] A = new int[N];
        for (int i = 0; i < N; i++) A[i] = sc.nextInt();

        int[] nim = new int[K + 1];
        for (int i = 0; i <= K; i++) nim[i] = 0;

        for (int k = 0; k < K; k++)
            if (nim[k] == 0)
                for (int i = 0; i < N; i++)
                    if (k + A[i] <= K) 
                        if (nim[k + A[i]] == 0) nim[k + A[i]] = 1;

        System.out.println(nim[K] == 1 ? "First" : "Second");
    }
}

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

def solve(N: int, D: int):
    print(math.ceil(N / (2 * D + 1)))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(N, D)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i=l;i<n;i++)
#define rer(i,l,n) for(int i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

vi v,w;
int n;
int dp[1010][1010];

int solve(int i,int j){
	if(dp[i][j]>=0) return dp[i][j];
	int res;
	if(i==n) res=0;
	else if(j<w[i]) res=solve(i+1,j);
	else res=max(solve(i+1,j),solve(i+1,j-w[i])+v[i]);
	return dp[i][j]=res;
}

int main(){
	for(int l=1;;l++){
		int W,x,y;
		v.clear(); w.clear();
		cin>>W;
		if(W==0) break;
		cin>>n;
		rep(i,0,n){
			scanf("%d,%d",&x,&y); v.pb(x); w.pb(y);
		}
		memset(dp,-1,sizeof(dp));
		int MAX=0,ans=0;
		rer(i,1,W){
			if(MAX<solve(0,i)){
				MAX=solve(0,i); ans=i;
			}
		}
		cout<<"Case "<<l<<":"<<endl; o(MAX); o(ans);
	}
}

Measured memory_bytes: 5312
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        long [] height = new long[n + 1];


        long [] cost = new long[n + 1];
        height[0] = 0;
        for (int i = 1; i <= n; ++i) {
            height[i] = scanner.nextLong();
            cost[i] = Long.MAX_VALUE;
        }
        cost[0] = 0L;
        cost[1] = 0L;
        cost[2] = Math.abs(height[2] - height[1]);
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= k && i + j <= n; ++j) {
                cost[i + j] = Math.min(
                        cost[i + j],
                        cost[i] + Math.abs(height[i + j] - height[i])
                );
            }
        }
        System.out.println(cost[n]);

    }
}


Measured memory_bytes: 62728
#include <cstdio>

using namespace std;
int n,ma,mb,x,y,sa,sb,s,i,j,Max,Max1,poz,nr1,a[44],b[44],c[44],nr[2000][2000];
int main()
{
    scanf ("%d %d %d", &n, &ma, &mb);
    for (i=1;i<=n;i++)
        scanf ("%d %d %d", &a[i], &b[i], &c[i]);
    Max=2000000000;
    Max1=0;
    for (i=1;i<(1<<(n/2+n%2));i++)
    {
        x=i;
        poz=1;
        s=0;
        sa=0;
        sb=0;
        while (x>0)
        {
            if (x%2==1)
            {
                s+=c[poz];
                sa+=a[poz];
                sb+=b[poz];
            }
            x/=2;
            poz++;
        }
        if (nr[sa][sb]>s || nr[sa][sb]==0)
            nr[sa][sb]=s;
        if ((sa*mb)==(sb*ma) && nr[sa][sb]<Max)
            Max=nr[sa][sb];
        if ((sa/ma+1)>Max1)
            Max1=sa/ma+1;
    }
    for (i=1;i<(1<<(n/2));i++)
    {
        x=i;
        poz=n/2+n%2+1;
        s=0;
        sa=0;
        sb=0;
        while (x>0)
        {
            if (x%2==1)
            {
                s+=c[poz];
                sa+=a[poz];
                sb+=b[poz];
            }
            x/=2;
            poz++;
        }
        nr1=sa/ma;
        if ((sb/mb)>nr1)
            nr1=sb/mb;
        nr1++;
        for (j=nr1;j<=(10*Max1);j++)
        {
            x=j*ma-sa;
            y=j*mb-sb;
            if (nr[x][y]>0 && (nr[x][y]+s)<Max)
                Max=nr[x][y]+s;
        }
        if ((sa*mb)==(sb*ma) && s<Max)
            Max=s;
    }
    if (Max<2000000000)
        printf ("%d\n", Max);
    else
        printf ("%d\n", -1);
    return 0;
}


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

int main() {
  string S,T;
  cin >>S>>T;
  int cnt=0;
  for(int i =0 ;i<S.size();i++){
    if(S.at(i)!=T.at(i)){
      cout <<"No"<<endl;
      cnt++;
      break;
    }
  }
  if(cnt==0){cout<<"Yes"<<endl;}

}

Measured memory_bytes: 3628
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2")  //Enable AVX

using namespace std;

using ll = long long;

#define mp make_pair

const int p = 1000000007;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

/*struct DSU {
    vector<int> sz;
    vector<int> parent;

    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }

    DSU(int n) {
        sz.resize(n);
        parent.resize(n);
        for (int i = 0; i < n; i++) make_set(i);
    }
};*/

/*const int N = 1000000;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}*/

const int N = 2e5;

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

    int n;
    cin>>n;
    vector<int> a(n);
    for (int i = 0; i<n; i++) cin>>a[i];
    vector<int> cnt(N);
    for (int i = 0; i<n; i++) cnt[a[i]]++;
    vector<int> c;
    for (auto it: cnt) if (it>1) c.push_back(it-1);
    sort(c.begin(), c.end());
    if (c.size()==0) {cout<<n; return 0;}
    int sum = 0;
    for (auto it: c) sum+=it;
    if (sum%2==1) sum++;
    cout<<n - sum;

}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  int ans=0;
  cin>>n;
  cin>>s;
  for(int i=1;i<n;i++){
    int a[30]={},b[30]={};
    for(int j=0;j<n;j++){
      if(j<i)a[s[j]-'a']=1;
      else b[s[j]-'a']=1;
    }
    int sum=0;
    for(int j=0;j<30;j++){
      if(a[j]&&b[j])sum++;
    }
    ans=max(ans,sum);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

if N == 1 and M == 0:
  print(0)
  exit()

sc = [LIST() for _ in range(M)]

ans = [-1]*N
for s, c in sc:	
  if N >= 2 and s == 1 and c == 0:
    print(-1)
    exit()
  if ans[s-1] != -1 and ans[s-1] != c: #既に値が入ってる
    print(-1)
    exit()
  ans[s-1] = c
    
if ans[0] == -1:
  ans[0] = 1

for i in range(N):
  if ans[i] == -1:
    ans[i] = 0
    
for n in ans:
  print(n, end="")

Measured memory_bytes: 5180
import java.util.*;
public class Main {
   private static int h[];
   private static int dp[];


  public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
        h = new int[n];
        dp = new int[n];

        for (int i = 0; i < n; i++) {
          h[i] = sc.nextInt();
        }

		// 30 10 60 10 60 50  
		dp[0] = 0;
		dp[1] = Math.abs(h[0] - h[1]);	//20
		for (int i=2; i < n; i++) {
			dp[i]=aaaa(i);
		}
		System.out.println(dp[n-1]);
	}

	private static int aaaa(int i) {
		int a = Math.abs(h[i] - h[i-1]); //i = 2  50
		int b = Math.abs(h[i] - h[i-2]); //       30

		return Math.min(dp[i-2] + b, dp[i-1] + a);
	}
}





Measured memory_bytes: 51976
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		char[] T = sc.next().toCharArray();
		int N = T.length;
		
		int oneSum = 0;
		ArrayList<Integer> indexes = new ArrayList<>();
		for(int i=0; i<N; i++) {
			if(T[i]=='1') {
				int length = 0;
				for(int j=i; j<N; j++) {
					if(T[j]=='1')
						length++;
					else
						break;
				}
				if(length%2==1) {
					indexes.add(i-(oneSum-indexes.size()));
				}
				oneSum += length;
				i += length;
			}
		}
		
		long zeroSum = N-oneSum;
		long ans = (zeroSum+1)*(oneSum-indexes.size())/2;
		
		for(int i=0; i<indexes.size(); i++) {
			int index = indexes.get(i);
			ans += zeroSum+1 - (index-i+(1+i%2))/2;
		}
		
		for(int i=oneSum-1; i>=1; i--) {
			ans += (i+1)/2;
		}
		
		System.out.println(ans);
		sc.close();
	}

}



Measured memory_bytes: 34404
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
		String x = sc.next();
		String y = sc.next();
		int a;
		a=x.compareTo(y);
		if (a<0){
		System.out.print("<");
        }else if (a>0){
        System.out.print(">");
        }else{
        System.out.print("=");
        }
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  ll x,y;
  cin>>x>>y;
  // if(x>=0&&y>=0) {
  //   if(y>=x) {
  //     cout << y -x << endl;
  //   } else {
  //     cout << 1+y+x << endl;
  //   }
  // } else if(x>=0&&y<0) {
  //   if(x>=-y) {
  //     cout << 1+x+y << endl;
  //   } else {
  //     cout << -y-x+1 << endl;
  //   }
  // } else if(x<0&&y>=0) {
  //   cout << y+x+1<<endl;
  // } else { // x<0&&y<0
  //   if(y-x>=0) {
  //     cout << y-x << endl;
  //   } else {
  //     cout << 2+(-y)+x << endl;
  //   }
  // }
  ll ans=1e10;
  if(y-x>=0) ans=min(ans,y-x);
  if(y-(-x)>=0) ans=min(ans,y-(-x)+1);
  if(-y-x>=0) ans=min(ans,-y-x+1);
  if(-y+x>=0) ans=min(ans,-y+x+2);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import itertools

def countOrder(n, plist, qlist):

    ans = 0
    p = 0
    q = 0

    irelist = list(itertools.permutations(range(1, n+1), n))

    for index, i in enumerate(irelist):
        if i == plist:
            p = index
        if i == qlist:
            q = index

    ans = abs(p-q)

    return ans

def main():
    n = int(input())
    plist = tuple(map(int, input().split()))
    qlist = tuple(map(int, input().split()))
    print(countOrder(n, plist, qlist))

if __name__ == '__main__':
    main()

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

int main() {
  int num;
  long long wa = 1;
  long long tmp = 0;
  bool zero = false;
  
  cin >> num;
  
  for(int i = 0; i < num; i++){
    cin >> tmp;
    wa *= tmp;
    if(tmp == 0) zero = true;
  }
  
  if(zero == true) cout << 0;
  else if(wa > 1000000000000000000 ||  wa == 0) cout << -1;
  else  cout << wa;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
using namespace std;

#define TEST 0
#if TEST
FILE* in = freopen("./Q.txt", "r", stdin);
FILE* out = freopen("./A.txt", "w",stdout);
#endif

#define MAXN 300000

vector<int> MSPrimes;
bool isNotMSPrime[MAXN];

void calMSPrime(int n){
    for(int i = 2; i*n < MAXN; i++){
        isNotMSPrime[i*n] = true;
    }
}

int main(int argc, const char * argv[]) {
    
    for(int i = 2; i < MAXN; i++){
        if(!isNotMSPrime[i] && (i % 7 == 1 || i % 7 == 6)){
            calMSPrime(i);
            MSPrimes.push_back(i);
        }
    }
    
    while(1){
        int n; cin >> n;
        if(n == 1) break;
        
        set<int> primes;
        for(unsigned id = 0; id < MSPrimes.size() && n >= MSPrimes[id]; id++){
            if(n % MSPrimes[id] != 0) continue;
            
            int nowId = id, nowN = n;
            while(nowId < MSPrimes.size() && nowN >= MSPrimes[nowId]){
                int nowPrime = MSPrimes[nowId];
                bool ok = false;
                
                while(nowN % nowPrime == 0){
                    ok = true;
                    nowN /= nowPrime;
                }
                if(ok) primes.insert(nowPrime);
                nowId++;
            }

        }
        
        cout << n << ":";
        for(auto i = primes.begin(); i != primes.end(); i++){
            cout << " " << *i;
        }
        cout << endl;
        primes.clear();
    }
#if TEST
    fclose(in);
    fclose(out);
#endif
}

Measured memory_bytes: 3580
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();
        int quantam=scan.nextInt();
        int erapsedTime=0;
        ArrayList<String> pname=new ArrayList<String>();
        ArrayList<Integer> ptime=new ArrayList<Integer>();
        
        for(int i=0; i<n; i++){
            pname.add(scan.next());
            ptime.add(scan.nextInt());
        }
        //System.out.println(pname+":"+ptime);
        
        while(ptime.size()!=0){
            if(ptime.get(0)<=quantam){
                erapsedTime+=ptime.remove(0);
                System.out.println(pname.remove(0)+" "+erapsedTime);
            }
            else{
                ptime.add(ptime.remove(0)-quantam);
                pname.add(pname.remove(0));
                erapsedTime+=quantam;
            }
        }
    }
}


Measured memory_bytes: 72996
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

	int N;
	cin >> N;
	int i = N;
	while (1) {
		int j = i;
		while (j % 2 == 0) j /= 2;
		if (j == 1) {
			cout << i << "\n";
			return 0;
		}
		i--;
	}

	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE OverloadedStrings #-}
import Data.Maybe
import Data.Char
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector.Unboxed as VU

main = do
  s <- getLine
  print $ solve s

solve :: String -> Int
solve "" = 0
solve [_] = 1
solve (a:b:[]) = if a==b then 1 else 2
solve (a:b:c:cs) = if a==b then 2 + solve cs else 1 + solve (b:c:cs)
  
  
-- IO
readInt :: BS.ByteString -> Int
readInt = fst . fromJust . BS.readInt

getInt :: IO Int
getInt = readInt <$> BS.getLine

getIntList :: IO [Int]
getIntList = unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

getIntVec :: Int -> IO (VU.Vector Int)
getIntVec n = VU.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

Measured memory_bytes: 9596
// 問題URL
// https://atcoder.jp/contests/abc132/tasks/abc132_a

import java.util.Scanner;
import java.util.Arrays;
import java.util.stream.*;

public class Main {
    public static void main(String[] args) {
        //コード
        Scanner scanner = new Scanner(System.in);
        String x = scanner.next();
        String[] ar = x.split("");
        int count = 0;
        int no_count = 0;

        for(int i = 0; i< ar.length; i++) {
            String s = ar[i];
            for(int j = 0; j < ar.length; j++) {
                if (s.equals(ar[j])) count++;
            }
            if(count >= 2) break;
            count = 0;
        }

        for(int i = 0; i< 4; i++) {
            if(ar[i].equals(ar[0])) no_count++;
            if(ar[i].equals(ar[1])) no_count++;
            if(ar[i].equals(ar[2])) no_count++;
            if(ar[i].equals(ar[3])) no_count++;
        }

        if(count >= 2 && no_count == 8) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace   std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define double    long double
#define ull       unsigned long long
#define mod       1000000007
#define vi        vector<ll>
#define extreme   inline
#define ppi       pair<ll,pair<ll,ll>>
#define pb        push_back
#define mp        make_pair
#define str       string
#define pi        2*acos(0.0)
#define pr(a,x,n) for(int i=x;i<n;i++){cout<<a[i]<<" ";}
#define p(a)      cout<<a;
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define test      cout<<"THIS_AND_THIS"<<endl;
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
void solve(){
	ll n;cin>>n;
	ll ans=inf;
	for(int i=1;i*i<=n;i++){
		if(n%i==0){
			ll x=n/i;
			ans=min(ans,abs(1-i)+abs(1-x));
		}
	}
	cout<<ans;
}
int32_t main(){
	kehsihba();
	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 3600
N, M = map(int, input().split())
cakes = []
for i in range(N):
    x, y, z = map(int, input().split())
    cakes.append([x, y, z])
res_ind = []
for i in range(2**3):
    tmp_bit = bin(i)[2:].zfill(3)
    tmp_points = [sum(cake) for cake in cakes]
    if tmp_bit[0] == '0':
        for ii, cake in enumerate(cakes):
            tmp_points[ii] -= 2 * cake[0]        
    if tmp_bit[1] == '0':
        for ii, cake in enumerate(cakes):
            tmp_points[ii] -= 2 * cake[1]
    if tmp_bit[2] == '0':
        for ii, cake in enumerate(cakes):
            tmp_points[ii] -= 2 * cake[2]
    res_ind.append(sum(sorted(tmp_points, reverse=True)[:M]))
print(max(res_ind))

Measured memory_bytes: 3316
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

#define int long long

#define rep(i, n) for (signed i = 0; i < signed(n); i++)
#define REP(i, s, n) for (signed i = signed(s); i < signed(n); i++)
#define rrep(i, n) for (signed i = signed(s) - 1; i >= 0; i--)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, const T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, const T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, const T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, const T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

void calc() {
	int a, b, c; cin >> a >> b >> c;
	if (a == b && b == c && a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
		cout << -1 << endl;
	} else {
		int cnt = 0;
		while (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
			int ta = (b + c) / 2;
			int tb = (a + c) / 2;
			int tc = (a + b) / 2;
			a = ta;
			b = tb;
			c = tc;
			cnt++;
		}
		cout << cnt << endl;
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	calc();
#ifdef _MSC_VER
	system("pause");
#endif
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {

    int N, K;
    cin >> N >> K;

    long long ans = 0;
    vector<long long> sum(N + 1, 0);
    for (int i = 1; i <= N; i++) sum[i] = sum[i - 1] + i;

    for (int i = K; i <= N + 1; i++) {
        ans += (sum[N] - (N - i >= 0 ? sum[N - i] : 0)) - sum[i - 1] + 1;
        ans %= MOD;
    }

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

Measured memory_bytes: 4780