akhauriyash/Code-Regression huggingface dataset:
x, y = map(int, input().split())
mod = 1000000007
class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv
if (x + y) % 3 != 0:
  print(0)
else:
  n = (x + y) // 3
  if n > x or n > y:
    print(0)
  else:
    nx = x - n
    comb = Combination(n)
    print(comb(n, nx))


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

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

int main() {
    int r;
    double k;
    cin >> r;

    k = 2 * r * M_PI;

    cout << k << endl;

    return 0;
}


Measured memory_bytes: 3780
// #Badhi moh maya chhe!


#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define Fo(i,k,n) for(ll i=k;k<n?i<=n:i>=n;k<n?i+=1:i-=1)
#define deb(x) cout << #x << "=" << x << endl
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);

ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
bool com(pll x,pll y)
{    return x.first>y.first;
}


int main() {
	IOS
    	ll t;
	//cin>>t;	
	t=1;
	while(t--)
	{
	ll n,m;
	//cin>>n;
	string s;
	cin>>s;
	if(s=="SUN")cout<<7;
	else if(s=="SAT")cout<<1;
else if(s=="FRI")cout<<2;
else if(s=="THU")cout<<3;
else if(s=="WED")cout<<4;
else if(s=="TUE")cout<<5;
else if(s=="MON")cout<<6;
	
	
	
	}
	
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;
  cin>>n;
  int a[n];int x=0;
 for(int i=0;i<n;++i){
  cin>>a[i];
 x =a[i]^x;
  }
  for(int i=0;i<n;++i){
    k=x^a[i];
    cout<<k<<" ";
  }
  return 0;
}

Measured memory_bytes: 4364
#include<bits/stdc++.h>
using namespace std;
int main(void){
	int n;
	array<int,100>ar;
	int i,j;
	int cnt;
	int flg;
	cin>>n;
	for(i=0;i<n;i++)	cin>>ar[i];
	cnt=0;
	flg=1;
	i=0;
	while(flg){
		flg=0;
		for(j=n-1;j>=i+1;j--){
			if(ar[j]<ar[j-1]){
				swap(ar[j],ar[j-1]);
				flg=1;
				cnt++;
			}
		}
		i++;
	}
	for(i=0;i<n;i++){
		if(i==0)	cout<<ar[i];
		else		cout<<" "<<ar[i];
	}
	cout<<endl;
	cout<<cnt<<endl;
	return 0;
}
	


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

int main() {
    int A, B, M; std::cin >> A >> B >> M;
    std::vector<int> a(A);
    int ma = 0;
    for (int i = 0; i < A; i++) {
        std::cin >> a[i];
        if (i == 0) {
            ma = a[0];
        } else {
            ma = std::min(ma, a[i]);
        }
    }
    std::vector<int> b(B);
    int mb = 0;
    for (int i = 0; i < B; i++) {
        std::cin >> b[i];
        if (i == 0) {
            mb = b[0];
        } else {
            mb = std::min(mb, b[i]);
        }
    }

    int m = ma + mb;

    for (int i = 0; i < M; i++) {
        int x, y, c; std::cin >> x >> y >> c;
        x--; y--;
        m = std::min(m, a[x] + b[y] - c);
    }
    std::cout << m << std::endl;
    return 0;
}

Measured memory_bytes: 3568
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

/* Starry Sky Tree */
//0-index

struct StarrySkyTree{
  typedef ll Type;
  int segn2;
  vector<Type> data,s_data;
  
  StarrySkyTree(int n){
    for(segn2=1;segn2<n;segn2*=2);
    data.assign(segn2*2,0);
    s_data.assign(segn2*2,0);
  }
  
  //get minimum value of [a,b]
  Type query(int a,int b,int l=0,int r=-1,int k=0){
    if(r==-1) r+=segn2;
    if(r<a || b<l) return 0;
    if(a<=l && r<=b) return data[k] + s_data[k];
    return max(query(a,b,l,(l+r)/2,k*2+1),query(a,b,(l+r)/2+1,r,k*2+2))+s_data[k];
  }
  
  //add x to [a,b]
  Type add(int a,int b,Type x,int l=0,int r=-1,int k=0){
    if(r==-1) r+=segn2;
    if(a<=l && r<=b){
      s_data[k]+=x;
    }else if(a<=r && l<=b){
      data[k] = max(add(a,b,x,l,(l+r)/2,k*2+1),add(a,b,x,(l+r)/2+1,r,k*2+2));
    }
    return data[k] + s_data[k];
  }
  
};

int main(){
  int n;
  ll x[SIZE], s[SIZE];
  
  scanf("%d",&n);

  StarrySkyTree seg(SIZE);
  
  for(int i=0;i<n;i++){
    scanf("%lld%lld",x+i,s+i);

    seg.add(i,i,-(x[i]-x[0]));
    seg.add(i,n-1,s[i]);
  }

  ll ans = 0;
  
  for(int i=0;i<n;i++){
    ans = max(ans, seg.query(0,INF));
    seg.add(i+1, n-1, x[i+1]-x[i]);
    seg.add(i+1, n-1, -s[i]);
  }

  printf("%lld\n",ans);
  
  return 0;
}


