akhauriyash/Code-Regression huggingface dataset:
#ifdef lolipop
#define _GLIBCXX_DEBUG
#endif

/*
    This ain't a milly rock
    This a money dance
    And my D' ain't hard
    That's a '30 in my pants
*/

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <set>
#include <ctime>
#include <map>
#include <random>
#include <iomanip>
#include <cmath>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <bitset>
#include <deque>
#include <utility>

#define int long long
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define ld long double

using namespace std;

// mt19937 rnd(time(nullptr));

inline void fastio() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

const int maximum = 1e18;

void solve() {
    int x;
    cin >> x;
    vector <int> fifth;
    vector <int> f;
    for(int i = 0; i * i * i * i * i < maximum; ++i) {
        fifth.push_back(i * i * i * i * i);
        f.push_back(i);
    }
//    cout << fifth.size() << '\n';
//    for(auto i : fifth) cout << i << ' ';
    int fs = fifth.size();
    for(int i = 0; i < fs; ++i) {
        for(int j = 0; j < fs; ++j) {
            if(fifth[i] + fifth[j] == x) {
                cout << f[i] << " -" << f[j];
                return;
            }
            if(fifth[i] - fifth[j] == x) {
                cout << f[i] << ' ' << f[j];
                return;
            }
        }
    }
}

signed main() {
#ifdef lolipop
    freopen("input.txt", "r", stdin);
#else
    fastio();
#endif

    int T = 1;
//    cin >> T;
    while(T--) {
        solve();
    }
    return 0;
}

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

int main()
{
    int n,a;
    vector<int> A, B;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a;
        A.push_back(a);       
    }
  	B = A;
    sort(B.begin(), B.end());
    for(int i=0;i<n;i++){
        if(B[n-1]!=A[i]){
            cout << B[n-1] << endl;
        }else{
            cout << B[n-2] << endl;
        }    
    }
    return 0;
}


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int first = -1;
  int now;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  for (int i = 0; i < N; i++) {
    if (vec.at(i) == 1) {
      first = i;
      break;
    }
  }
  if (first != -1) {
    now = 1;
    while (first != -1) {
    for (int i = first; i < N; i++) {
      if (vec.at(i) == now + 1) {
        first = i;
        now++;
        break;
      }
      first = -1;
    }
    }
    cout << N - now << endl;
    }
  else {
    cout << -1 << endl;
  }
  }

Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <string>

#include<stdio.h>
#include<math.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

using namespace std;

int main(){

  string str;
  int i=0,n=0,m=0;

  while(1){
    cin >>str;
    if(str=="-") break;
    cin >>n; //?????°

    for(i=0;i<n;i++){
      cin >>m;
      string left=str.substr(0,m);
      string right=str.substr(m);
      str=right+left;
    }
    
    cout <<str <<endl;
  }


  return 0;
}

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

using namespace std;

#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

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

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

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

    int D, N;
    cin >> D >> N;
    if(D == 0) {
        if(N == 100) cout << 101 << endl;
        else cout << N << endl;
    }
    else if(D == 1) {
        if(N == 100) cout << 10100 << endl;
        else cout << N * 100 << endl;
    }
    else {
        if(N == 100) cout << 1010000 << endl;
        else cout << N * 10000 << endl;
    }
    return 0;
}

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

typedef long long ll;

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    cout << A * B << endl;
    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
// 2D Plane 2N Points
typedef pair<int, int> P;

bool pairCompare(P a, P b){
    // if(a.first == b.first){
    //     return a.second < b.second;
    // }else{
    //     return a.first > b.first;
    // }
    return a.second < b.second;
}

int main(){
    int N;
    cin >> N;
    vector<P> a(N), b(N);

    for(int i = 0; i < N; ++i){
        cin >> a[i].first >> a[i].second;
    }
    for(int i = 0; i < N; ++i){
        cin >> b[i].first >> b[i].second;
    }
    // 降順
    sort(a.begin(), a.end(), pairCompare);
    sort(b.rbegin(), b.rend());
    // for(int i = 0; i < N; ++i){
    //     cout << a[i].first << " " << a[i].second << endl;
    // }
    // cout << endl;
    int pair = 0;
    while(b.size() > 0){
        P blue = b.back();
        b.pop_back();
        //cout << blue.first << " " << blue.second << endl;
        for(int i = a.size() - 1; i >= 0; --i){  
            if(a[i].first < blue.first && a[i].second < blue.second){
                //cout << a[i].first << " " << a[i].second << endl;
                a.erase(a.begin() + i);
                pair++;
                break;
            }
        }        
    }
    cout << pair << endl;
    return 0;
}



Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int main(){
  int N, D, X; cin >> N >> D >> X;
  int A[N];
  for(int i = 0; i < N; i++) cin >> A[i];

  int res = X;
  for(int i = 0; i < N; i++){
    for(int n = 0; n <= (D-1)/A[i]; n++){
      res ++;
    }
  }

  cout << res << endl;
  return 0;
}


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

