akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cmath>
using namespace std;
const int M=1000000007;
int n,m;
long long ans=1;
int main(){
	scanf("%d%d",&n,&m);
	if(abs(n-m)>1){
		printf("0\n");
		return 0;
	}
	for(int i=1;i<=n;++i)ans=ans*i%M;
	for(int i=1;i<=m;++i)ans=ans*i%M;
	if(n!=m)printf("%lld\n",ans);
	else printf("%lld\n",2*ans%M);
	return 0;
}

Measured memory_bytes: 1736
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;
#[derive(Clone, Debug, Default)]
struct Struct;


//#[proconio::fastout]
fn main() {
    input! {
        n: usize,
        mut f: [f64;n],
    }

    const PMAX:usize = 64;

    let mut v25 = vec![vec![0u64;PMAX];PMAX];
    // y = a * 1000000000.0
    // ai*ajが整数 -> yi*yjが2^18でも5^18でも割り切れる
    // v25[i][j] : y = 2^i * 5^j * a, a%2!=0, a%5!=0 となるyの個数 
    for x in &f {
        let mut y = (*x * 1000_000_000.0).round() as i64;
        let mut c2 = 0;
        let mut c5 = 0;
        while y % 2 == 0 {
            c2 += 1;
            y /= 2;
        }
        while y % 5 == 0 {
            c5 += 1;
            y /= 5;
        }
        v25[c2][c5] += 1;
        //println!("{} {} ", c2, c5 );
    }

    let mut acc25 = v25.clone(); // acc25[i][j] は  y % (2^i * 5^j) == 0 となる yの個数 
    for i in 0..PMAX {
        for j in 1..PMAX {
            acc25[i][PMAX-j-1] += acc25[i][PMAX-j];
        }
    }
    for i in 0..PMAX {
        for j in 1..PMAX {
            acc25[PMAX-j-1][i] += acc25[PMAX-j][i];
        }
    }

    let mut ans = 0u64;
    for p2 in 0..PMAX {
        for p5 in 0..PMAX {
            let q2 = if p2 > 18 { 0 } else { 18-p2 };
            let q5 = if p5 > 18 { 0 } else { 18-p5 };
            let sub = if p2 >= 9 && p5 >= 9 {1} else {0}; // 自分自身との組み合わせを除く
            ans += v25[p2][p5] * (acc25[q2][q5]-sub);

            //if v25[p2][p5] != 0 {
            //    println!("p2={} p5={} v={} acc={}", p2, p5, v25[p2][p5], acc25[q2][q5]);
            //}
        }
    }

    println!("{}", ans/2);
}


Measured memory_bytes: 6592
using System;
using System.Linq;

class Program {
    static void Main(string[] args) {
        string s1 = Cin.Next();
        string s2 = Cin.Next();
        string s3 = Cin.Next();
        Console.WriteLine(s1[0].ToString() + s2[1].ToString() + s3[2].ToString());
    }
}

public class Cin {
    private static string[] s = new string[0];
    private static int i = 0;

    private static char[] cs = new char[] { ' ' };

    public static string Next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return Next();
    }

    public static int Ni() {
        return int.Parse(Next());
    }

    public static long NextLong() {
        return long.Parse(Next());
    }

    public static double NextDouble() {
        return double.Parse(Next());
    }

}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;
const double eps = 1e-8;
double dot(P a, P b) { return real(conj(a) * b); }
double cross(P a, P b) { return imag(conj(a) * b); }
int ccw(P a, P b, P c) {
    b -= a; c -= a;
    if (cross(b, c) > eps) return 1;
    if (cross(b, c) < -eps) return -1;
    if (dot(b, c) < -eps) return 2;
    if (norm(c) > norm(b)) return -2;
    return 0;
}
bool intersectSS(P p1, P p2, P p3, P p4) {
    return ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0;
}
int n,m;long double ax[1000],ay[1000],bx[1000],by[1000],dist[1000];
vector<pair<int,long double> >x[1000];
long double dijkstra(int s,int t){
	priority_queue<pair<long double,int>,vector<pair<long double,int> >,greater<pair<long double,int> > >Q;
	Q.push(make_pair(0.0L,s));for(int i=0;i<1000;i++)dist[i]=1e9;dist[s]=0.0L;
	while(!Q.empty()){
		long double a1=Q.top().first;int a2=Q.top().second;Q.pop();
		for(int i=0;i<(int)x[a2].size();i++){
			if(dist[x[a2][i].first]>a1+x[a2][i].second){
				dist[x[a2][i].first]=a1+x[a2][i].second;
				Q.push(make_pair(dist[x[a2][i].first],x[a2][i].first));
			}
		}
	}
	return dist[t];
}
int main(){
	cin>>n>>m;for(int i=0;i<n;i++)cin>>ax[i]>>ay[i];
	for(int i=0;i<m;i++)cin>>bx[i]>>by[i];
	for(int i=0;i<1000;i++)x[i].clear();
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			if(intersectSS(P(ax[i],ay[i]),P(ax[j],ay[j]),P(bx[0],by[0]),P(bx[1],by[1]))==0){
				long double dst1=sqrtl((ax[i]-ax[j])*(ax[i]-ax[j])+(ay[i]-ay[j])*(ay[i]-ay[j]));
				x[i].push_back(make_pair(j,dst1));
				x[j].push_back(make_pair(i,dst1));
			}
		}
	}
	long double r1=dijkstra(0,1);
	for(int i=0;i<1000;i++)x[i].clear();
	for(int i=0;i<m;i++){
		for(int j=i+1;j<m;j++){
			if(intersectSS(P(bx[i],by[i]),P(bx[j],by[j]),P(ax[0],ay[0]),P(ax[1],ay[1]))==0){
				long double dst1=sqrtl((bx[i]-bx[j])*(bx[i]-bx[j])+(by[i]-by[j])*(by[i]-by[j]));
				x[i].push_back(make_pair(j,dst1));
				x[j].push_back(make_pair(i,dst1));
			}
		}
	}
	long double r2=dijkstra(0,1);
	long double r3=sqrtl((bx[0]-bx[1])*(bx[0]-bx[1])+(by[0]-by[1])*(by[0]-by[1]));
	long double r4=sqrtl((ax[0]-ax[1])*(ax[0]-ax[1])+(ay[0]-ay[1])*(ay[0]-ay[1]));
	if(min(r1,r2)>=1e8)printf("-1\n");
	else printf("%.15Lf\n",min(r1+r3,r2+r4));
	return 0;
}

