akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = 1<<29;
typedef long long int ll;

int main(){
    int N, M;cin >> N >> M;
    int L = 1, R = N;
    int ans = R - L + 1;
    rep(i, M){
        int l, r;cin >> l >> r;
        if(L < l){ans -= l - L;L = l;}
        if(r < R){ans -= R - r;R = r;}
    }
    cout << ((ans < 0) ? 0 : ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int main(){
	int a,b;cin>>a>>b;
	cout<<max(a+b,max(a,b)*2-1)<<endl;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

template<class T>
class SegmentTree {
    int n;
    vector<T> data;
    T def;
    function<T(T, T)> operation;
    function<T(T, T)> update;

    T _query(int a, int b, int k, int l, int r) {
        // 交差しない
        if (r <= a || b <= l) return def;
        // 区間 [a, b) に l, r が含まれる
        if (a <= l && r <= b) return data[k];
        // 左の子
        T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2);
        // 右の子
        T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r);
        return operation(c1, c2);
    }

public:
    /**
     * @param _n size
     * @param _def initial value
     * @param _operation operation for query
     * @param _update operation for update
     */
    SegmentTree(size_t _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update)
            : def(_def), operation(move(_operation)), update(move(_update)) {
        n = 1;
        while (n < _n) {
            n *= 2;
        }
        data = vector<T>(2 * n - 1, def);
    }

    /**
     * iの値をxに更新
     * @param i index ( 0-indexed )
     * @param x  value
     */
    void change(int i, T x) {
        i += n - 1;
        data[i] = update(data[i], x);
        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }

    /**
     * [a, b)の区間でクエリを実行
     */
    T query(int a, int b) {
        return _query(a, b, 0, 0, n);
    }

    /**
     * 添字でアクセス
     * @param i index ( 0-indexed )
     */
    T operator[](int i) {
        return data[i + n - 1];
    }
};

void Main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, pair<int, ll>>> items;
    SegmentTree<ll> segmentTree(N, INF, [](ll a, ll b) { return min(a, b); }, [](ll a, ll b){ return min(a, b); });
    rep(i, M) {
        int l, r;
        ll c;
        cin >> l >> r >> c;
        items.push_back({r, {l, c}});
    }
    sort(items.begin(), items.end());

    vector<ll> dp(N, INF);
    dp[0] = 0;
    segmentTree.change(0, 0);
    rep(i, M) {
        int r = items[i].first;
        int l = items[i].second.first;
        ll c = items[i].second.second;
        l--;
        r--;
        ll x = segmentTree.query(l, r + 1);
        ll tmp = x + c;
        dp[r] = min(dp[r], tmp);
        segmentTree.change(r, tmp);
    }
    if (dp[N - 1] != INF) {
        cout << dp[N - 1] << '\n';
    } else {
        cout << -1 << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

using namespace std ;

int main ( )
{
    int a , b ,c ;
    cin >> a >> b >> c ;
    if (( a + b + c ) >= 22 )
    {
        cout << "bust" << endl ;
    }
    else
        cout << "win" << endl ;
    return 0;
}


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

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


int main()
{
    int M;
    cin >> M;
    vector<long long> d(M), c(M);
    REP(i, M) cin >> d[i] >> c[i];

    long long D = accumulate(c.begin(), c.end(), (long long) 0);
    long long S = 0;
    REP(i, M) S += d[i]*c[i];

    cout << (D-1) + (S-1)/9 << endl; 

    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
vector<long long>g[200100];
bool ind[200107];
long long n,m,mx,ans;
void dfs(long long i){
    ind[i]=1;
    mx++;
    for(long long v:g[i]){
        if(ind[v]==0) dfs(v);
    }
}
int main()
{
   cin>>n>>m;
   long long x,y;
   for(long long i=0;i<m;i++){
       cin>>x>>y;
       g[x].push_back(y);
       g[y].push_back(x);
   }
   for(long long  i=1;i<=n;i++){
       if(ind[i]==0){
           mx=0;
           dfs(i);
           ans=max(mx,ans);
       }
   }
   cout<<ans;
}

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

const int N = 200001;
bool visited[N];
vector<int> adj[N];
vector<int> topo;
int dp[N];
int n, m;

void dfs(int v) {
    visited[v] = true;
    for (auto nx : adj[v]) {
        if (!visited[nx]) {
            dfs(nx);
        }
    }
    topo.push_back(v);
}

int solve(int v) {
    if (adj[v].size() == 0) {
        return 0;
    }
    int& ans = dp[v];
    if (ans != -1) {
        return ans;
    }
    ans = 0;
    for (auto nx : adj[v]) {
        ans = max(ans, solve(nx) + 1);
    }
    return ans;
}

int main() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
    }
    for (int i = 1; i <= n; i++) {
        if (!visited[i]) {
            dfs(i);
        }
    }
    reverse(topo.begin(), topo.end());
    memset(dp, -1, sizeof dp);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans = max(ans, solve(i));
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 11512
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result


N = int(input())
S = [input() for _ in range(N)]

d = {}
for s in S:
    s = "".join(sorted(s))
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
ans = 0
for v in d.values():
    if v > 1:
        ans += cmb(v, 2)
print(ans)        

Measured memory_bytes: 24980
#include<bits/stdc++.h>
using namespace std;
  
int main(){
  int N;
  cin >> N;
  vector<int> L(2*N);
  for(int i=0;i<2*N;i++){
    cin >> L.at(i);
  }
  long long sum=0;
  sort(L.begin(),L.end());
  for(int i=0;i<2*N;i+=2){
    sum+=L.at(i);
  }
  cout << sum << endl;
}
    

Measured memory_bytes: 3636
x, y = map(int, input().split())

a, b, c = (4, 6, 9, 11), (1, 3, 5, 7, 8, 10, 12), (2)

if x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")
elif x == 2 and y == 2:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,K;
  cin>>N>>K;
  
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin>>vec.at(i);
  }
  
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());

  int sum=0;
  for(int i=0;i<K;i++){
    sum+=vec.at(i);
  }
  
  cout<<sum<<endl;
}

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

