akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#include <set>
#include <map>
#include <complex>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000; //10^15
typedef long long ll;
typedef unsigned long long ull;


ll powMod(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll t = powMod(x, n/2, mod);
  t = t * t % mod;
  if (n & 1) return t * x % mod;
  return t;
}

int get_parent(int i, int *parent) {
  while (i != parent[i]) i = parent[i];
  return i;
}

void Union(int i, int j, int *parent, int *rank) {
  i = get_parent(i, parent);
  j = get_parent(j, parent);
  if (i == j) return;
  if (rank[i] < rank[j]) swap(i, j);
  parent[j] = i;
  rank[i] = max(rank[i], rank[j] + 1);
  return;
}

int main(void) {

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

  int parent[100100], rank[100100] = {}, c, d;
  int f[100100] = {}, b[100100] = {};
  rep(i, n) parent[i] = i;
  rep(i, m) {
    scanf("%d %d", &c, &d);
    c--; d--;
    Union(c, d, parent, rank);
    f[c]++; f[d]++;
  }
  rep(i, k) {
    scanf("%d %d", &c, &d);
    c--; d--;
    if (get_parent(c, parent) == get_parent(d, parent)) {
      b[c]++; b[d]++;
    }
  }

  int cnt[100100] = {}, p[100100];
  rep(i, n) {
    p[i] = get_parent(i, parent);
    cnt[p[i]]++;
  }

  rep(i, n) {
    printf("%d ", cnt[p[i]] - b[i] - f[i] - 1);
  }
  printf("\n");

  return 0;

}

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

using namespace std;

int main() {
	int n, somat = 0, somap = 0, mini;
	int vet[105];
	scanf("%d", &n);
	for(int i = 0; i < n; ++i) {
		scanf("%d", &vet[i]);
		somat += vet[i];
	}
	somap = somat;
	mini = 1e9;
	for(int i = 0; i < n; ++i) {
		somap -= vet[i];
		mini = min(mini, abs(somat - 2*somap));
	}
	printf("%d\n", mini);
	return 0;
}

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

#define rep_(v, f, l) for (int v = (f), v##_ = (l); v < v##_; ++v)
#define rep(v, n) rep_(v, 0, n)
#define lep(v, n) rep_(v, 1, n + 1)
#define rrep_(v, f, l) for (int v = (l), v##_ = (f); v >= v##_; --v)
#define rrep(v, n) rrep_(v, 0, n - 1)
#define rlep(v, n) rrep_(v, 1, n)
#define show_a(a, size) rep(a##_it, size) std::cout << a[a##_it] << " \n"[a##_it == a##_it_ - 1];
#define show_v(v) show_a(v, v.size())
#define eachv(v, i) rep(i, v.size())
#define reachv(v, i) rrep(i, v.size())
#define debug(x) std::cerr << #x << " = " << x << "\n";

using namespace std;

typedef long long int lint;

static inline int in(){ int x; scanf("%d", &x); return x; }
static inline lint inl(){ lint x; scanf("%lld", &x); return x; }

int main()
{
    int a;
    while (a = in() + in()){
        vector<pair<int, char> > stores;
        stores.push_back(make_pair(a, 'A'));
        rep(i, 4){
            stores.push_back(make_pair(in() + in(), 'B' + i));
        }
        sort(stores.begin(), stores.end(), greater<pair<int, char> >());
        printf("%c %d\n", stores[0].second, stores[0].first);
    }
    return (0);
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll N = 0;
  cin >> N;
  vector<ll>A(N);
  ll sum = 0;
  rep(i,N){
    cin >> A[i];
    sum += A[i];
    sum %= 1000000007;
  }
  ll ans = 0;
  rep(i,N-1){
    if(sum - A[i] >= 0){
      sum = sum - A[i];
      ans += (A[i] * sum) % 1000000007;
    }
    else{
      sum = sum - A[i] + 1000000007;
      ans += (A[i] * sum) % 1000000007;   
    }
  }
  cout << ans % 1000000007;
}
    

Measured memory_bytes: 4828
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

ll dp[100005][2][110];

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

    string s; cin >> s;
    int n = s.size();
    int D; cin >> D;

    dp[0][0][0] = 1;
    rep(i, n) rep(j, 2) rep(k, D){
        int lim = j? 9:s[i]-'0';
        rep(d, lim+1){
            (dp[i+1][j || d<lim][(k+d)%D] += dp[i][j][k]) %= mod;
        }
    }

    ll ans = 0;
    rep(j, 2) ans += dp[n][j][0], chmod(ans);
    ans -= 1;
    chmod(ans);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 18688
