akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, N;
    cin >> H >> N;
    int A[100010];
    rep(i, N) cin >> A[i];
    int ans = 0;
    rep(i, N) ans += A[i];
    if (ans >= H) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

i64 n, m;
vector<i64> a, b, c; 
i64 dp[1001][5000];
int main() {
  cin >> n >> m;
  a.assign(m + 1, 0);
  b.assign(m + 1, 0);
  c.assign(m + 1, 0);
  for (i64 i = 0; i < m; ++i) {
    cin >> a[i] >> b[i];
    for (i64 j = 0; j < b[i]; ++j) {
      i64 x;
      cin >> x;
      c[i] |= 1 << (x - 1);
    }
  }

  for (i64 i = 0; i <= m; ++i) {
    for (i64 s = 1; s < (1 << n); ++s)
      dp[i][s] = 1ll << 50;
  }

  for (i64 i = 0; i < m; ++i) {
    for (i64 s = 0; s < (1 << n); ++s) {
      dp[i + 1][s] = dp[i][s];
    }
    for (i64 s = 0; s < (1 << n); ++s) {
      i64 t = s | c[i];
      dp[i + 1][t] = min({dp[i + 1][t], dp[i][t], dp[i][s] + a[i]});
  //    cerr << i + 1 << '\t' << t << '\t' << dp[i + 1][t] << endl;
    }
  }
  i64 ans = dp[m][(1 << n) - 1];
  if (ans >= (1ll << 50)) ans = -1;
  cout << ans << endl;
  return 0;
}



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

// Optimization

//#pragma GCC optimize("O3")
#define endl '\n'

// Shortcut

#define int long long
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) Fora(iiii, a) cout << iiii << ' ';
#define PrintVl(a) Fora(iiii, a) cout << iiii << endl;
#define PrintA(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << ' ';
#define PrintAl(a, l, r) for (int iiii = l; iiii <= r; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a))
#define mset1(a) memset(a, 1, sizeof(a))
#define msetn1(a) memset(a, -1, sizeof(a))
#define msetinf(a) memset(a, 0x3f, sizeof(a))
#define gcd __gcd
#define __builtin_popcount __builtin_popcountll
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
#define div divi
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 1e5 + 5, mod = 1e9 + 7, mod1 = 998244353, mod2 = 1e9 + 9, inf = 1e9 + 7;
const ll infll = 1e18 + 7;

int n, m, k;
int q = 1;
int ans, tmp, cnt, idx, mx, mn, sum;
int x, y, z;
int a[N], b[N];
string s, t;

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
//cin >> q;
while (q--){
    cin >> x >> y;
    if (y < x) swap(x, y);
    while (y--) cout << x;
}
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int N;
char s[101];
char t[101];
int cmp(){
  int d=N;
  int flag=0;
  int i,j;
  for( i=N-1;i>=0;i--){
    flag=0;
    if(s[i]==t[0]){
      for(j=1;i+j<N;j++){
	if(s[i+j]!=t[j]){
	  //printf("not %c %c\n",s[i+j],t[j]);
	  flag=1;
	}
      }
    if(flag==0)d=i;
    }
    // printf("%d\n",d);
  }
  return d;
}
int main(){
  int len;
  scanf("%d",&N);
  scanf("%s %s",s,t);
  if(N==1){
    if(s[0]==t[0])printf("1\n");
    else printf("2\n");
    return 0;
  }
  len=cmp();
  printf("%d\n",len+N);
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int mm;
  string S;
  cin >> S ;
  mm=(S[5]-'0')*10+S[6]-'0';
  if(mm<=4){
  cout << "Heisei" << endl;
  }
  else{
  cout << "TBD" << endl;
  }
}

  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define em emplace
#define eb emplace_back
#define mp make_pair
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

constexpr ll MOD = 1000000007;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  int a; cin >> a;
  cout << a + a*a + a*a*a << endl;
  
  return (0);
}