Measured memory_bytes: 12672
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#define int long long
using namespace std;

signed main() {
	int N;
	cin >> N;
	vector<int> A(N);
  	vector<int> B(N);
	for(int i = 0;i < N;i++) {
		cin >> A.at(i);
      	cin >> B.at(i);
	}
	int answer = 0;
	for(int i = N - 1;i >= 0;i--) {
		if(B.at(i) != 1) {
			int cnt = (B.at(i) - ((A.at(i) + answer) % B.at(i))) % B.at(i);
			answer += cnt;
		}
	}
	cout << answer << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<map>

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

using namespace std;

int main() {
	string str;
	cin >> str;
	int c = 0;
	int f = 0;

	for (int i = 0; i < str.length(); i++) {

		if (str[i] == 'C')c = 1;
		if (c == 1 && str[i] == 'F')f = 1;
	}
	
	if (c == 1 && f == 1)cout << "Yes" << endl;
	else cout << "No" << endl;


	return 0;
}

Measured memory_bytes: 256
/*
[abc106] A - Garden
*/

#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

int A, B;

ll solve() { return A * B - A - B + 1; }

int main() {
    cin >> A >> B;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 2e5+5;

int n;
int d;
vector < int > P[50];

int sq(int x){
    return x*x;
}

int get(int a , int b){
    int dd = 0;
    for(int i = 0; i < d; i++){
        dd += sq(P[a][i] - P[b][i]);
    }
    for(int i = 0; i < 160; i++){
        if(i*i == dd)
            return 1;
    }
    return 0;
}

int main(){
    cin >> n >> d;
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= d; j++){
            int x;
            cin >> x;
            P[i].push_back(x);
        }
    }
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        for(int j = i+1; j <= n; j++){
            cnt += get(i , j);
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int D, L;
	cin >> D >> L;

	cout << D / L + D % L << endl;
	return 0;
}




Measured memory_bytes: 3180
n = int(input())
s = list(input())
a = 0
for i in range(n):
    x = list(set(s[:i]))
    y = list(set(s[i:]))
    t = 0
    for j in x:
        if j in y:
            t += 1
    a = max(a, t)
print(a)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <functional>
using namespace std;

// http://drken1215.hatenablog.com/entry/2019/06/15/021000
long long integer_cards(int n, int m, long long a[], int b[], long long c[]) {
  vector<pair<long long, int>> aa;
  for(int i=0; i<n;i++) {
    aa.push_back(make_pair(a[i], 1));
  }
  for(int i=0;i<m;i++) {
    aa.push_back(make_pair(c[i], b[i]));
  }
  sort(aa.begin(), aa.end(), greater<pair<long long, int>>());
  int cons = 0;
  long long ans = 0;
  int index = 0;
  while(cons < n) {
    int size = n - cons > aa[index].second ? aa[index].second : n - cons;
    //cout << "index: " << index << ", item: " << aa[index].first << ", " << "size:" << size << endl;
    ans += aa[index].first * size;
    index++;
    cons += size;
  }

  return ans;
}

int main() {
  int n;
  cin >> n;
  int m;
  cin >> m;
  long long a[n];
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  int b[m];
  long long c[m];
  for(int i =0;i<m;i++) {
    cin >> b[i];
    cin >> c[i];
  }
  auto ans = integer_cards(n, m, a, b, c);
  cout << ans;
}


Measured memory_bytes: 8432
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int[]d = new int[n];
		for(int i = 0; i < n; i++) {
			d[i] = stdIn.nextInt();
		}
		
		Arrays.sort(d);
		int cnt = 1;
		for(int i = 0; i < n-1; i++) {
			if(d[i]!=d[i+1]) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}

}


Measured memory_bytes: 22228
import java.util.*;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        PriorityQueue<Long> numbers = new PriorityQueue<>(3,Collections.<Long>reverseOrder());
        for (int i = 0; i < 3; i++) {
            numbers.add(scanner.nextLong());
        }
        int k = scanner.nextInt();

        for (int i = 0; i < k; i++) {
            long max = numbers.poll();
            numbers.add(max*2);
        }

        long ans = 0;
        while (true){
            if (numbers.isEmpty()){
                break;
            }
            ans += numbers.poll();
        }
        System.out.println(ans);
        scanner.close();
    }
}


Measured memory_bytes: 21204
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,m;
vi a,b;

