akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>

int main()
{
    static bool sieve[10001];
    std::vector<long long> primes = { 2 };
    for (int p = 2; p <= 10000;) {
        for (int j = p * 2; j <= 10000; j += p) {
            sieve[j] = true;
        }
        int pp = p;
        for (int i = p + 1; i <= 10000; i++) {
            if (!sieve[i]) {
                p = i;
                primes.push_back(i);
                break;
            }
        }
        if (pp == p)
            break;
    }

    int n, ans = 0;
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        int a;
        std::cin >> a;
        if (a > 10000) {
            bool is_prime = true;
            for (auto&& prime : primes) {
                if (a % prime == 0) {
                    is_prime = false;
                    break;
                }
            }
            if (is_prime)
                ans++;
        } else if (!sieve[a])
            ans++;
    }
    std::cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3196
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define pf push_front
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> bool chmax(t&a,u b){if(a<b){a=b; return true;} return false;}
template<class t,class u> bool chmin(t&a,u b){if(a>b){a=b; return true;} return false;}
template<class t,class u> t MAX(t a,u b){if(a>=b) return a; return b;}
template<class t,class u> t MIN(t a,u b){if(a<=b) return a; return b;}
template<class t> int SIZE(t s){return (int)s.size();}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using vvi=vc<vc<int>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
const long long INF = 1LL << 60;

vvc<ll> to(2505);
vvc<ll> rto(2505);
vc<bool> re1(2505);
vc<bool> ren(2505);
vc<bool> ok(2505,false);

void dfs(ll v, vc<bool> &re, vvc<ll> t){
    if(re[v]) return;
    re[v] = true;
    for(ll u: t[v]) dfs(u,re,t);
}

ll bell(ll start, ll goal, vvc<pair<ll,ll>> beto, vc<ll>& dist){
    ll n = SIZE(beto);
    dist[start] = 0;
    rep(roop,n) {
        bool ch = false;
        rep(i,n){
            for (pair<ll,ll> p: beto[i]){
                if(!ok[p.first]) continue;
                if(dist[i] != INF && dist[i]+ p.second < dist[p.first]){
                    dist[p.first] = dist[i] + p.second;
                    ch = true;
                    //cout << i+1 << "->" << p.first+1 << " " << dist[p.first]<< endl; //確認用
                    if(roop == n-1) return -1*INF;
                }
            }
        }
        if(!ch) break;
    }
    return dist[goal];
}

int main(){
    cout << fixed << setprecision(20);
    ll n,m,p; cin >> n >> m >> p;
    vvc<pair<ll,ll>> beto(n,vc<pair<ll,ll>>());
    vc<ll> dist(n,INF);
    rep(i,m){
        int a,b,c; cin >> a >> b >> c;
        a--; b--;
        c -= p;
        beto[a].eb(make_pair(b,-1*c));
        to[a].eb(b);
        rto[b].eb(a);
    }
    dfs(0,re1,to);
    dfs(n-1,ren,rto);
    rep(i,n) if(re1[i]&&ren[i]) ok[i]=true;
    ll ans = -1*bell(0,n-1,beto,dist);
    if(ans == INF) cout << -1 << endl;
    else cout << MAX(ans,0) << endl;
    return 0;
}


Measured memory_bytes: 343296
#include <bits/stdc++.h>
using namespace std;
typedef long long Long;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	Long a, b;
	cin >> a >> b;
	Long k = (a + b) / 2;
	if (abs(a - k) == abs(b - k)) cout << k << endl;
	else cout << "IMPOSSIBLE" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void swap(int *a, int *b) {
    int temp = *a;
    *a = *b;
    *b = temp;
}

