akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using in6 = int64_t;
using ind = double;
using pii = pair<int,int>;
using psi = pair<string,int>;
using vpi = vector<pii>;
using vps = vector<psi>;
#define rep(i, n) for (in6 i = 0; i < (in6)(n); i++)
#define repa(i,a,n) for(in6 i = a; i < (in6)(n); i++)
#define repdown(i,n) for(in6 i = n; i > 0; i--)
#define kyun ios::sync_with_stdio(false)
#define hinata cout << "\n"
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define inf 2147483647
#define dset(n) cout << fixed << setprecision(n)

void yes() {
  cout << "Yes";
}

void no() {
  cout << "No";
}

int main() {
  kyun;
  int n;
  cin >> n;
  int a,b;
  a = n % 100;
  b = n / 100;
  if(1 <= a && a <= 12) {
    if(1 <= b && b <= 12) cout << "AMBIGUOUS";
    else cout << "YYMM";
  }
  else {
    if(1 <= b && b <= 12) cout << "MMYY";
    else cout << "NA";
  }
  hinata;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,x,y;cin>>a>>b>>c>>x>>y;
  cout<<min(a*x+b*y,min(2*c*x+b*max(y-x,0),2*c*y+a*max(x-y,0)));
  
}

/*


*/

Measured memory_bytes: 3620
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

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 T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int N;
int A[210000];

long long MOD = 1000000007;

int main() {
  while (cin >> N) {
	map<int,int> ma;
	for (int i = 0; i < N; ++i) cin >> A[i], ma[A[i]]++;

	bool ok = true;
	if (N % 2 == 1) if (ma[0] != 1) ok = false;
	int start = 1;
	if (N % 2 == 1) start = 2;
	for (; start < N; start += 2) if (ma[start] != 2) ok = false;

	if (!ok) cout << 0 << endl;
	else {
	  long long res = 1;
	  for (int i = 0; i < N/2; ++i) {
		res *= 2;
		res %= MOD;
	  }
	  cout << res << endl;
	}
  }
}


Measured memory_bytes: 4480
import sys, io, os, re
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from pprint import pprint
from math import sin, cos, pi, radians, sqrt, floor, ceil
from copy import copy, deepcopy
from collections import deque
from fractions import gcd
from functools import reduce
from itertools import groupby
from heapq import heapify, heappush, heappop

# sys.setrecursionlimit(5000)

n1 = lambda: int(sys.stdin.readline().strip())
nn = lambda: list(map(int, sys.stdin.readline().strip().split()))
f1 = lambda: float(sys.stdin.readline().strip())
fn = lambda: list(map(float, sys.stdin.readline().strip().split()))
s1 = lambda: sys.stdin.readline().strip()
sn = lambda: list(sys.stdin.readline().strip().split())
nl = lambda n: [n1() for _ in range(n)]
fl = lambda n: [f1() for _ in range(n)]
sl = lambda n: [s1() for _ in range(n)]
nm = lambda n: [nn() for _ in range(n)]
fm = lambda n: [fn() for _ in range(n)]
sm = lambda n: [sn() for _ in range(n)]

def array1(n, d=0): return [d] * n
def array2(n, m, d=0): return [[d] * m for x in range(n)]
def array3(n, m, l, d=0): return [[[d] * l for y in xrange(m)] for x in xrange(n)]
def linc(A, d=1): return map(lambda x: x + d, A)
def ldec(A, d=1): return map(lambda x: x - d, A)

N = n1()

ans = 1000-N%1000
if ans == 1000:
    ans = 0

print(ans)

