akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
# DPL_1_H: Huge Knapsack Problem
# 0/1 Knapsack using Branch and Bound
# https://www.youtube.com/watch?v=yV1d-b_NeK8

from heapq import heappush, heappop


def max_value(t, xs):
    def _cost(weight, value, i):
        for j in range(i, n):
            v, w = xs[j]
            if weight + w > t:
                return (-value, -value - (v/w)*(t-weight))
            weight += w
            value += v
        return (-value, -value*1.0)

    n = len(xs)
    xs.sort(key=lambda x: x[0]/x[1], reverse=True)
    u, c = _cost(0, 0, 0)
    heap = [(c, u, 0, 0, 0)]
    maxcost = u
    while heap:
        cost, upper, weight, value, i = heappop(heap)
        if cost > maxcost:
            break
        if i < n:
            v, w = xs[i]
            if weight+w <= t:
                heappush(heap, (cost, upper, weight+w, value+v, i+1))
            u, c = _cost(weight, value, i+1)
            if c < maxcost:
                if u < maxcost:
                    maxcost = u
                heappush(heap, (c, u, weight, value, i+1))

    return -maxcost


def run():
    n, t = [int(i) for i in input().split()]
    xs = []

    for _ in range(n):
        v, w = [int(i) for i in input().split()]
        xs.append((v, w))

    print(max_value(t, xs))


if __name__ == '__main__':
    run()



Measured memory_bytes: 5684
w = input()
small = 'abcdefghijklmnopqrstuvwxyz'
large = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
count = 0
while True:
    text = input()
    if text == 'END_OF_TEXT':
        break
    else:
        stext = ''
        for i in text:
            j = 0
            while j < 26:
                if i == large[j]:
                    stext += small[j]
                    break
                j += 1
            if j == 26:
                stext += i
        t = list(map(str, stext.split(' ')))
        for p in t:
            if p == w:
                count += 1
print(count)


Measured memory_bytes: 5564
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline().rstrip('\n'))

h,w,k = LI()
a = [LS() for i in range(h)]
ans = 0
for r in range(1<<h):
    for c in range(1<<w):
        count = 0
        for i in range(h):
            for j in range(w):
                if (r>>i&1)==0 and (c>>j&1)==0 and a[i][j]=='#':
                    count += 1
        if count==k:
            ans += 1
print(ans)

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

