akhauriyash/Code-Regression huggingface dataset:
/*
 * a.cpp
 *
 *  Created on: 2019/06/08
 *      Author: MEIP-users
 */




#include <bits/stdc++.h>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <locale>
#include <queue>
#include <tuple>
#include <map>
#include <fstream>

using namespace std;


#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1e9+10)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))




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

	cout << s[0]<<s[1]<<s[2] << endl;
	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (ll i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(max(a*c,a*d),max(b*c,b*d)) << endl;
    return 0;
}


Measured memory_bytes: 3628
def main():
    n = int(input())
    if n % 10 in [2, 4, 5, 7, 9]:
        print("hon")
    elif n % 10 in [0, 1, 6, 8]:
        print("pon")
    else:
        print("bon")
    return

if __name__ == "__main__":
    main()

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

struct unionfind{
    vector<int> parent;
    vector<int> rank;
    vector<int> sizeb;
    vector<int> sizew;

    unionfind (int N) {
        parent = vector<int>(N);
        iota(parent.begin(), parent.end(), 0);
        rank = vector<int>(N, 0);
        sizeb = vector<int>(N, 0);
        sizew = vector<int>(N, 0);
        
    }
    int root(int x) {
        if (parent[x] == x) return x;
        parent[x] = root(parent[x]);
        return parent[x];
    }
    
    bool same(int x, int y){
        return root(x) == root(y);
    }
    
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if (x == y) return;
        if (rank[x] > rank[y]) {
            parent[y] = x;
            sizeb[x] += sizeb[y];
            sizew[x] += sizew[y];
        }
        else {
            parent[x] = y;
            sizeb[y] += sizeb[x];
            sizew[y] += sizew[x];
            if (rank[x] == rank[y]) rank[y] += 1;
        }
    }
};

int main(){
    int N;
    cin >> N;
    unionfind uf(200002);
    for (int i = 1; i <= 100000; i++) {
        uf.sizeb[i] = 1;
        uf.sizew[i+100000] = 1;
    }
    for (int i = 0; i < N; i++) {
        int x, y;
        cin >> x >> y;
        uf.unite(x, 100000+y);
    }
    ll ans = 0;
    for (int i = 1; i <= 200000; i++) {
        if (uf.root(i) == i) {
            ans += (ll)uf.sizeb[i] * uf.sizew[i];
        }
    }
    cout << ans-N << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pr pair<ll, ll>
#define vct vector<ll>
#define vpt vector<pr>
#define st set<ll>
#define pq priority_queue<ll>
#define mat vector<vector<ll> >
#define F(i, n) for (i = 0; i < n; i++)
#define Fr(i, n) for (i = n - 1; i >= 0; i--)
struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<long long, int, custom_hash>
void prv(vct v)
{
    for (ll i = 0; i < v.size(); i++)
        cout << v[i] << " ";
    cout << "\n";
}
ll poww(ll x, ll y, ll m)
{
    ll res = 1;
    while (y)
    {
        if (y % 2 == 0)
        {
            x = (x * x) % m;
            y = y / 2;
        }
        else
        {
            res = (res * x) % m;
            y--;
        }
    }
    return res;
}
void deb(string s, ll n)
{
    cout << s << " : " << n << "\n";
}
void prn(ll n) { cout << n << "\n"; }
void prs(string n) { cout << n << "\n"; }
ll cntd(ll n){
    ll an=0;
    while(n){
        an+=(n%10);
        n/=10;
    }
    return an;
}
mat mt;
void setmtsize(ll m,ll n, ll ini=0){
    mt.resize(m,vector<ll>(n,ini));
}
void prmt(mat m){
    for(ll i=0;i<m.size();i++)prv(m[i]);
}

ll n, k, m, l, r, x, y, ans=0;
ll t, t1, t2;

ll i, j;
// ll a, b;
ll mod = 1000000007;

void solve()
{
    cin>>n;
    string s;
    ll a1=0,a2=0,a3=0,a4=0;
    F(i,n){
        cin>>s;
        if(s=="AC")a1++;
        else if(s=="WA")a2++;
        else if(s=="TLE")a3++;
        else if(s=="RE")a4++;
    }
    cout<<"AC x "<<a1<<"\n";
    cout<<"WA x "<<a2<<"\n";
    cout<<"TLE x "<<a3<<"\n";
    cout<<"RE x "<<a4<<"\n";
    

}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll t = 1;
    // cin >> t;
    while (t--)
        solve();
    return 0;
}


Measured memory_bytes: 3664
str = gets.chomp
count=0

if /^k.*eyence$/ =~ str
    count += 1
elsif /^ke.*yence$/ =~ str
    count +=1
elsif /^key.*ence$/ =~ str
    count+=1
elsif /^keye.*nce$/ =~ str
    count += 1
elsif /^keyen.*ce$/ =~ str
    count += 1
elsif /^keyenc.*e$/ =~ str
    count += 1
end

if count == 1
    puts "YES"
