akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <cassert>
#include <numeric>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int64_t mod = 1000000007;
const int64_t tmpMod = 998244353;

int main() {
 
  string N;
  cin>>N;
  if(N[N.size()-1]=='s')N+="es";
  else N.push_back('s');
  //vector<int64_t> A(N);
  //for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int> > A(N,vector<int>(M));
  //for(int i=0; i<N; i++){
  //   for(int j=0; j<M; j++){
  //       cin>>A[i][j];
  //   }
  // }
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
  cout << N << endl;
}

Measured memory_bytes: 3624
#include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;

typedef struct{
	double L;
	double a;
	double b;
}color;

double dist(color x, color y){
	double p=x.L-y.L, q=x.a-y.a, r=x.b-y.b;
	return p*p+q*q+r*r;
}

int main(){
	int n, m;
	color c[20];
	double max=0;
	
	scanf(" %d %d", &n, &m);
	
	for(int i=0; i<n; ++i){
		scanf(" %lf %lf %lf", &c[i].L, &c[i].a, &c[i].b);
	}
	
	for(int i=(1<<n)-1; i>0; --i){
		int ct=0;
		for(int j=0; j<n; ++j){
			if((i>>j) & 1) ct++;	
		}	
		if(ct!=m) continue;
		
		//m??????????????????1????????£?????????(1????????£????????????????????????????£?)
		int nums[20];
		int pp=0;
		for(int j=0; j<n; ++j){
			if((i>>j) & 1) nums[pp++]=j; //???????????????????????¢
		}
		
		/*
		printf("   now:: i= %d\n", i);
		for(int j=0; j<pp; ++j){
			printf("nums[%d]=%d\n", j, nums[j]);		
		}
		*/
		
		//sum of distances
		double tmp=0;
		for(int j=0; j<pp; ++j){
			for(int k=j+1; k<pp; ++k){
				tmp+=dist(c[nums[j]], c[nums[k]]);
			}
		}
		//printf(" tmp= %lf\n", tmp);
		
		if(tmp>max) max=tmp;
	}

	printf("%lf\n", max);
}