int main() {
	int N, M; cin >> N >> M;
	vector<bool> broken(N, 0);
	for (int i = 0; i < M; i++) {
		int a; cin >> a;
		broken[a] = true;
	}

	vector<int> dp(N + 2, 0);
	const int mod = 1000000007;
	dp[N] = 1;
	for (int i = N - 1; i >= 0; i--) {
		if (broken[i]) {
			dp[i] = 0;
			continue;
		}
		dp[i] = (dp[i + 1] + dp[i + 2]) % mod ;
	}

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

Measured memory_bytes: 640
//AT2523 Digits in Multiplication
# include <iostream>
# include <cstring>
# include <cstdio>
# include <cmath>
using namespace std;
int main() {
    char str[11];
    long long n; cin>>n;
    for (int i=sqrt(n); i>=1; i--) 
        if (n%i==0) {
            sprintf(str,"%d",n/i);
            cout<<strlen(str);
            break;
        }
    return 0;
}

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

ratio = [list(map(int, input().split(' '))) for i in range(N)]
ans_T = ratio[0][0]
ans_A = ratio[0][1]
for i in range(1, N):
    now_T = ratio[i][0]
    now_A = ratio[i][1]

    count = max((ans_T+now_T-1)//now_T, (ans_A+now_A-1)//now_A)

    ans_T = ratio[i][0] * count
    ans_A = ratio[i][1] * count
print(ans_A + ans_T)


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
ll n,ans=0;
bool Main(){
    cin>>n;
    vector<ll> a(n);
    For(i,0,n){
        cin>>a.at(i);
        a.at(i)--;
    }
    ll now=0;
    For(i,0,n+2){
        now=a.at(now);
        ans++;
        if(now==1) break;
        if(i>n){
            ans=-1;
            break;
        }
    }
    cout<<ans<<endl;
}
int main(){
    Main();
    return 0;
}

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

int main(){
	#ifdef LOCAL_DEFINE
		freopen("../a.in","r",stdin);
		freopen("../a.out", "w",stdout);
	#endif
	int arr[6];
	for(int i=0;i<5;i++){
		cin >> arr[i];
	}
  
    sort(arr, arr + 5); 
  	int ans = INT_MAX;
    do { 
    	int best = arr[0];
    	while(best%10!=0){
    		best++;
    	}
    	for(int i=1;i<5;i++){
    		best += arr[i];
    		if(i!=4){
    			while(best%10!=0){
    				best++;
    			}
    		}    
    	}
    	ans=min(best,ans);
    } while (next_permutation(arr, arr + 5)); 
 	cout << ans << endl;
  
	return 0;
}

Measured memory_bytes: 256
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */


pub trait LexicalPermutation {
    fn next_permutation(&mut self) -> bool;
    fn prev_permutation(&mut self) -> bool;
}
impl<T> LexicalPermutation for [T]
where
    T: Ord,
{
    fn next_permutation(&mut self) -> bool {
        if self.len() < 2 {
            return false;
        }
        let mut i = self.len() - 1;
        while i > 0 && self[i - 1] >= self[i] {
            i -= 1;
        }
        if i == 0 {
            return false;
        }
        let mut j = self.len() - 1;
        while j >= i && self[j] <= self[i - 1] {
            j -= 1;
        }
        self.swap(j, i - 1);
        self[i..].reverse();
        true
    }
    fn prev_permutation(&mut self) -> bool {
        if self.len() < 2 {
            return false;
        }
        let mut i = self.len() - 1;
        while i > 0 && self[i - 1] <= self[i] {
            i -= 1;
        }
        if i == 0 {
            return false;
        }
        self[i..].reverse();
        let mut j = self.len() - 1;
        while j >= i && self[j - 1] < self[i - 1] {
            j -= 1;
        }
        self.swap(i - 1, j);
        true
    }
}

fn main() {
    input! {
        n: usize,
        pp: [usize;n],
        qq: [usize;n],
    }
    let mut v = (1..n+1).collect::<Vec<usize>>();
    let mut i = 1i32;
    let mut a = 0;
    let mut b = 0;
    loop {
        if v == pp {
            a = i;
        }
        if v == qq {
            b = i;
        }
        if !v.next_permutation() {
            break;
        }
        i += 1;
    }
    println!("{}", (a-b).abs());
}
/* vim:set foldmethod=marker: */


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

typedef pair<int,int> pii;
const int N=305;
const int MOD=1e9+7;
int n,m,ans;
vector<pii> nei[N];
int dp[N][N][N][4];

void add(int &x,int y){
	x+=y;
	if(x>=MOD) x-=MOD;
}

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		int l,r,x;
		scanf("%d%d%d",&l,&r,&x);
		nei[r].push_back(make_pair(l,x));
		if(l==r&&x!=1){
			puts("0");
			return 0;
		}
	}
	for(int i=1;i<=3;i++) dp[1][0][0][i]=1;
	for(int i=1;i<n;i++) for(int j=0;j<=i;j++) for(int k=0;k<=i;k++) for(int l=1;l<=3;l++) if(dp[i][j][k][l]){
//		printf("%d %d %d %d:%d ",i,j,k,l,dp[i][j][k][l]);
		int l1,l2,l3,a1,a2,a3;
		l1=l2=l3=0;
		if(l==1) l1=i,l2=j,l3=k;
		if(l==2) l1=j,l2=i,l3=k;
		if(l==3) l1=j,l2=k,l3=i;
		for(int x=1;x<=3;x++){
			a1=l1;a2=l2;a3=l3;
			if(x==1) a1=i+1;
			if(x==2) a2=i+1;
			if(x==3) a3=i+1;
			int ok=0;
			for(int o=0;o<nei[i+1].size();o++){
				int cnt=0;
				if(a1>=nei[i+1][o].first) cnt++;
				if(a2>=nei[i+1][o].first) cnt++;
				if(a3>=nei[i+1][o].first) cnt++;
				if(cnt==nei[i+1][o].second) ok++;
			}
//			if(i==2) printf("%d %d ",ok,nei[i+1].size());
			if(ok==nei[i+1].size()){
				if(x==1) add(dp[i+1][l2][l3][x],dp[i][j][k][l]);
				if(x==2) add(dp[i+1][l1][l3][x],dp[i][j][k][l]);
				if(x==3) add(dp[i+1][l1][l2][x],dp[i][j][k][l]);
			}
		}
//		puts("");
	}
	for(int j=0;j<=n;j++) for(int k=0;k<=n;k++) for(int l=1;l<=3;l++) add(ans,dp[n][j][k][l]);
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

int ans;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;

	int x = a;
	while(x <= b)
	{
		x += a;
		ans++;
		if(ans == c)
			break;
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
  int N, K;
  cin >> N >> K;
  int count = 0;
  for(int i=0; i<N; i++){
    int x;
    cin >> x;
    if(x>=K)count+=1;
  }
  cout << count<< endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main ()
{

    char a,b;
    scanf("%c %c",&a,&b);
    if(a=='H'&&b=='H')
        printf("H");
    if(a=='H'&&b=='D')
        printf("D");
    if(a=='D'&&b=='H')
        printf("D");
    if(a=='D'&&b=='D')
        printf("H");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M, T;
  cin >> N >> M >> T;
  vector<int> a(N);
  for (int i = 0; i < N; i++){
    cin >> a[i];
  }
  int ans = a[0] - M;
  for (int i = 0; i < N - 1; i++){
    ans += max(a[i + 1] - a[i] - M * 2, 0);
  }
  ans += max(T - a[N - 1] - M, 0);
  cout << ans << endl;
}


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

int abs(int a, int b){
    if(a >= b){
        return a - b;
    }
    else{
        return b - a;
    }
}

int main(){
    int n;
    cin >> n;
    int w[n+1];
    for(int i = 1; i <= n; i++){
        cin >> w[i];
    }
    int ans = 100000000;
    for(int i = 1; i <= n; i++){
        int a = 0;
        int b = 0;
        for(int j = 1; j <= i; j++){
            a += w[j];
        }
        for(int j = i+1; j <= n; j++){
            b += w[j];
        }
        ans = min(ans, abs(a,b));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <cmath>
#include <map>
#include <algorithm>
#include <queue>
#include <array>
#include <random>
#include <fstream>
#include <list>


int main() {
    long long n;
    long long pr[4];
    std::cin >> pr[0] >> pr[1] >> pr[2] >> pr[3]
             >> n;

    for (int i = 1; i < 4; ++i) {
        if (pr[i - 1] * 2 < pr[i]) {
            pr[i] = pr[i - 1] * 2;
        }
    }
    long long pay = 0;
    pay += (n / 2) * pr[3];
    n %= 2;
    pay += n * pr[2];
    std::cout << pay << std::endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

using namespace std;

const int maxn=200010;
const int mod=1e9+7;
#define int long long
int n,a[maxn],sum=0;

signed main(){
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		sum+=a[i];
		sum%=mod;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		( ans+=a[i]*( ((sum=sum-a[i])+mod)%mod ) )%=mod,(sum+=mod)%=mod;
	printf("%lld\n",ans%mod);
}


Measured memory_bytes: 3292
x,y,a,b,c = [int(x) for x in input().split()]
p = sorted([int(x) for x in input().split()], reverse=True)[:x]
q = sorted([int(x) for x in input().split()], reverse=True)[:y]
r = sorted([int(x) for x in input().split()])
print(sum(sorted(p + q + r, reverse=True)[:x+y]))


Measured memory_bytes: 22556
#include <stdio.h>
int main()
{
    int n, m, i, j;
    while (1)
    {
        scanf("%d %d", &n, &m);
        if (n == 0 && m == 0)
        {
            break;
        }
        
        for (int i = 1; i <= n; i++)
        {
            for (int j = 1; j <= m; j++)
            {
                if (i == 1 || j == 1 || i == n || j == m)
                {
                    printf("#");
                }
                else
                {
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2036
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      Map<Integer, Integer> cntMap = new HashMap<>();
      for(int i = 1; i <= n; i++)
        cntMap.put(i, 0);
      for(int i = 2; i <= n; i++) {
        int num = sc.nextInt();
        cntMap.put(num, cntMap.get(num) + 1);
      }
      for(int i = 1; i <= n; i++)
      System.out.println(cntMap.get(i));
  }
}

Measured memory_bytes: 72552
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define NP next_permutation
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef multiset<ll> S;
typedef priority_queue<ll> PQ;
typedef priority_queue<P,vector<P>,greater<P>> SPQ;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;

const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;

template<class T> bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T> void decimal(T a){cout<<fixed<<setprecision(a);}
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<endl;}
template<class T> void outvp(T v){rep(i,v.size())outp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> void outvv(T v){rep(i,v.size()){rep(j,v[i].size()){if(j)cout<<' ';cout<<v[i][j];}cout<<endl;}}

void YesNo(bool a){if(a) out("Yes"); else out("No");}
void yesno(bool a){if(a) out("yes"); else out("no");}
void YESNO(bool a){if(a) out("YES"); else out("NO");}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){ll c=1; while(b>0){if(b&1){c=a*c %mod;}a=a*a %mod;b>>=1;}return c;}
vi calc(ll x){vi res; while(x>0){res.eb(x%10);x/=10;}reverse(all(res)); return res;}

void solve() {
  ll a,b,c;
  cin>>a>>b>>c;
  if(c-a-b>0) YesNo(4*a*b<(c-a-b)*(c-a-b));
  else out("No");
}

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


Measured memory_bytes: 256
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
 
using namespace std;
 
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
    {
        if(n % 2 ==1)
            result=(result * x);
        x=(x*x);
        n=n/2;
    }
    return result;
}
 
class dsu{
    vi p,rank;
    vi set_count;
  
  public:
    dsu(int n){
        p.assign(n,0); 
        rank.assign(n,0);
        set_count.assign(n,1);
        for(int i=0;i<n;i++) p[i] = i;
    }
    int findSet(int x){
        return (p[x] == x) ? x:(p[x] = findSet(p[x]));
    }
    bool isSame(int i, int j){
        return (findSet(i) == findSet(j));
    }
    void unionSet(int i, int j){
        if(!isSame(i,j)){
            int x = findSet(i), y = findSet(j);
            if(rank[x] > rank[y]) {p[y] = x; set_count[x]+=set_count[y];}
            else{
                p[x] = y;
                set_count[y]+=set_count[x];
                if(rank[x] == rank[y]) rank[y]++;
            }
        }
    }
    int count(int x){
        return set_count[findSet(x)];
    }
};
 
signed main()
{
    tezz
 
    int n, m;
    cin>>n>>m;

    map<int, int> ma, mw;

    for(int i=0;i<m;i++){
        int x;
        string s;
        cin>>x>>s;

        if(s[0] == 'A'){
            ma[x]++;
        }
        else{
            if(!ma[x]) mw[x]++;
        }
    } 

    int counta=0, countw=0;
    for(auto it:ma){
        if(!it.y) continue;
        counta++;
        countw += mw[it.x];
    }

    cout<<counta<<' '<<countw;
}

Measured memory_bytes: 12800
n = gets.to_i
arr =[]
sum = 0
n.times{arr << gets.split(" ")}

arr.each do |v|
 if v[1] == "JPY"
  sum += v[0].to_f
 end
 if v[1] == "BTC"
   sum += (v[0].to_f * 380000)
 end
end

p sum



Measured memory_bytes: 1788
m=input()
li=list(map(int,input().split()))
n = int(m)
total=0
for i in range(1,n-1):
  if (li[i-1]<li[i]<li[i+1]) or (li[i-1]>li[i]>li[i+1]):
    total=total+1

print(total)

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

int main(void) {

	string str;
	getline(cin, str);

    for (int i = 0; i < str.size(); ++i) {
        char c = str[i];
        if ('a' <= c && c <= 'z') cout << (char)(c-'a'+'A');
        else if ('A' <= c && c <= 'Z') cout << (char)(c-'A'+'a');
        else cout << c;
    }

    cout << endl;

    
    return 0;
}

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

A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

ans = 0

for i in range(N):
    if i == 0:
        ans += B[A[i]-1]
    else:
        if A[i] - A[i-1] == 1:
            ans += B[A[i]-1] + C[A[i]-2]
        else:
            ans += B[A[i]-1]

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pp() pop_back()
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
#define uni(a) a.erase(unique(a.begin(),a.end()),a.end())
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 /*int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }*/
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int a){
	par= vector<int>(a,-1);
  }
  int find(int a){
    if(par[a]<0)
      return a;
    else
      return par[a]=find(par[a]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
int gcm(int a,int b){
    if(b==0)
        return a;
    return gcm(b,a%b);
}
int lcm(int a,int b){
    return a/gcm(a,b)*b;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
/*struct dfs(){

}*/
signed main(){
	int a,b;
	cin>>a>>b;
	int c=0;
	fo(i,b-a+1)
	c+=i;
	cout<<c-b<<endl;
}

Measured memory_bytes: 256
n = int(input())
cs = []
for i in range(5):
  city = int(input())
  cs.append(city)
m = min(cs)
if m >= n:
  ans = 5
elif m != 1:
  ans = (n + m - n%m) / m + 4
elif m == 1:
  ans = n + 4
print(int(ans))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
using namespace std;
const int N=1e5+5;
void fast()
{
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
}
int a=-1000000,b=1000000,n,m;
int main()
{
	cin>>n>>m;
	a=max(a,m-n+1);
	b=min(b,m+n-1);
	for(int i=a;i<=b;i++)cout<<i<<' ';
}

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

using namespace std;

int main()
{
	int N, A, B;
	cin >> N >> A >> B;

	if (A + B <= N) {
		cout << min(A, B) << " " << 0 << endl;
	}
	else {
		cout << min(A, B) << " " << A + B - N << endl;
	}
	
}

Measured memory_bytes: 3608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		Integer limit = sc.nextInt();
		StringBuffer sb = new StringBuffer();
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if (c == 'a') {
				if (i == s.length() - 1) {
					char new_c = (char) (((int) c) + Math.min('z' - c, limit));
					sb.append(new_c);
					limit -= 25;
				} else {
					sb.append(c);
				}
			} else {
				int delta = 'z' - c;
				if (limit > delta) {
					sb.append('a');
					limit -= delta + 1;
					if (limit == 0 && i + 1 < s.length()) {
						sb.append(s.substring(i + 1));
						break;
					}
				} else {
					if (i == s.length() - 1) {
						char new_c = (char) (((int) c) + Math.min(delta, limit));
						sb.append(new_c);
						limit -= delta;
					} else {
						sb.append(c);
					}
					continue;

				}

			}
		}
		if (limit > 0) {
			s = sb.toString();
			char c = s.charAt(s.length() - 1);
			if (c == 'z') {
				c = 'a';
				limit--;
			}
			int delta = limit % 26;
			if (c + delta > 'z') {
				delta -= 'z' - c;
				c = (char) ((int) 'a' + delta);
			}
			else {
				c += delta;
			}
			System.out.println(s.substring(0, s.length() - 1)
					+ c);
		} else {
			System.out.println(sb);
		}
	}

}


Measured memory_bytes: 17064
import java.util.*;
 public class Main{
	 public static void main(String arg[]){
		 Scanner sc=new Scanner(System.in);
		 String s=sc.next();
		 char ch[]=s.toCharArray();
		 Arrays.sort(ch);
		 if((ch[0]==ch[1])&&(ch[2]==ch[3])&&(ch[0]!=ch[2]))
			 System.out.println("Yes");
		 else System.out.println("No");
	 }
 }

Measured memory_bytes: 23636
#include<stdio.h>
#include<math.h>
int main()
{
    long long int A,P,pie1,pie2,rest1,rest2,sum;
    while(scanf("%lld %lld",&A,&P)!=EOF)
    {
        sum=0;
        pie1=(A*3)/2;
        rest1=(A*3)%2;
        pie2=(P)/2;
        rest2=(P)%2;
        sum=pie1+pie2+((rest1+rest2)/2);
        printf("%lld\n",sum);
    }
    return 0;
}

Measured memory_bytes: 128
/**
 * @jakestrj
 */

#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include "bits/stdc++.h"
using namespace std;
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define rep(i, j, k) for(int i=(j);i<(k);++i)
#define repi(i, j, k) for(int i=(j);i<=(k);++i)
#define per(i, j, k) for(int i=(j);i>(k);--i)
#define peri(i, j, k) for(int i=(j);i>=(k);--i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).begin(),(x).end(), greater<int>()
#define mem(a, b) memset(a, (b), sizeof(a))
#define mem2(a, b) memset(a, (b), sizeof(a[0][0])*len(a)*len(a[0]))
#define sz(x) ((int)(x).size())
#define len(x) (int)(sizeof(x)/sizeof(x[0]))
#define endl "\n"
#define INF 1e18
#define EPS 1e-9
#define PI 2*acos(0)
#define MOD 1000000007
typedef long long ll;
typedef long double ld;
typedef tuple<int, int, int> trio;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef map<int,int> mpii;
typedef set<int> si;

struct D {
	void solve(std::istream& cin, std::ostream& cout) {
		int n; cin >> n;
		vi a(n);
		rep(i, 0, n) cin >> a[i];
		sort(all(a));
		ll mx = a[n-1];
		double n_2 = /*(mx%2==0?(mx/2.0):((mx-1)/2.0));*/mx/2.0;
//		cout << ((n_2)) << endl;
		ld minD = 1e9;
		ll R=a[0];
		rep(i, 0, n-1){
			ld dist = abs(n_2 - a[i]);
			if(dist < minD){
				minD = dist;
				R = a[i];
			}
		}
		cout << mx << " " << R << endl;
	}
};


int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	D solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for(int i=0; i<n; i++)
    cin >> h.at(i);
  
  int count = 0;
  int answer = 0;
  
  for(int i=0; i<n-1; i++) {
    if(h.at(i) >= h.at(i+1)) {
      count ++;
      if(count > answer)
        answer = count;
    }
    else {
      count = 0;
    }
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main()
{
    int S;
    cin >> S;
    int Y = S/100;
    int M = S%100;
    if(((Y>=1)&&(Y<=12))&&((M>=1)&&(M<=12)))
    {
        cout<<"AMBIGUOUS";
    }
    else
    {
        if((Y>=1)&&(Y<=12))

        {
            cout<<"MMYY";
        }
        else if((M>=1)&&(M<=12))

        {
            cout<<"YYMM";
        }
        else
        {
            cout<<"NA";
        }
    }

}


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

using namespace std;

typedef long long LL;

const int N = 100003;

int n, m, a[5][5];
char s[N];
bool st[5][5];

int main()
{
    for (int i = 1; i <= 3; i+=1)
        for (int j = 1; j <= 3; j+=1)
            cin >> a[i][j];
    cin >> n;
    for (int i = 1; i <= n; i+=1)
    {
        int u; cin >> u;
        for (int j = 1; j <= 3; j+=1)
            for (int k = 1; k <= 3; k+=1)
                if (a[j][k] == u)
                    st[j][k] = true;
    }
    if (st[1][1] && st[1][2] && st[1][3]) puts("Yes");
    else if (st[2][1] && st[2][2] && st[2][3]) puts("Yes");
    else if (st[3][1] && st[3][2] && st[3][3]) puts("Yes");
    else if (st[1][1] && st[2][1] && st[3][1]) puts("Yes");
    else if (st[1][2] && st[2][2] && st[3][2]) puts("Yes");
    else if (st[1][3] && st[2][3] && st[3][3]) puts("Yes");
    else if (st[1][1] && st[2][2] && st[3][3]) puts("Yes");
    else if (st[1][3] && st[2][2] && st[3][1]) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
int A, B, K; cin >> A >> B >> K;
for (int i = min(A, B); i >= 1; --i) {
if (A % i == 0 && B % i == 0) {
--K;
if (K == 0) {
cout << i << endl;
return 0;
}
}
}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

// nCr mod p(n<p)をキビキビ計算する
// 構築:O(n), クエリ:O(1)
struct combination_mod {
    using lint = long long int;
    int sz;
    lint mod;
    vector<lint> fac;
    vector<lint> finv;
    combination_mod(int _sz, int _mod) : sz(_sz), mod(_mod) {
        fac.assign(sz + 1, 1);
        finv.assign(sz + 1, 1);
        vector<lint> inv(sz + 1, 1);
        for (int i = 2; i <= sz; 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;
        }
    }
    lint query(int n, int r) {
        return fac[n] * (finv[r] * finv[n - r] % mod) % mod;
    }
};
int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    lint mod = 998244353;
    lint n, a, b, k;
    cin >> n >> a >> b >> k;
    combination_mod cm(n, mod);
    lint ans = 0;
    // Aでi箇所塗る
    for (int i = 0; i <= n; i++) {
        // m:Bの数
        lint rem = k - a * i;
        lint m = rem / b;
        if (rem < 0 || rem % b != 0 || m > n) continue;
        lint temp = cm.query(n, i) * cm.query(n, m);
        temp %= mod;
        ans += temp;
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 7296
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/04/25 16:39:45 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

#define MOD 1e9+7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

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

// TOP
void	Main()
{
	int	n;
	cin >> n;
	vector<int>	V(26);
	rep(i, 26)
		V.at(i) = INT_MAX;
	rep(i, n)
	{
		string	s;
		cin >> s;
		vector<int>	temp(26);
		rep(j, s.size())
			temp.at(s.at(j) - 'a')++;
		rep(j, 26)
			V.at(j) = min(V.at(j), temp.at(j));
	}
	string	s;
	rep(i, 26)
	{
		rep(j, V.at(i))
			s += 'a' + i;
	}
	cout << s << endl;
}
// END

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


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr_inv(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define rep(i,n) repr(i,0,n)
#define INF 2000000000
#define INFLL 9000000000000000000
using namespace std;
int main(void)
{
	int n;
	long long ans=0;

	cin>>n;

	vector<long long> a(n), b(n), c(n);

	rep(i, n) cin>>a[i];
	rep(i, n) cin>>b[i];
	rep(i, n) cin>>c[i];

	sort(a.begin(), a.end());
	sort(c.begin(), c.end());

	rep(i, n){
		vector<long long>::iterator top=lower_bound(a.begin(), a.end(), b[i]);
		vector<long long>::iterator bottom=upper_bound(c.begin(), c.end(), b[i]);
		ans+=(long long)(top-a.begin())*(n-(long long)(bottom-c.begin()));
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 2560
//AtCoder ABC118 C - Monsters Battle Royale
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
int main() {
#if LOCAL&0
    std::ifstream in("./test/sample-1.in"); //input.txt
    std::cin.rdbuf(in.rdbuf());
#endif
    ll N; cin>>N;
    vector<ll> an(N);
    for(auto&& a:an){
        cin>>a;
    }    
    sort(an.begin(),an.end());
    ll ans=an[0];
    while(an.size()>1){
        for(ll i=1;i<an.size();++i){
            an[i]%=ans;
        }
        sort(an.begin(),an.end());
        an.erase(std::remove(an.begin(), an.end(), 0), an.end()); 
        ans=an[0];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
struct Fast {Fast(){std::cin.tie(0);std::ios::sync_with_stdio(false);}} fast;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define repR(i, n) for(ll i = n; i >= 0; i--)
#define For(i, m, n) for(ll i = m; i < n; i++)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) v.begin(), v.end()

using namespace std;

ll mod = 1e9+7;
inline ll gcd(ll a, ll b){
    ll r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

inline ll lcm(ll x, ll y)
{
    if(x == 0 || y == 0) {
        return -1;
    }
    
    return (x * y / gcd(x, y));
}

inline ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

inline ll nCr(ll n, ll r) {
    if ( r * 2 > n ) r = n - r;
    ll dividend = 1;
    ll divisor  = 1;
    for ( ll i = 1; i <= r; ++i ) {
        dividend *= (n-i+1);
        divisor  *= i;
    }
    return (dividend / divisor);
}

// 因数分解
inline vector<pair<ll, int>>factorize(ll n){
    vector<pair<ll, int>> res;
    for(ll i = 2; i * i <= n; ++i){
        if(n % i) continue;
        res.emplace_back(i, 0);
        while(n % i == 0){
            n /= i;
            res.back().second++;
        }
    }
    if(n != 1) res.emplace_back(n, 1);
    return res;
}

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

//階乗
inline ll factorialMethod(ll k){
    ll sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

inline ll vector_finder(std::vector<ll> vec, ll number) {
    auto itr = std::find(vec.begin(), vec.end(), number);
    size_t index = std::distance( vec.begin(), itr );
    if (index != vec.size()) { // 発見できたとき
        return 1;
        
        
    }
    else { // 発見できなかったとき
        return 0;
    }
}

void recursive_comb(ll *indexes, ll s, ll rest, std::function<void(ll *)> f) {
    if (rest == 0) {
        f(indexes);
    } else {
        if (s < 0) return;
        recursive_comb(indexes, s - 1, rest, f);
        indexes[rest - 1] = s;
        recursive_comb(indexes, s - 1, rest - 1, f);
    }
}

void foreach_permutation(int n, std::function<void(int *)> f) {
    int indexes[n];
    for (int i = 0; i < n; i++) indexes[i] = i;
    do {
        f(indexes);
    } while (std::next_permutation(indexes, indexes + n));
}

int main(){
    ll a, b;
    cin >> a >> b;
    
    For(i, 1, 1001){
        if((ll)(i * 0.08) == a
           && (ll)(i * 0.1) == b){
            cout << i << endl;
            return 0;
        }
    }
    
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
int MOD=1000000007;

int main(){
	long long N,M,ans=0;
	cin >> N >> M;
	if(N>=M){
		cout << M/2 << endl;
		return 0;
	}
	while(N!=0){
		M-=2;
		N-=1;
		ans+=1;
	}ans+=M/4;
	cout << ans << endl;
	}

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

int main() {
    int i,j;
    double A[5], B[5];
    int count=0;

    for(i=0;i<5;++i) {
        scanf("%lf", &A[i]);
    }

    for(i=0;i<5;++i){
        if((int)A[i]%10==0){
            B[i] = 0;
        }else if(A[i]<10){
            B[i] = 10 - A[i];
        }else if(A[i]<100){
            B[i] = A[i]/10 + 1;
            B[i] = ((int)B[i]) * 10 - A[i];
        }else{
            B[i] = (A[i]-100)/10 + 1;
            B[i] = ((int)B[i]) * 10 + 100 - A[i];
        }
    }




    for( i=0;i<5;i++)
    {
        for( j=i+1;j<5;j++)
        {
            if(B[i] > B[j])
            {
                count = B[i];
                B[i] = B[j];
                B[j] = count;
            }
        }
    }

    printf("%.0f\n",A[0]+A[1]+A[2]+A[3]+A[4]+B[0]+B[1]+B[2]+B[3]);
    return 0;
}

Measured memory_bytes: 128
n,c,k,*t=map(int,open(0).read().split())
t.sort(reverse=1)
a=0
while t:
  h=t.pop()
  i=h
  j=1
  while t and j<c and i-h<k:
    i=t.pop()
    j+=1
  if i-h>k:
    t.append(i)
  a+=1
print(a)

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

int dice[6];
int i,t;

int ue=1;
int hid=4;
int mig=3;
int mae=2;
int usi=5;
int sit=6;

int MoveAll(int ueA,int maeA);
void eMove();
void nMove();
void sMove();
void wMove();

int main(){
	int stmn,ueS,maeS=0;
	
	for(i=0;i<6;i++)scanf("%d",&dice[i]);
	scanf("%d",&stmn);
	for(i=0;i<stmn;i++){
		scanf("%d %d",&ueS,&maeS);
		printf("%d\n",MoveAll(ueS,maeS));
	}
	
	return 0;
}

int MoveAll(ueA,maeA){
	while(!((ueA==dice[ue-1])&&(maeA==dice[mae-1]))){
		int rnd=rand()%4;
		
		if(rnd==0)eMove();
		else if(rnd==1)nMove();
		else if(rnd==2)sMove();
		else wMove();
	}
	return dice[mig-1];
}

void eMove(){
	t=ue;
	ue=hid;
	hid=sit;
	sit=mig;
	mig=t;
	return;
}

void nMove(){
	t=ue;
	ue=mae;
	mae=sit;
	sit=usi;
	usi=t;
	return;
}

void sMove(){
	t=ue;
	ue=usi;
	usi=sit;
	sit=mae;
	mae=t;
	return;
}

void wMove(){
	t=ue;
	ue=mig;
	mig=sit;
	sit=hid;
	hid=t;
	return;
}



Measured memory_bytes: 2016
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    if N%2==0:
        print(N)
    else:
        print(N*2)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;

#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, i;
    cin>>n;
    string s, a;
    cin>>s;
    if(n & 1) {
    	cout<<"No\n";
    	return 0;
    }
    for(i=0; i<n/2; i++) {
    	a.pb(s[i]);
    }
    a = a + a;
   	if(a == s) {
   		cout<<"Yes\n";
   	}
   	else {
   		cout<<"No\n";
   	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <cstdlib>
#include <cstring>
#include <iterator>
#include <algorithm>
using namespace std;


const int N = 2e5 + 5;
vector<int> g[N];
bool vis[N];

void dfs(int u, int& sz)
{
    vis[u] = true;
    ++sz;
    for (int v : g[u])
    {
        if (!vis[v])
            dfs(v, sz);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    map<pair<int, int>, int> edge;
    int n, m;
    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int u, v;
        cin >> u >> v;
        if (edge.count({u, v}) == 0)
        {
            g[u].push_back(v);
            g[v].push_back(u);
            edge[ {u, v}] = 1;
            edge[ {v, u}] = 1;
        }
    }
    int ans = 0;
    memset(vis, false, sizeof vis);
    for (int i = 0; i < n; i++)
    {
        if (!vis[i])
        {
            int c = 0;
            dfs(i, c);
            //cout << i << " " << c << endl;
            ans = max(ans, c);
        }
    }
    cout << ans;
    return 0;
}

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

#define ll long long
#define ss second
#define ff first
#define pb push_back

using namespace std;

const int N = 1e6 + 69, mod = 1e9 + 7;

int n, m;

ll answer[1005][1005];

char A[1005][1005];

int main(){

        ios :: sync_with_stdio(0);

        cin >> n >> m;

        for(int i = 1; i <= n; i++){
                for(int j = 1; j <= m; j++){
                        cin >> A[i][j];

                        if(A[i][j] == '#') continue;

                        if(i*j == 1){
                                answer[1][1] = 1;
                                continue;
                        }

                        answer[i][j] = answer[i-1][j] + answer[i][j-1];
                        answer[i][j] %= mod;

                }
        }

        cout << answer[n][m] << endl;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N;
	cin >> N;
	vector<ll> A(N);
	REP(i, N) cin >> A[i];

	sort(A.begin(), A.end());
	A.erase(unique(A.begin(), A.end()), A.end());
	cout << A.size() << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int a, b; cin >> a >> b;
    if(a + b < 10) cout << a + b << endl;
    else cout << "error" << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		new Main().run();
	}
	private void run() throws IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(reader.readLine());
		int n = Integer.parseInt(st.nextToken());
		int k = Integer.parseInt(st.nextToken());
		int[] a = new int[n];
		int biggest = Integer.MIN_VALUE;
		int sum = 0;
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(reader.readLine());
			biggest = Math.max(biggest, a[i]);
			sum += a[i];
		}
		reader.close();
		
		int floor = biggest;
		int ceiling = sum;
		while (floor < ceiling) {
			int p = floor + (ceiling - floor) / 2;
			int total = 0;
			int cnt = 1;
			for (int i = 0; i < n; i++) {
				if (total + a[i] > p) {
					cnt++;
					total = 0;
				}
				total += a[i];
			}
			if (cnt <= k) {
				ceiling = p;
			} else {
				floor = p + 1;
			}
		}
	
		System.out.println(ceiling);
	}
}



Measured memory_bytes: 35432
//#define _GLIBCXX_DEBUG

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-9
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}

int f(int n, int a, int b){
    int ret = 0;
    ret += n/a;
    ret += n/b;
    ret -= n/lcm(a,b);
    return n-ret;
}

signed main(void) {
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout << f(b,c,d) - f(a-1,c,d) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
using namespace std;
vector <long long> adj[1000005];
long long F[1000005], a, b, n, m, dd[1000005], res;
long long dfs(long long u)
{
    for (long long v : adj[u])
        if (!dd[v])
        {
            dd[v] = 1;
            F[u] = max(F[u], dfs(v) + 1);
        }
        else F[u] = max(F[u], F[v] + 1);
    return F[u];
}

int main()
{
    //freopen("LONGEST.INP", "r", stdin);
    cin >> n >> m;
    for (long long i = 1; i <= m; i++)
    {
        cin >> a >> b;
        adj[a].push_back(b);
    }

    for (long long i = 1; i <= n; i++)
        if (!dd[i])
        {
            dd[i] = 1;
            dfs(i);
        }

    for (long long i = 1; i <= n; i++) res = max(res, F[i]);
    cout << res;
    return 0;
}


Measured memory_bytes: 33600
n,m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
ab.sort()
money = 0
drink = 0
for a,b in ab:
  money += a*b
  drink += b
  if drink >= m:
    money -= (drink-m) * a
    break
print(money)

Measured memory_bytes: 27760
import java.util.*;
public class Main {
    public static void main(String[] args ){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        int count = 0;
        for (int i = 0; i < n; i++) {
            int k = i;
            for (int j = i+1; j < n; j++) {
                while (k < n && a[k] < a[i] + a[j]) k++;
                count += k - (j+1);
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 40136
import java.util.*;

public class Main{
  public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		if(S.charAt(2) == S.charAt(3) && S.charAt(4) == S.charAt(5)) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 35604