Measured memory_bytes: 38376
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define per1(i,n) for(int i=n;i>0;i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
ll dp[3001][3001][4],A[3001][3001];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    double n,x,t;
    cin>>n>>x>>t;
    cout<<(ll)(ceil(n/x)*t);
}

Measured memory_bytes: 3700
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if (s < t)
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
    

    return 0;
}

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

int main() {
  int n, ma = 0;
  cin >> n;
  map<string, int> str;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    if (str.count(s)) ++str[s];
    else str[s] = 1;
    ma = max(ma, str[s]);
  }
  for (auto s : str) {
    if (s.second == ma) cout << s.first << "\n";
  }
}

Measured memory_bytes: 25216
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		//キーボード入力メソッド
		Scanner sc = new Scanner(System.in);

		//入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		//処理
		int array[] = {a,b,c};
		Arrays.sort(array);

		//出力
		System.out.println(array[0] +" "+ array[1] +" "+ array[2]);
	}

}



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

#define fastio                  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define input_output            freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); 

#define ll                      long long
#define read1(x)                 cin>>x
#define read2(x,y)               cin>>x>>y
#define pii                     pair<int, int>
#define pli                     pair<ll, int>
#define pil                     pair<int, ll>
#define pll                     pair<ll, ll>
#define vi                      vector<int>
#define vll                     vector<ll>
#define vb                      vector<bool>
#define vd                      vector<double>
#define vs                      vector<string>
#define ff                      first
#define ss                      second
#define pb                      push_back
#define ppb                     pop_back
#define pf                      push_front
#define ppf                     pop_front
#define vpii                    vector<pii>
#define umap                    unordered_map
#define uset                    unordered_set
#define clr(a,b)                memset(a,b,sizeof a)
#define all(ds)                 ds.begin(), ds.end()
#define rev(ds)                 ds.rbegin(), ds.rend()
#define asc(A)                  sort(A.begin(), A.end())
#define dsc(A)                  sort(A.begin(), A.end(), greater<int>())
#define gcd(x,y)                __gcd(x,y)
#define clr(a,b)                memset(a,b,sizeof a)
#define fr(i, n)                for(int i=0; i<n;++i)
#define fr1(i, n)               for(int i=1; i<=n; ++i)
#define rfr(i, n)               for(int i=n-1; i>=0; --i)
#define printVector(v)          for(int i= 0;i<v.size();i++) {cout<<v[i]<<" ";} cout<<endl;
#define precise(x)              cout<<fixed<<setprecision(x)
#define inf                     10000000000000

 

ll lcm(ll a, ll b) {return (a*b)/__gcd(a, b); }
ll power(ll x, ll y, ll m) { if(!y) return 1; ll p=power(x, y>>1, m)%m; p=p*p%m; return (y&1)?(x*p)%m:p;}
ll modInverse(ll a, ll m){ return power(a, m-2, m); }
bool isPrime(ll num){bool flag=true;for(ll i =2;i<=num/2;i++){if(num%i==0) {flag=false; break;} }return flag;}
ll sumofdigits(ll n){ll c=0;while(n>0){c++;n/=10;}return c;}
bool sortinrev(const pair<int,int>&a,const pair<int,int>&b) {return a.first > b.first; }
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) {return a.second < b.second; }

//const double PI= 2*acos(0.0);
// const ll MOD= 1000000007;

void solve(){
    int d, t, s;
    cin>>d>>t>>s;
    if(d <= t*s)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}


int main()
{
#ifndef ONLINE_JUDGE  
    input_output  
#else   
    fastio
#endif

    int t = 1;
    // cin>>t;
    while(t--){
        solve();
    }

    return 0;
}

Measured memory_bytes: 3660
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int M = in.nextInt();
            long[] x = new long[N];
            long[] y = new long[N];
            long[] z = new long[N];
            for (int i = 0; i < N; i++) {
                x[i] = in.nextLong();
                y[i] = in.nextLong();
                z[i] = in.nextLong();
            }

            int[] a = { -1, 1 };

            long max = (long) -1e18;
            for (int i : a) {
                for (int j : a) {
                    for (int k : a) {

                        long[] diff = new long[N];
                        for (int n = 0; n < N; n++) {
                            diff[n] = i * x[n] + j * y[n] + k * z[n];
                        }
                        Arrays.sort(diff);

                        long sum = 0;
                        for (int l = 0; l < M; l++) {
                            sum += diff[N - 1 - l];
                        }

                        max = Math.max(max, sum);
                    }
                }
            }

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