Measured memory_bytes: 3576
#include<iostream>
using namespace std;
int main(){
    string x;
    cin >> x;
    int i;
    for (i = 0; i < 3; i++){
        int a = x[i] - '0';
        if (a == 1) cout << 9;
        else if(a == 9) cout << 1;  
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>

int main() {
  char S[4];
  std::cin >> S;

  int plus = 0;
  int minus = 0;
  for (int i = 0; i < 4; ++i) {
    if ( S[i] == '+' ) ++plus;
    else if ( S[i] == '-' ) ++minus;
  }
  int sum = plus - minus;
  std::cout << sum << std::endl;

  return 0;
}


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

int main(){
int N, H;
cin >> N >> H; 
int a[114514], b[114514];
for(int i = 0; i < N; i++){
cin >> a[i] >> b[i];
}
sort(a, a + N, greater<int>());
sort(b, b + N, greater<int>());
int M = a[0]; 
int c[114514];
c[1] = b[0];  
for(int i = 1; i < N; i++){
c[i+1] = c[i] + b[i]; 
}
int ans = 1000000000; 
for(int i = 0; i <= N; i++){
int kaisuu = i + max((H - c[i] + M - 1)/M, 0); 
ans = min(ans, kaisuu); 
}
cout << ans << endl; 
}


Measured memory_bytes: 1408
N = int(input())
a = [int(x) for x in input().split()]

b = sorted(a)
M = ((N + 1) * N // 2 + 1) // 2


class BIT(object):
    def __init__(self, N=1):
        self.N = N
        self.bit = [0] * (N + 1)

    def add(self, i, x):
        while i <= self.N:
            self.bit[i] += x
            i += i & -i

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s


def is_OK(x):
    S = [1] * N
    for i in range(N):
        if a[i] < x:
            S[i] = -1
        if i > 0:
            S[i] += S[i - 1]
    S = [0] + S
    min_S = min(S)
    max_S = max(S)

    bit = BIT(max_S - min_S + 1)
    cnt = 0
    for S_i in S:
        S_i = S_i - min_S + 1
        cnt += bit.sum(S_i)
        bit.add(S_i, 1)
    return cnt >= M


left, right = 0, 10 ** 9 + 1
while right - left > 1:
    mid = (left + right) // 2
    if is_OK(mid):
        left = mid
    else:
        right = mid

print(left)

Measured memory_bytes: 112612
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())

N = I()
dist = [[100]*(N+1) for _ in range(N+1)]  # 2点間の最短距離
edges = {}

for i in range(N-1):
    a,b = MI()
    dist[a][b] = 1
    dist[b][a] = 1
    edges[(a,b)] = i
    edges[(b,a)] = i

for i in range(1,N+1):
    dist[i][i] = 0

for k in range(1,N+1):
    for i in range(1,N+1):
        for j in range(1,N+1):
            dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j])

M = I()
A = []  # uとvを結ぶ経路上にある辺の集合
for _ in range(M):
    u,v = MI()
    B = set()
    while True:
        if dist[u][v] == 1:
            B.add(edges[(u,v)])
            break
        else:
            for i in range(1,N+1):
                if dist[u][i] == dist[u][v]-1 and dist[i][v] == 1:
                    B.add(edges[(i,v)])
                    v = i
                    break
    A.append(B)

# 包除原理

ans = 0
for i in range(2**M):
    C = set()
    a = 0
    for j in range(M):
        if (i >> j) & 1:
            C = C | A[j]
            a = 1-a
    l = len(C)
    if a == 0:
        ans += pow(2,N-1-l)
    else:
        ans -= pow(2,N-1-l)

print(ans)


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

using namespace std;

vector<int> get_divisors(int n) {
    vector<int> ds;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ds.push_back(i);
            if (n / i != i) {
                ds.push_back(n / i);
            }
        }
    }
    sort(ds.begin(), ds.end());
    return ds;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> ds = get_divisors(m);
    reverse(ds.begin(), ds.end());
    for (auto d : ds) {
        if (m / d >= n) {
            cout << d << endl;
            return 0;
        }
    }
    assert (false);
    return 0;
}


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

#define ll long long int

static const auto _____ = []() {
    // fast IO code : this I understand
    ios::sync_with_stdio(false);
    cout.tie(NULL);
    cin.tie(0);
    return 0;
}();

int main(){
	string s;
	cin>>s;
	if(s[(s.size()-1)] == 's')
		s.append("es");
	else
		s.append("s");
	cout<<s<<endl;
	return 0;
}


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

public class Main{
  public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int[] As = new int[3];
        As[0] = scanner.nextInt();
        As[1] = scanner.nextInt();
        As[2] = scanner.nextInt();

