akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll x;
    cin >> x;
    ll now = 100;
    ll ans = 0;
    while (true)
    {
        if (now >= x)
        {
            putout(ans);
            return 0;
        }
        now = now + now / 100;
        ans++;
    }
}


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

struct Node
{
    int key;
    Node *next, *prev;
};

Node *nil;

Node* listSearch(int key)
{
    Node *cur = nil->next;
    while (cur != nil && cur->key != key )
    {
        cur = cur->next;
    }
    return cur;
}

void init()
{
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void printList()
{
    Node *cur = nil->next;
    int isf = 0;
    while (true)
    {
        if (cur == nil) break;
        if (isf++ > 0) printf(" ");
        printf("%d", cur->key);
        cur = cur->next;
    }
    printf("\n");
}

inline void deleteNode(Node *t)
{
    if (t == nil) return;
    t->prev->next = t->next;
    t->next->prev = t->prev;
    free(t);
}

inline void deleteFirst()
{
    deleteNode(nil->next);
}

inline void deleteLast()
{
    deleteNode(nil->prev);
}

inline void deleteKey(int key)
{
    deleteNode(listSearch(key));
}

void insert(int key)
{
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

int main()
{
#ifdef local
    freopen("test.in", "r", stdin);
    freopen("test.out", "w", stdout);
#endif
    char buf[20];
    int n;
    scanf("%d", &n);
    init();
    for (int i = 0; i < n; ++i)
    {
        int key;
        scanf("%s", buf);
        if (buf[0] == 'i')
        {
            scanf("%d", &key);
            insert(key);
        }
        else
        {
            if(strlen(buf) > 6)
            {
                if (buf[6] == 'F') deleteFirst();
                else deleteLast();
            }
            else
            {
                scanf("%d", &key);
                deleteKey(key);
            }
        }
    }
    printList();
    return 0;
}


Measured memory_bytes: 34428
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

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

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

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

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

const pid_t pid = getpid();
// Problem Specific Parameter:

int main(void){
	int n;
	cin >> n;
	using state = tuple<string, int, int>;
	vector<state> ary;
	rep(i, n){
		string s;
		int value;
		cin >> s >> value;
		ary.push_back(state(s, -value, i + 1));
	}

	sort(begin(ary), end(ary));
	rep(i, n) cout << get<2>(ary[i]) << endl;
	return 0;
}

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

string s;
bool single = true;
int ans = 0;

int main() {
  cin >> s;
  ans = 1;
  rep (i, s.size()) {
    if (!single) {
      ans++;
      single = true;
      continue;
    }
    if (s[i] == s[i-1]) {
      if (i == s.size()-1) ans--;
      ans++;
      i++;
      single = false;
    }else{
      ans++;
      single = true;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3752
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out



int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    int n;
    cin>>n;
    vi v(n);
    rep(i,n)cin>>v[i];
    ll ans=pow(3,n);
    ll odd=1;
    rep(i,n){
        if(v[i]%2==0)odd*=2;
    }
    cout<<ans-odd<<endl;
//////////////////////////////////////////////////////
return 0;}


Measured memory_bytes: 256
def main():
    n = int(input())
    l = len(str(n))
    v = int(str(n)[0]) + 9 * (l - 1)
    if str(n)[1:] == '9' * (l - 1):
        print(v)
    else:
        print(v-1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;



int main(){
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll res = 0;
    ll mn = min(a, k);
    res += mn;
    k -= mn;
    k -= b;
    if(k <= 0){
        cout << res << endl;
        return 0;
    }
    res -= min(c, k);
    cout << res << endl;
}



Measured memory_bytes: 3160
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
    ll N, NN;
    cin>>N;
    NN = N;
    ll S = 0;
    for(int i=1000000000;i>=1;i/=10){
        if(N/i>0){
            S += N/i;
            N %= i;
        }
    }
    if(NN%S==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}



Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;

int main()
{
  ll N; cin >> N;
  int K; cin >> K;
  FOR(i,0,K) {
    ll x, y; cin >> x >> y;
    if(N%2==0) {
      x = min(x, N - x + 1);
      y = min(y, N - y + 1);
      if(min(x, y)%3==0) cout << 3 << '\n';
      else if(min(x, y)%3==1) cout << 1 << '\n';
      else cout << 2 << '\n';
    } else {
      if(x > (N+1)/2) x = N - x + 1;
      if(y > (N+1)/2) y = N - y + 1;
      if(min(x, y)%3==0) cout << 3 << '\n';
      else if(min(x, y)%3==1) cout << 1 << '\n';
      else cout << 2 << '\n';
    }
  }
  return 0;
}

Measured memory_bytes: 3048
N, K = map(int, input().split())
a = list(map(int, input().split()))

amin = min(a)

if len(a) == a.count(amin) :
    print("0")
else :
    if K == 1 : 
        print(N - a.count(amin))
    else :
        if (N - a.count(amin)) % (K - 1) == 0 :
            print((N - a.count(amin)) // (K - 1))
        else :
            print((N - a.count(amin)) // (K - 1) + 1)

Measured memory_bytes: 14008
a , b , c = map(int,input().split())
n = 0

for i in range(10000):
    if a == b and b == c and a % 2 == 0:
        n -= 1
        break
    elif a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
        break
    else:
        a , b , c = (b + c) / 2 , (c + a) / 2 , (a + b) / 2
        n += 1
        if a % 2 == 1 or b % 2 == 1 or c % 2 == 1:
            break

print(n)

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


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

typedef pair<int, int> P;



int main() {

    int n; cin >> n;
    vector<P> w(n);
    int ta,tb;
    rep(i, n) {
        cin >> ta >> tb;
        w[i] = make_pair(tb, ta);
    }

    sort(w.begin(), w.end());

    int now=0;
    rep(i, n) {
        now += w[i].second;
        if(now > w[i].first) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;



}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeSet;

import static java.util.Arrays.binarySearch;
import static java.util.Arrays.copyOfRange;
import static java.util.Arrays.sort;

public class Main {

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;

        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);

        Task solver = new Task();
        solver.solve(1, in, out);
        out.close();
    }
}

class Task {

    private static int mod = 998244353;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        int m = in.nextInt();
        int x = in.nextInt();
        int[] c = new int[n];
        int[][] a = new int[n][m];
        for (int i = 0; i < n; i++) {
            c[i] = in.nextInt();
            for (int j = 0; j < m; j++) {
                a[i][j] = in.nextInt();
            }
        }
        int ans = -1;
        for (int i = 0; i < (1 << n); i++) {
            int s = 0;
            int[] b = new int[m];
            for (int j = 0; j < n; j++) if (((i >> j) & 1) == 1) {
                s += c[j];
                for (int k = 0; k < m; k++) {
                    b[k] += a[j][k];
                }
            }
            if (ok(b, x)) {
                if (ans == -1 || ans > s) {
                    ans = s;
                }
            }
        }
        out.println(ans);

   }

    private boolean ok(int[] b, int x) {
        for (int i = 0; i < b.length; i++) {
            if (b[i] < x) {
                return false;
            }
        }
        return true;
    }

}

class InputReader {

    private final BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String nextLine() {
        try {
            return reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            tokenizer = new StringTokenizer(nextLine());
        }
        return tokenizer.nextToken();
    }

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

    public long nextLong() {
        return Long.parseLong(next());
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }

}


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

int main() {

    while(1){
        int n;
        cin >> n;
        if (!n) return 0;
        vector<long long> dp(n + 1);
        dp[0] = 1;
        dp[1] = 1;
        dp[2] = 2;
        for (int i = 1; i <= n; ++i) {
            dp[i] = dp[i - 1] + (i > 1 ? dp[i - 2] : 0) + (i > 2 ? dp[i - 3] : 0);
        }
        cout << (dp[n] + 3650 - 1) / 3650 << "\n";
    }
}



Measured memory_bytes: 2984
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,a,b;
  cin>>N;
  for(int i=0;i<N;i++){
    int x;
    cin>>x;
    a=0;
    while(x%2==0){
      x/=2;
      a++;
      }
    if(i==0){
        b=a;
    }
    else{
      b=min(a,b);
    }
  }
  cout<<b<<endl;
}
       
      
    
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()

using namespace std;
using ll = long long;
using pii = pair<ll, ll>;

const int oo = 1e9 + 7;
const ll mod = 1e9 + 7, maxn = 81;
const double PI = acos(-1);
ll fat[100100];

void init(){
    fat[0] = 1;
    for (int i=1; i<100100; i++){
        fat[i] = (i*fat[i-1])%mod;
    }
}

ll fexp(ll a, ll b){
    ll ans = 1LL;

    while (b){
        if (b&1){
            ans = (ans*a)%mod;
        }
        a = (a*a)%mod;
        b = (b >> 1);
    }
    return ans;
}

ll c(ll a, ll b){
    if (a == b) return 1;
    if (b > a) return -1;
    ll x, y, z;
    x = fat[a];
    y = fexp(fat[b], mod-2);
    z = fexp(fat[a - b], mod-2);
    return (((x*y + mod)%mod)*z + mod)%mod;
}

int main (){
    ll n, k;
    cin >> n >> k;
    init();

    vector<ll> ps(n, 0), v(n);

    for (auto&x : v){
        cin >> x;
    }
    if (k == 1){
        cout << 0 << endl;
        return 0;
    }

    sort(all(v));
    ll minimo = 0, maximo = 0;
    for (ll i=0; i<n; i++){
        ll mi = c(n-i - 1, k - 1), ma = c(i+1 - 1, k - 1);
        // cout << mi << " " << ma << endl;
        if (i <= n-k){
            minimo = (minimo + mod + v[i]*mi)%mod;
        }
        if (i >= k-1){
            maximo = (maximo + mod + v[i]*ma)%mod;
        }
    }
    // cout << minimo << " " << maximo << endl;
    cout << ((maximo - minimo) + mod)%mod << endl;
    return 0;
}

Measured memory_bytes: 2560
n,m = map(int,input().split())
ls = []
for i in range(1,int(m**(1/2))+1):
    if m % i == 0:
        ls.append(i)
        ls.append(m//i)
ls = sorted(list(set(ls)),reverse=True)
for j in ls:
    if j*n <= m:
        print(j)
        break


Measured memory_bytes: 9412
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<(#a)<<':'<<(a)<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key < value;
}

int binary_search(vector<ll> a,ll key){
  ll ok = a.size();
  ll ng = -1;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}


int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  int n,m;cin>>n>>m;
  
  vector<vector<int> >s(m,vector<int>(0));
  vector<int> k(m);rep(i,m){
    cin>>k[i];
    vector<int> tmp(k[i]);
    rep(j,k[i])cin>>tmp[j];
    s[i] = tmp;
  }
  vector<int> p(m);rep(i,m)cin>>p[i];
  int ans = 0;
  rep(i,1<<n){
    bitset<10> bs(i);
    bool isOk = true;
    rep(j,m){
      int tmp = 0;
      rep(l,k[j]){
        tmp += bs[(s[j][l]-1)];
      }
      isOk &= p[j] == tmp%2;
    }
    ans += isOk;
  }
  print(ans);
  return 0;
} 


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main
{

  static boolean[][] z = new boolean[22][22];
  static boolean[][] zz = new boolean[22][22];
  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");

    System.out.println(sl[0].contains("7") ? "Yes" : "No");
  }

}

class RemRing
{
  long module;

  public RemRing(long module)
  {
    this.module = module;
  }

  public long sum(long a, long b)
  {
    return (a + b + module) % module;
  }

  public long sub(long a, long b)
  {
    return (a - b + module) % module;
  }

  public long prod(long a, long b)
  {
    return (a * b) % module;
  }

  public long div(long a, long b)
  {
    return (a * inv(b)) % module;
  }

  public long inv(long a)
  {
    long b = this.module;
    long u = 1;
    long v = 0;
    while (b > 0)
    {
      long t = a / b;
      a -= t * b;
      u -= t * v;
      long z = a;
      a = b;
      b = z;
      z = u;
      u = v;
      v = z;
    }
    u %= this.module;
    if (u < 0)
      u += this.module;
    return u;
  }
}


Measured memory_bytes: 32528
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int i = a * b;
  if(i % 2 == 0){
    cout<<"Even"<<endl;
  }
 if(i % 2 == 1){
    cout<<"Odd"<<endl;
  }
}

Measured memory_bytes: 3068
#include <stdio.h>

void swap(int *x, int *y)
{
  int temp = *x;
  *x = *y;
  *y = temp;
}

int main()
{
  int count;
  scanf("%d", &count);
  int numbers[count - 1], sortCounts = 0;

  for (int i = 0; i < count; ++i)
  {
    scanf("%d", &numbers[i]);
  }

  int swaped = 1, swapCount;

  while (swaped == 1)
  {
    swaped = 0;
    for (int j = 1; j < count; ++j)
    {
      if (numbers[j - 1] > numbers[j])
      {
        swapCount++;
        swap(&numbers[j - 1], &numbers[j]);
        swaped = 1;
      }
    }
  }

  for (int l = 0; l < count; ++l)
  {
    if (l == count - 1)
    {
      printf("%d", numbers[l]);
    }
    else
      printf("%d ", numbers[l]);
  }
  printf("\n%d\n", swapCount);

  return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    if(a==0)
        cout<<1<<endl;
    else if (b==0)
        cout<<2<<endl;
    else if (c==0)
    {
        cout<<3<<endl;
    }
    else if (d==0)
        cout<<4<<endl;
    else if (e==0)
    {
        cout<<5<<endl;
    }
}


Measured memory_bytes: 3592
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;
typedef long long LL;
const int MaxN = 1e5;
const int Inf = 1 << 30;

int main()
{
	int a,b,c,d;
	while(~scanf("%d%d%d%d",&a,&b,&c,&d)){
		printf("%d\n",max(a*b,c*d));
	}
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P; 
#define INF 100000000
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
   ll a,b,k;
   cin>>a>>b>>k;
   OUT(max((ll)0,a-k));
   OUT(max((ll)0,(b+min(a-k,(ll)0))));
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <climits>
#include <iomanip>
#define endl "\n"
#define debug(x) cout << #x << " : " << x << endl;
#define debug2(x, y) cout << #x << " : " << x  << ", " << #y << " : " << y << endl;
#define FASTIO ios_base::sync_with_stdio(false),cin.tie(0);
typedef long long ll;
using namespace std;

#define mod 1000000007

ll fermat(ll base, ll exp)
{
	ll res = 1;
	while(exp)
	{
		if(exp % 2 == 1)
			res = ((res % mod) * (base % mod)) % mod;
		base = ((base % mod) * (base % mod)) % mod;
		exp /= 2;
	}
	return res;
}

int main()
{

	FASTIO

	ll s;
	cin >> s;

	ll fact[2005];
	fact[0] = 1;

	for(ll i = 1; i <= 2000; i ++)
		fact[i] = (i * (fact[i - 1] % mod)) % mod;

	ll finalAns = 0;
	for(ll i = 1; i <= 2000; i ++)
	{
		ll num = s - 3 * (i);
		if(num < 0)
			break;
		ll den = i;

		ll numVal = fact[num + den - 1];		
		ll denVal = (((fact[num]) % mod) * (fact[den - 1])) % mod;

		ll denInv = fermat(denVal, mod - 2);

		ll ans = ((numVal % mod) * (denInv % mod)) % mod;
		finalAns += ans;

	}
	cout << finalAns % mod << endl;
		
}

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

int main(void){
  int H1, M1, H2, M2, K, x;

  cin >> H1 >> M1 >> H2 >> M2 >> K;

  x = (H2 * 60 + M2) - (H1 * 60 + M1) - K;

  cout << x << endl;
}

Measured memory_bytes: 3544
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[20][20];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}
ll dp[20500];
int main() {
	ll a, b;
	cin >> a >> b;
	if (a <= 0 && b >= 0) {
		cout << "Zero" << endl;
	}
	else if (a > 0 && b > 0) {
		cout << "Positive" << endl;
	}
	else if (a < 0 && b < 0) {
		if ((abs(a - b)+1) % 2 == 0) {
			cout << "Positive" << endl;
		}
		else {
			cout << "Negative" << endl;
		}
	}
}

Measured memory_bytes: 256
N = int(input())
c = input()

# 色を変えるのは、１つの石のみで、遅い
# 入れ替える場合はは、赤と白が左と右にある場合２つの石に効果を上げられるのでよい
# まずは入れ替えを考え、これ以上入れ替えれない（効果が少ない時）色を変える
# 理想は、wwww,,,RRRRと並ぶこと

def is_ok(c):
  s = True
  # どこかにW->Rの変化がある場合、false
  for i, p in enumerate(c[:-1]):
    if p == 'W':
      if c[i+1] == 'R':
        s = False
        break
  return s

if is_ok(c):
  print(0)
  exit()


# 下では最小となっていない
# 最小になるためには、Wだけ、Rだけにする方が早い場合もある

# WとRの数で、並べると最後の正解の並び方がわかり、それと最初との差分を取ることができるはず
Wn = len([x for x in c if x == 'W'])
Rn = len([x for x in c if x == 'R'])
# print(Wn, Rn)
c_r = 'R'*Rn+'W'*Wn
# print(c_r)
# print(c)

w_cnt = 0
for i in range(len(c)):
  if c_r[i] != c[i]:
    w_cnt += 1
# print(w_cnt)

# 入れ替えで最小にする場合の最小数
# 間違いが偶数だとそのまま割り算で答え、奇数だと1を足した操作数
if w_cnt % 2 == 0:
  a_c = int(w_cnt/2)
else:
  a_c = int((w_cnt+1)/2)
# print('a_c', a_c)

# WRRの場合は、WをRに変える方が早い
c_rr = 'R' * len(c)
r_cnt = 0
for i in range(len(c)):
  if c_rr[i] != c[i]:
    r_cnt += 1
a_r = r_cnt
# print('a_r', a_r)

print(min([a_c, a_r]))

# WWRWRRR


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

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

    static class ABC116_A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();

            int max = Math.max(Math.max(a, b), c);

            out.print(a * b * c / max / 2);


        }

    }
}



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

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

