akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

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

int main() {
  int n;
  cin >> n;
  int w[n];
  rep(i,n) cin >> w[i];
  int s = 0;
  rep(i,n) s += w[i];
  int c = 0;
  int ans = 100000;
  rep(i,n-1) {
    c += w[i];
    ans = min(ans,abs(s-c-c));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3580
#include <limits>
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <unordered_map>

using namespace std;

int main()
{
    uint64_t N,M;
    cin >> N >> M;
    if(N == 1 && M == 1)
    {
        cout << '1' << '\n';
        return 0;
    }
    else if(N == 1)
    {
        cout << (M-2) << '\n';
        return 0;
    }
    else if(M == 1)
    {
        cout << (N-2) << '\n';
        return 0;
    }
    else
    {
        cout << ((N-2)*(M-2)) << '\n';
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;


int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << ((a == c) ? 0 : 1) << endl;

    return 0;
}




Measured memory_bytes: 256
using System;
class Program{
        static int[,] maze;
        static int H;
        static int W;
        static int[] wd = new int[] { -1, 0, 1 ,-1 , 1, -1 , 0 , 1};
        static int[] hd = new int[] { -1, -1, -1, 0 , 0 , 1 , 1 , 1 };

        public static void Main()
        {
                        int cnt= 0;
            do
            {
                var line = Console.ReadLine().Split(' ');
                W = int.Parse(line[0]);
                H = int.Parse(line[1]);
                maze = new int[H, W];

                if (H == 0)
                {
                    break;
                }

                for (int i = 0; i < H; i++)
                {
                    var dataline = Console.ReadLine().Split(' ');
                    for (int j = 0; j < W; j++)
                    {
                        maze[i, j] = int.Parse(dataline[j]);
                    }
                }

                for (int i = 0; i < H; i++)
                {
                    for (int j = 0; j < W; j++)
                    {
                        if (maze[i, j] == 1)
                        {
                            DFS(i, j);
                            cnt++;
                        }
                    }
                }
                Console.WriteLine(cnt);
                cnt = 0;

            } while (true);
        }
        public static bool DFS(int x,int y)
        {
            maze[x, y] = 2;
            for (int i = 0; i < 8; i++)
            {
                var nh = hd[i] + x;
                var nw = wd[i] + y;

                if (nh < 0 || nw < 0 || nh >= H || nw >= W)
                {
                    continue;
                }

                if (maze[nh, nw] == 0 || maze[nh, nw] == 2)
                {
                    continue;
                }

                if (DFS(nh, nw))
                {
                    return true;
                }
            }
            return false;
        }
}


Measured memory_bytes: 9460
from collections import deque

N, M = map(int, input().split())
G = [[] for i in range(N+M)]
check = [0 for j in range(N+M)]


def bfs(s):
    q = deque()
    check[s] = 1
    q.append(s)

    while len(q) != 0:
        u = q.popleft()
        for v in G[u]:
            if check[v] == 0:
                check[v] = 1
                q.append(v)

        check[u] = 2


def main():
    for i in range(N):
        kl = list(map(int, input().split()))
        for j in range(kl[0]):
            G[i].append(N+kl[j+1]-1)
            G[N+kl[j+1]-1].append(i)

    bfs(0)

    for i in range(N):
        if check[i] == 0:
            print("NO")
            break
    else:
        print("YES")


if __name__ == '__main__':
    main()


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

#define ll long long
#define Fi first
#define Se second
#define Pb push_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvp vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;

#define all(v) v.begin(),v.end()
#define output_s(a) printf("%s\n",(a).c_str())

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m) for(int i=(int)(n);i>=(int)(m);i++)
#define RepA(x) for(auto &item:(x))

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

template<typename TypeInt> //最大公約数
TypeInt GCD(TypeInt a,TypeInt b){
    if(a%b==0) return b;
    else return GCD(b,a%b);
}
template<typename TypeInt> //最小公倍数
TypeInt LCM(TypeInt a,TypeInt b){
    return a*b/GCD(a,b);
}

//library----------------------------------------------


signed main(){
    CIN(N,Y);
    bool ok = false;
    int a=-1,b=-1,c=-1;
    RepS(x,0,N){
        for(int y=0;x+y<=N;y++){
            int z=N-x-y;
            if(x*10000+y*5000+z*1000==Y){
                ok=true;
                a=x,b=y,c=z;
                break;
            }    
        }
        if(ok) break;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}

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

using namespace std;

const long long MAX = 10000000000006;

int main()
{
    int n;

    cin >> n;

    vector <long long> a(n + 9, 0);
    vector < vector <long long> > dp(1005, vector <long long> (1005, MAX));
    vector <long long> s(n + 9, 0);

    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        s[i] = s[i - 1] + a[i];
        dp[i][i] = 0;
    }

    //infoarena parantezare optima a matricii

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n - i; j++)
    {
        for (int k = j; k < j + i; k++)
        {
            dp[j][i + j] = min(dp[j][i + j], dp[j][k] + dp[k + 1][i + j] + s[i + j] - s[j - 1]);
        }
    }

    cout << dp[1][n];


    return 0;
}


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


/*
*/

int main() {
  ll N,K;
  cin >> N >> K;
  vector<ll> h(N);
  rep(i,N){
    cin >> h[i];
  }
  vector<ll> dp(110000,INF);
  dp[0] = 0;
  for(int i = 0;i<N;i++){
    for(int j = 1;j<=K;j++){
      dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j] - h[i]));
    }
  }
  cout << dp[N-1] << endl;
}