int main(){
	while(1){
		cin>>n>>m;
		if(!n) break;
		a=vi(n);
		b=vi(m);
		vi dp(1<<n,inf);
		dp[0]=0;
		for(int i=0;i<n;i++) cin>>a[i];
		for(int i=0;i<m;i++){
			cin>>b[i];
			dp[0]+=b[i];
		}
		for(int i=1;i<1<<n;i++){
			int sum=0;
			for(int j=0;j<n;j++) if(i&1<<j) sum+=a[j];
			for(int j=0;j<n;j++) if(i&1<<j){
				int res=0;
				for(int k=0;k<m;k++){
					int A=abs(sum-b[k]),B=abs(sum-a[j]-b[k]);
					if(A<B) res+=B-A;
				}
				dp[i]=min(dp[i],dp[i-(1<<j)]-res);
			}
		}
		cout<<dp.back()<<endl;
	}
}

Measured memory_bytes: 3148
#include<iostream>
using namespace std;
int main(){
    int n;
    int d[110];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>d[i];
    }
    int num[110]={0}; //バケット
    for(int i=0;i<n;i++){
        num[d[i]]++; //大きさがd[i]のものの数をそれぞれカウント
    }
    int ans=0;
    for(int i=0;i<=100;i++){ //大きさは100以下
        if(num[i]!=0){
            ans++;//大きさiのものがあったらカウント
        }
    } 
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


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


class mint {
    long long x;
public:
    mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
    mint operator-() const {
        return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD - a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD - 2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res /= a;
    }

    friend ostream& operator<<(ostream& os, const mint& m) {
        os << m.x;
        return os;
    }
};

int main() {
	
    ll N;
    cin >> N;
    vector<ll> A(N + 1);
    repn(i, N) cin >> A[i];

    mint f=1;
    repn(i, N) f *= i;

    vector<mint> v(N + 1,0);
    repn(i, N) v[1] += f / i;

    for (ll i = 2; i <= N; i++) {
        v[i] = v[i - 1] - f / (N + 2 - i) + f / i;
        //cout << v[i] << endl;
    }

    mint ans = 0;
    repn(i, N) ans += v[i] * A[i];

    cout << ans;


		

	
	system("PAUSE");
}


Measured memory_bytes: 2040
#include<iostream>
#include<string>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	string a,b,c;
	cin>>a>>b>>c;
	if(a[a.size()-1]==b[0] && b[b.size()-1]==c[0])cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
r=input().split()
n=int(r[0])
m=int(r[1])

if n<m:
    x=sorted([int(i) for i in input().split()])[::-1]
    xd=sorted([x[i]-x[i+1] for i in range(m-1)])
    if n==1:
        ans=x[0]-x[-1]
    else:
        ans=sum(xd[:-(n-1)])
else:
    ans=0
print(ans)

Measured memory_bytes: 13832
#include <bits/stdc++.h>
#define ll long long
ll mod=1000000007;
#define vl vector<ll>
#define pl pair<ll,ll>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,b) for(ll i=0;i<b;i++)
#define RFOR(i,a,b) for(ll i=b-1;i>=a;i--)
#define rsort(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(),(v).end()
using namespace std;

int main(){
    ll n,m,a,b,ans=0;
    ll array[]={0,1,2,3,4,5,6,7};
    bool root[8][8];
    rep(i,8)rep(j,8)root[i][j]=false;

    cin>>n>>m;
    rep(i,m){
        cin>>a>>b;
        a--;b--;
        root[a][b]=1;
        root[b][a]=1;
    }
    do{
        bool flag=1;
        for(int i=0; i<n-1; i++){
           if(root[array[i]][array[i+1]]==0)flag=0;
        }
        if(flag==1)ans++;
    }while(next_permutation(array+1,array+n));
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int k = sc.nextInt();
    c = c * (int)Math.pow(2, k);
    for (int i = 0; i <= k; i++) {
      if (a < b && b < c) {
        System.out.println("Yes");
        break;
      }
      if (i == k) {
        System.out.println("No");
        break;
      }
      b *= 2;
      c /= 2;
    }
  }
}


Measured memory_bytes: 35744
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
int a[55];

int main() {
    int n,m;
    cin>>n>>m;
    int s=0;
    for(int i=0;i<n;i++){
		cin>>a[i];
		s+=a[i];
    }
    sort(a,a+n);
    for(int i=0;i<n-m;i++){
		s-=a[i];
    }
    cout<<s<<endl;

	return 0;
}


Measured memory_bytes: 256
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  if (n[0] == n[1] && n[1] == n[2]) cout << "Yes" << endl;
  else if (n[2] == n[3] && n[1] == n[2]) cout << "Yes" << endl;
  else cout << "No" << endl;


  
  return 0;
}

Measured memory_bytes: 256
/*
a+b>c and b+c>a and c+a>b

if maximum angle is A:
             > 0 ... acute???angled triangle
b^2+c^2-a^2  = 0 ... right triangle
             < 0 ... obtuse???angled triangle
*/