typedef vector<int>vec;
typedef vector<vec>mat;

mat mul(mat A,mat B){
    mat C(A.size(),vec(B[0].size()));
    rep(i,C.size()){
        rep(j,C[0].size()){
            rep(k,A[0].size()){
                C[i][j]|=A[i][k]&B[k][j];
            }
        }
    }
    return C;
}

mat mat_pow(mat A,int m){
    mat B(A.size(),vec(A.size()));
    rep(i,A.size())B[i][i]=1;
    while(m){
        if(m&1)B=mul(B,A);
        A=mul(A,A);
        m>>=1;
    }
    return B;
}

int N,M,Z;
int E[50][2];
void solve(){
    mat R(M*2,vec(M*2));
    mat X(M*2,vec(1));
    rep(i,M){
        rep(j,2){
            if(E[i][j]==0){
                X[i*2+1-j][0]=1;
            }
        }
    }
    rep(i,M){
        rep(j,M){
            if(i==j)continue;
            rep(k,2)rep(l,2){
                if(E[i][k]==E[j][l]){
                    R[i*2+1-k][j*2+l]=1;
                }
            }
        }
    }
    X=mul(mat_pow(R,Z-1),X);
    rep(i,M){
        rep(j,2){
            if(E[i][j]==N-1&&X[i*2+j][0]){
                cout<<"yes"<<endl;
                return;
            }
        }
    }
    cout<<"no"<<endl;
}