Measured memory_bytes: 1920
main:: IO ()
main = do
    _ <- getLine
    as <- (map read . words) <$> getLine
    print $ solve as

-- |
--
-- >>> solve [1 .. 6]
-- 1
--
-- >>> solve [10, -10]
-- 20
solve :: [Int] -> Int
solve as = minimum $ map (\x -> abs $ x - (s-x)) $ scanl1 (+) (init as)
  where s = sum as


Measured memory_bytes: 59772
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
#define No cout<<"No"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    int n;
    cin>>n;
    string s=to_string(n);
    int x=0;
    rep(i,s.size()){
        x+=(s[i]-'0');
    }
    if(n%x==0){Yes;}
    else{No;}
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
struct edge{int from,to,cost;};
signed main(){
  int a;
  cin>>a;
  vector<int> b(a+1);
  b[0]=0;
  int c=0;
  rep(i,a)
    cin>>b[i+1];
  rep(i,a){
    if(b[i]<b[i+1])
      c+=b[i+1]-b[i];
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    
    # 要素xが属するグループの根を返す
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        
        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x):
        return -self.parents[self.find(x)]
        
    def same(self, x, y):
        return self.find(x) == self.find(y)
    
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())
    
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def solve(N: int, M: int, A: "List[int]", B: "List[int]"):
    answer = [(N*(N-1))//2]
    uf = UnionFind(N)

    for i in range(M-1,0,-1):
        if uf.same(A[i]-1,B[i]-1):
            answer.append(answer[-1])
            continue
        else:
            answer.append(answer[-1]-uf.size(A[i]-1)*uf.size(B[i]-1))
            uf.union(A[i]-1,B[i]-1)

    for aa in answer[::-1]:
        print(aa)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
    solve(N, M, A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 19032
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int a[25],b[25], c[25];
int main()
{
    int n;
    cin>>n;
    for(int i=1; i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1; i<=n;i++)
    {
        cin>>b[i];
    }
    for(int i=1; i<=n-1;i++)
    {
        cin>>c[i];
    }
    long long c1=0;
    for(int i=1; i<=n;i++)
    {
        c1= c1+b[a[i]];
    }
    for(int i=2; i<=n; i++)
    {
        if(a[i]-a[i-1]==1)
        {
            c1= c1+c[a[i-1]];
        }
    }
    cout<<c1<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
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;
}
const int INF=1e18;
const int MOD=1e9+7;

int powMOD(int n,int r){
    if(r==0)return 1;
    if(r%2==0)return powMOD(n,r/2)*powMOD(n,r/2)%MOD;
    if(r%2==1)return powMOD(n,r-1)*n%MOD;
}

int modFAC(int x){
    if(x==1) return 1;
    return x*modFAC(x-1)%MOD;
}

int COM(int n,int r){
    int ret=1;
    REP(i,r){
        ret *= (n-i);
        ret %=MOD;
    }
    return ret*powMOD(modFAC(r),1e9+5)%MOD;
}

signed main(){
    int n;cin>>n;
    int ans=0;
    REP(i,n){
        int a;cin>>a;
        while(a%2==0){
            ans++;
            a/=2;
        }
    }
    cout<<ans<<endl;
}

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

int main() {
  string s;
  int a = 0;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) == '1'){
      a++;
    }
  }
  cout << a << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        boolean ok = true;
        for (int i = 0; i < n; i++) {
            int a = sc.nextInt();
            if (a % 2 == 0 && (a % 3 != 0 && a % 5 != 0)) {
                ok = false;
            }
        }

        System.out.println(ok ? "APPROVED" : "DENIED");
    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define modulo 998244353