        int bestCost = 99999;
        for(int i = 0; i < 3;i++){

            for(int j = 0; j < 3;j++){
                if(j == i) continue;
                int sum = 3 - i - j;
                int a = Math.abs(As[j] - As[i]);
                a+=  Math.abs(As[sum] - As[j]);
                if(a < bestCost){
                    bestCost = a;
                }
            }

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

Measured memory_bytes: 21588
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
#include<time.h>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;



int main()
{

    string p;
    cin >> p;
    set<char>t;

    for (int i = 0; i < p.size(); i++) {
        t.insert(p[i]);
    }
    if (t.size() <= 1)cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;

}

Measured memory_bytes: 3608
import java.util.Scanner;
 
class Main {
    public static void main(String[] args) {
        int x, y, r, w, h;
        String s = "No";
        Scanner sc = new Scanner(System.in);
        w = sc.nextInt();
        h = sc.nextInt();
        x = sc.nextInt();
        y = sc.nextInt();
        r = sc.nextInt();

        if (h-y-r >= 0 && y-r >= 0 && w-x-r >= 0 && x-r >= 0)
            s = "Yes";
        System.out.println(s);
    }
}


Measured memory_bytes: 26272
#include<bits/stdc++.h>
using namespace std;
int n;
int sz(int n)
{
	int s=0;
	for (int i=1;i<=n;i*=10)
	{
		s++;
	}
	return s;
}
int s;
int main()
{
	cin>>n;
	for (int i=1;i<=n;i++)
	{
		if (sz(i)%2) s++;
	}
	cout<<s<<endl;
	return 0;
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1



bool compe( pair<ll,ll> A , pair<ll,ll> B ){
    if( A.second != B.second ) return A.second > B.second;
    else return A.first > B.first;
}


int main() {

    int N;
    ll A,B;
    pair<ll,ll> P[100023];

    ll ans = 0;
    Scd(N);
    Rep(i,N){
        Scll2(A,B);
        ans += B;
        P[i].first = A;
        P[i].second = A+B;
    }
    sort(P,P+N,compe);

    Rep(i,N){
        if( i%2 == 0 )
            ans = ans-P[i].second;
        else
            ans;
    }

    printf ("%lld\n", -ans);


    return 0;
}



Measured memory_bytes: 1792
k = []

n, m = map(int, input().split())
for i in range(m):
    k.append(list(map(int, input().split())))
    del k[i][0] 

p = list(map(int, input().split()))

cnt = 0
ans = 0
for i in range(2 ** n):
    lis = [False] * n

    for j in range(n):
        if (i >> j) & 1:
            lis[j] = True
    #print(lis)
    cnt = 0
    for j in range(m):
        val = 0
        for l in range(len(k[j])):
            if lis[k[j][l]-1] == True:
                val += 1
            #print(lis[k[j][l]-1])
        if val % 2 == p[j]:
            cnt += 1
        #print(val)
        #print(cnt)
    if cnt == m:
        ans += 1
    #print(ans)



print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define mii map<int,int>
#define mll map<long long int,long long int>
#define mci map<char,int>
#define F first
#define S second
#define pb push_back
#define endl '\n'
#define yes cout << "YES\n"
#define no cout << "NO\n" 
#define pi 3.1415926536
#define mod  1000003
using namespace std;


int main(){
    IOS;

ll a,b,c,k;ll x=0;
  cin>>a>>b>>c>>k;
  if(k>=a) x=x+a;
  else x=x+k;
  k=k-a;
  if(k>=0){
  if(k>=b) x=x;
  else x=x;}
   k=k-b;
  if(k>=0){
  if(k>=c) x=x-c;
  else x=x-k;}
 cout<<x;
return 0;}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#include <atcoder/all>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<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; }

int main() {
  int t;
  cin>> t;
  REP(ti, t) {
    int n,m,a,b;
    cin>>n>>m>>a>>b;
    cout << floor_sum(n,m,a,b) << endl;
  }

  return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		Arrays.setAll(h, i -> sc.nextInt());
		
		int[] dp = new int[n];
		dp[0] = 0;
		dp[1] = Math.abs(h[0] - h[1]);
		for (int i = 2; i < n; i++) {
			dp[i] = Math.min(dp[i - 1] + Math.abs(h[i - 1] - h[i])
			               , dp[i - 2] + Math.abs(h[i - 2] - h[i]));
		}
		
		System.out.println(dp[n - 1]);
				
		sc.close();
	}

}




Measured memory_bytes: 51312
from collections import deque

MOD = 10**9 + 7

N = int(input())
adjL = [[] for v in range(N)]
degs = [0] * N
for _ in range(N-1):
    x, y = map(int, input().split())
    adjL[x-1].append(y-1)
    adjL[y-1].append(x-1)
    degs[x-1] += 1
    degs[y-1] += 1

dpWhite = [1] * N
dpBlack = [1] * N
vNow = 0
Q = deque([v for v in range(N) if degs[v] == 1])
while Q:
    vNow = Q.popleft()
    if degs[vNow] == 0: break
    dpW, dpB = dpWhite[vNow], dpBlack[vNow]
    for v2 in adjL[vNow]:
        if degs[v2] == 0: continue
        dpWhite[v2] *= dpW + dpB
        dpWhite[v2] %= MOD
        dpBlack[v2] *= dpW
        dpBlack[v2] %= MOD
        degs[v2] -= 1
        if degs[v2] == 1:
            Q.append(v2)
    degs[vNow] = 0

print((dpWhite[vNow] + dpBlack[vNow]) % MOD)


Measured memory_bytes: 30188
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define INF 0x3f3f3f3f
#define lowbit(x) (x&(-x))
#define mid ((l+r)>>1)
using namespace std;
template<class T>il read(T &x){
	x=0;int f=1;char k=getchar();
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=x*10+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x>9) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
const int N = 2e5+5;
int n,s,val[N];
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n);
	for(ri i=1;i<=n;++i)
		read(val[i]);
	sort(val+1,val+1+n);
	if(n==unique(val+1,val+1+n)-val-1)
		puts("YES");
	else
		puts("NO");
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))

using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const int N = 3 * (int)1e5;
vi t;
vector<bool> isP(N + 1);

int main(void){
    for(int n = 6; n <= N; n += 7){
        t.pb(n);
        if(n != 6) t.pb(n - 5);
    }
    sort(ALL(t));

    fill(ALL(isP), false);
    for(vi::iterator i = t.begin(); i != t.end(); i ++)
        isP[*i] = true;
    
    for(vi::iterator i = t.begin(); *i <= 547; i ++)
        if(isP[*i])
            for(vi::iterator j = i; (*i) * (*j) <= N; j ++)
                isP[(*i) * (*j)] = false;
    
    for(int in; cin >> in, in != 1; cout << endl){
        cout << in << ':';

        rep(i, N)
            if(isP[i] && !(in % i))
                cout << ' ' << i;
    }

    return 0;
}

Measured memory_bytes: 1628
from operator import itemgetter
n,m=map(int,input().split())
li=[list(map(int, input().split())) for i in range(n)]
li.sort(key=itemgetter(0))
ans=0
i=0
for i in li:
    a,b=i[0],i[1]
    if m>=b:
        ans+=a*b
        m-=b
    else:
        ans+=a*m
        break