namespace ABCtest
{
    delegate void Signal();
    class Program
    {
        static void Main(string[] args)
        {
            int D, N;
            string[] Array = Console.ReadLine().Split(' ');
            int value;

            if (Array.Length == 1) return;
            if (!int.TryParse(Array[0], out D) & !(D == 0 | D == 1 | D == 2)) return;
            if (!int.TryParse(Array[1], out N) & !(N >= 1 & N <= 100)) return;

            switch (D)
            {
                case 0:
                    Console.WriteLine(N == 100 ? N + 1 : N);
                    break;
                case 1:
                    Console.WriteLine(N == 100 ? 100 * N + 100 : 100 * N);
                    break;
                case 2:
                    Console.WriteLine(N == 100 ? 10000 * N + 10000 : 10000 * N);
                    break;
                default:
                    break;
            }
            Console.ReadLine();


        }
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to, cost;};
#define INF 1000000001

int V,E;
vector<edge> G[100005];
int d[100005];

void dijkstra(int s){
	priority_queue<P, vector<P>,greater<P> > que;
	for(int i=0;i<V;i++)d[i]=INF;
	d[s]=0;
	que.push(P(0,s));
	
	while(!que.empty()){
		P p=que.top();que.pop();
		int v=p.second;
		if(d[v]<p.first)continue;
		for(int i=0;i<G[v].size();i++){
			edge e=G[v][i];
			if(d[e.to]>d[v]+e.cost){
				d[e.to]=d[v]+e.cost;
				que.push(P(d[e.to],e.to));
			}
		}
	}
}

int main(void){
	int r,s;edge e;
	cin>>V>>E>>r;
	for(int i=0;i<E;i++){
		cin>>s>>e.to>>e.cost;
		G[s].push_back(e);
	}
	dijkstra(r);
	for(int i=0;i<V;i++){
		if(d[i]==INF)cout<<"INF\n";
		else cout<<d[i]<<endl;
	}
	
	return 0;
}



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

int h, w, sy, sx, gy, gx, ANS = 0;
char ch[55][55];

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
queue<P> que;


int main() {
    cin >> h >> w;
    rep(i,h){
        rep(j,w){
            cin >> ch[i][j];
        }
    }


    for (int sy = 1; sy < h+1; sy++){
        for (int sx = 1; sx < w+1; sx++){
            for (int gy = 1; gy < h+1; gy++){
                for (int gx = 1; gx < w+1; gx++){
                    if (ch[sy-1][sx-1] == '.' && ch[gy-1][gx-1] == '.'){
                        int ans[55][55] = {0}, flag[55][55] = {0};
                        flag[sy-1][sx-1] = 1;
                        que.push(P(sy-1,sx-1));
                        while (!que.empty()){
                            P p = que.front();
                            que.pop();
                            rep(i,4){
                                int x = p.second + dx[i];
                                int y = p.first + dy[i];
                                if (0 <= x && x <= w && 0 <= y && y <= h && !flag[y][x] && ch[y][x] == '.'){
                                    flag[y][x] = 1;
                                    ans[y][x] = ans[p.first][p.second] + 1;
                                    que.push(P(y,x));
                                }
                            }
                        }
                        ANS = max(ANS, ans[gy-1][gx-1]);
                    }
                    else continue;
                }
            }
        }   
    }
    cout << ANS << endl;
}

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    vector<long long> v(2020, 0);
    long long curr = 0;
    long long p = 1;
    v[0]++;
    reverse(s.begin(), s.end());
    for (auto &x: s) {
        curr = curr + (x - '0') * p;
        p = p * 10 % 2019;
        curr %= 2019;
        v[curr]++;
    }
    long long ans = 0;
    for (auto &x: v) {
        ans += x * (x-1) / 2;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3700
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		String line;
		while ((line = reader.readLine()) != null) {
			if (line.isEmpty()) {
				break;
			}

			int[] a = new int[10];
			for (int i = 0; i < line.length(); i++) {
				a[line.charAt(i) - '0']++;
			}
			int[] result = new int[10];
			for (int i = 1; i < 10; i++) {
				if (a[i] == 4) {
					continue;
				}

				for (int j = 1; j < 10; j++) {
					int[] m = Arrays.copyOf(a, a.length);
					m[i]++;
					m[j] -= 2;
					for (int k = 1; k < 8; k++) {
						if (m[k] < 0) {
							m[9] = -1;
							break;
						}
						if (m[k] == 1 || m[k] == 4) {
							m[k]--;
							m[k + 1]--;
							m[k + 2]--;
						} else if (m[k] == 2) {
							m[k] -= 2;
							m[k + 1] -= 2;
							m[k + 2] -= 2;
						}
					}
					if ((m[8] == 0 || m[8] == 3) && (m[9] == 0 || m[9] == 3)) {
						result[i]++;
						break;
					}
				}
			}
			int count = 0;
			boolean flag = false;
			for (int i = 1; i < 10; i++) {
				if (result[i] == 1) {
					flag = true;
					if (count != 0) {
						builder.append(' ');

					}
					builder.append(i);
					count++;
				}
			}

			if (!flag) {
				builder.append(0);
			}
			builder.append('\n');
		}
		System.out.print(builder);
	}
}