#define endl '\n'
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
using namespace std;
vector <int> adj[100001];
ll vis[100001];
ll fxp(ll a, ll b)
{
    if(b == 0)return 1;
	if(b%2 == 0){
		ll c = fxp(a,b/2);
		return (c*c)%1000000007;
	}
	return (a*fxp(a,b-1))%1000000007;
}
int lcm(int c,int d)
{
    int a=c;
    int b=d;
    int ans;
    if(a>=b)
    {
        while(b!=0)
        { 
            int x=b;
            b=a%b;
            a=x;
        }
        ans = ( c*d)/a;
    }
    else
    {
        while(a!=0)
        {
            int x=a;
            a=b%a;
            b=x;
        }
        ans = ( c*d)/b;  
    }
    return ans;
}
int root_find()
{
    ll x;
    for(int i=1;i<100001;i++)
    {
        if(adj[i].size()==1)
        {
            x = i;
            break;
        }
    }
    return x;
}
void dfs(int s,int y)
{
    for(int i=0;i<adj[s].size();i++)
    {
        if(adj[s][i]==y)
        continue;
        dfs(adj[s][i],s);
    }
}
void bfs(int s)
{
    queue <ll> q;
    q.push(s);
    vis[s]=1;
    while(!q.empty())
    {
        ll u = q.front();
        q.pop();
        for(int i=0;i<adj[u].size();i++)
        {
            if(vis[adj[u][i]]==0)
            {
            vis[adj[u][i]]=1;
            q.push(adj[u][i]);
            }
        }

    }
}
bool isPrime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}
ll smallestDivisor(ll n) 
{ 
    // if divisible by 2 
    if (n % 2 == 0) 
        return n/2; 
  
    // iterate from 3 to sqrt(n) 
    for (int i = 3; i * i <= n; i += 2) { 
        if (n % i == 0) 
            return n/i; 
    } 
  
    return n; 
}  
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin>>s;
    ll ans=0;
    for(int i=0;i<s.length();i++ )
    {
        ans = ans+s[i] -48;
    }
    //cout<<ans<<endl;
    if(ans%9==0)
    cout<<"Yes"<<endl;
    else
    {
        cout<<"No"<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 6116
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
typedef long long ll;
ll inf=1e14;
int main(){
	ll n,m,a,b,p,q;
	cin>>n>>m>>a>>b>>p>>q;
	if(a>b) swap(a,b),swap(p,q);
	ll ans=m;
	if(b==1){
		ll k=p+q;
		ll d=min(n,m/k);
		ans=m-k*d;
		if(d!=n) ans=min(ans,(d+1)*k-m);
	}else if(a==1){
		ll bq[45]={},sum[46]={};
		bq[0]=q;
		sum[1]=q;
		ll id=0;
		for(;id<n-1;id++){
			if(bq[id]>inf/b) break;
			bq[id+1]=bq[id]*b;
			sum[id+2]=sum[id+1]+bq[id+1];
		}
/*		show(id);
		rep(i,id+1){
			show(bq[i]);
			show(sum[i]);
		}*/
		//can use 0~id
		ll id_c=id;
		for(ll k=1;k<=min(n,id_c+1);k++){
			if(bq[k-1]==0) break;
//			show(k);
			ll left=m-p*k;
			ll now=0;
			id=id_c;
			int use=0;
			for(;id>=0;id--){
				if(now+bq[id]>left){
					if(k-use-1>=0&&k-use-1<=id) ans=min(ans,now+bq[id]+sum[k-use-1]-left);
				}else{
					now+=bq[id];
					use++;
					if(use==k){
						ans=min(ans,left-now);
						break;
					}
				}
			}
		}
	}else{
		ll id=0;
		ll l=p,r=q;
		ll num[45]={};
		for(;id<n;id++){
			num[id]=l+r;
			if(l>inf/a) break;
			if(r>inf/b) break;
			l*=a;
			r*=b;
		}
		if(id==n) id--;
		//can use 0~id
//		show(id);
//		rep(i,id+1){
//			show(num[i]);
//		}
		ll now=0;
		for(;id>=0;id--){
			if(now+num[id]>m){
				ans=min(ans,now+num[id]-m);
			}else{
				ans=min(ans,m-(now+num[id]));
				now+=num[id];
			}
		}
	}
	cout<<ans<<endl;
}

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

using namespace std;

#define int long long

const int N = (1ll << 18) + 1;
int n, a[N];
pair <int, int> f[N];

void Max(int i, int val) {
  if(f[i].second < val) {
    f[i].second = val;
  }
  if(f[i].first < f[i].second) swap(f[i].first, f[i].second);
}

main() {
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cin >> n;
  for(int i = 0; i < (1ll << n); ++i) cin >> a[i];
  for(int i = 0; i < (1ll << n); ++i) {
    Max(i, a[i]);
  }
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < (1ll << n); ++j) {
      if((j >> i & 1)) {
        Max(j, f[j ^ (1ll << i)].first);
        Max(j, f[j ^ (1ll << i)].second);
      }
    }
  }
  int ans = 0;
  for(int i = 1; i < (1ll << n); ++i) {
    ans = max(ans, f[i].first + f[i].second);
    cout << ans << '\n';
  }
}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
 }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  string s;
  cin>>n>>s;
  vvll dp(n+10,vll(n+10));
  for(int i=n-1;i>=0;i--){
    for(int j=n-1;j>=0;j--){
      if(s[i]!=s[j]) dp[i][j]=0;
      else dp[i][j]=dp[i+1][j+1]+1;
    }
  }
  ll ans=0;
  rep(i,n){
    rep(j,n){
      if(i>=j) continue;
      ans=max(ans,min(dp[i][j],j-i));
    }
  }
  COUT(ans);
}