// flagを用いたバブルソート
int bubbleSort(int A[],int N) {
    int i,j;
    int sw = 0;
    unsigned short flag = 1;
    for(i=0;flag;i++) {
        flag = 0;
        for(j=N-1;j>=i+1;j--) {
            if(A[j]<A[j-1]) {
                swap(&A[j],&A[j-1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main(void) {
    int i, A[100], N, sw;
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);

    sw = bubbleSort(A,N);

    for(i=0;i<N;i++) {
        if (i) printf(" ");
        printf("%d",A[i]);
    }
    printf("\n%d\n",sw);

    return 0;
}


Measured memory_bytes: 2116
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define pri 1000000007
#define all(x) x.begin(),x.end()
#define mnx 1000001
#define pr pair<ll,ll>
#define ez 
using namespace std;


void masterstroke()
{   ll n,x;
	cin>>n>>x;
	ll l[n+1];
	l[0]=0;
	ll ans=1;
	for(ll i=1;i<=n;i++){
		ll xa;cin>>xa;
		l[i]=l[i-1]+xa;
		if(l[i]<=x)ans++;
	}
	cout<<ans<<endl;


}


int main(){

	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)
	masterstroke();

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {

        while (true){
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            if (m == -1 && f == -1 && r == -1)
                break;
            String grade = "";
            int sum = m + f;
            if (m == -1 || f == -1)
                grade = "F";
            else if (sum >= 80)
                grade = "A";
            else if (sum >= 65 && sum < 80)
                grade = "B";
            else if (sum >= 50 && sum < 65)
                grade = "C";
            else if (sum >= 30 && sum < 50){
                if (r >= 50){
                    grade = "C";
                } else {
                    grade = "D";
                }
            } else {
                grade = "F";
            }
                System.out.println(grade);
        }
    }
}



Measured memory_bytes: 26484
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef long long ll;
const int maxn = 100005;
const int mod = 1000000007;


int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int t1,t2;
  ll a1,a2,b1,b2;
  cin>>t1>>t2>>a1>>a2>>b1>>b2;
  if(a1>b1){
    swap(a1,b1);
    swap(a2,b2);
  }
  ll x1 = a1 * t1 + a2 * t2;
  ll x2 = b1 * t1 + b2 * t2;
  if(x1<x2){
    cout<<0<<endl;
    return 0;
  }
  if(x1==x2){
    cout<<"infinity"<<endl;
    return 0;
  }
  ll ret = 1;
  bool is1 = false;
  ll l = 1, r = b1*t1/(x1-x2)+1;
  while(l<=r){
    ll m = (l+r)>>1L;
    ll pre = (x1-x2)*m;
    if(pre+a1*t1<b1*t1){
      l = m+1;
    } else {
      ret = m;
      is1 = (pre+a1*t1==b1*t1);
      r = m-1;
    }
  }
  ll ans = 1 + (ret-1)*2 + is1;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;
typedef long long ll;

const int MOD = 1e9+7;
const int INF = 1e9;
int N,A,B,C;
vector<int> l;
int dfs(int cnt, int a, int b, int c){
    if(cnt == N){
        if(a != 0&&b != 0&&c != 0){
            return abs(A-a) + abs(B-b) + abs(C-c) - 30;
        }
        else return INF;
    }
    int res = INF;
    res = min(res, dfs(cnt+1, a + l[cnt], b, c)+10);
    res = min(res, dfs(cnt+1, a, b + l[cnt], c)+10);
    res = min(res, dfs(cnt+1, a, b, c + l[cnt])+10);
    res = min(res, dfs(cnt+1, a, b, c));
    return res;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>N>>A>>B>>C;
    l.resize(N);
    rep(i,N)cin>>l[i];
    cout<<dfs(0,0,0,0)<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.io.IOException;

class Main{
  public static void main(String... args)throws IOException{
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int sum=0;
    for(int i=0;i<n;i++){
      int l = sc.nextInt();
      int r = sc.nextInt();
      sum += (r-l+1);
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 25044
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  int n;
  std::cin >> n;

  if(n<2) std::cout << n << '\n';
  else if(n<4) std::cout << '2' << '\n';
  else if(n<8) std::cout << "4" << '\n';
  else if(n<16) std::cout << "8" << '\n';
  else if(n<32) std::cout << "16" << '\n';
  else if(n<64) std::cout << "32" << '\n';
  else if(n<=100) std::cout << "64" << '\n';
  return 0;
}


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();
		String S = sc.next();
		char[] A=S.toCharArray();
		int count=0;
		
		for(int i=0;i<N-2;i++) {
			if(A[i]=='A') {
				if(A[i+1]=='B') {
					if(A[i+2]=='C') {
						count++;
					}
				}
			}
		}
		System.out.println(count);
		
		
	}
}


Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

double atan(int a, int b) {
    if (a == 0) return (b > 0 ? M_PI / 2 : -M_PI / 2);
    if (b == 0 && a < 0) return M_PI;
    if (a < 0 && b < 0) return atan((double)b / a) - M_PI;
    if (a < 0 && b > 0) return atan((double)b / a) + M_PI;
    return atan((double)b / a);
}

bool comp(pii a, pii b) {
    return atan(a.F, a.S) < atan(b.F, b.S);
}

int main() {
    int n;
    cin >> n;
    
    vector<pii> v;
    rep(i, n) {
        int x, y;
        cin >> x >> y;
        if (x == 0 && y == 0) continue;
        v.eb(pii(x, y));
    }
    
    double ans = 0;
    
    sort(all(v), comp);
    
    // cout << '\n'; rep(i, sz(v)) cout << v[i].F << " " << v[i].S << " " << atan(v[i].F, v[i].S) << '\n';
    
    
    rep(i, sz(v)) rep3(j, i, sz(v)) {
        int x = 0, y = 0;
        rep3(k, i, j + 1) {
            x += v[k].F;
            y += v[k].S;
        }
        chmax(ans, sqrt((double)x * x + (double)y * y));
    }
    
    
    // 逆方向に延ばす
    rep(i, sz(v)) {
        int x = 0, y = 0;
        rep(j, sz(v)) {
            int k = (i - j + sz(v)) % sz(v);
            x += v[k].F;
            y += v[k].S;
            chmax(ans, sqrt((double)x * x + (double)y * y));
        }
        
    }
    
    
    cout << fixed << setprecision(11) << ans << '\n';
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define nl '\n'
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
const int MOD = 998244353;
const int N = 2*1e5;

struct mi {
	ll v; explicit operator ll() const { return v; }
	mi() { v = 0; }
	mi(ll _v) { 
		v = (-MOD < _v && _v < MOD) ? _v : _v % MOD;
		if (v < 0) v += MOD;
	}
	friend bool operator==(const mi& a, const mi& b) { 
		return a.v == b.v; }
	friend bool operator!=(const mi& a, const mi& b) { 
		return !(a == b); }
	friend bool operator<(const mi& a, const mi& b) { 
		return a.v < b.v; }
   
	mi& operator+=(const mi& m) { 
		if ((v += m.v) >= MOD) v -= MOD; 
		return *this; }
	mi& operator-=(const mi& m) { 
		if ((v -= m.v) < 0) v += MOD; 
		return *this; }
	mi& operator*=(const mi& m) { 
		v = v*m.v%MOD; return *this; }
	mi& operator/=(const mi& m) { return (*this) *= inv(m); }
	friend mi pow(mi a, ll p) {
		mi ans = 1; assert(p >= 0);
		for (; p; p /= 2, a *= a) if (p&1) ans *= a;
		return ans;
	}
	friend mi inv(const mi& a) { assert(a.v != 0); 
		return pow(a,MOD-2); }
		
	mi operator-() const { return mi(-v); }
	mi& operator++() { return *this += 1; }
	mi& operator--() { return *this -= 1; }
    mi operator++(int) { mi temp; temp.v = v++; return temp; }
    mi operator--(int) { mi temp; temp.v = v--; return temp; }
	friend mi operator+(mi a, const mi& b) { return a += b; }
	friend mi operator-(mi a, const mi& b) { return a -= b; }
	friend mi operator*(mi a, const mi& b) { return a *= b; }
	friend mi operator/(mi a, const mi& b) { return a /= b; }
    friend ostream& operator<<(ostream& os, const mi& m) {
        os << m.v; return os;
    }
    friend istream& operator>>(istream& is, mi& m) {
        ll x; is >> x;
        m.v = x;
        return is;
    }
};

int MX = 2*1e5;
ll n, k, mm;
mi fac[N+5];
mi facInv[N+5];

// initialize factorials
void initFac(){
    fac[0] = 1;
    facInv[0] = 1;
    for(int i=1; i<=MX; i++){
        fac[i] = fac[i-1]*i;
        facInv[i] = inv(fac[i]);
    }
}

// C(n, k)
mi choose(int n, int k){
    if(k<0) return 0;
    if(n<0) return 0;
    if(k>n) return 0;

    mi res = fac[n]*facInv[n-k]*facInv[k];
    return res;
}


int main(){
    AC
    initFac();
    cin>>n>>mm>>k;
    mi m = mm;
    mi ans = 0;
    for(int i=0; i<=k; i++){
        ans+=choose(n-1, i)*m*pow(m-1, n-1-i);
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 6708
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int n = Integer.parseInt(st.nextToken());
		int W = Integer.parseInt(st.nextToken());
		int[] v = new int[n];
		int[] w = new int[n];
		for (int i = 0; i < n; i++) {
			st = new StringTokenizer(reader.readLine());
			v[i] = Integer.parseInt(st.nextToken());
			w[i] = Integer.parseInt(st.nextToken());
		}
		reader.close();
		System.out.println(getMaxValue(n, W, v, w));
	}

	private int getMaxValue(int n, int W, int[] values, int[] weigths) {
		int[][] dp = new int[n+1][W+1];
		for (int i = 1; i <= n; i++) {
			int w = weigths[i-1];
			int v = values[i-1];
			for (int j = 0; j <= W; j++) {
				if (w <= j) {
					dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j-w] + v);
				} else {
					dp[i][j] = dp[i-1][j];
				}
			}
		}
		return dp[n][W];
	}
}


Measured memory_bytes: 29080
//
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define MOD 1000000007
#define PI 3.14159265
#define EPS 1e-9
#define Pi acos(-1.0)
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;

/*CODE START HERE*/

string s;
string ans;

int main(){
    ios::sync_with_stdio(0);
    cin >> s;
    ans.clear();
    forn(i,(int)s.length()){
        if(i%2==0)
            ans.push_back(s[i]);
    }
    cout << ans << "\n";
    return 0;
}

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

using namespace std;

int main() {
	cin.tie(0);
	cout.tie(0);
	iostream::sync_with_stdio(0);
	long long n;
	cin>>n;
	long long res = n + 1;
	for (long long i = 1; i * i <= n; i++)
		if (n % i == 0) res = min(res, i + n / i);
	cout<<(res - 2)<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,i,j,c,d,x,flg1;
	while(1){
		scanf("%d",&a);
		if(a==0) break;
			for(i=a;i>1;i--){
				flg1=0;
				for(j=2;j*j<=i;j++){
					if(i%j==0){
						flg1=1;
						break;
					}
				}
				if(flg1==0){
					x=i-2;
					for(j=2;j*j<=x;j++){
						if(x%j==0){
							flg1=1;
							break;
						}					
					}
				}
				if(flg1==0){
					c=i;
					d=x;
					break;
				}	
			}
		printf("%d %d\n",d,c);
		c=0;
		d=0;
	}
	return 0;
}

Measured memory_bytes: 2664
#include<cstdio>
using namespace std;
typedef long long LL;
const int maxn=200005,TT=998244353;
int n,m,K,fac[maxn],inv[maxn],ans;
inline int QP(int a,int b)
{
	int ret=1,w=a;
	while(b)
	{
		if(b&1) ret=(LL)ret*w%TT;
		w=(LL)w*w%TT;b>>=1;
	}
	return ret;
}
inline int C(int n,int m){return (LL)fac[n]*inv[m]%TT*inv[n-m]%TT;}
int main()
{
	scanf("%d%d%d",&n,&m,&K);
	fac[0]=1;
	for(int i=1;i<=n;i++)
		fac[i]=(LL)fac[i-1]*i%TT;
	inv[n]=QP(fac[n],TT-2);
	for(int i=n-1;i>=0;i--) inv[i]=(LL)inv[i+1]*(i+1)%TT;
	for(int i=0;i<=K;i++)
		ans=(ans+(LL)C(n-1,i)*m%TT*QP(m-1,n-i-1)%TT)%TT;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3268
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
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; }
//setprecision(15)有効数字15桁
//-std=c++14
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
double a,b,c,d,e,f;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a>>b>>c>>d>>e>>f;
    double ans=0;
    double sum=100*a;
    double satou=0;
    for(int i=0;i<=f/(100*a);i++){
        for(int j=0;j<=(f-100*a*i)/(100*b);j++){
            for(int k=0;k<=(f-100*a*i-100*b*j)/c;k++){
                for(int l=0;l<=(f-100*a*i-100*b*j-k*c)/d;l++){
                    if(100*a*i+100*b*j+k*c+l*d<=f){
                        if((k*c+l*d)/(a*i+b*j)<=e){
                            if(ans<=100*(k*c+l*d)/(k*c+l*d+100*a*i+100*b*j)){
                                ans=100*(k*c+l*d)/(k*c+l*d+100*a*i+100*b*j);
                                sum=100*a*i+100*b*j+k*c+l*d;
                                satou=k*c+l*d;
                            }
                        }
                    }
                }
            }
        }
    }
    cout << sum <<" "<<satou<< "\n";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  int k, a, b;
  cin >> k >> a >> b;
  
  for(int i = a; i <= b; i++){
    if(i % k == 0){
      cout << "OK" << endl;
      return 0;
    }
  }

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


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

int main()
{
  int N;
  cin >> N;
  vector<int> D(N);
  for (int i = 0; i < N; i++)
  {
    cin >> D.at(i);
  }
  sort(D.begin(), D.end());
  D.erase(unique(D.begin(), D.end()), D.end());
  cout << D.size() << endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define int long long
const int mo=998244353,N=1e6+5;
int ksm(int a,int b){
	int ans=1;
	while (b){
		if (b&1) ans=ans*a%mo;
		a=a*a%mo;
		b>>=1;
	}
	return ans;
}
int fac[N],inv[N],f[N];

int C(int a,int b){
	return fac[a]*inv[b]%mo*inv[a-b]%mo;
}
signed main(){
	int n,m,ans=0;
	scanf("%lld%lld",&n,&m);
	fac[0]=1;
	for (int i=1;i<N;++i)
		fac[i]=(fac[i-1]*i)%mo;
	inv[N-1]=ksm(fac[N-1],mo-2);
	for (int i=N-2;i>=0;i--)
		inv[i]=(inv[i+1]*(i+1))%mo;
	if (n>m) std::swap(n,m);
	for (int i=0;i<=n;++i)
		f[i]=C(n,i)*C(m,i)%mo*fac[i]%mo*ksm(n+1,m-i)%mo*ksm(m+1,n-i)%mo;
	for (int i=0;i<=n;++i)
		 ans=((ans+(1-((i&1)<<1))*f[i])%mo+mo)%mo;
	printf("%lld\n",ans);
} 

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

int main() {
  vector<int> A(4);
  for(int i=0;i<4;i++){
    cin >>A.at(i);
  }
  sort(A.begin(),A.end());
  if(A.at(0)!=1){
    cout <<"NO" <<endl;
    return 0;
  }
  if(A.at(1)!=4){
    cout <<"NO" <<endl;
    return 0;
  }
  if(A.at(2)!=7){
    cout <<"NO" <<endl;
    return 0;
  }
  if(A.at(3)!=9){
    cout <<"NO" <<endl;
    return 0;
  }
  cout <<"YES" <<endl;
  return 0;
}

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

using namespace std;
typedef struct {
   int p;
   int x;
} pxdata;

vector <int> *tree;
int *counter;

bool *calced;

int func( int p )
{
    int c = counter[p];

    if ( calced[p] ) return c;
//    cout << p << " add " << counter[p] << endl;

    if ( tree[p].size() ) c += func( tree[p][0] );

    counter[p] = c;
    calced[p] = true;

    return c;
}

int main()
{
    int N, Q;

    cin >> N;
    cin >> Q;

    tree = new vector<int> [N];
    counter = new int[N];
    calced = new bool[N];

    // vector<int> tree[N]; 
    // int counter[N];

    fill( counter, counter+N, 0 );
    fill( calced, calced+N, false );

    int a, b;
    for ( int i = 0; i < N-1; i ++ ) {
        cin >> a;
        cin >> b;

        a--;
        b--;
        tree[b].push_back( a );
    }


    pxdata px[Q];

    for ( int i = 0; i < Q; i ++ ) {
        cin >> px[i].p >> px[i].x;
    }

    for ( int i = 0; i < Q; i ++ ) {
        int p = px[i].p-1;
        int x = px[i].x;

        counter[p] += x;
    }

///    for ( int i = 0; i < N; i ++ ) {
//        cout << i << ":";
//        for ( int j = 0; j < tree[i].size(); j ++ ) {
//            cout << tree[i][j] << " ";
//        }
//        cout << endl;
//    }


    for ( int i = 0; i < N; i ++ ) {
        cout << func(i) << " ";
    }
    cout << endl;

    return 0;

}

Measured memory_bytes: 15872
n,m = gets.split.map!(&:to_i)
a = gets.split.map!(&:to_i).sort!.reverse

s = [a.shift / 2]
(m-1).times do 
    if a == []
        a = s
        s = [a.shift / 2]
    elsif a[0] > s[0]
        s << a.shift / 2
    else
        s << s.shift / 2
    end
end

ans = 0
a += s
a.each do |e|
    ans += e
end

puts ans

Measured memory_bytes: 13296
#include<stdio.h>

int main(){
    int H,W,i,j;
    while(true){
        scanf("%d %d",&H,&W);
        if(H==0 && W==0){
            break;
        }
        else{
            for(j=0;j<W;j++)printf("#");
            printf("\n");
            for(i=1;i<H-1;i++){
                printf("#");
                for(j=1;j<W-1;j++)printf(".");
                printf("#");
                printf("\n");
            }
            for(j=0;j<W;j++)printf("#");
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2604
#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>
#include<complex>
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 = 4000001;
const double eps = 1E-18;

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 operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return 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, M;
	cin >> N >> M;

	vector<vector<ll>> g(N + 1);
	repn(i, M) {
		ll a, b;
		cin >> a >> b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	cout << "Yes" << endl;
	vector<ll> ans(N + 1, 0);

	queue<ll> q;
	q.push(1);

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

		for (ll w : g[v]) {
			if (ans[w] != 0) { continue; }
			ans[w] = v;
			q.push(w);
		}
	}

	for (ll i = 2; i <= N; i++)cout << ans[i] << endl;
}


Measured memory_bytes: 12948
/**
*  author: rits1272
*  created: Aug 22, 2020
**/
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define print(x) cout << "[" << #x << ":" << x << "] "; 
#define println(x) cout << "[" << #x << ":" << x << "]\n";

const int mxN = 2e5 + 1;
int n, heights[mxN];

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n;
    for(int i=0; i<n; i++)
	cin >> heights[i];
    int ans = 0;
    for(int i=1; i<n; i++){
	if(heights[i-1]>heights[i]){
	    ans += heights[i-1]-heights[i];
	    heights[i] = heights[i-1];
	}
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 5172
#include<bits/stdc++.h>
using namespace std;
int main()
{
   long long a,b,x,i,c=0,n,h,w;
    cin>>n>>h>>w;
    for(i=1;i<=n;i++)
    {
      cin>>a>>b;
      if(a>=h&&b>=w) c++;
    }
    cout<<c<<endl;


  return 0;
}


Measured memory_bytes: 3560
def Yes():
    print('Yes')
    exit()


def No():
    print('No')
    exit()


def parse(s):
    ret = [0, 0]
    for c in s:
        if c == ')':
            if ret[0]:
                ret[0] -= 1
            else:
                ret[1] -= 1
        else:
            ret[0] += 1
    return ret


N = int(input())
S = [parse(input()) for _ in range(N)]
S.sort(key=lambda a: -a[0] - a[1])
S1 = sorted([s for s in S if s[0] + s[1] >= 0], key=lambda a: -a[1])
S2 = sorted([s for s in S if s[0] + s[1] < 0], key=lambda a: -a[0])
cnt = 0
for s in S1:
    cnt += s[1]
    if cnt < 0:
        No()
    cnt += s[0]
for s in S2:
    cnt += s[1]
    if cnt < 0:
        No()
    cnt += s[0]
if cnt:
    No()
Yes()


Measured memory_bytes: 283008
#include <iostream>
#include <string>
using namespace std;
 
int main()
{
  char S[3];
  char T[3];
  int i;
  int sum;
  sum = 0;
  
  cin >> S;
  cin >> T;
     
  for (int i = 0; i < 3; i++){
    if(S[i]==T[i]){
      sum += 1;
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
l_max = 0
r_min = n+1
for i in range(m):
  l,r=map(int,input().split())
  l_max = max(l_max, l)
  r_min = min(r_min, r)
print(max(r_min-l_max+1,0))


Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
void Dice(char p, int []);
int Count(int[]);
 
int main() {
    int d[6], d2[6], i, flg = 0;
    char str[2][4] = { "No","Yes" };
    for (i = 0; i < 6; i++)  scanf("%d", &d[i]);
    for (i = 0; i < 6; i++)  scanf("%d", &d2[i]);
    if (Count(d) >= 10) { printf("Yes\n"); return 0; }
    if (d[0] == d2[0]);
    else if (d[5] == d2[0]) Dice('N', d), Dice('N', d);
    else if (d[1] == d2[0]) Dice('N', d);
    else if (d[4] == d2[0]) Dice('S', d);
    else if (d[2] == d2[0]) Dice('W', d);
    else if (d[3] == d2[0]) Dice('E', d);
    if (d[1] == d2[1]);
    else if (d[4] == d2[1]) Dice('L', d), Dice('L', d);
    else if (d[2] == d2[1]) Dice('R', d);
    else if (d[3] == d2[1]) Dice('L', d);
    for (i = 3; i < 6; i++) {
        if (d[i] != d2[i]) break;
        if(i==5) flg = 1;
    }
    printf("%s\n", str[flg]);
    return 0;
}
 
void Dice(char p, int d[]) {
    int tmp;
    if (p == 'S') { tmp = d[0]; d[0] = d[4]; d[4] = d[5]; d[5] = d[1]; d[1] = tmp; }
    if (p == 'W') { tmp = d[0]; d[0] = d[2]; d[2] = d[5]; d[5] = d[3]; d[3] = tmp; }
    if (p == 'E') { tmp = d[0]; d[0] = d[3]; d[3] = d[5]; d[5] = d[2]; d[2] = tmp; }
    if (p == 'N') { tmp = d[0]; d[0] = d[1]; d[1] = d[5]; d[5] = d[4]; d[4] = tmp; }
    if (p == 'L') { tmp = d[1]; d[1] = d[3]; d[3] = d[4]; d[4] = d[2]; d[2] = tmp; }
    if (p == 'R') { tmp = d[1]; d[1] = d[2]; d[2] = d[4]; d[4] = d[3]; d[3] = tmp; }
}
 
int Count(int d[]){
    int cnt = 0, i, j;
    for (i = 0; i < 5; i++) {
        for (j = i + 1; j < 6; j++)
            if (d[i] == d[j])++cnt;
    }
    return cnt;
}

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

int main(){
  long long N,A[200001],list[200001][2],i,j,ans=0,sum=0;
  cin>>N;
  for(i=0;i<200001;i++){
    for(j=0;j<2;j++) list[i][j]=0;
  }
  for(i=0;i<N;i++){
    cin>>A[i];
    list[A[i]][0]++;
  }
  for(i=1;i<=200000;i++){
    list[i][1]=list[i][0]*(list[i][0]-1)/2;
    sum+=list[i][1];
  }
  for(i=0;i<N;i++){
    cout<<sum-(list[A[i]][1]-(list[A[i]][0]-1)*(list[A[i]][0]-2)/2)<<endl;
  }
}

Measured memory_bytes: 7296
#include "bits/stdc++.h"

using namespace std;

int main() {

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

	long long n, c, k;
	cin >> n >> c >> k;

	vector<long long> t(n);

	for (auto &a : t) {
		cin >> a;
	}

	sort(t.begin(), t.end());

	int ans = 1;
	int time = t[0] + k;
	int count = 0;
	for (long long i = 0; i < n; i++) {

		count++;

		if (count > c || time < t[i]) {
			ans++;
			time = t[i] + k;
			count = 1;
		}

	}

	cout << ans << endl;

	return 0;

}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define NUM 100005
typedef pair<int,int> P;

int N,M;
int POW[31];
int table[NUM],input_rank[NUM];
map<P,int> dp[31];

int recursive(int left,int right,int range_winner_final_input_rank,int size){

	if(range_winner_final_input_rank == size && dp[size].find(P(left,right)) != dp[size].end()){
		return dp[size][P(left,right)];
	}

	int L = 0,R = M,mid = (L+R)/2;
	int index = 0;

	while(L <= R){

		if(table[mid] <= left){

			index = mid;
			L = mid+1;

		}else{
			R = mid-1;
		}
		mid = (L+R)/2;
	}

	int ret = BIG_NUM;

	if(index+1 <= M && table[index] <= left && table[index+1] >= right){

		if(input_rank[index] >= size+1){

			ret = POW[N-size]-POW[N-size]/POW[N-input_rank[index]+1];

		}else{

			ret = POW[N-size];

			if(input_rank[index] == range_winner_final_input_rank){
				ret--;
			}
		}

	}else{

		mid = (left+right)/2;
		ret = min(recursive(left,mid,range_winner_final_input_rank,size+1)+recursive(mid,right,size+1,size+1),
 				recursive(left,mid,size+1,size+1)+recursive(mid,right,range_winner_final_input_rank,size+1));
	}

	if(range_winner_final_input_rank == size){

		return dp[size][P(left,right)] = ret;

	}else{
		return ret;
	}
}

int main(){

	for(int i = 0; i < 31; i++)POW[i] = pow(2,i);

	scanf("%d %d",&N,&M);

	for(int i = 0; i <= M; i++){
		scanf("%d",&table[i]);
	}

	for(int i = 0; i < M; i++){
		scanf("%d",&input_rank[i]);
	}

	printf("%d\n",recursive(0,POW[N],0,0));

	return 0;
}



Measured memory_bytes: 22880
def gcd(a, b):
    while True:
        a, b = b, a % b
        if b == 0:
            break
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


n = int(input())
ls = [int(input()) for _ in range(n)]
res = ls[0]
for x in ls[1:]:
    res = lcm(res, x)
print(res)

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

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

class combination_cache {
 private:
  explicit combination_cache(const int64_t p)
      : mod(p), max(1), fac(2, 1), finv(2, 1), inv(2, 1) {}
  ~combination_cache() = default;
  const int64_t mod;
  int64_t max;

 public:
  combination_cache(const combination_cache &) = delete;
  combination_cache &operator=(const combination_cache &) = delete;
  combination_cache(combination_cache &&) = delete;
  combination_cache &operator=(combination_cache &&) = delete;

  std::vector<int64_t> fac;
  std::vector<int64_t> finv;
  std::vector<int64_t> inv;

  static const combination_cache &get(const int64_t n, const int64_t p) {
    static combination_cache instance(p);

    assert(p == instance.mod);
    if (instance.max < n) {
      instance.fac.reserve(n + 1);
      instance.finv.reserve(n + 1);
      instance.inv.reserve(n + 1);
      for (int64_t i = instance.max + 1; i <= n; i++) {
        instance.fac.push_back(instance.fac[i - 1] * i % p);
        instance.inv.push_back(p - instance.inv[p % i] * (p / i) % p);
        instance.finv.push_back(instance.finv[i - 1] * instance.inv[i] % p);
      }
      instance.max = n;
    }
    return instance;
  }
};

int64_t combination(const int64_t n, const int64_t k, const int64_t p) {
  if (n < k || n < 0 || k < 0) {
    return 0;
  }
  const auto &cache = combination_cache::get(n, p);
  return cache.fac[n] * (cache.finv[k] * cache.finv[n - k] % p) % p;
}

int main() {
  int64_t n, m, k;
  std::cin >> n >> m >> k;
  constexpr int64_t mod = 998244353;

  std::vector<int64_t> pred(n + 1);
  pred[0] = 1;
  pred[1] = m;
  for (int64_t i = 2; i < n + 1; i++) {
    pred[i] = (pred[i - 1] * (m - 1)) % mod;
  }

  combination(n - 1, n, mod);

  int64_t ans = 0;

  for (int64_t dup = 0; dup <= k; dup++) {
    ans += (pred[n - dup] * combination(n - 1, dup, mod)) % mod;
    ans %= mod;
  }

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 9528
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,t) for(ll i = (ll)(s); i < (ll)(t); i++)
#define rrep(i,s,t) for(ll i = (ll)(s-1);(ll)(t) <= i; i--)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
constexpr ll INF = numeric_limits<ll>::max()/4;
constexpr ll n_max = 2e5+10;
#define int ll

template <typename A, typename B>
string to_string(pair<A, B> p);
string to_string(const string &s) {return '"' + s + '"';}
string to_string(const char *c) {return to_string((string) c);}
string to_string(bool b) {return (b ? "true" : "false");}
template <size_t N>
string to_string(bitset<N> v){
    string res = "";
    for(size_t i = 0; i < N; i++) res += static_cast<char>('0' + v[i]);
    return res;
}
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) res += ", ";
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p){return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}

void debug_out() {cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

template<class T>
bool chmax(T &a, T b){if(a < b){a = b; return true;} return false;}
template<class T>
bool chmin(T &a, T b){if(a > b){a = b; return true;} return false;}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string a;cin >> a;
    string b;cin >> b;
    string c;cin >> c;

    ll base = 10000;
    ll A = a.size(), B = b.size(), C = c.size();
    vector<ll> ab(base*2, 1), ac(base*2, 1), bc(base*2, 1);
    auto match = [&](char c, char d){
        return c == '?' || d == '?' || c == d;
    };
    rep(i,0,a.size())rep(j,0,b.size()){
        ab[i-j+base] &= match(a[i], b[j]);
    }
    rep(i,0,a.size())rep(j,0,c.size()){
        ac[i-j+base] &= match(a[i], c[j]);
    }
    rep(i,0,b.size())rep(j,0,c.size()){
        bc[i-j+base] &= match(b[i], c[j]);
    }
    rep(i,-10,10)debug(i, ab[i+base], ac[i+base], bc[i+base]);
    ll ans = 6000;
    for(int i = -4000; i <= 4000; i++){
        for(int j = -4000; j <= 4000; j++){
            if(ab[i+base] && ac[i+j+base] && bc[j+base]){
                ll l = min({0LL, i, i+j});
                ll r = max({A, i+B, i+j+C});
                chmin(ans, r-l); 
            }
        }
    }

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

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
int main(){
  cout << fixed << setprecision(20);
  int N, A, B;
  cin >> N >> A >> B;
  vector<long long> v(N);
  for (int i = 0; i < N; i++){
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  long long mx_sum = 0;
  int mx_cnt = 1;
  for (int i = A; i <= B; i++){
    long long sum = 0;
    for (int j = 0; j < i; j++){
      sum += v[N - 1 - j];
    }
    if (sum * mx_cnt > mx_sum * i){
      mx_sum = sum;
      mx_cnt = i;
    }
  }
  cout << (double) mx_sum / mx_cnt << endl;
  vector<vector<long long>> binom(51, vector<long long>(51));
  for (int i = 0; i < 51; i++){
    binom[i][0] = 1;
    binom[i][i] = 1;
  }
  for (int i = 2; i < 51; i++){
    for (int j = 1; j < i; j++){
      binom[i][j] = binom[i - 1][j - 1] + binom[i - 1][j];
    }
  }
  long long ans = 0;
  for (int i = A; i <= B; i++){
    long long sum = 0;
    for (int j = 0; j < i; j++){
      sum += v[N - 1 - j];
    }
    if (sum * mx_cnt == mx_sum * i){
      long long last = v[N - i];
      int a = lower_bound(v.begin(), v.end(), last) - v.begin();
      int b = upper_bound(v.begin(), v.end(), last) - v.begin();
      ans += binom[b - a][N - i - a];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
S = input()
a = len(S)
T = 0
b = 0

if a % 2 == 0:
  b = a // 2
  for i in range(b):
    if S[2*i] == 'L':
      T += 1    
  for i in range(b):
    if S[2*i+1] == 'R':
      T += 1

else:
  b = a // 2
  for i in range(b+1):
    if S[2*i] == 'L':
      T += 1
  for i in range(b):
    if S[2*i+1] == 'R':
      T += 1  

if T == 0:
  print('Yes')
else:
  print('No')

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

int main(){
    long long A,B,V,W,T;
    cin >> A >> V >> B >> W >> T;
    if(A < B){
      if((A+V*T) >= (B+W*T)){
        cout << "YES" << endl;
        return 0;
      }else{
        cout << "NO" << endl;
        return 0;
      }
    }else{
      if((A-V*T) <= (B-W*T)){
        cout << "YES" << endl;
      }else {
        cout << "NO" << endl;
      }
    }
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007

int main(){
    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int cnt=0,m=a[0],t=0;
    for(int i=1;i<n;i++){
        if(a[i]-m>t){
            cnt=1;
            t=a[i]-m;
        }
        else if(a[i]-m==t){
            cnt++;
        }
        m=min(m,a[i]);
    }
    cout<<cnt<<endl;
}


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

    int a,b,c;
    int count;


    public void input(){
	Scanner scan = new Scanner(System.in);
	count = 0;
	a = scan.nextInt();
        b = scan.nextInt();
        c = scan.nextInt();

	for(int i = a;i <= b;i++){
	    if(c % i == 0){
		count = count + 1;
	    }
	}



    }
    public void output(){
	System.out.println(count);


    }
    



    public static void main(String[] args){
	Main  p = new Main();
	p.input();
       	p.output();
    }
}

Measured memory_bytes: 26408
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll INF = 1e18;

int main() {
    ll n, m, p;
    cin >> n >> m >> p;
    VL a(m), b(m), c(m);
    VVI e(n);
    REP(i,m){
        a[i] = in() - 1;
        b[i] = in() - 1;
        c[i] = in();
        e[b[i]].push_back(a[i]);
    }
    VI reach(n);
    reach[n - 1] = 1;
    queue<int> que;
    que.push(n - 1);
    while (!que.empty()){
        int now = que.front();
        que.pop();
        for (int next : e[now]){
            if (reach[next]) continue;
            reach[next] = 1;
            que.push(next);
        }
    }
    VL dist(n, -INF);
    dist[0] = 0;
    REP(i,n+1){
        bool found = false;
        REP(j,m){
            if (!reach[b[j]] || dist[a[j]] == -INF) continue;
            ll x = dist[a[j]] + c[j] - p;
            if (x > dist[b[j]]){
                found = true;
                dist[b[j]] = x;
            }
        }
        if (!found) break;
        if (i == n){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << max(0LL, dist[n - 1]) << endl;

    return 0;
}


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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
  int  x,y,z;
  cin>>x>>y>>z;
  int ans=(x-z)/(y+z);
  cout<<ans<<endl;








return 0;}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n;
    int i;

    scanf("%d", &n);
    int inp[n], reverse[n];

    for (i = 0; i < n; i++){
        int inp_i;
        scanf("%d", &inp_i);
        inp[i] = inp_i;
    }

    for (i = 0; i < n; i++){
        reverse[i] = inp[n - 1 - i];
    }

    for (i = 0; i < n; i++){
        if (i){
            printf(" ");
        }
        printf("%d", reverse[i]);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
using namespace std;
bool prime[56006];
vector<int> ans;
int n;
void init() {
  for(int i = 2; i <= 56000; i++) {
    if(prime[i]) continue;
    for(int j = i + i; j + i <= 56000; j += i) {
      prime[j] = true;
    }
  }

  return;
}

int main() {
  
  cin >> n;
  init();
  int k = 2;
  while(n--) {
    for(;;k++) {
      if(!prime[k] && (k % 5 == 1)) {
	ans.push_back(k);
	break;
      }
    }
    k++;
	
  }

  for(int i = 0; i < ans.size(); i++) {
    if(i == ans.size() - 1) cout << ans[i] << endl;
    else cout << ans[i] <<' ';
  }
}


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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}


signed main(void)
{	
	int n, i;
	cin >> n >> i;
	print(n - i + 1);
}

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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using v = vector<T>;
template <class T>
using vv = v<v<T>>;
#define ALL(c) (c).begin(), (c).end()

int main()
{
    ll mod = 1000000007;
    ll ans = 0, k = 0;
    int N;
    cin >> N;
    v<ll> A(N), B(N + 1, 0);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        B[i + 1] = B[i] + A[i];
    }

    for (int i = 0; i < N; i++)
    {
        k = A[i] * ((B[N] - B[i + 1])%mod);
        ans += k;
        ans = ans % mod;
    }

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

Measured memory_bytes: 6428
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
// #include <boost/multiprecision/cpp_int.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>

using namespace std;
// using namespace boost::multiprecision;

typedef long long ll;
typedef long double ld;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mis map<int,string>
#define msi map<string,int>
#define mll map<ll,ll>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()
#define srta(a) sort(all(a))
#define srtd(a) sort(all(a),greater<型>())
#define rvs(s) reverse(all(s))
#define psb push_back
#define ppb pop_back
#define ers erase
#define isu isupper
#define isl islower
#define lb(a,k) lower_bound(all(a),k)
#define ub(a,k) upper_bound(all(a),k)
#define bs(a,k) binary_search(all(a),k)
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const int I_INF = 1001001001;
const ll LL_INF = 1001001001001001001;
const ld EPS = 0.001;

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

    vl a(N);
    rep (i, N) cin >> a[i];

    ll ans = 0;
    rep (i, N) {
        for (int j=i; j<N; j++) {
            for (int k=j;  k<N; k++) {
                if (a[i] != a[j] && a[i] != a[k] && a[j] != a[k]) {
                    if (a[i]+a[j] > a[k] && a[j]+a[k] > a[i] && a[k]+a[i] > a[j]) ans++;
                }
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3604