Measured memory_bytes: 16988
import java.io.*;
import java.util.*;
import java.lang.Math;
import java.util.Arrays;

public class Main {
    public static void main(final String[] args) {

        Scanner sc = new Scanner(System.in);

        String s;
        MainRoop : while(true){
            s = sc.next();

            if(s.equals("0"))break MainRoop;

            int sum = 0;
            for(int i = 0; i < s.length(); i++)sum += (s.charAt(i) - '0');

            System.out.println(sum);
        }
    }
  
}


Measured memory_bytes: 26196
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Queue;
import java.util.Scanner;


public class Main {
	static int[][] map;
	static boolean[] flag;
	static int N;
	static int ans = 0;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		N = Integer.parseInt(sc.next());
		int M = Integer.parseInt(sc.next());
		map = new int[N][N];
		
		flag = new boolean[N];
		Arrays.fill(flag, true); //true:通っていない
		
		for(int i=0; i<M; i++){
			int a = Integer.parseInt(sc.next())-1;
			int b = Integer.parseInt(sc.next())-1;
			map[a][b] = 1;
			map[b][a] = 1;
		}
		
		flag[0]=false;
		walk(0,0);
		
		System.out.println(ans);
		
		sc.close();
	}

	public static void walk(int pos, int walked){

		for(int i=0; i<N; i++){
			if(map[pos][i] == 1 && flag[i]){
				walked++;
				if(walked == N-1){
					ans++;
					return;
				}
				flag[i] = false;
				//System.out.println("from:"+pos+" to:"+i+" walked:"+walked);
				walk(i, walked);
				walked--;
				flag[i] = true;
			}
		}
		return;
	}
	
}


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



int main()
{
 
    ll x,y;
    string ans="No";
    cin>>x>>y;
    if(y%2!=0)
        cout<<ans<<endl;
    else
    {
        ll y1=((y/2)-x);
        ll x1=((2*x)-(y/2));
        if(y1>=0 and x1>=0)
        {
            ans="Yes";
        }
        cout<<ans<<endl;
    }

    
    return 0;
}

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

int main() {
    using namespace std;
    unsigned long N;
    cin >> N;
    set<unsigned long> s;
    copy_n(istream_iterator<unsigned long>(cin), N, inserter(s, end(s)));
    puts(s.size() == N ? "YES" : "NO");
    return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define PI acos(-1.0)
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	ll x,k,d;
  cin >> x >> k >> d;

  if(x < 0) x *= -1;

  ll ans = 0;

  ll div = x/d;
  if(div >= k){
    ans = x - k * d;
    cout << ans << endl;
    return 0;
  }

  k -= div;
  x -= d*div;
  if(k % 2 == 0){
    cout << x << endl;
  }else{
    cout << d - x << endl;
  }

  return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> IP;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)