else
    puts "NO"
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

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

  typedef pair<int, int> P;
  int N, K; cin >> N >> K;
  if(K > nCr(N-1, 2ll)){
    cout << -1 << endl;
    return 0;
  }
  int cnt = N-1, vers = nCr(N-1, 2ll);
  vector<P> vec;
  REP(i, N-1) vec.pb(P(1, i+2));
  for(int i = 2; i <= N; i++){
    bool OK = 0;
    for(int j = i+1; j <= N; j++){
      if(i == j) continue;
      if(vers == K){
        OK = 1; break;
      }
      vec.pb(P(i, j)); cnt++; vers--;
    }
    if(OK) break;
  }
  cout << cnt << endl;
  for(auto x : vec){
    cout << x.first << ' ' << x.second << endl;
  }
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,n) for(register int i=1;i<=n;i++)
using namespace std;
int n,k,a[100001],mmin=1000000,bj,ans=1000000,t1,t2,kk;
int main(){
  cin>>n>>k;
  rep(i,n){
  	scanf("%d",&a[i]);
  	if(a[i]<mmin){
  	  mmin=a[i];
	  bj=i;	
	}
  }
  kk=k-1;
  rep(i,k){
    t1=max(bj-i,0);
    t2=max(n-k-bj+i,0);
	if((t1%kk)!=0)
	  t1=t1/kk+1;
	else
	  t1=t1/kk;
	if((t2%kk)!=0)
	  t2=t2/kk+1;
	else
	  t2=t2/kk;
  	ans=min(ans,t1+t2);
  }
  cout<<ans+1;
  return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
using namespace std;
int a[200000], L[200000], R[200000];
int main() {
	//abc166_e
	int n;

	cin >> n;
	int i;
	for (i = 0; i < n; i++) {
		cin >> a[i];
		L[i] = i - a[i];
		R[i] = i + a[i];
	}
	//i > j
	//i - j = ai + aj
	//i - ai = j + aj
	int left, right, mid, upper, downer;
	sort(R, R + n);
	long long int counter = 0;
	for (i = 0; i < n; i++) {
		left = -1;
		right = n;
		while (right - left > 1) {
			mid = (left + right) / 2;

			if (L[i] > R[mid]) {
				left = mid;
			}
			else {
				right = mid;
			}
		}
		downer = left;
		left = -1;
		right = n;
		while (right - left > 1) {
			mid = (left + right) / 2;
			if (L[i] >= R[mid]) {
				left = mid;
			}
			else {
				right = mid;
			}
		}
		upper = right;
		counter = counter + upper - downer - 1;

	}
	cout << counter << endl;
	return 0;

}

Measured memory_bytes: 5992
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define pi (double) acos(-1)
using namespace std;

int main() {
    double a, b, x;
    cin >> a >> b >> x;
    cout << setprecision(15);
    if(x > (a*a*b)/2){
        double m = (2*x)/(a*a)-b;
        b-=m;
    }
    double d = (2*x)/(a*b);
    if(x > (a*a*b)/2)d = a;
    double c = sqrt(b*b+d*d);
    double angle = acos((c*c+d*d-b*b)/(2*d*c));
    angle = angle/ pi * (double)180;
    cout << angle;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	double r = sc.nextDouble();
	double pi = Math.PI;
	double area = pi*r*r;
	double length = 2*r*pi;
	System.out.printf("%f %f\n",area, length);
    }
}

Measured memory_bytes: 28228
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>

using namespace std;

int main(){
  long long int n,t,a;
  cin >> n;
  cin >> t >> a;
  for(int i=1;i<n;i++){
    int input_t,input_a;
    cin >> input_t >> input_a;
    if(t%input_t!=0) t+=input_t-t%input_t;
    if(a%input_a!=0) a+=input_a-a%input_a;
    if(t/input_t == a/input_a) continue;
    else{
      if((t/input_t) > (a/input_a))
        a=t/input_t*input_a;
      else
        t=a/input_a*input_t;
      }
  }
  cout << t+a << endl;
}


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

using namespace std;
typedef long long ll;

struct enemy {
  int pos, life;
  enemy(int p, int l): pos(p), life(l) {}

  bool operator <(const enemy &rhs) const {
    return pos < rhs.pos;
  }
};

int get_pos(vector<enemy> &enemies, int dist) {
  int left = 0, right = enemies.size();
  while (right - 1 > left) {
    int mid = (right + left) / 2;
    if (enemies[mid].pos <= dist) left = mid;
    else right = mid;
  }
  return left;
}

int main() {
  int n, d;
  ll a;
  cin >> n >> d >> a;

  vector<enemy> enemies;
  for (int i = 0; i < n; ++i) {
    int x, h;
    cin >> x >> h;
    enemies.push_back(enemy(x, h));
  }

  sort(enemies.begin(), enemies.end());
  vector<ll> sum(n, 0);
  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    if (i > 0) {
      sum[i] += sum[i - 1];
    }
    ll remain = enemies[i].life - sum[i];
    if (remain > 0) {
      int right = get_pos(enemies, enemies[i].pos + d + d);
      ll n_bomb = ceil((double)remain / a);
      sum[i] += n_bomb * a;
      if (right + 1 < n) {
	sum[right + 1] -= n_bomb * a;
      }
      ans += n_bomb;
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3440
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var S = Str;
		var s = new HashSet<char>("ATGC");
		for (var l = S.Length; l >= 0; l--)
		{
			for (var i = 0; i + l <= S.Length; i++)
			{
				var T = S.Substring(i, l);
				var t = new HashSet<char>(T);
				if (t.IsSubsetOf(s)) { WriteLine(l); return; }
			}
		}
	}
}


Measured memory_bytes: 13396
import sys
input = sys.stdin.readline

s = input().replace("\n","")

reverse_s = s[::-1]