Measured memory_bytes: 26604
#include<bits/stdc++.h>
using namespace std;
typedef long long l;
l max(l a,l b){
    if(a>b) return a;
    else return b;
}
int main(){
    l a,b,c;
    cin>>a>>b>>c;
    cout<<max((a-2)*(c-b)+1,0)<<endl;
}


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

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))    
#define OUT(P) cout << (P) << endl    
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl    
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;    
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)    
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)    
typedef long long ll;    
const long DIVIDE = 1e9+7;

int sum_digits(int num);    
template <class T>    
vector<T> copy_vector(vector<T> vec);    
long gcd(long a, long b);    
long lcm(long a, long b);
// ****** print functions ****** //
template <class T, class U>
void print_pairs(const vector<pair<T, U>> pairs);
template <class K, class V>
void print_map(const map<K, V> m);


int main() {    
    int n, m;
    cin >> n >> m;
    vector<vector<int>> costs(n+1, vector<int>(3, -1));

    vector<vector<int>> g(n+1);
    for(int i=0; i<m; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
    }

    int start, goal;
    cin >> start >> goal;

    queue<pair<int, int>> que; // (point, state)
    que.push({start, 0}); // push start
    costs[start][0] = 0;

    // 幅優先探索
    while(!que.empty()) {
        const int node = que.front().first;
        const int state = que.front().second;
        que.pop();

        // 隣接頂点を探索
        for(int i=0; i<g[node].size(); i++) {
            int x = g[node][i];
            const int next_state = (state + 1) % 3;
            if(costs[x][next_state] != -1) {
                continue;
            }
            costs[x][next_state] = costs[node][state] + 1;
            que.push({ x, next_state });
        }
    }
    if(costs[goal][0] != -1) {
        costs[goal][0] /= 3;
    }
    cout << costs[goal][0] << endl;

    return 0;    
}    

/******************************/    
/***** DECRARED FUNCTIONS *****/    
/******************************/    

int sum_digits(int num) {    
    int rtn = 0;    
    while(num != 0) {    
        int tmp = num % 10;    
        rtn += tmp;    
        num /= 10;    
    }    
    return rtn;    
}    

// vectorのコピー    
template <class T>    
vector<T> copy_vector(vector<T> vec) {    
    vector<T> rtn;    
    rtn.reserve(vec.size());    
    copy(vec.begin(), vec.end(), back_inserter(rtn));    
    return rtn;    
}    

long gcd(long a, long b) {    
    if(b==0) return a;    
    else return gcd(b, a % b);    
}

long lcm(long a, long b) {
    long gcd_ = gcd(a, b);
    return (a * b) / gcd_;
}

template <class T, class U>
void print_pairs(const vector<pair<T, U>> &pairs) {
    for(int i=0; i<pairs.size(); i++) { 
        cout << "(" << pairs[i].first << ", " << pairs[i].second << ")" << " "; 
    } 
    cout << endl;
}

template <class K, class V>
void print_map(const map<K, V> &m) {
    for(auto it=m.cbegin(); it!=m.cend(); it++) {
        cout << it->first << ": " << it->second << endl;
    }
}


Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);i <= (e);(i)++)

int N;

int main(){
  cin >> N;
  vector<int> a(N);
  rep(i,0,N - 1) cin >> a[i];

  int Mi = max_element(a.begin(),a.end()) - a.begin();
  using p = pair<int,int>;
  vector<p> vec;
  rep(i,0,N - 1){
    if(i == Mi) continue;
    vec.push_back({abs(a[i] - (a[Mi] - a[i])),i});
  }

  int Mi2 = (*min_element(vec.begin(),vec.end())).second;

  cout << a[Mi] << " " << a[Mi2] <<endl;
}


Measured memory_bytes: 1784
#include<iostream>
#include<sstream>
#include<iomanip>
#include<stdlib.h>
#include<string>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<utility>
using namespace std;
#define loop(i,l,r) for(int (i)=(int)(l);(i)<(int)(r);(i)++)
#define rloop(i,l,r) for(int (i)=(int)(l);(i)>(int)(r);(i)--)
#define rep(i,n) loop(i,0,n)
#define rrep(i,n) rloop(i,n-1,-1)
#define INF 0x3f3f3f3f
#define mod 1000000007
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

vector<string> split(stringstream& ss){
	string str;
	vector<string> res;
	while(ss>>str)res.push_back(str);
	return res;
}

