akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000001000
#define int long long
using namespace std;
signed main()
{
    int n;
    while (cin >> n, n)
    {
        //cout << "--------------------------------------------" << endl;
        //cout << n << endl;
        vector<int> vec(n + 1);
        string s;
        int seq = 0;
        bool none_flag = false;
        bool x = false;
        rep(i, n)
        {
            cin >> s;
            if (s == "x")
            {
                seq++;
                x = true;
                if ((i + 1) % 2 == 0)
                    vec[i] = INF;
                else
                    vec[i] = -INF;
            }
            else
            {
                seq = 0;
                vec[i] = atoi(s.c_str());
                if (i > 0 && (i + 1) % 2 == 0)
                {
                    if (vec[i] <= vec[i - 1])
                        none_flag = true;
                }
                if (i > 0 && (i + 1) % 2 == 1)
                {
                    if (vec[i] >= vec[i - 1])
                        none_flag = true;
                }
            }
            if (seq > 1)
                none_flag = true;
            //cout << s << " ";
        }
        //cout << endl;
        //cout << vec[0] << " " << vec[1] << endl;
        if (none_flag)
        {
            cout << "none" << endl;
            continue;
        }
        if (!x)
        {
            cout << "ambiguous" << endl;
            continue;
        }
        int sup = INF, inf = -INF;
        int max_tmp, min_tmp;
        rep(i, n)
        {
            if (vec[i] == INF || vec[i] == -INF)
            {
                if ((i + 1) % 2)
                {
                    if (i == 0)
                        max_tmp = vec[i + 1];
                    else if (i == n - 1)
                        max_tmp = vec[i - 1];
                    else
                        max_tmp = min(vec[i + 1], vec[i - 1]);
                    sup = min(sup, max_tmp);
                }
                else
                {
                    if (i == 0)
                        min_tmp = vec[i + 1];
                    else if (i == n - 1)
                        min_tmp = vec[i - 1];
                    else
                        min_tmp = max(vec[i + 1], vec[i - 1]);
                    inf = max(inf, min_tmp);
                }
            }
            //cout << inf << " " << sup << endl;
        }
        sup--;
        inf++;
        //cout << inf << " " << sup << endl;
        if (sup == inf)
            cout << sup << endl;
        else if (sup == -INF - 1 || inf == INF + 1)
            cout << "ambiguous" << endl;
        else if (inf < sup)
            cout << "ambiguous" << endl;
        else
            cout << "none" << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
//
//  main.cpp
//  Cat Snuke and a Voyage
//
//  Created by wenhan on 2017/7/29.
//  Copyright © 2017年 wenhan. All rights reserved.
//
#include<cstdio>
using namespace std;
int a[200005],b[200005]={0};
int s;
int main()
{
    int n,m;
    int x,y;
    s=0;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&x,&y);
        if(x==1)
            a[++s]=y;
        if(y==n)
            b[x]++;
    }
    bool f=false;
    for(int i=1;i<=s;i++)
        if(b[a[i]]==1)
        {
            f=true;
            break;
        }
        if(f)
            printf("POSSIBLE\n");
        else
            printf("IMPOSSIBLE\n");
    return 0;
}

Measured memory_bytes: 1280
cake = []
donut = []
for i in range(1, 26):
	cake.append(i*4)
for i in range(1, 15):
	donut.append(i*7)

n = int(raw_input())

flag = False
if n in cake: flag = True
if n in donut: flag = True
if not flag:
	for i in range(0, len(cake)):
		for j in range(0, len(donut)):
			if n == cake[i] + donut[j]:
				flag = True
				break
		if flag: break

if flag: print 'Yes'
else: print 'No'

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

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(){
    string s;cin>>s;
    cout<<count(all(s),'1')<<endl;
    return 0;
}


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