s1len = int((len(s)/2))

s1 = s[:s1len]
reverse_s1 = s1[::-1]
# print(s1)

s2len = int((len(s)/2) + 1)
s2 = s[s2len:]
reverse_s2 = s2[::-1]
# print(s2)


if (s == reverse_s) and (s1 == reverse_s1) and (s2 == reverse_s2):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
const int maxN = 2005;
bool can[maxN][maxN];
int n;
int a[maxN];
typedef bitset < maxN > bs;
bs bad[maxN];
bool used[maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
//    freopen("input.txt", "r", stdin);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (i == j) continue;
            bool f = (__gcd(a[i], a[j]) == 1);
            if (!f) bad[i][j] = true;
        }
    }
    bs cur_ban = 0;
    vector < int > ans;
    for (int i = 1; i <= n; i++) {
        bs all = 0;
        for (int v = 1; v <= n; v++) {
            if (!used[v]) {
                all[v] = 1;
            }
        }
        vector < int > cand;
        for (int v = 1; v <= n; v++) {
            if (!used[v] && cur_ban[v] == 0) {
                cand.emplace_back(v);
            }
        }
        bs good = 0;
        queue < int > q;
        int dd = -1;
        for (int p = 0; p < cand.size(); p++) {
            if (good[cand[p]]) continue;
            q.push(cand[p]);
            while (!q.empty()) {
                int v = q.front();
                q.pop();
                good[v] = true;
                bs add = (bad[v] & all) & (all ^ good);
                for (int c = add._Find_first(); c < add.size(); c = add._Find_next(c)) {
//                    cout << c << " WUT " << endl;
//                    cout << add._Find_next(c) << endl;
                    good[c] = true;
                    q.push(c);
                }
            }
            if (good == all) {
                dd = cand[p];
                break;
            }
        }
        assert(dd != -1);
        ans.emplace_back(a[dd]);
        used[dd] = true;
        for (int c = 1; c <= n; c++) {
            if (!used[c]) {
                if (bad[c][dd]) cur_ban[c] = false;
                if (c > dd && !bad[c][dd]) cur_ban[c] = true;
            }
        }
    }
    for (int v : ans) cout << v << " ";
    return 0;
}

Measured memory_bytes: 4184
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	ll x,n;cin>>x>>n;
    ll d;
    ll s[105];mset(s);
    for(int i=0;i<n;i++){
        cin>>d;
        s[d]=true;
    }
    for(int i=0;i<105;i++){
        if(!s[x-i]){cout<<x-i<<"\n";return 0;}
        if(!s[x+i]){cout<<x+i<<"\n";return 0;}
    }

}


Measured memory_bytes: 3632
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
#define ll long long
ll n,a[400010],sum[400040];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		sum[i]=sum[i-1]+a[i];
	}
	sort(sum+1,sum+n+1);
	ll ans=0,tmp=1,tt=0;
	if(sum[1]==0) tt++;
	for(int i=2;i<=n;i++)
	{
		if(sum[i]==0) tt++;
		if(sum[i]==sum[i-1])
		{
		  	tmp++;
		  	continue;
		}
		else ans+=(tmp*tmp-tmp)/2,tmp=1;
	}
	ans+=(tmp*tmp-tmp)/2;
	cout<<ans+tt;
	return 0;
}

Measured memory_bytes: 5888
import sys
import math
import numpy as np
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

s = ns()

for i in range(1,4):
    if s[i-1] == s[i]:
        print("Bad")
        quit()
print("Good")

Measured memory_bytes: 12436
def same_hantei(a, b, c):
    if a==b or b==c or c==a:
        return 0
    else:
        return 1

def is_triangle(a, b, c):
    ret = same_hantei(a, b, c)
    if ret == 0:
        return 0
    if a+b > c and b+c > a and c+a > b:
        return 1
    else:
        return 0

num = int(input())
arr = [int(e) for e in input().split()]

count = 0
for i in range(0, num-2):
    for j in range(i+1, num-1):
        for k in range(j+1, num):
            res = is_triangle(arr[i], arr[j], arr[k])
            count += res

print(count)


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

vector<int> letter_occurence(26);

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

    for (int i = 0; i < s.length(); ++i)
        ++letter_occurence[(int)(s[i] - 97)];
    
    for (int i = 0; i < 26; ++i)
        if (letter_occurence[i] == 0)
        {
            cout << (char)(i + 97) << '\n';
            return 0;
        }

    cout << "None\n";
}

Measured memory_bytes: 512
n,a,b,c,d=map(int,input().split())
s=input()
if d>c:
    if "##" in s[b-1:d] or "##" in s[a-1:c]:
        print("No")
    else:
        print("Yes")
elif c>d:
    if ("##" not in s[a-1:c]) and ("..." in s[b-2:d+1]):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 40816
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int N;cin>>N;
    vector<string> S(60);
    for(int i=0;i<N;i++)cin>>S[i];
    mat v(60,vec(30,0));
    vec M(30,10000000);
    for(int i=0;i<N;i++){
        for(int j=0;j<S[i].size();j++){
            int a=S[i][j]-'0'-49;
            v[i][a]++;
        }
        for(int k=0;k<26;k++)
            M[k]=min(M[k],v[i][k]);
    }
    for(int i=0;i<26;i++){
        char c=i+49+'0';
        for(int j=0;j<M[i];j++)
            cout<<c;
    }
    return 0;
}