int main(){
	int n,num;
	char table[9][5]={{'.',',','!','?',' '},{'a','b','c'},{'d','e','f'},{'g','h','i'},{'j','k','l'},{'m','n','o'},{'p','q','r','s'},{'t','u','v'},{'w','x','y','z'}};
	string s;
	cin>>n;
	rep(i,n){
		cin>>s;
		num=0;
		rep(j,s.size()){
			if(s[j+1]=='0'){
				if(s[j]=='0')continue;
				else cout<<table[s[j]-'1'][s[j]-'1'==0?num%5:s[j]-'1'==6||s[j]-'1'==8?num%4:num%3];
				num=0;
			}else if(s[j+1]==s[j]){
				num++;
			}
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1200
#include <iostream>
#include <cstdio>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <cstring>
using namespace std;

#ifdef ENABLE_LL
#define int long long
#endif

#ifdef ENABLE_LL
#define I "%lld"
#define II "%lld%lld"
#define III "%lld%lld%lld"
#define IIII "%lld%lld%lld%lld"
#define IN "%lld\n"
#define IIN "%lld%lld\n"
#define IIIN "%lld%lld%lld\n"
#define IIIIN "%lld%lld%lld%lld\n"
#else
#define I "%d"
#define II "%d%d"
#define III "%d%d%d"
#define IIII "%d%d%d%d"
#define IN "%d\n"
#define IIN "%d%d\n"
#define IIIN "%d%d%d\n"
#define IIIIN "%d%d%d%d\n"
#endif

#ifdef __LOCALE__
#define see(a) std::cout << #a << "=" << a << std::endl
#define ses(a) std::cout << #a << "=" << a << " " 
#else
#define see(a) //std::cout << #a << "=" << a << std::endl
#define ses(a)
#endif
#define repe(a,b) for (int a=0;a<(int)b.size();a++)
#define rep(i,n) for (int i=0;i<n;i++)
#define repa(i,n) for (int i=1;i<=n;i++)
#define repi(i,a,b) for (int i=a;i<=b;i++) 
#define repb(i,a,b) for (int i=a;i>=b;i--)
typedef pair < int , int > pr;
typedef pair < pr  , int > prr;
#define L first
#define R second
template <class T> inline bool checkMin(T& a , T b) { return (a > b ? a=b,1 : 0); }
template <class T> inline bool checkMax(T& a , T b) { return (a < b ? a=b,1 : 0); }
class Scanner{ private: istream& ist;public: Scanner(istream& in):ist(in){} string next(){ string r; ist >> r; return r; } string nextLine(){ string r; getline(ist,r); return r; } int nextInt(){ int r; ist >> r; return r; } double nextDouble(){ double r; ist >> r; return r; }};
Scanner sc(cin);

const int N = 55;
string s[N];
int t[N];
int n;

void init() {
    scanf(I,&n);
    rep (i,n) cin >> s[i] >> t[i];
}

void solve() {
    string x = sc.next();
    int i=0;
    while (x != s[i]) i++;
    int ans = 0;
    for (i++;i<n;i++) ans += t[i];
    printf(IN,ans);
}


#ifdef ENABLE_LL
#undef int
#endif
int main(){
    init();
    solve();
    return 0;
}


Measured memory_bytes: 256
N = int(input())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
ans = 0
for i in range(N-1, -1, -1):
    A[i] += ans
    ans += B[i] - (A[i] % B[i]) if A[i] % B[i] != 0 else 0
# print(A)
print(ans)


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

using namespace std;
using ll = long long;
const int MAXN = 100000 + 100;

ll n, a, b;
ll h[MAXN];

bool f(ll mi) {
	ll need = 0;
	for (int i = 0; i < n; i++) {
		ll cur = h[i] - mi * b;
		if (cur <= 0)
			continue;
			
		// ceil(need / (a - b))
		need += (cur + a - b - 1) / (a - b);
		if (need > mi)
			return false;
	}
	
	return (need <= mi);
}

int main(void) {
	cin >> n >> a >> b;
	
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	
	ll sum = accumulate(h, h + n, 0LL);
	
	// cout << sum << "\n";
	
	ll le = 1, ri = 0x3f3f3f3f;
	ll ans = -1;
	while (le <= ri) {
		ll mi = le + (ri - le) / 2;
		// cout << le << " " << ri << " " << mi << " " << f(mi) << "\n";
		if (f(mi)) {
			ans = mi;
			ri = mi - 1;
		} else {
			le = mi + 1;
		}
	}
	
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 4384
//arc065_c.cpp
//Sat Jun  9 20:09:01 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
using namespace std;
using ll=long long;

int main(){
	string s;
	cin >> s;

	int flag = 0;

	while (s.size()>0){
		if (s == "dreamer" || s == "eraser" || s == "erase" || s == "dream"){
			break;
		}
		if (s.substr(s.size()-7,7)=="dreamer"){
			s = s.substr(0,s.size()-7);
		}else if (s.substr(s.size()-6,6)=="eraser"){
			s = s.substr(0,s.size()-6);
		}else if (s.substr(s.size()-5,5)=="erase" ||
				  s.substr(s.size()-5,5)=="dream" ){
			s = s.substr(0,s.size()-5);
		}else {
			flag = 1;
			break;
		}
	}

	if (flag == 0){
		cout << "YES" << endl;
	}else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 512
S = list(input())
N = list(map(int,S))
def minus(x,y):
    if y == 0:
        return x
    else:
        return -1*x
def sign(x):
    if x == 0:
        return '+'
    else:
        return '-'
ans = ''
for i in range(7):
    b = list(map(int,format(i,'b').zfill(3)))
    seven = N[0]
    for k in range(3):
        seven +=  minus(N[k+1],b[k])
    if 7 == seven:
        for j in range(3):
            ans += S[j] + sign(b[j])
        ans += S[3] + "=7"
        print(ans)
        quit()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define li long long
#define itn int
 
using namespace std;
 
inline int nxt(){
	int n;
	scanf("%d", &n);
	return n;
}

template <typename T>
ostream& operator <<(ostream& ostr, const vector<T>& a) {
	ostr << "(";
	for (size_t i = 0; i < a.size(); ++i) {
		if (i) {
			ostr << ", ";
		}
		ostr << a[i];
	}
	ostr << ")";
	return ostr;
}

int main() {
	int n = nxt(), m = nxt();
	vector<int> cnt(26);
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		for (char c : s) {
			cnt[c - 'a'] += 1;
		}
	}

	int quad = 0, dbl = 0, sngl = 0;
	for (int x : cnt) {
		quad += x / 4;
		dbl += x % 4 / 2;
		sngl += x % 2;
	}

	int need_quad = (n / 2) * (m / 2);
	int need_sgnl = (n % 2) * (m % 2);
	int need_dbl = (n * m - need_sgnl - 4 * need_quad) / 2;

	if (need_quad > quad) {
		puts("No");
		return 0;
	}
	quad -= need_quad;
	dbl += quad * 2;
	if (need_dbl > dbl) {
		puts("No");
		return 0;
	}
	puts("Yes");

	return 0;
}

Measured memory_bytes: 256
def main():
    s = input()
    lst1 = []
    lst2 = []
    total_area = 0

    for i in range(len(s)):
        if s[i] == "\\":
            lst1.append(i)
        elif s[i] == "/" and len(lst1) > 0:
            j = lst1.pop()
            area = i - j
            total_area += area
            while len(lst2) > 0 and lst2[-1][0] > j:
                area += lst2.pop()[1]
            lst2.append([j, area])
    print(total_area)
    print(len(lst2), *[area for j, area in lst2])


if __name__ == "__main__":
    main()



Measured memory_bytes: 6172
#include <iostream>
#include <algorithm>
#include <string.h>
using namespace std;

int n, wt;
int v[100], w[100];
long a[101][10001];

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

	for (int i = 0; i < n; i++)
		cin >> v[i] >> w[i];

	memset(a, 0, sizeof(a));

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= wt; j++) {
			if (j < w[i - 1])
				a[i][j] = a[i - 1][j];
			else
				a[i][j] = max(a[i][j - w[i - 1]] + v[i - 1], a[i - 1][j]);
		}
	}

	cout << a[n][wt] << endl;

	return 0;
}


Measured memory_bytes: 11008
import java.awt.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.List;

public class Main {
    public static void main(String args[]) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Integer arr[]=new Integer[n];
        Integer arrToSort[]=new Integer[n];
        for (int i=0;i<n;i++){
            arr[i]=sc.nextInt();
            arrToSort[i]=arr[i];
        }
        Arrays.sort(arr);
        for (int i=0;i<n;i++){
            if (!arr[i].equals(arrToSort[i]) && arr[i]!=arrToSort[i]-1 && arr[i]!=arrToSort[i]+1){
                System.out.println("No");
                System.exit(0);
            }
        }
        System.out.println("Yes");

    }

}



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