int main() {
	string s;
	cin >> s;
	int n , i , j, k , l;
	n = s.length();
	auto f = [&](char c) {
	    return c-'0';
	};
	int ans = INT_MAX;
	for(i = 0;i < n-2;++i) {
	    int num = f(s[i])*100+f(s[i+1])*10+f(s[i+2]);
	    ans = min(ans , abs(num - 753));
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var N, Y int
	fmt.Scanf("%d %d", &N, &Y)

	for i := 0; i <= N; i++ {
		for j := 0; j <= N - i; j++ {
			if k := N - (i + j); Y == 10000*i + 5000*j + 1000*k {
				fmt.Printf("%d %d %d\n", i, j, k)
				return
			}
		}
	}
	fmt.Printf("-1 -1 -1")
	return 
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
//#pragma GCC optimize(2)
using namespace std;
const int N=1<<16;
const int M=1LL<<30;
const int inf=1e9+7;
const LL INF=1e18;
const double eps=1e-6;
typedef complex<double>C;
const double PI(acos(-1.0));
//for(int mask=i;mask>0;mask=(mask-1)&i)
//int a[25]= { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
//__gcd, atan2(y,x)=y/x , __int128
//c(n,k)=c(n-1,k-1)+c(n-1,k)
//c(i,r),i for r to n =c(n+1,r+1)
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){int s=0;while(x){s+=BIT[x];x-=x&-x;}return s;}
//int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
//LL pw(LL a,LL b){LL t=1;for(;b;b>>=1,a=a*a%M)b&1?t=t*a%M:0;return t;}
//log() = ln() , log(x)/log(y)=log(y)-base-x
//INT_MAX 127,INT_MIN 128
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
//cout<<fixed<<setprecision(12)<<ans<<endl;
//__builtin_popcount(mask)
int n,x;
int a[N];
int main(){Accel
	cin>>n>>x;
	REP(i,n){
		cin>>a[i];
	}
	sort(a,a+n);
	int cnt=0;
	for(int i=0;i<n;i++){
		if(x>=a[i])
			x-=a[i],cnt++;
	}
	if(x&&cnt==n)cnt--;
	cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
// 1,000,000,000,000,001
int main(void)
{
  int n, m, fl = 0;
  ll k, apos = 0, bpos = 0, alla = 0, timeb, max = 0, ch = 0;
  ll a[200001];
  ll b[200001];
  ll i, rest;
  scanf("%d%d%lld", &n, &m, &k);
  for (i = 0; i < n; i++)
  {
    scanf("%lld", &a[i]);
  }
  for (i = 0; i < n; i++)
  {
    alla += a[i];
    if (alla <= k)
    {
      apos++;
    }
    else
    {
      alla -= a[i];
      break;
    }
  }
  for (i = 0; i < m; i++)
  {
    scanf("%lld", &b[i]);
  }
  while (1)
  {
    if (bpos == m)
      break;
    alla += b[bpos];
    if (alla <= k)
    {
      bpos++;
    }
    else
    {
      alla -= b[bpos];
      break;
    }
  }
  //printf("%lld %lld\n", apos, bpos);
  if (apos == n && bpos == m)
  {
    printf("%d\n", n + m);
    return 0;
  }
  //このときはできるだけaを読んでから、隙間をbで埋めた状態
  //よってこの段階ではaからapos冊,bからbpos冊読んだ状態になっている(a[apos-1], b[bpos-1]までを使っている)
  rest = k - alla; //残った時間
  max = apos + bpos;
  i = 0;
  while (apos > 0)
  {
    rest += a[apos - 1]; //aの最後の１冊を読むのをやめた
    apos--;
    while (1) //この時間でBをどれだけ読めるか?
    {
      if (bpos == m)
      { //読み切った
        break;
      }
      rest -= b[bpos];
      if (rest >= 0)
      {
        bpos++;
      }
      else
      {
        rest += b[bpos];
        break;
      }
    }
    ch = bpos + apos;
    if (ch > max)
      max = ch;
  }
  printf("%lld\n", max);
  return 0;
}


Measured memory_bytes: 4848
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, M;
  vl A;
  cin >> N >> M;
  cout << max(N + M, max(N + N - 1, M + M - 1)) << endl;

  return 0;
}


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

using namespace std;
typedef long long ll;

int main() {
    int k;
    cin >> k;
    vector<int> a;
    a.push_back(0);
    while (k--) {
        int p = -1;
        for (int i = 0; i < a.size(); i++) {
            if (i < a.size() - 1 && a[i + 1] >= a[i] && a[i] < 9) {
                a[i]++;
                for (int j = i - 1; j >= 0; j--) a[j] = max(0, a[j + 1] - 1);
                p = i;
                break;
            }
        }
        if (p == -1) {
            if (a.back() == 9) a.push_back(1);
            else a.back()++;
            for (int i = a.size() - 2; i >= 0; i--) a[i] = max(0, a[i + 1] - 1);
        }
    }
    reverse(a.begin(), a.end());
    for (auto e : a) cout << e;
    cout << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n;
    cin >> n;
    n %= 10;
    if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) cout << "hon" << endl;
    else if (n == 0 || n == 1 || n == 6 || n == 8) cout << "pon" << endl;
    else cout << "bon" << endl;
    return 0;
}

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

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

    int cnt = 0;
    for (int i = 0; i < N; i++) {
        int t;
        cin >> t;
        if (t >= K) cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <boost/rational.hpp>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> grid(H);
  rep(i, H) {
    cin >> grid[i];
    grid[i].push_back('?');
  }
  grid.push_back(string(W + 1, '?'));

  const int INF = H * W;
  vector<vector<int>> dist(H + 1, vector<int>(W + 1, INF));
  dist[0][0] = 0;
  rep(i, H) rep(j, W) {
    chmin(dist[i][j + 1], dist[i][j] + (grid[i][j] != grid[i][j + 1]));
    chmin(dist[i + 1][j], dist[i][j] + (grid[i][j] != grid[i + 1][j]));
  }

  int result =
      dist[H - 1][W - 1] + (grid[0][0] == '#') + (grid[H - 1][W - 1] == '#');
  cout << (result + 1) / 2 << endl;
  return 0;
}


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

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q>
ostream& operator << (ostream& os, pair<P, Q> p)
{
  os << "(" << p.first << "," << p.second << ")";
  return os;
}


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

  string s;
  int k;
  while (cin >> s >> k) {
    vector<string> v;
    for (int i = 0; i < s.size(); ++i) {
      string t;
      for (int j = 0; j < 5 && i + j < s.size(); ++j) {
        t += s[i + j];
        v.push_back(t);
      }
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    cout << v[k - 1] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1660
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def solve():
    ans = -inf
    for si in range(n):
        cs = [0]
        i = si
        for _ in range(k):
            i = pp[i]
            cs.append(cs[-1] + cc[i])
            if i == si: break
        cur = max(cs[1:])
        if len(cs) < k + 1:
            d = len(cs) - 1
            c = k // d
            r = k - d * c
            cur1=cs[-1] * c + max(cs[:r+1])
            cur2=cs[-1]*(c-1)+max(cs)
            cur = max(cur,cur1,cur2)
        #print(cs)
        ans = max(ans, cur)
    print(ans)

inf=10**16
n,k=MI()
pp=LI1()
cc=LI()
solve()


Measured memory_bytes: 86504
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static bool Solve(string S)
        {
            const string K = "keyence";
            int N = S.Length;
            int i = 0;
            while (i < Math.Min(N, 7) && S[i] == K[i]) { ++i; }
            int j = 0;
            while (j < Math.Min(N, 7) && S[N - j - 1] == K[6 - j]) { ++j; }
            return i + j >= 7;
        }

        static void Main(string[] args)
        {
            Console.WriteLine(Solve(Read()) ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 13140
n, m = gets.split.map(&:to_i)
h = gets.split.map(&:to_i)
check = Array.new(n, true)

m.times do
  a, b = gets.split.map(&:to_i)
  a -= 1
  b -= 1
  if h[a] > h[b]
    check[b] = false
  elsif h[a] < h[b]
    check[a] = false
  else
    check[a] = false
    check[b] = false
  end
end

puts check.filter { |i| i == true }.length


Measured memory_bytes: 22584
import sys
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    a, b = geta(int)

    print(max(0, a - 2 * b))


if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
#include<iostream>
using namespace std;
int main(){
  int x, y;
  cin >> x >> y;
  for (int i=0; i <=x; i++){
  	if ((i*2+(x-i)*4)==y){
  		cout <<"Yes" << endl;
  		return 0;
  	}
  }
  cout << "No" << endl;
}


Measured memory_bytes: 3100
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct process {
  char name[16];
  int time;
} process;

/* copy the process ** from q to p ** */
void processcpy(process *p, process *q){
  strcpy(p->name, q->name);
  p->time = q->time;
}

/* double-linked linear list of process 
   (to implement process queue) */
typedef struct Node_t {
  process data;
  struct Node_t *next;
  struct Node_t *prev;
} Node;

typedef struct List {
  Node *head;
  Node *tail;
} List;

Node *create_Node(process new_data){
  Node *ret = (Node*)malloc(sizeof(Node));
  if(!ret){
    fprintf(stderr, "could not allocate a node.\n");
    exit(1);
  }
  processcpy(&(ret->data), &new_data);
  ret->prev = NULL;
  ret->next = NULL;
  return ret;
}

int is_nil(const List *l){
  return (l->head == NULL && l->tail == NULL);
}

Node *push_front(List *l, process data){
  Node *new_node = create_Node(data);
  Node *temp;
  if(is_nil(l)){
    l->head = l->tail = new_node;
  }else{
    temp = l->head;
    l->head = temp->prev = new_node;
    new_node->next = temp;
  }
  return new_node;
}

process pop_back(List *l){
  process ret; Node *temp;
  if(is_nil(l)){
    fprintf(stderr, "Error: Couldn't pop from empty list\n");
  }else{
    temp = l->tail;
    processcpy(&ret, &(temp->data));
    if(l->head == l->tail){
      // if l has just one element,
      // l->head and l->tail must be NULL after pop_front.
      l->head = NULL; 
    }
    l->tail = temp->prev;
    free(temp);
  }
  return ret;
}

/* for initializing list */
void init_list(List *l){
  l->head=NULL;
  l->tail=NULL;
}

/* free allocated memories */
void free_list(List *l){
  Node *ptr=l->head, *temp;
  while(ptr!=NULL){
    temp=ptr->next;
    free(ptr);
    ptr=temp;
  }
  init_list(l);
}

int main(void){
  List queue; init_list(&queue);
  int n, q;
  int time=0;
  process p;

  /* read input stream */
  scanf("%d %d", &n, &q);
  for(int i=0; i<n; i++){
    scanf("%s %d", p.name, &(p.time));
    push_front(&queue,p);
  }

  /* Let's simulate scheduling naively! */
  while(!is_nil(&queue)){
    p = pop_back(&queue);
    if(p.time <= q){
      /* process can be finished */
      time += p.time;
      printf("%s %d\n", p.name, time);
    }else{
      /* process cannot be finished, then handle p for q [ms],
	 and then moved it to the end of the queue */
      p.time -= q;
      push_front(&queue,p);
      time += q;
    }
  }

  free_list(&queue);
  return 0;
}



Measured memory_bytes: 4048
#include <bits/stdc++.h>
using namespace std;
int k,n,a[200001],mx,i;
int main() {
    cin >> k >> n;
    for (i=1; i<=n; i++)
    {
        cin >> a[i];
        if (i>1 )
            mx=max(mx,a[i]-a[i-1]);
    }
    mx=max(mx,k-a[n]+a[1]);
    cout<<k-mx;

}


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



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

    int n,k;
    cin>>n>>k;
    if(k==1){
        cout<<0<<endl;
        return 0;
    }
    cout << n-k << endl;

}

Measured memory_bytes: 256
//設定言語check
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
#include <math.h>
using namespace std;

int main(){
  int N, R, D, count, ans = 0 ;
  cin >> N ;
  int A[N] ;
  for(int i=0;i<N;i++){
    cin >> A[i] ;
  }
  for(int i=0;i<N;i+=2){
    if(A[i] % 2 == 1) ans++ ;
  }
  
  cout << ans << endl ;
  return 0 ;
}  

Measured memory_bytes: 3668
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	int a,b,c,d;
    cin>>a>>b>>c>>d;
    int x,y;
	x=(a+d-1)/d;
    y=(c+b-1)/b;
    if(x>=y)    cout<<"Yes";
    else    cout<<"No";
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  int n; cin >> n;
  set<int> st;
  for (int i = 0; i < n; i++) {
    int a; cin >> a;
    st.insert(a);
  }
  if (st.size() == n) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main() {
	ll n;
	cin>>n; 
	ll a[n],i;
	for(i=0;i<n;i++) cin>>a[i];
	ll dp[n];
	dp[0]=0;
	dp[1]=abs(a[1]-a[0]);
	for(i=2;i<n;i++) {
		ll t1=abs(a[i]-a[i-1]);
		ll t2=abs(a[i]-a[i-2]);
		dp[i]=min(t1+dp[i-1],t2+dp[i-2]);
	}
	cout<<dp[n-1]<<"\n";
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "\n[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "\n[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]\n";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    int n, k, r, s, p;
    string t;
    cin >> n >> k >> r >> s >> p >> t;

    vector<pair<int, char>> m {{ r, 's' }, { p, 'r' }, { s, 'p' }};
    sort(m.begin(), m.end(), [] (auto& p, auto& p1) {
        return p.first > p1.first;
    });
    
    int ans = 0;
    vector<bool> used (n, false);

    for (auto it = m.begin(); it != m.end(); ++it) {
        for (int i = 0; i < n; ++i) {
            if (t[i] == it->second && (i - k < 0 || t[i-k] != t[i] || !used[i-k])) {
                ans += it->first;
                used[i] = true;
            }
        }

    }

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



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


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

    vector< int >L(n);
    for (int &x : L) cin >> x;

    sort(L.rbegin(), L.rend());

    int ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            if (L[i]==L[j]) continue;
            for (int k = j+1; k < n; k++) {
                if (L[j]==L[k]) continue;
                ans += L[j]+L[k] > L[i];
            }
        }
    }

    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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 T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } 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; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;
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;
}
signed main()
{
    int n, k;
    cin >> n >> k;
    COMinit();
   
        int index = n;
        for (int i = 0; i <= n; i++)
        {
            if(i>k){
                index = i;
                break;
            }
        }
        
        ll cnt = 0;
       // cerr << index << endl;
        for (int i = n; i > n-index; i--)
        {
            cnt += COM(n, i) * COM(n - 1, i - 1);
            cnt %= MOD;
          //  cerr << cnt << endl;
        }
        cout << cnt << endl;
    
  

        return 0;
}