#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
//#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define pow(a) a*a
int comp(const void*a, const void*b) {
	return *(int*)a - *(int*)b;
}
int main() {
	int n,f=0,side[3],at,ot,rt;	
	at = ot = rt = 0;
	while(~fscanf(stdin,"%d%d%d",side,side+1,side+2)){
		qsort(side, 3, sizeof(int), comp);
		if (side[0] + side[1] <= side[2] || side[1] + side[2] <= side[0] || side[0] + side[2] <= side[1]) f = 1;
		if (f) continue;
		if (pow(side[0]) + pow(side[1]) - pow(side[2]) > 0)at++;
		else if (pow(side[0]) + pow(side[1]) - pow(side[2]) == 0)rt++;
		else if (pow(side[0]) + pow(side[1]) - pow(side[2]) < 0)ot++;
	}
	fprintf(stdout, "%d %d %d %d\n", at + rt + ot, rt, at, ot);
	return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long n,m;
  cin>>n>>m;
  vector<pair<long long,long long>>a(n);
  for(long long i=0;i<n;i++){
    cin>>a[i].first>>a[i].second;
  }
  sort(a.begin(),a.end());
  long long x=0;
  long long kotae=0;
  long long count=0;
  while(x<=m){
    if(a[count].second+x<=m){
      kotae+=a[count].second*a[count].first;
      x+=a[count].second;
      count++;
    }else {
      kotae+=(m-x)*a[count].first;
      break;
    }
  }
  cout<<kotae<<endl;   
  return 0;
}

Measured memory_bytes: 1792
while 1:
	n=input()
	if n==0:break
	p=raw_input().split()+["end"]
	sp=p[0]
	for i in range(n):
		if str(int(p[i])+1)!=p[i+1]:
			if sp!=p[i]:
				print sp+"-"+p[i],
			else:
				print sp,
			sp=p[i+1]
	print

Measured memory_bytes: 4212
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<queue>
#define mem(x) memset(x,0,sizeof(x)) 
#define sca(x) scanf("%d",&x)
#define scaa(x,y) scanf("%d%d",&x,&y)
#define inf 0x7f7f7f7f
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#pragma GCC optimize(2)
using namespace std;
const double pi=acos(-1); 
const double eps=1e-6;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef long long ll;
typedef pair<char,char> pcc;
string s[100005];
char ans[100005];
int n,a,b,c;
void dfs(int i, int a, int b, int c) {
	if (i == n) {
		cout << "Yes\n";
		for (int i = 0; i < n; i++)
			cout << ans[i] << "\n";
		exit(0);
	}
	if (s[i] == "AB") {
		if (a) ans[i] = 'B', dfs(i+1,a-1,b+1,c);
		if (b) ans[i] = 'A', dfs(i+1,a+1,b-1,c);
	}
	if (s[i] == "BC") {
		if (b) ans[i] = 'C', dfs(i+1,a,b-1,c+1);
		if (c) ans[i] = 'B', dfs(i+1,a,b+1,c-1);
	}
	if (s[i] == "AC") {
		if (a) ans[i] = 'C', dfs(i+1,a-1,b,c+1);
		if (c) ans[i] = 'A', dfs(i+1,a+1,b,c-1);
	}
}

int main() {
	cin >> n >> a >> b >> c;
	for (int i = 0; i < n; i++)
		cin >> s[i];
	dfs(0,a,b,c);
	cout << "No";
}

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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;

  int ans = 0;

  for (int i = 0; i <= A; i++) {
    for (int j = 0; j <= B; j++) {
      for (int k = 0; k <= C; k++) {
        if(i * 500 + j * 100 + k * 50 == X) ans++;
      }
    }
  }

  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const int MAXN = 6005;
const int INF = 1e5;
int A[MAXN], nxt[MAXN], dp[MAXN][MAXN], ans = 0, base = 0, N;
inline int Cost(int a, int b, int c) {
  return A[a] == A[b] && A[b] == A[c];
}
void chmax(int &x, int val) {
  x = max(x, val);
}
inline void Transition(int i, int j, int cur) {
  if (cur > 3 * N) return;
  if (cur == 3 * N)
    return void(chmax(ans, dp[i][j] + Cost(i, j, cur)));
  for (int u = 1; u <= 3; ++u)
    for (int v = u + 1; v <= 3; ++v)
      chmax(dp[cur + u - 1][cur + v - 1], dp[i][j] + Cost(i, j, cur + (u ^ v) - 1));
 
  for (int c : {i, j}) {
    chmax(dp[c][cur + 0], dp[i][j] + Cost(i ^ j ^ c, cur + 1, cur + 2));
    chmax(dp[c][cur + 1], dp[i][j] + Cost(i ^ j ^ c, cur + 0, cur + 2));
    chmax(dp[c][cur + 2], dp[i][j] + Cost(i ^ j ^ c, cur + 0, cur + 1));
  }
}
 
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
 
  cin >> N;
  for (int i = 1; i <= 3 * N; i++) {
    cin >> A[i];
  }
 
  while (true) {
    bool change = false;
    for (int i = 3; i + 2 <= 3 * N; i += 3) {
      if (A[i] == A[i + 1] && A[i + 1] == A[i + 2]) {
        base += 1;
        for (int j = i + 3; j <= 3 * N; j++) {
          A[j - 3] = A[j];
        }
        N -= 1;
        change = true;
        break;
      }
    }
    if (!change) {
      break;
    }
  }
  
  vector<int> last(3 * N + 1, 3 * N + 1);
  for (int i = 3 * N; i > 0; i--) {
    nxt[i] = last[A[i]];
    last[A[i]] = i;
  }
  for (int i = 0; i < MAXN; i++) {
    for (int j = 0; j < MAXN; j++) {
      dp[i][j] = -INF;
    }
  }
  dp[1][2] = 0;
  for (int i = 1; i <= 3 * N; i++) {
    for (int j = i + 1; j <= 3 * N; j++) {
      Transition(i, j, (j + 3) / 3 * 3);
      // Find next occurrence of A[i]
      if (j / 3 * 3 < nxt[i] / 3 * 3) {
        Transition(i, j, nxt[i] / 3 * 3);
      }
      if (j / 3 * 3 < nxt[j] / 3 * 3) {
        Transition(i, j, nxt[j] / 3 * 3);
      }
    }
  }
 
  cout << ans + base << "\n";
  return 0;
}