Measured memory_bytes: 256
def main():
    item_count, capacity = [int(x) for x in input().split()]
    weights, values = [], []
    for _ in range(item_count):
        w, v = [int(x) for x in input().split()]
        weights.append(w)
        values.append(v)

    # dp[ i ][ sum_v ] := i 番目までの品物から価値が sum_v 以上を
    #                     達成するように選んだときの、重さの総和の最小値
    INF = 10 ** 9 + 1
    max_v = sum(values)
    dp = [[INF] * (max_v + 1) for _ in range(item_count)]
    for i in range(item_count):
        dp[i][0] = 0
    ans = 0
    for item_i in range(item_count):
        for sum_v in range(1, max_v + 1):
            v = values[item_i]
            if v <= sum_v:
                min_w = min(
                    # weights[item_i], values[item_i] を選ぶ場合。
                    # ここで価値が負にならないよう条件分岐した。
                    dp[item_i - 1][sum_v - v] + weights[item_i],
                    dp[item_i - 1][sum_v])
            else:
                min_w = dp[item_i - 1][sum_v]
            dp[item_i][sum_v] = min_w
            if min_w <= capacity:
                ans = max(ans, sum_v)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 151588
#include <bits/stdc++.h>
using namespace std;
using ll         = long long;
constexpr ll MOD = 1000000007;
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define REP2(i, x, n) for (ll i = x; i < (n); i++)
#define PR(x) cout << (x) << "\n"
#define PS(x) cout << (x) << " "
#define PRYES(x) PR((x) ? "Yes" : "No")
const long long INF = numeric_limits<long long>::max();
// SourceTest用出力マクロ
#ifdef SOURCE_TEST
#define SPR(x) PR(x)
#define SPS(x) PS(x)
#else
#define SPR(x) \
    {}
#define SPS(x) \
    {}
#endif
int main() {
    ll N, M;
    cin >> N >> M;

    vector<ll> digits(N, -1);
    bool isOk = true;
    REP(i, M) {
        ll s, c;
        cin >> s >> c;
        if (digits[s - 1] != -1 && digits[s - 1] != c) {
            isOk = false;
            break;
        }

        digits[s - 1] = c;
    }
    if (digits[0] == 0 && N != 1) {
        isOk = false;
    }
    if (!isOk) {
        PR(-1);
    } else {
        ll ans = 0;
        REP(i, N) {
            ans *= 10;
            if (digits[i] == -1) {
                if (i == 0 && N != 1) {
                    ans += 1;
                } else {
                    ans += 0;
                }
            } else {
                ans += digits[i];
            }
        }
        PR(ans);
    }

    return 0;
}

Measured memory_bytes: 3624
s=input()
t=input()
n,m=len(s),len(t)
if n==0:
    print(m)
    exit()
if m==0:
    print(n)
    exit()
pre=[i for i in range(m+1)]
for i in range(n):
    nxt=list(range(m+1))
    nxt[0]=i+1
    for j in range(m):
        cost=0 if s[i]==t[j] else 1
        nxt[j+1]=min(pre[j+1]+1,nxt[j]+1,pre[j]+cost)
    pre,nxt=nxt,pre

print(pre[m])


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  int n;cin>>n;
  vector<int>x(n);
  rep(i,n)cin>>x[i];
  int ans=1e9;
  rep(i,150){
    int cnt=0;
    rep(j,n){
      cnt+=(x[j]-i)*(x[j]-i);
    }
    ans=min(ans,cnt);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3580
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<vector>
#include<set>
#include<sstream>
#include<cstdlib>
#include<time.h>
#include<math.h>
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define repp(i,n,a) for(int i=n;i>=a;i--)
#define ll long long
#define ull unsign long long
#define ms(x,a) memset(x,a,sizeof(x))
#define lowbit(x) ((x)&(-x))
#define gcd(a,b) _gcd(a,b)
#define inf 0x3f3f3f3f
#define eps 1e-8
#define mod 1e9+7
#define sd(x) scanf("%d",&x)
#define pd(x) printf("%d\n",x)
using namespace std;
const int maxn=1e5+10;
const double pi=acos(-1.0);
ll a[maxn],b[maxn];
ll sum=0;
int main()
{
	ll n,m;
	scanf("%lld%lld",&n,&m);
	ll tot=m+n-1;
	rep(i,1,n){
		if(abs(tot)>abs(m+i-1))tot=m+i-1;
		sum+=(m+i-1);
	}
	sum-=tot;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define lol long long
#define LIM 200111
using namespace std;

int parent[LIM], rk[LIM], ans[LIM];

int findSet(int a) {
    if(parent[a] == a) return a;
    return parent[a] = findSet(parent[a]);
}

void joinSet(int a, int b) {
    a = findSet(a);
    b = findSet(b);
    if(a==b) return;
    if(rk[a]>rk[b]){
        parent[b]=a;
        ans[a]+=ans[b];
    }
    else if(rk[a]<rk[b]){
        parent[a]=b;
        ans[b]+=ans[a];
    }
    else{
        parent[b]=a;
        rk[a]++;
        ans[a]+=ans[b];
    }
}

int main() {
    for(lol i=0; i<LIM; i++){
        parent[i]=i;
        rk[i]=1;
        ans[i]=1;
    }
    lol a,b;
    cin >> a >> b;
    while(b--){
        lol y,z;
        cin >> y >> z;
        joinSet(y-1,z-1);
    }
    int ans1=1;
    for(int i=0; i<a; i++){
        ans1 = max(ans1, ans[findSet(i)]);
    }
    cout << ans1;
    return 0;
}


Measured memory_bytes: 5972
#include <bits/stdc++.h>
using namespace std;
int N, D, X;
int main() {
    cin >> N >> D >> X;
    vector<int> A(N, 0);
    for(int i = 0; i < N; ++i) {
        cin >> A.at(i);
    }

    int choco = 0;

    for(int i = 0; i < N; ++i) {
        int day = 1;
        while(day <= D) {
            choco++;
            day += A.at(i);
        }
    }

    cout << choco + X << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 5;
typedef long long int LL;

int n, k, c;
string s;
int l[maxn], r[maxn];

int main(){
	scanf("%d %d %d", &n, &k, &c);
    cin>>s;
    
	memset(l, 0, sizeof(l));
	memset(r, 0, sizeof(r));
	int cnt = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == 'o'){
			l[i] = ++cnt;
			i += c;
		}
	}
	cnt = k;
	for(int i = n-1; i >= 0; i--){
		if(s[i] == 'o'){
			r[i] = cnt--;
			i -= c;
		}
	}
	for(int i = 0; i <n; i++){
		if(r[i] == l[i] && r[i] > 0){
			printf("%d\n", i+1);
		}
	}
}


Measured memory_bytes: 11644
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int num,a,b,c,d;
	scanf("%d",&num);
	a=num%10;
	b=num/10%10;
	c=num/100%10;
	d=num/1000;
	if(a==b||b==c||c==d)
	{
		printf("Bad");
	}
	else
	{
		printf("Good");
	}
	return 0;
} 

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