Measured memory_bytes: 12160
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int x; cin >> x;
    cout << (x^1) << endl;
    return 0;
}


Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,b,cnt=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>b;
        cnt=__gcd(cnt,b);
    }
    cout<<cnt<<endl;
    return 0;

}


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

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

using namespace std;

int main(){
	int a,b,c,x; cin>>a>>b>>c>>x;
	int ans=0;
	rep(i,a+1) rep(j,b+1) rep(k,c+1) if(i*500+j*100+k*50==x) ans++;
	cout<<ans<<endl;

	return 0;
}


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

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

    const int NMMAX = 60;
    int A[NMMAX], B[NMMAX];

    for(int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
    }

    int road[NMMAX];
    for(int i = 0; i < N; i++) {
        road[i] = 0;
    }

    for(int i = 0; i < M; i++) {
        road[A[i]-1] += 1;
        road[B[i]-1] += 1;
    }

    for(int i = 0; i < N; i++) {
        cout << road[i] << endl;
    }
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

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<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


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

    vector<ll> ab(N);

    ll sumb=0;
    REP(i,N){
        int a,b;
        cin >> a >> b;
        sumb += b;
        ab[i] = a + b;
    }

    sort(all(ab),greater<>());

    ll ans = -sumb;
    for(int i=0 ; i < N ; i += 2) ans += ab[i];

    pl(ans)

    return 0;
}

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