int main() {
	lint N, M;
	cin >> N >> M;
	vector<lint>A(N);
	lint sum = 0;
	rep(i, N) {
		cin >> A[i];
		sum += A[i];
	}
	sort(A);
	reverse(A);
	if (A[M - 1] * 4 * M < sum) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN =  100+7;
struct node {
    int id;
    node* next;
};
node* g[MAXN];
bool visit[MAXN];
int d[MAXN];
int f[MAXN];
int mytime;
stack<int> s;
void dfs(int i){
    node* p = g[i];
    while(p->next!=NULL){
        p=p->next;
        if(visit[p->id]==false){
            s.push(p->id);
            mytime++;
            d[p->id] = mytime;
            visit[p->id] = true;
            dfs(p->id);
        }

    }
    s.pop();
    mytime++;
    f[i] = mytime;

}
int main() {
//    freopen("../in.txt", "r", stdin);
    memset(visit, false, sizeof(visit));
    int n;
    scanf("%d", &n);
    int i;
    for(i = 1; i <= n; i++) {
        g[i] = (node*)malloc(sizeof(node));
        g[i]->next = NULL;
    }
    for(i = 0; i < n; i++) {
        int num;
        int k;
        scanf("%d", &num);
        scanf("%d", &k);
        int j;
        for(j = 0; j < k; j++) {
            int r;
            scanf("%d", &r);
            node* t = (node*)malloc(sizeof(node));
            t->id = r;
            t->next = NULL;
            node* p = g[num];
            while(p->next != NULL) p = p->next;
            p->next = t;
        }
    }
    mytime = 0;
    while(true){
        int u;
        int g = -1;
        for(u = 1; u <= n; u++){
            if(visit[u]==false){
                g = u;
                break;
            }
        }
        if(g==-1){
            break;
        }
        s.push(g);
        mytime++;
        d[g] = mytime;
        visit[g] = true;
        dfs(g);
    }

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



Measured memory_bytes: 3232
#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(c) begin(c), end(c)
#define range(i,a,b) for(int i = a; i < (int)(b); i++)
#define rep(i,b) range(i,0,b)
#define eb emplace_back
typedef long long ll;
auto const inf = numeric_limits<ll>::max()/4;

using Weight = ll;
using Capacity = int;
struct Edge {
    int src, dst; Weight weight;
    Edge(int s, int d, int w) : src(s), dst(d), weight(w) {}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

vector<Weight> dijkstra(const Graph &g, int s){
    const Weight inf = numeric_limits<Weight>::max()/4;
    typedef tuple<Weight,int> State;
    queue<State> q;
    vector<Weight> dist(g.size(), inf);
    dist[s] = 0; q.emplace(0,s);
    while (q.size()) {
        Weight d; int v;
        tie(d,v) = q.front(); q.pop(); d *= -1;
        /* if(v == t) return d; */
        if (dist[v] < d) continue;
        for(auto & e : g[v]){
            if (dist[e.dst] > dist[v] + e.weight) {
                dist[e.dst] = dist[v] + e.weight;
                q.emplace(-dist[e.dst], e.dst);
            }
        }
    }
    return dist;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    int V,E,r;
    while(cin >> V >> E >> r){
        Graph g(V);
        rep(i,E){
            int a,b,c;
            cin >> a >> b >> c;
            g[a].eb(a,b,c);
        }
        vector<Weight> dist = dijkstra(g,r);
        for(int i = 0; i < (int)dist.size(); i++){
            if(dist[i] == inf) cout << "INF";
            else cout << dist[i];
            cout << endl;
        }
    }
}

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

int main(){
    int n,k;
    cin >> n >> k;
    int num = 1;
    for(int i=0; i<n; i++){
        if(num+k > num*2){
            num *= 2;
        }else{
            num += k;
        }
    }
    cout << num << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int arr[3];
  for(int i=0;i<3;i++) cin>>arr[i];
  int count1=0,count2=0;
  for(int i=0;i<3;i++){
    if(arr[i]==5){
      count1++;
    }
    else{
      count2++;
    }
  }
  if(count1==2 && count2==1){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}
  
  



Measured memory_bytes: 256
import numpy as np
 
n = int(input())
arr = np.array([int(i) for i in input().split()])
mod = 10 ** 9 + 7
s = 0

for i in range(60):
    c1 = np.count_nonzero(arr & 1)
    s += 2 ** i * c1 * (n - c1)
    arr >>= 1
print(s % mod)

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

#define rep(i, n) for(int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using ll = long long;

struct Q
{
	ll a, b;
};

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

	vector<Q> q1, q2;

	rep(i, n)
	{
		string s;
		cin >> s;

		Q q = {};
		{
			ll close = 0, open = 0;
			rep(j, s.length())
			{
				if (s[j] == ')')
				{
					close++;
				}
				if (s[j] == '(')
				{
					open++;
				}
				q.a = max(q.a, close - open);
			}
		}
		reverse(all(s));
		{
			ll close = 0, open = 0;
			rep(j, s.length())
			{
				if (s[j] == ')')
				{
					close++;
				}
				if (s[j] == '(')
				{
					open++;
				}
				q.b = max(q.b, open - close);
			}
		}

		if (q.b - q.a >= 0)
			q1.push_back(q);
		else
			q2.push_back(q);
	}

	//auto p = &Q::a;
	//auto f = [p](Q x, Q y)
	//{
	//	return x.*p < y.*p;
	//};

	sort(all(q1), [](const Q& x, const Q& y) {
		return x.a < y.a;
		});

	//p = &Q::b;
	sort(rall(q2), [](const Q& x, const Q& y) {
		return x.b < y.b;
		});

	ll pos = 0, min_pos = 0;
	rep(i, q1.size())
	{
		pos -= q1[i].a;
		min_pos = min(min_pos, pos);
		pos += q1[i].b;
	}
	rep(i, q2.size())
	{
		pos -= q2[i].a;
		min_pos = min(min_pos, pos);
		pos += q2[i].b;
	}

	if (pos == 0 && min_pos >= 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

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

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;


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

  int n;
  cin>>n;
  int odd = (n + 1) / 2;
  int even = n / 2;
  cout << odd * even << endl;

  return 0;
}


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

using namespace std;

int main(){
    long long int a,b,v,w,t;
    cin>>a>>v>>b>>w>>t;
    
    if(b>=a){
        if((b-a)<=(v-w)*t)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    else{
        if((a-b)<=(v-w)*t)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 3636
//abc167_d.cpp
//Sun May 10 20:56:13 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

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

int main(){
	ll n,k;
	cin >> n >> k;

	ll a[n];
	for (int i=0;i<n;i++){
		cin >> a[i];
		a[i]--;
	}

	ll passed[n];
	fill(passed,passed+n,0);
	passed[0] = 1;
	ll cur = 0;
	ll count = 1;
	ll when[n];
	fill(when,when+n,0);
	while (1){
		cur = a[cur];
		if (count ==k){
			cout << cur+1 <<endl;
			return 0;
		}
		if (passed[cur]==1){
			ll loopsize = count-when[cur];
			ll amari = (k-count)%loopsize;
//			cout << amari << endl;
			amari += when[cur];
			for (ll i=0;i<n;i++){
				if (when[i]==amari){
					cout << i+1 <<endl;
					return 0;
				}
			}
		}else {
			passed[cur] = 1;
			when[cur] = count;
			count++;
		}
	}

}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    vector<int>v;
    string s;
    cin>>s;
    rep(i,s.size()){
        if(isdigit(s[i])){
            v.pb(s[i]-'0');
        }
        else{
            if(v.size())v.pop_back();
        }
    }
    rep(i,v.size())cout<<v[i];cout<<endl;
    return 0;
}


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

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

    vector<int> x(5, 0);
    int sum = 0;
    for (int i = 0; i < 5; i ++) cin >> x[i];
    sort(x.begin(), x.end(), [](int a, int b)
            {int i = a%10, j = b%10;
             if (i == 0) i = 10;
             if (j == 0) j = 10;
             return i < j;
            });

    for (int i = 4; i > 0; i--)
        if (x[i] % 10)
            sum += x[i] + (10 - (x[i]%10));
        else
            sum += x[i];
    cout << sum + x[0] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <functional>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

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

template <typename T>
class segment_tree{
    private:
        static int calc_size(int n){
            int m = 1;
            while(m < n){
                m *= 2;
            }
            return m;
        }

        T query(int s, int t, int i, int l, int r) const {
            if(r <= s || t <= l){
                return init;
            }

            if(s <= l && r <= t){
                return node[i];
            }

            int m = l + (r - l) / 2;
            T vl = query(s, t, i * 2 + 1, l, m);
            T vr = query(s, t, i * 2 + 2, m, r);
            return f(vl, vr);
        }

    public:
        int n;
        vector<T> node;
        T init;
        function<T(T, T)> f;

        segment_tree(int n, T init, function<T(T, T)> f)
            : n(calc_size(n)), node(calc_size(n) * 2, init), init(init), f(f){}

        void update(int i, const T& x){
            i += (n - 1);
            node[i] = x;
            while(i > 0){
                i = (i - 1) / 2;
                node[i] = f(node[2*i+1], node[2*i+2]);
            }
        }

        T query(int s, int t) const {
            return query(s, t, 0, 0, n);
        }
};

signed main(){
    int n, q;
    cin >> n >> q;

    segment_tree<int> st(n, INF, [](int a, int b){return min(a, b);});

    rep(i, q){
        int com, x, y;
        cin >> com >> x >> y;

        if(com == 0){
            st.update(x, y);
        }

        if(com == 1){
            cout << st.query(x, y+1) << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 4960
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n); i >= 0; i--)
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;

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

// 多次元 vector 生成
template <class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template <class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template <class T> 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;
}

int dp[3005][3005] = {0};

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

    string s, t;
    cin >> s >> t;

    FOR(i, 0, s.size() + 1) {
        FOR(j, 0, t.size() + 1) {
            if (j + 1 < t.size() + 1) {
                chmax(dp[i][j + 1], dp[i][j]);
            }
            if (i + 1 < s.size() + 1) {
                chmax(dp[i + 1][j], dp[i][j]);
            }
            if (i + 1 < s.size() + 1 && j + 1 < t.size() + 1) {
                if (s[i] == t[j]) {
                    chmax(dp[i + 1][j + 1], dp[i][j] + 1);
                } else {
                    chmax(dp[i + 1][j + 1], dp[i][j]);
                }
            }
        }
    }

    string ans = "";

    int i = s.size();
    int j = t.size();
    while (0 < i || 0 < j) {
        // cout << i << " " << j << " " << endl;
        if (i > 0 && dp[i][j] == dp[i - 1][j]) {
            i--;
        } else if (j > 0 && dp[i][j] == dp[i][j - 1]) {
            j--;
        } else if (i > 0 && j > 0 && dp[i][j] > dp[i - 1][j - 1]) {
            ans.push_back(t[j - 1]);
            // cout << s[i - 1] << " " << t[j - 1] << endl;
            i--;
            j--;
        } else {
            if (i > 0) {
                i--;
            }
            if (j > 0) {
                j--;
            }
        }
    }

    reverse(ALL(ans));

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 35456
#include <iostream>
using namespace std;
int main(){

  int a,b,c,t;
  cin >>a>>b>>c;

  if(a>b){
    t=a;
    a=b;
    b=t;
  }
  if(b>c){
    t=c;
    c=b;
    b=t;
  }
  if(a>b){
    t=b;
    b=a;
    a=t;
  }

  cout <<a<<" "<<b<<" "<<c<<"\n";
 
  return 0;

}

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

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20; // ~ Log N
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

#define LSOne(S) (S & (-S))
#define isBitSet(S, i) ((S >> i) & 1)



void solve() {
	ll n;
	cin>>n;
	int a[n];
	for(ll i=0;i<n;i++)
	cin>>a[i];
	ll ans=0;
	if(n==1){
		cout<<0<<endl;
		return;
	}
	for(int i=1;i<n;i++){
		if(a[i-1]>a[i]){
			ans+=a[i-1]-a[i];
			a[i]=a[i-1];
		}
	}
	cout<<ans<<endl;
	return;

}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

        //cout << "Case #" << t  << ": ";
        solve();
}

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return abs(x-y)/gcd(x,y); }


int main() {
  lint n; cin >> n;
  vector<lint> p(n+1); for(lint i=1;i<n+1;i++) { cin >> p[i]; }

  lint ans=0;

  for(lint i=1;i<n+1;i++) {
    if(i==p[i]) {
      if(i<n) {
        p[i]=p[i+1];
        p[i+1]=i;
      } else if(i==n) {
        p[n]=p[n-1];
        p[n-1]=n;
      }
      ans++;
    }
  }

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define FAST ios_base::sync_with_stdio(false);cin.tie();cout.tie();

int32_t main(){

    int n;cin>>n;
    vector<int> v(n);
    vector<int> freq(1000005,0);
    for(auto &i : v) {cin>>i;freq[i]++;}

    int ans=0;

    for(int i=0;i<n;i++){
        freq[v[i]]--;
        bool ok=true;
        for(int j=1;j*j<=v[i];j++){
            if(v[i]%j==0){
                if(freq[j]!=0){ok=false;break;}
                if(freq[v[i]/j]!=0){ok=false;break;}
            }
        }

        if(ok) ans++;

        freq[v[i]]++;
    }

    cout<<ans<<"\n";

    
    return 0;
}

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

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

using namespace std;

using ll = long long int;

const int MOD_NUM = 1e9 + 7;

int main() {
    // Input
    int N;
    vector<ll> A;

    cin >> N;
    A = vector<ll>(N);
    rep(i, N) cin >> A[i];

    // Process
    sort(A.begin(), A.end(), greater<ll>());

    ll ans = 0;
    const int turning_point = (N + 1) / 2;
    rep(i, N - 1) {
        if (i < turning_point)
            ans += A[i];
        else
            ans += A[N - 1 - i];
    }

    // Output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4844
#include <bits/stdc++.h> 
using namespace std; 
#define for_(i, s, e) for (int i = s; i < e; i++)
#define for__(i, s, e) for (ull i = s; i < e; i++)
#define SSTR(x) static_cast<std::ostringstream&>((std::ostringstream() << std::dec << x)).str()
typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;


int main() {
    #ifndef ONLINE_JUDGE
	// freopen("test.in", "r", stdin);
    #endif
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
	unordered_map<string, int> mp;
	for_(i, 0, n) {
		string s; cin >> s;
		mp[s] += 1;
	}

	int mx = 0;
	for (pair<string, int> i: mp) mx = max(i.second, mx);
	vector<string> all;
	for (pair<string, int> i: mp) {
		if (i.second == mx) {
			all.push_back(i.first);	 
		}
	}

	sort(all.begin(), all.end());
	for (string i: all) cout << i << endl;

    return 0;
}

Measured memory_bytes: 25284
n,m = gets.split(' ').map(&:to_i)
a = Array.new(m)
b = Array.new(m)
graph = Array.new(n).map{ [] }
for m_i in 0...m do
    a[m_i], b[m_i] = gets.split(' ').map(&:to_i).map{ |a| a-1 }
    graph[a[m_i]] << b[m_i]
    graph[b[m_i]] << a[m_i]
end


queue = [0]
dists = Array.new(n) ; dists[0] = 0
signs = Array.new(n)
visited = Array.new(n,false) ; visited[0] = true

while !queue.empty? do
    room = queue.shift
    # for m_i in 0...m do
    #     if a[m_i] == room && !visited[b[m_i]]
    #         queue.push b[m_i]
    #         dists[b[m_i]] = dists[room]+1
    #         signs[b[m_i]] = room
    #         visited[b[m_i]] = true
    #     elsif b[m_i] == room && !visited[a[m_i]]
    #         queue.push a[m_i]
    #         dists[a[m_i]] = dists[room]+1
    #         signs[a[m_i]] = room
    #         visited[a[m_i]] = true
    #     end
    # end
    graph[room].each do |r|
        if !visited[r]
            queue.push r
            signs[r] = room
            dists[r] = dists[room]+1
            visited[r] = true
        end
    end

    # p "queue #{queue}"
    # p "signs #{signs}"
end

# p dists
# p signs
# p visited

puts 'Yes'
for n_i in 1...n
    puts signs[n_i]+1
end


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

int main() {
  int N, L, answer=0;
  cin >> N >> L;
  vector<int> taste(N);
  bool contain0 = false;
  for (int i=0; i<N; i++) {
    taste.at(i) = L+i;
  }
  for (int i=0; i<N; i++) {
    if (taste.at(i)==0) {
      contain0 = true;
      break;
    }
  }
  sort(taste.begin(), taste.end());
  if (!contain0) {
    if (taste.at(0) > 0) {
      for (int i=1; i<N; i++) {
        answer += taste.at(i);
      }
    }
    if (taste.at(N-1) < 0) {
      for (int i=0; i<N-1; i++) {
        answer += taste.at(i);
      }
    }
  }
  else {
    for (int i=0; i<N; i++) {
      answer += taste.at(i);
    }
  }
  cout << answer << endl;
}

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

using namespace std;

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

    vector<double> p(N);
    for (int coin = 1; coin <= N; coin++) cin >> p[coin - 1];

    vector<long double> DP(N + 1);
    DP[0] = 1;
    for(int coin = 1; coin <= N; coin++)
        for(int index = N; index > 0; index--)
            DP[index] = (DP[index - 1]*p[coin - 1]) + (DP[index]*(1 - p[coin - 1]));

    cout << setprecision(10) << DP[1 + N / 2];

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,tmp;
	while(cin>>n,n){
		int a[100],r=n-1,cnt=0;
		for(int i=0;i<n;i++)cin>>a[i];
		for(int i=0;i<n-1;i++){
			for(int j=0;j<r;j++){
				if(a[j]>a[j+1]){
					tmp=a[j];a[j]=a[j+1];a[j+1]=tmp;
					cnt++;
				}
			}
			r--;
		}
		cout<<cnt<<endl;
	}
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;

int N, T;
int dp[3001] = {0};
pair<int, int> arr[3001];

int main() {
    cin >> N >> T;
    for (int i = 1; i <= N; i++) {
        cin >> arr[i].first >> arr[i].second;
    }

    sort(arr + 1, arr + 1 + N);

    for (int i = 1; i <= N; i++) {
        int a = arr[i].first, b = arr[i].second;
        for (int j = 0; j < T; j++) {
            dp[T] = max(dp[T], dp[j] + b);
        }
        for (int j = T - 1; j > 0; j--) {
            if (j >= a) {
                dp[j] = max(dp[j], dp[j - a] + b);
            }
        }
    }
    cout << dp[T] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }

const int mod=1000000007;
const int INF=1001001001;

int main() {
  int N;
  cin>>N;
  cout<<(N+999)/1000*1000-N<<endl;
  return 0;  
}

Measured memory_bytes: 3636
#include<cstdio>


int main(){
    int a,b,c;
    scanf("%d%d",&a,&b);
    c = 1;
    if(b == 100) b = 101;
    for(int i = 0;i < a;i++){
        c *= 100;
    }
    printf("%d",c * b);
    return 0;
}

Measured memory_bytes: 128
n = input()
array = []
i = 1
while i <= n:
    x = i
    if x % 3 == 0:
        array.append(i)
    else:
        while x != 0:
            if x % 10 == 3:
                array.append(i)
                break
            x /= 10
    i += 1
print str(array).replace('[', ' ').replace(']', '').replace(',', '')

Measured memory_bytes: 4452
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60 ; const ll mod=1e9+7 ;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------

int main(){
	int a,b,c; cin  >> a >> b >> c;
	int ans = c-(a-b);
	cout << max(ans,0) << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
P =[]
s = 0
for _ in range(n):P.append(list(map(int,input().split())))
P.append(P[0])
for j in range(n):s += P[j][0]*P[j+1][1] - P[j][1]*P[j+1][0]
print(s*0.5)

Measured memory_bytes: 7672
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
if n%2 == 1:
    print(0)
    exit()
m = n//2
x = 0
for i in range(1,30):
    x += m//(5**i)
print(x)


Measured memory_bytes: 3064
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

ll DP[100001];


ll Calc(int turn){
  if (turn == 0) return DP[0] = 0;
  if (DP[turn] != -1) return DP[turn];

  ll ans = 1e9;
  ll now = 1;
  while (turn - now >= 0){
    ans = min(ans, Calc(turn - now) + 1);
    now *= 6;
  }
  now = 1;
  while (turn - now >= 0){
    ans = min(ans, Calc(turn - now) + 1);
    now *= 9;
  }
  return DP[turn] = ans;
}

int main(){
  int N; cin >> N;
  fill(DP, DP + N + 1, -1);
  cout << Calc(N) << endl;
  return 0;
}

Measured memory_bytes: 5760
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long
#define ggr getchar();getchar();return 0;
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int a[3];
signed main() {
	rep(i, 3)cin >> a[i];
	sort(a, a + 3);
	cout << a[0] * a[1] / 2 << endl;
	ggr
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	

    LL N; cin >> N;
    FOR(a,1,3501)
    {
        FOR(b,a,3501)
        {
            if(4*a*b-N*(a+b) != 0)
            {

            if((N*a*b) % (4*a*b-N*(a+b)) == 0) 
            {
                if((N*a*b) / (4*a*b-N*(a+b)) > 0)
                {

                cout << a<<" " <<b<<" "<< (N*a*b) / (4*a*b-N*(a+b)) << endl;
                return 0;
            }
            }
        }
        }
    }

}


Measured memory_bytes: 256
function main(input){
    d=input;
    var a=["Christmas","Christmas Eve","Christmas Eve Eve","Christmas Eve Eve Eve"];
    var b=[25,24,23,22]
    for (var i = 0;i<4;i++){
        if (d==b[i]){
            console.log(a[i])
        }
    }
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <iostream>
#include <iomanip>
#include <complex>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <sstream>
using namespace std;

const double EPS = 1e-10;
const double INF = 1e12;
#define EQ(n,m) (abs((n)-(m)) < EPS)
#define X real()
#define Y imag()

typedef complex<double> P;
typedef vector<P> VP;
struct L : array<P, 2>{
    L(const P& a, const P& b){ at(0)=a; at(1)=b; }
    L(){}
};
double dot(P a, P b){
    return (conj(a)*b).X;
}
double cross(P a, P b){
    return (conj(a)*b).Y;
}
P projection(const L& l, const P& p) {
    double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
    return l[0] + t*(l[0]-l[1]);
}
P reflection(const L& l, const P& p) {
    return p + 2.0*(projection(l, p) -p);
}
P crosspointLL(const L &l, const L &m) {
  double A = cross(l[1]-l[0], m[1]-m[0]);
  double B = cross(l[1]-l[0], l[1]-m[0]);
  return m[0] + B/A *(m[1]-m[0]);
}

struct PorL{
    L p;
    bool isP;
};

PorL marge(PorL a, PorL b){
    PorL res;
    if(a.isP && b.isP){
        res.p[0] = a.p[0];
        res.p[1] = b.p[0];
        res.isP = false;
    }else if(!a.isP && !b.isP){
        res.p[0] = crosspointLL(a.p, b.p);
        res.isP = true;
    }else{
        if(a.isP) swap(a, b);
        res.p[0] = reflection(a.p, b.p[0]);
        res.isP = true;
    }
    return res;
}

PorL parse(string s){
    PorL res;
    bool empty = true;
    int begin = 0;
    while(begin < (int)s.length()){
        int pos = begin +1;
        int depth = 1;
        bool noat = true;
        while(depth > 0){
            if(s[pos] == '(') depth++;
            if(s[pos] == ')') depth--;
            if(s[pos] == '@') noat = false;
            pos++;
        }
        PorL ret;
        if(s[begin +1] == '('){
            ret = parse(s.substr(begin+1, pos-begin-2));
        }else if(noat){
            stringstream buf(s.substr(begin, pos-begin));
            buf >> ret.p[0];
            ret.isP = true;
        }else{
            ret = parse(s.substr(begin, pos-begin));
        }
        if(empty){
            res = ret;
            empty = false;
        }else{
            res = marge(res, ret);
        }
        begin = pos+1;
    }
    return res;
}

int main(){
    while(1){
        string s;
        cin >> s;
        if(s=="#") break;

        PorL ret = parse(s);
        cout << fixed << setprecision(10);
        cout << ret.p[0].X << " " << ret.p[0].Y << endl;
    }
    return 0;
}


Measured memory_bytes: 3316
n = int(input())
# M,A,R,C,H
num = [0] * 5
check_list = ['M','A','R','C','H']
for _ in range(n):
    s = input()
    for i, c in enumerate(check_list):
        if s[0] == c:
            num[i]+=1
            break
ans = 0
for i in range(5-2):
    for j in range(i+1, 5-1):
        for k in range(j+1, 5):
            ans += num[i]*num[j]*num[k]
print(ans)

Measured memory_bytes: 3064
using System;
using System.Linq;

namespace AtCoderTutorial
{
    public class AtCoder176
    {
        public static void Main(string[] args)
        {
            long N = long.Parse(Console.ReadLine());
            long[] an = Console.ReadLine().Split(' ').Select(_ => long.Parse(_)).ToArray();
            long total = 0;

            for (long i = 1; i < an.Length; i++)
            {
                if (an[i - 1] > an[i])
                {
                    long diff = an[i - 1] - an[i];
                    total += diff;
                    an[i] += diff;
                }
            }

            Console.WriteLine(total);
        }
    }
}

Measured memory_bytes: 47784
n = int(input())
lst = list(map(int, input().split()))

# counter
from collections import Counter
cntr = Counter(lst)

# combination
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

total = 0
# countSameNames
for value in cntr.values():
    if value > 1:
        total += combinations_count( value, 2 )


for l in lst:
    print(total - (cntr[l]-1))

Measured memory_bytes: 26268
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
double pie=3.14159265358979;
long long mod=998244353;
//
int main(){
	char s;
	cin>>s;
	if('A'<=s&&s<='Z'){
		cout<<'A'<<endl;
	}else{
		cout<<'a'<<endl;
	}
	return 0;
}

Measured memory_bytes: 3620