akhauriyash/Code-Regression huggingface dataset:
import sys

N = int(input())

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

diff = sys.maxsize

for t in range(N-1):
    s1 = 0
    s2 = 0
    for i in range(t+1):
        s1 += W[i]
    for i in range(t+1, N):
        s2 += W[i]
    
    if abs(s1-s2) < diff:
        diff = abs(s1-s2)
        
print(diff)

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

// DAME:

// TIPS: stack処理

/*
    かっこ列の整合性
    - stackを使用
    - 左かっこがきたらstackに追加
    - 右かっこがきた時に、stackが空だったら[不整合エラー検出]で、空でなかったらstackにある左かっこと
    今ある右かっことをペアにしてstackからpopする
*/
int main() {
    int n;
    string s;
    cin >> n >> s;
    int need_left = 0;
    int pointer = 0;
    
    for(int i=0; i<s.size(); i++){
        if(s[i] == '('){
            ++pointer;
        }else{
            if(pointer == 0){
                ++need_left;
            }else{
                --pointer;
            }
        }
    }

    int need_right = pointer;

    string res = "";
    for(int i=0; i<need_left; i++){
        res += '(';
    }
    res += s;

    for(int i=0; i<need_right; i++){
        res+=')';
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
import math
from statistics import mean
for e in sys.stdin:
    n = int(e)
    if n == 0:
        break
    s = [0]*n
    s = list(map(int,sys.stdin.readline().split()))
    m = mean(s)
    Val = 0
    for i in range(n):
        Val += (s[i]-m)**2/float(n)
    sigma = math.sqrt(Val)
    print(str(sigma))


Measured memory_bytes: 7072
#include <iostream>
typedef long long ll;
using namespace std;

int main() {
    string s;
    cin>>s;
    int ans = 700;
    if(s[0]=='o') ans+=100;
    if(s[1]=='o') ans+=100;
    if(s[2]=='o') ans+=100;
    cout<<ans;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll h, w;

    cin >> h >> w;

    if (h == 1 || w == 1)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << (h * w + 1) / 2 << endl;
    }
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 205;
int h, w;
char ans[N][N];
int main() {
    cin >> h >> w;
    for (int i = 1; i <= h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> ans[i][j];
        }
    }
    for (int i = h * 2; i > 0; --i) {
        for (int j = 0; j < w; ++j) {
            ans[i][j] = ans[(i + 1) / 2][j];
        }
    }
    for (int i = 1; i <= h * 2; ++i) {
        for (int j = 0; j < w; ++j) {
            cout << ans[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main()
{
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int X, Y, Z, K; cin >> X >> Y >> Z >> K;
    vector<Int> A(X), B(Y), C(Z);
    for (auto& a : A) cin >> a;
    for (auto& b : B) cin >> b;
    for (auto& c : C) cin >> c;
    sort(rbegin(A), rend(A));
    sort(rbegin(B), rend(B));
    sort(rbegin(C), rend(C));
    using T = tuple<Int, int, int, int>;
    priority_queue<T> Q;
    set<T> S;
    T t(A[0] + B[0] + C[0], 0, 0, 0);
    Q.push(t), S.insert(t);
    for (int cnt = 0; cnt < K; cnt++) {
        Int sum, i, j, k; tie(sum, i, j, k) = Q.top();
        Q.pop();
        cout << sum << '\n';
        if (i+1 < X) {
            T t(A[i+1] + B[j] + C[k], i+1, j, k);
            if (!S.count(t)) Q.push(t), S.insert(t);
        }
        if (j+1 < Y) {
            T t(A[i] + B[j+1] + C[k], i, j+1, k);
            if (!S.count(t)) Q.push(t), S.insert(t);
        }
        if (k+1 < Z) {
            T t(A[i] + B[j] + C[k+1], i, j, k+1);
            if (!S.count(t)) Q.push(t), S.insert(t);
        }
    }
    return 0;
}

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

int main(){
  int n;
  cin>>n;
  int t[n],sum=0;
  for(int i=0;i<n;i++){
    cin>>t[i];
    sum+=t[i];
  }
  int m;
  cin>>m;
  int p[m],x[m];
  for(int i=0;i<m;i++){
    cin>>p[i]>>x[i];
  }
  for(int i=0;i<m;i++){
    cout<<sum-t[(p[i]-1)]+x[i]<<endl;
  }

  
  return 0;

}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S):
    return S.count('ABC')


def main():
    read_int()
    S = read_str()
    print(slv(S))


if __name__ == '__main__':
    main()


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

double calc(double x1, double y1, double x2, double y2){
    return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S; cin >> S;
    string key = "keyence";
    rep(i, 7){
        string l = key.substr(0, i);
        string r = key.substr(i);
        string judL = S.substr(0, i);
        string judR = S.substr(S.length()-7+i);
        if(judL == l && judR == r){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int ttt = sc.nextInt();
        int[] c = new int[n];
        int[] t = new int[n];
        for(int i = 0 ; i < n ; i++){
            c[i] = sc.nextInt();
            t[i] = sc.nextInt();
            if(t[i] > ttt){
                c[i] = 2020;
            }
        }
        Arrays.sort(c);
        if(c[0] == 2020){
            System.out.println("TLE");
        }else{
            System.out.println(c[0]);
        }
    }
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    vector<int> ans(n);
    rep (j, 2) {
      int cnt = 0;
      rep (i, n) {
        if (s[i] == 'R') {
          cnt++;
        } else {
          ans[i] += cnt / 2;
          ans[i - 1] +=  (cnt + 1) / 2;
          cnt = 0;
        }
      }
      reverse(ans.begin(), ans.end());
      reverse(s.begin(), s.end());
      rep (i, n) {
        if (s[i] == 'R') {
          s[i] = 'L';
        } else {
          s[i] = 'R';
        }
      }
    }
    rep (i, n) {
      if (i == n - 1) {
        cout << ans[i] << endl;
      } else {
        cout << ans[i] << " ";
      }
    }

    return 0;
}


Measured memory_bytes: 1104
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int N;
long long h[100010];
long long dp[100010];

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  ll sum = 0;
  rep(i,N+100)
  {
    sum += i;
    if(sum>=N)
    {
      cout << i << endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>

int main()
{
    std::string s;
    std::cin >> s;

    std::reverse(begin(s), end(s));

    const int mod = 1000000007;

    long long reminds[13] = { 1 };

    int position = 1;

    for (auto num : s) {
        long long new_reminds[13] = { 0 };
        if (num == '?') {
            for (int i = 0; i < 10; i++) {
                for (int k = 0; k < 13; k++) {
                    new_reminds[(i * position + k) % 13] += reminds[k];
                    new_reminds[(i * position + k) % 13] %= mod;
                }
            }
        } else {
            int i = num - '0';
            for (int k = 0; k < 13; k++) {
                new_reminds[(i * position + k) % 13] += reminds[k];
                new_reminds[(i * position + k) % 13] %= mod;
            }
        }

        std::copy(std::begin(new_reminds), std::end(new_reminds), reminds);
        position *= 10;
        position %= 13;
    }
    std::cout << reminds[5] << std::endl;

    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll  long long
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define pb push_back
#define Max(x,y,z) max(x,max(y,z))
#define f first
#define s second
#define lbd lower_bound
#define sz(x)       (ll)x.size()
#define pi 3.1415926536
#define mod 1000000007
using namespace std;
vector<ll> v;
ll find_divisors(ll a)
{
    ll b=sqrt(a);
    for(ll i=1;i<=b;i++)
    {   if(a%i==0)
    {
        if(a/i==i)
            v.pb(i);
        else
        {
            v.pb(i);
            v.pb(a/i);
        }
    }
    }
}
void solve()
{
    ll n,m,k,x,y,res=0,l,cnt=0,sum=0,z,sum1=0,cnt1=0,h,res1,cnt2=0;
   cin>>n;
   set<ll> s1;
   find_divisors(n);
   m=sz(v);
   rep(i,0,m)
   {    //cout<<v[i]<<" ";
       x=v[i]-1;
       if(x>0){
        if(n%x==(n/x))
        s1.insert(x);}
   }
   x=s1.size();
   for(auto i:s1)
       cnt+=i;
       cout<<cnt;

}
int main()
{   speed_up
    ll t;
   // cin>>t;
    t=1;
    while(t--)
        solve();
}


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

int main() {
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;
  if (s == u) {
    a--;
  } else {
    b--;
  }
  cout << a << " " << b << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
int main() {
	string s, t;
	cin >> s >> t;
	int n = s.size(), m = t.size();
	int co = 0, ans = 10000000;
	bool ans1 = false;
	for (int i = 0; i <= n - m; i++) {
		for (int j = 0; j < m; j++) {
			if (s[i + j] == t[j] ) {
				co++;
			}
			else if (s[i + j] == '?') {
				co++;
				ans1 = true;
			}
			else {
				break;
			}
		}
		if (co == m) {
			ans = i;
			if (ans1 == false) {
				break;
			}
		}
		co = 0;
	}
	if (ans == 10000000) {
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	else {
		for (int k = 0; k < ans; k++) {
			if (s[k] == '?') {
				cout << 'a';
			}
			else {
				cout << s[k];
			}
		}
	}
	cout << t;
	for (int l = ans+m; l < n; l++) {
		if (s[l] == '?') {
			cout << 'a';
		}
		else {
			cout << s[l];
		}
	}
	cout << endl;
	return 0;
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)

using namespace std;
using ll = long long;

int main(){
    int n, q; 
    ll k;
    cin >> n >> k >> q;
    vector<int> a(n, k);
    for (int i = 0; i < q; i++)
    {
        int tmp; cin >> tmp;
        a[tmp-1]++;
    }
    for (int i = 0; i < n; i++)
    {
        if(a[i]-q > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = [0] + list(map(int,input().split())) + [0]
c = []
total = 0
for i in range(n+1):
    tmp = abs(a[i+1] - a[i])
    c.append(tmp)
    total += tmp
    
for i in range(1,n+1):
    ans = total - c[i-1] - c[i] + abs(a[i+1] - a[i-1])
    print(ans)

Measured memory_bytes: 20552
#include <bits/stdc++.h>
using namespace std;
#define fr first
#define sc second
#define int long long
#define pb push_back
#define OK puts("OK");
#define sz(s) (int)s.size()
#define pii pair<int,int>
#define all(s) s.begin(), s.end()
#define allr(s) s.rbegin(), s.rend()
#define rep(i,n) for (i=0;i<(n);++i)
#define rep1(i,n) for (i=1;i<=(n);++i)
#define ret return
#define flag bool f=1;
#define scan1(a) scanf("%lld",&(a));
#define scan2(a,b) scanf("%lld %lld",&(a),&(b));
#define scan3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c));
#define nemeshay ios::sync_with_stdio(0),cin.tie(0);
const int INF = 1e12+7,N = (1<<20);
int q[N];
int rec(int l,int r,int x,int y){
    if (l > r)ret 0;

    int mn = INF,i;
    for (i=l;i<=r;++i){
        mn = min(mn , rec(l,i-1,x,x+y) + q[i] * (x+y) + rec(i+1,r,x+y,y));
    }
    ret mn;

}

main(){
    int n,i,j;
    cin>>n;
    rep(i,n){
        cin>>q[i];
    }
    n-=2;


    cout <<q[0] + q[n+1] + rec(1,n,1,1);



}








Measured memory_bytes: 256
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        abcd: String,
    }

    let vch: Vec<i16> = abcd.chars().map(|c| c.to_digit(10).unwrap() as i16).collect();
    let vb = vec![vch[1], -vch[1]];
    let vc = vec![vch[2], -vch[2]];
    let vd = vec![vch[3], -vch[3]];
    for b in &vb {
        for c in &vc {
            for d in &vd {
                if vch[0] + b + c + d == 7 {
                    println!("{}{:+}{:+}{:+}=7", vch[0], b, c, d);
                    return;
                }
            }
        }
    }
}


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

#define pb push_back
#define f first 
#define s second
#define ll long long
#define FOR(a, s) for(int a = 0; a<s; a++)
#define sz(s) (int)s.size()
ll n, m, q;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
	
	string s;
	cin >> s;
	n = sz(s);
	int ans = 0;
	FOR(i, n)
		ans += (s[i]!=s[n-1-i]);
	cout << ans/2 << '\n';
}

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

int main(){
  int K, A, B;
  cin >> K >> A >> B;
  bool judge = false;
  for(int i = A; i <= B; i++){
    if(i % K == 0) judge = true;
  }
  if(judge) cout << "OK" << endl;
  else cout << "NG" << endl;
}

Measured memory_bytes: 3636
#!/usr/bin/env python3
S = input()
Q = int(input())

count = True
ans = S

ireru_mae = ''
ireru_usiro = ''
for i in range(Q):
    T = input().split()
    if len(T)==1:
        count = not(count)
        continue

    if count:
        if T[1] == '1': ireru_mae = T[2] + ireru_mae
        else: ireru_usiro += T[2]
    else:
        if T[1] == '1': ireru_usiro += T[2]
        else: ireru_mae = T[2] + ireru_mae

ans = ireru_mae + ans + ireru_usiro
if count:
    print(ans)
else:
    print(ans[::-1])


Measured memory_bytes: 4628
import java.util.Scanner;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final String s = scanner.next();
        final int length = s.length();

        int count = 0;
        for (int i = 0; i < (length + 1) / 2; i++) {
            if (s.charAt(i) == 'p') {
                count--;
            }
        }
        for (int i = (length + 1) / 2; i < length; i++) {
            if (s.charAt(i) == 'g') {
                count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 24148
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <functional>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define MAX(a, b) ((a)>(b)?(a):(b))
#define MIN(a, b) ((a)<(b)?(a):(b))
#define SWAP(a, b) ((a)!=(b)?(a)^=(b)^=(a)^=(b):(a)=(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

using namespace std;

typedef long long ll;

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

ll lcm(ll a, ll b){
  ll value = gcd(a, b);
  return a/value * b;
}

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

  ll ans = 1;
  REP(i, n){
    ll t;
    cin >> t;

    if(ans < t) SWAP(ans, t);
    ans = lcm(ans, t);
  }

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <cstdio>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define int long long
using namespace std;

signed main() {
    int n, k;
    cin >> n >> k;
    if (n % k == 0) {
        cout << 0 << endl;
    } else {
        cout << 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
//133 C - Remainder Minimization 2019

#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
using namespace std;
typedef long long int int64;
typedef unsigned long long uint64;

int main(){
    uint64 l , r;
    cin >> l >> r;
    unsigned int min = 2019;
    bool f = false;
    for(uint64 i=l; i <r ; ++i){
        for(uint64 j=i+1 ; j<=r ;++j){
            if((i*j)%2019 == 0) { min = 0; f = true; break;}
            if((i*j)%2019 < min ) min = (i*j)%2019;
        }
        if(f) break;
    }
    cout << min << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

void OutputError(std::string s) {
  cerr << "\033[93m" << s << "\033[m" << endl;
  return;
}

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  if (a <= 0 && 0 <= b) {
    cout << "Zero" << endl;
  } else if (1 <= a) {
    cout << "Positive" << endl;
  } else if ((b - a + 1) % 2 == 0) {
    cout << "Positive" << endl;
  } else {
    cout << "Negative" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define vv(T) std::vector<std::vector<T>>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;

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

	vector<int> ans(n, -1);
	bool f = true;
	for (int i = 0; i < m; ++i)
	{
		int s, c;
		cin >> s >> c;
		--s;
		if (ans[s] == -1)
			ans[s] = c;
		else if (ans[s] != c)
			f = false;
	}
	if (!f)
		cout << -1 << endl;
	else if (n == 2 && ans[0] == 0)
		cout << -1 << endl;
	else if (n == 3 && ans[0] == 0)
		cout << -1 << endl;
	else
	{
		for (int i = 0; i < n; ++i)
		{
			if (ans[i] == -1 && i == 0)
				n == 1 ? ans[i] = 0 : ans[i] = 1;
			else if (ans[i] == -1)
				ans[i] = 0;
			cout << ans[i];
		}
		cout << endl;
	}
}



Measured memory_bytes: 3624
#pragma region Include
#include <bits/stdc++.h>
#pragma endregion

using namespace std;

#pragma region Macros
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define all(c) (c).begin(), (c).end()
#define newl "\n"
#define out(x) cout << (x) << newl
#define dump(x) \
  cout << "Line " << __LINE__ << " : " << #x << " = " << (x) << newl
template <class T>
using VV = vector<vector<T>>;
#define Uni(v) (v).erase(unique((v).begin(), (v).end()), (v).end());

template <typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
  os << "[";
  rep(i, vec.size()) os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  os << "]";
  return os;
}

template <typename T>
ostream& operator<<(ostream& os, vector<vector<T>>& mat) {
  os << "[";
  rep(i, mat.size()) os << mat[i] << (i + 1 == mat.size() ? "" : ",\n ");
  os << "]";
  return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x;
  return is;
}

template <typename V, typename H>
void resize(vector<V>& vec, const H head) {
  vec.resize(head);
}

template <typename V, typename H, typename... T>
void resize(vector<V>& vec, const H& head, const T... tail) {
  vec.resize(head);
  for (auto& v : vec) resize(v, tail...);
}
constexpr double EPS = 1e-10;
const int INF = 0x3f3f3f3f;

string tostring(int i, int digit) {
  auto cur = cout.flags();
  stringstream ss;
  ss << setw(digit) << setfill('0') << i;
  string ret = ss.str();
  cout.flags(cur);
  return ret;
}

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

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

#pragma endregion

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N, M, X;
  cin >> N >> M >> X;
  vector<ll> C(N);
  vector<vector<ll>> A(N, vector<ll>(M));
  rep(i, N) {
    cin >> C[i];
    cin >> A[i];
  }

  bool possible = false;
  ll mincost = INF;
  int S = pow(2, N);
  for (ll i = 0; i < S; ++i) {
    vector<ll> sum(M);
    ll cost = 0;
    rep(j, N) {
      ll d = i >> j & 1;
      //cout << i << "," << d << endl;
      if (d == 1) {
        rep(k, M) { sum[k] += A[j][k]; }
        cost += C[j];
      }
    }
    //dump(sum);
    //dump(cost);
    bool flag = true;
    rep(j, M) {
      if (sum[j] < X) {
        flag = false;
        break;
      }
    }
    if (flag) {
      possible = true;
      mincost = min(mincost, cost);
    }
  }

  if (possible) {
    out(mincost);
  } else {
    out(-1);
  }
  return 0;
}

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

int main()
{
  int s[2][4];
  for (int i = 0; i < 2; i++){
    for (int j = 0; j < 4; j++){
      cin >> s[i][j];
      if (j != 0) s[i][j] += s[i][j - 1];
    }
  }

  cout << max(s[0][3], s[1][3]) << endl;

  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    long long INF = 1LL << 60;
    int N,K;
    cin >> N >> K;
    vector<int> h(N);
    vector<long long> dp(N+K,INF);

    for(int i = 0;i < N;i++){
        cin >> h[i];
    }
    dp[0] = 0;
    for(int i = 0;i < N;i++){
        for(int j = 1;j <= K;j++){
            dp[i + j] = min(dp[i + j],dp[i] + abs(h[i + j] - h[i]));
        }
    }
    cout <<  dp[N - 1] << endl;

}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,D,X;
    cin >>N>>D>>X;
    
    ll sum=0;
    rep(i,N){
        ll a;
        cin>>a;
        sum += 1+(D-1)/a;
    }
    cout << sum+X << endl;


    return 0;
    

}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < 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 INF LLONG_MAX
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    string s;
    cin >> s;
    ll k; cin >> k;
    set<char> st(s.begin(), s.end());
    if (st.size() == 1 && *st.begin() == '1') {
        cout << 1 << endl;
        return 0;
    }
    ll inf_index = -1;
    REP(i, s.size()) {
        if (s[i] != '1') {
            if (k - 1 < i) {
                cout << 1 << endl;
            } else {
                cout << s[i] << endl;
            }
            return 0; 
        }
    }
    return 0;
}

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

int main(){
	int a[105], n, m, s = 0;
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		cin >> a[i];		
		s += a[i];
	}
	sort(a+1,a+1+n);
	bool f = true;
	for(int i = n; i > n - m; i--)
		if(a[i] * 4 * m < s) f = false;	
	if(f) cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]
x=[l[i][0] for i in range(n)]
x.sort()
y=[l[i][1] for i in range(n)]
y.sort()
ans=[]
for i1 in range(n):
  for i2 in range(i1,n):
    for i3 in range(n):
      for i4 in range(i3,n):
        ct=0
        for i5 in range(n):
          if min(x[i1],x[i2])<=l[i5][0]<=max(x[i1],x[i2]) and min(y[i3],y[i4])<=l[i5][1]<=max(y[i3],y[i4]):ct+=1
        if ct>=k:
          ans.append(abs(x[i1]-x[i2])*abs(y[i3]-y[i4]))
print(min(ans))

Measured memory_bytes: 116188
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	array := []string{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"}
	for i := 0; i < 7; i++ {
		if array[i] == s {
			fmt.Println(7-i)
		}
	}
}


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

typedef long long ll;
typedef long int lint;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n,d;
    cin >> n >> d;
    ll ans = 0;
    for(ll i = 0,x,y; i < n; i++)
    {
        cin >> x >> y;
        if(x*x + y*y <= d*d) ans++;
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>

#define ff first
#define ss second

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

int main()
{
    ios::sync_with_stdio(false);
	cin.tie(0);
    
    int n;
    cin>>n;
    string s;
    cin>>s;
    string t=s;
    sort(t.begin(),t.end());
    int answer=0;
    for(int i=0; i<n; i++) if(t[i]!=s[i]) answer+=1;
    cout<<answer/2;

    return 0;
}


Measured memory_bytes: 3872
import copy

N, M = map(int,input().split())
E = [list(map(int, input().split())) for _ in range(M)]



def dfs(flg, E, i):
	q = []
	for e in E:
		if e[0] == i:
			if flg[e[1]-1] == 0:
				q.append(e[1])
		if e[1] == i:
			if flg[e[0]-1] == 0:
				q.append(e[0])
	if len(q) == 0:
		if flg.count(0) == 0:
			return 1
		else:
			return 0

	ans = 0
	for n in q:
		temp = copy.deepcopy(flg)
		temp[n-1] = 1
		ans += dfs(temp, E, n)

	return ans

flg = [0 for _ in range(N)]
flg[0] = 1
print(dfs(flg, E, 1))

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

void A()
{
  // 入力
  string S;
  cin >> S;
  
  // 出力
  if( S == "ABC" ) cout << "ARC" << endl;
  else cout << "ABC" << endl;
}

void B()
{
  // 入力
  int N, K;
  cin >> N >> K;
  
  vector<int> d(K);
  vector<vector<int>> A;
  for( int i = 0; i < K; ++i ){
    cin >> d[i];
    
    vector<int> a(d[i]);
    for( int j = 0; j < d[i]; ++j ){
      cin >> a[j];
    }
    A.push_back(a);
  }
  
  // すぬけくんを用意する
  // true: いたずらされるすぬけくん
  // false: いたずらされないすぬけくん
  vector<bool> sunuke_kun(N);
  for( int i = 0; i < N; ++i ) sunuke_kun[i] = true;
  
  // お菓子を持っている場合、すぬけくんはいたずらされない
  for( int i = 0; i < K; ++i )
    for( int j = 0; j < d[i]; ++j )
      sunuke_kun[A[i][j]-1] = false;
  
  // いたずらされないすぬけくんの人数を数える
  int ans = 0;
  for( auto i : sunuke_kun )
    if( i ) ++ans;
  
  // 出力
  cout << ans << endl;
}

void C()
{
  // 入力
  int N, M;
  cin >> N >> M;
  
  vector<int> H(N);
  for( int i = 0; i < N; ++i )
    cin >> H[i];
  
  vector<int> A(M), B(M);
  for( int i = 0; i < M; ++i )
    cin >> A[i] >> B[i];
  
  // 展望台を用意する
  // true: 良い展望台
  // false: 良くない展望台
  vector<bool> observatory(N);
  for( int i = 0; i < N; ++i )
    observatory[i] = true;
  
  // 各展望台が良い展望台か確認する
  // 同じ高さの場合については問題文に記載なし
  // 入力例2と合うようにする
  for( int i = 0; i < M; ++i )
    if( H[A[i]-1] == H[B[i]-1] ){
      observatory[A[i]-1] = false;
      observatory[B[i]-1] = false;
    } else if( H[A[i]-1] < H[B[i]-1] ){
      observatory[A[i]-1] = false;
    } else {
      observatory[B[i]-1] = false;
    }
  
  // 良い展望台の数を数える
  int ans = 0;
  for( auto i : observatory )
    if( i ) ++ans;
  
  // 出力
  cout << ans << endl;
}

int main()
{
  //A();
  //B();
  C();
  
  return 0;
}

Measured memory_bytes: 4576
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,ans=0;
	cin>>n;
	vl v(n);
	rep(i,n)cin>>v[i];
	vl cnt(100,0);
	rep(i,n){
		int j=0;
		ll tmp=v[i];
		while(tmp!=0ll){
			if(tmp&1ll)cnt[j]++;
			j++;
			tmp=tmp>>(1);
		}
	}
	rep(i,100){
		ll tmp=(((cnt[i]*(n-cnt[i]))%MOD)*((1ll<<i)%MOD))%MOD;
		ans+=tmp;
		ans%=MOD;
	}
	puta(ans);
}


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

int main() {
  string sb;
  cin >> sb;
  
  int bs = 0;
  int ws = 0;
  string sw = sb;
  for(int i = 0; i < sb.size(); ++i){
    if(i % 2){
      if(sb.at(i) == '0') bs++;
      if(sw.at(i) == '1') ws++;
    }
    else{
      if(sb.at(i) == '1') bs++;
      if(sw.at(i) == '0') ws++;
    }
  }
  
  cout << min(bs, ws) << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

signed main() {
	int h, w,n;
	cin >> h >> w >> n;
	vector<int> c(n);
	REP(i, n) {
		scanf("%d", &c[i]);
	}
	int cur = 0;
	vector<vector<int>> out(h, vector<int>(w));
	REP(i, h) {
		REP(j, w) {
			out[i][j] = cur + 1;
			c[cur]--;
			if (!c[cur])
				cur++;

		}
	}

	REP(i, h) {
		if (!(i%2)) {
			REP(j, w) {
				printf("%d", out[i][j]);
				if (j != w - 1)
					printf(" ");
			}
		}
		else {
			for(int j = w-1; 0<= j; j--) {
				printf("%d", out[i][j]);
				if (j != 0)
					printf(" ");
			}
		}

		printf("\n");
	}

	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long int
#define mx 1007
double arr[mx];

#define pi acos(-1)
using namespace std;


int main()
{
    ll n,item,temp;
    cin>>n;
    vector<ll>v;
    map<ll,ll>mp;
    ll sum=0;
    if(n>=400 && n<=599)
        cout<<8<<endl;
    else if(n>=600 && n<=799)
        cout<<7<<endl;

    else if(n>=800 && n<=999)
        cout<<6<<endl;
    else if(n>=1000 && n<=1199)
        cout<<5<<endl;
    else if(n>=1200 && n<=1399)
        cout<<4<<endl;
    else if(n>=1400 && n<=1599)
        cout<<3<<endl;
    else if(n>=1600 && n<=1799)
        cout<<2<<endl;
    else if(n>=1800 && n<=1999)
        cout<<1<<endl;



    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repp(i,a,b) for(ll i=a;i<=b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define endl "\n"
#define deb(x) cerr << #x << "=" << x << endl
#define debb(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define mod ((ll)1e9+7)
#define N ((ll)1e4)
#define pb push_back
#define in insert
#define F first
#define S second
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define PI 3.1415926535897932384626
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define speed ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define test ll t; cin>>t; while(t--)
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
ll dr[] = { -1, 1, 0, 0};
ll dc[] = {0, 0, 1, -1};

/*Functions*/
ll gcd(ll a, ll b);
ll exp(ll x, ll y, ll p);
ll exp(ll x, ll y);
void InverseofNumber();
void InverseofFactorial();
void factorial();
ll Binomial(ll n, ll R);


ll factorialNumInverse[N + 1];
ll naturalNumInverse[N + 1];
ll fact[N + 1];

void fileIO() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

int main() {
    clock_t start, end;
    start = clock();
    speed
    // InverseofNumber(),InverseofFactorial(),factorial();
    // fileIO();
    ll n; cin >> n;
    map<string, ll> mp;
    rep(i, 0, n) {
        string s; cin >> s;
        mp[s]++;
    }
    cout << "AC x " << mp["AC"] << endl;
    cout << "WA x " << mp["WA"] << endl;
    cout << "TLE x " << mp["TLE"] << endl;
    cout << "RE x " << mp["RE"] << endl;

    end = clock();
    double timeTaken = double(end - start) * 1000 / double(CLOCKS_PER_SEC);
    deb(timeTaken);

    return 0;
}



/*All Functions*/
ll gcd(ll a, ll b) {
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll exp(ll x, ll y, ll p) {
    ll res = 1;
    while (y) {
        if (y % 2)
            res = (res * x % p) % p;
        x = (x * x) % p;
        y /= 2;
    }
    return res;
}
ll exp(ll x, ll y) {
    ll res = 1;
    while (y) {
        if (y % 2)
            res = (res * x ) ;
        x = (x * x) ;
        y /= 2;
    }
    return res;
}
void InverseofNumber() {
    naturalNumInverse[0] = naturalNumInverse[1] = 1;
    for (ll i = 2; i <= N; i++)
        naturalNumInverse[i] = naturalNumInverse[mod % i] * (mod - mod / i) % mod;
}
void InverseofFactorial() {
    factorialNumInverse[0] = factorialNumInverse[1] = 1;
    for (ll i = 2; i <= N; i++)
        factorialNumInverse[i] = (naturalNumInverse[i] * factorialNumInverse[i - 1]) % mod;
}
void factorial() {
    fact[0] = 1;
    for (ll i = 1; i <= N; i++)
        fact[i] = (fact[i - 1] * i) % mod;
}
ll Binomial(ll n, ll R) {
    ll ans = ((fact[n] * factorialNumInverse[R]) % mod * (factorialNumInverse[n - R]) % mod) % mod;
    return ans;
}

Measured memory_bytes: 3852
#include<iostream>
#include<algorithm>
int ride2(int n){return n*n;}
using namespace std;
int main(){
    int a[3],n;
    cin>>n;
    while(n--){
        for(int i=0;i<3;i++)cin>>a[i];
        sort(a,a+3);
        int judge=ride2(a[2])-ride2(a[0])-ride2(a[1]);
        if(!judge)
            cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }

    return 0;
}

Measured memory_bytes: 1172
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> bulb(N), count(N, 0);
    for (int i = 0; i < N; i++) {
        cin >> bulb[i];
    }
    count[0] = 1;
    for (int i = 1; i < N; i++) {
        if (bulb[i-1] != bulb[i]) {
            count[i] = count[i-1] + 1;
        } else {
            count[i] = 1;
        }
    }
    auto solve = [=](){
        vector<int> v;
        int mx = 1;
        for (int i = N-1; i >= 0; i--) {
            mx = max(mx, count[i]);
            if (count[i] == 1) {
                v.push_back(mx);
                mx = 1;
            }
        }
        if (v.size() == 1) {
            return v[0];
        }
        
        int res = 0;
        for (size_t i = 0; i < v.size()-1; i++){
            res = max(res, v[i]+v[i+1]);
            if (i+2 < v.size()) {
                res = max(res, v[i]+v[i+1]+v[i+2]);
            }            
        }
        return res;
    };

    cout << solve() << endl;    
    return 0;
}

Measured memory_bytes: 4348
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

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

typedef pair<int, int> pii;

int n, m;
vector<int> edge[5000];
int cnt[5000];

int main() {
	cin >> n >> m;
	
	REP(i, m) {
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		edge[a].push_back(b);
		cnt[b]++;
	}
	
	vector<int> ans;
	bool flag = false;
	vector<int> next;
	
	REP(i, n) if (cnt[i] == 0) next.push_back(i);
	
	REP(i, n) {
		int tar = next[next.size() - 1];
		ans.push_back(tar + 1);
		next.erase(next.end() - 1);
		
		if (next.size() > 0) flag = true;
		
		REP(j, edge[tar].size()) {
			int to = edge[tar][j];
			if (--cnt[to] == 0) next.push_back(to);
		}
	}
	
	REP(i, ans.size()) printf("%d\n", ans[i]);
	if (flag) puts("1");
	else puts("0");
	
	return 0;
}

Measured memory_bytes: 3960
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<utility>
#include<cstdio>
#include<set>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include <bitset>
using namespace std;
const int mod=1e9+7;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define rep2(i,x,n) for (int i= x;i<n;i++)
#define all(v) v.begin(), v.end()
#define nepe(v) next_permutation(all(v))
#define F first 
#define S second
#define PB push_back 
#define MP make_pair
using ll = long long;
using vi = vector<int>; 
using vvi = vector<vi>;
using vl=vector<long long>;
using vvl = vector<vl>;
using vp =vector<pair<int,int>>;

typedef pair<int,int> P;
string s;
int k;
ll INF = 1000000000000;

int main(){
    ll N,K;
    cin >>N>>K;
    vi A(N),dist(N,-1);
    rep(i,N) cin >>A[i];
    int s =1;
    dist[0]=0;
    int step=0;
    int fi,lp;
    while(true){
        s=A[s-1];
        step++;
        if(dist[s-1]==-1){
            dist[s-1]=step;
        }   
        else {
            lp = step-dist[s-1];
            fi =dist[s-1];
            break;
        }
    }
    int ans =1;
    if(fi>=K){
        rep(i,K){
            ans =A[ans-1];
        }
    }
    else{
        K = (K-fi)%lp;
        rep(i,fi+K){
            ans =A[ans-1];
        }
    }
    cout <<ans;
}

Measured memory_bytes: 4844
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
using namespace std;

int search(int n,int m,int& count){
    count++;
    if(n%m==0){
        return m;
    }
    return search(m,n%m,count);
}





int main(){
    while(1){
    int n,m;
    int count=0;
    cin>>n>>m;
        if(n==0 && m==0){break;}
    if(m>n){swap(n,m);}
    int ans=search(n,m,count);
    cout<<ans<<" "<<count<<endl;
    
    }
    
    return 0;
}


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

using namespace std;
using ll = long long;

int main() {
	ll a, b, c, d;

	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

	ll ans = a * c;
	ans = max(ans, a * d);
	ans = max(ans, b * c);
	ans = max(ans, b * d);

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


Measured memory_bytes: 3820
#include <stdio.h>
#include <string.h>
int main(){
  int i,j,n,len[100];
  char w[200][100];
  scanf("%d",&n );
  for(i=0;i<n;i++){
  scanf("%s",w[i]);
  len[i]=strlen(w[i]);
}

  for(i=0;i<n-1;i++){
    if(w[i][len[i]-1]!=w[i+1][0]){
    printf("No");
    return 0;
  }
  }
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      if(strcmp(w[i],w[j])==0){
      printf("No");
      return 0;
    }
    }
  }
  printf("Yes");

}


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

  public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int[] types = new int[8];
      int maxCnt = 0;
      for(int i = 0; i < n; i++) {
        int score = sc.nextInt();
        if(1 <= score && score < 400) {
          types[0] = 1;
        } else if(400 <= score && score < 800) {
          types[1] = 1;
        } else if(800 <= score && score < 1200) {
          types[2] = 1;
        } else if(1200 <= score && score < 1600) {
          types[3] = 1;
        } else if(1600 <= score && score < 2000) {
          types[4] = 1;
        } else if(2000 <= score && score < 2400) {
          types[5] = 1;
        } else if(2400 <= score && score < 2800) {
          types[6] = 1;
        } else if(2800 <= score && score < 3200) {
          types[7] = 1;
        } else {
          maxCnt++;
        }
      }
      int min = 0;
      int max = 0;
      for(int i = 0; i < types.length; i++) {
        if(types[i] > 0) {
          max++;
          min++;
        }
      }
      if(min == 0 && maxCnt > 0)
        min = 1;
      System.out.println(min + " " + (max + maxCnt));
  }

}


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

class Program
{
    static void Main(string[] args)
    {
        char[] S = Console.ReadLine().ToArray();

        int[,] mod = new int[13, 10];
        for (int i = 0; i < 13; i++)
            for (int j = 0; j < 10; j++)
                mod[i, j] = (10 * i + j) % 13;

        ulong[,] dp = new ulong[S.Length, 13];
        for (int i = 0; i < S.Length; i++)
        {
            if (i == 0)
            {
                if (S[0] == '?')
                    for (int j = 0; j < 10; j++)
                        dp[0, j] = 1;
                else
                    dp[0, S[0] - '0'] = 1;
            }
            else if (S[i] == '?')
            {
                for (int j = 0; j < 10; j++)
                    for (int k = 0; k < 13; k++)
                        dp[i, mod[k, j]] += dp[i - 1, k];
            }
            else
            {
                int j = S[i] - '0';
                for (int k = 0; k < 13; k++)
                    dp[i, mod[k, j]] += dp[i - 1, k];
            }
            for (int j = 0; j < 13; j++)
                dp[i, j] %= 1000000007;
        }

        Console.WriteLine(dp[dp.Length / 13 - 1, 5]);
    }
}

Measured memory_bytes: 22240
s = str(input())
K = int(input())
stack = []
for i in range(len(s)):
    for j in range(i+1, min(i+K, len(s))+1):
        sub = s[i:j]
        if sub not in stack:
            stack.append(sub)
stack.sort()
print(stack[K-1])

Measured memory_bytes: 3952
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
using namespace std;

int key=0;


int linearSearch(int A[], int n){
  int i=0;
  A[n]=key;
  while(A[i]!=key){
    i++;
  }
  if(i!=n)return 1;
  else return 0;
  //return i!=n;
}

int main(){
  int n=0,q=0;
  int S[100000];
  int T[100000];
  //int search[100000];
  int count=0;
  //int key=0;
  cin>>n;
  for(int i=0;i<n;i++)cin>>S[i];
  cin>>q;
  for(int i=0;i<q;i++)cin>>T[i];
  for(int i=0;i<q;i++){
    key=T[i];
    //cin>>key;
    if(linearSearch(S,n))count++;
  }
  cout<<count<<endl;
  return 0;
}



Measured memory_bytes: 3104
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
const int MN=1e5+5;
int n,m,tot;
int main(){
	scanf("%d%d",&m,&n);
	for(reg int i=1,x;i<=n;i++)
		scanf("%d",&x),tot+=x;
	puts(tot>=m?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int a[251];
int main(void) {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 1; i <= n; i++) {
		int parent = i / 2;
		int left = i * 2;
		int right = i * 2 + 1;
		cout << "node " << i << ": key = " << a[i]<<", ";
		if (parent) {
			cout  << "parent key = " << a[parent] << ", ";
		}
		if (left <= n) {
			cout  << "left key = " << a[left] << ", ";
		}
		if (right <= n) {
			cout << "right key = " << a[right] << ", ";
		}
		cout << endl;
	}
}


Measured memory_bytes: 3080