print(ans)



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

typedef long long ll;
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
 
using namespace std;

int main(){

    ll n,h;
    cin >> n>> h;
    ll a[n],b[n];
    REP(i,n) cin >> a[i] >> b[i];
    sort(a,a+n);
    sort(b,b+n);

    ll cnt = 0;
    int c = n-1;
    while(h > 0){
        if(a[n-1] < b[c] && c >= 0){
            h -= b[c];
            cnt++;
            c--;
        }else{
            h -= a[n-1];
            cnt++;
        }
    }
    cout << cnt;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
//ofstream fout("output.txt");
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define IOS ios_base::sync_with_stdio(0);
#define pi 4*atan(1)
#define f(n) for(int i=0;i<n;++i)
#define fab(a,b) for(int i=a;i<=b;++i)
#define fba(b,a) for(int i=b;i>=a;--i)
#define reset(a,x) memset(a,x,sizeof(a))
typedef pair<int,int> ipair;
typedef vector<int> vi;
int main(){
    IOS
    cin.tie(0);


   

        int n;
        cin>>n;
        int cnt=0,temp=0;
        if(n>=500)
        {
            temp=n/500;
            n-=temp*500;
            cnt+=1000*temp;
        }

        if(n>=5){
            temp=n/5;
            n-=temp*5;
            cnt+=5*temp;
        }

        cout<<cnt<<endl;
    







    return 0;
}










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

using namespace std;

int main()
{	
	       int N;
	       cin >> N;
	       string str;
	       cin >> str;
	       int arr[260] , brr[260];
	       memset(arr , -1 , sizeof arr);
	       memset(brr , -1 , sizeof brr);
	       for(int i = 0 ; i < str.size() ; i++) {
	       	int ch = str[i] - 'a';
	       	if(arr[ch] != -1) continue;
	       	for(int j = str.size() - 1 ; j > i ; j--) {
	       		int ch2 = str[j] - 'a';
	       		if(ch == ch2) {
	       			brr[ch] = j + 1; ///End
	       			arr[ch] = i + 1; ///Start
	       			break;
	       	   }
	       	 }
	       }
	       int cnt = 0 , ans = 0;
	       for(int i = str.size() - 1 ; i >= 0 ; i--) {
	       	int ch = str[i] - 'a';
	       	if(!arr[ch] == i + 1 or !brr[ch] == i + 1) continue;
	       	if(brr[ch] == i + 1) cnt++ , ans = max(ans , cnt);
	       	if(arr[ch] == i + 1) cnt-- , ans = max(ans , cnt);
	      }
	       cout << ans << endl;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] P = new int[N];
		for(int i=0; i<N; i++) {
			P[i] = sc.nextInt();
		}
		
		int min = N;
		int ans = 0;
		for(int i=0; i<N; i++) {
			if(P[i]<=min) {
				ans ++;
				min = P[i];
			}
		}

		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 82544
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T>using onset=tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
void solve(){
  #ifndef ONLINE_JUDGE    
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}
signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf   
    ll n; 
    cin>>n; 
    if(n>=30){
      cout<<"Yes";
    }
    else
      cout<<"No";
    //printclock;
    return 0;
}
    

Measured memory_bytes: 3516
#include<bits/stdc++.h>
using namespace std;
const int N=2e3+100;
#define ll long long

vector<int> a,b,c;

void solve(){
    int x,y,A,B,C;
    scanf("%d%d%d%d%d",&x,&y,&A,&B,&C);
    for(int i=0;i<A;++i){
        int m;scanf("%d",&m);a.push_back(m);
    }
    for(int i=0;i<B;++i){
        int m;scanf("%d",&m);b.push_back(m);
    }
    for(int i=0;i<C;++i){
        int m;scanf("%d",&m);c.push_back(m);
    }
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    for(int i=A-1;i>=A-x;--i){
        c.push_back(a[i]);
    }
    for(int i=B-1;i>=B-y;--i){
        c.push_back(b[i]);
    }
    sort(c.rbegin(),c.rend());
    ll sum=0;
    for(int i=0;i<x+y;i++){
        sum+=c[i];
    }
    cout<<sum<<endl;
}

int main(){
    solve();
}


Measured memory_bytes: 3188
#include <iostream>

using namespace std;