Measured memory_bytes: 1248
#include <iostream>
#include <cmath>
#include <string>
using namespace std;
string S; double K, p[101], X = 5e15;
int main() {
  cin >> S >> K;
  for(int i = 1, s; i <= S.size(); i++) {
    s = S[i-1]-'0';
    p[i] = p[i-1]+pow(s, X);
    if(K <= p[i]) {cout << s; break;}
  }
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> P;
typedef priority_queue<P,vector<P>,greater<P>> P_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e18;
const double PI=3.1415926535897932;
vec dx={1,0,-1,0};
vec dy={0,1,0,-1};

#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end());
#define ADD(a,b) a=(a+b)%mod

vec d[10010];

int main(){
    ll N; cin>>N;
    rep(i,N-1){
        ll a,b; cin>>a>>b;
        a--; b--;
        d[a].pb(b);
        d[b].pb(a);
    }
    vec c(N);
    rep(i,N) cin>>c[i];
    sort(ALL(c));
    reverse(ALL(c));
    ll ans=0;
    REP(i,1,N) ans+=c[i];
    queue<ll> Q;
    Q.push(0); ll j=1;
    vec ANS(N,-1);
    ANS[0]=c[0];
    while(!Q.empty()){
        ll A=Q.front();
        Q.pop();
        rep(i,d[A].size()){
            ll B=d[A][i];
            if(ANS[B]<0){
                ANS[B]=c[j];
                j++;
                Q.push(B);
            }
        }
    }
    cout<<ans<<endl;
    rep(i,N) cout<<ANS[i]<<' ';
    cout<<endl;


}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

int digit_sum(int n) {
    int res = 0;
    while(n) {
        res += (n % 10);
        n /= 10;
    }
    return res;
}

void solve() {
    int n;
    std::cin >> n;
    int ans = 1e9;
    repeat(i, 1, n) {
        ans = std::min(ans, digit_sum(i) + digit_sum(n - i));
    }
    std::cout << ans << std::endl;
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    string L;
    cin >> L;

    ll pow2 = 1, pow3 = 1;
    for (int i = 0; i < L.length(); ++i)
        (pow3 *= 3) %= MOD;

    ll ans = 0;
    for (int i = 0; i < L.length(); ++i) {
        (pow3 *= 333333336) %= MOD;
        if (L[i] == '0')
            continue;
        (ans += pow2 * pow3 % MOD) %= MOD;
        (pow2 *= 2) %= MOD;
    }
    (ans += pow2) %= MOD;

    cout << ans << endl;

    return 0;
}


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

int main(){
    int ans=0;
    int N,M;
    cin >> N >> M;
    int H[N]; //N個の標高
    int l[N];
    for(int i=0;i<N;i++){
        cin >> H[i];
        l[i] = 0;
    }
    int P[M][2];
    for(int i=0;i<M;i++){
        //道M本繰り返し
        cin >> P[i][0];
        cin >> P[i][1];
    }

    for(int i=0;i<M;i++){
        if(H[P[i][0]-1]>H[P[i][1]-1]){
            l[P[i][1]-1] = 1;
        }
        else if(H[P[i][0]-1]<H[P[i][1]-1]){
            l[P[i][0]-1] = 1;
        }
        else{
            l[P[i][1]-1] = 1;
            l[P[i][0]-1] = 1;
        }
    }
    for(int i=0;i<N;i++){
        //cout << l[i];
        if(l[i]==0) ans+=1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5160
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
#define PP pair<P,P>
using namespace std;

int main(){
    int n; cin >> n;
    double ans=0;
    rep(i,n){
        double x; string s; cin >> x >> s;
        if(s=="JPY") ans+=x;
        else ans+=x*380000.0;
    }
    cout << ans << endl;
return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
 
using namespace std;
using ll = long long;
 
 
int main() {
 
	ll N;
	cin >> N;
	
	vector<ll> d(N);
	
	rep(i, N){
		cin >> d[i];
	}
	
	sort(d.begin(), d.end());
	
	ll M, ans;
	M =(N + 1)/2;
	
	ans = d[M] - d[M-1];
	
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 4052
<?php
fscanf(STDIN, "%d %d", $N, $M);

$arr = [];
for ($n=0; $n<$N; $n++) {
    fscanf(STDIN, "%d %d", $A, $B);
    isset($arr[$A]) ? $arr[$A] += $B : $arr[$A] = $B;
}
ksort($arr);

$p = 0;
$c = 0;
foreach($arr as $k => $v){
  if ($c == $M) break;
  $min = min($v, $M-$c);
  $p += $k*$min;
  $c += $min;
}

echo intval($p);

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

#define PI 3.14159265359
//2の累乗数かどうか
bool hantei(int N) {
	bool flag = false;
	while (1) {
		if (N % 2 == 0) N /= 2;
	}
	if (N == 1) flag = true;

	return flag;
}
vector<ll> divisor(ll n){
	vector<ll> res;//約数を格納する列
	for(ll i= 1;i*i <= n;i++){
		if(n % i == 0){
		   res.push_back(i);
		   if(i != n/i) res.push_back(n/i);
		 }
	}
	return res;
}
vector<ll> v;//ルンルン数を格納する列

void bfs(vector<ll> &v, int K) {
	v = {1, 2, 3, 4, 5, 6, 7, 8, 9};
	queue<ll> que;

	for (int i = 1; i <= 9; i++) {
		que.push(i);
	}
	
	//queにルンルン数を追加
	while (1) {
		ll iTop = que.front();
		que.pop();
		for (int i = -1; i <= 1; i++) {

			int c = (iTop % 10) + i;//iTopのケツに付ける数
			if (c < 0 || c > 9) continue;

			que.push(10 * iTop + c);
			v.push_back(10 * iTop + c);
		}
		if (v.size() >= K) break;
	}
}

int main() {
	int K;
	cin >> K;
	bfs(v, K);
	sort(v.begin(), v.end());
	cout << v[K - 1] << endl;
}

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

void solve(long long D) {
  if (D == 25) cout << "Christmas" << endl;
  if (D == 24) cout << "Christmas Eve" << endl;
  if (D == 23) cout << "Christmas Eve Eve" << endl;
  if (D == 22) cout << "Christmas Eve Eve Eve" << endl;
}

int main() {
  long long D;
  scanf("%lld", &D);
  solve(D);
  return 0;
}


Measured memory_bytes: 256
//  Copyright © 2020 Diego Garcia Rodriguez del Campo. All rights reserved.
#include<bits/stdc++.h>
#define MAX 200005
#define optimiza_io cin.tie(0); ios_base::sync_with_stdio(0);
using namespace std;
typedef long long ll;

ll N, M;

int main()
{
    optimiza_io
    cin >> N >> M;
    ll l = 1, r = N;
    
    if( N % 2 == 0 ) {
        ll l = 1, r = N/2;
        while( l < r ) {
            if( M ) {
                M--;
                cout << l << " " << r << "\n";
            }
            l++;
            r--;
        }
        l = N/2+1;
        r = N-1;
        while( l < r ) {
            if( M ) {
                M--;
                cout << l << " " << r << "\n";
            }
            l++;
            r--;
        }
        return 0;
    }
    
    while( M -- ) 
        cout << l++ << " " << r-- << "\n";
    return 0;
}

// CHECAR LIMITES 

Measured memory_bytes: 3652
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    ll INF = 1e9+7;
    ll MOD = 998244353;
    typedef pair<ll,ll> ii;
    #define f(i,a,b) for(long long i = a;i < b;i++)
    #define rf(i,a,b) for(long long i=a;i>=b;i--)
    #define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #define w(t) while(t--)
    #define c(n); cin>>n;
    #define p(n) cout<<n;
    #define pl(n) cout<<n<<endl;
    #define ps(n); cout<<n<<" ";
    #define F first
    #define S second
    #define pb(a) push_back(a)
    ///I hope I will get uprating and don't make mistakes
    ///I will never stop programming
    ///sqrt(-1) Love C++
    /// @TheofanisOrfanou Theo830
    ///AtCoder Beginner Contest 148
    int main(void){
        fastio;
        ll n;
        c(n);
        ll arr[n];
        ll last = 0;
        f(i,0,n){
            c(arr[i]);
            if(arr[i] == last+1){
                last++;
            }
        }
        if(last == 0){
            pl(-1);
            return 0;
        }
        pl(n-last);
    }


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int H, W, d;
char C[4] = {'R', 'G', 'B', 'Y'};
int main() {
	cin >> H >> W >> d;
	int cx, cy;
	int color;
	for(int iy = 0; iy < H; iy++) {
		for(int ix = 0; ix < W; ix++) {
			cx = ix + iy + 10000, cy = ix - iy + 10000;
			color = (cx / d) % 2 + ((cy / d) % 2) * 2;
			cout << C[color];
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;

int main() {
  int k;
  cin >> k;
  vector<int> node(k, 1e9);
  deque<int> dq;
  dq.push_front(1);
  node[1] = 1;
  while (true) {
    int now = dq.front();
    if (now == 0) {
      cout << node[0] << endl;
      return 0;
    }
    dq.pop_front();
    if (node[(now * 10) % k] > node[now]) {
      dq.push_front((now * 10) % k);
      node[(now * 10) % k] = node[now];
    }
    if (node[(now + 1) % k] > node[now] + 1) {
      dq.push_back((now + 1) % k);
      node[(now + 1) % k] = node[now] + 1;
    }
  }
}

Measured memory_bytes: 896
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), cout, ", ") << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, ostream &os = cout, string sep = " ")
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), os, ", ") << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    AIN(ll, A, N - 1);
    vi dp(N + 1);
    FOR(a, A)
    {
        ++dp[a];
    }
    REP1(i, N)
    {
        OUT(dp[i]);
    }
}

Measured memory_bytes: 6428
#include<cstdio>
#include<cstring>
using namespace std;
int main(void){
	char s[100000];
	int i;
	int n;
	scanf("%s",s);
	n=strlen(s);
	for(i=0;i<n;i++)	if((i+1)%2!=0)	printf("%c",s[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    
    public static final int MOD = (int)1e9+7;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int x = Integer.parseInt(sc.next());
        
        Rikai[] sanko = new Rikai[n];
        for(int i=0; i<n; i++){
            int cost = Integer.parseInt(sc.next());
            int[] a = new int[m];
            for(int j=0; j<m; j++){
                a[j] = Integer.parseInt(sc.next());
            }
            sanko[i] = new Rikai(cost,m,x,a);
        }
        
        ArrayList<Rikai>[] dp = new ArrayList[n+1];
        for(int i=0; i<=n; i++){
            dp[i] = new ArrayList<>();
        }
        dp[0].add(new Rikai(0,m,x,new int[m]));
        
        int ans = (int)1e9;
        for(int i=0; i<=n; i++){
            for(Rikai tmp : dp[i]){
                if(i<n){
                    dp[i+1].add(tmp.kounyu(sanko[i]));
                    dp[i+1].add(tmp);
                }
                ans = Math.min(ans, tmp.cost());
            }
        }
        
        if(ans < (int)1e9){
            System.out.println(ans);
        }else{
            System.out.println(-1);
        }
        
    }
    
    
}

class Rikai{
    public int cost,m,x;
    public int[] rikaido;
    
    public Rikai(int cost, int m, int x, int[] rikaido){
        this.cost = cost;
        this.m = m;
        this.x = x;
        this.rikaido = new int[m];
        for(int i=0; i<m; i++){
            this.rikaido[i] = rikaido[i];
        }
    }
    
    public Rikai kounyu(Rikai z){
        int[] newrikaido = new int[m];
        for(int i=0; i<m; i++){
            newrikaido[i] += this.rikaido[i];
            newrikaido[i] += z.rikaido[i];
        }
        int newcost = this.cost + z.cost;
        return new Rikai(newcost,m,x,newrikaido);
    }
    
    public int cost(){
        for(int tmp : rikaido){
            if(tmp<x){
                return (int)1e9;
            }
        }
        return cost;
    }
}


Measured memory_bytes: 28632
#include<bits/stdc++.h>
#define N 200005
#define oo 0x7fffffff
#define ll_inf 0x7fffffffffffffff
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ren(i,n) for(int i=0;i<(n);i++)
#define abs(x,y) ((x)>(y)?(x)-(y):(y)-(x))
#define fi first
#define se second
#define pb push_back

using namespace std;

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


int t,n,m,k,nn;
int a[N]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
ll dap;
map<int,int> aa;

int main(void){
	int x=0,y,z;
	//freopen("in.txt","r",stdin);
	scanf("%d",&n);

	printf("%d",a[n-1]);


	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n;
    cin >> n;
    int a[n + 1], x[n + 1] = {0};
    repi(i, n, 0)
    {
        cin >> a[i];
        if (i % 2)
            x[0] -= a[i];
        else
            x[0] += a[i];
    }
    a[n] = a[0];
    cout << x[0] << endl;
    repi(i, n, 1)
    {
        x[i] = 2 * a[i - 1] - x[i - 1];
        cout << x[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include<bits/stdc++.h>
 
using namespace std;
 
int main() {
    int n , i , j , k , v[3] = {0}, a[3];
    cin>>n;
    for(i=0;i<n;i++) 
    {
        for(j = 0;j<3;j++)cin>>a[j];

        int x[3] = {0};
        for(k = 0;k<3;k++)
        {
            for(j = 0;j<3;j++)
            {
                if(k!=j)
                x[k] = max(x[k],v[j]+a[k]);
            }
        }
        for(j = 0;j<3;j++)v[j]= x[j];
    }
    cout<<max(max(v[0],v[1]),v[2]);
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] h = new int[N];
		for (int i = 0; i < N; i++)
			h[i] = sc.nextInt();
		Arrays.sort(h);
		int min = Integer.MAX_VALUE;
		for (int i = 0; i <= N-K; i++)
			min = Math.min(min, h[i + K - 1] - h[i]);

		System.out.println(min);

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 24712
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	for (int i = 0; i < 5; i++)
	{
		int x;
		cin >> x;

		if (x == 0)
		{
			cout << i + 1;
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 3660
#include<iostream>
using namespace std;
int main(){
  int h1, m1, s1, h2, m2, s2;
  while(cin >> h1 >> m1 >> s1 >> h2 >> m2 >> s2){
    int tim = h2 * 3600 + m2 * 60 + s2 - h1 * 3600 - m1 * 60 - s1;
    cout << tim / 3600 << " " << tim % 3600 / 60 << " " << tim % 60 << endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl
#define show2(a, n, m) rep(i, n) { rep(j, m) {cout << a[i][j] << ' ';} cout << endl;} 
#define chmin(a, b) a = min(a, b)
#define chmax(a, b) a = max(a, b)

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<long long, long long> pll;
typedef long double ld;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

vector<vi> g;
vi dp;
int n;

int dfs(int s) {
	if(dp[s] != -1) return dp[s];
	int ret = 0;
	for(auto i: g[s]) chmax(ret, dfs(i) + 1);
	return dp[s] = ret;
}

int main() {
//	cout << fixed << setprecision(15);
	int m;
	cin >> n >> m;
	g = vector<vi>(n);
	rep(i, m) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		g[x].push_back(y);
	}
	dp = vi(n, -1);
	int ans = 0;
	rep(i, n) chmax(ans, dfs(i));
	cout << ans << endl;
}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
#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 RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;
int ans;

void bubblesort(vector<int>& a){
    REP(i,a.size()){
	for(int j=0;j<a.size()-1;j++){
	    if(a[j] > a[j+1]){
		swap(a[j],a[j+1]);
		ans++;
	    }
	}
    }
}

int main(){
    while(true){
	int n;
	vector<int> a;
	ans = 0;
	cin >> n;
	if(n == 0) break;
	REP(i,n){
	    int temp;
	    cin >> temp;
	    a.PB(temp);
	}
	bubblesort(a);
	cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
#define int long long
using namespace std;
int x;
string s;
signed main()
{
	cin>>x>>s;
	if(x<s.size())
	{
		for(int i=0;i<x;i++)
		printf("%c",s[i]);
		printf("...");
		return 0;
	}
	cout<<s;
    return 0;
}

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

const int MAXN = 1 << 18; // 2.6e5
int N = 200000, n, a[200000], h[200000];
long long int seg[2 * MAXN]; // root is seg[1]

void update(int p, long long int val)
{
    for (seg[p += N] = val; p > 0; p >>= 1)
        seg[p >> 1] = max(seg[p], seg[p ^ 1]);
}

long long int query(int l, int r) // [l, r]
{
    long long int res = 0;
    for (l += N, r += N; l <= r; l >>= 1, r >>= 1)
    {
        if (l & 1)
            res = max(res, seg[l++]);
        if (!(r & 1))
            res = max(res, seg[r--]);
    }
    return res;
}

int main() {
    cin >> n;
    for(int i = 0; i < n; ++i)
        cin >> h[i];
    for(int i = 0; i < n; ++i)
        cin >> a[i];
    for(int i = 0; i < n; ++i) {
        update(h[i], query(1, h[i] - 1) + a[i]);
    }
    cout << query(1, MAXN) << endl;
    return 0;
}

Measured memory_bytes: 5888
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

long long MOD = 1e9+7;
int MAX_INT = 1e9;

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

  int X;
  cin >> X;
  for(int i = 0; i < X + 1; i++) {
    int rest = X - i * 100;
    if(0 <= rest && rest <= 5*i) {
      cout << 1 << endl;
      return 0;
    }
    if(rest < 0) break;
  }
  cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 3508
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}
int dp[1<<16][16];

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n-1){
        int s,t,c;
        cin >> s >> t >> c;
        a[s]^=c;
        a[t]^=c;
    }
    int sm = 0;
    vector<int> c(16);
    rep(i,n){
        c[a[i]]++;
    }
    cerr << endl;
    for(int i=1;i<16;i++){
        sm += c[i]/2;
        c[i]%=2;
    }
    int tar = 0;
    for(int i=1;i<16;i++){
        tar ^= (c[i]<<(i-1));
    }
    Fill(dp,inf);
    dp[0][0] = 0;
    for(int bits=0;bits<(1<<16);bits++){
        for(int i=0;i<16;i++){
            for(int j=1;j<16;j++){
                if((bits>>(j-1))&1)continue;
                if(i==j){
                    chmin(dp[bits^(1<<(j-1))][i^j],dp[bits][i] );
                
                }else{
                    chmin(dp[bits^(1<<(j-1))][i^j],dp[bits][i] + 1);
                }
            }
        }
    }
    int ss = dp[tar][0];
    cout << sm + ss  << endl;
    
    return 0;
}

Measured memory_bytes: 4864
//Name: Dividing Snacks
//Level: 3
//Category: DP,動的計画法
//Note:

/*
 * ブロックを左から順にA,Bに割り振っていき，AをN/2個取ることを考える．
 * i番目のブロックをAにするとき，
 * ・i-1番目がAなら追加コスト0(ただし，これがちょうどN/2個目のときは直後で切断しないといけない)
 * ・i-1番目がBなら追加コストcost[i-1]
 * i番目のブロックをBにするとき，
 * ・i-1番目がAなら追加コストcost[i-1]
 * ・i-1番目がBなら追加コスト0
 * で割り振ることができる．
 * よって状態は，
 * ・直前のブロックをAとBどちらにしたか
 * ・あといくつAを取れば良いか
 * で定められるから，各状態について最小コストを覚えながらDPする．
 */
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

inline bool update(int &a, int v) {
    if(a < v) return false;
    a = v;
    return true;
}
// dp[ptr][which][need]
// which: A=0, B=1
// need: remaining of A
int dp[2][2][5001];
const int INF = 10000*10000;

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

    int N;
    cin >> N;
    vector<int> cost(N-1);
    for(int i = 0; i < N-1; ++i) {
        cin >> cost[i];
    }
    int ans = INF;
    int ptr = 0;
    fill_n(dp[ptr][0], N/2+1, INF);
    fill_n(dp[ptr][1], N/2+1, INF);
    dp[ptr][0][N/2-1] = 0;
    dp[ptr][1][N/2] = 0;
    ptr ^= 1;
    for(int i = 1; i < N; ++i) {
        int prev = ptr ^ 1;
        fill_n(dp[ptr][0], N/2+1, INF);
        fill_n(dp[ptr][1], N/2+1, INF);
        for(int j = 0; j <= N/2; ++j) {
            // 直前がAのとき
            if(j+1 <= N/2) update(dp[ptr][0][j], dp[prev][0][j+1]);
            update(dp[ptr][1][j], dp[prev][0][j] + cost[i-1]);
            
            // 直前がBのとき
            if(j+1 <= N/2) update(dp[ptr][0][j], dp[prev][1][j+1] + cost[i-1]);
            update(dp[ptr][1][j], dp[prev][1][j]);

            // ここで残りが0になるなら，直後で切らないといけない
            if(j == 0) {
                if(i < N-1) dp[ptr][0][j] += cost[i];
            }
            //cout << j << ": " << dp[ptr][0][j] << ' ' << dp[ptr][1][j] << endl;
        }
        update(ans, min(dp[ptr][0][0], dp[ptr][1][0]));
        ptr ^= 1;
    }
    cout << ans << endl;
    return 0;
}

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

#define MAX_NUM (1000000000 + 7)

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

int main() {
  cout << setprecision(15);
  u32 A, B;
  cin >> A >> B;
  u32 res = 0;
  for (u64 i = 1; i <= 1250; ++i) {
    if ((u32)(i * 0.08) == A && (u32)(i * 0.1) == B) {
      res = i;
      break;
    }
  }
  if (res == 0)
    cout << -1 << endl;
  else
    cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double dp[3001][3001] , x , v[3000];
int n;
main(){ios::sync_with_stdio(false),cin.tie(0);
	cin >> n;
	for(int i=1 ; i<=n ; ++i) cin >> v[i];
	for(int i=0 ; i<=n ; ++i) dp[0][i] = 1;
	for(int i=1 ; i<=n ; ++i)
		for(int j=1 ; j<=n ; ++j)
			dp[i][j] = dp[i-1][j-1]*v[j] + dp[i][j-1]*(1-v[j]);
	cout << fixed << setprecision(10) <<dp[n%2?n/2+1:n/2][n];
}

Measured memory_bytes: 70656
using System;
using System.Text; 
using System.Collections.Generic;
using System.Linq;

public class Remainder
{
    static public void Main ()
    {
        //var NM = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        var X = long.Parse(Console.ReadLine());
        long ans = X/11*2;
        
        if(X%11 == 0){
            
        }else if(X%11 <= 6){
            ans++;
        }else{
            ans += 2;
        }
        
        
        
        Console.WriteLine(ans);

    }

}


Measured memory_bytes: 13140
#include <stdio.h>
#define min(X, Y) ((X) < (Y) ? (X) : (Y))

int main()
{
	int a, b, k;
	int div;
	int cnt = 0;

	scanf("%d %d %d", &a, &b, &k);

	for (div = min(a, b); div >= 1; div--) {
		if (a % div == 0 && b % div == 0) {
			cnt++;

			if (cnt == k) {
				printf("%d\n", div);

				return 0;
			}
		}
	}


	return 0;
}


Measured memory_bytes: 128
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
      InputStream inputStream = System.in;
      OutputStream outputStream = System.out;
      Scanner sc = new Scanner(inputStream);
      PrintWriter out = new PrintWriter(outputStream);
      int N = Integer.parseInt(sc.next());
      int bit = 0;
      for(int i = 0; i < N; i++){
      	bit |= Integer.parseInt(sc.next());
      }
      out.println(Integer.numberOfTrailingZeros(bit));
      out.close();
    }
}

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

using namespace std;

bool m[3][3];
map<int, pair<int,int> > mp;
int main() {

    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            int x;
            cin >> x;
            mp[x] = {i,j};
        }
    }

    int n;
    cin >> n;
    while(n--) {
        int x;
        cin >> x;
        if(!mp.count(x)) continue;
        m[mp[x].first][mp[x].second] = 1;
    }

    bool flag = 0;
    for (int i = 0; i < 3; ++i) {
        bool f = 1;
        bool f2 = 1;
        for (int j = 0;j < 3; ++j) {
            f &= m[i][j];
            f2 &= m[j][i];
        }
        flag |= f;
        flag |= f2;
    }

    flag |= (m[0][0] and m[1][1] and m[2][2]);
    flag |= (m[0][2] and m[1][1] and m[2][0]);
    puts(flag ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define fast_in ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mp  make_pair
#define pb  push_back
#define  sz(x)   (int)x.size()
#define  all(x)  x.begin(), x.end()
#define	 allr(x)  x.rbegin(), x.rend()
#define  bit(x)  __builtin_popcountll(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int,int> pii;
const int inf = (int) 1e9+99999, mod = (int)1e9+7;
const ll linf = (ll) 2e18+99999;
int mul (int x, int y) { return ((ll)x * y) % mod; } 
int sub (int x, int y) { x -= y; if (x < 0) return x + mod; return x; } 
int add (int x, int y) { x += y; if (x >= mod) return x - mod; return x; }
 
const int maxn = (int) 3e5;
 
#define int ll

ll bp (ll n, int k) {
	ll res = 1;
	while (k) {
		if (k % 2 == 1)
			res *= n;
		k /= 2;
		n *= n;
	}
	return res;
}

ll solve () {
	ll n; cin >> n;
	if (n % 2 == 1) return 0;

	ll res = 0;
	ll k = 1;
	while (true) {
		res += n / (bp (5, k) * 2);	

		if (bp (5, k + 1) > n) break;
		k ++;
	}

	return res;
}

main () { fast_in;
    int t = 1; //cin >> t;
    while (t --) {
    	cout << solve () << endl;    
    }
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <queue>
using namespace std;
int main(){
int n,ans;
while(cin>>n && n>0){
ans=0;
for(int i=2;i<n;i++){
if(i%2==0){
if((2*n)%i==0 && n%i!=0 && n/i-i/2>=0 ) ans++;
}
else {
if(n%i==0 && n/i>i/2) ans++;

}


}
cout<<ans<<endl;

}



return 0;
}

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

signed main(){
  char A,B;
  cin>>A>>B;
  int AA=A-'A';
  int BB=B-'B';
  if(A>B)cout<<">"<<endl;
  else if(A<B)cout<<"<"<<endl;
  else cout<<"="<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>

int binarySearch(int*,int,int);

int main(){
  int n,q,i,j;
  int s[100000],t,f=0;

  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&s[i]);

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&t);
    if(binarySearch(s,t,n))f++;
  }
  
  printf("%d\n",f);
  
  return 0;
}

int binarySearch(int A[],int t,int n){
  int i;
  int l = 0, r = n, mid;

  while(l<r){
    mid = (l + r)/2;
    if(A[mid] == t)return 1;
    else if(t < A[mid])r = mid;
    else l = mid + 1;
  }
 
  return 0; 
}

Measured memory_bytes: 992
#include<bits/stdc++.h>
using namespace std;
long long n,W,dp[103][100005],w[105],v[105];
int main(){
	cin>>n>>W;
	for(int i=0;i<n;i++)cin>>w[i]>>v[i];
	for(int i=w[0];i<=W;i++)dp[0][i-w[0]]=v[0];
	for(int i=1;i<n;i++){
		for(int j=0;j<=W;j++)
			dp[i][j]=dp[i-1][j];
		for(int j=0;j<=W-w[i];j++)
			dp[i][j]=max(dp[i][j],dp[i-1][j+w[i]]+v[i]);
	}
	cout<<dp[n-1][0];
}


Measured memory_bytes: 80128
MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort!{|x,y|y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n,m=gsmi
a=gsmi.sort

# "増える量がX以上となるのがmとなる" Xを二分探索で探す O(N(logN)^2)
# lは条件を満たす、rは条件を満たさない(X=lとなる)
l=0
r=2*10**5+1
while l+1!=r do
  cen=(l+r)/2
  #puts "l:#{l},r:#{r},cen:#{cen}"
  # TODO必要ならbreak文
  cnt=0
  n.times do |i|
    i2=cen-a[i]
    idx=a.bsearch_index{|x|x>=i2}
    next if idx.nil?

    c=(n-1)-idx+1
    cnt+=c
    # M以上組み合わせがあるならbreak
    break if cnt>=m
  end

  if cnt>=m
    #OKなので右へ
    l=cen
  else
    r=cen
  end
end

# 累積和
ruisum=[0]
n.times do |i|
  ruisum<< ruisum[-1]+a[i]
end
#puts ruisum.to_s

# 合計を求める
sum=0
cnt=0
n.times do |i|
  i2=l-a[i]
  idx=a.bsearch_index{|x|x>=i2}
  next if idx.nil?

  c=(n-1)-idx+1
  cnt+=c

  rui=ruisum[n]-ruisum[idx]
  s=c*a[i]+rui
  sum+=s
end

# 余分に加えた分を補正
puts sum-l*(cnt-m)


Measured memory_bytes: 14124
#include<stdio.h>
#include<stdlib.h>
int connect[100000];

int topreturn(int n){
	while(connect[n]!=n)n=connect[n];
	return n;
}

int main(void){
	int n,m,x,y,i,tmp,p[100000];
	scanf("%d%d",&n,&m);
	for(i=0;i<n;++i){
		scanf("%d",&p[i]);
		connect[i]=i;
	}
	for(i=0;i<m;++i){
		scanf("%d%d",&x,&y);
		x=topreturn(x-1);
		y=topreturn(y-1);
		if(x>y){tmp=x;x=y;y=tmp;}
		connect[y]=connect[x];
	}
	tmp=0;
	for(i=0;i<n;++i)
		if(topreturn(i)==topreturn(p[i]-1))++tmp;
	printf("%d\n",tmp);
	return 0;
}

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

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

    int i = 0, j = s.size()-1;
    while(i<j){
        if(s[i] != s[j]){
            cout << "No";
            return 0;
        }
        ++i;
        --j;
    }
    cout << "Yes";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 500000
#define X 998244353
#define swap(x,y) (x^=y^=x^=y)
#define Qinv(x) Qpow(x,X-2)
#define A(x,y) (1LL*Fac[x]*IFac[(x)-(y)]%X)
#define C(x,y) (1LL*A(x,y)*IFac[y]%X)
#define Inc(x,y) ((x+=(y))>=X&&(x-=X))
using namespace std;
int n,m,Fac[N+5],IFac[N+5],Pn[N+5],Pm[N+5];
I int Qpow(RI x,RI y) {RI t=1;W(y) y&1&&(t=1LL*t*x%X),x=1LL*x*x%X,y>>=1;return t;}
int main()
{
	RI i,t,ans=0;scanf("%d%d",&n,&m),n>m&&swap(n,m);
	for(Fac[0]=Pn[0]=Pm[0]=i=1;i<=m;++i)
		Fac[i]=1LL*Fac[i-1]*i%X,Pn[i]=1LL*Pn[i-1]*(n+1)%X,Pm[i]=1LL*Pm[i-1]*(m+1)%X;
	for(IFac[m]=Qinv(Fac[m]),i=m-1;~i;--i) IFac[i]=1LL*IFac[i+1]*(i+1)%X;
	for(i=0;i<=n;++i) t=1LL*C(n,i)*A(m,i)%X*Pn[m-i]%X*Pm[n-i]%X,Inc(ans,i&1?X-t:t);
	return printf("%d",ans),0;
}

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

int main()
{
    std::vector<bool> is_prime(3);
    is_prime.at(0) = is_prime.at(1) = false;
    is_prime.at(2) = true;

    int n, n_max = 1;
    int cnt;
    while (std::cin >> n) {
        if (n_max < n) {
            is_prime.resize(n + 1, true);

            for (auto i = 2; i <= n / 2; i++) {
                if (is_prime.at(i) == true) {
                    for (auto j = 2 * i; j <= n; j += i) {
                        is_prime.at(j) = false;
                    }
                }
            }

            n_max = n;
        }

        cnt = 0;
        for (auto i = 2; i <= n; i++) {
            if (is_prime.at(i) == true) {
                cnt++;
            }
        }

        std::cout << cnt << std::endl;
    }

    return 0;
}

Measured memory_bytes: 1344
#include <iostream>
using namespace std;
int main() {
	int A, B, C, D;
	int sq1, sq2;
	cin >> A >> B >> C >> D;
	sq1 = A*B;
	sq2 = C*D;
	if (sq1>sq2)
	{
		cout << sq1 << endl;
	}
	else {
		cout << sq2 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template <class T, class U>ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T>ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "{";
	rep(i, v.size()) {
		if (i) os << ",";
		os << v[i];
	}
	os << "}";
	return os;
}
template <class T, class U>istream& operator>>(istream& is, pair<T, U>& p) {
	is >> p.first >>p.second ;
	return is;
}
template <class T>istream& operator>>(istream& is,  vector<T>& v) {
	rep(i, v.size()) {
		is >> v[i];
	}
	return is;
}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=0;
	cin >>n;
	V a(n+2,0LL);
	rep(i, n) { cin >> a[i + 1]; }
	ll cnt = 0LL;
	rep(i, a.size()) {
		if(i==0){
			continue;
		}
		 cnt += abs(a[i - 1] - a[i]);
		  }
	      clog << cnt<<endl;

	      for (int i = 1; i < n + 1;i++){
		      cout << (cnt - abs(a[i] - a[i - 1]) - abs(a[i] - a[i + 1]) +
		               abs(a[i - 1] - a[i + 1]))<<endl;
	      } }

Measured memory_bytes: 4060
import sys
L,R=map(int, sys.stdin.readline().split())
sho1=(L-1)/2019
sho2=R/2019
if 1<=sho2-sho1:
    print 0
else:
    ans=float("inf")
    for i in range(L,R):
        for j in range(i+1,R+1):
            ans=min(ans,i*j%2019) 
    print ans

Measured memory_bytes: 29676
import java.util.*;
//import java.lang.Math;
public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        String S=sc.nextLine();
        int N=S.length();
        char C[]=S.toCharArray();
        for(int i=0;i<N;i++){
            if(Character.isUpperCase(C[i])){
                C[i]+=32;
                System.out.print(C[i]);
            }
            else if(Character.isLowerCase(C[i])){
                C[i]-=32;
                System.out.print(C[i]);
            }
            else System.out.print(C[i]);
        }
        System.out.println();
    }
}


Measured memory_bytes: 26860
num = 0
nm1 = [int(x) for x in input().split()]

if nm1[0] == 1 and nm1[1] == 1:
    print(nm1[0])
elif nm1[0] == 1:
    print(nm1[1]-2)
elif nm1[1] == 1:
    print(nm1[0]-2)
else:
    print((nm1[0]-2)*(nm1[1]-2))


Measured memory_bytes: 3060
import sys
s=[list(map(int,e.split(',')))for e in sys.stdin]
for i in range(1,len(s)):
 k=len(s[i]);b=k>len(s[i-1])
 for j in range(k):s[i][j]+=max(s[i-1][(j-b)*(j>0):j-b+2])
print(*s[-1])


Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,flag=0;
  cin>>n;
  	
  for(int i=0;i<26;i++){
	for(int j=0;j<15;j++){
		if(n==4*i+7*j && n>=4){
			flag=1;
        }
    }
  }

  	if(flag==1){
		cout<<"Yes"<<endl;
    }else{
		cout<<"No"<<endl;
    }
}

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

using namespace std;

int main() {
    int n;
    vector<pair<string, int>> array, copy;

    cin >> n;
    array.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> array[i].first >> array[i].second;
    }
    copy = array;
    sort(array.begin(), array.end());

    for (int j = 0;j < array.size() - 1;j++){
        if (array[j].first == array[j + 1].first) {
            int num = 1;
            while (true) {
                if (j + num >= array.size()) {
                    break;
                }
                else if (array[j].first != array[j + num].first) {
                    break;
                }
                num++;
            }
            partial_sort(array.begin() + j, array.begin() + j + num, array.begin() + j + num, greater<pair<string, int>>());
        }
    }

    for (int k = 0; k < array.size(); k++) {
        int m = 0;
        while (copy[m] != array[k]) {
            m++;
        }
        cout << m + 1 << endl;
    }
    return 0;
}


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

int main(){
	int N;
	cin>>N;
	string s;
	cin>>s;
	int cnt=0,x=0;
	for(int i=0;i<N;i++){
		if(s[i]=='R') cnt++;
		else x++;
	}
	if(cnt>x) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
} 

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

using namespace std;

#define MAXN 100010
typedef long long LL;

int n, m, c[15][15];
LL f[15][33000], g[33000], sum;

int main( int argc , char * argv[] ){
//	freopen( "input.txt" , "r" , stdin );
//	freopen( "output.txt" , "w" , stdout );
    memset(f, -0x3f, sizeof(f));
    int i, j, k, u, v, d, t;
    scanf("%d %d", &n, &m);
    for(i = 1; i <= m; ++i){
        scanf("%d %d %d", &u, &v, &d);
        --u; --v; sum += d;
        c[u][v] = c[v][u] = d;
    }
    t = 1 << n; f[0][1] = 0;
    for(i = 1; i < t; ++i)
        for(u = 0; u < n; ++u){
            if(!((i >> u) & 1)) continue;
            for(v = u + 1; v < n; ++v){
                if(!((i >> v) & 1)) continue;
                if(!c[u][v]) continue;
                g[i] += c[u][v];
            }
        }

    for(i = 1; i < t; ++i){
        for(u = 0; u < n; ++u){
            if(!((i >> u) & 1)) continue;
            if(f[u][i] < 0) continue;
            for(j = k = (t - 1) ^ i; j; j = (j - 1) & k)
                f[u][i | j] = max(f[u][i | j], f[u][i] + g[j | (1 << u)]);
        }

        for(u = 0; u < n; ++u){
            if(!((i >> u) & 1)) continue;
            if(f[u][i] < 0) continue;
            for(v = 0; v < n; ++v){
                if((i >> v) & 1) continue;
                if(!c[u][v]) continue;
                f[v][i | (1 << v)] = max(f[v][i | (1 << v)], f[u][i] + c[u][v]);
            }
        }
    }
    printf("%lld\n", sum - f[n - 1][t - 1]);
	return 0;
}


Measured memory_bytes: 4352