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

int main() {
    int n;
    cin >> n;
    vector<vector<vvl>> dp(n + 1, vector<vvl>(4, vvl(4, vl(4, 0))));
    for (int i = 0; i < 4; ++i) {
        for (int j = 0; j < 4; ++j) {
            for (int k = 0; k < 4; ++k) {
                if ((i == 0 && j == 1 && k == 2) || (i == 1 && j == 0 && k == 2) || (i == 0 && j == 2 && k == 1))
                    continue;
                dp[3][i][j][k] = 1;
            }
        }
    }
    // 0a 1c 2g 3t
    for (int i = 4; i <= n; ++i) {
        for (int j = 0; j < 4; ++j) {
            for (int k = 0; k < 4; ++k) {
                for (int l = 0; l < 4; ++l) {
                    for (int m = 0; m < 4; ++m) {
                        if (k == 0 && l == 1 && m == 2)
                            continue;
                        if (j == 0 && k == 1 && m == 2)
                            continue;
                        if (k == 1 && l == 0 && m == 2)
                            continue;
                        if (k == 0 && l == 2 && m == 1)
                            continue;
                        if (j == 0 && l == 1 && m == 2)
                            continue;
                        dp[i][k][l][m] = (dp[i][k][l][m] + dp[i - 1][j][k][l]) % MOD;
                    }
                }
            }
        }
    }
    ll ret = 0;
    for (int j = 0; j < 4; ++j) {
        for (int k = 0; k < 4; ++k) {
            for (int l = 0; l < 4; ++l) {
                ret = (ret + dp[n][j][k][l]) % MOD;
            }
        }
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<queue>
#include<vector>
using namespace std;
#define ll long long 
#define il inline
ll read(){
    ll x=0,f=1; char ch=getchar();
    while (ch<'0'||ch>'9') ch=getchar();
    while (ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+ch-'0'; ch=getchar();
    }
    return x*f;
}
ll a; ll b,c; ll bb;
int main(){
    a=read(); b=read(); c=read();
    bb=b*100+c;
    cout<<(a*bb)/100;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    if((s[0]=='R')&&(s[1]=='R')&&(s[2]=='R'))
        cout<<3;
    else if(((s[0]=='R')&&(s[1]=='R'))||((s[1]=='R')&&(s[2]=='R')))
        cout<<2;
    else if (((s[0]=='R'))||((s[1]=='R'))||((s[2]=='R')))
        cout<<1;
    else
        cout<<0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os, const map<T,U>& mp){ os << "{"; for(auto& p : mp){ os << p << ","; } os << "}"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int,int>;
using vi = std::vector<int>;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

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

    double x = 0;
    rep(i,n){
        double t = 1;
        rep(j,n) if(i!=j){
            t *= a[j];
        }
        x += t;
    }

    double y = 1;
    rep(i,n) y*=a[i];

    double ans = y / x;
    cout << Double(ans) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,a,t;
  a=0;
  cin>>n;
  t=n;
  for (int i=0;i<9;i++){
    a+=n%10;
      n/=10;
  }
  if(t%a==0)
    cout<<"Yes"<<endl;
  else
    cout <<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
 
	public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	         String S = sc.next();
      if(S.equals("Sunny")){
        System.out.println("Cloudy");
      }else if(S.equals("Cloudy")){
        System.out.println("Rainy");
      }else if(S.equals("Rainy")){
        System.out.println("Sunny");
      }
    }
}



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

int64_t dp[111][2][4];
int main()
{
    string N;
    int K, M;
    cin >> N;
    cin >> K;
    M = N.size();
    //   cout << N << " " << K << endl;

    dp[0][0][0] = 1;
    int r, c, i, j, k, l;
    for (i = 0; i < M; i++)
    {
        for (j = 0; j < 2; j++)
        {
            //j=0すなわちN未満であることが確定：0-9の値をとれる
            //j=1すなわちN未満であることが未確定：i桁目と同じ値
            r = j ? 9 : N[i] - '0';
            for (k = 0; k <= K; k++)
            {
                for (l = 0; l <= r; l++)
                {
                    c = k + !!l; //l=0で0,l!=0で1をkに足す
                    if (c <= K)
                        dp[i + 1][j || l < r][c] += dp[i][j][k];
                }
            }
        }
    }
    cout << dp[M][0][K] + dp[M][1][K] << endl;
}

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

int main() {
	
	int h, w;
	cin >> h >> w;
	vector<string> s(h+1);
	rep(i, h){
		cin >> s[i];
		s[i] += '#';
	}
	rep(i, w) s[h][i] += '#';
	
	vector<vector<int>> cnt(h, vector<int>(w));
	
	rep(i, h){
		int l = 0;
		rep(j, w+1){
			if(s[i][j] == '#'){
				for(int k=j-l; k<j; k++){
					cnt[i][k] += l;
				}
				l = 0;
			}else{
				l++;
			}
		}
	}
	rep(j, w){
		int l = 0;
		rep(i, h+1){
			if(s[i][j] == '#'){
				for(int k=i-l; k<i; k++){
					cnt[k][j] += l;
				}
				l = 0;
			}else{
				l++;
			}
		}
	}
	int max = 0;
	rep(i, h){
		rep(j, w){
			int range = cnt[i][j] - 1;
			if(max < range) max = range;
		}
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 20096
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op


# globals
inf = float('inf')
input = stdin.readline


def main():
    s = get_str()
    if len(s) == 2:
        print(1, 1)
        return
    rs = [0] * len(s)
    ls = [0] * len(s)
    r = 0
    for i, c in enumerate(s):
        if c == 'R':
            r += 1
        else:
            rs[i] = r
            r = 0
    l = 0
    for i, c in reversed(list(enumerate(s))):
        if c == 'L':
            l += 1
        else:
            ls[i] = l
            l = 0
    ans = []
    for i in range(len(s)):
        n = 0
        if s[i] == 'L':
            n += ls[i-1] // 2 + ls[i-1] % 2
            n += rs[i] // 2
        else:
            n += ls[i] // 2
            n += rs[i+1] // 2 + rs[i+1] % 2
        ans.append(n)
    print(' '.join(map(str,ans)))
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def gets(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    setrecursionlimit(4100000)
    main()


Measured memory_bytes: 90100
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, Q;
  string S;
  cin >> N >> Q >> S;
  
  vector<int> a(N);
  for (int i = 1; i < N; i++) {
    int cnt = 0;
    if (S.at(i -1) == 'A' && S.at(i) == 'C') {
      cnt++;
    }
    a.at(i) = a.at(i-1) + cnt;
  }
  
  for (int i = 0; i < Q; i++) {
    int l, r;
    cin >> l >> r;
    cout << a.at(r-1) - a.at(l-1) << endl;
  }
}


Measured memory_bytes: 1408
n = int(input())
a = [ [] for _ in range(11) ]
a[0].append("a")

alp = "abcdefghijklmn"
for i in range(1, 10):
    for aa in a[i-1]:
        for c in alp[:i+1]:
            max_e = max( [ord(x) for x in aa] )
            if max_e+1 < ord(c): break
            a[i].append(aa+c)

for ans in a[n-1]:
    print(ans)


Measured memory_bytes: 14532
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int n,a[105],num,cnt,ans,b[105];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++)
	  scanf("%d",&a[i]);
	cnt=1;
	for (int i=2;i<=n+1;i++)
	{
		num++;
		if (a[i]!=a[i-1])
		{
			cnt++;
			b[cnt]=num;
			num=0;
		}
	}
	for (int i=1;i<=cnt;i++)
	{
		if (b[i]%2==0) ans=ans+b[i]/2;
		if (b[i]%2==1) ans=ans+b[i]/2;
	}
	printf("%d",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
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; }

int n;
vector<long long> A(200200, 0);
vector<long long> sum(200200, 0);

int main() {
    cin >> n;
    for(int i = 0; i < n; ++i) cin >> A.at(i);

    sum.at(0) = A.at(0);
    for(int i = 1; i < n; ++i) {
        sum.at(i) += sum.at(i-1) + A.at(i);
    }

    long long cnt = 0;
    map<long long, long long> mp;
    for(int i = 0; i < n; ++i) {
        if(sum.at(i) == 0) cnt++;
        mp[sum.at(i)]++;
    }

    for(auto x : mp) {
        long long mcnt = x.second;
        cnt += (mcnt*(mcnt-1)) / 2;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 15872
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

const ll MOD=1e9+7;
ll powm(ll x,ll k){
    ll res=1;
    while(k){
        if(k&1) res=res*x%MOD;
        k>>=1;
        x=x*x%MOD;
    }
    return res;
}
ll modInv(ll x){
    return powm(x,MOD-2);
}
int main(){
    int n;
    cin>>n;
    vector<ll> x(n);
    for(int i=0;i<n;i++) cin>>x[i];
    vector<ll> fact(n,1);
    for(int i=0;i+1<n;i++) fact[i+1]=fact[i]*(i+1)%MOD;
    ll A=0,B=0,C=0;
    for(int j=1;j<=n-2;j++){
        A+=fact[n-1]*x[j]%MOD*(1-modInv(j+1))%MOD;
        A%=MOD;
        A=(A%MOD+MOD)%MOD;
    }

    for(int i=0;i<=n-3;i++){
        B+=fact[n-1]*x[i]%MOD*(1-modInv(n-i-1))%MOD;
        B%=MOD;
    }

    for(int i=0;i<=n-2;i++){
        C+=fact[n-1]*modInv(n-1-i)%MOD*(x[n-1]-x[i]);
        C%=MOD;
    }

    ll res=A-B+C;
    res=(res%MOD+MOD)%MOD;

    cout<<res<<endl;

    
    return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>
int main() {
	char s[101];
	int alCnt[26] = {0};
	scanf("%s", s);
	for (int i = 0; i < strlen(s); i++) {
		alCnt[s[i] - 'a']++;
	}
	for (int i = 0; i < 26; i++) {
		if (alCnt[i] % 2 == 1) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];

	auto ans = minmax_element(A.begin(), A.end());

	cout << *ans.second - *ans.first << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define maxn 55
#define maxm 205
#define mod 1000000007
using namespace std;

int n,m,k;
int info[maxn],Prev[maxm],to[maxm],cnt_e;
void Node(int u,int v){ Prev[++cnt_e]=info[u],info[u]=cnt_e,to[cnt_e]=v; }

int dfn[maxn],low[maxn],sta[maxn],tot,fac[maxm]={1,1},inv[maxm]={1,1},invf[maxm]={1,1};
int vis[maxn],tim;
vector<vector<int> >pd;
void dfs(int u){
	dfn[u] = low[u] = ++tot;sta[++sta[0]] = u;
	for(int i=info[u],v;i;i=Prev[i]) if(!dfn[v=to[i]]){
		dfs(v);
		if(low[v] >= dfn[u]){
			vector<int>p;p.push_back(u);
			for(int t = -1;t!=v;)
				p.push_back(t = sta[sta[0]--]);
			pd.push_back(p);
		}
		low[u] = min(low[u] , low[v]);
	}else low[u] = min(low[u] , dfn[v]);
}

int Pow(int base,int k){
	int ret = 1;
	for(;k;k>>=1,base=1ll*base*base%mod) if(k&1) ret=1ll*ret*base%mod;
	return ret;
}

int C(int a,int b){ return 1ll * fac[a] * invf[b] % mod * invf[a-b] % mod; }

int main(){
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1,u,v;i<=m;i++) scanf("%d%d",&u,&v),Node(u,v),Node(v,u);
	for(int i=2;i<maxm;i++) 
		fac[i] = 1ll * fac[i-1] * i % mod,
		inv[i] = 1ll * (mod - mod / i) * inv[mod % i] % mod ,
		invf[i] = 1ll * invf[i-1] * inv[i] % mod;
	for(int i=1;i<=n;i++) if(!dfn[i]) dfs(i);
	int ans = 1;
	for(auto U:pd){
		++tim;
		for(int u:U) vis[u] = tim;
		int cnt = 2*U.size();
		for(int u:U) for(int i=info[u],v;i;i=Prev[i]) 
			if(vis[v=to[i]]==tim) cnt--;
		if(cnt>0) ans = 1ll * ans * k % mod;
		else if(cnt == 0){
			int sum = 0;
			for(int i=1;i<=U.size();i++)
				sum = (sum + Pow(k,__gcd((int)U.size(),i))) % mod;
			ans = 1ll * ans * sum % mod * Pow(U.size(),mod-2) % mod;
		}else ans = 1ll * ans * C(U.size()-cnt/2+k-1,k-1) % mod;
	}
	printf("%d\n",(ans+mod)%mod);
}

Measured memory_bytes: 256
get_number(Number) :-
    get_string(String),
    number_string(Number, String).

get_string(String) :-
    current_input(Input),
    read_string(Input, ' \n', '', _, String).

/* memo
    code(int)
    string_code(1, S, C), (C: code)
    char_code(X, Y) (X: char, Y: code)
*/

f("SUN", 7).
f("MON", 6).
f("TUE", 5).
f("WED", 4).
f("THU", 3).
f("FRI", 2).
f("SAT", 1).

main:-
    get_string(S),
    f(S, X),
    writeln(X).


Measured memory_bytes: 8032
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A[][] = new int[2][N];
    
    for(int i=0; i<2; i++){
      for(int j=0; j<N; j++){
        A[i][j] = sc.nextInt();
      }
    }
    
    int max = 0;
    
    for(int i=0; i<N; i++){
      int temp = 0;
      for(int j=0; j<=i; j++){
        temp += A[0][j];
      }
      for(int j=i; j<N; j++){
        temp += A[1][j];
      }
      if(temp > max){
        max = temp;
      }
    }
    System.out.println(max);
  }
}

Measured memory_bytes: 36060
#include<iostream>

int main(){
    int A, B, K;
    std::cin >> A >> B >> K;

    int minVal = std::min(A, B);
    int cnt = 0;
    for(int val = minVal; val > 0; val--){
        if(A % val == 0 && B % val == 0) cnt++;
        if(cnt == K){
            std::cout << val << std::endl;
            return 0;
        }
    }
    return 0;
}

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

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

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


int main(){
	
	int X, N, Y;
	vector<int> p;
	vector<int> ref;
	
	cin >> X >> N;
	
	if( N == 0 ){
		Y = X;
	}
	else{
		p.resize(N);
		
		for(int i = 0;i < N;i++){
			cin >> p[i];
		}
		
		sort(p.begin(),p.end());
		
		if( X < p[0] ){
			Y = X;
		}
		else if( X > p[N - 1] ){
			Y = X;
		}
		else{
			ref.resize(100);
			for(int i = 0;i < N;i++){
				ref[ p[i] - 1 ] = 1;
			}
			
			if( ref[ X - 1 ] == 0 ){
				Y = X;
			}
			else{		
				for(int i = 1;i < 100;i++){
					if( ref[ X - 1 - i ] == 0 ){
						Y = X - i;
						break;
					}
					else if( ref[ X - 1 + i ] == 0 ){
						Y = X + i;
						break;
					}
				}
			}
			
		}
	}
	cout << Y;

	return 0;
	
}

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

const double PI = acos(-1.0);
const int N = 100001;
const int MOD = 1e9 + 7;
typedef long long ll;

int a[N];

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

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

  for(int i = 1; i <= n; i++)
    {
      	cin>>x;

    	ll mn = min(x, a[i - 1]);
    	x -= mn;
    	ans += mn;
    	a[i - 1] -= mn;

    	mn = min(x, a[i]);
    	x -= mn;
    	ans += mn;
    	a[i] -= mn;
    }
    cout<<ans;


}





Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

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

	int n; cin >> n;
	vector<int64_t> ts(n);
	for (auto& t : ts) {
		cin >> t;
	}

	int64_t sum = 0;
	FOR_LT(i, 0, n - 1) {
		FOR_LT(j, i + 1, n) {
			sum += ts[i] * ts[j];
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
//perreo a poca luz

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <assert.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

void fastIO() {
    std::ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
}

#define EPS (1e-12)
#define FOR(i,f,t) for(int i=f; i<(int)t; i++)
#define FORR(i,f,t) for(int i=f; i>(int)t; i--)
#define FORE(i,c) for(auto i = (c).begin(); i != (c).end(); i++)
#define pb push_back
#define all(obj) obj.begin(), obj.end()
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)

#define fst first
#define snd second

template<typename T, typename U> inline void mnze(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void mxze(T &x, U y) { if(x < y) x = y; }

void _scan( int &x ) { scanf("%d",&x); }
void _scan( long long &x ) { scanf("%lld",&x); }
void _scan( double &x ) { scanf("%lf",&x); }
void _scan( long double &x ) { scanf("%Lf",&x); }
void _scan( char &x ) { scanf(" %c",&x); }
void _scan( char *x ) { scanf("%s",x); }
void scan() {}
template<typename T, typename... U>
void scan( T& head, U&... tail ) { _scan(head); scan(tail...);}

template<typename T> void _dbg(const char* sdbg, T h) { cerr<<sdbg<<"="<<h<<"\n"; }
template<typename T, typename... U> void _dbg(const char* sdbg, T h, U... t) {
    while(*sdbg != ',')cerr<<*sdbg++; cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr <<#x <<" = "; FORE(_i, (x)) cerr <<*_i <<", "; cerr <<"\n"; }}
#define debuga(x, sz) {{cerr <<#x <<" = "; FOR(_i, 0, sz) cerr << x[_i] <<", "; cerr <<"\n"; }}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debuga(x, sz)
#define cerr if(0)cout
#endif

///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////



int main(){
    int n, t = 0;
    scan(n);
    while(n--){
        int ti, xi, yi;
        scan(ti, xi, yi);
        int sum = xi + yi;
        if (ti % 2 == 0){
            if (sum % 2 == 0 && sum  <= ti)
                continue;
            else{
                printf("No\n");
                return 0;
            }
        }else{
            if (sum % 2 != 0 && sum <= ti)
                continue;
            else{
                printf("No\n");
                return 0;
            }
        }
    }
    printf("Yes\n");
    return 0;
}

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


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

   long long a;
   int cnt1=0;
   for (int i = 0; i < n; ++i){
      cin>>a;
      if(a%2==1)
         cnt1++;
   }

   
   if(cnt1==0)
      cout<<"second"<<endl;
   else
      cout<<"first"<<endl;

}


Measured memory_bytes: 256
program answer
  implicit none
  character(len=10) :: a, b, c
  character(len=26) :: s
  character(len=26) :: t
  integer(8) :: i

  read(*,*) a, b, c

  t="abcdefghijklmnopqrstuvwxyz"

  s="ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  
  do i = 1, 26
     if(a(1:1)==t(i:i)) then
        a(1:1)=s(i:i)
     end if

     if(b(1:1)==t(i:i)) then
        b(1:1)=s(i:i)
     end if

     if(c(1:1)==t(i:i)) then
        c(1:1)=s(i:i)
     end if
  end do
  
  write(*,*)  a(1:1), b(1:1), c(1:1)
  stop
  end program answer

Measured memory_bytes: 2832
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define res(i,n) for(int i=n;;i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define REV(i,n) for(int i=n-1;i>0;i--)
#define req(i,n,m) for(int i=n;i<m;i++)
#define REQ(i,n,m,l) for(int i=n;i<m;i+=l) 
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
int mod = 998244353;
long double PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998626034825342117;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
signed gcd(long long x, long long y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
signed lcm(long long x, long long y) {
    return x / gcd(x, y) * y;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
int main() {
    int N, K; cin >> N >> K;
    vector<int>A(N);
    vector<int>count(200001);
    rep(i, N) {
        cin >> A[i];
        count[A[i]]++;
    }
    sort(count.begin(), count.end());
    reverse(count.begin(), count.end());
    long long ans = 0;
    rep(i, 200001) {
        if (i < K)continue;
        ans += count[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4860
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readvec(vector<T> &a);
void readindex(vector<int> &a);

class BIT
{
public:
    vector<int> bit;
    int M;

    BIT(int M):
        bit(vector<int>(M+1, 0)), M(M) {}

    int sum(int i) {
        if (!i) return 0;
        return bit[i] + sum(i-(i&-i));
    }

    void add(int i, int x) {
        if (i > M) return;
        bit[i] += x;
        add(i+(i&-i), x);
    }
};

signed main(){

    int N, M; cin >> N >> M;
    vec l(N), r(N);
    REP(i, N) cin >> l[i] >> r[i];

    vector<Pii> p(N);
    REP(i, N) p[i] = Pii(r[i] - l[i] + 1, i);
    SORT(p);

    int d0 = 1;
    vec ans(M + 1);
    BIT bit(M + 1), bit2(M + 1);
    REP(i, N){
        int D = p[i].first;
        int n = p[i].second;

        bit.add(1, 1);
        bit.add(D + 1, -1);

        FOR(d, d0 + 1, D + 1){
            FOR(k, 1, M / d + 1) ans[d] += bit2.sum(d * k);
        }
        d0 = D;
        bit2.add(l[n], 1);
        bit2.add(r[n] + 1, -1);
    }
    FOR(d, d0 + 1, M + 1){
        FOR(k, 1, M / d + 1) ans[d] += bit2.sum(d * k);
    }

    FOR(d, 1, M + 1) ans[d] += bit.sum(d);
    FOR(d, 1, M + 1) cout << ans[d] << endl;
    
    return 0;
}


template<typename T>
void readvec(vector<T> &a){
    REP(i, a.size()){
        cin >> a[i];
    }
}
void readindex(vector<int> &a){
    REP(i, a.size()){
        cin >> a[i];
        a[i]--;
    }
}

Measured memory_bytes: 12672
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Joy
 */

#include <bits/stdc++.h>

#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF ll(1e9)
#define INFL ll(1e18)
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int ctoi(char c) {return c - '0';}

class CTaxIncrease {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int A, B;
	    in >> A >> B;
	    int ans = -1;
        for (int i = 1; i <= 1250; ++i) {
            if (i * 8 / 100 == A && i / 10 == B) {
                ans = i;
                break;
            }
        }
        out << ans << '\n';
	}
};


int main() {
	CTaxIncrease solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
n = int(input())
p = list(map(float,input().split()))

#dp[n][n]=0

dp = [[0 for i in range(n+1)] for j in range(n+1)]

dp[0][0] = 1.0

for i in range(1,n+1):
  for j in range(0,n+1):
    if j==0:
      dp[i][j] = (1.0 - p[i-1]) * dp[i-1][j]
    else:
      dp[i][j] = p[i-1] * dp[i-1][j-1] + (1.0 - p[i-1]) * dp[i-1][j]

res = 0.0
for i in range(n//2 + 1 , n+1):
  res += dp[n][i]

print(res)
      
      
      
      
      

Measured memory_bytes: 259848
/*
    In the name of Allah

    MohammadErfan Gooneh

*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

#define endl                        '\n'
#define all(a, n)                   for (int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define IOS                         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
int main() {
    IOS ;
    int a , b ;
    cin >> a >> b;
    cout << (a*3 + b)/2 ;



























return 0 ;
}


Measured memory_bytes: 3604
#pragma gcc optimize("Ofast")
#include <cstdio>
#include <queue>
#include <bitset>
using namespace std;

bitset <100> maskdiv[100], invmaskdiv[100], full;
int n;
vector <int> a;
long long ans=0;
//mulai dari pos=1, bukan pos=0 because smashing first gem --> ans=0 --> already considered
//"return bruteForcePrune(something)" actually returns nothing (void)
void bruteForcePrune(long long potential, long long curr=0, bitset <100> currmask=full, int pos=1) {
	//potential is an upperbound for the answer
	if(potential<=ans){//prune
		return;
	}
	//base case
	if(pos==n){
		ans=curr;
		return;
	}
	//gem already smashed
	if(!currmask[pos]){
		return bruteForcePrune(potential, curr, currmask, pos+1);
	}
	//tidak ada gunanya smash gem yg non-negative
	if(a[pos]>=0){
		return bruteForcePrune(potential, curr+a[pos], currmask, pos+1);
	}
	//keep the bad gem
	bruteForcePrune(potential+a[pos], curr+a[pos], currmask, pos+1);
	//smash the bag gem (and some other gems after)
	//maskdiv and invmaskdiv are precomputed so no time is wasted on ~ operator
	bitset <100> toDelete=currmask&maskdiv[pos];
	for(int i = pos+1;i < n;i ++){
		if(toDelete[i]){
			//potential goes down when a positive gem is smashed
			if(a[i]>0){
				potential-=a[i];
			}
		}
	}
	return bruteForcePrune(potential, curr, currmask&invmaskdiv[pos], pos+1);
}
int main(){
	//precompute masks
	for(int i = 0;i < 100;i ++){
		for(int j = i+1;j <= 100;j += i+1){
			maskdiv[i][j-1]=true;
		}
		invmaskdiv[i]=~maskdiv[i];
	}
	//cuma kepake sekali sih ini
	full.set();
	//input
	scanf("%d", &n);
	a.resize(n);
	long long fullPotential=0;
	for(int&i:a){
		scanf("%d", &i);
	}
	//if gems numbered 51-100 are negative, they definitely won't be considered
	for(int i = n/2;i < n;i ++){
		a[i]=max(a[i], 0);
	}
	for(int i = 1;i < n;i ++){
		fullPotential+=max(a[i], 0);
	}
	bruteForcePrune(fullPotential);
	printf("%lld\n", max(ans+a[0], 0ll));
}

Measured memory_bytes: 3256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

using ll = long long;
using ld = long double;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "YES"; }
  string_type do_falsename() const { return "NO"; }
};

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
  string A, B;
  cin >> A >> B;

  bool none = true;
  for (char c: B)
    if (c == '1') none = false;
  if (none) {
    bool ok = true;
    for (char c: A)
      if (c == '1') ok = false;
    if (ok) { cout << 0 << endl; return 0; }
    cout << -1 << endl;
    return 0;
  }

  const int n = A.size();
  vector<int> left(n, n), right(n, n);
  REP(i,n) {
    for (int j = 0; j <= n; ++j) {
      if (B[(i + n - j) % n] == '1') chmin(left[i], j);
      if (B[(i + j) % n] == '1') chmin(right[i], j);
    }
  }
  // REP(i,n) cout << left[i] << " " << right[i] << endl;
  int res = 1e9;
  for (int p = -2 * n; p <= 2 * n; ++p) {
    vector<pair<int,int>> vec;
    REP(i,n) {
      const int j = ((i + p) % n + n) % n;
      if (A[i] == B[j]) continue;
      if (p < 0) {
        int l = max(0, left[i] - abs(p));
        vec.emplace_back(l, right[i]);
      }
      else {
        int r = max(0, right[i] - abs(p));
        vec.emplace_back(left[i], r);
      }
    }
    sort(ALL(vec));
    int cnt = abs(p) + vec.size();
    const int m = vec.size();
    for (int i = m - 2; i >= 0; --i) {
      chmax(vec[i].second, vec[i + 1].second);
    }
    if (vec.empty()) {
      chmin(res, cnt);
    }
    else {
      chmin(res, cnt + vec.front().second * 2);
      chmin(res, cnt + vec.back().first * 2);
    }
    REP(i,m-1) {
      chmin(res, cnt + 2 * (vec[i].first + vec[i+1].second));
    }
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
S = sorted(int(input()) for i in range(n))
sum = sum(S)
if sum % 10 != 0:
    print(sum)
    exit()
for s in S:
    if s % 10 != 0:
        sum -= s
        break
else:
    print(0)
    exit()
print(sum)

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

int main()
{
    int i;
    char s[200000]={};
    scanf("%s",&s);
    for(i=0;i<strlen(s);i++){
        if(s[i]=='?') printf("D");
        else printf("%c",s[i]);
    }    
    return 0;
}


Measured memory_bytes: 2288
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <unordered_map>
using namespace std;


int main() {
	int N,M,A,B;
	

	cin >> N >> M;
	bool* ans = new bool[N+1];
	for (int i = 1; i <= N; ++i)
		ans[i] = true;
	int* height = new int[N+1];
	for (int i = 1; i <= N; ++i)
		cin >> height[i];
	//unordered_map<int, int> m;
	for (int i = 0; i < M; ++i)
	{
		cin >> A >> B;
		if (height[A] == height[B])
		{
			ans[A] = false;
			ans[B] = false;
		}
		else if (height[A] > height[B])
		{
			ans[B] = false;
		}
		else
			ans[A] = false;
	}
	int count = 0;
	for (int i = 1; i <= N; ++i)
	{
		if (ans[i])
			++count;
	}
	cout << count << endl;
	return 0;
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
#define INF 1000000

int main()
{
  int n;cin>>n;
  int i,j;
  vector<vector<int>> g(n);
  rep(i,n)
  {
    int u,k;cin>>u>>k;
    u--;
    rep(j,k)
    {
      int vj;cin>>vj;
      vj--;
      g[u].emplace_back(vj);
    }
  }
  queue<int> q;
  queue<int> q2;
  q.push(0);
  vector<int> ans(n,INF);
  ans[0]=0;
  while(!q.empty())
  {
    while(!q.empty())
    {
      int now=q.front();
      q.pop();
      rep(i,g[now].size())
      {
        if(ans[g[now][i]]==INF)
        {
          q2.push(g[now][i]);
          ans[g[now][i]]=ans[now]+1;
        }
      }
    }
    while(!q2.empty())
    {
      q.push(q2.front());
      q2.pop();
    }
  }
  rep(i,n)
  {
    cout<<i+1<<' ';
    if(ans[i]==INF)cout<<-1<<endl;
    else cout<<ans[i]<<endl;
  }
}


Measured memory_bytes: 3152
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int sx,sy;
int gx,gy;
int main(){
	int n,m;
	while(cin>>n>>m,n+m){
		vector<int>d(n,inf);
		vector<bool>used(n);
		vvi cost(n,vi(n));
		rep(i,n)rep(j,n)cost[i][j]=inf;
		rep(i,m){
			int a,b,c;
			cin>>a>>b>>c;
			cost[a][b]=cost[b][a]=c;
		}
		d[0]=0;
		int out=0;
		while(1){
			int v=-1;
			rep(i,n)if(!used[i]&&(v==-1||d[v]>d[i]))v=i;
			if(v==-1)break;
			used[v]=true;
			out+=d[v];
			rep(i,n)d[i]=min(d[i],cost[v][i]);
		}
		cout<<out<<endl;
		//int sum=0;
		//rep(i,n)cout<<i<<" "<<d[i]<<endl;//sum+=d[i];
		//cout<<sum<<endl;
	}
}

Measured memory_bytes: 1264
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<long long> L(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &L[i]);
  }
  sort(L.begin(), L.end());
  ll ans = 0;
  for (int i = 0; i < N; ++i)
  {
    for (int j = i + 1; j < N; ++j)
    {
      int ok = j, ng = N;
      while (abs(ok - ng) > 1)
      {
        int mid = (ok + ng) / 2;
        if (L[i] + L[j] > L[mid])
          ok = mid;
        else
          ng = mid;
      }
      if (ok > j)
      {
        ans += ok - j;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,k;
    cin>>a>>b;
    k=(a+b)/2;
    if(abs(k-a)==abs(k-b))
        cout<<k<<endl;
    else
        cout<<"IMPOSSIBLE"<<endl;
    return 0;
}



Measured memory_bytes: 3620
//***Little by little one travels far***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

ll a[3*100002];
ll bits[63];

ll fun(ll b){
  ll c=0;
  while(b>0){
    bits[c++]+=b%2;
    b=b/2;
  }
}

int main()
{
  ll n,s=0,m=1e9+7;
  cin>>n;

  forn(i,n)
  cin>>a[i];

  for(ll i=1;i<n;i++){
    fun(a[i-1]);
    vector<ll> v;
    ll b=a[i];
    while(b!=0){
      v.pb(b%2);
      b=b/2;
    }
    for(ll j=0;j<63;j++){
      if(j==v.size()) v.pb(0);
      if(v[j]==0)
        s=(s+(((min(i,bits[j]))%m)*((ll)pow((ll)2,j)%m))%m)%m;
      else{
        s=(s+(((min(i,i-bits[j]))%m)*((ll)pow((ll)2,j)%m))%m)%m;
      }
      //cout<<bits[j];
    }
    //cout<<endl;
    // cout<<s<<" ";
  }
  cout<<s;
}

Measured memory_bytes: 2560
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
//const ll MOD=998244353;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  // cout << fixed << setprecision(15);

  ll N; cin>>N;
  vector<ll> A(N),cum(N+1,0); rep(i,N) cin>>A[i];
  rep(i,N) cum[i+1]=cum[i]+A[i];
  map<ll,ll> mp;
  for(auto s:cum) mp[s]++;
  ll ans=0;
  for(auto p:mp){
    ll k,v; tie(k,v)=p;
    ans+=v*(v-1)/2;
  }
  
  cout<<ans<<endl;
  
  return 0;
}

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

int main()
{
	int n,p[100];
	cin>>n;
	for(int i=0;i<n;i++) cin>>p[i];
	
	int maxv=0,sum=0;
	for(int i=0;i<n;i++){
		if(p[i]>maxv) maxv=p[i];
		sum+=p[i];
	}
	
	cout<<sum-maxv/2<<endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in);) {
      int N = sc.nextInt();
      int M = sc.nextInt();
      int C = sc.nextInt();
      sc.nextLine();

      int[] BArray = new int[M];
      int answer = 0;
      for (int i = 0; i < BArray.length; i++) {
        BArray[i] = sc.nextInt();
      }
      sc.nextLine();
      for (int i = 0; i < N; i++) {
        int result = 0;
        for (int j = 0; j < M; j++) {
          result += sc.nextInt() * BArray[j];
        }
        if (0 < (result + C)) {
          answer++;
        }
        sc.nextLine();
      }

      System.out.println(answer);
    }
  }
}

Measured memory_bytes: 23124
# DP
def main():
    N, W = map(int, input().split())

    dp = [-1] * (W + 1)
    dp[W] = 0
    for _ in range(N):
        w, v = map(int, input().split())
        for i in range(w, W + 1):
            dpi = dp[i]
            if dpi == -1:
                continue
            if dp[i - w] < dpi + v:
                dp[i - w] = dpi + v
    print(max(dp))


main()


Measured memory_bytes: 7724
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P  = pair<int, int>;
int main() {
    int w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << setprecision(15) << (double)w * h / 2.0 << " ";
    cout << (x && y && w / x / 2 * x * 2== w && h / y / 2 * y * 2 == h ? 1 : 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#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=2e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;
const ll MAXtwo = (1<<18);

vector<ii> v;
ll bit[MAXtwo];
vector<ll> idx[MAXn];
ll lowbit(ll x){return x&(-x);}
ll add(ll x,ll y){
  ll ret = (x+y)%MOD;
  return ret;
}
void ins(ll x,ll val){
  for (;x>0;x-=lowbit(x)) bit[x] = add(bit[x],val);
}
ll qr(ll x){
  ll ret = 0;
  for (;x<MAXtwo;x+=lowbit(x)) ret = add(ret,bit[x]);
  return ret;
}
int main(){
  IOS();
  ll n;
  cin >> n;
  REP1 (i,n) {
    ll x;
    cin >> x;
    idx[x].eb(i);
  }
  REP (i,MAXn) {
    REP (j,SZ(idx[i])-1) {
      if (idx[i][j+1]-idx[i][j] == 1) continue;
      v.eb(idx[i][j],idx[i][j+1]);
    }
  }

  sort(ALL(v),[&](const ii a,const ii b){
    return a.X > b.X;
  });
  assert(SZ(v) <= MAXn);
  debug(v,MAXtwo);
  ll ans = 1;
  REP (i,SZ(v)) {
    ll tmp = qr(v[i].Y)+1;
    ans = add(ans,tmp);
    ins(v[i].X,tmp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 16244
#include <iostream>

using namespace std;
typedef long long ll;
ll inf = 1000000000000000000;
int main(){
    long long x,k,d; cin >> x >> k >> d;
    if(x<0) x *= -1;
    if(k<inf/d){
        if(k*d<=x){
            cout << x - k*d << endl;
        }else{
            k -= x/d;
            x %= d;
            if(k&1){
                cout << d - x << endl;
            }else{
                cout << x << endl;
            }
        }
    }else{
        k -= x/d;
        x %= d;
        if(k&1){
            cout << d - x << endl;
        }else{
            cout << x << endl;
        }
    }
}

Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int A = scan.nextInt();
        int P = scan.nextInt();
        int answer = (A*3+P)/2;
        System.out.println(answer);
    }
}


Measured memory_bytes: 21844
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=100010,Mod=1e9+7;
int a[N];
int main(){
	int n=gi(),mn=Mod;
	for(int i=1;i<=n;i++)a[i]=gi();
	for(int i=n;i;i--){
		mn=min(mn,a[i]);
		if(a[i]-mn>1){puts("No");return 0;}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 640
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

N, M = MAP()

ab = [LIST() for _ in range(M)]
ab.sort(key = lambda x: (x[0], x[1]))

ans = 0
tmp_l = -INF
tmp_r = -INF
for l, r in ab:
    if tmp_r <= l:
        ans += 1
        tmp_r = r
        tmp_l = l
    if tmp_l < l:
        tmp_l = l
    if r < tmp_r:
        tmp_r = r

print(ans)



Measured memory_bytes: 36432