using namespace std;
using ll = long long;
using ld = long double;

//#define int long long
//signed main(){
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll h,w;
    cin >> h >> w;
    if(h==1 || w==1){
        cout << "1" << "\n";
        return 0;
    }
    ll ans=((h+1)/2)*((w+1)/2)+(h/2)*(w/2);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n;
    cin >> n;
    int a;
    int ans = 0;
    rep(i, n) {
        cin >> a;
        while (a % 2 == 0) {
            ans++;
            a /= 2;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int n,m,A,B;
int main(){
	scanf("%d%d%d%d",&n,&m,&A,&B);
	for (int i=1;i<=B;i++){
		for (int j=1;j<=A;j++) putchar('0');
		for (int j=1;j<=m-A;j++) putchar('1');
		puts("");
	}
	for (int i=1;i<=n-B;i++){
		for (int j=1;j<=A;j++) putchar('1');
		for (int j=1;j<=m-A;j++) putchar('0');
		puts("");
	}
	return 0;
}

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

int main(){

 int a, b, c;
 int i, j;

 for(i = 1; i < 10; i++){
  for(j = 1; j < 10; j++){
   c = i * j;
   cout << i << "x" << j << "=" << c << endl;
  }
 }
 
 return 0;
}

Measured memory_bytes: 1116
import sys
sys.setrecursionlimit(10**8)

def sort(a):
	a.sort()

def rev(a):
	a.reverse()

def sd():
	return int(input())

def _sd():
	return map(int,input().split())


def ss():
	return input()

def sf():
	return float(input())

def dfs():
		# write dfs code here. And delete pass.
		pass

def bfs():
		# write bfs code here. And delete pass.
		pass
 
def main():
	f=bool(False)
	ans = int(0)
	N=sd()
	A=list(map(int,input().split()))
	while(1):
		for i in range(N):
			if A[i]%2:
				f=True
			else : 
				A[i]/=2
		if(not f):
			ans+=1
		else:
			break
	print(ans)

main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main(){long n,m=1e9+7;vector<int>a(26,0);cin>>n;string s;cin>>s;while(n--)a[s[n]-'a']++;n=1;for(int i;i<26;i++)n=n*(a[i]+1)%m;cout<<n-1;}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
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;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long N, std::vector<long long> H) {
  int cnt = 0;
  for (int i = 0; i < N; i++) {
    bool ok = true;
    for (int j = 0; j < i; j++)
      if (H[j] > H[i]) ok = false;
    if (ok) cnt++;
  }

  cout << cnt << endl;
}

int main() {
  cout << setprecision(10);
  long long N;
  scanf("%lld", &N);
  std::vector<long long> H(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &H[i]);
  }
  solve(N, std::move(H));
  return 0;
}