#define ll long long
const int inf = 1e9+7;
const ll INF = 1e18+7;

using namespace std;

string s,t;
void rotate(){
  char tmp = s[0];
  s = s.substr(1,s.size()-1);
  s += tmp;
}

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

  cin >>s>>t;
  int n = s.size();
  for(int i = 0; i < n;++i){
    if(s == t){
      cout<<"Yes\n";
      return 0;
    }
    rotate();
  }
  cout<<"No\n";
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int P=1e9+7,MAXN=100010;
int dp[MAXN][14];
char s[MAXN];
int main () {
	scanf("%s",s+1);
	int n=strlen(s+1); 
	dp[0][0]=1;
	for (int i=1;i<=n;i++) {
		if (s[i]!='?') {
			for (int j=0;j<=12;j++) {
				dp[i][j]=dp[i-1][((13+j-s[i]+'0')*4)%13];
			}
		} else {
			for (int j=0;j<=12;j++) {
				for (int k=0;k<=9;k++) {
					dp[i][j]=(dp[i][j]+dp[i-1][((13+j-k)*4)%13])%P;
				}
			}
		}
	}
	printf("%d\n",dp[n][5]);
}

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

int main () {
  int n;
  string s;
  cin >> n >> s;
  long long ans = 0;
  long long r = 0, g = 0, b = 0;
  
  for(char c : s) {
    if (c == 'R') r++;
    if (c == 'G') g++;
    if (c == 'B') b++;
  }
  ans = r * g * b;
  
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n ; ++j) {
      if (i - j < 0 || i + j >= n) continue;
      if (s[i] != s[i+j] && s[i] != s[i-j] && s[i+j] != s[i-j]) ans--;
    }
  }
  cout << ans <<endl;
}
      


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i,n) for(long long i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  long long n,m;
  cin>>n>>m;
  long long x[n],y[m];
  REP(i,n){
    cin>>x[i];
  }
  REP(i,m){
    cin>>y[i];
  }
  
  long long X=0,Y=0;
  REP(i,n){
    X = mod(X + mod((2*i-n+1)*x[i]));
  }
  REP(i,m){
    Y = mod(Y + mod((2*i-m+1)*y[i]));
  }
  
  long long ans;
  ans = mod(X*Y);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
/*

Coded by peyha X

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int NMAX = 1e3 + 1, KMAX = 3;

string n;
int k, m, compteurs[NMAX][KMAX], ans = 0;

int ncr(int k, int n)
{
	
	int ans = 1;
	for(int i = 0; i < k; i++)
	{
		ans *= (n - i);
	}
	for(int i = 0; i < k; i++)
	{
		ans /= (i + 1);
	}
	return ans;
}

int exp(int x,int n)
{
	if(n == 0)
		return 1;
	return x * exp(x, n - 1);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> n >> k;
	
	m = n.size();
	
	//en mettant un 0 au debut
	//ans += ncr(k, m - 1);
	
	int non_zero = 0;
	for(int index = 0; index < m; index++)
	{
		//on a gardé les index - 1 premiers chiffres et on regarde ce qu'on peut mettre
		if(n[index] != '0')
		{
			non_zero ++;
			int digit = n[index] - '0', restant = m - index - 1, digit_restant = k - non_zero;
			//cout << digit << ' ' << restant << ' ' << digit_restant << '\n';
			
			ans += exp(9, digit_restant + 1) * ncr(digit_restant + 1, restant) + (digit - 1) * exp(9, digit_restant) * ncr(digit_restant, restant);
		} 
		
		if(non_zero == k)
		{
			ans ++;
			break;
		}
		
	}
	
	cout << ans << '\n';
	
	
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  
  
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt(),m=sc.nextInt();
    int[] p = new int[m];
    String[] q = new String[m];
    
    for(int i = 0;i<m;i++){
      p[i] = sc.nextInt();
      q[i] = sc.next();
    }
    
    int[] ac = new int[100000];
    int[] wc = new int[100000];
    for(int i =0;i<100000;i++){
      ac[i]=0;
      wc[i]=0;
    }
    
    for(int i = 0;i<m;i++){
    	if(q[i].equals("AC")){
          ac[p[i]] = 1;
        }else if(ac[p[i]]!=1){
          wc[p[i]] += 1;
        }
    }
    int acsum = 0,wcsum = 0;
    for(int i =0;i<100000;i++){
      if(wc[i]!=0&&ac[i]==0){
        wc[i] = 0;
      }
    }
    
    for(int i =0;i<100000;i++){
      acsum += ac[i];
      wcsum += wc[i];
    }
    
    System.out.println(acsum +" "+wcsum);
    
  }
}


Measured memory_bytes: 70452
#include <iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<set>
#define MAXN 1002

using namespace std;

int main()
{

    int A,B,C,X,Y;
    scanf("%d%d%d%d%d",&A,&B,&C,&X,&Y);
    int sum=0;
    if(X>Y){
        if((A+B)>=2*C){
            sum+=2*C*Y;
            X=X-Y;
        }else{
            sum+=(A+B)*Y;
            X=X-Y;
        }
        if(A>=2*C){
            sum+=2*C*X;
        }else
            sum+=A*X;
    }else{
        if((A+B)>=2*C){
            sum+=2*C*X;
            Y=Y-X;
        }else{
            sum+=(A+B)*X;
            Y=Y-X;
        }
        if(B>=2*C){
            sum+=2*C*Y;
        }else
            sum+=B*Y;
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)(x).size())
#define mset(a,v) memset(a,v,sizeof(a))
#define mcpy(a,b) memcpy(a,b,sizeof(a))
#define MOD 998244353
using namespace std;
typedef long long ll;

ll pm(ll a, ll e){
	ll r=1;
	while(e){
		if(e&1)r=r*a%MOD;
		e>>=1;
		a=a*a%MOD;
	}
	return r;
}

ll f[300005];

ll c(int n, ll k){
	if(k<0||k>n)return 0;
	return f[n]*pm(f[k],MOD-2)%MOD*pm(f[n-k],MOD-2)%MOD;
}

int main(){
	f[0]=1;
	fore(i,1,300005)f[i]=f[i-1]*i%MOD;
	int n;ll a,b,k;
	scanf("%d%lld%lld%lld",&n,&a,&b,&k);
	ll r=0;
	fore(i,0,n+1){
		ll t=k-a*i;
		if(t<0)break;
		if(t%b)continue;
		r+=c(n,i)*c(n,t/b)%MOD;
		r%=MOD;
	}
	printf("%lld\n",r);
	return 0;
}

Measured memory_bytes: 2560
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let s = read::<String>().chars().collect::<Vec<_>>();
    let mut ans = 0;
    let mut s_cnt = 0;
    for ch in s {
        if ch == 'T' {
            if s_cnt == 0 {
                ans += 1;
            } else {
                s_cnt -= 1;
            }
        } else {
            s_cnt += 1;
        }
    }
    println!("{}", ans * 2);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

const double PI = acos(-1);
 
int main() {

    double a,b,x;

    cin>>a>>b>>x;

    double ans;

    if(x<a*a*b/2)   ans=atan(a*b*b/x/2)*180/PI;
    else            ans=atan(2*(b/a-x/(a*a*a)))*180/PI;

    printf("%.9f",ans);
  
 return 0;
}

Measured memory_bytes: 512
#include<set>
#include<cstdio>
using namespace std;

const int dir[10][2]={{0,0},{0,-1},{0,-2},{-1,0},{-1,-1},{-1,-2},{-2,0},{-2,-1},{-2,-2}};
#define MAXN 100000
int H,W,N;
long long Ans[10];
int A[MAXN+5],B[MAXN+5];
set<pair<int,int> > S1,S2;

int main(){
    scanf("%d%d%d",&H,&W,&N);
    for(int i=1;i<=N;i++){
        scanf("%d%d",&A[i],&B[i]);
        S1.insert(make_pair(A[i],B[i]));
    }
    for(int i=1;i<=N;i++){
        for(int j=0;j<9;j++){
            int x=A[i]+dir[j][0],y=B[i]+dir[j][1],cnt=0;
            if(x<1||x+2>H||y<1||y+2>W)
                continue;
            if(S2.count(make_pair(x,y)))
                continue;
            S2.insert(make_pair(x,y));
            for(int k=0;k<9;k++)
                cnt+=S1.count(make_pair(x-dir[k][0],y-dir[k][1]));
            Ans[cnt]++;
        }
    }
    long long tot=0;
    for(int i=1;i<=9;i++)
        tot+=Ans[i];
    printf("%lld",(H-2ll)*(W-2ll)-tot);
    for(int i=1;i<=9;i++)
        printf("\n%lld",Ans[i]);
}


Measured memory_bytes: 47872
#include <stdio.h>
int main(void){
    int N, A, B, q = 0, q1 = 0, q2 = 0, q3 = 0;
    int P[100] = {};
    int i;
    
    scanf("%d", &N);
    scanf("%d %d", &A, &B );
    for( i=0 ; i<N ; i++ ) scanf("%d", &P[i]);
    
    for( i=0 ; i<N ; i++ ){
        
        if(P[i] <= A) q1++;
        
    }
    for( i=0 ; i<N ; i++ ){
        
        if(P[i] >= A+1 && P[i] <= B) q2++;
        
    }
    
    for( i=0 ; i<N ; i++ ){
        
        if(P[i] >= B+1) q3++;
        
    }
    
    q = 0;
    if( q1 < q2 ){
        q = q1;
    }else{
        q = q2;
    } 
    if(q > q3) q = q3;
    
    printf("%d",q);
    
    return(0);
    
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define ALL(C) (C).begin(),(C).end()
#define INPUT(P) std::cin>>(P)
#define INPUT2(P1,P2) std::cin>>(P1)>>(P2)
#define INPUT3(P1,P2,P3) std::cin>>(P1)>>(P2)>>(P3)
#define INPUTS(I,N,V) REP(I,N) std::cin>>V[I]
#define OUTPUT(P) std::cout<<P<<std::endl
#define OUTPUT2(P1,P2) std::cout<<P1<<" "<<P2<<std::endl
#define OUTPUT3(P1,P2,P3) std::cout<<P1<<" "<<P2<<" "<<P3<<std::endl
#define OUTPUTS(I,N,V) REP(I,N) std::cout<<V[i]<<std::endl
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using namespace std;
int i,j,k;
int N;
int a[3000];
int A;
inline void solve(){
  INPUT(N);
  INPUTS(i,N,a);
  REP(i,N)A+=(a[i]-1);
  OUTPUT(A);
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}

/********************************************************/
//	d.erase(unique(all(d)), d.end());
vector<ll> g[100005];
ll k;

ll dfs(ll x,ll p,ll y)
{
	ll c=1,q=k,z=g[x].size();
	q=k-y;
	for(auto n:g[x]) if(n!=p)
	{
		c=(c*dfs(n,x,z))%mod;
		z--;
	}
	// q-=(p>0);
	// q-=(pp>0);
	// debug3(x,p,q);
	// debug3(x,y,g[p].size());
	return q<0?0:(q*c)%mod;
}


int main()
{
	IOS;
	ll n,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		// reverse(a.begin(),a.end());
		cin>>n>>k;
		// n=s.length();
		// ll a[n];
		rep(i,n-1)
		{
			cin>>j>>m;
			g[j].pb(m);
			g[m].pb(j);
		}
		c=dfs(1,0,0);
		
		cout<<c;
		
		if(t!=0)
	   		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 11648
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
using namespace std;
typedef long long ll;

int main() {
	ll N, K;
	cin >> N >> K;

	vector<ll> l(N);
	for (ll i = 0; i < N; i++)
	{
		cin >> l[i];
	}

	sort(l.begin(), l.end());
	ll ans = 0;
	for (auto i = l.end()-1; i >= l.end() - K; i--)
	{
		ans += *i;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include<iomanip>
//#include<bits/stdc++.h>


using namespace std;

int main(){
	int a;
	cin>>a;
	int g[255]={};
	for(int i=0;i<a*2;i++)
		cin>>g[i];
	sort(g,g+2*a);
	int x=0;
	for(int i=0;i<2*a;i+=2){
		x+=g[i];
	}
	cout<<x<<endl;
	return 0;
}



Measured memory_bytes: 256
n, k = map(int, input().split())
h = []
for i in range(n):
    h.append(int(input()))
h.sort(reverse = True)
ans = 10000000000
maxh = h[:k]
maxn = 0
for i in range(k, n):
    if ans > maxh[maxn] - maxh[(maxn-1)%k]:
        ans = maxh[maxn] - maxh[(maxn-1)%k]
    maxh[maxn] = h[i]
    maxn = (maxn+1) % k
if ans > maxh[maxn] - maxh[(maxn-1)%k]:
    ans = maxh[maxn] - maxh[(maxn-1)%k]
print(ans)


Measured memory_bytes: 7836
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <queue>

using namespace std;
typedef long long ll;

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

int main() {

    string b;
    cin >> b;
    string out = "";
    if(b=="A") out = "T";
    else if(b=="T") out = "A";
    else if(b=="C") out = "G";
    else if(b=="G") out = "C";
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    int a[200000], b[200000];
    char op[200000];
    int i = 0;
    while(true) {
        cin >> a[i] >> op[i] >> b[i];
        if(op[i] == '?') break;
        i++;
    }

    for(int j = 0; j < i; j++) {
        switch(op[j]) {
            case '+':
                cout << a[j] + b[j] << endl;
            break;
            case '-':
                cout << a[j] - b[j] << endl;
            break;
            case '*':
                cout << a[j] * b[j] << endl;
            break;
            case '/':
                cout << a[j] / b[j] << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 3120
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int k=sc.nextInt();
		int s=sc.nextInt();

		int c=0;
		for(int x=0;x<=k;x++) {
			for(int y=0;y<=k;y++) {
				if(x+y==s) {
					c++;
				}else if(s-(x+y)<=k&&x+y<s) {
					c++;
				}


			}
		}
		System.out.println(c);

	}

}

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

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

ll mpow(ll a,ll b){
    ll res=1;
    //a%=mod;
    while(b){
    	if(b%2) res=res*a; //%mod;
		a=a*a; //%mod;
		b/=2;
	}
	return res;
}

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

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

void solve(){
	//code
	int a,b;
	cin>>a>>b;
	if(a>2*b){
		cout<<a-2*b;
	}
	else cout<<0;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	solve();
 	return 0;
}


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

using namespace std;

int main(void) {
    int n;

    cin >> n;

    vector<vector<int>> mat(n, vector<int>(3, 0));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> mat[i][j];
        }
    }

    vector<vector<int>> dp(n, vector<int>(3, -1));
    
    dp[0][0] = mat[0][0];
    dp[0][1] = mat[0][1];
    dp[0][2] = mat[0][2];

    for (int i = 1; i < n; i++) {
        for (int j = 0; j < 3; j++) {
            for (int k = 0; k < 3; k++) {
                if (j != k) {
                    dp[i][j] = max(dp[i - 1][k] + mat[i][j], dp[i][j]);
                }
            }
        }
    }

    int ans = 0;
    for (int j = 0; j < 3; j++) {
        ans = max(ans, dp[n - 1][j]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

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

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001;

int n;
vi p;
map<int,int> st;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n; p.resize(n);
    F0R(i,n) {
        cin >> p[i];
        if (st.count(p[i]-1)) {
            st[p[i]] = st[p[i]-1]+1;
            st.erase(p[i]-1);
        } else st[p[i]] = 1;
    }
    int ans = n;
    for (auto a: st) ans = min(ans,n-a.s);
    cout << ans;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)

Measured memory_bytes: 10496
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"

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

	int n,m;
	cin>>n>>m;
	vi in(n);
	rep(i,n)cin>>in[i];
	vvi dp(n,vi(n));
	rep(i,n)rep(j,n)if(in[i]>in[j])dp[i][j]=1;
	int MOD=1000000007;
	rep(q,m){
		int a,b;
		cin>>a>>b;
		a--;b--;
		rep(i,n)if(i!=a&&i!=b){
			dp[i][a]=dp[i][b]=(dp[i][a]+dp[i][b])*((MOD+1)/2)%MOD;
			dp[a][i]=dp[b][i]=(dp[a][i]+dp[b][i])*((MOD+1)/2)%MOD;
		}
		dp[a][b]=dp[b][a]=(dp[a][b]+dp[b][a])*((MOD+1)/2)%MOD;
	}
	int out=0;
	rep(i,n)loop(j,i+1,n)(out+=dp[i][j])%=MOD;
	rep(i,m)(out*=2)%=MOD;
	cout<<out<<endl;
}






Measured memory_bytes: 72844
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
ll q[31];
ll r[31];
int main() {
  int n;
  string s;
  cin >> n >> s;
  int cnt = 0;
  rep(i,n) if(s[i] == 'R') cnt++;
  int d = n / 2;
  if(d < cnt) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# 整数の入力
lis = list(map(int,input().split()))
lists = []
inc = 0
# スペース区切りの整数の入力
for i in range(2):
    for j in range(2):
        lists.append(lis[i]*lis[j+2])
        inc += 1

    
# 出力
print("{}".format(max(lists)))

Measured memory_bytes: 9164
#include<iostream>
#include<cstdio>
#include<cctype>
#include<cstring>
using namespace std;

const int dataset_MAX = 1201,num_MAX=1001;
int sum[dataset_MAX];


int main(){
	int dataset = 0;
	for (;;dataset++){
		char num[num_MAX];
		sum[dataset] = 0;
		cin >> num;
		int i = 0;
		for (;i<(unsigned int)strlen(num); i++){
			sum[dataset] += num[i] - '0';
		}
		if (num[0] == '0')break;
	}
	for (int i = 0; i < dataset; i++){
		cout << sum[i] << endl;
	}
	return 0;
}


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

using namespace std;
#define int long long
#define endl '\n'

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t; cin >> t;
    for (; t; t--) {
        int n; cin >> n;
        vector<int> k(n), l(n), r(n);
        vector<pair<int, int>> vl(n);
        for (int i = 0; i < n; i++) {
            cin >> k[i] >> l[i] >> r[i];
            k[i]--;
            vl[i] = {(l[i] - r[i]), i};
        }
        sort(vl.rbegin(), vl.rend());
        int ans = 0;
        set<int> q;
        for (int i = 0; i < n; i++) q.insert(i);
        for (int i = 0; i < n; i++) {
            if (vl[i].first <= 0) break;
            int id = vl[i].second;
            auto t = q.upper_bound(k[id]);
            if (t == q.begin()) {
                ans += r[id];
            }
            else {
                ans += l[id];
                t--;
                q.erase(t);
            }
        }
        for (int i = 0; i < n; i++) q.insert(i);
        for (int i = n - 1; i >= 0; i--) {
            if (vl[i].first > 0) break;
            int id = vl[i].second;
            auto t = q.upper_bound(k[id]);
            if (t == q.end()) ans += l[id];
            else {
                ans += r[id];
                q.erase(t);
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 20336
#include<stdio.h>

int main(){
int S,i,j,k;
int a,b;
a = b = 0;
scanf("%d",&S);
      
for(i=1;i<=S;i++){
  b = 0;
  for(j=1;j<=i;j++){
    if((i%j) == 0){
      b++;
    }
  }
  if(b == 8 && i%2 ==1)
    a++;
}

printf("%d\n",a);

return 0;
}

Measured memory_bytes: 128
from collections import deque

s = input()
q = int(input())

que = deque(s)
rev = 1
for qi in range(q):
    tmp = input()
    if tmp[0] == '1':
        rev *= -1
    if tmp[0] == '2':
        _, f, c = tmp.split()
        fi = 2 * (int(f) - 1) - 1
        if fi * rev == 1:
            que.append(c)
        else:
            que.appendleft(c)
lque = list(que)

if rev == 1:
    print(''.join(map(str, lque)))
    exit()

ans = ''
for i in range(len(lque)):
    ans += lque.pop()
print(ans)




Measured memory_bytes: 10992
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rrep(i,a,b) for(int i=(a);i>=(b);--i)
#define PB push_back
#define ar2 array<int,2> 
typedef long long LL;
const int P = 998244353;
const int N = 2e5, M = 1e6;
const double pi = acos(-1);
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

LL n,a[N+5],sum[M+5],sum2[M+5];
int cnt[M+5];
vector<int> fac[M+5];

LL pw(LL x,int n){
	LL res = 1;
	for(;n;n>>=1,x=x*x%P)if(n&1)res=res*x%P;
	return res;
}
void add(LL &x,LL y){x+=y;if(x>=P)x-=P;}
void sub(LL &x,LL y){x-=y;if(x<0)x+=P;}

int main() {
	ios_base::sync_with_stdio(false);cin.tie(0);
	cin>>n;
	rep(i,1,n)cin>>a[i];
	rep(i,1,M)for(int j=i+i;j<=M;j+=i)fac[j].push_back(i);
	rep(i,1,n){
		for(auto x:fac[a[i]]) add(sum[x],a[i]), add(sum2[x],a[i]*a[i]%P), ++cnt[x];
		add(sum[a[i]],a[i]), add(sum2[a[i]],a[i]*a[i]%P), ++cnt[a[i]];
	}
	LL ans = 0, inv2 = pw(2,P-2);
	rrep(i,M,1)if(cnt[i]){
		LL x = sum[i], y = sum2[i];
		x = x*x%P, sub(x,y), x = x*inv2%P;
		sum2[i] = x;
	}
	rrep(i,M,1)if(cnt[i]){
		add(ans,sum2[i]*pw(i,P-2)%P);
		for(auto x:fac[i]) sub(sum2[x],sum2[i]);
		//cout<<i<<" "<<sum2[i]<<" "<<cnt[i]<<endl;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 135936
#include <stdio.h>

int main(void)
{
	int n;
	float height;
	int cnt[6] = {0};
	int i, j;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%f", &height);
		
		if (height < 165.0){
			cnt[0]++;
		}
		else if (height < 170.0){
			cnt[1]++;
		}
		else if (height < 175.0){
			cnt[2]++;
		}
		else if (height < 180.0){
			cnt[3]++;
		}
		else if (height < 185.0){
			cnt[4]++;
		}
		else {
			cnt[5]++;
		}
	}
	for (j = 0; j < 6; j++){
		printf("%d:", j + 1);
		while (cnt[j] != 0){
			printf("*");
			cnt[j]--;
		}
		printf("\n");
	}
	
	return (0);
}

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

int main()
{
	int n;
	cin>>n;
	double a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=0;i<n-1;i++)
	{
		a[i+1]=(double)(a[i+1]+a[i])/2;
	}
	cout<<a[n-1]<<endl;
	return 0;
}

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

#define mem(t, v)   memset ((t) , v, sizeof(t))
#define all(x)      x.begin(),x.end()
#define un(x)       x.erase(unique(all(x)), x.end())
#define sf(n)       scanf("%d", &n)
#define sff(a,b)    scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sl(n)       scanf("%lld", &n)
#define sll(a,b)    scanf("%lld %lld", &a, &b)
#define slll(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define D(x)        cerr << #x " = " << (x) << '\n'
#define DBG         cerr << "Hi" << '\n'
#define pb          push_back
#define PI          acos(-1.00)
#define xx          first
#define yy          second
#define eps         1e-9

typedef unsigned long long int ULL;
typedef long long int LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;


inline int setBit(int N, int pos) { return N=N | (1<<pos); }
inline int resetBit(int N, int pos) { return N= N & ~(1<<pos); }
inline bool checkBit(int N, int pos) { return (bool)(N & (1<<pos)); }

//int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
//int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1}; //Four & Eight Direction
int A, B, C, D, E, F;
int vis[3010][3010];
void dfs(int sugar, int water)
{
    if(sugar + water > F)
        return;
    if(vis[sugar][water])
        return;
    vis[sugar][water] = true;
    int a = sugar, b = water + 100*A;
    dfs(a,b);
    a = sugar, b = water + 100*B;
    dfs(a,b);
    a = sugar + C, b = water;
    dfs(a,b);
    a = sugar + D, b = water;
    dfs(a, b);
}
int main()
{
//    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    sfff(A,B,C);
    sfff(D,E,F);
    dfs(0,0);
    double ans = 0;
    pii sltn = {0,0};
    for(int i = 0; i<=F; i++)
    {
        for(int j = 0; j<=F; j++)
        {
            if(vis[i][j] && (100*i) <= j * E)
            {
                double density = ((double)i)/(i+j);
                if((i*sltn.xx) >= (sltn.yy*(i+j)) )
                    sltn = {i+j,i};
            }
        }
    }
    cout << sltn.xx << " " << sltn.yy << endl;
    return 0;
}




Measured memory_bytes: 33792
#include <bits/stdc++.h>
#define MP make_pair
using namespace std;
typedef long long LL;
const LL N = 100010;
inline LL read()
{
  char ch=getchar(); LL p=0; LL f=1;
  while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();}
  while(ch>='0' && ch<='9'){p=p*10+(ch-'0'); ch=getchar();}
  return p*f;
}

map<char,bool>mp; LL co[N];

int main()
{

  LL n=read(); mp.clear(); 
  
  for(int i=1;i<=n;i++){char ch; scanf("\n%c",&ch); if(mp[ch]==0) mp[ch]=1;}

  // printf("%d\n",mp.size());

  if(mp.size()==3) printf("Three\n");
  else printf("Four\n");

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a , b,c,d;
  cin >> a >> b ;
  
  c = a * b;
  d = c % 2;
  
  if(d == 0){
    cout << "Even"<< endl;
  }else{
    cout << "Odd" << endl;
  }
}

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

int main() {
  int n;
  cin >>n;
  double a,b;
  b =0;
  for(int i=0 ; i<n ; i++){
    cin >>a;
    b = b + 1/a;
  }
  cout <<1/b <<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 100000

int parent(int);
int left(int);
int right(int);

int main(){
  int i,num,H[MAX+1];

  scanf("%d",&num);
  for(i=1;i<=num;i++)
    scanf("%d",&H[i]);

  for(i=1;i<=num;i++){
    printf("node %d: key = %d, ",i,H[i]);
    if(parent(i) >= 1)printf("parent key = %d, ",H[parent(i)]);
    if(left(i) <= num)printf("left key = %d, ",H[left(i)]);
    if(right(i) <= num)printf("right key = %d, ",H[right(i)]);
    printf("\n");
  }

  return 0;
}

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
} 



Measured memory_bytes: 2044
n,t = map(int,input().split())

a = []
for i in range(n):
    c,tt = map(int,input().split())
    if tt <= t :
        a.append([c,tt])

if len(a) > 0 :
    a.sort(key=lambda x : x[0])
    print(a[0][0])
else :
    print("TLE")




Measured memory_bytes: 3316
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
double pi = 3.141592653589793;
using namespace std;
//ここから始めよう
int dp[2][114];
int a[2][114];
int solve(int i,int j){
    if(dp[i][j])return dp[i][j];
    else if(i==0)dp[i][j]=solve(i,j-1)+a[i][j];
    else if(j==0)dp[i][j]=solve(i-1,j)+a[i][j];
    else dp[i][j]=max(solve(i-1,j),solve(i,j-1))+a[i][j];
    return dp[i][j];
}
signed main(){
    int n;cin>>n;
    rep(i,0,2){
        rep(j,0,n){
            cin>>a[i][j];
        }
    }
    dp[0][0]=a[0][0];
    cout<<solve(1,n-1)<<endl;
    return 0;
}

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

	static int[] pos=new int[8];
	static boolean[] row=new boolean[8],
			rup=new boolean[15],
			rdown=new boolean[15];
	static boolean[][] def=new boolean[8][8];

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();

		for(int i=0;i<n;i++) {
			int r=Integer.parseInt(in.next()),c=Integer.parseInt(in.next());
			def[c][r]=true;
			row[r]=true;
			rup[c+r]=true;
			rdown[c-r+7]=true;
		}
		set(0);
	}

	static void set(int i) {
		for(int j=0;j<8;j++) {
			if(!row[j] && !rup[i+j] && !rdown[i-j+7]) {
				pos[i]=j;

				if(i==7) {
					print();
				}
				else {
					row[j]=rup[i+j]=rdown[i-j+7]=true;
					set(i+1);
					row[j]=rup[i+j]=rdown[i-j+7]=false;
				}
			}
			else if(def[i][j]){
				pos[i]=j;
				if(i==7)print();
				else set(i+1);
			}
		}
	}

	static void print() {
		for(int i=0;i<8;i++) {
			for(int j=0;j<8;j++)System.out.print((pos[j]==i)? "Q":".");
			System.out.println();
		}
	}

}



Measured memory_bytes: 26328
package main

import (
	"fmt"
)

func main() {
	ct := 0
	length := 0
	for i := 0; i < 3; i++ {
		var tmp int
		fmt.Scan(&tmp)
		if tmp == 5 || tmp == 7 {
			ct++
		}
		length += tmp
	}
	if ct == 3 && length == 17 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


Measured memory_bytes: 1768
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
int lcm(int a, int b){
  return a / gcd(a,b) * b;
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

int dp[3005][3005]; //[n][t];

int main(){
  int n,t; cin >> n >> t;
  vector<pair<int,int>> f(n);
  rep(i,n){
    cin >> f[i].first >> f[i].second;
  }
  sort(f.begin(),f.end());
  int ans = 0;
  rep(i,n){
    rep(j,t){
      //i個目を食べない時
      chmax(dp[i+1][j],dp[i][j]);
      //i個目を食べる時(t-1を超える場合はアウト)
      if(j+f[i].first < t) chmax(dp[i+1][j+f[i].first], dp[i][j]+f[i].second);
      //printf("i=%d,j=%d,dp=%d\n",i,j,dp[i+1][j+f[i].first]);
    }
    int tmp = dp[i][t-1] + f[i].second; //i個目のものを最後に食べるケース
    chmax(ans,tmp);
  }
  /*
  rep(i,n){
    cout << endl;
    rep(j,t){
      cout << dp[i][j] << " ";
    }
    cout << "||";
  }
  */
  cout << ans << endl;

  
  return 0;
}

Measured memory_bytes: 35456
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<stdlib.h>
//#include<string.h>
//#include<algorithm>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define READ freopen("in.txt","r",stdin)
#define WRITE freopen("out.txt","w",stdout);
#define pb push_back
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define sf(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sl2(x,y) scanf("%lld %lld",&x,&y)

#define sl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sd(x) scanf("%lf",&x);
#define pLL pair<long long,long long>
#define pDB pair<double,double>
#define ff first
#define sn second
#define PRINT_CASE  printf("Case %d: ",tc++)
#define PRINT_CASENL  printf("Case %d:\n",tc++)
//#define mx 100005
#define lnd tree[ind<<1]
#define rnd tree[(ind<<1)+1]
#define cnd tree[ind]
#define lndp b,(b+e)>>1,(ind<<1)
#define rndp ((b+e)>>1)+1,e,(ind<<1)+1
#define IN(a,x,y) (a>=x && a<=y)
#define popcountL __builtin_popcountll
#define popcount __builtin_popcount
/// int other=mask^((1<<n)-1);
typedef long long ll;
typedef long long int lln;
typedef pair<int,int> pii;
ll INF=1<<28;
//typedef long long lld;
const double PI=acos(-1.0);
//int fx[]={1,-1,0,0}; //direction array
//int fy[]={0,0,1,-1};
int dir[4][2]={1,0,-1,0,0,-1,0,1};
int knight[8][2]={1,2,1,-2,2,1,2,-1,-1,2,-1,-2,-2,1,-2,-1};
const long double EPS=1e-7;
//#define INF 10000

struct compare
{
  bool operator()(const pair<int,pii>& l, const pair<int,pii>& r)
  {
      if(l.ff==r.ff)
      {
          return l.sn.ff>r.sn.ff;
      }
      return l.ff<r.ff;
  }
};
// bool operator<(pair<int,pii> l, pair<int,pii> r)
//  {
//      if(l.ff==r.ff)
//      {
//          cout<<"ok "<<endl;
//          return l.sn.ff<r.sn.ff;
//      }
//      return l.ff>r.ff;
//  }

/////////////////////////////////////template sesh/////////////////////////////////////////////////////

///code goes from here
const int mx=500150;
///
int mod=1000000007;

ll arr[mx];

int main()
{
//    SPEED;
//    mem(dp,-1);
    int t,tc=1;
//    sf(t);
    t=1;
    while(t--)
    {
        int k,n;
        sf(n);
        for(int i=0;i<n;i++)
        {
            sl(arr[i]);
        }
        ll val=1000;
        int i=1;
        while(i<n)
        {
            if(arr[i]>arr[i-1])
            {
                ll k=val/arr[i-1];
                val%=arr[i-1];
                val+=(arr[i]*k);
            }
            i++;
        }
        cout<<val<<endl;
    }

    return 0;
}



Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    int a;
    cin>>a;
    string s;
    cin>>s;
    if(a>=3200)cout<<s<<endl;
    else{
        cout<<"red"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;

class Program
{
	const int mod = 1000000007;
	static void Main(string[] args)
	{
		int n = int.Parse(Console.ReadLine());
		var h = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

		int ans = 0;
        while(h.Max()>0)
		{
			int cnt = 0;
            for(var i = 0; i < n; i++)
			{

				if (i < n - 1 && h[i] > 0 && h[i + 1] <= 0)
				{
					cnt++;
				}
                else if (i == n - 1 && h[i] > 0 ) { cnt++; }
				h[i]--;
			}
			ans += cnt;
		}
		Console.WriteLine(ans);
        

	}
}

Measured memory_bytes: 13396