signed main(){
    while(scanf("%lld%lld%lld",&N,&M,&Z),N||M||Z){
        rep(i,M)rep(j,2)cin>>E[i][j],E[i][j]--;
        solve();
    }
    return 0;
}

Measured memory_bytes: 3476
main(){
	double c;int n,m,d;
	scanf("%d%d%d",&n,&m,&d);
	c=(m-1.0)/n;
	if(d==0)printf("%.12lf\n",c);else
		printf("%.12lf\n",2.0*(n-d)/n*c);
	return 0;
}


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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int w,a,b; cin >> w >> a >> b;

  int ans;
  if(a+w<b){
    ans = b-(a+w);
    cout << ans << endl;
  }
  else if(b+w<a){
    ans = a-(b+w);
    cout << ans << endl;
  }
  else cout << "0" << endl;
  
  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n, m;
    cin >> n >> m;
    vl a(n);
    rep(i, n) cin >> a[i];
    vector<pll> v(m);
    rep(i, m) {
        ll b, c;
        cin >> b >> c;
        v[i] = make_pair(c, b);
    }
    sort(rall(v));
    sort(all(a));
    int id = 0;
    rep(i, m) {
        ll b = v[i].se, c = v[i].fi;
        while(b > 0 && id < n) {
            if(a[id] > c) break;
            a[id] = c;
            b--;
            id++;
        }
    }
    ll sum = 0LL;
    rep(i, n) sum += a[i];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define maxn
