akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

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;
}
vector<bool> seen;
void dfs(const Graph &G, int v){
    seen[v] = true; // vを訪問済みにする
    
    for(auto next_v: G[v]){
        if(seen[next_v]) continue; // next_vが探索済みならスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int get_digit(ll n){
    int digit = 0;
    if(n == 0){
        return 1;
    }
    while(n != 0){
        digit++;
        n /= 10;
    }
    return digit;
}
bool is_junretu(ll n){
    int digit = get_digit(n);
    string s;
    s = to_string(n);
    bool flg= true;
    for(int i = 1; i <= digit; i++){
        if(s.find(i) == string::npos){
            flg = false;
            break;
        }
    }
    return flg;
}

ll gcd(ll x, ll y){
    return y != 0 ? gcd(y, x % y) : x;
}
ll lcm(ll x, ll y){
    return x * y / gcd(x, y);
}
int main(){

    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll cnt_c, cnt_d, cnt_cd;
    cnt_c = (b / c) - ((a - 1) / c);
    cnt_d = (b / d) - ((a - 1) / d);
    cnt_cd = (b / lcm(c, d)) - ((a - 1)  / lcm(c, d));
    ll cnt;
    cnt = cnt_c + cnt_d - cnt_cd;
    ll ans = (b - a + 1) - cnt;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int r,g,b;
    scanf("%d %d %d",&r,&g,&b);
    if((r*100+g*10+b) % 4 == 0){
        printf("YES\n");
    }else{
        printf("NO\n");
    }
    
    return 0;
}

Measured memory_bytes: 128
import math

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

use=[-1 for _ in range(N)]
for i in reversed(range(N)):
    use[i]=a[i]
    #print(i,use)
    if i+1==N//2+1:
        break
#print('half')
for i in reversed(range(N//2)):
    x=i+1
    tmp=0
    cnt=2
    while cnt*x<=N:
        tmp+=use[cnt*x-1]
        #print(x,cnt,tmp)
        cnt+=1
    use[i]=(tmp+a[i])%2
    #print(use)

print(sum(use))
ans=""
for i in range(N):
    if use[i]==1:
        ans+=str(i+1)+" "
ans.split()
print(ans)


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

#define ls rt<<1
#define rs rt<<1|1
const int maxn = 100 + 10;
const int maxm = 1e6 + 10 ;
const int inf=0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
const int st=(1<<20)-1;
const int mod = 1e9+7;
const double eps = 1e-5;
const int vec[2][2]={1,0,0,1};

inline int read(){
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}

int main() {
#ifdef LOCAL
    freopen("input.txt","r",stdin);
#endif // LOCAL
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    ll x,y,ans=0,tmp;
    cin>>x>>y;
    ans=0; tmp=x;
    while(tmp<=y) {
        ans++;
        tmp<<=1;
    }
    cout<<ans;
    return 0;
}
//校园网真tm卡


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <string.h>
//#include <unordered_set>
//#include <unordered_map>
//#include <bits/stdc++.h>

#define MP(A,B) make_pair(A,B)
#define PB(A) push_back(A)
#define SIZE(A) ((int)A.size())
#define LEN(A) ((int)A.length())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define fi first
#define se second
#define int ll

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef long long ll;
typedef unsigned long long ull;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod eps=1e-11;
const lod pi=acos(-1);
const int oo=1<<30;
const ll loo=1ll<<62;
const int mods=998244353;
const int MAXN=600005;
const int INF=0x3f3f3f3f;//1061109567
/*--------------------------------------------------------------------*/
inline int read()
{
	int f=1,x=0; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') f=-1; c=getchar(); }
	while (c>='0'&&c<='9') { x=(x<<3)+(x<<1)+(c^48); c=getchar(); }
	return x*f;
}
PR p[MAXN];
int s[MAXN];
signed main()
{
	int n=read(),C=read(),ans=0;
	for (int i=1;i<=n;i++) p[i].fi=read(),p[i].se=read();
	for (int i=n;i>=1;i--) s[i]=s[i+1]+p[i].se;
	for (int i=n,smax1=0,smax2=0;i>=0;i--)
	{
		int t=(s[1]-s[i+1]);
		upmax(ans,t-p[i].fi);
		upmax(ans,t+smax1-p[i].fi*2);
		upmax(ans,t+smax2-p[i].fi);
		upmax(smax1,s[i]-(C-p[i].fi));
		upmax(smax2,s[i]-(C-p[i].fi)*2);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 6016
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<=b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

int N;
V<int> xv, yv;
int main(){
    INIT;
    cin >> N;
    REP(i,N) {
        int x, y; cin >> x >> y;
        xv.push_back(x);
        yv.push_back(y);
    }
    if(N == 1) {
        cout << 1;
        return 0;
    }
    V<int> v(N);
    v.resize(N);
    std::iota(ALL(v),0);
	std::sort(ALL(v),[&](int x,int y){
		if(xv[x]==xv[y]) return yv[x]<yv[y];
		return xv[x]<xv[y];
	});

    V<std::tuple<int,int>> zz;
    REP(i,N) {
        FOR(j,i+1,N) {
            zz.push_back(make_tuple(xv[v[j]]-xv[v[i]],yv[v[j]]-yv[v[i]]));
        }
    }
    /*REP(i,N) {
        cout << xv[v[i]] << " " << yv[v[i]] << "\n";
    }*/
    int ans = N;
    REP(i,zz.size()) {
        int dx,dy;
        std::tie(dx,dy) = zz[i];
        int cnt = N;
        V<bool> used; 
        used.resize(N,false);
        REP(j,N) {
            int nx = xv[v[j]], ny = yv[v[j]];
            used[v[j]] = true;
            FOR(k,j+1,N) {
                int cx = xv[v[k]], cy = yv[v[k]];
                if(!used[v[k]] && nx+dx == cx && ny+dy == cy) {
                    cnt--; nx = cx; ny = cy; used[v[k]] = true;
                }
            }
        }
        ans = std::min(ans, cnt);
    }
    cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

struct node{
	int l, r, parent, sibling, degree, depth, height, type;
};

int dfs(vector<node> &tree, int n, int par, int dp){
	auto &now = tree.at(n);
	now.parent = par;
	now.depth = dp;
	now.degree = 0;
	now.sibling = -1;
	int re1 = 0, re2 = 0;
	if(now.l != -1){
		now.degree++;
		re1 = dfs(tree, now.l, n, dp+1);
	}
	if(now.r != -1){
		now.degree++;
		re2 = dfs(tree, now.r, n, dp+1);
	}
	if(now.l != -1 && now.r != -1){
		tree.at(now.l).sibling = now.r;
		tree.at(now.r).sibling = now.l;
	}
	if(now.parent == -1)now.type = -1;
	else if(now.degree == 0) now.type = 1;
	else now.type = 0;
	now.height = max(re1, re2);
	return now.height+1;
}

int main(){
	int n;
	cin >> n;
	vector<node> tree(n);
	rep(i, n){
		int id, il, ir;
		cin >> id >> il >> ir;
		tree.at(id).l = il;
		tree.at(id).r = ir;
	}
	vector<bool> c(n, false);
	rep(i, n){
		auto now = tree.at(i);
		int il = now.l, ir = now.r;
		if(il != -1) c.at(il) = true;
		if(ir != -1) c.at(ir) = true;
	}
	int st = -1;
	rep(i, n){
		if(c.at(i) == false){
			st = i;
			break;
		}
	}
	tree.at(st).type = -1;
	dfs(tree, st, -1, 0);
	rep(i, n){
		auto &now = tree.at(i);
		cout << "node " << i << ": parent = " << now.parent << ", sibling = " << now.sibling << ", degree = " << now.degree << ", depth = " << now.depth << ", height = " << now.height << ", ";
		if(now.type == -1) cout << "root" << endl;
		else if(now.type == 1) cout << "leaf" << endl;
		else cout << "internal node" << endl;
	}

	return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	ll ret=0;
	int pre=0;
	cin>>N;
	FOR(i,N) {
		cin>>x;
		if(x>=pre) pre=x;
		else ret+=pre-x;
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 3548
n = int(input())
A = list(map(int, input().split()))

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

E = gcd(A[0], A[1])
if n == 2: print(E)
else:
    for i in range(2, n):
        E = gcd(E, A[i])
    print(E)

Measured memory_bytes: 15020
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

count = 0
a.each do |e|
  while true
    break_flg = true
    if e > 0 and e.even?
      e/=2
      count += 1
      break_flg = false
    end
    break if break_flg
  end
end

puts count


Measured memory_bytes: 2428
import sys,math,itertools
N = int(input())

def primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

P = primes(55555)
P = list(filter(lambda x: x % 5 == 1, P))
P = [str(x) for x in P]

print(" ".join(P[0:N]))



Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vqi = vector<queue<int>>;

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

void dfs(vqi &g, vi &d, vi &f, int v, int &t) {
  if (d[v] && g[v].empty()) {
    t--;
    return;
  }

  if (!d[v]) d[v] = t;

  while (!g[v].empty()) {
    int next = g[v].front(); g[v].pop();
    if (!d[next] )dfs(g, d, f, next, ++t);
  }

  f[v] = max(++t, f[v]);
}

int main() {
  int n;
  cin >> n;
  
  vqi g(n);
  rep(i, n) {
    int u, k;
    cin >> u >> k;

    rep(j, k) {
      int v;
      cin >> v;
      g[u - 1].push(v - 1);
    }
  }

  vi d(n), f(n);
  stack<int> s;
  s.push(0);

  int t = 1;
  rep(i, n) {
    dfs(g, d, f, i, t);
    t++;
  }

  rep(i, n) printf("%d %d %d\n", i + 1, d[i], f[i]);
}



Measured memory_bytes: 3288
while True:
    try:
        weight = int(input())
    except:
        break
    g = []
    while weight != 1:
        weight, b = divmod(weight, 2)
        g.append(b)
    g.append(weight)
    print(*[pow(2*g[i], i) for i in range(len(g)) if g[i]])

Measured memory_bytes: 7512
#include <iostream>
#include <vector>

int main(){
   std::vector<std::vector<int>> c(3, std::vector<int> (3));
   for (int i=0; i<3; i++){
      for (int j=0; j<3; j++){
         std::cin >> c.at(i).at(j);
      }
   }

   int a1, a2, a3, b1, b2, b3;
   for (int i=0; i<3; i++){
      int b1_b2;
      if (i == 0){
         b1_b2 = c.at(i).at(0) - c.at(i).at(1);
      } else{
         if (c.at(i).at(0) - c.at(i).at(1) != b1_b2){
            std::cout << "No" << std::endl;
            return 0;
         }
      }
   }

   for (int i=0; i<3; i++){
      int b1_b3;
      if (i == 0){
         b1_b3 = c.at(i).at(0) - c.at(i).at(2);
      } else{
         if (c.at(i).at(0) - c.at(i).at(2) != b1_b3){
            std::cout << "No" << std::endl;
            return 0;
         }
      }
   }

   for (int i=0; i<3; i++){
      int b2_b3;
      if (i == 0){
         b2_b3 = c.at(i).at(1) - c.at(i).at(2);
      } else{
         if (c.at(i).at(1) - c.at(i).at(2) != b2_b3){
            std::cout << "No" << std::endl;
            return 0;
         }
      }
   }

   for (int i=0; i<3; i++){
      int a1_a2;
      if (i == 0){
         a1_a2 = c.at(0).at(i) - c.at(1).at(i);
      } else{
         if (c.at(0).at(i) - c.at(1).at(i) != a1_a2){
            std::cout << "No" << std::endl;
            return 0;
         }
      }
   }

   for (int i=0; i<3; i++){
      int a1_a3;
      if (i == 0){
         a1_a3 = c.at(0).at(i) - c.at(2).at(i);
      } else{
         if (c.at(0).at(i) - c.at(2).at(i) != a1_a3){
            std::cout << "No" << std::endl;
            return 0;
         }
      }
   }

   for (int i=0; i<3; i++){
      int a2_a3;
      if (i == 0){
         a2_a3 = c.at(1).at(i) - c.at(2).at(i);
      } else{
         if (c.at(1).at(i) - c.at(2).at(i) != a2_a3){
            std::cout << "No" << std::endl;
            return 0;
         }
      }
   }

   std::cout << "Yes" << std::endl;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long 
#define INF 1e9
#define LINF 1e18
 
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;
 
const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };
 
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

signed main() {
	int W, H, x, y;
	cin >> W >> H >> x >> y;
	cout << double(W) * double(H) / 2 << " ";
	cout << (x * 2 == W && y * 2 == H) << endl;
    return 0;
}

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

int main(){
  int n,l;
  cin >> n >> l;
  vector<string> v(n);
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  for(int i = 0; i < n; i++){
    cout << v[i];
  }
  cout << '\n';

  
}


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


def solve(N: int, S: str):
    lists = list(S)
    sample = ""
    for item in lists:
        if len(sample) == 0:
            sample += item
        elif sample[-1] != item:
            sample += item
    print(len(sample))
    return


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

if __name__ == '__main__':
    main()


Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
    ll N, D, A;
    cin >> N >> D >> A;
    vector<ll> X(N), H(N);
    rep(i, N){
        cin >> X.at(i) >> H.at(i);
    }
    vector<pair<ll, ll>> monster(N);
    rep(i, N){
        monster.at(i) = make_pair(X.at(i), H.at(i));
    }
    sort(all(monster));
    ll ans = 0;
    ll tot = 0;
    queue<pair<ll, ll>> q;
    rep(i, N){
      ll x = monster.at(i).first;
      ll h = monster.at(i).second;
      while(!q.empty() && q.front().first < x){
        tot -= q.front().second;
        q.pop();
      }
      h -= tot;
      if(h <= 0){
        continue;
      }
      ll c = (h+A-1)/A;
      ans += c;
      tot += A*c;
      q.push(make_pair(x+2*D, A*c));
    }
    cout << ans << endl; 
}

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

#define all(v)   v.begin(), v.end()
#define endl "\n";
#define pb push_back
#define F first
#define S second
#define JULEE_DO_THE_THING fast()
#define to_str to_string
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMIN INT_MIN
#define IMAX INT_MAX
#define pow POW

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double dd;
typedef string str;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef pair<int, int> pii;

void fast() {
	cin.tie(0);
	cout.tie(0);
	cin.sync_with_stdio(0);
}

bool compare(int &a, int &b) {
	return a > b;
}

ll numOfDigits(ll n) {
	if (!n)
		return 1;
	return (ll) (log10(n)) + 1;
}

ull POW(ll a, ll b);

/*

 */

ll BN();

int main() {
	JULEE_DO_THE_THING;
	//freopen("test cases\\.txt", "r", stdin) ;
    int n; cin>>n;
    vecint v1(n), v2(n), v(n);
    for(int i=0; i<n; i++) cin>>v1[i];
    for(int i=0; i<n; i++) cin>>v2[i];
    for(int i=1; i<=n; i++) v[i-1] = i;
    if(v1==v2) return cout<<0, 0;
    int cnt = 1, found1 = 0, found2 = 0;
    do{
        if(v1==v || v2==v){
            if(!found1) found1 = cnt;
            else {
                found2 = cnt;
                break;
            }
        }
        cnt++;
    }while(next_permutation(all(v)));
    cout<<abs(found1-found2);
	return 0;
}

ll BN() {
	ll low = 0;
	ll up = 0;
	ll ans = 0;
	while (low <= up) {
		ll mid = ((low + up) / 2);
		if (mid) {
			ans = mid;
			low = mid + 1;
		} else
			up = mid - 1;
	}
	return ans;
}

ull POW(ll a, ll b) {
	ull res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a;
		a = a * a;
		b >>= 1;
	}
	return res;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
using namespace std;
inline int read()
{
	int f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
const int MAXN=200005;
const int mod=1e9+7;
void ad(int &x,int y){x+=y;if(x>=mod)x-=mod;}
struct line{int a,b;}w[MAXN],L[MAXN];
bool cmp1(line n1,line n2){return n1.b<n2.b;}
bool cmp2(line n1,line n2){return n1.b!=n2.b?n1.b<n2.b:n1.a<n2.a;}
int n,bi[MAXN],ls[MAXN],f[MAXN],s[MAXN],lslen;
int lowbit(int x){return x&-x;}
void modify(int x,int c){for(;x<=n;x+=lowbit(x))bi[x]=min(bi[x],c);}
int qry(int x){int ret=999999999;for(;x>=1;x-=lowbit(x))ret=min(ret,bi[x]);return ret;}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)w[i].a=read(),w[i].b=read();
	for(int i=1;i<=n;i++)ls[i]=w[i].a;sort(ls+1,ls+1+n);
	for(int i=1;i<=n;i++)w[i].a=lower_bound(ls+1,ls+1+n,w[i].a)-ls;
	sort(w+1,w+1+n,cmp1);
	memset(bi,63,sizeof(bi));
	for(int i=1;i<=n;i++)
	{
		int u=qry(n-w[i].a+1);
		if(u>n)L[i].a=i;else L[i].a=u;
		modify(n-w[i].a+1,i);
	}memset(bi,63,sizeof(bi));
	for(int i=n;i>=1;i--)
	{
		int u=qry(w[i].a);
		if(u>n)L[i].b=i;else L[i].b=n-u+1;
		modify(w[i].a,n-i+1);
	}
	sort(L+1,L+1+n,cmp2);int ans=0;
	for(int i=1,j=0;i<=n;i++)
	{
		while(L[i].a>L[j+1].b+1)++j;
		s[i]=s[i-1];f[i]=(s[i]-s[j]+mod)%mod;
		if(L[i].a==1)ad(f[i],1);
		if(L[i].b==n)ad(ans,f[i]);
		ad(s[i],f[i]);
	}pr2(ans);
	return 0;
}


Measured memory_bytes: 6400
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
#include<iomanip>
#include<stack>
#include<string.h>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define sz(a) (int)a.size()
using namespace std;

int main() {
	char c;
	cin >> c;
	if (c <= 'Z') cout << 'A' << endl;
	else cout << 'a' << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
#define I int
#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define P(a) printf("%d\n",a)
#define PL(a) printf("%lld\n",a)
#define PT(t) printf("Case %d: ",t)
#define PB(a) push_back(a)
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define ll long long 
using namespace std;
#define mx 500004
#define md 2000000000000000000ll
typedef pair<int, int >P;
typedef vector<ll>V;

////////define value/////

int main(){
   int ar[4] ={0};
   for(int i=1;i<=2;i++){
       int x;
       cin>>x;
       ar[x]++;
   }
   for(int i=1;i<=3;i++){
       if(!ar[i]){
           cout<<i<<endl;
       }
   }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int m,f,r;
    cin >> m >> f >> r;
    // cout << "\n";
    while (m != -1 || f != -1 || r != -1 ) {
      /* code */
      if(m == -1 || f == -1){
        cout << "F" << "\n";
      }else if((m+f) >= 80){
        cout << "A" << "\n";
      }else if((m+f) >= 65){
        cout << "B" << "\n";
      }else if((m+f) >= 50){
        cout << "C" << "\n";
      }else if((m+f) >= 30 && r >= 50){
        cout << "C" << "\n";
      }else if((m+f) >= 30){
        cout << "D" << "\n";
      }else{
        cout << "F" << "\n";
      }
      cin >> m >> f >> r;
    }
    return 0;
}


Measured memory_bytes: 3032
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

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

l,r,d = l_in()

print(sum(i%d ==0 for i in range(l,r+1)))


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

#define Rep(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, n) Rep(i, 0, n)

template<class T> T read() {
	T t;
	cin >> t;
	return t;
}

int main(){
	int n = read<int>(), k = read<int>();
	int x1[n], y1[n], z1[n], x2[n], y2[n], z2[n];
	set<int> xSet, ySet, zSet;
	rep(i,n){
		x1[i]=read<int>();
		y1[i]=read<int>();
		z1[i]=read<int>();
		x2[i]=read<int>();
		y2[i]=read<int>();
		z2[i]=read<int>();
		xSet.insert(x1[i]);
		xSet.insert(x2[i]);
		ySet.insert(y1[i]);
		ySet.insert(y2[i]);
		zSet.insert(z1[i]);
		zSet.insert(z2[i]);
	}
	int xList[xSet.size()], yList[ySet.size()], zList[zSet.size()];
	// map<int, int> xMap, yMap, zMap;
	int i;
	i=0;
	for(set<int>::iterator it = xSet.begin();it!=xSet.end();it++){
		xList[i]=*it;
		// xMap[*it]=i;
		i++;
	}
	i=0;
	for(set<int>::iterator it = ySet.begin();it!=ySet.end();it++){
		yList[i]=*it;
		// yMap[*it]=i;
		i++;
	}
	i=0;
	for(set<int>::iterator it = zSet.begin();it!=zSet.end();it++){
		zList[i]=*it;
		// zMap[*it]=i;
		i++;
	}
	long long ans = 0;
	rep(x,xSet.size()-1){
		rep(y,ySet.size()-1){
			rep(z,zSet.size()-1){
				// printf("(%d, %d, %d)->(%d, %d, %d)\n",xList[x],yList[y],
				// 		zList[z],xList[x+1],yList[y+1],zList[z+1]);
				int count = 0;
				rep(j,n){
					// printf("\t%d (%d, %d, %d)->(%d, %d, %d)",j,x1[j],y1[j],z1[j],x2[j],y2[j],z2[j]);
					if(x1[j] <= xList[x] && xList[x+1] <= x2[j] && 
							y1[j] <= yList[y] && yList[y+1] <= y2[j] && 
							z1[j] <= zList[z] && zList[z+1] <= z2[j]){
						count++;
						// cout << "\to";
					}
					// cout << endl;
				}
				if(count>=k){
					ans += ((long long)xList[x+1]-xList[x])*(yList[y+1]-yList[y])*(zList[z+1]-zList[z]);
				}
				// cout << endl;
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1204
#include<iostream>
    #include<stdio.h>
    using namespace std;
    int main()
    {
        long int n,i,cnt=0,hi=0;
        cin>>n;
        long int h[n];
        for(i=0;i<n;i++)
        {
            cin>>h[i];
        }
        for(i=0;i<n-1;i++)
        {
            if(h[i]>=h[i+1])
            {
                cnt++;
                
            }
            else
            {      if(hi<cnt)
                     { hi=cnt;}
                cnt=0;
                
            }
        }
        if(hi<cnt)
          { hi=cnt;}
       cout<<hi; 
        return 0;
    }

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }
int c[10001];
int main()
{
	int n;
	cin >> n;
	rep(x, 1, 101) {
		rep(y, 1, 101) {
			rep(z, 1, 101) {
				if (x * x + y * y + z * z + x * y + y * z + z * x <= 10000)c[x * x + y * y + z * z + x * y + y * z + z * x]++;
			}
		}
	}
	rep(i, 1, n+1)printf("%d\n", c[i]);
	return 0;
}

Measured memory_bytes: 3728
#include <iostream>

#define EPS (1e-10)

using namespace std;

double a[2], b[2], c[2], d[2];

bool isParallel() {
  double ax = b[0] - a[0], ay = b[1] - a[1];
  double bx = d[0] - c[0], by = d[1] - c[1];
  double cross = ax * by - ay * bx;
  if (-EPS < cross && EPS > cross)
    return true;
  else
    return false;
}

int main() {
  int n;
  cin >> n;
  if (n < 1) return -1;
  for (int i = 0; i < n; i++) {
    cin >> a[0] >> a[1] >> b[0] >> b[1] >> c[0] >> c[1] >> d[0] >> d[1];
    if (isParallel()) cout << "YES\n";
    else cout << "NO\n";
  }
  return 0;
}

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
Int mod = 1e9+7;
//Int mod = 998244353;

typedef struct {
    Int y, x;
} p_t;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    Int a, b;
    cin >> a >> b;
    dump(6 - a - b);
    return 0;
}

Measured memory_bytes: 256
S = input()

N = len(S)
B_idx = []
W_idx = []

for i, s in enumerate(S):
    if s == 'B':
        B_idx.append(i)
    else:
        W_idx.append(i)

ans_B = 0
ans_W = 0

counter = 0
for w in W_idx:
    ans_W += (w - counter)
    counter += 1

counter = 0
for b in reversed(B_idx):
    ans_B += (N - b - 1 - counter)
    counter += 1
    
ans = max(ans_B, ans_W)
    
print(ans)

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

long long K, dp[555]; string S;

int main() {
	cin >> K;
	for (int i = 0; i <= 550; i++) {
		unsigned long long R = 1;
		for (int j = i + 1; j <= i + 7; j++) R *= j;
		R /= 5040;
		dp[i] = R;
	}
	for (int i = 549; i >= 0; i--) {
		while (K >= dp[i]) { S += "L"; K -= dp[i]; }
		S += "AVITSEF";
	}
	reverse(S.begin(), S.end());
	cout << S << endl;
	return 0;
}

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

int main()
{
  int n;
  cin >> n;
  string s[n];
  map<string, ll> num;
  rep(i, n) {
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
    num[s[i]]++;
  }

  ll ans = 0;
  for (auto i : num) {
    if (i.second == 1) continue;
    ans += i.second * (i.second - 1) / 2;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 18176
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <map>
#include <queue>
#define rep(i,n) for (int i=0;i<(n);i++)

using namespace std;

int main() {
	int h, n;
	cin >> h >> n;
	vector<int> a(n);
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}

	for (int i = 0;i < n;i++) {
		h -= a[i];
		if (h <= 0) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}

//AAAAAAAAAAAAA
//int main() {
//	int h,a;
//	cin >> h >> a;
//
//	if (h % a != 0)
//		cout << h / a + 1 << endl;
//	else cout << h / a << endl;
//	
//	return 0;
//}

Measured memory_bytes: 3768
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i)
#define mod 1e9 + 7
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	　　　　　 　 _... ..._
	　　　　　 , ´⌒ ⌒ヽ
	　　　 　 ﾉｨ（ノﾉ）ﾉ）ﾉ）
	　　　 　 （（q|.ﾟ ヮﾟﾉ|ﾊ
	　　　　　　△ﾑ,8ﾑﾌつ
	　　　　　/(ﾝ_/＿ヽ＼
	　　　　 ～～i_ﾌ_ﾌ～´
	*/
	string s;
	cin >> s;
	string ans;
	string anss;
	string ansss;
	REP(0, 4) {
		ans += s[i];
	}
	REP(6, 12) {
		anss += s[i];
	}
	REP(14, 18) {
		ansss += s[i];
	}
	cout << ans << " " << anss << " " << ansss << endl;
	return 0;
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int a,b,c,d;
  string s,s1;
  cin>>a>>b;
  if(a*b==15)
  cout<<"*"<<endl;
  else if(a+b==15)
    cout<<"+"<<endl;
  else
    cout<<"x"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
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); }

//CODE

void solve(void)
{
  int N;
  cin>>N;
  int K;
  cin>>K;
  vector<int> vec(N);
  for (int i = 0; i < N; i++)
  {
    cin>>vec[i];
  }
  sort(ALL(vec),greater<int>());
  if(N <= K)
  {
    cout<<0<<endl;
    return;
  }
  int SUM = 0;
  for (int i = K; i < N; i++)
  {
    SUM += vec[i];
  }
  cout<<SUM<<endl;
  
  

  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>
#define M 1000000
#define L 14

char H[M][L];
int cnt=0;

int getChar(char ch){
  if(ch =='A') return 1;
  else if(ch=='C') return 2;
  else if(ch=='G') return 3;
  else if(ch=='T') return 4;
}

long long getKey(char str[]){
  long long sum=0,p=1,i;
  
  for(i=0;i<strlen(str);i++){
    sum+=p*(getChar(str[i]));
    p*=5;
  }
  
  return sum;
}


int h1(int key){
  return key % M;
}
int h2(int key){
  return 1 + key % (M-1);
}


int find(char str[]){
  int i=0;
  int j;
  int k=getKey(str);
  
  while(i<M){
      j=(h1(k)+i*h2(k))%M;
      if(!strcmp(H[j],str)){
          return j;
        }
      else if(H[j][0]=='\0'){
          return 0;
        }
      else
        {
          i++;
        }
    }
  return 0;
}

int insert(char str[]){
  int i=0;
  int j;
  int k=getKey(str);

  while(i<M){
    j=(h1(k)+i*h2(k))%M;
    if(!strcmp(H[j],str)){
      return j;
    }
    else if(H[j][0]=='\0'){
      strcpy(H[j],str);
      return j;
    }
    else{
      i++;
    }
  }
  
  return -1;
}

int main(){
  int i,n,h;
  char str[L],com[9];
  
  for(i=0;i<M;i++) H[i][0]='\0';
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s%s",com,str);

    if(com[0]=='i'){
      insert(str);
    }
    else{
      if(find(str)){
        printf("yes\n");
      }
      else{
        printf("no\n");
      }
    }
  }
  
  return 0;
}



Measured memory_bytes: 15360
using System;

    class Program
    {

        static void Main()
        {
            string[] input = Console.ReadLine().Split(' ');
            string[] input2 = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int m = int.Parse(input[1]);

            //配列操作========================================
            for (int i = 0; i < m; i++)
            {
                n -= int.Parse(input2[i]);
            }
            n = n <= -1 ? -1 : n;
            Console.WriteLine(n.ToString());
        }
    }

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;

signed main() {
    ll M, K;
    cin>>M>>K;
    if (K < 0 || K >= (1<<M)) {
        cout<<-1<<endl;
        return 0;
    }

    if (M == 1) {
        if (K == 0) {
            cout<<"0 0 1 1"<<endl;
        } else {
            cout<<-1<<endl;
        }
        return 0;
    }

    rep(i, 0, 1<<M){
        if (i != K) {
            cout<<i<<" ";
        }
    }
    cout<<K<<" ";
    for (ll i=(1<<M)-1; i>=0; i--) {
        if (i != K) {
            cout<<i<<" ";
        }
    }
    cout<<K<<endl;

    return 0;
}


Measured memory_bytes: 1920
#include <iostream>
#include <vector>
#include <string.h>
using namespace std;

int inf = 1e9;
int H,W;

struct edge{int to, cap, rev;};
vector<edge> G[10010];
bool used[10010];
void add_edge(int from, int to, int cap){
	G[from].push_back((edge){to,cap,G[to].size()});
	G[to].push_back((edge){from,0,G[from].size()-1});
}

int dfs(int v,int t,int f){
	if(v==t) return f;
	used[v] = true;
	for(int i=0;i<G[v].size();i++){
		edge &e = G[v][i];
		if(!used[e.to] && e.cap>0){
			int d = dfs(e.to,t,min(f,e.cap));
			if(d>0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s,int t){
	int flow = 0;
	for(;;){
		memset(used,0,sizeof(used));
		int f = dfs(s,t,inf);
		if(f==0) return flow;
		flow += f;
	}
}

char F[101][101];
int main(){
	cin >> H >> W;
	int sx,sy,tx,ty;
	for(int i=1;i<=H;i++){
		for(int j=1;j<=W;j++){
			cin >> F[i][j];
			if(F[i][j]=='S'){
				add_edge(0,i,2*inf);
				add_edge(0,j+H,2*inf);
				sx = i; sy = j;
			}
			if(F[i][j]=='T'){
				add_edge(i,H+W+1,2*inf);
				add_edge(j+H,H+W+1,2*inf);
				tx = i; ty = j;
			}
			if(F[i][j]!='.'){
				add_edge(i,j+H,1);
				add_edge(j+H,i,1);
			}
		}
	}
	if(ty==sy || sx== tx) cout << -1 << endl;
	else cout << max_flow(0,H+W+1) << endl;
}

Measured memory_bytes: 1152
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <utility>
#include <math.h>

using namespace std;

#define ll long long

int main(){
    int N, X, ans = 1;
    cin >> N >> X;
    int L[N],D[N+1] = {};
    for(int i = 0; i < N; i++){
        cin >> L[i];
        D[i+1] = D[i] + L[i];
        if(D[i+1] <= X)ans++;
        else break;
    }
    cout << ans << endl;
    return 0;
}


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

#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define rep(i,n,z) for(int i=z;i<n;i++)
#define rrep(i,z) for(int i=z;i>=0;i--)
#define nl cout<<endl
#define vi vector<int>
#define vlli vector<long long int>
#define umap unordered_map
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define ipair pair <int,int>
#define llipair pair <lli,lli>
#define pq priority_queue
#define displaymatrix(a,m,n) for(int i=0;i<m;i++){for(int j=0;j<n;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define printarray(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}nl;
#define vinput(a,n) vlli a(n);rep(i,n,0)cin>>a[i]
#define ainput(a,n) rep(i,n,0)cin>>a[i]
#define SO(a) sort(a.begin(),a.end())
#define all(x) (x).begin(),(x).end()
#define SOP(a,comp) sort(a.begin(),a.end(),comp)
#define inf INT_MAX
#define endl '\n'

int main()
{
    fastio;
    int s,w;
    cin>>s>>w;
    if(w >= s)cout<<"unsafe"<<endl;
    else cout<<"safe"<<endl;
}

Measured memory_bytes: 3616
//	created : 15/12/30
// 	autor   : Rp7rf
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>

using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define vi vector<int>


int main(void){
	int n;
	while(cin>>n){
		vi in(n);
		rep(i,n)cin>>in[i];
		sort(in.begin(),in.end());
		int ret = in[0];
		loop(i,1,n){
			in[i] += in[i-1];
			ret += in[i];
		}
		cout<<ret<<endl;
	}
}

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

#define rep(i, n) for (ll i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1e9;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

int main() {
  ll n, X;
  cin >> n >> X;
  vector<ll> x(n), d(n);
  rep(i, n) cin >> x[i];
  if (n == 1) {
    cout << abs(x[0] - X);
    return 0;
  }

  x.push_back(X);
  sort(x.begin(), x.end());

  ll g = gcd(x[1] - x[0], x[2] - x[1]);
  for (int i = 3; i < n + 1; ++i) g = gcd(g, x[i] - x[i - 1]);

  cout << g << endl;
  return 0;
}


Measured memory_bytes: 2560
fun main(arg: Array<String>) {
    val (H, W, A, B) =  listOfInt()
    var ans = ModInt(0)
    for (h in 1 .. H - A) {
        if (B == W - 1 && h != H - A) continue
        ans += comb(h - 1 + B, B) *
            comb(H - h + W - B - if (h != H - A) 2 else 1, H - h)
    }
    println(ans)
}

var fac = mutableListOf<ModInt>()
private fun fact(n: Int): ModInt {
    if (fac.size == 0) fac.add(ModInt(1))
    while (fac.size <= n) {
        fac.add(fac.last() * ModInt(fac.size))
    }
    return fac[n]
}
private fun comb(n: Int, k: Int) = fact(n) / fact(k) / fact(n - k)


data class ModInt(private var v: Long) {
    companion object { private const val MOD = 1000000007L }
    init { this.v %= MOD }
    constructor(n: Int): this(n.toLong())
    operator fun plus(other: Int) = ModInt((this.v + other) % MOD)
    operator fun plus(other: ModInt) = ModInt((this.v + other.v) % MOD)
    operator fun minus(other: Int) = ModInt((this.v + MOD - other) % MOD)
    operator fun minus(other: ModInt) = ModInt((this.v + MOD - other.v) % MOD)
    operator fun times(other: Int) = ModInt(this.v * other % MOD)
    operator fun times(other: ModInt) = ModInt(this.v * other.v % MOD)
    operator fun div(other: ModInt) = ModInt(this.v * pow(other.v, MOD - 2) % MOD)
    private fun pow(a: Long, b: Long): Long {
        if (b == 0L) return 1L
        if (b % 2 == 0L) {
            val d = pow(a, b / 2)
            return (d * d) % MOD
        }
        return a * pow(a, b - 1) % MOD
    }
    override fun toString() = this.v.toString()
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)
fun listOfInt(delta: Int = 0) = listOfString().map { Integer.parseInt(it) + delta }

//10000


Measured memory_bytes: 47736
# abc144_a.py
# https://atcoder.jp/contests/abc144/tasks/abc144_a

# A - 9x9 /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 100点

# 問題文
# 高橋君は九九を覚えたので、1以上 9 以下の 2つの整数の積を計算することができます。それ以外の計算はできません。
# 2つの整数 A, Bが与えられます。
# 高橋君が A×Bを計算できるならその結果を、できないなら代わりに -1 を出力してください。

# 制約
#     1≤A≤20
#     1≤B≤20
#     入力中のすべての値は整数である。

# 入力
# 入力は以下の形式で標準入力から与えられる。
# A B

# 出力
# 高橋君が A×Bを計算できるならその結果を、できないなら -1 を出力せよ。

# 入力例 1
# 2 5

# 出力例 1
# 10

# 2×5は 10です。

# 入力例 2
# 5 10

# 出力例 2
# -1

# 5×10は 50ですが、高橋君には計算できないので、かわりに -1 を出力します。

# 入力例 3
# 9 9

# 出力例 3
# 81


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    # N = int(lines[0])
    A, B = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    if A > 9 or B > 9:
        result = -1
    else:
        result = A*B

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['2 5']
        lines_export = [10]
    if pattern == 2:
        lines_input = ['5 10']
        lines_export = [-1]
    if pattern == 3:
        lines_input = ['9 9']
        lines_export = [81]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9232
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
#include <math.h>
#include <sstream>
#include <iterator>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
const  long long INF = 1LL << 60;
typedef unsigned long long ll;
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;
}



int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である

    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }

    return true;
}

map<ll,ll> mp;

auto findFactors(ll num){
	
    ll i;
    while (num % 2 == 0){ // 偶数の素数は2のみ
        if(mp.count(2)){
			mp[2] = mp[2] + 1;
		}
		else{
			mp[2] = 1;
		}
        num /= 2;
    }
    for (i = 3; i <= num; i++){ // 他の素数で割っていく
        while (num % i == 0){
			if(mp.count(i)){
			mp[i] = mp[i] + 1;
		}
		else{
			mp[i] = 1;
		}
            num /= i;
        }
    }
    return 0;
}
ll kaizyou(ll n){
    if(n == 1){
        return 1;
    }
    else{
        return (n * kaizyou(n-1)) % 1000000007;
    }
}

int main(){ 
    string S; cin >> S;
    int t = S.size();
    ll cnt = 0;
    ll ans = 0;
    for(int i = t - 1; i >= 0; i--){
        if(S[i] == 'W'){
            cnt ++;
        }
        else{
            ans += cnt;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(){
  long a,b,x,c,tmp=0;
  scanf("%ld%ld",&a, &b);
  x=a*b;
  if(a<b){
    tmp=a;
    a=b;
    b=tmp;
  }

  c=a%b;
  while(c!=0){
    a=b;
    b=c;
    c=a%b;
  }
  printf("%ld\n",x/b);
  return 0;
}


Measured memory_bytes: 128