Measured memory_bytes: 144604
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

    int h, w, m;
    cin>>h>>w>>m;
    vector<pair<int, int>> v;

    int r[h], c[w];
    memset(r, 0, sizeof(r));
    memset(c, 0, sizeof(c));

    while(m--){
        int i, j;
        cin>>i>>j;
        i--; j--;
        v.push_back({i, j});
        r[i]++;
        c[j]++;
    }

    int mr = 0, mc = 0;
    for (auto e:r){
        mr = max(mr, e);
    }
    for (auto e:c){
        mc = max(mc, e);
    }

    set<int> sr, sc;
    for (int i=0; i<h; i++){
        if (r[i]==mr) sr.insert(i);
    }
    for (int j=0; j<w; j++){
        if (c[j]==mc) sc.insert(j);
    }

    int cnt = sr.size()*sc.size();

    for (auto p:v){
        int i = p.first, j = p.second;
        if (sr.count(i) and sc.count(j)){
            cnt--;
        }
    }

    if (cnt>0){
        cout<<mr+mc<<endl;
    }
    else{
        cout<<mr+mc-1<<endl;
    }


    return 0;
}


/*

..#
###
.#.

*/


Measured memory_bytes: 40768
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

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

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int N, M, K, Q, W, H, R, C;
char table[110][110];
int dis[110][110];