Measured memory_bytes: 72888
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
using Graph = vector<vector<int>>;
int main() {
    int N, M; cin >> N >> M;
    Graph G(N);
    rep(i,M) {
        int a, b; cin >> a >> b;
        G[a-1].push_back(b-1);
        G[b-1].push_back(a-1);
    }
    vector<int> vec;
    for(int i = 0; i < N; i++) {
        vec.push_back(i);
    }
    int ans = 0;
    do {
        // cout << "===========" << endl;
        // cout << vec[0] << endl;
        if(vec[0] != 0) continue;
        // cout << vec[0] << endl;
        bool flag = true;
        for(int i = 0; i < N; i++) {
            if(i != (N-1)) {
                vector<int> mm = G[vec[i]];
                auto itr = find(mm.begin(), mm.end(), vec[i+1]);
                if(itr == mm.end()) flag = false;
            }
        }
        if (flag) ans++;

    } while(next_permutation(vec.begin(), vec.end()));
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int H, W;
string S[60];
struct point {
	int x, y;
};
int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
int d[60][60];
void bfs() {
	for (int i = 0; i < 60; i++) {
		for (int j = 0; j < 60; j++) {
			d[i][j] = mod;
		}
	}
	d[0][0] = 1;
	queue<point> que;
	que.push({ 0,0 });
	while (!que.empty()) {
		point now = que.front();
		que.pop();
		if (now.x == W - 1 && now.y == H - 1)break;
		for (int i = 0; i < 4; i++) {
			int nx = now.x + dx[i]; int ny = now.y + dy[i];
			if (nx >= 0 && nx < W && ny >= 0 && ny < H && d[ny][nx] == mod && S[ny][nx] == '.') {
				d[ny][nx] = d[now.y][now.x] + 1;
				que.push({ nx,ny });
			}
		}
	}
}
int main()
{
	cin >> H >> W;
	for (int i = 0; i < H; i++) cin >> S[i];
	int ans = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (S[i][j] == '.') ans++;
		}
	}
	bfs();
	if (d[H - 1][W - 1] == mod) cout << -1 << endl;
	else cout << ans - d[H - 1][W - 1] << endl;
}

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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			int k = sc.nextInt();
			if (n == 0) {
				break;
			}
			int[] dice = new int[n];
			Arrays.fill(dice, 1);
			long sum = 0;
			LOOP: while(true) {
				int bill = 0;
				for(int i=0;i<n;i++) {
					bill += dice[i];
				}
				bill = Math.max(1, bill - k);
				sum += bill;
				
				for(int i=0;i<n;i++) {
					dice[i]++;
					if (dice[i] > m) {
						dice[i] = 1;
						if (i == n - 1) {
							break LOOP;
						}
					}else{
						break;
					}
				}
			}
			double ans = sum * Math.pow(1D / m, n);
			System.out.printf("%.7f\n", ans);
		}
	}

}

Measured memory_bytes: 28072
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef pair<int, pii> pipii;
int s[200005], t[200005], x[200005], d[200005];
pipii p[200005];
int ans[200005];
set<pii> cur;
set<pii>::iterator its, its2;
int main(){
    memset(ans, -1, sizeof(ans));
    int n, q;
    scanf("%d%d", &n, &q);
    for(int i=1;i<=n;i++){
        scanf("%d%d%d", &s[i], &t[i], &x[i]);
        p[i] = pipii(x[i], pii(s[i], t[i]));
    }
    sort(p+1, p+1+n);
    for(int i=1;i<=q;i++){
        scanf("%d", &d[i]);
        cur.insert(pii(d[i], i));
    }
    for(int i=1;i<=n;i++){
        int x = p[i].first, s = p[i].second.first, t = p[i].second.second;
        int l = s-x, r = t-1-x;
        its = cur.lower_bound(pii(l, 0));
        while(its != cur.end() && its->first <= r){
            int j = its->second;
            ans[j] = x;
            its2 = its;
            its2++;
            cur.erase(its);
            its = its2;
        }
    }
    for(int i=1;i<=q;i++) printf("%d\n", ans[i]);
}

Measured memory_bytes: 17536
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, S: "List[str]"):
    from collections import Counter
    c = Counter(S)
    ans = []
    t = c.most_common()[0][1]
    # print(t)
    for k,v in c.most_common():
        if v == t:
            ans.append(k)

    # print(ans)
    ans.sort()
    for i in ans:
        print(i)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = [next(tokens) for _ in range(N)]  # type: "List[str]"
    solve(N, S)

if __name__ == '__main__':
    main()


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

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

using namespace std;
using ll = long long;

int done[100][100];
pair<int, int> vec[4] = {make_pair(0, 1), make_pair(1, 0), make_pair(0, -1), make_pair(-1, 0)};
int vecidx = 0;

bool solve(int H, int W, int x, int y);