int main(){
    int n,a[100],*p=a,*q=a;

    cin >> n;

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

    int temp;
    while(p<q){
        temp = *p;
        *p = *q;
        *q = temp;
        p++;q--;
    }

    for(int i=0;i<n-1;i++){
        cout<<a[i]<<" ";
    }
    cout <<a[n-1]<<endl;

    return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

template <typename T, T F(T, T), T INIT>
struct SegmentTree {
    T n;
    vector<T> v;

    SegmentTree(T n_){
        n = 1;
        while(n < n_){ n *= 2; }
        v.resize(2 * n - 1);
        fill(v.begin(), v.end(), INIT);
    }

    // zero-indexed
    void update(ll k, T a){
        k += n - 1;
        v[k] = a;
        while(k > 0){
            k = (k - 1) / 2;
            v[k] = F(v[k * 2 + 1], v[k * 2 + 2]);
        }
    }

    // [a, b), zero-indexed
    T query(ll a, ll b) const {
        return query_internal(a, b, 0, 0, n);
    }

    T query_internal(ll a, ll b, ll k, ll l, ll r) const {
        if(r <= a || b <= l){ return INIT; }
        if(a <= l && r <= b){
            return v[k];
        }else{
            T v1 = query_internal(a, b, k * 2 + 1, l, (l + r) / 2);
            T v2 = query_internal(a, b, k * 2 + 2, (l + r) / 2, r);
            return F(v1, v2);
        }
    }
};

ll op(ll a, ll b){ return min(a, b); }

int main(){
    ll n, m;
    cin >> n >> m;
    vector<array<ll, 3>> lrc(m);
    REP(i, m){
        cin >> lrc[i][0] >> lrc[i][1] >> lrc[i][2];
        lrc[i][0]--;
        lrc[i][1]--;
    }
    sort(lrc.begin(), lrc.end());

    SegmentTree<ll, op, numeric_limits<ll>::max()> st(n);
    st.update(0, 0);
    REP(i, m){
        ll mval = st.query(lrc[i][0], lrc[i][1]);
        if(mval == numeric_limits<ll>::max()){
            continue;
        }
        ll newval = mval + lrc[i][2];
        st.update(
            lrc[i][1],
            op(newval, st.query(lrc[i][1], lrc[i][1] + 1))
        );
    }
    if(st.query(n - 1, n) == numeric_limits<ll>::max()){
        cout << -1 << endl;
    }else{
        cout << st.query(n - 1, n) << endl;
    }
    return 0;
}


Measured memory_bytes: 4608
import qualified Data.ByteString.Char8 as BC
import Data.Maybe (fromJust)
import Data.Array.IO
import Data.List
import Control.Monad

main = do
  n <- readLn :: IO Int
  p <- getIntListBC
  memo <- newListArray (0, n+1) (0:p) :: IO (IOUArray Int Int)
  let index = [1..n]
  foldM swap memo index
  print =<< readArray memo 0

bsToInt :: BC.ByteString -> Int
bsToInt = fst . fromJust . BC.readInt

getIntListBC :: IO [Int]
getIntListBC = map bsToInt . BC.words <$> BC.getLine

swap :: IOUArray Int Int -> Int -> IO (IOUArray Int Int)
swap memo i = do
  count <- readArray memo 0
  n <- readArray memo i
  m <- readArray memo $ i + 1
  let (nn, mm, count') = if i == n then (m, n, count + 1) else (n, m, count)
  writeArray memo i nn
  writeArray memo (i+1) mm
  writeArray memo 0 count'
  return memo


Measured memory_bytes: 2940
function Main(input) {
	input = input.split("\n");
    var series = input[1].split(" ");
    series.map(str => parseInt(str, 10));
    var n = parseInt(input[0], 10);
    var count = 0;
    for(var i = 0; i < n; i++){
        count = count + (((i+1) == series[i])?0:1);
    }
    var res = (count != 0 && count != 2)?"NO":"YES";
	//出力
	console.log(res);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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


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

  int ans = 1;
  for(int i=1; i *i <= m; ++i){
    if(m % i == 0 ){
      if(m / i >= n){
	ans = max(ans, i);
      }

      if(m / (m / i) >= n){
	ans = max(ans, m/i);
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int h[2],k[2],a[4];
	int i,j,hi,ke;
	
	scanf("%d %d",&h[0],&k[0]);
	
	scanf("%d %d",&h[1],&k[1]);
	
	for(i=0;i<4;i++) scanf("%d",&a[i]);
	
	hi=h[0]*a[0]+k[0]*a[1]+
		h[0]/10*a[2]+k[0]/20*a[3];
		
	ke=h[1]*a[0]+k[1]*a[1]+
		h[1]/10*a[2]+k[1]/20*a[3];
		
	if(hi==ke) printf("even\n");
	
	else if(hi>ke)printf("hiroshi\n");
	
	else if(hi<ke)printf("kenjiro\n");
}	


Measured memory_bytes: 2692
#include<cstdio>

int main() {
    int S;
    scanf("%d",&S);
    int h = S / 3600;//時間
    S %= 3600;// S = S % 3600
    int m = S / 60;//分
    int s = S % 60;//秒

    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2680
#include <iostream>
#include <vector>
#include <algorithm>
#define int long long
using namespace std;

typedef pair<int,int> P;

int bit[100001][2],n;
vector<P> bug;

int sum(int i,int num){
	int s = 0;
	while(i > 0){
		s += bit[i][num];
		i -= i & -i;
	}
	return s;
}

void add(int i,int x,int num){
	while(i <= 100000){
		bit[i][num] += x;
		i += i & -i;
	}
}

bool C(int x,int ok){
	return sum(x,0) * ok >= sum(x,1);
}

signed main(){
	int ma = 0;
	cin >> n;
	for(int i = 0;i < n;i++){
		int a,b;
		cin >> a >> b;
		bug.push_back(P(b,a));
	}
	sort(bug.begin(),bug.end(),greater<P>());
	for(int i = 0;i < n;i++){
		int ok = bug[i].first,foo = bug[i].second;
		add(foo,1,0);
		add(foo,foo,1);
		int low = 0,up = 100001;
		while(up - low > 1){
			int mid = (up + low) / 2;
			if(C(mid,ok)) low = mid;
			else up = mid;
		}
		int s = sum(low,0);
		if(low != 100000 && sum(low + 1,0) - sum(low,0) >= 2){
			int j = 1;
			for(;j < sum(low + 1,0) - sum(low,0);j++){
				if((sum(low,0) + j) * ok < sum(low,1) + j * (low + 1)) break;
			}
			s += j - 1;
		}
		ma = max(s,ma);
	}
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 11196
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;
struct poi{int to,cost;
  poi(int t, int c){
    to = t;cost = c;
  }
  };
vector<ll> d;
vector<vector<poi> > edges;
int V,E,r;
ll INF = 5000000000;

/*bool berm(){
  for(int ct=0;ct<V;ct++){
    for(int i=0;i<E;i++){
      int v = edges[i].to;
      int u = edges[i].from;
      int c = edges[i].cost;
      if(d[u] + c < d[v]){
	d[v] = d[u] + c;
		if(ct == V-1){
	  return false;
	  }
      }
    }
  }
  return true;
  }*/
typedef pair<int,int> P;
int dijk(){
  priority_queue<P,vector<P>,greater<P> > que;
  que.push(P(0,r));
  while(!que.empty()){
    P p = que.top(); que.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int i = 0;i < edges[v].size(); i++){
      poi e = edges[v][i];
      if (d[e.to] > d[v] + e.cost){
	d[e.to] = d[v] + e.cost;
	que.push(P(d[e.to], e.to));
      }
    }
  }
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> V >> E >> r;//V is number of point,E is number of hen,r is defpoint
  d.resize(V,INF);
  d[r] = 0;
  edges.resize(V,vector<poi>());
  REP(i,E){
    int from,to,cost;
    cin >> from >> to >> cost;
    edges[from].push_back(poi(to,cost));
  }
  dijk();
  REP(i,V)
    if(d[i] == INF)cout << "INF" << endl;
    else cout << d[i] << endl;
  return 0;
}

Measured memory_bytes: 13260
n,m = map(int,input().split())
a = [int(_) for _ in input().split()]
b = [0]*m
c = [0]*m

for i in range(m):
    b[i],c[i] = map(int,input().split())

a.sort()

d = [[b[i],c[i]] for i in range(m)]

d.sort(key = lambda t:-t[1])

l = []
cnt = 0
for i in range(m):
    if cnt >= n:
        break
    for  j in range(d[i][0]):
        l.append(d[i][1])
        cnt += 1
        if cnt >= n:
            break
l.extend([0]*(n))

ans = 0
for i in range(n):
    ans += max(l[i],a[i])
print(ans)

Measured memory_bytes: 30328
#include<cstdio>
#define pritnf printf
#define scnaf scanf
#define retrun return
#define sizoef sizeof
#define inl inline
#define br break
#define con continue
#define mst(a,b) memset(a,b,sizeof(a))
#define fora(x,a,b) for(re nti (x)=(a);(x)<=(b);++(x))
#define forb(x,a,b) for(re nit (x)=(a);(x)>=(b);--(x))
#define foral(x,a,b) for(re ll (x)=(a);(x)<=(b);++(x))
#define forbl(x,a,b) for(re ll (x)=(a);(x)>=(b);--(x))
#define re register
#define stt struct
#define infa (0x3f3f3f3f)
#define infb (0x7fffffff)
#define infd (0x7f)
#define abss(x) ((x)>(0)?(x):(-1)*(x))
#define maxx(a,b) ((a)>(b)?(a):(b))
#define minn(a,b) ((a)<(b)?(a):(b))
#define in(a) freopen("D:/""/in"a".in","r",stdin)
#define out(a) freopen("D:/""/out"a".out","w",stdout)
typedef long long ll;
typedef int itn,nti,tin,tni,nit;
using namespace std;
const nit maxa=104;
const nit maxb=1e2;
const nit maxc=5;
#include<iostream>

string x;
nit s;

tni main()
{
    cin>>x;
    s=x.size();
    for(re nit i=0;i<s;i=i+2)
    {
        pritnf("%c",x[i]);
    }
    pritnf("\n");
    //
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
//cout << fixed << setprecision(8) << a << endl;
#define Fast_Input ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define pb push_back
#define mem(a, b)     memset(a, b, sizeof(a))
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
/*sort(v.begin(), v.end(),
     [](const pair<int, int>& x, const pair<int, int>& y)
{
    if (x.first != y.first)
        return x.first < y.first;
    return x.second < y.second;
});
*/
int const fx[]= {+1,+0,-1,+1};
int const fy[]= {-1,+1,+0,+0};
const int inf = numeric_limits<int>::max();
const ll mx=1e5;
const ll mod=1e9+7;
vector<int>v[mx+2];
int vis[mx+5],cost[mx+5];
void BFS(int x)
{
    int i;
    queue<int>q;
    q.push(x);
    vis[x]=1;
    cost[x]=0;
    while(!q.empty())
    {
        x=q.front();
        q.pop();
        for(i=0;i<v[x].size();i++)
        {
            if(!vis[v[x][i]])
            {
                q.push(v[x][i]);
                vis[v[x][i]]=1;
                cost[v[x][i]]=cost[x]+1;
            }
        }
    }
}
int main()
{
    int n,m,i,x,y,c=0;
    cin >> n >> m;
    while(m--)
    {
        cin >> x >> y;
        v[x].pb(y);
        v[y].pb(x);
    }
    BFS(1);
    for(i=1;i<=n;i++)
    {
        if(!vis[i])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    int j;
    for(i=2;i<=n;i++)
    {
        int mini=cost[i],ans;
        for(j=0;j<v[i].size();j++)
        {
            if(cost[v[i][j]]<mini)
            {
                mini=cost[v[i][j]];
                ans=v[i][j];
            }
        }
        cout << ans << endl;
    }
    return 0;
}




Measured memory_bytes: 10860
#include <iostream>
#include <queue>
#include <algorithm>
#include <string>
#include <utility>
#include <vector>
#include <map>
#include <stack>
#include <iomanip>
#include <set>
#include <sstream>
#include <cmath>
#include <deque>
#include <list>
#include <bitset>
using namespace  std;
typedef pair<long long , long long> P;
typedef long long ll;
typedef long long lint;
#define REP(i, n) for(long long (i)=0; (i)<(n); ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define FST first
#define SND second

signed main(){
    lint a,b;
    cin >>a>>b;
    if(a<=5) cout << 0 <<endl;
    else if(a<=12) cout << b/2 << endl;
    else cout << b << endl;
return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <numeric>

int main(int argc, char const *argv[]) {

  int K;
  scanf("%d", &K);

  int sum = 0;
  for (int i = 1; i <= K; i++) {
    for (int j = 1; j <= K; j++) {
      for (int k = 1; k <= K; k++) {
        sum += std::gcd(std::gcd(i, j), k);
      }
    }
  }

  std::cout << sum << '\n';

  return 0;
}

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

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

  // int型の2次元配列(3×4要素の)の宣言
  vector<string> data(2);
  
  for (int i = 0; i < 2; i++) {
    cin >> data.at(i);
  }
  
    for (int j = 0; j < N; j++) {
      cout << data.at(0).at(j) << data.at(1).at(j);
    }

}


Measured memory_bytes: 256
n=1299709
p=[1]*(n+1)
p[0],p[1]=0,0
for i in range(2,int(n**0.5)+1):
    if p[i]:        
        for j in range(i*i,n+1,i):
            p[j]=0
#p=[i for i in range(n+1) if p[i]==1]
while 1:
    n=int(input())
    if n==0:break
    if p[n]:
        print(0)
        continue
    i=n
    while p[i] is 0:i-=1
    j=i+1
    while p[j] is 0:j+=1
    print(j-i)

Measured memory_bytes: 17360
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    int t;
    cin >> s;
    t = s.size();
    for( int i = 0; i < t; i++){
        if(s[i] == '1') s[i] = '9';
        else if(s[i] == '9') s[i] = '1';
    }
    cout << s << endl;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,b) for(int i=0; i<int(b);i++)
#define eb emplace_back

typedef int Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src_, int dst_, Weight weight_) :
        src(src_), dst(dst_), weight(weight_) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
        e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

int const MAX_V = 100000;
void stronglyConnectedComponents(Graph const & g, int cmp[MAX_V]){
    int n = g.size();
    Graph rg(n);
    rep(i,n) for(auto & e : g[i]) rg[e.dst].eb(e.dst, e.src, e.weight);
    int cnt = 0;
    static int lavel[MAX_V], used[MAX_V], ord[MAX_V], S[MAX_V];
    rep(i,n) lavel[i] = used[i] = cmp[i] = 0;
    int sz = 0;
    rep(i,n){
        if(used[i]) continue;
        int s = 0;
        S[s++] = i;
        while(s){
            int v = S[s-1];
            used[v] = true;
            bool pushed = false;
            for(auto & e : g[v]){
                int dst = e.dst;
                if(!used[dst]){
                    S[s++] = dst;
                    pushed = true;
                }
            }
            if(!pushed){
                int t = S[s-1];
                if(!lavel[t]){
                    lavel[t] = cnt++;
                    ord[sz++] = t;
                }
                s--;
            }
        }
    }
    rep(i,n) used[i] = 0;
    int k = 0;
    rep(i,n){
        int u = ord[n-i-1];
        if(used[u]) continue;
        int s = 0;
        S[s++] = u;
        while(s){
            int v = S[--s];
            used[v] = true;
            cmp[v] = k;
            for(auto & e : rg[v]){
                int d = e.dst;
                if(!used[d]) S[s++] = d;
            }
        }
        k++;
    }
}

int main(){
    int n,m;
    scanf("%d%d", &n,&m);
    Graph g(n);
    rep(i,m){
        int a,b;
        scanf("%d%d", &a,&b);
        g[a].eb(a,b,0);
    }
    int c[MAX_V];
    stronglyConnectedComponents(g,c);
    int q; cin >> q;
    rep(i,q){
        int a,b;
        scanf("%d%d", &a,&b);
        printf("%d\n", c[a]==c[b]);
    }
}

Measured memory_bytes: 2412
n = int(input())
w = list(map(int, input().split()))

min_val = 100 * 100
total_val = sum(w)
for t, _ in enumerate(w):
    tmp = abs(total_val - 2 * sum(w[:t+1]))
    if min_val > tmp:
        min_val = tmp
print(min_val)

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> S(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> S.at(i).at(j);
    }
  }
  vector<vector<int>> L(H, vector<int>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (S.at(i).at(j) == '#') L.at(i).at(j) = 0;
      else {
        if (j == 0) L.at(i).at(j) = 1;
        else L.at(i).at(j) = L.at(i).at(j - 1) + 1;
      }
    }
  }
  vector<vector<int>> R(H, vector<int>(W));
  for (int i = 0; i < H; i++) {
    for (int j = W - 1; j >= 0; j--) {
      if (S.at(i).at(j) == '#') R.at(i).at(j) = 0;
      else {
        if (j == W - 1) R.at(i).at(j) = 1;
        else R.at(i).at(j) = R.at(i).at(j + 1) + 1;
      }
    }
  }
  vector<vector<int>> D(H, vector<int>(W));
  for (int j = 0; j < W; j++) {
    for (int i = H - 1; i >= 0; i--) {
      if (S.at(i).at(j) == '#') D.at(i).at(j) = 0;
      else {
        if (i == H - 1) D.at(i).at(j) = 1;
        else D.at(i).at(j) = D.at(i + 1).at(j) + 1;
      }
    }
  }
  vector<vector<int>> U(H, vector<int>(W));
  for (int j = 0; j < W; j++) {
    for (int i = 0; i < H; i++) {
      if (S.at(i).at(j) == '#') U.at(i).at(j) = 0;
      else {
        if (i == 0) U.at(i).at(j) = 1;
        else U.at(i).at(j) = U.at(i - 1).at(j) + 1;
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      int x = L.at(i).at(j) + R.at(i).at(j) + D.at(i).at(j) + U.at(i).at(j) - 3;
      if (S.at(i).at(j) == '.') ans = max(ans, x);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 70056
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll gcd(ll a, ll b);
ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int main(void){
  
  int a[3][3], memo[3][3] = {};
  for (int i = 0; i < 3; i++){
    for (int j = 0; j < 3; j++){
      cin >> a[i][j];
    }
  }
  int n;
  cin >> n;
  int b;
  for (int k = 0; k < n; k++){
    cin >> b;
    for (int i = 0; i < 3; i++){
      for (int j = 0; j < 3; j++){
        if (b == a[i][j])
          memo[i][j] = 1;
      }
    }
  }

  int ok = 0;
  for (int i = 0; i < 3; i++){
    if (memo[i][0] * memo[i][1] * memo[i][2] > 0)
      ok = 1;
  }
  for (int i = 0; i < 3; i++){
    if (memo[0][i] * memo[1][i] * memo[2][i] > 0)
      ok = 1;
  }
  if (memo[0][0] * memo[1][1] * memo[2][2] > 0)
    ok = 1;
  if (memo[2][0] * memo[1][1] * memo[0][2] > 0)
    ok = 1;


  if (ok)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
 


  return 0;
}

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

ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <sstream>


using namespace std;
int main()
{
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	cout << a / b << " " << a%b << " " << setprecision(5) << fixed << (double)a / (double)b << endl;
	return 0;
}

Measured memory_bytes: 3268
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int n, a, b;
vector<long> h;

bool enough(int ii) {

	long long an = 0;
	for (int i = 0; i < n; i++) {
		if (h[i] > b * ii) an += (h[i] - b * ii - 1) / (a - b) + 1;
	}
	return an <= ii;
}

int main() {
	
	cin >> n >> a >> b;
	long max = 0;
	for (int i = 0; i < n; i++) {
		long hoge; cin >> hoge;
		h.push_back(hoge);
		if (max < hoge) max = hoge;
	}

	int r = 0, l = (max - 1) / b + 1;
	while (r != l) {
		int mid = (r + l) / 2;
		bool e = enough(mid);
		if (e) l = mid;
		else r = mid + 1;
	}
	
	cout << r << endl;

	return 0;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  
  int board[H + 2][W + 2] = {0};
  int i,j;
  
  for (i = 1; i < H + 1; i++){
  	for(j = 1; j < W + 1; j++){
      char ch;
      cin >> ch;
      if (ch == '#'){
        // 周辺8タイルを+1する
        board[i - 1][j] += 1;
        board[i - 1][j - 1] += 1;
        board[i - 1][j + 1] += 1;
        board[i][j - 1] += 1;
        board[i][j + 1] += 1;
        board[i + 1][j] += 1;
        board[i + 1][j - 1] += 1;
        board[i + 1][j + 1] += 1;
        board[i][j] = 100;
      }     
    }
  }
  // output
  for (i = 1; i < H + 1; i++){
    for (j = 1; j < W + 1; j++){
      if (board[i][j] >= 100)
        cout << '#';
      else
        cout << board[i][j];
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    string str;
    cin>>str;
    if(str=="Sunny")
    {
        cout<<"Cloudy"<<endl;
    }
    else if(str=="Cloudy")
    {
        cout<<"Rainy"<<endl;
    }
    else if(str=="Rainy")
    {
        cout<<"Sunny"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256