int main() {
    cin >> H >> W;

    int black = 0;
    REP(y, H) {
        REP(x, W) {
            cin >> table[x][y];
            if (table[x][y] == '#') black++;
        }
    }

    queue<P> que;
    que.push({0, 0});

    REP(y, H) {
        REP(x, W) { dis[x][y] = INF; }
    }

    dis[0][0] = 1;
    while (!que.empty()) {
        P now = que.front();
        que.pop();
        int x = now.first;
        int y = now.second;
        vector<int> dx = {1, -1, 0, 0};
        vector<int> dy = {0, 0, 1, -1};
        REP(i, 4) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (0 <= nx && nx < W && 0 <= ny && ny < H && dis[nx][ny] == INF && table[nx][ny] != '#') {
                que.push({nx, ny});
                dis[nx][ny] = dis[x][y] + 1;
            }
        }
    }

    if (dis[W - 1][H - 1] == INF) {
        cout << -1 << endl;
    } else {
        cout << H * W - dis[W - 1][H - 1] - black << endl;
    }

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            List<int> lstInp = new List<int>();
            List<int> lstIn2 = new List<int>();
            sS = System.Console.ReadLine().Trim().Split(' ');
            for (int i = 0; i < sS.Length; i++)
            {
                lstInp.Add(int.Parse(sS[i]));
                lstIn2.Add(int.Parse(sS[i]));
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            lstIn2.Sort();
            string sOut = "YES";
            int iD = 0;
            for (int i = 0; i < lstInp.Count; i++)
            {
                if (lstInp[i] != lstIn2[i]) { iD += 1; }
                if (iD > 2) { sOut = "NO"; break; }
            }

            // 出力
            System.Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 13268
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = int(input())
    now = 1
    for i in range(1, N + 1):
        now *= i
        now %= (10 ** 9 + 7)
    print(now)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
#include<iostream>
 #include<stdio.h>
 #include<cstdlib>
 #include<cstdio>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 #include<deque>
 #include<functional>
 #include<utility>
 #include<list>
 
 using namespace std;
 
 /*
 int stringToint(const string S)
 {  
    int result=0;
    if(S[0]=='-')
    {
      for(int i=1;i<S.length();i++)
      {
        result=10*result+(S[i]-'0');        
      }             
      result=-result;
    }
    else
    {
      for(int i=0;i<S.length();i++)
      { 
        result=10*result+(S[i]-'0');      
      }
    }  
    return result;  
 }  
 */
 
 int main()
 {
   string s;
   string word;
   stack<double> mm;
   while(cin>>word)
   {
     if(word=="+"||word=="-"||word=="*"||word=="/")
       {
         double a=mm.top();
         mm.pop();
         double b=mm.top();
         mm.pop();
         double result;
         if(word=="+") result=b+a;
         else if(word=="-") result=b-a;
         else if(word=="*") result=b*a;
         else result=b/a;
         mm.push(result);     
       }   
       else if(word.length()>=2&&word[0]=='-'||(isdigit(word[0]))) 
       {
         //double kk=1.0*(stringToint(word));
         mm.push(atoi(word.c_str()));
         //mm.push(kk);                                                          
       }        
     if(getchar()=='\n')
     {    
       double final_result=mm.top();
       printf("%.10lf\n",final_result);
       mm.pop();
     }           
   }  
   //while(1);
   return 0;
 }

 
  

Measured memory_bytes: 3276
#include<bits/stdc++.h>
using namespace std;
double ans,x;
int n;
char t[10];

int main(){
	ans =0.00000000;
	scanf("%d",&n);
	while(n--){
		scanf("%lf %s",&x,&t);
		if(strcmp(t,"BTC")==0) x = x*380000.0;
		ans+=x;
	}
	printf("%.5lf\n",ans);
	return 0;
}

Measured memory_bytes: 256
# coding: utf-8
n = int(input())
al = sorted(list(int(i) for i in input().split()))
bl = sorted(list(int(i) for i in input().split()))
cl = sorted(list(int(i) for i in input().split()))
ans = 0

def low_left(a, key):
    left = -1
    right = len(a)
    while right - left > 1:
        center = (left + right) // 2
        if a[center] >= key:
            right = center
        else:
            left = center
    return left+1 
    
def high_right(a, key):
    left = -1
    right = len(a)
    while right - left > 1:
        center = (left + right) // 2
        if a[center] <= key:
            left = center
        else:
            right = center
    return n-right
    
for i in bl:
    ans += low_left(al, i) * high_right(cl, i)

print(ans)

Measured memory_bytes: 24264
N = int(input())

sxy41 = []
sxy23 = []

for i in range(N):
    
    x,y = map(int,input().split())

    if x == 0 and y >= 0:

        s = float("inf")

    elif x == 0 and y < 0:

        s = -1 * float("inf")

    else:

        s = y / x

    if x >= 0:
        sxy41.append([s,x,y])
    else:
        sxy23.append([s,x,y])

sxy41.sort()
sxy23.sort()

sxy = []

for i in sxy41:
    sxy.append(i)
for i in sxy23:
    sxy.append(i)

ans = 0


for i in range(N):

    for j in range(i):

        nowx = 0
        nowy = 0

        for k in range(i-j+1):

            k += j

            nowx += sxy[k][1]
            nowy += sxy[k][2]

        ans = max(ans,(nowx ** 2 + nowy ** 2) ** 0.5)


sxy = []

for i in sxy23:
    sxy.append(i)
for i in sxy41:
    sxy.append(i)


for i in range(N):

    for j in range(i+1):

        nowx = 0
        nowy = 0

        for k in range(i-j+1):

            k += j

            nowx += sxy[k][1]
            nowy += sxy[k][2]

        ans = max(ans,(nowx ** 2 + nowy ** 2) ** 0.5)

print (ans)

        


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

int main(){
  long n,c,k;
  cin >> n >> c >> k;
  long t[n];
  for(long i=0;i<n;i++)
    cin >> t[i];
  sort(t,t+n);
  long bus=0;
  for(long i=0;i<n;){
    long a = t[i];
    long j=i+1;
    while(t[j]<=a+k&&j<n)
      j++;
    i+=min(c,j-i);
    bus++;
  }
  cout << bus << endl;
}


Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
//#include<cstdio>
//#include<algorithm>
//#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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

	ll N, K;
	cin >> N >> K;

	ll A[60][50][50] = {};
	rep(i, N) rep(j, N) cin >> A[0][i][j];

	const ll mod = 1e9 + 7;
	rep(i, 59) {
		rep(j, N) {
			auto a = A[i + 1][j];
			rep(x, N) {
				auto b = A[i][x];
				rep(k, N) {
					a[k] += A[i][j][x] * b[k];
					a[k] %= mod;
				}
			}
		}
	}

	ll B[50];
	rep(i, N) B[i] = 1;
	rep(i, 60) {
		if (K >> i & 1) {
			ll C[50] = {};
			rep(j, N) {
				auto a = A[i][j];
				rep(k, N) {
					C[j] += a[k] * B[k];
					C[j] %= mod;
				}
			}
			rep(j, N) B[j] = C[j];
		}
	}

	ll kotae = 0;
	rep(i, N) kotae = (kotae + B[i]) % mod;
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  string S;cin>>S;cout<<S;if(S[S.size()-1]=='s')cout<<"e";cout<<"s"<<endl;
}


