akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;


int main(void){
    int64_t N,ans=1;
    cin >> N;
  vector<int64_t> A(N);
  for(int64_t i=0;i<N;i++){
    cin >> A.at(i);
    if(A.at(i)==0){
      cout << 0 << endl;
      return 0;
    }
  }
  for(int64_t i=0;i<N;i++){
    if(1000000000000000000/ans<A.at(i)){
      cout << -1 << endl;
      return 0;
    }
    ans*=A.at(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    int N;
    cin >> N;
    int A[N];
    REP(i, N){
        cin >> A[i];
    }

    sort(A, A+N);
    bool flag = true;
    REP(i, N-1){
        if (A[i] == A[i+1]){
            flag = false;
            break;
        }
    }

    if (flag) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 4404
# -*- coding: utf-8 -*-
from collections import Counter
def inpl(): return list(map(int, input().split()))

N = int(input())
C = Counter(inpl())

ans = 0
for k in C.keys():
    for j in range(-1, 2):
        ans = max(C[k-1+j] + C[k+j] + C[k+j+1], ans)
print(ans)

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

int main(){
    int X,A,B;
    cin>>X>>A>>B;
    if(B>(X+A)){
        cout<<"dangerous"<<endl;
    }
    else if(B<(X+A)&&B<=X){
        cout<<"delicious"<<endl;
    }
    else{
        cout<<"safe"<<endl;
    }

}

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

int main(){
	string a;
	cin>>a;
	long long pd=0,i;
	for(i=0;i<a.size();i++){
		if(pd==0&&a[i]=='C')  pd=1;
		if(pd==1&&a[i]=='F'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
town = [list(map(int, input().split())) for _ in range(N)]

s = 0
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        s += ((town[i][0] - town[j][0])**2 + (town[i][1] - town[j][1])**2)**0.5

print(s / N)

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


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

using namespace std;

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  int cnt = 0;
  for (int i = 100; i > 0; --i) {
  	if (a % i == 0 && b % i == 0) {
      ++cnt;
      if (cnt == k) {
      	cout << i << '\n';
        return 0;
      }
    }
  }
  assert(false);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
struct Istream {
	template <class T> 
	Istream &operator >>(T &x) {
		static char ch;static bool neg;
		for(ch=neg=0;ch<'0' || '9'<ch;neg|=ch=='-',ch=getchar());
		for(x=0;'0'<=ch && ch<='9';(x*=10)+=ch-'0',ch=getchar());
		x=neg?-x:x;
		return *this;
	}
	template <class T>
	operator T() {
		static T x;
		*this>>x;
		return x;
	}
}is;
struct Ostream {
	template <class T>
	Ostream &operator <<(T x) {
		x<0 && (putchar('-'),x=-x);
		static char stack[233];static int top;
		for(top=0;x;stack[++top]=x%10+'0',x/=10);
		for(top==0 && (stack[top=1]='0');top;putchar(stack[top--]));
		return *this;
	}
	Ostream &operator <<(char ch) {
		putchar(ch);
		return *this;
	}
}os;
const int MAXN=1e5+11;
std::vector<int> G[MAXN];
int stack[MAXN],top,n;
bool FindPath(int pos,int from) {
	stack[++top]=pos;
	if(pos==n) {
		return 1;
	} else {
		for(int u : G[pos]) if(u!=from)
			if(FindPath(u,pos))
				return 1;
	}
	top--;
	return 0;
}
int color[MAXN];
void Color(int pos) {
	for(int u : G[pos]) {
		if(!color[u]) {
			color[u]=color[pos];
			Color(u);
		}
	}
}
int main() {
	is>>n;
	for(int i=1;i<=n-1;++i) {
		int x=is,y=is;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	FindPath(1,0);
	for(int l=1,r=top;l<=r;++l,--r) {
		color[stack[l]]=1;
		if(l!=r) {
			color[stack[r]]=-1;
		}
	}
	for(int i=1;i<=n;++i)
		if(color[i])
			Color(i);
	int cnt=0;
	for(int i=1;i<=n;++i) {
		cnt+=color[i]==1;
	}
	bool fw=cnt>n-cnt;
	std::cout<<(fw?"Fennec":"Snuke")<<'\n';
	return 0;
}


Measured memory_bytes: 11136
n = int(input())
a= [int(x) for x in input().split(" ",n-1)]
s = 0
for x in range(n):
    s += a[x-1]
r = 0
l = 0
x = 0
while r < s/2:
    r += a[x]
    x += 1
y = 1
while l < s/2:
    l += a[n-y]
    y += 1
if r == s//2:
    print(0)
else:
    k = min(r,l)  
    v = k - s/2
    m = v // 0.5
    print(int(m))

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

int main () 
{
    string S;
    cin >> S;
    int count[3] = {0};
    
    for (int i = 0; i < 3; i++) {
        if (S[i] == 'a') count[0]++;
        if (S[i] == 'b') count[1]++;
        if (S[i] == 'c') count[2]++;
    }
    
    if(count[0] ==1 && count[1]==1 && count[2]==1) std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cmath>
#include <deque>
#include <iterator>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}

const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;

int main() {
  string s; cin >> s;
  ll x, y; cin >> x >> y;
  V<V<bool> > dp(2*s.size()+1, V<bool>(s.size()+2, false));
  dp[s.size()][0] = dp[s.size()][1] = true;
  ll j = 2, d = 0;
  REP(i, s.size()) {
    if (s[i] == 'F') d++;
    else {
      if (j == 2) {dp[s.size()+d][2] = true; j++; d=0; continue;}
      REP(k, 2*s.size()+1) {
        if (k-d < 0) {
          if (k+d > 2*s.size()) continue;
          else dp[k][j] = dp[k+d][j-2];
        } else if (k+d > 2*s.size()) {
          if (k-d < 0) continue;
          else dp[k][j] = dp[k-d][j-2];
        } else dp[k][j] = dp[k-d][j-2] | dp[k+d][j-2];
      }
      j++; d = 0;
    }
  }
  if (d > 0) {
    if (j == 2) {dp[s.size()+d][2] = true;}
    else {
      REP(k, 2*s.size()+1) {
        if (k-d < 0) {
          if (k+d > 2*s.size()) continue;
          else dp[k][j] = dp[k+d][j-2];
        } else if (k+d > 2*s.size()) {
          if (k-d < 0) continue;
          else dp[k][j] = dp[k-d][j-2];
        } else dp[k][j] = dp[k-d][j-2] | dp[k+d][j-2];
      }
    }
    j++;
  }
  if (j % 2 == 0) {
    if (dp[x+s.size()][j-2] && dp[y+s.size()][j-1]) cout << "Yes" << endl;
    else cout << "No" << endl;
  } else {
    if (dp[x+s.size()][j-1] && dp[y+s.size()][j-2]) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 18944
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s = list(input())
n = len(s)
t = list(input())
for i in range(n+5):
    now = []
    now.append(s[-1]); s.pop(-1) 
    now += s
    s = now
    if s == t:
        print('Yes')
        break
else:
    print('No')

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

int main() {
    char c;
    cin >> c;
    vector <char> vowel = {'a', 'e', 'i', 'o', 'u'};
    bool flag = false;
    for (char v : vowel){
        if (c == v) {
            flag = true;
            cout << "vowel" << endl;
        }
    }
    if (flag == false) cout << "consonant" << endl;
    return 0;  
}

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

int N, M;
int modulo = 1000000007;

unsigned long long memoFact[100001] = {1};

unsigned long long factorial (int n) {
	if (memoFact[n] != 0) return memoFact[n];
	return (factorial(n - 1) * n) % modulo;
}

int main() {
	cin >> N >> M;
	if (abs(N - M) > 1) {
		cout << 0 << endl;
		return 0;
	}
	cout << factorial(N) * factorial(M) % modulo * ((N == M) ? 2 : 1) % modulo << endl;
	return 0;
}

Measured memory_bytes: 1792
// D - People on a Line
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
using VVII = vector<vector<pair<int,int>>>;

#define V_MAX 100000
vi visited(V_MAX+1);
vi dist(V_MAX+1);

void dfs(VVII &T, int p, int w){
	if(visited[p]) return;
	visited[p] = true;
	dist[p] = w;
	for(auto cw:T[p]){
		int np,nw; tie(np,nw) = cw;
		dfs(T, np, w+nw);
	}
}

int main(){
	int N,M; cin>>N>>M;
	if(M==0){ puts("Yes"); return 0; }

	VVII V(N+1);
	int l,r,d, L = INT_MAX, R = 0;
	rp(i, 0, M){
		cin>>l>>r>>d;
		V[l].emplace_back(r, d);
		V[r].emplace_back(l,-d);
		L = min(L, l);
		R = max(R, r);
	}

	rp(l, L, R+1){
		dfs(V, l, 0);
		for(auto rd:V[l]){
			tie(r,d) = rd;
			if(abs(d) != abs(dist[r]-dist[l])){ puts("No"); return 0; }
		}
	}
	puts("Yes");
}

Measured memory_bytes: 12416
from math import ceil
h,w=map(int,input().split())

word={}
A=[list(input()) for _ in range(h)]
for i in A:
    for j in i:
        if j not in word:word[j]=1
        else:word[j] +=1

D=[0]*5
if h%2==0 and w%2==0:
    D[4]=(h*w)//4
elif (h%2==0 and w%2==1) or (h%2==1 and w%2==0):
    if h%2==1:
        D[2]=w//2
        D[4]=w*(h-1)//4
    else:
        D[2]=h//2
        D[4]=h*(w-1)//4
else:
    D[2]=(h+w-2)//2
    D[4]=(h-1)*(w-1)//4
    D[1]=1

P=[0]*5
for i in word.values():
    P[4] +=i//4;i %=4
    P[2] +=i//2;i %=2
    P[1] +=i

for i in (4,2,1):
    if D[i]==P[i]:continue
    elif D[i]<P[i]:
        P[i//2] +=(P[i]-D[i])*2
    else:print("No");exit()
print("Yes")

Measured memory_bytes: 38896
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#include<stack>
using namespace std;
int main(void) {
	int n;
	cin >> n;
	cout << n / 2 + n % 2 << endl;
	return 0;
}
	
	



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if(a == b) cout<<c<<endl;
	else if(a == c) cout<<b<<endl;
	else cout<<a<<endl;
	return 0;	
} 

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import math
    
def abs(num):
    if num < 0:
        return -num
    else:
        return num

def abc163e(n, a):
    hap_dict = dict()
    hap_list = []
    for elem in range(n):
        if a[elem] in hap_dict:
            hap_dict[a[elem]].append(elem)
        else:
            tmp_list = [elem]
            hap_dict[a[elem]] = tmp_list
            hap_list.append(a[elem])
    
    hap_list.sort(reverse=True)

    left = 0
    right = n-1

    num = 0
    dp = [[0 for re in range(n+1)] for le in range(n+1)]
    for hap in hap_list:
        pos_list = hap_dict[hap]

        while len(pos_list) != 0:
            tgt = pos_list.pop()

            num += 1

            for left in range(num+1):
                right = num-left
                if left == num: # left end
                    dp[left][right] = dp[left-1][right] + hap * abs(tgt-left+1)
                elif left == 0: # right end
                    dp[left][right] = dp[left][right-1] + hap * abs(n-right-tgt)
                else:
                    left_dp = dp[left-1][right] + hap * abs(tgt-left+1)
                    right_dp = dp[left][right-1] + hap * abs(n-right-tgt)
                    dp[left][right] = max(left_dp, right_dp)
                #print("[",str(left),"][",str(right),"]=",str(dp[left][right]))

    ans_list = []
    for i in range(num+1):
        ans_list.append(dp[i][num-i])
    return max(ans_list)

###
# main
if(__name__ == '__main__'):
    # input
    n = int(input())
    a = list(map(int, input().split(" ")))

    ans = abc163e(n, a)

    # output
    print(ans)
    
# else:
    # do nothing


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

int main()
{
  int n;
  cin>>n;
  int a[n];
  bool ok =true;
  for(int i=0; i<n; i++) cin>>a[i];
  for(int i=0; i<n; i++) 
  {
    if(a[i]%2==0)
    {  if(a[i]%5==0 or a[i]%3==0) continue;
       else ok =false;
    }
  }
  if(ok) cout<<"APPROVED";
  else cout<<"DENIED";
  
}


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N, Y;

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

	cin >> N >> Y;

	rep(i, 0, N + 1)rep(j, 0, N + 1 - i)
	{
		if ((Y - i * 10000 - j * 5000) / 1000 == N - (i + j))
		{
			cout << i << " " << j << " " << N - (i + j) << endl;
			return 0;
		}
	}

	cout << "-1 -1 -1" << endl;

	return 0;
}

Measured memory_bytes: 384
#include <cstdio>

int main()
{
	int a;
	scanf("%d", &a);
	if(a==1)
	{
		printf("Hello World");
	}
	int b,c;
	scanf("%d %d", &b, &c);
	if(a==2)
	{
		printf("%d", b+c);
	}
}

Measured memory_bytes: 1708
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 30;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------

string a, b, c;

char up(int n)
{
	char ans = 'A' + (n - 'a');
	return ans;
}

int main()
{
	cin >> a >> b >> c;
	cout << up(a[0]) << up(b[0]) << up(c[0]) << endl;

	return 0;
}


Measured memory_bytes: 256
<?php
$p=array();
while(1){
  list($a,$o,$b)=explode(' ',trim(fgets(STDIN)));
  if($o=='?'){break;}
  switch($o){
    case '+':$p[]=$a+$b;break;
    case '-':$p[]=$a-$b;break;
    case '*':$p[]=$a*$b;break;
    case '/':$p[]=floor($a/$b);break;
  }
}
print implode(PHP_EOL,$p);
?>

Measured memory_bytes: 15428
// package app;

import java.util.Arrays;
import java.util.Objects;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);

        // final String x = sc.next();
        // final String y = sc.next();

        final int a = sc.nextInt();
        final int b = sc.nextInt();
        final int c = sc.nextInt();
        // final int D = sc.nextInt();
        // System.out.println();

        System.out.println((b - a) == (c - b) ? "YES" : "NO");

        // System.out.println(A <= X && A + B >= X ? "YES" : "NO");

    }
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
int main () {
  int n;
  cin >> n;
  double a[n];
  double s = 0;
  for (int i = 0; i <n ; i++) {
    cin >> a[i];}
  for (int i = 0; i< n; i++) {
    s += 1 / a[i];} 
  cout << 1 / s; }
    

Measured memory_bytes: 256
#include <iostream>
#include<sstream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#define  mem memset(a,0,sizeof(a))

const int mo=1000000007;
const int inf=0x3f3f3f3f;

typedef long long ll;
using namespace std;

int main()
{
     cin.sync_with_stdio(false);
    int a[100005];
    int n,c,k;
    int num=0,ans=0;
    cin>>n>>c>>k;
    int i,j;
    int x,y;
    for(i=0;i<n;i++)
        cin>>a[i];
    sort(a,a+n);
    for(i=0;i<n;i++)
    {
        if(num==c)
        {
            num=0;
        }
        if(a[i]<x||a[i]>y)
        {
            num=0;
        }
        if(num==0)
        {
            num++;
            ans++;
            x=a[i];
            y=a[i]+k;
            //cout<<a[i]<<'*'<<x<<endl;
            //cout<<a[i]<<'/'<<num<<endl;
            continue;
        }
        if(a[i]>=x&&a[i]<=y)
        {
            num++;
            //cout<<a[i]<<'*'<<x<<endl;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
const int inf = 1e9;
// ダイクストラO(elogv)
struct edge{
  int to, cost;
  edge(int t, int c) {
    to = t, cost = c;
  }
};
typedef pair<int, int> P;
int N;
vector<edge> G[11111];
int d[11111];
void dijkstra(int s){
  priority_queue<P, vector<P>, greater<P> >que;
  FOR(i,1,N+1) 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(auto &e : G[v]){
      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()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin>>N;
  FOR(i,0,N){
    int u, k;
    cin >> u >> k;
    FOR(j,0,k){
      int v, c;
      cin >> v >> c;
      G[u].push_back(edge(v, c));
    }
  }
  dijkstra(0);
  FOR(i,0,N){
    cout << i << " " << d[i] << endl;
  }
}


Measured memory_bytes: 8108
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdouble vector<double>
#define vstring vector<string>
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

const int MAX_N = 1000000;
static const int INFTY = (1 << 21);

class Edge{
public:
	int from, to, cost;
	int backedge;
	Edge(int from = 0, int to = 0, int cost = 0) :
		from(from), to(to), cost(cost){
		backedge = -1;
	}

};

class Node{
public:
	vector<Edge> edges;
	int prenum;
	int parent;
	int lowest;
	Node(){
		prenum = -1;
		parent = -1;
	}
};

class Graph{
public:
	vector<Node> nodes;
	int prenum;
	Graph(int n) {
		rep(i, n) { Node n;  nodes.push_back(n); }
		prenum = 0;
	}
};

Graph G(0);

void dfs(Edge &e){

	Node& n = G.nodes[e.to];

	if (n.prenum != -1) {
		int parent = G.nodes[e.from].parent;
		if (e.to == parent){
			e.backedge = -1; // neither backedge nor treeedge
		}
		else{
			e.backedge = 1;
		}
		return;
	}

	// set parameter
	G.prenum++;
	e.backedge = 0; // not backage
	n.prenum = G.prenum;
	n.parent = e.from;
	n.lowest = n.prenum;

	for (auto &ee : n.edges){
		dfs(ee);
	}

	for (auto &ee : n.edges){
		if (ee.backedge != -1){
			n.lowest = min(n.lowest, G.nodes[ee.to].lowest);
		}
	}

}


int main() {

	int V, E;
	cin >> V >> E;

	G = Graph(V);

	rep(i, E){
		int from, to;
		cin >> from >> to;
		G.nodes[from].edges.push_back(Edge(from, to, 0));
		G.nodes[to].edges.push_back(Edge(to, from, 0));
	}

	Edge e(-1, 0, 0);
	dfs(e);

	rep(i, V){
		// printf("%d %d %d %d\n", i, G.nodes[i].parent, G.nodes[i].prenum, G.nodes[i].lowest);
	}

	set<int> ret;
	rep(i, V){
		if (G.nodes[i].parent == -1){
			int count = 0;
			rep(j, V){
				if (G.nodes[j].parent == i) count++;
			}
			if (count > 1) ret.insert(i);
		}
		else{
			Node n = G.nodes[i];
			Node p = G.nodes[n.parent];
			if (p.prenum <= n.lowest && p.parent != -1){
				ret.insert(n.parent);
			}
		}
	}

	for (auto &i : ret){
		cout << i << endl;
	}
}

Measured memory_bytes: 5916
n = int(input())
xu = []
for _ in range(n):
    xu.append(input().split()) 

ans = 0.0
for i in range(n):
    if xu[i][1] == 'BTC':
        ans += float(xu[i][0])*380000.0
    else:
        ans += float(xu[i][0])

print(ans)

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

const int maxN = 200010;

int A[2][maxN];

int main (){
	int n, k, i, j, p;
	scanf("%d%d", &n, &k);
	for(i = 0; i < n; ++i) scanf("%d", A[0] + i);
	for(p = 0; p < k; ++p){
		int cur = p & 1, nxt = 1 - cur;
		for(i = 0; i < n; ++i)
			if(A[cur][i] != n) break;
		if(i == n) break;
		for(i = 0; i < n; ++i) A[nxt][i] = 0;
		for(i = 0; i < n; ++i){
			if(i < A[cur][i]) ++A[nxt][0];
			else ++A[nxt][i - A[cur][i]];
if(i + A[cur][i] + 1 < n)
			--A[nxt][i + A[cur][i] + 1];
		}
		for(i = 0; i < n; ++i) A[nxt][i] += A[nxt][i - 1];
	}
	for(i = 0; i < n; ++i) printf("%d ", p < k ? n : A[k & 1][i]);
	return 0;
}

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

int main () {
  int N;
  cin >> N;
  int i;
  int l[N];
  int r[N];
  int num=0;
  for (i=0;i<N;++i) {
    cin >> l[i];
    cin >> r[i];
    num += r[i]-l[i]+1;
  }
  cout << num<< endl;
}

Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
#include <functional>

//#include "All.h"

using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    REP(i, b) tmp *= a;
    return tmp;
}

int S, W;

int main() {
    cin >> S >> W;
    if (S <= W) {
        cout << "unsafe" << endl;
    }
    else {
        cout << "safe" << endl;
    }
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
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 INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    int n;
    cin >> n;
    vector<int> A(n);
    vector<pii> X;
    rep(i, n) {
        int a;
        cin >> a;
        X.push_back({a, i});
    }
    auto compare = [](pii a, pii b) {
        if (a.fi > b.fi) return true;
        else if (a.fi == b.fi) return a.se < b.se;
        else return false;
    };
    sort(all(X), compare);
    vector<int> dp(n + 1, INF);
    rep(i, (int)X.size()) {
        int idx = X[i].se;
        *lower_bound(all(dp), idx) = idx;
    }
    int ans = 0;
    chmax(ans, (int)(lower_bound(all(dp), INF) - dp.begin()));
    cout << ans << endl;
}

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


Measured memory_bytes: 4912
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
int nx[4] = {1,0,-1,0};
int ny[4] = {0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,b;
    cin >> n;
    ll a[n][20] = {0};
    rep(i,n){
        cin >> b;
        rep(j,20){
            if (b&(1<<j)) a[i][j] = 1;
        }
    }
    ll m[20] = {0},r = 0,ans = 0;
    rep(l,n){
        bool ok = 1;
        ll cnt = 0;
        ll len = r-l;
        while(ok){
            rep(k,20){
                if(m[k]+a[r][k] > 1) ok = 0;
            }
            if (ok){
                rep(k,20) m[k] += a[r][k];
                r++;
                cnt++;
            }
        }
        ans += (cnt+len)*(cnt+len+1)/2-len*(len+1)/2;
        rep(k,20){
            m[k] -= a[l][k];
        }
    }
    PRINT(ans);
}


Measured memory_bytes: 31488
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,k = inpm()
A = inpl()

ans = float('inf')
for bi in itertools.product([0,1],repeat=n-1):
    if bi.count(1) < k-1:
        continue

    pre = A[0]
    s = 0
    for i in range(1,n):
        if bi[i-1] == 1:
            pre = max(pre+1,A[i])   
            s += max(0,pre-A[i])
        else:
            pre = max(pre,A[i])
    ans = min(ans,s)

print(ans)


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

using namespace std;

#define int long long

int n;
int a[300001];
int pre_mx[300001], suf_mn[300001];

priority_queue<int> suf;
priority_queue<int, vector<int>, greater<int>> pre;

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

	cin >> n;
	for (int i = 1; i <= 3 * n; i++)
		cin >> a[i];

	int sum = 0;	
	for (int i = 1; i <= n; i++)	
	{
		sum += a[i];
		pre.push(a[i]);
	}	
	pre_mx[n] = sum;
	for (int i = n + 1; i <= 2 * n; i++)
	{
		sum += a[i];
		pre.push(a[i]);
		sum -= pre.top();
		pre.pop();
		pre_mx[i] = sum;
	}

	sum = 0;	
	for (int i = 3 * n; i >= 2 * n + 1; i--)	
	{
		sum += a[i];
		suf.push(a[i]);
	}	
	suf_mn[2 * n + 1] = sum;
	for (int i = 2 * n; i >= n + 1; i--)
	{
		sum += a[i];
		suf.push(a[i]);
		sum -= suf.top();
		suf.pop();
		suf_mn[i] = sum;
	}
	int ans = -1e18;
	for (int i = n; i <= 2 * n; i++)	
		ans = max(ans, pre_mx[i] - suf_mn[i + 1]);
	cout << ans; 		
}

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

namespace ConsoleApp15
{
    class Class15
    {
        static void Main()
        {
            int N = int.Parse(Console.ReadLine());
            var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
            bool[] frag = new bool[N];
            for (int i = 0; i < N; i++)
                frag[i] = p[i] == i+1 ? true : false;

            int count = 0;
            for(int i = 0; i < N; i++)
            {
                if (frag[i])
                {
                    frag[i] = false;
                    if(i+1<N) frag[i + 1] = false;
                    count++;
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 20192
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  // 
  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n;cin>>n;
  P(((n+1)*n)/2);
  return 0;
}


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

using namespace std;

#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()

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

template<class T>
void print(vector<T>& V, bool spaced = true) {
    string space;
    spaced ? space = " " : space = "";
    for(int i = 0; i < V.size(); i++) {
        cout<< V[i] << space;
    }cout<< '\n';
}

template<class T>
void printendl(vector<T>& V) {
    for(int i = 0; i < V.size(); i++) {
        cout<< V[i] << '\n';
    }
}

template<class T>
T gcd(T a, T b) {
    T r;
    while (b != 0) {
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}

template <class T>
T lcm (T a, T b) {
    return a / gcd(a, b) * b;
}

template<class T>
T Max(T a, T b) {
    return (a < b) ? b : a;
}

template<class T>
T Min(T a, T b) {
    return (a < b) ? a : b;
}

//str

bool isPalindrome(string str){
    
    int length = str.length();
 
    for (int i = 0; i < (length / 2); i++)
        if (str[i] != str[length - 1 - i])
            return false;
 
    return true;    
}

void reverseStr(string& str) 
{ 
    int n = str.length(); 
    for (int i = 0; i < n / 2; i++) 
        swap(str[i], str[n - i - 1]); 
}


int n;
vector<int> v;
int dp[1000000 + 4];
const int INF = 10e8;

int solve(int i) {

    if(i == 0) return 0;
    if(i < 0) return INF;
    if(dp[i] != -1) return dp[i];
    int dp_1 = abs(v[i-1] - v[i]) + solve(i-1);
    int dp_2 = abs(v[i-2] - v[i]) + solve(i-2);
    return dp[i] = min(dp_1, dp_2);
}


//Read through the messages at the end when you're done

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    
    cin>> n;
    memset(dp, -1, sizeof(dp));
    for(int i = 0; i < n; ++i) {
        int x; cin>> x;
        v.pb(x);
    }

    cout << solve(n-1) << '\n';

    
    

    return 0;
}

    //Use long long da5eel rabbak!
    //Dont use endl;
    //DONT SUBMIT IZA UR NOT SURE WALLAHI BTENDAM
    //Dear Amine, just because it worked for the test cases doesnt necessarily mean it is correct.
    //Dear Amine, try it on ur own test cases iza ur not SURE
    //In case u didnt use long long, CHECK FOR POTENTIAL OVERFLOWS
    //DONT FORGET TO MOD EVERYTHING IZA U NEED TO MOD



Measured memory_bytes: 9336
S = input()

candidates = []

tmp = []

for char in S:
    if char in ["A", "T", "G", "C"]:
        tmp.append(char)
    else:
        candidates.append(tmp)
        tmp = []

if tmp != []:
    candidates.append(tmp)

sorted_candidates = sorted(candidates, reverse=True, key=lambda x: len(x))
print(len(sorted_candidates[0]))

Measured memory_bytes: 3064
// g++ temp.cpp
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <cstring>
#include <set>
#include <map>
#include <string>
#include <climits>
using namespace std;

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define EACH(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
const unsigned long long MOD = 100000000000000000;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
void solve(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,k,X,Y;
  cin>>n>>k>>X>>Y;
  if(n>k){
  cout<<X*k+Y*(n-k)<<endl;
   } else {
    cout<<X*n<<endl;
   }
}
int main(){
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
        int W,H,x,y,r;
        scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);

        if(y-r>=0 && x-r>=0 && y+r<=H && x+r<=W)
                puts("Yes");
        else
                puts("No");

        return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define endl "\n"     
#define pb push_back
#define mp make_pair
#define ff first
#define ss second

const int N=1e5+5;
int n,a[N],b[N],c[N],cache[N][3];

int dp(int pos,int ch)
{
     if(pos==n+1)
          return 0;
     int &ans=cache[pos][ch];
     if(ans!=-1)
          return ans;
     ans=0;     
     if(ch==0)
          return ans=max(b[pos]+dp(pos+1,1),c[pos]+dp(pos+1,2));
     else if(ch==1)
          return ans=max(a[pos]+dp(pos+1,0),c[pos]+dp(pos+1,2));
     else
          return ans=max(b[pos]+dp(pos+1,1),a[pos]+dp(pos+1,0));
}

int32_t main()
{
	IOS;

     memset(cache,-1,sizeof cache);
	cin>>n;
	
	for(int i=1;i<=n;i++)
	     cin>>a[i]>>b[i]>>c[i];
	
	cout<<max(dp(1,0),dp(1,1));
	     
	return 0;
}

Measured memory_bytes: 9600
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N;
  string s, t;
  cin >> N >> s >> t;
  int l = N;
  for (int i = 0; i < N; i++) {
    bool flag = true;
    for (int j = 0; j < N; j++) {
      if (i + j >= N) continue;
      if (t[j] != s[i + j]) {
        flag = false;
        break;
      }
    }
    if (flag) {
      l = i;
      break;
    }
  }
  cout << N + l << endl;
  return 0;
}

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

using namespace std;

int main() {
  int N, T;
  cin >> N >> T;
  int answer = numeric_limits<int>::max();
  for (int i = 0; i < N; i++) {
    int c, t;
    cin >> c >> t;
    if (t <= T) {
      answer = min(answer, c);
    }
  }

  if (answer == numeric_limits<int>::max()) {
    cout << "TLE";
  } else {
    cout << answer;
  }

  return 0;
}


Measured memory_bytes: 256
class UnionFind():
 def __init__(self, n):
  self.n = n
  self.parents = [-1] * n

 def find(self, x):
  if self.parents[x] < 0:
   return x
  else:
   self.parents[x] = self.find(self.parents[x])
   return self.parents[x]

 def union(self, x, y):
  x = self.find(x)
  y = self.find(y)

  if x == y:
   return

  if self.parents[x] > self.parents[y]:
   x, y = y, x

  self.parents[x] += self.parents[y]
  self.parents[y] = x

 def size(self, x):
  return -self.parents[self.find(x)]
 def same(self, x, y):
  return self.find(x) == self.find(y)

N,M,K = map(int,input().split())
uf = UnionFind(N)
lst=[0]*(N)
ans=[0]*(N)
for i in range(M):
 A,B=map(int,input().split())
 uf.union(A-1,B-1)
 lst[A-1]+=1
 lst[B-1]+=1
for i in range(K):
 A,B=map(int,input().split())
 if uf.same(A-1,B-1):
  lst[A-1]+=1
  lst[B-1]+=1
for i in range(N):
 ans[i]=uf.size(i)-lst[i]-1
L=[str(a) for a in ans]
L=' '.join(L)
print(L)

Measured memory_bytes: 18736
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 2e5+5;
char s[MAX], t[MAX];
int ans;

int main(int argc, char** argv) {
	scanf("%s %s", s, t);
	int sz = strlen(s);
	rep(i, 0, sz)
		ans += (s[i] != t[i]);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 4052
n = int(input())
posX, posY = 0, 0
ans = True
for i in range(n):
    t, x, y = list(map(int, input().split()))
    d = (abs(posX - x) + abs(posY - y))
    if(d > t):
        ans = False
        break
    elif(d % 2 != t % 2):
        ans = False
        break
if(ans):
    print("Yes")
else:
    print("No")



Measured memory_bytes: 3060
#include <iostream>
#include <string>
using namespace std;
int main(){
	int n;
	string s;
	cin >> n;
	cin >> s;
	int count = 0;
	for(int i = 0;i < n;i++){
		if(s[i] == 'R'){
			count++;
		}
	}
	if(count > (n - count)){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 384
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

const INF: i64 = 1 << 50;

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        n: usize,
        ab: [(i64, i64); n],
    }
    let mut ba = vec![];
    for &(a, b) in &ab {
        ba.push((b, a));
    }
    ba.sort();
    ba.reverse();
    let mut last = INF;
    for &(b, a) in &ba {
        last = min(last, b);
        last -= a;
    }
    puts!("{}\n", if last >= 0 { "Yes" } else { "No" });
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 17656
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			int N = cin.nextInt();
			if(N==0)
				break;
			int[] sum = new int[N];
			int max=0, min=242344;
			for(int i = 0; i < N;i++){
				for(int j=0;j<5;j++){
					sum[i]+=cin.nextInt();
				}
				if(max<sum[i]){
					max=sum[i];
				}
				min = Math.min(min,sum[i]);
			}
			System.out.println(max + " " + min);
		}
	}

}

Measured memory_bytes: 12000
n = int(input())
s = []
f = 0

for i in range(n):
    t = input()
    if t in s:
        f = 1
    elif i != 0 and s[i-1][-1] != t[0]:
        f = 1
    s.append(t)
    
if f == 0:
    print("Yes")
else:
    print("No")

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

typedef long long int ll;
const ll MOD = 1e9 + 7;

ll pow(int m, int n){
    ll res = 1;
    ll x = m;
    while(n){
        if(n&1)
            res = (res * x) % MOD;
        x = (x * x) % MOD;
        n >>= 1;
    }
    return res;
}

int main(){
    int m, n; cin >> m >> n;
    cout << pow(m, n) << endl;
    return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mo = 1000000007;
const ll INF = 1LL << 60; //MAX 9223372036854775807

int main()
{
ll n;
cin >> n;
ll t[n] = {};
ll ans[n] = {};
rep(i, n){
    cin >> t[i];
    t[i]=t[i]*2;
}
ll k=0;
rep(i,n-1){
    k=t[i]-k;
}
ans[0]=(t[n-1]-k)/2;
rep(i,n-1){
    ans[i+1]=t[i]-ans[i];
}
for (int i = 0; i < n; ++i) {
    cout << ans[i] << " ";
}cout  << endl;

return 0;
}


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

int f(int n){
 if(n % 2 == 0) return n / 2;
  else return 3 * n + 1;
}

int main(void){
  int N;
  cin >> N;
  int a = N / 100, b = N % 100 / 10, c = N % 10;
  if(a < b || a < c) cout << (a + 1) * 100 + (a + 1) * 10 + a + 1; 
  else cout << a * 100 + a * 10 + a;
  return 0;
}

Measured memory_bytes: 256
/*
 * @Author: RBQRBQ
 * @Date: 2020-04-05 21:40:13
 * @LastEditors: RBQRBQ
 * @LastEditTime: 2020-04-05 22:01:15
 */
//ac代码 
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std; 
typedef long long ll;
const ll maxn =10000000+10;
const ll mod=998244353;
inline ll qpow(ll a, ll n, ll p)  
{
    ll ans = 1;
    while(n)
    {
        if(n & 1ll) 
		ans = ans * a % p;
        a = a * a % p;
        n >>= 1ll;
    }
    return ans;
}
ll A[maxn+10];
ll B[maxn+10];

void exPower( int b, int p, int & a, int & k ) {
    if( p == 0 ) {
        a = 1; k = 0;
        return;
    }
    exPower( p, b % p, k, a );
    k -= b / p * a;
    return;
} 
int inv( int b, int p ) {
    int a, k;
    exPower( b, p, a, k );
    if( a < 0 ) a += p;
    return a;
}
void init( int n ) {
    A[ 0 ] = 1;
    for( int i = 1; i <= n; ++i ) A[ i ] = A[ i - 1 ] * i % mod;
    B[ n ] = inv( A[ n ], mod );
    for( int i = n - 1; i >= 0; --i ) B[ i ] = B[ i + 1 ] * ( i + 1 ) % mod;
    return;
}
inline ll C(ll a, ll b)
{
    if(a < b)
        return 0;
    return (A[a] * B[b] %mod)*B[a-b]%mod;
}
ll mul(ll x,ll y)
{
    return (x*y)%mod;
}
ll add(ll x,ll y)
{
    return (x+y>=mod)?x+y-mod:x+y;
}
ll pre[maxn];
int  main()
{
    int N;
    cin>>N;
    ll ans=qpow(3,N,mod);
    init(maxn);
    ll pos=0;
    pre[0]=1ll;
    for(int i=1;i<=N/2-1;i++)
    {
        pre[i]=mul(pre[i-1],2);
    }
    for(int i=1;i<=N/2;i++)
    {
        //pos=(pos%mod+(qpow(2,(N/2-i),mod)*C(N,N/2+i))%mod)%mod;
        pos=add(pos,mul(pre[N/2-i],C(N,N/2+i)));
    }
    pos=pos*2%mod;
    cout<<(ans-pos+mod)%mod;
}

Measured memory_bytes: 197760
s = ["", ""]

s[0] = input()
s[1] = input()

WtoE = []
wtoec = 0
EtoW = []
etowc = 0

for c in s[1]:
    if c == "W":
        wtoec = wtoec + 1
    WtoE.append(wtoec)

for c in s[1][::-1]:
    if c == "E":
        etowc = etowc + 1
    EtoW.append(etowc)
EtoW.reverse()

a = []
for i in range(0, int(s[0])):
    ans = WtoE[i] + EtoW[i]
    if WtoE[i] != 0 and s[1][i] == "W" or EtoW[i] != 0 and s[1][i] == "E":
        ans = ans - 1

    a.append(ans)

print(min(a))


Measured memory_bytes: 30240
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

vector<int> pg(){
  vector<int> pl(1299710,1);
  pl[0]=pl[1]=0;
  for(int i=2;i*i<=1299709;++i)
    if(pl[i])
      for(int j=i*i;j<=1299709;j+=i)
        pl[j]=0;
  int old=2;
  vector<int> v(1299710,0);
  for(int i=3;i<=1299709;++i){
    if(pl[i]){
      int l=i-old;
      for(int j=old+1;j<i;++j){
        v[j]=l;
      }
      old=i;
    }
  }
  return v;
}

int main() {
  vector<int> v=pg();
  while(1){
    int n;
    cin>>n;
    if(!n)break;
    cout<<v[n]<<endl;
  }
  return 0;
}

Measured memory_bytes: 11092
#include <iostream>
#include<cmath>
#define ll long long
using namespace std;
ll n;
ll dp[1000050],a[1000050];
int main(){
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    dp[1]=0;
    dp[0]=0;
    dp[2]=abs(a[2]-a[1]);
    for(int i=3;i<=n;i++){
        dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));

    }
    cout<<dp[n];
    return 0;
}

Measured memory_bytes: 5228
#include <iostream>

using namespace std;

int main(){
  int a, b;
  std::cin >> a >> b;
  int ans;
  for(int i=1; i<4; i++){
    if( a != i && b != i ){
      ans = i;
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 888
N, M = gets.split.map(&:to_i)
as = []
(1..N).each do |i|
    as[i] = gets.split.map(&:to_i)
end

ans = 1000

loop do
    arr = Array.new(M+1, 0)
    (1..N).each do |i|
        arr[as[i][0]] += 1
    end
    max = arr.max
    ans = max if ans > max
    ind = arr.find_index(max)
    (1..N).each do |i|
        as[i].delete(ind)
    end
    break if as[1].length == 0
end

puts ans

Measured memory_bytes: 3580
using System;
public class B{
    public static void Main(){
        int n = int.Parse(Console.ReadLine());
        
        for (int ans = n; ans<1000;ans++){
            int m = ans;
            int pre = m%10;
            m /=10;
            bool flag = true;
            for (int i = 0; i<2;i++){
                
                int now = m%10;
                
                if ( now != pre){
                    flag = false;
                }
                m/=10;
            }
            if (flag){
                 Console.WriteLine(ans);
                 Environment.Exit(0);
            }
        }
    }
}


Measured memory_bytes: 13140