#define maxm
#define maxb
#define maxr 200000
#define maxs
#define M 
#define pii pair<int, int>
#define pdd pair<double, double>
#define uint unsigned int
#define ull unsigned long long int
#define ll long long int 
#define lowbit(x) x & -x
#define fi first
#define se second
#define pb push_back
#define next NEXT
#define hash HASH
#define ls ch[x][0]
#define rs ch[x][1]
#define pi 3.141592653589793
#define ei 2.718281828459045
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
#define srep(i, l, r) for (register int i = l; i < r; i++)
#define sper(i, r, l) for (register int i = r; i > l; i--)
#define erep(i, x) for (register int i = h[x]; i; i = e[i].next)
#define gc() ((p1 == p2 && (p2 = (p1 = buffer) + fread(buffer, 1, maxr, stdin), p1 == p2)) ? EOF : *p1++)
//#define ONLINE_JUDGE
//#define DEBUG
using namespace std;

char *p1, *p2, buffer[maxr];
template <class T> void read(T& x){
    char ch = gc(); x = 0; bool f = 1;
    while (!('0' <= ch && ch <= '9') && ch != '-') ch = gc();
    if (ch == '-') f = 0, ch = gc();
    while ('0' <= ch && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = gc();
    x = f ? x : -x;
}

int gcd(int x, int y){
	if (!y) return x;
	return gcd(y, x % y);
}

int main(){
	int x;
	scanf("%d", &x);
	printf("%d", x * 360 / gcd(x, 360) / x); 
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)

typedef long long LL;
typedef long double LD;

struct sta{
  int x;
  int pre;
  int ppre;
};

int main(){
  int n,m,s,t;
  cin >> n >> m >> s >> t;
  s--,t--;
  vector<vector<int>> e(n);
  int u,v;
  rep(i,m){
    cin >> u >> v;
    e[u-1].push_back(v-1);
    e[v-1].push_back(u-1);
  }
  int len;
  vector<LL> sd(n+1,0),td(n+1,0);
  vector<int> dist(n,-1);
  queue<pair<int,int>> q;
  q.push({s,0});
  dist[s]=0;
  while(!q.empty()){
    auto now = q.front();
    q.pop();
    for(int nx:e[now.first]){
      if(dist[nx]==-1){
        dist[nx]=now.second+1;
        q.push({nx,now.second+1});
      }else{ 
        if(dist[nx]==now.second+1){
        }
      }
    }
  }
  rep(i,n) if(dist[i]!=-1) sd[dist[i]]++;
  len=dist[t];
  dist=vector<int>(n,-1);
  q.push({t,0});
  dist[t]=0;
  while(!q.empty()){
    auto now = q.front();
    q.pop();
    for(int nx:e[now.first]){
      if(dist[nx]==-1){
        dist[nx]=now.second+1;
        q.push({nx,now.second+1});
      }else{ 
        if(dist[nx]==now.second+1){
        }
      }
    }
  }
  rep(i,n) if(dist[i]!=-1) td[dist[i]]++;
  LL ans=0;
  rep(i,len-1){
    if(len-2-i<0) break;
    ans+=sd[i]*td[len-2-i];
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 11840
import sys
def input():
    return sys.stdin.readline()[:-1]
def main():
    N = int(input())
    P = []
    for k in range(1,1+int((N-1)**(1/2))):
        if (N-1)%k == 0:
            P.append((N-1)//k)
            P.append(k)
    P = set(P)
    ans = len(P)
    for k in range(2,1+int(N**(1/2))):
        if N%k == 0:
            t = N//k
            while t%k == 0:
                t //= k
            if t%k == 1:
                ans += 1
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 9404
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;

unsigned getdigit(unsigned NUM){
    return log10(NUM) + 1;
}

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

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;
const ll INF = 1e9 + 7;

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


/////////////////////////////////////////////////////////////////////////////////////////
int main(){
    int n,m;
    cin >> n >> m;

    map<int,int> ac,wa;

    for (int i = 0;i < m;i++){
        int p;
        string s;
        cin >> p >> s;

        if (s == "AC") ac[p]++;
        if (ac[p] == 0){
            wa[p]++;
        }
    }

    int AC = 0,WA = 0;
    for (auto a : ac){
        if (a.second > 0) AC++;
    }
    
    for (auto b : wa){
        if (ac[b.first] > 0){
            WA += b.second;
        }
    }

    cout << AC << " " << WA << endl;
}

Measured memory_bytes: 6144
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let x = read::<String>();
  let y = read::<String>();

  println!(
    "{}",
    if x < y {
      "<"
    } else if y < x {
      ">"
    } else {
      "="
    }
  );
}



Measured memory_bytes: 4352
//Abu Sayeb Rayhan
//Comilla University
//13 March,2020

#include<bits/stdc++.h>
#define lli long long int
#define pi 2*acos(0.0)
#define spc " "
#define mod 100000009
#define forn(a,n) for(int i=a;i<n;i++)
#define sayeb ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define boss cout<<"sayeb"<<endl
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define maxi 10000000000000000
int ar[10000000];
using namespace std;

void solve()
{
    int k;
    cin>>k;
    vector<int>v{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout<<v[k-1]<<endl;
}

int main()
{
	sayeb;
    int t;
    //cin>>t;while(t--)
    solve();
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define sol (k+k)
#define sag (k+k+1)
#define orta ((bas+son)/2)
#define inf 1000000000000000007
#define mod 1000000007
#define N 100005
using namespace std;
typedef long long ll;

ll n, x, y, ans, a[N], seg[2][4*N], sif[2][4*N];//[0] = x [1] = y

void put(ll d, ll k){
	seg[d][k] = 0;
	sif[d][k] = 1;
}

void push(ll d, ll k){
	if(sif[d][k]){
		put(d, sol);
		put(d, sag);
		sif[d][k] = 0;
	}
}

void up(ll d, ll k, ll bas, ll son, ll x, ll y){
	if(bas == son){
		seg[d][k] = (seg[d][k] + y)%mod;
		return;
	}
	push(d, k);
	if(x <= orta)
		up(d, sol, bas, orta, x, y);
	else
		up(d, sag, orta + 1, son, x, y);
	seg[d][k] = (seg[d][sol] + seg[d][sag])%mod;
}

ll qu(ll d, ll k, ll bas, ll son, ll x, ll y){
	if(bas > y or son < x)
		return 0;
	if(bas >= x and son <= y)
		return seg[d][k];
	push(d, k);
	return (qu(d, sol, bas, orta, x, y) + qu(d, sag, orta + 1, son, x, y))%mod;
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%lld %lld %lld",&n ,&x ,&y);
	for(ll i = 1; i <= n; i++)
		scanf("%lld",a + i);

	a[0] = -inf;

	up(0, 1, 0, n, 0, 1);
	up(1, 1, 0, n, 0, 1);

	for(ll i = 2; i <= n; i++){

		ll top1 = 0, top2 = 0;

		ll ind = upper_bound(a + 1, a + n + 1, a[i] - y) - a - 1;
		top1 = qu(0, 1, 0, n, 0, ind);

		ind = upper_bound(a + 1, a + n + 1, a[i] - x) - a - 1;
		top2 = qu(1, 1, 0, n, 0, ind);


		if(a[i] - a[i - 1] < x)
			put(0, 1);

		if(a[i] - a[i - 1] < y)
			put(1, 1);


		up(1, 1, 0, n, i - 1, top1);
		up(0, 1, 0, n, i - 1, top2);

	}
	ans = (qu(0, 1, 0, n, 0, n) + qu(1, 1, 0, n, 0, n))%mod;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 13312
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define mod 1000000007
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main()
{
    fastio;
    int n,m;
    cin >> n >> m;
    int ans1=0,ans2=0;
    if(n>0)
        ans1=(n*(n-1))/2;
    if(m>0)
        ans2=(m*(m-1))/2;
    cout << ans1+ans2 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int m,f,b,r;
	scanf("%d%d%d",&m,&f,&b);
	r=b-m;
	if(r>0&&f>=r){
		printf("%d\n",r);
	}else if(r>0&&f<r){
		printf("NA\n");
	}else{
		printf("%d\n",0);
	}
	return 0;
}



Measured memory_bytes: 2728
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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 main(){
    ll n,m;cin >> n >>m;
    vvl v(n,vl(n,inf));
    vpl p(m);vl w(m);
    rep(i,n)v[i][i]=0;
    rep(i,m){
        ll a,b,c;cin >>a >>b >>c;a--;b--;
        v[a][b]=c;v[b][a]=c;
        p[i].fi=a;p[i].se=b;w[i]=c;
    }
    rep(k,n)rep(i,n)rep(j,n)chmin(v[i][j],v[i][k]+v[k][j]);
    ll ans=0;
    rep(i,m){
        ll x=p[i].fi,y=p[i].se,c=w[i];
        if(v[x][y]!=c)ans++;
    }
    cout <<ans <<endl;
}

Measured memory_bytes: 384
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int n, x;
    scan(n, x);
    auto a = readln.split.to!(int[]);

    long ans = inf6;

    auto deq = Deque!(int)(n);

    foreach (k ; 0 .. n) {
        long t = 1L * k * x;

        deq.clear();
        foreach (i ; 0 .. k + 1) {
            while (!deq.empty && a[deq.back] >= a[i]) {
                deq.popBack();
            }
            deq.pushBack(i);
        }

        debug {
            writeln("k:", k);
            writeln(deq);
        }

        t += a[deq.front];

        foreach (i ; k + 1 .. n + k) {
            while (!deq.empty && deq.front < i - k) {
                deq.popFront();
            }
            while (!deq.empty && a[(deq.back) % n] >= a[i % n]) {
                deq.popBack();
            }
            deq.pushBack(i);
            debug {
                writefln("i: %d, deq: %s", i, deq);
            }
            t += a[deq.front % n];
        }

        ans = min(ans, t);
    }

    writeln(ans);
}


struct Deque(T) {
    private {
        int N, head, tail;
        T[] deq;
    }

    this(int n) {
        N = n + 1;
        deq = new T[](N + 1);
    }

    void clear() {
        head = tail;
    }

    bool empty() {
        return head == tail;
    }

    bool full() {
        return head == ((tail + 1) % N);
    }

    int length() {
        return (tail - head + N) % N;
    }

    T front() {
        assert(!empty);
        return deq[head];
    }

    T back() {
        assert(!empty);
        return deq[(tail - 1 + N) % N];
    }

    void pushFront(T x) {
        assert(!full);
        head = (head - 1 + N) % N;
        deq[head] = x;
    }

    void pushBack(T x) {
        assert(!full);
        deq[tail++] = x;
        tail %= N;
    }

    void popFront() {
        assert(!empty);
        head = (head + 1) % N;
    }

    void popBack() {
        assert(!empty);
        tail = (tail - 1 + N) % N;
    }

    alias insert = pushBack;
    alias removeFront = popFront;
    alias removeBack = popBack;

    T opIndex(size_t index)
    in {
        assert(0 <= index && index < length);
    }
    body {
        return deq[(head + index) % N];
    }

    alias opDollar = length;
}







void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 2428
from sys import stdin, stdout, stderr

a = [0] * 50
lim = 10**6

while 1:
    n, p = map(int, stdin.readline().split())

    if n + p == 0:
        break

    wan = p
    i = 0

    for i in range(lim):
        pos = i % n

        if wan > 0:
            a[pos] += 1
            wan -= 1

            if a[pos] == p:
                print(pos)
                a[pos] = 0
                break
        else:
            wan += a[pos]
            a[pos] = 0

Measured memory_bytes: 7688
# include <bits/stdc++.h>
# define ll long long
using namespace std;
const int N = 2e5 + 10, INF = 1e9 + 100, lg = 19;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int a, b, c;
	cin >> a >> b >> c;
	if((a == b && b != c) || (a == c && c != b) || (c == b && c != a)){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}
}


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


def solve(N: int, X: int, m: "List[int]"):
    ms = sorted(m)
    count = N
    account = X - sum(ms)
    while account - ms[0] >= 0:
        account -= ms[0]
        count += 1
    print(count)

# 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
    X = int(next(tokens))  # type: int
    m = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, X, m)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064