Measured memory_bytes: 3608
#include <stdio.h>
#define N 100
int main(void){
    int i,n;
    int a[N];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i=n-1;i>=0;i--){
        printf("%d",a[i]);
        if(i>0) printf(" ");
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2756
#include<stdio.h>
int main(void)
{
	int A=0,B=0,C=0,count=0,N,i;
	char s[51];
	scanf("%d ",&N);
	for(i=0;i<N;i++)
	scanf("%c",&s[i]);
	for(i=0;i<N-2;i++)
	{
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
		count++;
	}
	printf("%d",count);
	return 0;
}

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

int main() {
	int N;
	int s[100];
	int loop;
	int i, j;
	int d;
	int sum = 0;
	cin >> N;
	for (loop = 0; loop < N; loop++)cin >> s[loop];
	for (i = 0; i < N; i++)
		for (j = 1; j < N - i; j++)
			if (s[j - 1] > s[j]) {
				d = s[j - 1];
				s[j - 1] = s[j];
				s[j] = d;
			}
	for (loop = 0; loop < N; loop++)sum += s[loop];
	if (sum % 10 != 0) {
		cout << sum << "\n";
		return 0;
	}
	for (loop = 0; loop < N; loop++) 
		if (s[loop] % 10 != 0) {
			cout << sum - s[loop] << "\n";
			return 0;
		}
	cout << "0\n";
	return 0;
}

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

int main(){
    ll n,ans = 0;
    cin >> n;
    VLL p(n);
    rep(i,n)cin >> p[i];
    ll minp = p[0];

    rep(i,n){
        if(p[i] <= minp){
            ++ans;
            if(p[i] < minp)minp = p[i];
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1920
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;

int main() {
    int N, M;
    cin >> N >> M;
    int minimum = M;

    for (int i = 1; i < N; i++) {
        if (M % i == 0 && M / i >= N) minimum = min(minimum, M / i);
    }
    for (int i = N; i * i <= M; i++) {
        if (M % i == 0) {
            minimum = min(minimum, i);
            if (M / i >= N) {
                minimum = min(minimum, M / i);
            }

        }
    }
    cout << M / minimum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXL = 1e3+7;
char s1[MAXL];
char s2[MAXL];
int dp[MAXL][MAXL];
int maxLCS(char s1[], char s2[]){
    int l1 = strlen(s1);
    int l2 = strlen(s2);
    int i;
    for(i = 0; i <= l1; i++){
        dp[0][i] = 0;
    }
    for(i = 0; i <= l2; i++){
        dp[i][0] = 0;
    }
    int j;
    for(i = 1; i <= l2; i++){
        for(j = 1; j <= l1; j++){
            int max_k = max(dp[i-1][j], dp[i][j-1]);
            if(s1[j-1] == s2[i-1]) max_k = max(max_k, dp[i-1][j-1]+1);
            else max_k = max(max_k, dp[i-1][j-1]);
            dp[i][j]= max_k;
        }
    }
    return dp[l2][l1];
}
int main(){
//    freopen(".../in.txt", "r", stdin);
    int q;
    scanf("%d", &q);
    for(int i = 0; i < q; i++){
        scanf("%s", s1);
        scanf("%s", s2);
        int q = maxLCS(s1, s2);
        printf("%d\n", q);
    }
    return 0;
}




Measured memory_bytes: 7124
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	int r = 0;
	int b = 0;
	cin >> n;
	char* a = new char[100];
	cin >> a;
	for (int i = 0; i < n; i++) {
		if (a[i] == 'R') r++;
		if (a[i] == 'B') b++;
	}
	if (r > b) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;

}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

struct UnionFind
{
  vector<int> par;
  vector<int> siz;
  UnionFind(int N) : par(N), siz(N, 1) {for (int i = 0; i < N; i++) par[i] = i;}
  void init(int N) {
    siz.assign(N, 1);
    par.resize(N);
    for(int i = 0; i < N; ++i) par[i] = i;
  }
  int root(int x) {
    while(par[x] != x) {x = par[x] = par[par[x]];}
    return x;
  }
  bool unite(int x, int y)
  {
    x = root(x);
    y = root(y);
    if(x == y) return false;
    if(siz[x] < siz[y]) swap(x, y);
    siz[x] += siz[y];
    par[y] = x;
    return true;
  }
  bool isSame(int x, int y) {return root(x) == root(y); }
  int size(int x) { return siz[root(x)]; }
};

int main()
{
  int n, m;
  cin >> n >> m;
  UnionFind uf(n+1);
  rep(i, m) {
    int x, y, z;
    cin >> x >> y >> z;
    uf.unite(x, y);
  }
  int ans = 0;
  for(int i = 1; i <= n; ++i) if(uf.root(i) == i) ++ans;
  cout << ans << endl;
}

Measured memory_bytes: 4016
# coding: utf-8
ab = input().split()
a = int(ab[0])
b = int(ab[1])
hantei = 0
if a%2==0:
  hantei = 1
if b%2==0:
  hantei = 1
if hantei == 0:
  print("Odd")
else:
  print("Even")

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

ll N, K, S;
ll ans[int(1e5+5)];

int main(){
  cin >> N >> K >> S;
  for (int i = 0; i < K; i++) ans[i] = S;
  if (S == 1e9){
    for (int i = K; i < N; i++) ans[i] = 1e9 - 1;
  }else{
    for (int i = K; i < N; i++) ans[i] = 1e9;
  }

  cout << ans[0];
  for (int i = 1; i < N; i++) cout << " " << ans[i];
  cout << endl;

  return 0;
}


Measured memory_bytes: 4416
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    vector<int> w(n+1,0), s(n+1,0);
    for(int i=1; i<n+1; ++i){
        cin >> w[i];
        s[i] = s[i-1]+w[i];
    }

    int mn=1e9;
    for(int i=1; i<n; ++i){
        mn=min(mn,abs(s[n]-2*s[i]));
    }
    cout << mn << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
L = [0] * M
for i in range(N):
    for j in range(1, A[i][0] + 1):
        L[ A[i][j] -1 ] += 1
print(L.count(N))


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

ll modpow(ll x, ll n, ll p){
    if(n == 1) return x % p;
    if(n % 2 == 1) return (x * modpow(x, n-1, p)) * p;
    ll t = modpow(x, n/2, p);
    return (t * t) % p; 
}

int main() {
    string s;
    cin >> s;
    int count[2019];
    
    int n = (int)s.size();
    
    rep(i, 2019){
        count[i] = 0;
    }
    count[0] = 1;
    
    ll res = 0;
    
    int m = 1;
    int x = 0;
    rep(i, n){
        int k = s[n - 1 - i] - '0';
        x = (x + (m * k)) % 2019;
        // cout << x << endl; 
        res += count[x];
        ++count[x];
        m = (m * 10) % 2019;
    }
    
    cout << res << endl;
    return 0;
}

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

using namespace std;

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

	long double b,tmp;
	long long a;
	cin>>a>>b;
	tmp=a*b;
	long long ans=(long long)truncl(tmp);
	cout<<ans<<'\n';
}


Measured memory_bytes: 3748
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(a<b){
    	System.out.println("a < b");
    }else if(a>b){
    	System.out.println("a > b");
    }else{
    	System.out.println("a == b");
    }
    
  
  }
}

Measured memory_bytes: 25892
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
const long long LLINF = 1LL<<60;
const int INF = 1e9;
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; }
typedef long long ll;
#define pint pair<int,int>
using namespace std;