#include<bits/stdc++.h>
#define int long long
#define double long double
#define vi vector<int>
#define vpi vector<pair<int,int> >
#define mii map<int,int>
#define mpi map<pair<int,int>,int>
#define msi map<string,int>
#define set set<int>
#define u_set unordered_set<int>
#define pb push_back
#define endl "\n"
#define ll long long int
#define vll vector<long long int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define umap unordered_map 
#define mod 1000000007
#define fori(a,n) for(int i=a;i<n;i++)
#define forj(a,n) for(int j=a;j<n;j++)
#define MAX 300303
#define V vector
using namespace std;
int H,W;
char a;
V<V<char>> grid(1001,V<char>(1001));
vvi dp(1001,vi(1001,-1));
int rec(int i,int j){
    if(i >= H || j >= W || grid[i][j] == '#')return 0;
    if(i == H-1 && j == W-1)return 1;
    if(dp[i][j] != -1)return dp[i][j];
    return dp[i][j] = (rec(i+1,j) + rec(i,j+1) + mod)%mod;
}
signed main()
{
    io
    cin >> H >> W;
    fori(0,H)
        forj(0,W)
            cin >> grid[i][j];
    cout << rec(0,0) << endl;
}

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

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' '; cout << endl;
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' '; cout << endl;
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 1e5 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e18 + 7;
const ll infll = 1e18 + 7;

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, m; cin >> n >> m;
    ForE(i, 1, m){
        int x; cin >> x; n -= x;
    }
    if (n < 0) Ptest(-1);
    cout << n;
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#ifdef JLOCAL
#include "stress.h"
#endif
using namespace std;

#define rep(i, z, n) for (int i = (z); i < int(n); ++i)
#define repr(i, n, z) for (int i = int(n) - 1; i >= (z); --i)
#define shl(n) (1 << (n))
#define hbit(n, i) (((n) >> (i)) & 1)

#define STRESS 0
using lint = long long;

vector<int> g[111111];
int cs[111111];
int cn[111111];
bool used[111111];

void dfs(int v, int c) {
    cs[c]++;
    cn[v] = c;
    used[v] = true;
    for (int i : g[v]) {
        if (!used[i]) {
            dfs(i, c);
        }
    }
}

void solve(istream& cin, ostream& cout) {
    int n;
    cin >> n;
    vector<int> a(n + 1);
    int x = 0;
    rep(i, 0, n) {
        cin >> a[i];
        x ^= a[i];
    }
    a[n] = x;
    vector<int> b(n + 1);
    x = 0;
    rep(i, 0, n) {
        cin >> b[i];
        x ^= b[i];
    }
    b[n] = x;

    auto ax = a;
    auto bx = b;
    sort(ax.begin(), ax.end());
    sort(bx.begin(), bx.end());
    if (ax != bx) {
        cout << -1;
        return;
    }

    x = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] != b[i]) {
            x++;
            int p = lower_bound(ax.begin(), ax.end(), a[i]) - ax.begin();
            int q = lower_bound(ax.begin(), ax.end(), b[i]) - ax.begin();
            g[p].push_back(q);
            g[q].push_back(p);
        }
    }

    if (x == 0) {
        cout << 0;
        return;
    }

    int cc = 0;
    for (int i = 0; i <= n; i++) {
        if (!used[i]) {
            dfs(i, cc++);
        }
    }

    for (int i = 0; i < cc; i++) {
        if (cn[lower_bound(ax.begin(), ax.end(), a[n]) - ax.begin()] != i && cs[i] >= 2) {
            x++;
        }
    }
    cout << x;
}

int main() {
#if !defined(JLOCAL) || !STRESS
#ifdef JLOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve(cin, cout);
#else
    srand();
    for (int ti = 0; ti < 100; ti++) {
        stress::gen();
        stress::stupid();
        ifstream in("input.txt");
        ofstream out("output.txt");
        solve(in, out);
        out.flush();
        stress::check();
    }
    cout << "ok" << endl;
#endif
    return 0;
}


Measured memory_bytes: 11136
N,M = map(int,input().split(" "))
switch = []
for i in range(M):
    tmp = list(map(int,input().split(" ")))
    switch.append(tmp)

p = list(map(int,input().split(" ")))


light = [0 for i in range(N)] 



def search(N,M,switch,p,l,light):
    if l<N:
        l += 1
        a=search(N,M,switch,p,l,light)
        light[l-1]+=1 
        b = search(N,M,switch,p,l,light)
        return a+b
    else:
        flag = 0
        for i in range(M):
            a = 0
            for j in range(switch[i][0]):
                a +=light[switch[i][j+1]-1]
            if a%2 == p[i]:
                continue
            else:
                flag = 1
                break
        if flag == 0:
            return 1
        else:
            return 0
  