int main()
{
  string S, T;
  cin >> S >> T;
  bool ok = true;
  map<char, char> ma, ima;
  for (int i = 0; i < S.size(); i++)
  {
    char s = S.at(i), t = T.at(i);
    if (ma.count(s) > 0) // ma に s が存在している
      if (ma[s] != t)    //ma の キーsの値がtではない
        ok = false;
    if (ima.count(t) > 0) // imaにtが存在している
      if (ima[t] != s)    // imaのキーtの値がsではない
        ok = false;
    ma[s] = t;  //maのキーsに値tをセット
    ima[t] = s; // imaのキーTに値sをセット
  }
  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 776
'use strict';
function main(input) {
  const args = input.split('\n'),
        NKQ = args[0].split(' '),
        N = parseInt(NKQ[0]),
        K = parseInt(NKQ[1]),
        Q = parseInt(NKQ[2]),
        A = args.slice(1, Q+1);
  const limitter = Q - K;
  let counter = new Array(N);
  for (let i = 0; i < N; ++i) {
    counter[i] = 0;
  }
  for (let a of A) {
    ++counter[parseInt(a)-1];
  }
  for (let c of counter) {
    if (c > limitter) {
      console.log('Yes');
    } else {
      console.log('No');
    }
  }
}

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

Measured memory_bytes: 30852
#include<bits/stdc++.h>
using namespace std;
vector<int> dp;
int helperfn(int i,vector<vector<int> >&matrix)
{
	// cout<<"helperfn"<<"  "<<i<<endl;
	if(matrix[i].size()==0)
	return 0;
	
	if(dp[i]!=-1)
		return dp[i];
	int maxi=0;
	for(int j=0;j<matrix[i].size();j++)
	{
		maxi=max(maxi,1+helperfn(matrix[i][j],matrix));
	}	

	dp[i]= maxi;
	return maxi;



}

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

	vector<vector<int> > matrix(n+2);
	
	for(int i=0;i<=n;i++)
		dp.push_back(-1);

	for(int i=0;i<m;i++)
	{
		int a,b;
		cin >> a >> b;
		matrix[a].push_back(b);
	}
	
	int ans=0;
	
	for(int i=1;i<=n;i++)
	{
		
			int x =helperfn(i,matrix);
		
	}

	for(int i=1;i<=n;i++)
	ans=max(ans,dp[i]);
	
	cout<<ans;
	return 0;

}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int N;
  cin >> N;
  string s[50];
  string x;
  int sum_t = 0;
  int t[50];
  REP(i, N) {
    cin >> s[i];
    cin >> t[i];
    sum_t += t[i];
  }
  cin >> x;
  int current_sum = 0;
  int ans = 0;
  REP(i, N) {
    if (s[i] == x) {
      ans = sum_t - current_sum - t[i];
      break;
    }
    current_sum += t[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>



int top=0;
int a[100];

void push(int);
int pop(void);

int main()
{
  int tmp1,tmp2;
  char s[100];


  
  
  while(scanf("%s",s) != EOF)
    {
      if(s[0] == '+')
	{
	  tmp1 = pop();
	  tmp2 = pop();
	  
	  push(tmp1+tmp2);
	  // printf("%d",S[top]);

	}
      else if(s[0] =='-')
	{
	   tmp1 = pop();
	   tmp2 = pop();

	   push(tmp2-tmp1);
	  
	}
      else if(s[0] =='*')
	{
	  tmp1 = pop();
	  tmp2 = pop();

	  push(tmp1*tmp2);
	}
      else
	{


	  push(atoi(s));
	  //	  printf("%d",tmp1);
	}
      
    }
  printf("%d\n",pop());

  return 0;
}

void push(int num)
{
 top++;
  a[top] = num;
 
 
}

int pop()
{
 
  top--;
  return a[top+1];
}





Measured memory_bytes: 2096
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(int n);            // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。
vector<pair<long long,long long>> prime_factorize(long long p); // 素因数分解

// class
// ------------------------------------------------
class Combi {
  public:
    Combi();
    long long Combination(long long n, long long k);
    long long nPk_modp(long long n, long long k, long long p);
  private:
    map<long long, map<long long, long long>> memo;
    long long n_num;
    long long k_num;
};

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(long long(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(long long(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<long> vll;
// code
// ------------------------------------------------
int main() {

    ll n;
    cin >> n;

    ll ans = kiriage(n,1000) * 1000 - n;

    cout << ans << endl;

    return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n) {
  int i = 1;
  while(1) {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n) {
  int s = 0;
  while(n) {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str) {
  for(auto itr = str.begin();itr != str.end() ; itr++) {
    if(97 <= *itr && *itr <= 122) {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str) {
  for(auto itr = str.begin();itr != str.end() ; itr++) {
    if(65 <= *itr && *itr <= 90) {
      *itr = *itr + 32;
    }
  }
  return str;
}


Combi::Combi() {
  n_num = -1;
  k_num = -1;
};

ll Combi::Combination(ll n, ll k) {

  ll ret;
  if(memo[n][k] != 0) {
    ret = memo[n][k];
  } else if(n == k || k == 0) {
    memo[n][k] = 1;
    ret = 1;
  } else {
    ret = Combination(n - 1, k - 1) + Combination(n - 1, k);
    memo[n][k] = ret;
  }
  return ret;
}

long long Combi::nPk_modp(long long n, long long k, long long p) {
  ll ans = 1;
  for(long long i = k; i <= n; i++) {
    ans = (ans * i) % p;
  }

  return ans;
};

vector<pair<long long,long long>> prime_factorize(long long p) {
    vector<pair<long long,long long>> ret;

    for(long long x = 2; x * x <= p; ++x) {
        if(p % x != 0) continue;
        long long num = 0;
        while(p % x == 0) {
            num++;
            p /= x;
        }
        ret.push_back(make_pair(x,num));
    }

    if(p != 1) ret.push_back(make_pair(p, 1));
    
    return ret;
}

Measured memory_bytes: 3588
N = int(input())

flag = False

d1 = [0]*N
d2 = [0]*N
for i in range(N):
  d1[i], d2[i] = input().split()
  
for k in range(N-2):
  if ((d1[k])==(d2[k]))and((d1[k+1])==(d2[k+1]))and((d1[k+2])==(d2[k+2])):
    flag = True
    break
    
if flag:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9200
{-# LANGUAGE OverloadedStrings #-}

import Data.ByteString as B
import Data.ByteString.Char8 as BC

main = do
  s <- BC.getLine
  if check s
    then BC.putStrLn "Yes"
    else BC.putStrLn "No"

check :: B.ByteString -> Bool
check str = c3 == c4 && c5 == c6
  where
    c3 = str `BC.index` 2
    c4 = str `BC.index` 3
    c5 = str `BC.index` 4
    c6 = str `BC.index` 5


Measured memory_bytes: 380
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main(){
  int i,j,k,N,H,W,cnt=0,map[2001][2001],hmap[2001][2001]={0},wmap[2001][2001]={0};
  scanf("%d",&H);
  scanf("%d",&W);
  char ss[2001];
  for(i=0;i<H;i++){
    scanf("%s",ss);
    for(j=0;j<W;j++){
      if(ss[j]=='#'){
        map[i][j]=0;
        hmap[i][j]=0;
        for(k=1;k<=cnt;k++){
          hmap[i][j-k]=cnt;
        }
        cnt=0;
      }else{
        cnt++;
        map[i][j]=1;
      }
    }
    if(cnt>0){
      for(k=1;k<=cnt;k++){
        hmap[i][j-k]=cnt;
      }
    }
    cnt=0;
  }

  cnt=0;
  for(i=0;i<W;i++){
    for(j=0;j<H;j++){
      if(map[j][i]==0){
        wmap[j][i]=0;
        for(k=1;k<=cnt;k++){
          wmap[j-k][i]=cnt;
        }
        cnt=0;
      }else{
        cnt++;
      }
    }
    if(cnt>0){
      for(k=1;k<=cnt;k++){
        wmap[j-k][i]=cnt;
      }
    }
    cnt=0;
  }
  int ans=0;
  for(i=0;i<H;i++){
    for(j=0;j<W;j++){
      if(ans<hmap[i][j]+wmap[i][j])ans=hmap[i][j]+wmap[i][j];
    }
  }
  printf("%d",ans-1);
  return 0;
}

Measured memory_bytes: 47232
def factorization(n):
    L=[]
    temp=n
    print(n,end="")
    print(":",end="")
    for i in range(2, int(n**(1/2)//1)+1):
        if temp%i==0:
            c=0
            while temp%i==0:
                c+=1
                temp//=i
            L.append([i, c])
            for j in range(c):
                print("",i,end="")
    if temp!=1:
        print("",temp,end='')
    print()
    return L
n=int(input()) 
factorization(n)



Measured memory_bytes: 5628
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    ll n,ans=0,m=1; cin>>n;
    vector<ll> c(n,0),sum(n+1,0);
    rep(i,n) cin>>c[i];
    rep(i,n-1) m=m*4%MOD;
    sort(al(c));
    rep(i,n) sum[i+1]=(sum[i]+c[i])%MOD;
    rep(i,n){
        ans=(ans+(m*sum[i+1])%MOD);
        ans%=MOD;
    }
    ans=(ans+(m*sum[n])%MOD)%MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 3328
#include <stdio.h>
int main(void){
   int k,x;
   
   scanf("%d%d",&k,&x);
   if(k==1){printf("%d",x);return 0;}
   
   for(int i=0;i<(k-1)*2+1;i++){
       printf("%d ",x-(k-1)+i);
   }
   return 0;
}


Measured memory_bytes: 1712
#include <bits/stdc++.h>
#define rep0(i, n) for(int i=0; i<(int)(n);i++)
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep0(i, n) cin >> a[i];
    multiset<int> colmin; //別々の色ごとで最後に塗られた数
    colmin.insert(a[n-1]);
    for(int i = n - 2 ; i >= 0 ; i --){
        auto it = colmin.upper_bound(a[i]);
        if(it != colmin.end())colmin.erase(it);//既存の色で塗れる場合は既存を削除して
        colmin.insert(a[i]); //追加
    }
    cout << colmin.size() << endl;
    return 0;
}

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


#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(int x = (l);x<=(u);x++)
#define RREP(x,l,u) for(int x = (l);x>=(u);x--)
#define mst(x,a) memset(x,a,sizeof(x))
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
#define sz(x) ((int)x.size())
#define cl(x) x.clear()

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;

const int maxn = 110;
const int mod = 1e9+7;
const int MAX = 1000000010;
const double eps = 1e-6;
const double PI = acos(-1);

template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}

template<typename A,typename B> inline void read(A&x,B&y){read(x);read(y);}
template<typename A,typename B,typename C> inline void read(A&x,B&y,C&z){read(x);read(y);read(z);}
template<typename A,typename B,typename C,typename D> inline void read(A&x,B&y,C&z,D&w){read(x);read(y);read(z);read(w);}
template<typename A,typename B> inline A fexp(A x,B p){A ans=1;for(;p;p>>=1,x=1LL*x*x%mod)if(p&1)ans=1LL*ans*x%mod;return ans;}
template<typename A,typename B> inline A fexp(A x,B p,A mo){A ans=1;for(;p;p>>=1,x=1LL*x*x%mo)if(p&1)ans=1LL*ans*x%mo;return ans;}

int n,m,K,ans=1;

vector<int> G[maxn];

PII S[maxn];int top;

int dfn[maxn],low[maxn],vi[maxn],tot;

int Cnk(int n,int k){
	int ans=1;
	REP(i,1,k)ans=1ll*ans*(n-i+1)%mod*fexp(i,mod-2)%mod;
	return ans;
}

int calc(int n,int m){
//	cout<<n<<' '<<m<<endl;
	if(m<n)return K;
	if(m>n)return Cnk(m+K-1,K-1);
	int ans=0;
	REP(i,0,n-1)ans=(ans+fexp(K,__gcd(i,n)))%mod;
//	dbg(ans);
	return 1ll*ans*fexp(n,mod-2)%mod;
}

void dfs(int u,int f){
	dfn[u]=low[u]=++tot;
	for(auto v:G[u])if(v!=f){
		PII tmp(u,v);
		if(dfn[v]<=dfn[u])S[++top]=tmp;
		if(!dfn[v]){
			dfs(v,u);
			low[u]=min(low[u],low[v]);
			if(low[v]>=dfn[u]){
				int V=0,E=0,u,v;
				memset(vi,0,sizeof(vi));
//				cout<<"New"<<endl;
				do{
					u=S[top].fi,v=S[top].se;
//					cout<<u<<' '<<v<<endl;
					if(!vi[u])vi[u]=1,V++;
					if(!vi[v])vi[v]=1,V++;
					top--;E++;
				}while(MP(u,v)!=tmp);
				ans=1ll*ans*calc(V,E)%mod;
			}
		}
		else low[u]=min(low[u],dfn[v]);
	}
}

void Work(){
	REP(i,1,n)if(!dfn[i])dfs(i,0);
	iout(ans);
}

void Init(){
	read(n,m,K);
	REP(i,1,m){
		int u,v;
		read(u,v);
		G[u].PB(v);G[v].PB(u);
	}
}

int main(){
	Init();
	Work();
	return 0;
}


Measured memory_bytes: 256
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
from fractions import Fraction
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def _pf(s): return print(s, flush=True)

N = _I()
TA = [LI() for _ in range(N)]
"""
まず割合を求める
割合が違ったら数字を変更する必要がある
2:1にしないといけないのに
10-20
だったら、
答えは40-20であるが、
2:1をまず10-20より大きくする
まず割る
10/2=5
20/1=20
だからまず20倍する
40:20
これが答えであればok
逆ならどうか
17:25
2-3
なら
そもそも17:25が正解
じゃあ一方だけこえてたら？
17:25
21-3
これなら
まず小さい方は25にする
21-25
そこから割合を求める
21/17=1....
25/25 = 1
2倍する
34:50
満たしている
"""

vals = [1,1]
for t, a in TA:
    #  # まず同じ大きさにする
    #  if vals[0] < t:
    #      vals[0] = t
    #  if vals[1] < a:
    #      vals[1] = a

    xt = math.ceil(Fraction(vals[0], t))
    xa = math.ceil(Fraction(vals[1] , a))

    max_x = max(xt, xa)
    #  t *= max_x
    #  a *= max_x
    vals[0] = t * max_x
    vals[1] = a * max_x

print(sum(vals))


Measured memory_bytes: 6476
#include<stdio.h>
int main(void) {
	int A, B, C, D;
	scanf("%d %d %d %d", &A, &B, &C, &D);
	if ((A*B) > (C*D)) { printf("%d\n", A*B); }
	else { printf("%d\n", C*D); }
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    vector<vector<bool>> l(m);
    rep(i,m){
        vector<bool> b(n);
        int k;
        cin >>k;
        rep(j,k){
            int s;
            cin >>s;
            --s;
            b[s] = true;
        }
        l[i] = b;
    }

    vector<int> p(m);
    rep(i,m) cin >>p[i];

    int ans = 0;
    rep(mask,1<<n){
        vector<int> ct(m);
        rep(i,n)if(mask>>i&1){
            rep(j,m)if(l[j][i]) (ct[j]+=1)%=2;
        }
        ans += (ct == p);
    }
    cout << ans << endl;
    return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 1e6 + 5;




int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    
    string s;
    cin>>s;
    if (s.back()=='s') s+="es"; else s += "s";
    out(s);
    return 0;
}


Measured memory_bytes: 3652