int main() {
    int a, b; cin >> a >> b;
    cout << 6 - a- b << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
int N,A,B,C,l[8];

int main(){
  int N;
  char s[100];
  cin>>N;
  for (int i(0);i<N;i++) cin>>s[i];
  for (int i(0);i<N;i++){
    if (s[i]=='Y') {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
  return 0;
}

Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//infinity
#define INTINF 2000000000
#define LONGINF 2000000000

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
	int N;
	cin >> N;
	vector<int> tmp;
	vector<int> v;

	int low = N / 2 - 1, high = N / 2;
	int lower, higher;

	REP(i, N){
		int x;
		cin >> x;
		tmp.push_back(x);
		v.push_back(x);
	}

	sort(tmp.begin(), tmp.end());
	lower = tmp[low];
	higher = tmp[high];

	REP(i, N){
		if(v[i] <= lower){
			cout << higher << endl;
		}else{
			cout << lower << endl;
		}
	}
	return 0;
}


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

bool sortbysec(const pair<long long,long long>&a,const pair<long long,long long> &b)
{
	return(a.second<b.second);
	//sort(s.begin(),s.end(),sortbysec);
	//s.push_back(make_pair(x,y));
}

int main()
{
	//vector<pair<long long,long long>> ve;
	long long n,w;
	cin>>n>>w;
	long long j,i,a[n+5],b[n+5];
	for(i=1;i<=n;i++)
		cin>>a[i]>>b[i];
	long long dp[n+1][w+1];
	for(i=0;i<w+1;i++)
		dp[0][i]=0;	
	for(i=1;i<=n;i++)
	{
		for(j=0;j<=w;j++)
		{
			dp[i][j]=dp[i-1][j];
			if(j-a[i]>=0)
				dp[i][j]=max(dp[i][j],b[i]+dp[i-1][j-a[i]]);
			   	
			//cout<<dp[i][j]<<" ";
		}
		//cout<<endl;
	}
	cout<<dp[n][w];
	return 0;
}

Measured memory_bytes: 79104