int main(void){
    int H, W, N; cin >> H >> W >> N;
    pair<int, int> pos = make_pair(0, 0);
    int grid[H][W];
    rep(i, 100) rep(j, 100) done[i][j] = 0;

    rep(i, N){
        int temp; cin >> temp;
        rep(j, temp){
            grid[pos.first][pos.second] = i+1;
            done[pos.first][pos.second] = 1;
            if(solve(H, W, pos.first, pos.second)){
                if(vecidx == 3) vecidx = 0;
                else vecidx++;
            }
            pos.first += vec[vecidx].first; pos.second += vec[vecidx].second;
        }
    }
    rep(i, H){
        rep(j, W){
            cout << grid[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

bool solve(int H, int W, int x, int y){
    int next_x = x + vec[vecidx].first;
    int next_y = y + vec[vecidx].second;
    //範囲内かつまだ塗ってなかったら方向転換の必要なし
    if(0 <= next_x && next_x < H && 0 <= next_y && next_y < W && done[next_x][next_y] == 0) return false;
    else return true;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> A(N+1);
  vector<int> B(N);
  for(auto &i:A)cin >> i;
  for(auto &i:B)cin >> i;
  long long ans = 0;
  for (int i = 0; i < N; i++){
    ans += min(A[i], B[i]);
    B[i] -= A[i];
    if (B[i] > 0){
      ans += min(A[i+1],B[i]);
      A[i+1] = max(0, A[i+1]-B[i]);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int n;
	cin >> n;
	int one = n%10;
	int ten = n/10;
	if(one == 9 || ten == 9)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

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

int main() {
    int n, c; cin >> n >> c;
    int x = 100100;
    vector<vector<int>> ns(c, vector<int>(x, 0));
    for (int i=0; i<n; i++) {
        int s, t, c; cin >> s >> t >> c;
        ns[c-1][s]++;
        ns[c-1][t]--;
    }

    for (auto &arr: ns)
        for (int i=x-1; i>0; i--)
            if (arr[i-1] < 0) {
                arr[i] += arr[i-1];
                arr[i-1] = 0;
            }

    for (auto &arr: ns) {
        int s = 0;
        for (int i=0; i<x; i++) {
            s += arr[i];
            arr[i] = s;
        }
    }


    vector<int> ms(x, 0);
    for (int i=x-1; i>0; i--)
        for (auto &arr: ns)
            ms[i] += arr[i];

    /*
    for (auto &arr: ns) {
        for (int i=0; i<x; i++)
            cout << arr[i] << " ";
        cout << endl;
    }

    for (int i=0; i<x; i++)
        cout << ms[i] << " ";
    cout << endl;
    */
    cout << *max_element(ms.begin(), ms.end()) << endl;
}

Measured memory_bytes: 12536
/*

*/
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout << setprecision(12)
#define rep(i,a,n) for (ll i=a;i<n;i++)
#define per(i,a,n) for (ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((ll)(x).size())
#define cin1(x) cin >> x
#define cin2(x, y) cin >> x >> y
#define cin3(x, y, z) cin >> x >> y >> z
#define cin4(x, y, z, _) cin >> x >> y >> z >> _
#define cin5(x, y, z, p, q) cin >> x >> y >> z >> p >> q
#define cou(x) cout << x
#define cous(x) cout << x << " "
#define coul(x) cout << x << "\n"
#define ret(x) return x
#define MAX 1000000007
#define start int main() {   fastio
#define finish ret(0); }
#define Test ll _t; cin1(_t); rep(w, 0, _t)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cntv(v,a) count(v.begin(),v.end(),a)
#define fans(x) \
    if ( x  ) coul("YES"); \
    else coul("NO")
#define mset(x, y) memset(x, y, sizeof(x))
#define fileshow  freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)

struct point{    int x, y, ind;   char ch;  };
typedef long long ll;
typedef vector<ll> VI;
typedef pair<ll,ll> PII;
typedef double db;
//mt19937 mrand(random_device{}());
const ll mod=1000000007;
//ll rnd(ll x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}ret(res);}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll fact[13];
void factorial() {   fact[0]=1;  rep(i, 1, 12) fact[i]=(fact[i-1]*i);  }
 //for sieve function
//void sieve() {    rep(i, 2, MAX)  {  if (spf[i] == 0) {  spf[i] = i;   sie.pb(i);  }    for (ll j=0; j<SZ(sie) && i*sie[j] <= MAX && sie[j] <= spf[i]; j++)   spf[i * sie[j]] = sie[j]; }   }
bool cmp(point A, point B){   if(A.x != B.x) ret(A.x < B.x);  ret(A.y < B.y);   }
//void segPre(ll l, ll h, ll in) {  ll segTree[3*mx];   if ( l == h ){  segTree[ in ] = arr[ l ];   return;  }   ll m = (l + h) / 2; pre(l, m, 2*in);  pre(m+1, h, 2*in+1);    segTree[ in ] = segTree[ in*2 ] | segTree[ in*2+1 ];   segTree[ in ] = segTree[ in*2 ] ^ segTree[ in*2+1 ];    }
// head collected
// Don't use variable name as --> prev, time, _t, w, y1
// Don't use ceil and pow function

ll n, k, _, ans, q, _1, _2;


start;

    cin2(n, k);

    if ( k >= n )
        coul("unsafe");
    else
        coul("safe");

finish


/*
5 4
3 1 8 9 7
1 1 5
1 2 12
1 9 3
2 1 5


*/


Measured memory_bytes: 3660
N = int(input())
c = list(map(str,input()))
w = []
r = []
for i in range(N):
  if c[i] == 'W':
    w.append(i+1)
  else:
    r.append(i+1)
k = 0
W = len(w)
R = len(r)
L = min([W,R])
for i in range(L):
  if w[i] < r[R - i - 1]:
    k += 1
print(k)    

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

using namespace std;
#define int long long 

int32_t main(){

    string a,b;
    cin>>a>>b;
    a+= b;
    int p = stoi(a);
  
    int i = 1;
    while( i*i <p ){
        i++;
    }
    if(i*i == p ) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<double,double> point;
const ll MAX = 30000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n),b(n),p(n);
    rep(i,n){
        cin >> p[n-i-1];
        p[n-i-1]--;
        a[i] = i+1;
        b[i] = n-i;
    }
    vector<ll> u(n+1,0),d(n+1,0);
    rep(i,n){
        a[p[i]] += n-i;
        b[p[i]] += n-i;
        u[p[i]+1] += n-i;
        d[0] += n-i;
        d[p[i]] -= n-i; 
    }
    rep(i,n){
        u[i+1] += u[i];
        d[i+1] += d[i];
    }
    rep(i,n){
        a[i] += u[i];
        b[i] += d[i];
    }
    array_output(all(a));
    array_output(all(b));
}


Measured memory_bytes: 4648
#include <stdio.h>

int main ()
{
	int x, a, b;
	scanf("%d %d %d", &x, &a, &b);
	
	if(x>a && x>b)
	{
		if(x-a > x-b)
		{
			printf("B");
		}
		else
		{
			printf("A");
		}
	}
		
	else if(x>a && x<b)
	{
		if(x-a > b-x)
		{
			printf("B");
		}
		else
		{
			printf("A");
		}
	}
		
	else if(x<a && x>b)
	{
		if(a-x > x-b)
		{
			printf("B");
		}
		else
		{
			printf("A");
		}
	}
	
	else if(x<a && x<b)
	{
		if(a-x > b-x)
		{
			printf("B");
		}
		else
		{
			printf("A");
		}
	}
		
	return 0;
}

Measured memory_bytes: 1660
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define MAX 1000
void push(int x);
int pop(void);
int isEmpty(void);
int isFull(void);
int keisan(char *s);
int is_digit(char *s){
  if (*s == '+' || *s =='-') {
		s++;
		if (*s >= '0' && *s <= '9') return 1;
		return 0;
	}
  if (*s >= '0' && *s <= '9') return 1;
	return 0;
}
int get_number(char *s)
{
	int sign = 0, n = 0;
	if (*s == '+') {
		s++;
	} else if (*s == '-') {
		sign = 1;
		s++;
	}
	while (*s >= '0' && *s <= '9') {
		n = n * 10 + (*s - '0');
		s++;
	}
	if (sign==1) return -n;
	return n;
}
int top=0;
int S[1000];
int main(){
  int i,x=0,y=0;
  char s[1000];
  scanf("%[^\n]*s", s);
    
  printf("%d\n",keisan(s));

  return 0;
}
int isEmpty(void ){
  if( top== 0)return 0;
  return 1;
}
int isFull(void ){
  if( top >= MAX - 1)return 0;
  return 1;
}
void push(int x){
  if(isFull == 0)printf("error\n");
  
  S[top++] = x;
  
}
int pop(void ){
  
  if(isEmpty == 0)printf("error\n");
  return S[--top];
}
int keisan(char *s){
  int x,y,n;
   while (*s) {
if (is_digit(s)) {
			n = get_number(s);
			push(n);
			while (*s == '-' || *s == '+') {
				s++;
			}
			while (n) {
				n /= 10;
				s++;
			}
			} else {
			switch (*s) {
			case '+':
				x = pop();
				y = pop();
				push(x+y);
				break;
			case '-':
				x = pop();
				y = pop();
				push(y-x);
				break;
			case '*':
				x = pop();
				y = pop();
				push(y*x);
				break;
			case '/':
				x = pop();
				y = pop();
				if (x == 0) break;
				push(y/x);
				break;
			case '%':
				x = pop();
				y = pop();
				if (x == 0) break;
				push(y%x);
			}
			s++;
		}
   }
   return pop();
}



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

int main() {
    int N;
    cin >> N;
    string res = "No";

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (N == i * 4 + j * 7) res = "Yes";
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <stdio.h>
#include <set>
#include <vector>
using namespace std;


int main(){
    int n;
    cin>>n;
    int i;
    for(i=1;; i++){
        if(i*i>n){
            cout<<(i-1)*(i-1)<<endl;
            break;
        }
    }
    
    return 0;
}

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


int main() {
    int N,M;
    int ans = 0;
    cin >> N >> M;
    vector<int> V(M,0);
    rep(i,N) {
        int K;
        cin >> K;
        rep(j,K) {
            int A;
            cin >> A;
            V[A - 1]++;
        }
    }
    rep(k,M) {
        if (V[k] == N) {
            ans++;
        }
    }
    cout << ans << endl;
}


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

int main() {
	int N;
	cin >> N;
	vector<vector<int>> data(N, vector<int>(2));

	for (int i = 0; i < N; i++) {
		cin >> data.at(i).at(0) >> data.at(i).at(1);
	}

	for (int i = 0; i < N - 2; i++) {
		if (data.at(i).at(0) == data.at(i).at(1) && data.at(i+1).at(0) == data.at(i+1).at(1) && data.at(i+2).at(0) == data.at(i+2).at(1)) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i = 0; i < (n); i++)
typedef long long ll;
// Welcome to my source code!

int getP(int n) {
    if (n == 0) return 0;
    return n-1 + getP(n-1);
}

int main() {
    int n;
    cin >> n;
    int x[n], y[n];
    REP(i,n) cin >> x[i] >> y[i];
    int p = getP(n);
    double route[p];
    int f = 0;
    double distX = 0.0, distY = 0.0;
    for (int i = 0; i < n-1; i++) {
        for (int j = i+1; j < n; j++) {
            distX = pow(x[i] - x[j], 2);
            distY = pow(y[i] - y[j], 2);
            route[f++] = sqrt(distX + distY);
        }
    }
    double sum = 0.0;
    int t = n-1;
    REP(i,p) {
        sum += route[i] * t;
    }
    cout << setprecision(12) << sum / p << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
  private static String solve(int n, String[] ss) {
    for (String s : ss) {
      if ("Y".equals(s)) {
        return "Four";
      }
    }
    return "Three";
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    String[] ss = reader.next(n);
    out.println(solve(n, ss));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


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


string s;
map<char,int>q;
long long ans;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>s;
    ans=s.size()*(s.size()-1)/2;
    for(int i=0;i<s.size();i++){
        q[s[i]]++;
    }
    for(auto it:q){
        ans-=(long long)it.second*(it.second-1)/2;
    }
    cout<<ans+1;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int n; cin >> n;
  rep(i, n) {
    int y, m, d; cin >> y >> m >> d;
    int cnt = 0;
    while (y != 1000 || m != 1 || d != 1) {
      d++;
      if (y % 3 == 0) {
        if (d == 21) m++, d = 1;
      } else {
        if (m % 2 == 1 && d == 21) m++, d = 1;
        else if (m % 2 == 0 && d == 20) m++, d = 1;
      }
      if (m == 11) y++, m = 1;
      cnt++;
    }
    cout << cnt << '\n';
  }
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

ll n;
V a;
V dp;

bool is_min(ll idx) {
	for (ll i = idx; i <= n; i++) {
		if (a[idx] >= a[i]) {
			return false;
		}
	}

	return true;
}

void solve_abc_d() {
	// n, m;
	//ll a, b;
	//ll x, y;
	ll h, w;
	ll k;
	ll l_ans = 0;

	cin >> n;

	a = V(n + 5);
	rep(i, n) cin >> a[i+1];

	dp = V(n+5);

	//dp[0] = 1000;
	//dp[1] = 1000;
	//dp[2] = max(dp[1], dp[1] - a[1] * (dp[1] / a[1]) + a[2] * (dp[1] / a[1]));

	dp[0] = 1000;
	priority_queue<P> stock;
	ll tmp, num;
	bool buy;
	dp[0] = 1000;
	rep1(i, n) {
		dp[i] = dp[i - 1];
		rep1(j, i) {
			dp[i] = max(dp[i], dp[j] - a[j] * (dp[j] / a[j]) + a[i] * (dp[j] / a[j]));
		}
	}

	cout << dp[n] << "\n";

	return;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(15);

	solve_abc_d();

	return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <string>
using namespace std;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
typedef long long ll;
typedef long double ld;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int main(){
  ll n,m,k,i,j,result=0,d,t,s;
  cin >> d >> t >> s;
  cout << (s*t>=d ? "Yes" : "No") << endl;
  return 0;
}

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

using namespace std;
using ll =long long;
//nCm 
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//nCmここまで

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}
const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	int n , k; 
	cin >> n >> k; 
	vector<int> p(n);
	rep(i,n) cin >> p[i];
	rep(i,n) p[i] ++ ;
	int mx = 0 ;
	int s = 0 ;
	queue<int> q;
	rep(i,n) {
		s += p[i] ;
		q.push(p[i]);
		if(q.size() > k){
			s -=q.front();q.pop();
		}
		if( q.size() == k ){
			mx = max(mx,s);
		}
	}
	double ans = mx ;
	ans /= 2 ;
	cout << setprecision(10);
	cout << ans << endl;
	return 0 ;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 7;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")

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

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n){
        t *= i;
        t %= mod;
    }
    return t;
}

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

ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = 1;
    for(ll i = 0; i < b; i++) {
        ans *= (a - i);
        ans /= (i + 1);
        ans %= mod;
    }
    return ans;
}

int main(){
    ll n,r = 0,g = 0,b = 0;
    cin >> n;
    string s;
    cin >> s;
    rep0(i, n){
        if(s[i] == 'R')++r;
        else if(s[i] == 'G')++g;
        else ++b;
    }
    ll ans = r*g*b;
    rep0(j, n)rep0(i, j){
        if(j + j - i >= n)continue;
        map<char,bool> c;
        c['R'] = false;
        c['G'] = false;
        c['B'] = false;
        c[s[i]] = true;
        c[s[j]] = true;
        c[s[j + j - i]] = true;
        if(c['R']&c['G']&c['B'])--ans;
    }
    pf(ans);
    return 0;
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define setbits(x)  __builtin_popcountll(x)
#define mod 1000000007
#define v(n) vector<int> v(n)
#define w(x) int x;cin>>x;while(x--)
#define ps(x,y) fixed<<setprecision(y)<<x
#define f(i,j,n) for(int i=j;i<=n;i++)
#define  FAST ios_base::sync_with_stdio(0);cin.tie(0);cin.tie(0);
void c_p_c(){
    ios_base::sync_with_stdio(0);cin.tie(0);cin.tie(0);
   /* #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/
}
int main(){
    c_p_c();int t=0;
    string s;
    cin>>s;
    if(s[0]==s[1]&&s[1]==s[2]&&s[1]=='S')
     cout<<"0";
    else
    {f(i,0,1)
      if(s[i]==s[i+1]&&s[i]=='R')
        t++;
    cout<<t+1;}
}   
    
    
     

     
   









Measured memory_bytes: 3612
type dice = {
  one : int ;
  two : int ;
  three : int ;
  four : int ;
  five : int ;
  six : int };;

let throw_dice dir dice  =
  match dir with
    "W" -> {dice with one = dice.three;
                      three = dice.six;
                      six = dice.four;
                      four = dice.one}
  | "E" -> {dice with one = dice.four;
                      four = dice.six;
                      six = dice.three;
                      three = dice.one}
  | "S" -> {dice with one = dice.five;
                      two = dice.one;
                      six = dice.two;
                      five = dice.six}
  | _ -> {dice with one = dice.two;
                      two = dice.six;
                      six = dice.five;
                      five = dice.one};;

let check_dicenum str dice =
  let len = String.length str in
  let rec f i d =
    if i = len then d.one
    else f (i+1) (throw_dice (Char.escaped str.[i]) d)
  in
  f 0 dice ;;

let () =
  let as_ = Array.init 6 (fun _ -> Scanf.scanf "%d " (fun a -> a)) in
  let dice = {one = as_.(0); two = as_.(1); three = as_.(2); four = as_.(3); five = as_.(4); six = as_.(5)} in
  let str = Scanf.scanf "%s\n" (fun a -> a) in
  Printf.printf "%d\n" (check_dicenum str dice) ;;


Measured memory_bytes: 2772
n = int(input())

D = []
for i in range(n):
    d = list(map(int, input().split()))
    D.append(d)

flg = False
cnt = 0

for i in D:
    a, b = i[0], i[1]
    if a == b:
        cnt += 1

    else:
        cnt = 0

    if cnt >= 3:
        flg = True
        break
if flg:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9184
#include<bits/stdc++.h>  
using namespace std;  
  
#define fast ios::sync_with_stdio(false);cin.tie(NULL)  
#define fi first  
#define se second  
#define all(v) (v).begin(),(v).end()  
#define pb push_back  
#define eb emplace_back
#define em emplace
#define mp make_pair
  
typedef long long ll;  
typedef pair<int,int> pii;  
typedef pair<ll,ll> pll;  
const long long INF = 1e18;  
const int inf = 1e9;

int n, m;
int p[100010];

int Find(int a) { return p[a] ? p[a] = Find(p[a]) : a; }
void Union(int a, int b) {
	if(Find(a) == Find(b)) return;
	
	n--;
	p[Find(b)] = Find(a);
}

int main() {
	fast;

	cin >> n >> m;

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

		Union(a, b);
	}

	cout << n-1;
}

Measured memory_bytes: 4044
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <deque>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
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;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vector<vec> v){for(auto e:v){for(auto ee:e)cout<<ee<<" ";cout<<endl;}}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}
const int INF=1e6;
const ll int MOD=998244353;

main(){
    int n=in();
    ll ans=1;
    vec a;
    rep(i,n)a.pb(in());
    sort(all(a));
    rep(i,n){
        ans=(ans * __gcd((int)i,a[i])%MOD);
    }
    cout<<ans;
}

Measured memory_bytes: 892
import java.util.Scanner;

//Addition Game
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int T = sc.nextInt();
		while(T--!=0){
			String s = sc.next();
			int t = 0;
			while(1<s.length()){
				int x = (s.charAt(0)-'0')+(s.charAt(1)-'0');
				s = x+s.substring(2);
				t = 1-t;
			}
			System.out.println(t==0?"Audrey wins.":"Fabre wins.");
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

using namespace std;
int mem[3003][3003];
vector<pair<int, int> > vp;

int n;
int solve(int ind, int rem){
    if(rem <= 0 || ind == n) return 0;
    int &ret = mem[ind][rem];
    if(~ret) return ret;

    ret = solve(ind + 1, rem  - vp[ind].first) + vp[ind].second;
    return ret = max(ret, solve(ind + 1, rem));
}

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
#endif
    int rem;
    scanf("%d %d", &n, &rem);
    vp.resize(n);
    for(int i=0; i<n;i++)
        scanf("%d %d", &vp[i].first, &vp[i].second);
    sort(vp.begin(), vp.end());
    memset(mem, -1, sizeof(mem));
    printf("%d\n", solve(0, rem));
    return 0;
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define pb push_back

using namespace std;

typedef long long ll;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

void solve() {

}

int main() {
  int n;
  cin >> n;
  rep(i,n+1) {
    int v = i * 1.08;
    if( v == n ) {
      cout << i << endl;
      return 0;
    }
  }
  puts(":(");
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;
using ll = long long;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main()
{
	int n, C, s, t, c, imos[100010] = {}, x = 0, i;

	cin >> n >> C;
	for (i = 0; i < n; i++) {
		cin >> s >> t >> c;
		imos[s - 1]++;
		imos[t]--;
	}

	for (i = 1; i < 100005; i++) {
		imos[i] += imos[i - 1];
	}

	for (i = 0; i < 100005; i++) {
		if (x < imos[i]) {
			x = imos[i];
		}
	}

	cout << min(x, C) << endl;
}


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

int main(){
    int n;
    cin >> n;
    vector<int64> a(n), b(n);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
    }
    int64 sum = 0;
    for(int i = n - 1; i >= 0; i--){
        a[i] += sum;
        sum += (b[i] - a[i] % b[i]) % b[i]; 
    }
    cout << sum << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n, m; cin >> n >> m;
	vector<vector<pair<int, ll>>> e(n);
	rep(i, 1, m)
	{
		int l, r;
		ll d;
		cin >> l >> r >> d;
		--l, --r;
		e[l].push_back({ r,d });
		e[r].push_back({ l,-d });
	}
	ll INF = 1LL<<60;
	vector<ll> coo(n, INF);
	rep(i, 0, n - 1)
	{
		if (coo[i] != INF)continue;

		coo[i] = 0;
		queue<int> q;
		q.push(i);
		while (!q.empty())
		{
			int now = q.front();
			int lim = e[now].size();
			q.pop();
			rep(j, 0, lim - 1)
			{
				int next = e[now][j].first;
				int dist = e[now][j].second;
				if (coo[next] != INF)
				{
					if (coo[now] + dist != coo[next])
					{
						cout << "No" << endl;
						return 0;
					}
				}
				else
				{
					coo[next] = coo[now] + dist;
					q.push(next);
				}
			}
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 13824
#include <stdio.h>

int main(void) {
	int i;
	int k=0;
	
	
	while(1){
		
		scanf("%d", &i);
			if(i==0){
				break;
			}
		
		++k;
		printf("Case %d: %d\n", k, i);
	
	}
	
	return 0;
}

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

int main(){
    int n,m;
    cin >> n >> m;
    priority_queue<int> Q;
    rep(i,n){
        ll x;
        cin >> x;
        Q.push(x);
    }
    rep(i,m){
        ll x = Q.top();
        Q.pop();
        Q.push(x/2);
    }
    ll ans = 0;
    rep(i,n){
        ans += Q.top();
        Q.pop();
    }
    cout << ans << endl;
}



Measured memory_bytes: 892
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define ggr getchar();getchar();return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
//combination(Nが小さい時はこれを使う
const int MAX = 330000;
int fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
}

// 二項係数計算
long long COMB(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}

//繰り返し二乗法（Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= (i % mod); res %= mod;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//UnionFind
class UnionFind {
protected:
	int* par, * rank, * size;
public:
	UnionFind(unsigned int size) {
		par = new int[size];
		rank = new int[size];
		this->size = new int[size];
		rep(i, size) {
			par[i] = i;
			rank[i] = 0;
			this->size[i] = 1;
		}
	}
	int find(int n) {
		if (par[n] == n)return n;
		return par[n] = find(par[n]);
	}
	void unite(int n, int m) {
		n = find(n);
		m = find(m);
		if (n == m)return;
		if (rank[n] < rank[m]) {
			par[n] = m;
			size[m] += size[n];
		}
		else {
			par[m] = n;
			size[n] += size[m];
			if (rank[n] == rank[m])rank[n]++;
		}
	}
	bool same(int n, int m) {
		return find(n) == find(m);
	}
	int getsize(int n) {
		return size[find(n)];
	}
};
int dight(int n) {
	int ans = 1;
	while (n >= 10) {
		n /= 10;
		ans++;
	}
	return ans;
}
int dight_sum(int n) {
	int sum = 0;
	rep(i, 20)sum += (n % (int)pow(10, i + 1)) / (pow(10, i));
	return sum;
}
int dight_min(int n) {
	int ans = 9;
	while (n >= 10) {
		ans = min(ans, n % 10);
		n /= 10;
	}
	ans = min(ans, n);
	return ans;
}
int dight_max(int n) {
	int ans = 0;
	while (n >= 10) {
		ans = max(ans, n % 10);
		n /= 10;
	}
	ans = max(ans, n);
	return ans;
}
signed main() {
	int a, b;
	cin >> a >> b;
	cout << a * b << " " << (a + b) * 2 << endl;
	ggr
}



Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <numeric>
#include <cmath>
#include <iomanip> //cout << fixed << setprecision(15) << << endl;
#include <cassert>
//#include "atcoder/all"

using namespace std;
//using namespace atcoder;

#define ll long long int
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define P pair<int,int>

int mx8[] = {0,0,1,-1,-1,1,-1,1};
int my8[] = {-1,1,0,0,-1,-1,1,1};
int mx4[] = {1,-1,0,0};
int my4[] = {0,0,-1,1};
const int MOD = 1000000007;


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

    ll a,b,c,d; cin >> a >> b >> c >> d;
    ll h = a*c,i=a*d,j=b*c,k=b*d;
    cout << max(h,max(max(i,j),k)) << endl;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
	int n;
	vector<pair<int,int> > xy;
	cin >> n;
	for(int i=0;i<n;i++) {
		int x, y;
		cin >> x >> y;
		xy.push_back({x,y});
	}
	sort(xy.begin(),xy.end());
	double sum  = 0;
	ll key = 1;
	for(int i=1;i<=n;i++) key *= i;
	do {
		double tmp = 0;
		int nx = xy[0].first;
		int ny = xy[0].second;
		for(int i=1;i<n;i++) {
			tmp += sqrt((nx - xy[i].first)*(nx - xy[i].first) + (ny - xy[i].second)*(ny - xy[i].second));
			nx = xy[i].first, ny = xy[i].second;
		}
		sum += tmp/(double)key;
	} while(next_permutation(xy.begin(), xy.end()));
	
	cout << fixed << setprecision(8) <<  sum << endl;
}

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


int main() {
vector<vector<int>> data(8, vector<int>(3));
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
  cin>>data.at(i).at(j);
    }
  }
  for(int k=3;k<6;k++){
for(int j=0;j<3;j++){
  	for(int i=0;i<3;i++){
    
  data.at(k).at(i)=data.at(i).at(k-3);
    }
  }
  }

  for(int i=0;i<3;i++){
  data.at(6).at(i)=data.at(i).at(i);
  }
for(int i=0;i<3;i++){
  data.at(7).at(i)=data.at(i).at(2-i);
  }
    
    int N;
  cin>>N;
  vector<int> b(N);
  for(int i=0;i<N;i++){
    cin>>b.at(i);
  }
  vector<int> k(8);
  for(int i=0;i<8;i++){
  	k.at(i)=0;
     for(int j=0;j<3;j++){
    for(int l=0;l<N;l++){
  if(b.at(l)==data.at(i).at(j)){
   k.at(i)++; 
  }
    }
      
  }
  }
  
    for(int i=0;i<8;i++){ 
    if(k.at(i)==3){
        cout<<"Yes"<<endl;
      break;
       }
 
      if(i==7){
        cout<<"No"<<endl;
       }
    }
       
}

Measured memory_bytes: 256