ans = search(N,M,switch,p,0,light)
print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    string a;
    cin >> a;
    int n = 0, w = 0, s = 0, e = 0;
    for (auto t : a) {
        if (t == 'N')
            n++;
        if (t == 'E')
            e++;
        if (t == 'S')
            s++;
        if (t == 'W')
            w++;
    }
    if ((n == 0 && s > 0) || (n > 0 && s == 0))
        cout << "No" << endl;
    else if ((w == 0 && e > 0) || (w > 0 && e == 0))
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string> 
using namespace std;
char s[200010];
long long ans, cnt[2000];
int main() {
	scanf("%s", s);
	int n = strlen(s);
	for(int i = 0; i < n; i++) {
		ans += i - cnt[s[i]];
		cnt[s[i]]++;
	}
	printf("%lld", ans + 1);
} 

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using Graph = vector<vector<int> >;
using P = pair<int, int>; 
// MOD
const int mod = 1000000007;
using ll = long long;
long long INF = 1<<30;
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
//int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 
mint f(int n) {
  if (n == 0) return 1;
  mint x = f(n/2);
  x *= x;
  if (n%2 == 1) x *= 2;
  return x;
}
 
mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i,a) {
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double PI=3.14159265358979323846;
bool seen[100][100];

bool memo[110];
bool flag;
Graph G;

int dist[100][100];

bool compare_f(pair<int, int> &x, pair<int, int> &y) {
  return x.second< y.second;
}


struct Unionfind{
    vector<int> par;

    Unionfind(int n) : par(n, -1){}

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

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

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

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

ll sum(ll l, ll r){
    return (l+r)*(r-l+1)/2;
}


int main() {
    int n, k; cin >> n >> k;
    mint ans = 0;
    for(int i=k; i<=n+1; i++){
        ll l = sum(0, i-1), r = sum(n-i+1, n);
        ans += (r - l + 1);
    }
    cout << ans.x << endl;
}

Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
long long a[110];
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int ans=0;
	for (int i=1;i<=n;i++){
		for (int j=i+1;j<=n;j++){
			for (int k=j+1;k<=n;k++){
				if (a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k]&&a[i]+a[j]>a[k]&&a[i]+a[k]>a[j]&&a[j]+a[k]>a[i]) {
					ans++;
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;


//      DEEP

using namespace std;
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define pb push_back
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pi;
typedef pair<long long,long long> pll;
typedef set<int> si;


/*
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
*/
/*
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
*/

const ll mod = 1e9 + 7;
const ll modl=998244353;
const double pie=3.1415926535;
                                                    //power
ull power(ull x,ull y){
   if(y==0) return 1;
   else{
     if(y%2==0) return power(x*x,y/2);
     else return x*power(x*x,(y-1)/2);
   }
}

                        //                    Modular Exponentiation

ll mod_power(ll x, ll y, ll m)
{
    ll r = 1;     // Initialize result

    x = x % m; // Update x if it is more than or equal to m

    if (x == 0) return 0; // In case x is divisible by m;

    while (y > 0)
    {
        // If y is odd, multiply x with result
        if (y & 1)
            r = (r*x) % m;

        // y must be even now
        y = y/2;
        x = (x*x) % m;
    }
    return r;
}

                                                      //GCD
ll gcd(ll x,ll y){
   if(y==0)return x;
   return gcd(y,x%y);
}
                                              // SIEVE

/*
bool isPrime[100001];
void sieve(int N) {

        for(int i = 0; i <= N;++i) {
            isPrime[i]=true;
        }
        isPrime[0]=false;
        isPrime[1]=false;

        for(int i = 2; i * i <= N; ++i) {
             if(isPrime[i] == true) {
                 for(int j = i * i; j <= N ;j += i)
                     isPrime[j] = false;
            }
        }
    }
*/

int main(){
    boost;
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
      double h,a;
      cin>>h>>a;
      int ans=ceil(h/a);
      cout<<ans<<endl;
 }
}















Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
#define INF 1000000000
typedef long long int ll;
typedef pair<ll,ll> P;
template <typename T> std::string tostr(const T& t){std::ostringstream os; os<<t; return os.str();}
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
 
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<a*b/2<<endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
s=[]
t=[]
for i in range(n):
    ts,tt=input().split()
    s.append(ts)
    t.append(int(tt))
x=input()
ans=0
ok=False
for i in range(n):
    if ok:
        ans += t[i]
    if s[i]==x:
        ok=True
print(ans)

Measured memory_bytes: 38384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
    int N,M;
    int s[5];
    char c[5][2];
    char num[5];
    scanf("%d %d",&N,&M);
    for(int i = 0 ; i < M ; i++){
        scanf("%d %s",&s[i],&c[i]);
    }
    int begin,end;
    switch(N){
        case 1:
            begin = 0;
            end = 9;
            break;
        case 2:
            begin = 10;
            end = 99;
            break;
        case 3:
            begin = 100;
            end = 999;
            break;
    }
    int flg,ans=-1;
    for(int i = begin ; i <= end ; i++){
        sprintf(num,"%d",i);
        flg = 1;
        for(int j = 0 ; j < M ; j++){
            if(num[s[j] - 1] != c[j][0]){
                flg = 0;
                break;
            }
        }
        if(flg == 1){
            ans = i;
            break;
        }
    }
    printf("%d",ans);

    return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int r;
    cin >> r;
    double ans = 2 * PI * r;
    printf("%.10f\n", ans);
    return 0;
}


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

using namespace std;

#define endl '\n'

typedef long long ll;

int main()
{
#ifdef jcg
	assert(freopen("input.in", "r", stdin));
	// assert(freopen("output.out", "w", stdout));
#endif

	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;

	vector<ll> a(n), b(n);

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

	ll ans = 0;

	for (int i = n - 1; i >= 0; --i)
	{
		ll mul = (ans + a[i] + b[i] - 1) / b[i] * b[i];
		ans += mul - ans - a[i];
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>
# define MOD 1000000000+7
# define INF 1e9
# define LINF 1e18
typedef long long ll;

using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int n = 1, d[100000] = {};
int abc = 0, arc = 0, ans = 0;

int main() {

	
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	sort(d, d + n);

	cout << d[n/2] - d[n/2-1] << endl;




}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

vector<ll> e[MAXn];
ll dp[MAXn][2];
ll mul(ll x,ll y){
  ll ret = x*y;
  return ret%MOD;
}
void dfs(ll x,ll p){
  dp[x][0] = dp[x][1] = 1;
  for (auto i:e[x]) {
    if (i == p) continue;
    dfs(i,x);
    dp[x][0] = mul(dp[x][0],dp[i][0]+dp[i][1]);
    dp[x][1] = mul(dp[x][1],dp[i][0]);
  }
}
int main(){
  IOS();
  ll n;
  cin >> n;
  REP (i,n-1) {
    ll u,v;
    cin >> u >> v;
    u--,v--;
    e[u].eb(v);
    e[v].eb(u);
  }

  dfs(0,0);
  cout << (dp[0][0] + dp[0][1])%MOD << endl;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  if(a<b){
    cout << "a < b" << endl; 
  }
  else if(a>b){
    cout << "a > b" << endl;
  }
  else {
    cout << "a == b" << endl;
  }
}



Measured memory_bytes: 3080
#C
import math

S = int(input())
#print(S)#
sum = 0
def gen(n, post, sum):
    #print('n, post, sum -- ', n, post, sum)#
    if n<10: 
        #print(post)#
        if post==0: return n+sum
        else: return n * 10**int(math.log10(post)+1) + post + sum
    else:
        nxn = n//10
        d = n%10
        if post==0: nxpost = d
        else: nxpost = d * 10**int(math.log10(post)+1) + post
        # dの左に+をいれるか否か
        #print('next n, post, sum -- ', nxn, nxpost, sum)
        pluson = gen(nxn, 0, nxpost+sum)  # +入り 
        plusoff = gen(nxn, nxpost, sum) # +なし
        #print(pluson, plusoff)#
        return pluson + plusoff
print(gen(S, 0, 0))   

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

using modint = atcoder::modint998244353;

vector<modint> fact, fact_inv;

void create_mod_tables(int num){
    fact.assign(num+1, 1);
    fact_inv.assign(num+1, 1);
    for(int i=1; i<=num; i++) fact[i] = fact[i-1] * i;
    fact_inv[num] = fact[num].inv();
    for(int i=num; i>0; i--) fact_inv[i-1] = fact_inv[i] * i;
}

modint comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] * fact_inv[k];
}
 
int main(){
	int N;
	cin >> N;
	map<int, int> mp;
	for(int i=0; i<2*N; i++){
		int a;
		cin >> a;
		mp[a]++;
	}
	create_mod_tables(2*N);
    
	// 二重階乗
	vector<modint> ff(2*N+1, 1);
	for(int i=2; i<=2*N; i++) ff[i] = ff[i-2] * i;

	queue<vector<modint>> que;
	for(auto [k, a] : mp){
		vector<modint> v(a/2+1);
		for(int i=0; i<=a/2; i++){
			v[i] = comb_mod(a, 2*i);
			if(i) v[i] *= ff[2*i-1];
		}
		que.push(v);
	}
	while(que.size() > 1){
		auto a = que.front(); que.pop();
		auto b = que.front(); que.pop();
		que.push(atcoder::convolution(a, b));
	}
	modint ans = 0;
	auto& V = que.front();
	int sz = V.size();
	for(int i=0; i<sz; i++){
		modint res = V[i];
		if(i < N) res *= ff[2*(N-i)-1];
		ans += res * (i%2 ? -1 : 1);
	}
	cout << ans.val() << endl;
}


Measured memory_bytes: 14572
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

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

int main() {
    ll N,P;
    cin >> N >> P;
    ll A[N];
    bool existOdd = false;
    rep(i,N){
        cin >> A[i];
        if(A[i]%2==1) existOdd = true;
    }
    ll out = 0;
    if(existOdd) out = pow(2,N-1);
    else{
        if(P==0) out = pow(2,N);
        else out = 0;
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
/*
Original problem: https://atcoder.jp/contests/abc135/tasks/abc135_c
Author: sammochen
*/

#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

using namespace std;

#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)

#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
typedef vector<ll> VLL;
typedef vector<int> VI;

const ll mod = 1e9+7;

namespace SOLVE {
    void main() {
        int n;
		cin >> n;
		VI towns(n+1);
		VI heros(n);
		REP(i,0,n+1) {
			cin >> towns[i];
		}
		REP(i,0,n) {
			cin >> heros[i];
		}
		
		ll ans = 0;
		REP(i,0,n) {
			// greedy: hero should always save own town first
			if (heros[i] <= towns[i]) {
				ans += heros[i];
				towns[i] -= heros[i];
			} else if (heros[i] <= towns[i] + towns[i+1]) {
				ans += heros[i];
				towns[i + 1] -= (heros[i] - towns[i]);
				towns[i] = 0;
			} else {
				ans += (towns[i] + towns[i+1]);
				towns[i + 1] = 0;
				towns[i] = 0;
			}
		}
		cout << ans << endl;

    }
}


signed main() {
	int t;
	t = 1;
	// cin >> t;
	while (t--) {
		SOLVE::main();
	}

	return 0;
}

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

int main() {
  int n, x;
  cin >> n >> x;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  ll ans = 0;
  if (a[0] > x) {
    ans += a[0]-x;
    a[0] = x;
  }
  rep(i,n-1){
    if (a[i] + a[i+1] > x) {
      ans += (a[i] + a[i+1] - x);
      a[i+1] = x - a[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3752
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long N = sc.nextInt();
		long[] input = new long[(int) (N + 1)];
		long div = 0;
		for (int i = 0; i < N + 1; i++) {
			input[i] = sc.nextInt();
			div += input[i];
		}
		div--;
		long nowTop = 1 - input[0];
		long numOfTop = 1;

		for (int i = 0; i < N; i++) {
			// 最深部でないのに、アクティブなノードが0になったときの枝切り
			if (i != N - 1 && nowTop == 0) {
				System.out.println(-1);
				System.exit(0);
			}
			// アクティブなノードが0未満の枝切り
			if (nowTop < 0) {
				System.out.println(-1);
				System.exit(0);
			}

			if (div > 0) {
				// 可能な限り分ける
				long nowDiv = Math.min(nowTop, div);
				div -= nowDiv;
				nowTop += nowDiv;
				numOfTop += nowTop;
				// 分岐できない頂点を除去
				nowTop -= input[i + 1];
			} else {
				// 分けない
				numOfTop += nowTop;
				// 分岐できない頂点を除去
				nowTop -= input[i + 1];
			}
		}
		if (nowTop == 0) {
			System.out.println(numOfTop);
		} else {
			System.out.println(-1);
		}
	}

}


Measured memory_bytes: 60012
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9
typedef pair<mp,mp> mmp;
int dx[] = {0,1,0,-1};//h
int dy[] = {1,0,-1,0};//w

int main(){
	while(1){
	int w,h;
	cin>>w>>h;
	if(w==0)break;
	priority_queue<mmp,vector<mmp> ,greater<mmp> > q;
	vector<vector<vector<int> > > dp(h+2,vector<vector<int> >(w+2,vector<int>(4,inf ) ) );
	vector<vector<int> > s(h+2,vector<int>(w+2,0) );
	int c[4];
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>s[i][j];
		}
	}
	for(int i=0;i<4;i++)cin>>c[i];

	//dp[1][1] = 0;
	q.push(mmp(mp(0,0),mp(1,1) ));
	int res = inf;
	while(!q.empty()){
		mmp now = q.top();
		q.pop();
		int cost = now.first.first;
		int dir = now.first.second;
		int x = now.second.first;
		int y = now.second.second;
		if(cost >= dp[x][y][dir])continue;
		dp[x][y][dir] = cost;
		if(s[x][y]!=4){
			int nd = (dir+s[x][y])%4;
			int nx = x+dx[nd];
			int ny = y+dy[nd];
			if(1<=nx&&nx<=h&&1<=ny&&ny<=w){
				q.push(mmp(mp(cost,nd),mp(nx,ny) ) );
			}
		}
		for(int i=0;i<4;i++){
			int nc = cost+c[i];
			int nd = (dir+i)%4;
			int nx = x+dx[nd];
			int ny = y+dy[nd];
			if(1<=nx&&nx<=h&&1<=ny&&ny<=w){
				q.push(mmp(mp(nc,nd),mp(nx,ny) ) );
			}
		}
	}
	for(int i=0;i<4;i++){
		res = min(res,dp[h][w][i]);
	}
	cout<<res<<endl;
	/*	for(int i=1;i<=h;i++){
			for(int j=1;j<=w;j++){
				cout<<dp[i][j]<<' ';
			}
			cout<<endl;
		}*/
	}
	return 0;
}




Measured memory_bytes: 3700
/* ITP1_10_B */
#include <stdio.h>
#include <math.h>

/* ??¢???????¨????????????¢??° */
double calc_equivalent(short e1, short e2, short angle);
/* ??¨????????????????¨????????????¢??° */
double calc_length(short e1, short e2, short angle);
/* ??????????¨????????????¢??° */
double calc_height(short e, short angle);
/* ?????°???????????§?????????????????????????????¢??° */
double convert_deg_to_rad(double deg);

int main(void)
{
	short edge1 = 0, edge2 = 0, angle = 0;
	scanf("%hd %hd %hd", &edge1, &edge2, &angle);
	
	double s = 0, l = 0, h = 0;
	
	s = calc_equivalent(edge1, edge2, angle);
	l = calc_length(edge1, edge2, angle);
	h = calc_height(edge2, angle);
	
	printf("%lf\n", s);
	printf("%lf\n", l);
	printf("%lf\n", h);
	
	return 0;
}

/* ??¢???????¨????????????¢??° */
double calc_equivalent(short e1, short e2, short angle)
{
	return e1 * e2 * sin( convert_deg_to_rad( angle ) ) / 2;
}

/* ??¨????????????????¨????????????¢??° */
double calc_length(short e1, short e2, short angle)
{
	double e3 = sqrt( pow( e1, 2 ) + pow( e2, 2 )
		- (2 * e1 * e2 * cos( convert_deg_to_rad( angle ) ) ) );
	return e1 + e2 + e3;
}

/* ??????????¨????????????¢??° */
double calc_height(short e, short angle)
{
	return e * sin(convert_deg_to_rad(angle));
}

/* ?????°???????????§?????????????????????????????¢??° */
double convert_deg_to_rad(double deg)
{
	return (deg * M_PI) / 180;
}

Measured memory_bytes: 684
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    ll n,m;
    cin>>n>>m;
    priority_queue<ll> q;
    for(ll i=0;i<n;i++){
	ll a;
	cin>>a;
	q.push(a);
    }
    for(ll i=0;i<m;i++){
	ll now = q.top();
	q.pop();
	q.push(now/2);
    }
    ll sum =0 ;
    while(!q.empty()){
	sum+=q.top();
	q.pop();
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1400
#include<iostream>
#include<algorithm>
#define MAX 100000
using namespace std;
int n, A[MAX + 1], L[MAX];
int lis() {
	L[0] = A[0];
	int length = 1;
	for (int i = 1; i < n; i++) {
		if (L[length - 1] < A[i]) {
			L[length++] = A[i];
		}
		else {
			*lower_bound(L, L + length, A[i]) = A[i];
		}
	}
	return length;
}
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> A[i];
	}
	cout << lis() << endl;
}



Measured memory_bytes: 3888
N = int(input())
A = list(map(lambda x: 2 * int(x), input().split()))

all_mount = sum(A) // 2
A_1 = all_mount
for i in range(1, N, 2):
  A_1 -= A[i]
  
mounts = [A_1]
for i in range(N-1):
  mounts.append(A[i] - mounts[i])
  
print(" ".join(map(str, mounts)))

Measured memory_bytes: 19144
import bisect

n = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

A.sort()
C.sort()

ans = 0
for b in B:
    a = bisect.bisect_right(A, b-1)
    c = len(C)-bisect.bisect_right(C, b)
    ans += a*c
print(ans)

Measured memory_bytes: 105308
s = gets.chomp("")

if (s.length)%2 == 0
  half = (s.length)/2
  front = s[0, half].reverse
  back =  s[half, s.length]
  count =0
  half.times do |i|
    if front[i] != back[i]
      count += 1
    end
  end
  puts count
else
  half = (s.length)/2
  front = s[0, half].reverse
  back =  s[half+1, s.length]
  count =0
  half.times do |i|
    if front[i] != back[i]
      count += 1
    end
  end
  puts count
end


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

int main()
{
    int a[6] = { 1, 5, 10, 50, 100, 500 }, b[6];

    int sum = 0;
    for( int i = 0; i < 6; i++ )
    {
        cin >> b[i];
        sum += a[i] * b[i];
    }

    if( sum >= 1000 )
        cout << 1 << endl;
    else
        cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vvi vector<vector<int>>
#define pii pair<int, int>
#define all(x) (x).begin(),(x).end()
#define lla(x) (x).rbegin(),(x).rend()
#define rep(i, n) for (int i = 0; i < n; i++)
#define Rep(i, n) for (int i = 1; i <= n; i++)

const int INF = 1001001001;

int n, q;

vi x[200200];

main(){
    cin >> n >> q;
    rep(i, n){
        if(i){
            int  a, b;
            cin >> a >> b;
            a--;b--;
            x[a].push_back(b);
            x[b].push_back(a);
        }
    }
    vll s(n, 0);
    rep(i,q){
        int a, b;
        cin >> a >> b;
        s[--a] += b;
    }
    queue<int> que;
    que.push(0);
    vector<bool> d(n, false);
    d[0] = true;
    while(!que.empty()){
        int t = que.front();que.pop();
        for(auto i : x[t]){
            if(!d[i]){
                d[i] = true;
                s[i] += s[t];
                que.push(i);
            }
        }
    }
    rep(i, n){
        if(i)putchar(32);
        cout << s[i];
    }
    putchar(10);
}

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

internal static class CR
{
    public static string GetText() { return Console.ReadLine(); }
    public static List<string> GetTexts() { return Console.ReadLine().Split(' ').ToList(); }
    public static long GetLong() { return long.Parse(Console.ReadLine()); }
    public static List<long> GetLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }
}

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var n = CR.GetLong();

            return n % 2 == 0 ? (n / 2) : ((int)(n / 2) + 1);
        }
    }
}


Measured memory_bytes: 13140
#define _USE_MATH_DEFINES
#include<iostream>
#include<sstream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<unordered_map>
#include<math.h>
#include<iterator>

using namespace std;

long long MOD = 1e9+7;

int main(){
  int n;
  cin >> n;
  vector<long long> a(n),b(n),c(n),d(n),e(n);
  for (auto&& it : a) {
    cin >> it;
  }
  for (auto&& it : b) {
    cin >> it;
  }
  for (int i = 0; i < n-1; i++) {
    c[i+1]=0;
    d[i]=0;
    e[i]=0;
    if(a[i+1]>a[i]){
      c[i+1]=a[i+1];
    }
  }

  c[0]=a[0];
  c[n-1]=b[n-1];
  d[n-1]=0;
  e[n-1]=0;

  for (int i = 0; i < n-1; i++) {
    if(b[i+1]<b[i]){
      if(c[i]!=b[i] && c[i]!=0){
        cout <<0<<endl;
        return 0;
      }
      c[i]=b[i];
    }
  }


  //check
  int check=c[0];
  for (int i = 0; i < n; i++) {
    if(check<c[i])check=c[i];
    if(a[i]!=check){
      cout << 0<<endl;
      return 0;
    }
  }
  check=c[n-1];
  for (int i = n-1; i >=0; i--) {
    if(check<c[i])check=c[i];
    if(b[i]!=check){
      cout << 0<<endl;
      return 0;
    }
  }

  long long ans=1;
  for (int i = 0; i < n; i++) {
    if(c[i]==0){
      ans = (ans*min(a[i],b[i]))%MOD;
    }
  }
  cout << ans<<  endl;
}



Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
#define INF __INT32_MAX__
#define LINF __LONG_LONG_MAX__

int main() {
    ll N, H;
    cin >> N >> H;
    vl A(N), B(N);
    ll amax = -1;
    rep(i, N) {
        cin >> A[i] >> B[i];
        amax = max(amax, A[i]);
    }

    priority_queue<ll> pq;
    rep(i, N) {
        if (B[i] > amax) {
            pq.push(B[i]);
        }
    }

    ll cnt = 0;
    while (!pq.empty()) {
        if (H <= 0) break;
        ll b = pq.top(); pq.pop();
        H -= b;
        cnt++;
    }

    if (H > 0) {
        cnt += H / amax;
        if (H % amax != 0) cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 5824
A = [[0,0]]
N = int(input())
for _ in range(N):
    t,x,y = map(int,input().split())
    A.append([t,x+y])
for i in range(1,N+1):
    
    if A[i][0]-A[i-1][0] >= abs(A[i][1]-A[i-1][1]) and (A[i][0]-A[i-1][0])%2 == (A[i][1]-A[i-1][1])%2:
        continue
    else:
        print('No')
        exit()
print('Yes')


Measured memory_bytes: 87808
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i)  cin >> a[i];
    sort(a.begin(), a.end());
    ll ans = 0;
    int foo = a[0], bar = a[0];
    int cnt = 1;
    bool flag = true;
    ll sum = 0;
    int left = 1, right = n - 2;
    while(cnt < n){
        if(n - cnt >= 2){
            if(flag){
                sum += a[right] + a[right + 1] - foo - bar;
                foo = a[right];
                bar = a[right + 1];
                right -= 2;
                flag = false;
            }
            else{
                sum += foo + bar - a[left] - a[left + 1];
                foo = a[left];
                bar = a[left + 1];
                left += 2;
                flag = true;
            }
            cnt += 2;
        }
        else{
            if(flag)    sum += max(a[right] - foo, a[right] - bar);
            else    sum += max(foo - a[left], bar - a[left]);
            ++cnt;
        }
    }
    chmax(ans, sum);
    foo = a[n - 1], bar = a[n - 1];
    left = 0, right = n - 3;
    cnt = 1;
    flag = true;
    sum = 0;
    while(cnt < n){
        if(n - cnt >= 2){
            if(flag){
                sum += foo + bar - a[left] - a[left + 1];
                foo = a[left];
                bar = a[left + 1];
                left += 2;
                flag = false;
            }
            else{
                sum += a[right] + a[right + 1] - foo - bar;
                foo = a[right];
                bar = a[right + 1];
                right -= 2;
                flag = true;
            }
            cnt += 2;
        }
        else{
            if(flag)    sum += max(foo - a[left], bar - a[left]);
            else    sum += max(a[right] - foo, a[right] - bar);
            ++cnt;
        }
    }
    chmax(ans, sum);
    cout << ans << endl;
}

Measured memory_bytes: 768
/*
THE BEST IS YET TO COME
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define r(i,s,l) for(int i=s;i<l;i++)
#define mod 1000000007
#define INT_BITS 32
#define ld long double
#define pp pair<long long,long long>
#define ss second
#define ff first
#define N 2000005
#define all(a) a.begin(),a.end()
#define pb push_back
using namespace std;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}
int main()
{
    fast();
    string s;
    cin>>s;
    int n=s.length();
    vector<ll> a(n);
    int r=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='R')
            r++;
        else
        {
            //cout<<r<<endl;
            if(r&1)
            {
            a[i]+=r/2;
            a[i-1]+=r/2+1;
            }
            else
            {
                a[i]+=r/2;
                a[i-1]+=r/2;
            }
            //cout<<a[i]<<" "<<a[i-1]<<endl;
            r=0;
        }
    }
    int l=0;
    for(int i=n-1;i>=0;i--)
    {
        if(s[i]=='L')
            l++;
        else
        {
            //cout<<r<<endl;
            if(l&1)
            {
            a[i]+=l/2;
            a[i+1]+=l/2+1;
            }
            else
            {
                a[i]+=l/2;
                a[i+1]+=l/2;
            }
            //cout<<a[i]<<" "<<a[i-1]<<endl;
            l=0;
        }
    }
    r(i,0,n)
    cout<<a[i]<<" ";


    return 0;

}



Measured memory_bytes: 1488
import fractions
n,num=map(int,input().split())
num_set=set(map(lambda x:int(x),input().split()))
two_times_set=set()

for i in num_set:
    for j in range(1,30):
        i//=2
        if i%2!=0:
            two_times_set.add(j)
            break

    if len(two_times_set)!=1:
        print(0)
        break
else:
    num_list=list(num_set)
    lcm=num_list[0]
    for i in range(1,len(num_list)):
        lcm = lcm * num_list[i] // fractions.gcd(lcm, num_list[i])    
    #print((num-lcm//2)//(lcm)+1)

    lcm//=2
    print(int(((num/lcm)+1)/2))



Measured memory_bytes: 13288
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template <size_t I, class H, class... T> struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template <class H, class... T> struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template <class... T> istream& operator>>(istream&i,tuple<T...>& t) { t = TupleReaderWriter<sizeof...(T), T...>::r(i); return i; }
template <class... T> ostream& operator<<(ostream& o, tuple<T...>& t) { string delim = " "; TupleReaderWriter<sizeof...(T) - 1, T...>::w(o, t, delim); return o; }
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using vector2d = vector<vector<T>>;
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    int N, M, S;
    cin >> N;
    vector<int> T(N);
    for(auto &x : T) cin >> x;
    S = accumulate(WHOLE(T), 0);
    cin >> M;
    for(int i = 0; i < M; i++) {
        int P, X;
        cin >> P >> X;
        cout << S - T[--P] + X << endl;
    }
    return 0;
}

Measured memory_bytes: 256