Measured memory_bytes: 256
A,B,K = map(int,input().split())
if A >= K:
  A = A - K
  B = B
elif A < K and B >= K-A:
  B=B-(K-A)
  A=0
elif K > A+B:
  A=0
  B=0

out = str(A) + " " + str(B)
print(out)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
const int COMMAX = 100000;
const int MOD = 1000000007;
vector<long long> fac, finv, inv;
 
void InitializeCombination(void){
    fac.push_back(1LL);
    fac.push_back(1LL);
    finv.push_back(1LL);
    finv.push_back(1LL);
    inv.push_back(0LL); //Though 0^(-1) cannot be defined, there should be some number in inv[0]
    inv.push_back(1LL);
    for (int i = 2; i < COMMAX; i++){
        fac.push_back(fac[i-1] * (long long)i % (long long)MOD);
        inv.push_back((long long)MOD - inv[MOD%i] * (long long)(MOD/i) % (long long)MOD);
        finv.push_back(finv[i-1] * inv[i] % (long long)MOD);
    }
}
 
long long Combination(int n, int r){
    if (n < r) return 0LL;
    if (n < 0 || r < 0) return 0LL;
    return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD;
}

int main(void){

    int N, K, Abuf;
    vector<int> A;
    cin >> N >> K;
    for(int i=0; i<N; i++){
        cin >> Abuf;
        A.push_back(Abuf);
    }

    sort(A.begin(), A.end());
    long long res = 0LL;

    InitializeCombination();

    for(int i=0; i<=N-K; i++){
        res += MOD + (long long)A[N-i-1]*Combination(N-i-1, K-1)%MOD;
        res %= MOD;
        res += MOD - (long long)A[i]*Combination(N-i-1, K-1)%MOD;
        res %= MOD;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3304
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s; cin >> s;
  int n = s.size();
  int cnt = 0;
  REP(i,n) if(s[i]=='o') cnt++;
  cout << (15-n+cnt>=8 ? "YES\n" : "NO\n");

  return 0;
}


Measured memory_bytes: 256
class _Node {
  constructor(key, parent = null, left = null, right = null) {
    this.key = key;
    this.parent = parent;
    this.left = left;
    this.right = right;
  }
}

class BinaryTree {
  constructor() {
    this.root = null;
  }

  static get Node() { return _Node; }

  insert(key) {
    this.root = new BinaryTree.Node(key, null, null, null);
    this.insert = (key) => {
      let x = this.root, y;
      let newNode = new BinaryTree.Node(key, null, null, null);
      while (x !== null) {
        y = x;
        x = x[key < x.key ? 'left' : 'right'];
      }
      newNode.parent = y;
      y[key < y.key ? 'left' : 'right'] = newNode;
    }
  }

  printByIneorder() {
    let str = '';
    let innerFunc = (n) => {
      if (n === null) return;
      innerFunc(n.left);
      str += ` ${n.key}`;
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  printByPreorder() {
    let str = '';
    let innerFunc = (n) => {
      if (n === null) return;
      str += ` ${n.key}`;
      innerFunc(n.left);
      innerFunc(n.right);
    }
    innerFunc(this.root);
    console.log(str);
  }

  print() {
    this.printByIneorder();
    this.printByPreorder();
  }
}

(function main(){
  const lines = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
  const n = Number(lines.shift());

  const tree = new BinaryTree();
  lines.map((line) => line.split(' ')).forEach(function(cmd) {
    switch(cmd[0].charAt(0)) {
    case 'i': tree.insert(Number(cmd[1])); break;
    default: tree.print();
    }
  });

})();



Measured memory_bytes: 269480
#include<bits/stdc++.h>
using namespace std;
#include<string.h>
#define v vector<int>
#define vpp vector<pair<int,int>>
#define ll long long int
#define ull unsigned long long
#define ld long double
#define f(a,b) for(ll i =a;i<b;i++)
#define vi vector<int>
#define vl vector<ll>
#define pri pair<int,int>
#define mpi map<int,int>
#define prl pair<ll,ll>
#define mp make_pair
#define mpl map<ll,ll>
#define pb push_back
#define MOD 1000000007
#define ub upper_bound
#define lb lower_bound
ll fast_pow(ll k, ll p)
{
if (p == 0)
        return 1;
 
    ll P = fast_pow(k, p/2);
    P = (P * P) % MOD;
 
    if (p % 2 == 1)
        P = (P * k) % MOD;
 
    return P;
}
ll invmod(ll a,ll m)
{
    return fast_pow(a,m-2);
}

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 nextPowerOf2(ll n)
{
    n>>=1;
    ll count = 0;

    if (n && !(n & (n - 1)))
        return n;

    while( n != 0)
    {
        n >>= 1;
        count += 1;
    }

    return 1 << count;
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
    C[0] = 1;
  
    for (ll i = 1; i <= n; i++) 
    {
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 


//////////////////////*********CODE***********/////////////////////
int main (){
    ll n;
    cin>>n;
    ll c=0;
    for(ll i=1;i<=sqrt(n);i++){
        if(n%i==0){
            ll x=n;
            if(i!=1){
            while(x%i==0){
                x=x/i;
            }
            if(x%i==1&&i!=1) c++;}
            ll d=n/i;
            if(n%d==0&&d!=i){
                 ll x=n;
            while(x%d==0){
                x=x/d;
            }
            if(x%d==1&&d!=1) c++;
            }
        }
    }
    for(ll i=1;i<=sqrt(n-1);i++){
        if((n-1)%i==0){
            if(i!=1) c++;
            ll d=(n-1)/i;
            if((n-1)%d==0&&d!=i) c++;
        }
    }
    cout<<c<<endl;
}

Measured memory_bytes: 384
N,K,Q=  list(map(int,input().split(" ")))
mem = [K - Q] * (N + 1)
for _ in range(Q):
    m = int(input())
    mem[m] += 1

for i,p in enumerate(mem[1:]):
    if p <= 0:
        print("No")
    else:
        print("Yes")



Measured memory_bytes: 51928
n, k = map(int, input().split())
a = [int(x) for x in input().split()]
mod = 1000000007
t = 0
for i in range(n):
    for j in range(n-i-1):
        if a[i+j+1] < a[i]:
            t += 1
a.sort()
s = 0
for i in range(n):
    for j in range(n-i-1):
        if a[i+j+1] > a[i]:
            s += 1
key = ((k%mod)*((k-1)%mod)//2)%mod
ans = ((t*k)%mod+(s*key)%mod)%mod
print(ans)

Measured memory_bytes: 3188
N = int(input())
list_x= list(map(int, input().split(' ')))
Alice, Bob= 0, 0
x = 0
for i in range(N):
    x = max(list_x)
    list_x.remove(x)
    if i % 2 == 0:
        Alice += x
    else:
        Bob += x
print(str(Alice - Bob))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;

int a,b,c,d;

int main(){

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

cin>>a>>b>>c>>d;

if(a+b>c+d){
	cout<<"Left"<<endl;
}
if(a+b==c+d){
	cout<<"Balanced"<<endl;
}
if(a+b<c+d){
	cout<<"Right"<<endl;
}

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1000000007;
const double PI = acos(-1);

int main()
{
	int d, t, s;
	cin >> d >> t >> s;
	if (s * t >= d) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,d;
    cin>>n>>d;
    vector<vector<int> > v(n,vector<int>(d));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<d;j++)
        {
            cin>>v[i][j];
        }
    }
    int ans =0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            int norm=0;
            for(int k=0;k<d;k++)
            {
                int diff = abs(v[j][k]-v[i][k]);
                norm+= diff*diff;
            }
            bool flag = false;
            for(int k=0;k<=norm;k++)
            {
                if(k*k == norm)
                {
                    flag=true;
                }
            }
            if(flag)ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ITP1_3_B
{
    class Program
    {
        static void Main()
        {
            var list = new List<int>();
            int input;
            while ((input = int.Parse(Console.ReadLine())) != 0)
                list.Add(input);
            for(int i = 0; i < list.Count; i++)
                Console.WriteLine("Case " + (i + 1) + ": " + list[i]);
        }
    }
}

Measured memory_bytes: 9532
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()
#define pb push_back

typedef long long ll;
const int inf = 1e9+7;
const ll infll = 1 << 60LL;
const ll mod = 1e9 + 7;
// 0~3までは左右前後 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

// 型による変数のオーバーフローに気をつけろ！！
// 悩んだら図やグラフを書け！！悩む前から書け！！

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

	ll n, m, q;
	cin >> n >> m >> q;
	vector<pair<ll, ll>>lr, pq;
	rep(i, m) {
		int l, r;
		cin >> l >> r;
		lr.push_back({ l,r });
	}
	rep(i, q) {
		int p, _q; // ←バーつけるなら両方つける、わかりにくい
		cin >> p >> _q;
		pq.push_back({ p,_q });
	}

	ll cnt = 0;
	// 質問1e5個あるじゃん
	// てことはlognで解かなきゃいけないのでは？
	// もしくは累積和で定数倍に持ち込む

	// ちょうどlからrまでつないでいる線路の数
	vector<vector<ll>> num;
	num = vector<vector<ll>>(n, vector<ll>(n, 0));

	rep(i, m) {
		num[lr[i].first-1][lr[i].second-1]++;
	}

	// 例えば、2から5までに完全に含まれる列車の本数を求めたいとき、
	// num[2...5][2...5]の数をタス

	vector < vector<ll> >sum;
	sum = vector<vector<ll>>(n, vector<ll>(n, 0));

	rep(i, n) {
		sum[0][0] = num[0][0];
	}
	// 縦に累積和
	rep(i, n) {
		rep(j, n) {
			if (j == 0) continue;
			sum[i][j] = sum[i][j - 1] + num[i][j];
		}
	}

	rep(i, q) {
		cnt = 0;
		Rep(j, pq[i].first - 1, pq[i].second) {
			if(pq[i].first - 2 >= 0)
				cnt += sum[j][pq[i].second - 1] - sum[j][pq[i].first - 2];
			else {
				cnt += sum[j][pq[i].second - 1];
			}
		}
		cout << cnt << endl;
	}

	return 0;
}

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

#define ll long long

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

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


int gcd(int a, int b){
  int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}

/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int n,k;
  scanf("%d%d",&n,&k);

  ll A[n];
  for(int i=0;i<n;i++){
    scanf("%lld",&A[i]);
  }

  sortup(A,n);
  ll ans=0;
  for(int i=0;i<n-k;i++){
    ans+=A[i];
  }

  printf("%lld\n",ans);

  return 0;
}

Measured memory_bytes: 4668
#include <cstdio>

int main()
{
	int n;
	scanf("%d", &n);
	
	int ans = -n;
	
	for (int i = 0; i < n; ++i)
	{
		static int x;
		scanf("%d", &x);
		ans += x;
	}
	
	printf("%d", ans);
}

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

using namespace std;

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

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    // cout << setprecision(8) << setiosflags(ios::fixed);

    int n;
    cin >> n;

    vector<int> v(n), c(n);
    for (auto &v_i : v) cin >> v_i;
    for (auto &c_i : c) cin >> c_i;

    int max_diff = 0;
    for (int i = 0; i < n; ++i)
        max_diff += max(0, v[i] - c[i]);

    cout << max_diff << endl;

    return 0;
}


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

using namespace std;

using ll = long long;

int main(){

    string s; cin >> s;
	ll arr[2560] = {0};
	for(ll i = 0; i < s.length(); ++i){
		arr[s[i]]++;
	}
	sort(arr, arr + 2560, greater<ll>());
	if(arr[0] - arr[1] <= 1  && arr[1] - arr[2] <= 1 && arr[0] - arr[2] <= 1){
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 1e6 + 5;
int a[maxn];
vector<int> fact[maxn];
int book[maxn] , prime[maxn] , cnt = 0;
void getp()
{
    for (int i = 2 ; i < maxn ; i++){
        if (!book[i]){
            prime[++cnt] = i;
            fact[i].push_back(i);
            for (int j = i + i ; j < maxn ; j += i)
                book[j] = 1 , fact[j].push_back(i);
        }
    }
    return ;
}
int sign[maxn];
int main()
{
    ios::sync_with_stdio(false);
    int n; cin >> n;
    getp();
    for (int i = 1 ; i <= n ; i++) {
        cin >> a[i];
    }
    bool ok = false;
    for (int i = 1 ; i <= n ; i++){
        for (auto g : fact[a[i]]){
            sign[g]++;
            if (sign[g] > 1) {
                ok = true;
                break;
            }
        }
        if (ok) break;
    }
    if (!ok) cout << "pairwise coprime" << endl;
    else {
        int all = a[1];
        for (int i = 1 ; i <= n ; i++) all = __gcd(all , a[i]);
        if (all == 1) cout << "setwise coprime" << endl;
        else cout << "not coprime" << endl;
    }
    return 0;
}


Measured memory_bytes: 67456
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
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;}

int main(){
    ll a, b, k;
    cin >> a >> b >> k;

    ll takahashi = a, aoki = b;

    if(takahashi >= k){
        cout << takahashi - k << " " << aoki << endl;
        return 0;
    }else if(aoki > (k - takahashi)){
        cout << 0 << " " << aoki - (k - takahashi) << endl;
        return 0;
    }

    cout << 0 << " " << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
int main()
{
  int N;
  string s;
  cin >> N;
  if(N < 1200){
    cout << "ABC" << endl;
  }else if(N < 2800)
    cout << "ARC" << endl;
  else
    cout << "AGC" << endl;
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int A, B, K;
	cin>>K>>A>>B;
	bool pos = false;;
	while(A<=B)
	{
		if(A%K==0)
		{
			pos = true;
			break;	
		}
		A++;
	}
	if(pos)
		cout<<"OK";
	else
		cout<<"NG";
}

Measured memory_bytes: 3636
import numpy as np
n,m,c = map(int, input().split())
b = np.array([int(i) for i in input().split()])
ans = 0
for ii in range(n):
    a = np.array([int(i) for i in input().split()])
    if (np.dot(a,b) + c) > 0:
        ans += 1
print(ans)


Measured memory_bytes: 18976
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MOD=1e9+7;
static const ll MAX=101010;

/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

ll cnt[33][MAX];

int main(void) {
  ll i, j, k, l;
  
  ll N;
  cin >> N;
  ll C;
  cin >> C;
  
  for(i=0; i<N; i++) {
    ll s, t, c;
    cin >> s >> t >> c;
    t++; c--;
    cnt[c][s]++;
    cnt[c][t]--;
  }
  
  for(i=0; i<C; i++) {
    for(j=1; j<MAX; j++) {
      cnt[i][j]+=cnt[i][j-1];
    }
    
    for(j=1; j<MAX; j++) {
      if(cnt[i][j]>=2) cnt[i][j]=1;
    }
    
  }
  
  
  ll ans=0;
  for(j=1; j<MAX; j++) {
    ll t=0;
    for(i=0; i<C; i++) {
      if(cnt[i][j]) t++;
    }
    
    chmax(ans, t);
  }
  
  pt(ans);
  
}




Measured memory_bytes: 24832