using namespace std;

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

#define All(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main(){
   int w,a,b;
   cin >> w >> a >> b;
   if(a<b){
      cout << (b-a-w<0?0:b-a-w) << endl;
   }else{
      cout << (a-b-w<0?0:a-b-w) << endl;
   }
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;  // 1e9+7
const int INF = 100100100;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define debug(x) cerr << #x << ": " << x << '\n'

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B, C;
  cin >> A >> B >> C;
  cout << (((B + C - A) >= 0) ? (B + C - A) : 0) << '\n';
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a[9];
	int b;
	int i=0;
	
	while(cin>>b && b!=0){
		for(i=0;i<9;i++){
			cin>>a[i];
			b=b-a[i];
		}
		cout<<b<<endl;
	}
	return 0;
}

Measured memory_bytes: 2972
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

int n, a;

int main() {
    int currmax = 0; LL res = 0;

    GI(n);

    FORN(i, n) {
        GI(a);

        if (a <= currmax) {
            continue;
        }
        else if (a == currmax + 1) {
            currmax = a;
        }
        else {
            if (a % (currmax + 1) == 0) {
                res += a / (currmax + 1) - 1;
            }
            else {
                res += a / (currmax + 1);
            }
        }

        if (i == 0) currmax = 1;
    }

    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 256
def solve():
    H, W = map(int, input().split())
    S = []
    for h in range(H):
        s = input()
        S.append(s)

    for h in range(H):
        for w in range(W):
            if S[h][w] == '#':
                ok = False
                if h > 0 and S[h - 1][w] == '#':
                    ok = True
                if h < H - 1 and S[h + 1][w] == '#':
                    ok = True
                if w > 0 and S[h][w - 1] == '#':
                    ok = True
                if w < W - 1 and S[h][w + 1] == '#':
                    ok = True
                if not ok:
                    print('No')
                    return

    print('Yes')


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define em3 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
#define X real()
#define Y imag()
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define EPS 1e-7
long long mod = 1e9 + 7;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const double pi = acos(-1);
typedef complex <double> point;
typedef tuple<int, int, int> line;
typedef vector<point> polygon;
ll n , mx , w[100005] , val [100005] ;
/// ind , w --> value
ll memo[200][100005];
ll solve(ll i , ll sum)
{
    if(sum > mx)
        return -1e10;
    if(i == n)
        return 0;
    if(memo[i][sum] != -1)
        return memo[i][sum];
    ll ans1 = 0 , ans2 = 0;
    ans1 += solve(i + 1 , sum + w[i]) + val[i];
    ans2 += solve(i + 1 , sum);
    memo[i][sum] = max(ans1 , ans2);
    //cout << i << " " << sum << " " << memo[i][sum] << endl;
    return memo[i][sum];
}

int main()
{
    em3
    memset(memo , -1 , sizeof memo);
    cin >> n >> mx;
    for(int i = 0 ; i < n ; i++)
        cin >> w[i] >> val[i];
    cout << solve(0 , 0) << endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int t_prev = 0, x_prev = 0, y_prev = 0;
    for (int i = 0; i < n; i++) {
        int t, x, y;
        cin >> t >> x >> y;
        int dt = t - t_prev, dx = x - x_prev, dy = y - y_prev;
        if (dt < dx + dy || (dt & 1) != ((dx + dy) & 1)) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 256
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [list(input()) for _ in range(n)]

x,a,b = map(int, input().split())

if (b <= a):
    print("delicious")
elif (b <= x+a):
    print("safe")
else:
    print("dangerous")



Measured memory_bytes: 9016
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;
const int M    = 1e9 + 7;

ll vis[N];
ll dp[N];
int  main(){
	
	ll n,m;
	cin>>n>>m;
	ll x;

	while(m--){
		cin>>x;
		vis[x] = 1LL;
	}
	if(vis[0] == 0)dp[0] = 1LL;
	if(vis[1] == 0)dp[1] = 1LL;

	for(ll i=2;i<=n;i++){
		if(vis[i])continue;
		dp[i] = (dp[i]+dp[i-1])%M;
		dp[i] = (dp[i]+dp[i-2])%M;
	}
	
	cout<<dp[n]%M<<endl;
	return 0;
}

Measured memory_bytes: 5168
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N;
  cin >> N;
  ll ans = INF;
  ll b;
  string s_a, s_b;
  for (int a = 1; a < N; a++) {
    b = N - a;
    s_a = to_string(a);
    s_b = to_string(b);
    ll cnt = 0;
    for (auto c : s_a) {
      cnt += c - '0';
    }
    for (auto c : s_b) {
      cnt += c - '0';
    }
    ans = min(ans, cnt);
  }
  cout << ans << endl;
  return 0;
}

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

struct Dice{
	int num[6];
	void roll(char c){
		char tmp;
		if(c == 'N'){
			tmp = num[4];
			num[4] = num[0];
			num[0] = num[1];
			num[1] = num[5];
			num[5] = tmp;
		}
		else if(c == 'E'){
			tmp = num[2];
			num[2] = num[0];
			num[0] = num[3];
			num[3] = num[5];
			num[5] = tmp;
		}
		else if(c == 'S'){
			tmp = num[1];
			num[1] = num[0];
			num[0] = num[4];
			num[4] = num[5];
			num[5] = tmp;
		}
		else if(c == 'W'){
			tmp = num[3];
			num[3] = num[0];
			num[0] = num[2];
			num[2] = num[5];
			num[5] = tmp;
		}
	}
	void match1(int n){
		int i = 0;
		while(num[i] != n){
			i++;
		}
		switch(i){
			case 0: break;
			case 1: roll('N'); break;
			case 2: roll('W'); break;
			case 3: roll('E'); break;
			case 4: roll('S'); break;
			case 5: roll('S'); roll('S'); break;
		}
	}
	void match2(int n){
		int i = 0;
		while(num[i] != n){
			i++;
		}
		switch(i){
			case 1: break;
			case 2: roll('W'); roll('S'); roll('E'); break;
			case 3: roll('E'); roll('S'); roll('W'); break;
			case 4: roll('W'); roll('S'); roll('E'); roll('W'); roll('S'); roll('E'); break;
		}
	}
};

int main(){
	Dice d[100];
	int n;
	cin >> n;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 6; j++){
			cin >> d[i].num[j];
		}
	}
	int same[n];
	for(int i = 0; i < n; i++){
		same[i] = -1;
		for(int j = 0; j < 5; j++){
			for(int k = i+1; k <= 6; k++){
				if(d[i].num[j] == d[i].num[k]){
					same[i] = d[i].num[j];
					break;
				}
			}
			if(same[i] != -1)
				break;
		}
	}
	for(int i = 0; i < n; i++){
		if(same[i] != -1){
			for(int j = 0 ; j < 6; j++){
				if(d[i].num[j] != same[i]){
					d[i].match1(d[i].num[j]);
					break;
				}
			}
		}	
	}
	for(int i = 0; i < n-1; i++){
		for(int k = i+1; k < n; k++){
			for(int j = 0; j < 6; j++){
				if(d[k].num[j] == d[i].num[0]){
					d[k].match1(d[i].num[0]);
					break;
				}
			}
			for(int j = 0; j < 6; j++){
				if(d[k].num[j] == d[i].num[1]){
					d[k].match2(d[i].num[1]);
					break;
				}
			}
			bool flag = true;
			for(int j = 0; j < 6; j++){
				if(d[k].num[j] != d[i].num[j]){
					flag = false;
					break;
				}
			}
			if(flag){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 3112
a,b,c,x,y = map(int,input().split())
a = min(a,2*c)
b = min(b,2*c)
ans = 10**20
for i in range(min(x,y)*2+1):
    ans = min(ans,c*i+a*max(0,x-i//2)+b*max(0,y-i//2))

print(ans)

Measured memory_bytes: 38896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int h,w;
    cin >> h >> w;
    vector<string> pic(h);
    
    rep(i,h) cin >> pic[i];

    rep(i,h+2){
        if(i == 0 || i == h+1){
            rep(j,w+2){
                cout << '#';
            if(j == w+1) cout <<endl;
        }
        }

        else{
            rep(j,3){
               if(j == 0 || j == 2) cout << '#';
               else cout << pic[i-1];
               if(j == 2) cout << endl;
            }
    }
    
}
return 0;
}


Measured memory_bytes: 256
n, L = list(map(int, input().split(' ')))

a = [abs(L+i-1) for i in range(1,n+1)]

min_a = a.index(min(a))
result = 0
for i in range(n):
    if i != min_a:
        result += L+i+1-1
    else:
        continue
print(result)


Measured memory_bytes: 2940
#include <iostream>
#include <vector>

using namespace std;

int cnt;

void Merge(vector<int> &A){
  int n = (int)A.size();
  
  if(n > 1){
    vector<int> L(A.begin(), A.begin()+n/2);
    vector<int> R(A.begin()+n/2, A.end());

    Merge(L);
    Merge(R);

    int l = (int)L.size(), r = (int)R.size();
    for(int i = 0,j = 0,k = 0 ; i < n ; i++){
      cnt++;
      if(k == r) A[i] = L[j++];
      else if(j == l) A[i] = R[k++]; 
      else if(L[j] < R[k]) A[i] = L[j++];
      else A[i] = R[k++];
    }
  }
  
}

int main(){
  int n;
  
  cin >> n;
  vector<int> v(n);
  for(int i = 0 ; i < n ; i++){
    cin >> v[i];
  }

  Merge(v);

  int len = (int)v.size();
  for(int i = 0 ; i < len ; i++){
    if(i == len-1) cout << v[i] << endl;
    else cout << v[i] << " ";
  }
  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 7044
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vv = vector<vi>;
using P  = pair<int,int>;
const int INF = 1001001001;
const int MOD = 1000000007;

ll modpow(ll a, ll n, ll mod = MOD) {
    
    ll rtn = 1;
    a %= MOD;
    while (n) {
        if (n & 1) rtn *= a;
        a *= a;
        rtn %= mod;
        a   %= mod;
        n >>= 1;
    }
    return rtn;
}


int main(){
    ll n;
    cin >> n;
    
    ll ans = modpow(10,n,MOD) + modpow(8,n,MOD) + 2*MOD - 2*modpow(9,n,MOD);
    ans %= MOD;
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize ("O3")
//#pragma GCC target ("sse4")
#define endl "\n"
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T, class T2> inline bool chkmax(T &x, const T2 &y) { return x < y ? x = y, 1 : 0; }
template<class T, class T2> inline bool chkmin(T &x, const T2 &y) { return x > y ? x = y, 1 : 0; }
const ll mod = 1e9 + 7;
template<class T> inline void fix(T &x) {if(x >= mod | x <= -mod) {x %= mod;} if(x < 0) {x += mod;}}

signed main() {
    //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll n, m;
    cin >> n >> m;
    ll ans = 0;
    if(n > 0) {
        ans += n * (n - 1);
    }
    if(m > 0) {
        ans += m * (m - 1);
    }
    cout << ans / 2 << endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(n);++i)
const int INF =1001001001;
using ll=long long;
using P = pair<int,int>;
using Graph =vector<string>;
Graph field;
queue<P> q;

int main() {
string a,b;
cin>>a>>b;
ll c=0;
ll d=a.size();
rep(i,d){
  if(a[i]!=b[i]){
    c++;
  }
}
cout<<c<<endl;
}


Measured memory_bytes: 3856
N, K = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(2 * K)]

treated = (list(range(1, N+1)))

for i in range(K):
  tt = list(set(list(range(1, N+1))) - set(l[2*i+1]))
  treated = list(set(treated) & set(tt))

print(len(treated))

Measured memory_bytes: 9200
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		int N = int.Parse(str[0]);
		int M = int.Parse(str[1]);
		int P = int.Parse(str[2]);
		int[,]A = new int[M,3];
		for(var i=0;i<M;i++){
			string[] str2 = Console.ReadLine().Split();
			A[i,0] = int.Parse(str2[0]);
			A[i,1] = int.Parse(str2[1]);
			A[i,2] = int.Parse(str2[2]);
		}
		var list = new List<int[]>[N];
		for(var i=0;i<N;i++){
			list[i] = new List<int[]>();
		}
		for(var i=0;i<M;i++){
			list[A[i,0]-1].Add(new int[3]{i,A[i,1]-1,A[i,2]});
		}
		var listA = new List<int>();
		listA.Add(0);
		long[]T = new long[N];
		int[]S = new int[N];
		int[]F = new int[N];
		F[0] = 1;
		while(listA.Count>0){
			var list2 = new List<int>(listA);
			listA.Clear();
			for(var i=0;i<list2.Count;i++){
				var i1 = list2[i];
				if(S[i1]==1){
					long a1 = T[i1] - P;
					for(var j=0;j<list[i1].Count;j++){
						int m1 = list[i1][j][0];
						int n2 = list[i1][j][1];
						long a2 = a1 + list[i1][j][2];
						if(F[n2]==0){
							S[n2]=1;
							listA.Add(n2);
                 			F[n2]=1;
						} else if(F[n2]>=1 && S[n2]==0){
                          	S[n2]=1;
                          	listA.Add(n2);
                        }
					}
				} else {
					long a1 = T[i1] - P;
					for(var j=0;j<list[i1].Count;j++){
						int m1 = list[i1][j][0];
						int n2 = list[i1][j][1];
						long a2 = a1 + list[i1][j][2];
                     	if(F[n2]>=2500 && S[n2]==0 && a2>T[n2]){
                       		S[n2] = 1;
                          	listA.Add(n2);
                        } else if(F[n2]>=1 && S[n2]==0 && a2>T[n2]){
							T[n2] = a2;
                          	F[n2]++;
                          	listA.Add(n2);
						} else if(F[n2]==0){
							T[n2] = a2;
							F[n2] = 1;
							listA.Add(n2);
						}
					}
				}
			}
		}
		if(S[N-1]==1){
			Console.WriteLine("-1");
		} else if(T[N-1]<=0){
			Console.WriteLine("0");
		} else {
			Console.WriteLine(T[N-1]);
		}
	}
}


Measured memory_bytes: 27480
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll x, ll y) {
	ll res = 1;
	for (ll i = 0; i < y; i++) res = res * x % mod;
	return res;
}

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

	if (s < 3) {
		cout << 0 << endl;
		return 0;
	}

	vector<ll> dp(s + 1, 0);
	dp[0] = 1;
	for (int i = 3; i <= s; i++) dp[i] = (dp[i - 1] + dp[i - 3]) % mod;
	cout << dp[s] << endl;
	return 0;
}

Measured memory_bytes: 3620
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  (n, m) = InputLine.to_ia
  h = InputLine.to_ia
  
  ys = [0] * n
  m.times do |i|
    (a, b) = InputLine.to_ia

    ys[a - 1] = [ys[a - 1], h[b - 1]].max
    ys[b - 1] = [ys[b - 1], h[a - 1]].max
  end

  puts h.zip(ys).filter{|x, y| x > y}.size.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

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

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

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

ll f(ll a, ll b, ll n) {
  ll c = lcm(a, b);
  ll A = n / a;
  ll B = n / b;
  ll C = n / c;
  return n - (A + B - C);
}

int main() {
  ll A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << f(C, D, B) - f(C, D, A - 1) << endl;
  return 0;
}


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

int main()
{
  int N, K, Q, A;
  cin >> N >> K >> Q;
  vector<int>  B(N);
  rep(i, Q){
    cin >> A;
    B.at(A-1)++;
  }
  rep(i, N){
    if(B.at(i)>Q-K) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
} 

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

int main() {
	int a,b,k,x;
	cin >> a >> b >> k;
	for (int i=0; i<k && a+i<=b; ++i) {
		cout << (x=a+i) << endl;
	}
	for (int i=k-1; i>=0; --i) {
		if (x<b-i) cout << b-i << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
int main(){   
   int n;
   cin>>n;
   for (int i = n; i <=999; i++)
   {
      string s;
      s=to_string(i);
      if(s[0]==s[1] && s[1]==s[2] && s[2]==s[0]){
       cout<<i;
       break;
      }
   }
   
   

   return 0;
}


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

typedef vector<long long> vec;
typedef vector<vec> mat;

mat Mul(mat& A, mat& B, long long MOD) {
	mat C(A.size(), vec(B.front().size()));
	for (int i = 0; i < A.size(); i++) {
		for (int k = 0; k < B.size(); k++) {
			for (int j = 0; j < B.front().size(); j++) {
				C[i][j] += ((A[i][k] % MOD) * (B[k][j] % MOD) % MOD);
				C[i][j] = C[i][j] % MOD;
			}
		}
	}
	return C;
}

mat Calc(mat A, long long N, long long M) {
	if (N == 1) return A;
	if (N % 2 == 0) {
		mat B = Calc(A, N / 2, M);
		return Mul(B, B, M);
	}
	mat B = Calc(A, N - 1, M);
	return Mul(B, A, M);
}

int main() {
	long long L, A, B, C[18], M, COUNT;
	mat P(1, vec(3));
	cin >> L >> A >> B >> M;
	COUNT = L;
	P[0][0] = 0, P[0][1] = A, P[0][2] = 1;
	for (int i = 0; i < 18; i++) {
		long long N1 = 1, N2 = 1;
		for (int j = 0; j < i; j++) N1 *= 10, N2 *= 10;
		N2 *= 10;
		N1--, N2--;
		if (N2 < A || COUNT == 0) {
			C[i] = 0;
			continue;
		}
		else if (N1 < A) {
			C[i] = (N2 - A) / B + 1;
		}
		else {
			C[i] = (N2 - A) / B - (N1 - A) / B;
		}
		if (COUNT < C[i]) C[i] = COUNT, COUNT = 0;
		else COUNT -= C[i];
	}
	for (int i = 0; i < 18; i++) {
		if (C[i] == 0) continue;
		mat Q(3, vec(3));
		Q[0][0] = (long long)pow(10, i + 1) % M, Q[0][1] = 0, Q[0][2] = 0;
		Q[1][0] = 1, Q[1][1] = 1, Q[1][2] = 0;
		Q[2][0] = 0, Q[2][1] = B % M, Q[2][2] = 1;
		mat R(3, vec(3));
		R = Calc(Q, C[i], M);
		P = Mul(P, R, M);
	}
	cout << P[0][0];
}

Measured memory_bytes: 256
n = int( raw_input( ) )
minv = int( raw_input( ) )
maxv = 0 - 1000000000
 
for j in range( n-1 ):
  num = int( raw_input( ) )  
  diff = num - minv
  if maxv < diff:
    maxv = diff
  if num < minv:
    minv = num
 
print maxv

Measured memory_bytes: 12696
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader r = new MyReader();        
        int H, W;
        {int[] a = r.ii(); H = a[0];}
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < H; i++){
            String s = r.s();
            for(int j = 0; j < 2; j++){
                sb.append(s);
                sb.append("\n");
            }
        }
        print(sb);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 21588
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		int d;
		int a;;
		boolean[] b = new boolean[n+1];
		int count = 0;

		for(int i=1;i<=k;i++) {
			d = scan.nextInt();
			for(int j=1;j<=d;j++) {
				a = scan.nextInt();
				b[a] = true;
			}
		}

		for(int i=1;i<=n;i++) {
			if(!b[i]) {
				count++;
			}
		}
		System.out.println(count);

	}

}

Measured memory_bytes: 46288