Measured memory_bytes: 196608
import math
A,B = map(str,input().split())
A = int(A)
B = B.split('.')
if not len(B[1])==2:
    B[1].append('0')
B = int(''.join(B))
C = str(A*B)
C = C[:-2]
if C == '':
    C = 0
print(C)


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

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; }

const string YES = "Yes";
const string NO = "No";

int main(){
    int d, t, s;
    cin >> d >> t >> s;
    if ((d+s-1)/s <= t) cout << YES << endl;
    else cout << NO << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define nodes 400005
#define int long long int
void fast(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
main()
{
    int a,b;
    cin>>a>>b;
    if(b>=10||a>=10)cout<<"-1"<<endl;
    else cout<<(a*b)<<endl;
 
}


Measured memory_bytes: 256
// Problem : C - Skill Up
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <cstring>
#include <iostream>
#include <algorithm>
#define INF 998244353
using namespace std;
struct book
{
 int c,a[15];
}b[15];
int res[15],ans=INF;
int main()
{
 int n,m,x;
 cin>>n>>m>>x;
 for(int i=0;i<n;i++)
 {
  cin>>b[i].c;
  for(int j=1;j<=m;j++)
   cin>>b[i].a[j];
 }
 for(int p=0;p<(1<<n);p++)
 {
  int cost=0;
  memset(res,0,sizeof(res));
  for(int i=0;i<n;i++)
  {
   if(p&(1<<i))
   {
    cost+=b[i].c;
    for(int j=1;j<=m;j++)
     res[j]+=b[i].a[j];
   }
  }
  bool flag=true;
  for(int j=1;j<=m;j++)
   flag&=(res[j]>=x);
  if(flag)ans=min(ans,cost);
 }
 if(ans==INF)cout<<-1<<endl;
 else cout<<ans<<endl;
 return 0;
}

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

int main() {
  int m,n,i=1,a;
  cin>>n>>m;
  while(i<=m){
  cin>>a;
    
   n-=a; 
  i++;
  }
  
  if(n>=0)
  cout<<n<<endl;
 else cout<<-1<<endl;
 
}



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

int main(){
  int N;
  string A, B, C;
  cin >> N >> A >> B >> C;
  int ans = 0;
  for(int i = 0; i < N; ++i){
    set<char> S;
    S.insert(A[i]);
    S.insert(B[i]);
    S.insert(C[i]);
    ans += (int)S.size() - 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        x : usize,
        y : usize,
    };

    println!(
        "{}",
        if 2 * x <= y && y <= 4 * x && y % 2 == 0 {
            "Yes"
        } else {
            "No"
        }
    );
}


Measured memory_bytes: 2112
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

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 TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    int N;
    cin >> N;
    vector<pair<int,int>> p;
    map<int,int> m;
    ll ans = 0;
    for(int i = 0; i < N; i++){
        int l;
        cin >> l;
        m[l]++;
    }
    for(auto ite = m.begin(); ite != m.end(); ite++){
        p.emplace_back(*ite);
    }
    for(int i = 0; i < p.size(); i++){
        for(int j = i + 1; j < p.size(); j++){
            for(int k = j + 1; k < p.size(); k++){
                if(p[i].first < p[j].first + p[k].first && p[j].first < p[i].first + p[k].first && p[k].first < p[j].first + p[i].first)
                    ans += p[i].second * p[j].second * p[k].second;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <iomanip>
#include <stack>
#include <queue>
#include <deque>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef pair <int, int> pii;

//#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
//  order_of_key (k) : Number of items strictly smaller than k .
//  find_by_order(k) : K-th element in a set (counting from zero).
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define mkp make_pair
#define F first
#define S second
#define show(a) cerr << #a <<" -> "<< a <<"\n"
#define fo(a, b, c, d) for(int (a) = (b); (a) <= (c); (a) += (d))
#define foo(a, b, c ,d) for(int (a) = (b); (a) >= (c); (a) -= (d))
#define int ll

const int N = 2e5 + 5;
const int INF = 1e9 + 5;

int n, a, b, c, d;

bool check(int l, int r, int l2, int r2) {
	return ((l2 <= l && l <= r2) || (l2 <= r && r <= r2));
}

main () {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> a >> b >> c >> d;
	for(int i = 1; i <= n - 2; ++i) {
		if(check(a + c * i, a + i * d, b + c * (n - i - 1), b + d * (n - i - 1))) {
			cout << "YES";
			return 0;
		}
	}
	cout << "NO";
	return 0;
}
/*
	If you only do what you can do, 
	You will never be more than you are now!
*/

Measured memory_bytes: 384
L, R = map(int, input().split())
min_rad = 2019
R_max = min(L+2019, R)
for i in range(L, R_max):
    for j in range(i+1, R_max+1):
        temp = i%2019 * j%2019
        if temp < min_rad:
            min_rad = temp
print(min_rad)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);
vector<ll> divisor(ll x){
    vector<ll> div;
    for(ll i=1;i*i<=x;i++){
        if(i*i!=x && x%i==0){
            div.pb(i);
            div.pb(x/i);
        }
        else if(x%i==0) div.pb(i);
    }
    sort(all(div));
    return div;
}

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    ll N; cin>>N;
    ll ans=INF;
    vector<ll> v=divisor(N);
    rep(i,(sz(v)+1)/2){
        chmin(ans,max(digsz(v[i]),digsz(N/v[i])));
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3624
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n,m,k;
    cin >> n >> m >> k;
    vector<long long> a(n+1),b(m+1);
    for(int i = 1; i < n+1; ++i){
        int x; cin >> x;
        a[i] = x+a[i-1];
    }
    for(int i = 1; i < m+1; ++i){
        int x; cin >> x;
        b[i] = x+b[i-1];
    }
    int b_cnt = m;
    int ans = 0;
    for(int i = 0; i < n+1; ++i){
        if(k < a[i]) break;
        while(k < a[i]+b[b_cnt]) b_cnt--;
        ans = max(ans, i+b_cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6344
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>

using namespace std;
int main(void)
{
    int a,b;
    cin >> a >> b;
    if(a+b == 15){
        cout << "+";
    }else if(a*b == 15){
        cout << "*";
    }else{
        cout << "x";
    }
    return 0;
}

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

typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;

void solve() {
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	float tak = ceil(c*1.0/b);
	float aok = ceil(a*1.0/d);
	//aok++;
	if(tak <= aok) cout << "Yes\n";
	else cout << "No\n";
	
}

int32_t main() {_
	//tc(t)
		solve();
}



Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using P=pair<int,int>;
int main(){
int N;
  cin>>N;
  vector<int>people(N,0);
  for(int i=0;i<N-1;i++){
  int a;
    cin>>a;
    people.at(a-1)++;
  }
  for(int i=0;i<N;i++){
  cout<<people.at(i)<<endl;
  }
}
  

Measured memory_bytes: 4040
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 998244353LL

bool dbgflag = false;


int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  //cout << fixed << setprecision(15);
  
  ll n;
  cin >> n;
  map<ll, ll> num;
  for (int i = 0; i < n; i++) {
    ll a;
    cin >> a;
    num[a]++;
  }
  ll ans = 0;
  for (int i = 1; i <= 100000; i++) ans += num[i] * i;

  ll q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    ll b, c;
    cin >> b >> c;
    ans += (c - b) * num[b];
    num[c] += num[b];
    num[b] = 0;
    cout << ans << endl;
  }
}


Measured memory_bytes: 9892
#include <bits/stdc++.h>
#define ll long long
#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    char c;
    cin >> c;
    if (isupper(c))
        cout << "A";
    else 
        cout << "a";    
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
long long dp[2020][2020];
int main() {
	int n; cin >> n;
	int a[n]; for (int &i : a) cin >> i;
	int p[n]; iota(p, p + n, 0);
	sort(p, p + n, [&] (int x, int y) {
		return a[x] > a[y];
	});
	for (int l = 0; l < n; l++) {
		for (int r = 0; l + r < n; r++) {
			int now = l + r;
			dp[l + 1][r] = max(dp[l + 1][r], dp[l][r] + 1LL * a[p[now]] * abs(p[now] - l));
			dp[l][r + 1] = max(dp[l][r + 1], dp[l][r] + 1LL * a[p[now]] * abs(p[now] - (n - 1 - r)));
		}
	}
	long long ans = 0;
	for (int i = 0; i <= n; i++) 
		ans = max(ans, dp[i][n - i]);
	cout << ans;
}

Measured memory_bytes: 26328
# YouTube解説
MOD = 1000000007
n, k = [int(x) for x in input().split()]
d = [pow(k // i, n, MOD) for i in range(1, k + 1)]
d.insert(0, 0)

for i in range(k, 0, -1):  # 大きいほうから
    for j in range(i * 2, k + 1, i):  # iの倍数
        # d[6] = d'[6] - d[12] - d[18] ...
        d[i] -= d[j]
        d[i] %= MOD
ans = 0
for i, item in enumerate(d):
    ans += i * item
    ans %= MOD
print(ans)


Measured memory_bytes: 76444
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
int a,b;
int main() {
	//freopen("1.txt","r",stdin);
	read(a); read(b);
	printf("%d\n",max(0,a-2*b));
	return 0;
}

Measured memory_bytes: 256
l = [
 5,
 25,
 125,
 625,
 3125,
 15625,
 78125,
 390625,
 1953125,
 9765625,
 48828125,
 244140625,
 1220703125,
 6103515625,
 30517578125,
 152587890625,
 762939453125,
 3814697265625,
 19073486328125,
 95367431640625,
 476837158203125,
 2384185791015625,
 11920928955078125,
 59604644775390625,
 298023223876953125,
 1490116119384765625,
 7450580596923828125]
a = int(input())
res = 0
for i in l:
    res+= (a//i)//2
if a%2==1 or a<10:
    print(0)
else:
    print(res)
    

Measured memory_bytes: 3060
N,X=map(x->parse(Int,x),split(readline()," "))
L=map(x->parse(Int,x),split(readline()," "))

tmpD=0
flag=true
for i in 1:N
    tmpD+=L[i]
    if tmpD > X
        print(i)
    	flag=false
        break
    end
end
flag && print(N+1)

Measured memory_bytes: 110276
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define rep(i,x,y) for(long i=x;i<y;i++)
#define range(a) a.begin(),a.end()
const long mod=1e9+7;
struct solution{long x,y;};
solution bezout(long a,long b){//ax+by=1,gcd(a,b)=1
	solution sol;
	if(__gcd(a,b)!=1){//exception
		cout<<"error"<<endl;
		sol.x=0; sol.y=0; 
	}else if(a%b==1){
		sol.x=1;
		sol.y=-a/b;
	}else{
		sol=bezout(b,a%b);
		swap(sol.x,sol.y);
		sol.y=sol.y-(a/b)*sol.x;
	}return sol;
}
long inverse(long x){//x^-1
	if(__gcd(x,mod)!=1){
		return 0;
	}else{
		solution sol=bezout(x,mod);
        sol.x=sol.x%mod;
		return (sol.x+mod)%mod;
	}
}
int main(){
	long N,K;cin>>N>>K;
	long A[K],B[K];
	A[1]=1;B[1]=N-K+1;long ans;
	rep(i,1,K+1){
        ans=(A[i]*B[i])%mod;
		cout<<(ans+mod)%mod<<endl;
        if(i>N-K){
            A[i+1]=0;
            B[i+1]=0;
        }else{
		    A[i+1]=((A[i]*(K-i))%mod)*inverse(i)%mod;
		    B[i+1]=((B[i]*(N-K-i+1))%mod)*inverse(i+1)%mod;
        }
        //cout<<A[i]<<" "<<B[i]<<endl;
	}
}

Measured memory_bytes: 256
import sys
 
 
def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    s, t = list(map(str, readline().rstrip().decode('utf-8').split()))
    a, b = list(map(int, readline().split()))
    if s == str(readline().rstrip().decode('utf-8')):
        print(a - 1, b)
    else:
        print(a, b - 1)
 
 
if __name__ == '__main__':
    solve()

Measured memory_bytes: 2940
#include<stdio.h>

int main(){
  int a,b,d,r;
  double f,A;
  scanf("%d%d",&a,&b);
  d =a/b;
  r =a%b;
  A=a;
  f=A/b;
  printf("%d %d %lf",d,r,f);
  return 0;}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<ll>>;

Graph G;
ll dp[100010];
ll branch[100010];
ll N, M;

int main(int argc, char **argv)
{
	cin >> N >> M;
	G.resize(N, vector<ll>());

	for (ll i = 0; i < M; ++i)
	{
		ll a, b; cin >> a >> b; --a, --b;
		G[a].push_back(b);
		++branch[b];
	}

	queue<ll> que;
	for (ll i = 0; i < N; ++i) if (branch[i] == 0) que.push(i);

	while (!que.empty())
	{
		ll v = que.front(); que.pop();

		for (auto &nv : G[v])
		{
			branch[nv]--;
			if (branch[nv] == 0)
			{
				que.push(nv);
				dp[nv] = dp[v]+1;
			}
		}
	}

	ll res{0};
	for (ll i = 0; i < N; ++i) res = max(res, dp[i]);
	std::cout << res << std::endl;
}

Measured memory_bytes: 7296
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

int main() {
    ll n, m;
    string s;
    cin >> n >> m >> s;

    vl dp(n+1, INF);
    queue<ll> Q;

    dp[n] = 0;
    Q.push(0);
    for(ll i = n-1; i >= 0; i--) {
        while(1) {
            if(Q.size() == 0) {
                out(-1);
                re0;
            }
            if(Q.front() != INF && Q.size() <= m) {
                break;
            } 
            Q.pop();
        }
        if(s[i] == '0') {
            dp[i] = Q.front() + 1;
        } 
        Q.push(dp[i]);
    }
    
    vl ans;
    ll x = 0;
    ll rest = dp[0];
    while(x < n) {
        rest--;
        ll i = 1;
        while(dp[x+i] != rest) {
            i++;
        } 
        ans.pb(i);
        x += i;
    }

    rep(i, ans.size()) {
        cout << ans[i] << " ";
    }

    cout << endl;
    re0;
}

Measured memory_bytes: 2296
let f (str: string) =
    let mutable i = 1
    let mutable count = 0
    while i < str.Length do
        if str.[i] <> str.[i - 1]
            then count <- count + 1
        i <- i + 1
    count + 1

stdin.ReadLine() |> ignore
let input = stdin.ReadLine()
let ans = f input

printfn "%d" ans

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

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

int main() {
  char str[3];
  cin >> str;
  int count = 0;
  for (int n = 0; n < 3; n++) {
      if (str[n] == 'o') count++;
  }

  int ans = 700 + count * 100;
  cout << ans << endl;
}

Measured memory_bytes: 256
s = input()

x = 0
count0 = 0
count1 = 0

for i in s:
    if i == str(x):
        count0 += 1
    x = int(not(x))

x = 1
for i in s:
    if i == str(x):
        count1 += 1
    x = int(not(x))
#print("count0:" + str(count0))
#print("count1:" + str(count1))
print(min(count0, count1))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

struct BIT{
    vector<ll> bt;
    size_t n,m;
    explicit BIT(size_t n):n(n),m(1){
        while(m<=n) m<<=1u;
        m>>=1u;
        bt.resize(n+1);
    }
    ll sum(ll i){//sum of [1,i](1-index)
        if(!i) return 0;
        ll tmp{};
        for(size_t k=i;k;k-=k&-k) tmp+=bt[k];
        return tmp;
    }
    void ad(ll i,ll x){//add to i(1-index)
        for(size_t k=i;k<=n;k+=k&-k) bt[k]+=x;
    }
    ll lb(ll k){//if sum(i)<k and sum(i) >= k, return i
        ll x=0;
        for(size_t i=m;i>0;i>>=1u){
            if(x+i<=n&&bt[x+i]<k) {
                k-=bt[x+i];
                x+=i;
            }
        }
        return x+1;
    }
};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>> p(n);
    for(auto&lr:p) cin>>lr.first>>lr.second;
    sort(p.begin(),p.end(),[](auto x,auto y){
        return x.second-x.first<y.second-y.first;
    });
    BIT bt(m+1);
    int s{},t{n},tmp;
    Fr(d,m){
        while(s<n&&p[s].second-p[s].first+1<d){
            --t;
            bt.ad(p[s].first,1);
            bt.ad(p[s].second+1,-1);
            ++s;
        }
        tmp=0;
        for(int i=d;i<=m;i+=d) tmp+=bt.sum(i);
        cout<<t+tmp<<'\n';
    }
}

Measured memory_bytes: 4096
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] array=new int[3];
	array[0] = sc.nextInt();
	array[1] = sc.nextInt();
	array[2] = sc.nextInt();
    int max = Math.max(array[0],array[1]);
    max = Math.max(max,array[2]);
    System.out.println(array[0]+array[1]+array[2]-max);
  }
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define FORR(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)

#define DEBUG(x) cout << #x << ": " << (x) << endl
#define PRINT(x) cout << x << endl
#define all(x) x.begin(),x.end()

int main() {
    int N;
    cin >> N;
    vector<long> A(N+1),B(N);
    REP(i,N+1)cin >> A[i];
    REP(i,N) cin >> B[i];

    ll ans = 0;
    long remain = 0;
    for(int i=0;i<N;i++){
        ans += min(A[i],remain+B[i]);
        remain = min(B[i],max(0L,remain+B[i]-A[i]) ) ;
    }

    ans += min(A[N],remain);
    cout << ans << endl;

}



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

signed main(){
    int a,b;
    scanf("%d%d",&a,&b);

    for(register int i=1;i<=1250;++i){
        if(floor((double)(i*0.08))==a&&floor((double)(i*0.1))==b){
            printf("%d\n",i);
            //system("pause");
            return 0;
        }
    }

    puts("-1");
    //system("pause");
    return 0;
}

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

int main() {
  int a, b, c, d;
  int left, right;
  
  cin >> a >> b >> c >> d;
  
  left = a+b;
  right = c+d;

  if ( left > right) {
	cout << "Left" << endl;
  }
  else if (left == right){
    cout << "Balanced" << endl;
  }
  else{
    cout << "Right" << endl;
  }

}


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

using namespace std;

typedef long long LL;

#define fin "\n"


#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

template <typename T>
inline void chmin(T &l,T r){l=min(l,r);}

template <typename T>
inline void chmax(T &l,T r){l=max(l,r);}

template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
typedef vector<LL> V;

int main(){
    int N,K;
    cin>>N>>K;
    V f(N+2,0),b(N+2,0),a(N);
    cin>>a;
    REP(i,N){
        f[i+1]=max(f[i]+a[i],f[i]);
        b[N-i]=max(b[N-i+1]+a[N-i-1],b[N-i+1]);
    }
    LL res=-1e15;
    LL sum=0;
    REP(i,K)sum+=a[i];
    REP(i,N){
        if(i+K<=N){
            chmax(res,f[i]+sum+b[i+K+1]);
            chmax(res,f[i]+b[i+K+1]);
            
            sum-=a[i];
            if(i+K<N)sum+=a[i+K];
        }
    }
    cout<<res<<endl;
    

    
    return 0;
}


Measured memory_bytes: 2560
N = int(input())
def check(x):
    x = str(x)
    return x.count("3") >= 1 and x.count("5") >= 1 and x.count("7") >= 1
def dfs(x):
    if x > N or x >= 10**9:
        return 0
    ans = 0
    ans += int(check(x))

    ans += dfs(10 * x + 3)
    ans += dfs(10 * x + 5)
    ans += dfs(10 * x + 7)
    return ans
print(dfs(0))

Measured memory_bytes: 43756
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
#define rep2(i,a,n) for (int i = a; i < n; i++)
using namespace std;
int N;
// int A[220000];
vector<int> res;
int main() {
    cin >> N;
    res.resize(N,0);
    rep(i, N-1) {
        int t; cin >> t;
        res[t-1] += 1;
    }
    rep(i, N) {
        cout << res[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 4028
#include<iostream>
using namespace std;
int main(){
  int r,g,b,n,ans=0;
  cin >> r >> g >> b >> n;
  for(int i=0;i*r<=n;i++){
    for(int j=0;j*g+i*r<=n;j++){
      if((n-i*r-j*g)%b==0)ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
vector<int>vec[100010];
int a[100010];
int n;
int len;
int x,y;
int size[100010];
int siz[100010];
int xx[100010];
bool flag=1;
void output(bool b){
	if(b)cout<<"Fennec";
	else cout<<"Snuke";
	exit(0);
}
void work(){
//	cout<<"hello\n";
	int pos=len-1;
	int lps=0;
	while(pos>=0){
		siz[xx[pos]]=size[xx[pos]]-lps;
		lps=size[xx[pos]];
		pos--;
	}
	ll sum1=siz[1],sum2=siz[n];
	if(len==2){
		output(sum1>sum2);
	}
	int pos1=0,pos2=len-1;
	int cnt=0;
	while(pos1+1<pos2){
//		cout<<sum1<<' '<<sum2<<' '<<cnt<<'\n';
		cnt++;
		if(cnt&1){
			pos1++;
			sum1+=siz[xx[pos1]];
		}
		else {
			pos2--;
			sum2+=siz[xx[pos2]];
		}
	}
//	cout<<sum1<<' '<<sum2<<' '<<cnt<<'\n';
	if(sum1==sum2){
		if(cnt&1)cout<<"Fennec";
		else cout<<"Snuke";
		exit(0);
	}
	output(sum1>sum2);
}
void dfs(int idx,int par,int step){
//	cout<<idx<<'\n';
	size[idx]=1;
	a[step]=idx;
	if(idx==n&&flag){
		for(int i=0;i<step+1;i++){
			xx[i]=a[i];
		}
		flag=0;
		len=step+1;
	}
	for(int i=0;i<vec[idx].size();i++){
		if(vec[idx][i]!=par)dfs(vec[idx][i],idx,step+1),size[idx]+=size[vec[idx][i]];
	}
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>n;
	for(int i=1;i<n;i++){
		cin>>x>>y;
		vec[x].pb(y);
		vec[y].pb(x);
	}
//	for(int i=1;i<=n;i++)cout<<i<<':'<<vec[i].size()<<'\n';
	dfs(1,-1,0);
	work();
	return 0;
}


Measured memory_bytes: 13184
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

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


def solve():
    n = ri()
    A = rl()
    types = dd(int)
    ans = 0
    for i, h in enumerate(A):
        j = i + 1
        ans += types[j - h]
        types[j + h] += 1
    print (ans)






mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()


Measured memory_bytes: 132024
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<cmath>
#include<stack>
#include <algorithm>
#include <functional>
//#include<stdlib.h>
using namespace std;


int main() {
	int n,m; long long int k = 0;
	cin >> n;
	m = n / 2;
	vector<int>b(n);
	vector<int>v(n);
	for (int a = 0; a < n; a++) { cin >> b[a]; k += b[a]; b[a] *= 2; }
	for (int a = 0; a < m; a++) { k -= b[2*a+1]; }
	v[0] = k;
	cout << v[0];
	for (int a = 0; a < n-1; a++) { v[a + 1] = b[a] - v[a]; cout <<" "<< v[a + 1]; }
	return 0;
}

Measured memory_bytes: 2048