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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> a(N), b(N), c(M), d(M);
  for (int i=0; i<N; i++)
    cin >> a.at(i) >> b.at(i);
  for (int i=0; i<M; i++)
    cin >> c.at(i) >> d.at(i);
  int minmht = -1, minp=0;
  for (int i=0; i<N; i++) {
    for (int j=0; j<M; j++) {
      if (minmht==-1 || minmht>abs(a.at(i)-c.at(j))+abs(b.at(i)-d.at(j))) {
        minp = j+1;
        minmht = abs(a.at(i)-c.at(j))+abs(b.at(i)-d.at(j));
      }
    }
    cout << minp << endl;
    minmht = -1;
    minp = 0;
  }
}

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

int main() {
  int N, A, B, C, D;
  /*
  Nは入力された4桁の整数
  Aは千の位，Bは百の位，Cは十の位，Dは一の位
  同じ数字が3連続なら「良い整数」
  */
  cin >> N;
  A = N / 1000;
  B = (N - 1000*A)/100;
  C = (N - 1000*A - 100*B)/10;
  D = (N - 1000*A - 100*B - 10*C)/1;
  if (A == B) {
    if (B == C) {
    	cout << "Yes" << endl;
    }
    else {
    	cout << "No" << endl;
    }
  }
  else {
    if (B == C) {
    	if (C == D) {
        	cout << "Yes" << endl;
        }
      	else {
        	cout << "No" << endl; 
    	}
    }
    else {
    	cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
    import java.lang.Math;
    public class Main {
        public static void main(String[] args){
            final Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int[] p = new int[n + 1];
            int[][] m = new int[n + 1][n + 1];
            for(int i = 1; i <= n; i++) {
                p[i - 1] = sc.nextInt();
                p[i] = sc.nextInt();
            }
            for(int i = 1; i <= n; i++)
                m[i][i] = 0;
            for(int j = 2; j <= n; j++) {
                for(int i = 1; i <= n - j + 1; i++) {
                    int k = i + j - 1;
                    m[i][k] = 200000;
                    for(int l = i; l <= k - 1; l++) {
                        if(m[i][k] > m[i][l] + m[l + 1][k] + p[i - 1] * p[l] * p[k]){
                            m[i][k] = m[i][l] + m[l + 1][k] + p[i - 1] * p[l] * p[k];
                        }
                    }
                }
            }
            System.out.println(m[1][n]);
        }
    }


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

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

using ll = long long;

int main() {
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);

    ll ans;
    
    if (X / D >= K) {
        ans = X - D * K;
    } else {
        ll e = X / D;
        K -= e;
        X -= e * D;
        if (K % 2 != 0) X = abs(X - D);
        ans = X;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (int i = (a), lim_i = (b); i < lim_i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Thu Mar 26 18:17:40 JST 2020
 **/

template <class T, class S> vector<T> make_vec(size_t n, S x) { return vector<T>(n, x); }
template <class T, class... Ts> auto make_vec(size_t n, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(n, make_vec<T>(ts...));
}

signed main() {
    string s, t;
    cin >> s >> t;
    Int n = s.size(), m = t.size();
    auto dp = make_vec<Int>(n + 1, m + 1, 0);
    REP(i, n) {
        REP(j, m) {
            dp[i + 1][j + 1] = max({dp[i][j + 1], dp[i + 1][j], dp[i][j] + (s[i] == t[j])});
        }
    }
    string ans;
    Int i = n - 1, j = m - 1;
    while (i >= 0 && j >= 0) {
        if (s[i] == t[j]) {
            ans.push_back(s[i]);
            i--, j--;
        } else if (dp[i][j + 1] > dp[i + 1][j]) {
            i--;
        } else {
            j--;
        }
    }
    cout << string(ans.rbegin(), ans.rend()) << endl;
}


Measured memory_bytes: 70784
import java.util.*;
public class Main {
   	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
        int k = sc.nextInt();
        long mod = 1000000007;
        long [] [] pascal = new long [2001][2001];
        for(int i=0;i<=2000;i++){
        for(int j=0;j<=i;j++){if(j==0 || j==i){pascal[i][j]=1;}
                             else{pascal[i][j]=(pascal[i-1][j-1]+pascal[i-1][j])%mod;}
                             }
        }
        for(int i=1;i<=k;i++){long a = pascal[k-1][i-1];
                              long b = pascal[n-k+1][i];
          if((a*b)%mod>=0){System.out.println((a*b)%mod);}
                             else{System.out.println((a*b)%mod+mod);}}		
	}
}

Measured memory_bytes: 79952
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

N, M = MAP()

S = input()
T = input()

if S[0] != T[0]:
	print(-1)
	exit()

G = gcd(N, M)

n = N//G
m = M//G

for i in range(G):
	if S[::n][i] != T[::m][i]:
		print(-1)
		break
else:
	print(N*M//G)


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

using ll = long long;
const ll INF = 1e18 + 5;



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n,m,x,y;
    cin>>n>>m;
    vector<int> adj[n+1];
    vector<int> ind(n+1,0);
    for(int i=0;i<m;i++){
		cin>>x>>y;
		adj[x].emplace_back(y);
		ind[y]++;
	}
    queue<int> q;
    for(int i=1;i<=n;i++){
		if(!ind[i])
			q.push(i);
	}
	vector<int> order;
	
	while(!q.empty()){
		int s = q.front();
		q.pop();
		order.push_back(s);
		for(int v : adj[s]){
			ind[v]--;
			if(!ind[v])
				q.push(v);
		}
	}
    vector<int> dp(n+1,0);
    int ans = 0;
    for(int v : order){
		for(int u : adj[v]){
			dp[u] = max(dp[u],1+dp[v]);
			ans = max(ans,dp[u]);
		}
	}
    
    cout<<ans;
    
 
    return 0;
}









Measured memory_bytes: 7032
# Jasmine_ss's code modified by centipede_human

function MultipleOf2019(str)
    S = str
    n = length(S)
    T = zeros(Int, n+1)
    N = zeros(Int, 2019)
    N[1] += 1
    m = 1
    for i in n:-1:1
        T[i] = mod(T[i+1] + parse(Int, S[i])*m, 2019)
        m*=10; m%=2019
        N[T[i]+1] += 1
    end
#     println(T)
    println(sum(div(m*(m-1), 2) for m in N))
end
MultipleOf2019(readline())


Measured memory_bytes: 168168
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H;
	while(cin>>H>>W) {
		ll ans = (H*W+1)/2;
		if(H==1 || W==1) ans = 1;
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 1000000007
#define PI 3.14159265358979323846
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;

   // cin>>t;
    while(t--)
    {
       ll n,i,j;
       cin>>n;
       ll arr[n+1];
       for(i=0;i<n;i++)
        cin>>arr[i];
       sort(arr,arr+n);
       reverse(arr,arr+n);
       ll pow[n+5];
       pow[0]=1;
       for(i=1;i<=n;i++)
        pow[i]=(pow[i-1]*2)%hell;
       ll ans=0;
       ans=(arr[0]*pow[n-1])%hell;
       for(i=1;i<n;i++)
       {
           ll x=((arr[i]*(pow[i]+(i*pow[i-1])%hell)%hell)%hell*pow[n-1-i])%hell;
           ans=(ans+x)%hell;
       }
       ans=(ans*pow[n])%hell;
       cout<<ans;
    }
}


Measured memory_bytes: 6724
import itertools


def is_compatible(hyp, testimonies):
    return all((key in hyp) == (val == 1) for key, val in testimonies.items())


def is_compatible_all(hyp, all_testimonies):
    return all(is_compatible(hyp, all_testimonies[i]) for i in hyp)


def main():
    n = int(input())

    all_testimonies = [{}]
    for _ in range(n):
        ai = int(input())
        statements = {}
        for _ in range(ai):
            x, y = input().split()
            statements[int(x)] = int(y)
        all_testimonies.append(statements)

    for e in all_cases(n):
        if is_compatible_all(e, all_testimonies):
            print(len(e))
            return

    print(0)


def all_cases(n):
    for r in range(n, 0, -1):
        for ensemble in itertools.combinations(range(1, n + 1), r):
            yield set(ensemble)


if __name__ == '__main__':
    main()


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

int main(void){
  int n,x; cin >> n >> x;
  int l[n];
  rep(i,n) cin >> l[i];
  int count = 0,check = 0,i=0;
  while(check <= x){
    check += l[i];
    count++;
    i++;
  }
  if(count > n+1) cout << n + 1 << endl;
  else cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7


def main():
    N = int(input())
    ans = pow(10, N, m) - (2 * pow(9, N, m) % m)
    ans %= m
    ans += pow(8, N, m)
    ans %= m
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9484
N,K=map(int,input().split())
X=list(map(int,input().split()))

M=float("inf")
for i in range(N-K+1):
    a,b=X[i],X[i+K-1]
    if 0<=a or b<=0:
        M=min(M,max(abs(a),abs(b)))
    else:
        c=min(abs(a),abs(b))
        M=min(M,abs(a)+abs(b)+abs(c))
print(M)

Measured memory_bytes: 85428
#include <stdio.h>
#include <ctype.h>

int main()
{
  char s1[11], s2[11], s3[11];

  scanf("%s%s%s", s1, s2, s3);
  
  printf("%c%c%c", toupper(s1[0]), toupper(s2[0]), toupper(s3[0]));

return 0;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll q, h, s, d;
    ll n;
    cin >> q >> h >> s >> d;
    cin >> n;
    n *= 4;
    ll ans = 0;

    h = min(h, q * 2);
    s = min(s, h * 2);
    d = min(d, s * 2);

    ans += (n / 8) * d;
    n %= 8;

    ans += (n / 4) * s;
    n %= 4;

    ans += (n / 2) * h;
    n %= 2;

    ans += (n / 1) * q;
    n %= 1;

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



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

void input(string& rsColor)
{
  int nColorSiz;
  cin >> nColorSiz >> rsColor;
}

int calcColor(string sColor)
{
  int nColorCnt = 0;
  int nBgn = 0;

  while (nBgn < sColor.size() )
  {
    int nFoward = nBgn;

    while ( nFoward < sColor.size() - 1  &&
            sColor[nFoward] == sColor[nFoward + 1] )
      nFoward++;

    nColorCnt++;
    nBgn = nFoward + 1;
  }
  return nColorCnt;
}

int main()
{
  string sColor;

  input(sColor);
  cout << calcColor(sColor) << endl;

  return 0;
}

Measured memory_bytes: 3804
def dijkstra(s):
    #始点sから各頂点への最短距離
    #n:頂点数,　w:辺の数, cost[u][v] : 辺uvのコスト(存在しないときはinf)
    d = [float("inf")] * n
    used = [False] * n
    d[s] = 0
    
    while True:
        v = -1
        #まだ使われてない頂点の中から最小の距離のものを探す
        for i in range(n):
            if (not used[i]) and (v == -1):
               v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
               break
        used[v] = True
               
        for j in range(n):
               d[j] = min(d[j],d[v]+cost[v][j])
    return d

Xs,Ys,Xt,Yt = map(int,input().split())
n = int(input())
p = [(Xs,Ys,0),(Xt,Yt,0)]
for i in range(2,n+2):
    p.append(tuple(map(int,input().split())))
cost = [[0]*(n+2)for i in range(n+2)]

for i in range(n+2):
    for j in range(i,n+2):
        cost[i][j] = cost[j][i] =  max(((p[i][0]-p[j][0])**2+(p[i][1]-p[j][1])**2)**0.5 - p[i][2] - p[j][2],0)
cost = tuple(cost)
n += 2

res = dijkstra(0)
print(res[1])


Measured memory_bytes: 25076
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
using namespace std;
int main() {
	int n;
	vector<pair<int, int>> a;
	cin >> n;
	int co = 0;
	int a1, b1;
	for (int i = 0; i < n; i++) {
		cin >> a1 >> b1;
		a.emplace_back(b1, a1);
	}
	sort(a.begin(),a.end());
	for (int j = 0; j < n; j++) {
		co += a[j].second;
		if (co > a[j].first) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int N,K,Q;
cin >> N >> K >> Q;
vector<int> vec(Q);
map<int,int> question;
question[0] = 0;
for (int i = 1;i < N+1;i++) {
    question[0] = 0; 
}
for (int i = 0;i < Q;i++) {
    cin >> vec.at(i);
    question[vec.at(i)] += 1;
}

for (int i = 1;i < N+1;i++) {
    if (K-(Q-question[i])> 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


return 0;
}

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

long long Decimal4(long long d){
	std::vector<long long> v;
	while(d){
		v.push_back(d%4);
		d /= 4;
	}

	long long j = 1, res = 0;
	for(int i=0;i<v.size();i++){
		res += (j * v[i]);
		j *= 10;
	}

	return res;
}

int main(){
	int i;
	while(std::cin >> i, i >= 0){
		std::cout << Decimal4(i) << '\n';
	}
}

Measured memory_bytes: 0
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


void no()
{
  std::cout << "No" << std::endl;

  exit(0);
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::string S;

  std::cin >> S;

  std::map<char, int> map;
  
  for (const auto& c : S)
    map[c] ++;

  if (map.size() != 2)
    no();

  for (const auto& kv : map)
    if (kv.second != 2)
      no();

  std::cout << "Yes" << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int maxn = 3e6 + 5 ;
const ll mod = 1e9 + 7 ;
int r1 , c1 , r2 , c2 ;
ll fac[maxn] ;
ll inv[maxn] ;
ll qpow(ll a , ll b)
{
   ll ans = 1 ; 
   a %= mod ;
   while(b)
   {
     if(b & 1)  ans = (ans * a) % mod ;
     b >>= 1 , a = (a * a) % mod ;
   }
   return ans % mod ;
}
void init() 
{
   fac[0] = fac[1] = 1 ;
   for(int i = 2 ; i <= 3e6 ; i ++)
     fac[i] = (fac[i - 1] * i) % mod ;	
   inv[3000000] = qpow(fac[3000000] , mod - 2) ;
   for(int i = 2999999 ; i >= 0 ; i --)
     inv[i] = inv[i + 1] * (i + 1) % mod ;
}
ll C(int n , int m)
{
   return fac[n] * inv[m] % mod * inv[n - m] % mod ;
}
ll sum(int r , int c)
{
	ll ans = 0 ;
	for(int i = 1 ; i <= r + 1 ; i ++)
	  ans += C(i + c , c) , ans %= mod ;
	return ans ;
}
int main()
{
	scanf("%d%d%d%d" , &r1 , &c1 , &r2 , &c2) ;
	init() ;
	ll ans = 0 ;
	ans += sum(r2 , c2) ;
	ans -= sum(r2 , c1 - 1) ;
	ans -= sum(r1 - 1 , c2) ;
	ans += sum(r1 - 1 , c1 - 1) ;
	ans %= mod ;
	ans += mod ;
	ans %= mod ;
	printf("%lld\n" , ans) ;
	return 0 ;
}

Measured memory_bytes: 47104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class MainClass
{
	private static int Cnt=0;
	private static Dictionary<String,int> Ora=new Dictionary<String,int>();
	public static void Main(string[] args)
	{
		string[] k = Console.ReadLine().Split(' ');
		int n = int.Parse(k[0]);
		int m = int.Parse(k[1]);
		List<Bolb> bolbs=new List<Bolb>();
		bool[] sw=new bool[n];
		
		for(int i = 0; i < m; i ++)
		{
			string[] s = Console.ReadLine().Split(' ');
			Bolb b = new Bolb();
			for(int j = 0; j < s.Length;j++)
			{
				int num=int.Parse(s[j]);
				if(j==0)
				{
					b.Connecting=num;
					continue;
				}
				b.Switches.Add(num-1);
			}
			bolbs.Add(b);
			
		}
		string[] t = Console.ReadLine().Split(' ');
		for(int i = 0; i < t.Length;i++)
		{
			bolbs[i].Amari=int.Parse(t[i]);
		}
		
		
		Sousa(0,bolbs,sw);
		Console.WriteLine(Cnt);
	}
	
	private static void Sousa(int i, List<Bolb> bolbs, bool[] sw)
	{
		if(i>sw.Length)
			return;
		string str=ToStr(sw);
		if(!Ora.ContainsKey(str))
		{
		Ora.Add(str,1);
		bool p=true;
		foreach(Bolb k in bolbs)
		{
			if(!k.IsLight(sw))
			{
				p=false;
				break;
			}
		}
		
		if(p)
		{
			Cnt++;
		}
		}
				if(i>=sw.Length)
			return;

			sw[i]=false;
			Sousa(i+1,bolbs,sw);
			sw[i]=true;
			Sousa(i+1,bolbs,sw);
		
		
	}

	private static string ToStr(bool[] sw)
	{
		StringBuilder sb = new StringBuilder();
		for(int i = 0; i < sw.Length;i++)
		{
			sb.Append((int)(sw[i]?(1):(0)));
		}
		return sb.ToString();
	}
	
	public static int Clamp(int val, int max, int min = 0)
	{
		return Math.Min(max, Math.Max(min, val));
	}

	
}

public class Bolb
{
	public int Index{get;set;}
	public int Connecting{get;set;}
	public List<int> Switches{get;set;}
	public int Amari{get;set;}
	
	public Bolb()
	{
		Switches=new List<int>();
	}
	
	public bool IsLight(bool[] sw)
	{
		int knt=0;
		for(int i = 0; i < Switches.Count;i++)
		{
			if(sw[Switches[i]])knt++;
		}
		
		return (knt%2==Amari);
	}
}



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

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    string s, t;
    cin >> n >> s >> t;
    rep(i,n) cout << s[i] << t[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
static const int N=100;

int main(){
    int M[N][N];//0 0 起点的邻接矩阵
    int n,u,k,v;

    cin >> n;
    for(int i=0; i<n; i++) {
        for (int j = 0; j < n; j++)
            M[i][j] = 0;
    }

    for(int i=0; i<n; i++){
        cin >> u >> k;
        u--;//转换为0零起点
        for(int j=0; j<k; j++){
            cin >> v;
            v--;//转换为零起点
            M[u][v] = 1;//在顶点u和顶点v之间画出一条边
        }
    }

    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(j) cout << " ";
            cout << M[i][j];
        }
        cout<<endl;
    }

    return 0;




}


Measured memory_bytes: 3108
n = int(input())
x = list(map(int,input().split()))
ave = sum(x)//n
sum1=0
sum2=0
for i in range(n):
    sum1+=(x[i]-ave)*(x[i]-ave)
    sum2+=(x[i]-ave-1)*(x[i]-ave-1)
print(min(sum1,sum2))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

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

int main() {
	ll A, B, C, D;
	cin >> A >> B >> C >> D;
	ll l = C*D/gcd(C, D);
	ll ans = B - (B/C + B/D - B/l);
	ans -= (A-1) - ((A-1)/C + (A-1)/D - (A-1)/l);
	cout << ans << endl;
	return 0;
}


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

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

// #define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline void chmax(T& a,T const& b){a=max(a,b);}
template<class T> inline void chmin(T& a,T const& b){a=min(a,b);}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60; 

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  // int N,M; cin >> N >> M;
  // vi p(N); rep(i,N) cin >> p[i];
  string s; int K; cin >> s >> K;
  int N = s.size();
  int cnt = 0;
  vector<string> li;
  function<void(string)> go = [&](string a){
    rep(i,li.size()) if(li[i]==a) return;
    li.pb(a);
    sort(ALL(li));
    dump(li);
    if(li.size()==K+1) li.pop_back();
  };
  vi ary(N);
  iota(ary.begin(),ary.end(),0);
  sort(ary.begin(),ary.end(),[&](int l,int r){
    return s[l] < s[r];
  });
  char lst = 'a';
  for(auto i:ary){
    string a = "";
    if(N>4000){
      if(s[i]>lst && ary.size()==K) break;
    }
    a += s[i];
    go(a);
    REP(j,i+1,N){
      a += s[j];
      go(a);
      cnt++;
      if(cnt>int(1e7)){
        cout << li[K-1] << endl;
        return 0;
      }
    }
  }
  if(N==1) li.pb(s);
  cout << li[K-1] << endl;
  return 0;
}


Measured memory_bytes: 256
s = input()
a = int(s[0:2])
b = int(s[2:4])
if 0 < a <= 12 and 0 < b <= 12:
    print("AMBIGUOUS")
elif (a == 0 or a > 12) and 0 < b <= 12:
    print("YYMM")
elif (b == 0 or b > 12) and 0 < a <= 12:
    print("MMYY")
else:
    print("NA")

Measured memory_bytes: 38384
import java.math.BigDecimal;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        System.out.println(BigDecimal.valueOf(K).multiply(BigDecimal.valueOf(K - 1).pow(N-1)));
    }
}


Measured memory_bytes: 23764
text=input()
string=input()


#common_length[i]は、探索列がstring[i]で探索を終了したときに、
# string[i-common_lneght[i] + 1] 〜string[i]で構成される文字列が、探索価値を持つことを示す



len_string=len(string)
common_length=[0]*len_string
tmp=0
tmp_tmp=0
for i in range(1,len_string):
    if(string[i]==string[tmp]):
        tmp_tmp=tmp
        while(string[i]==string[tmp_tmp] and tmp_tmp >0):
            tmp_tmp=common_length[max([tmp_tmp-1,0])]
        common_length[i-1]=tmp_tmp
        tmp+=1
    else:
        common_length[i-1]=tmp
        while(string[i]!=string[tmp] and tmp>0):
            tmp=common_length[max([tmp-1,0])]
        if(string[i]==string[tmp]):
            tmp+=1

if(string[-1]==string[tmp-1]):
    common_length[-1]=tmp
common_length[0]=0


tmp=0

for i in range(len(text)):
    if(text[i]!=string[tmp]):
        while(text[i]!=string[tmp] and tmp>0):
            tmp=common_length[max([tmp-1,0])]
        if(text[i]==string[tmp]):
            tmp+=1
    else:
        tmp+=1
        if(tmp==len_string):
            print(i-tmp+1)
            tmp=common_length[-1]



        





Measured memory_bytes: 8368
#include<stdio.h>
main()
{
int a, b, c, d, e, max=-11111;
scanf("%d%d",&a, &b); 
c=a-b;
if(c>max)
max=c;
d=a*b;
if(d>max)
max=d;
e=a+b;
if(e>max)
max=e;
printf("%d",max); 
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
// typedef long double ldouble;

using Graph = vector<vector<int>>;

// int ctoi(const char c){
//   if('0' <= c && c <= '9') return (c-'0');
//   return -1;
// }

// int gcd(int a, int b){
//   int ma = max(a,b);
//   int mi = min(a,b);
//   if(mi == 0) return ma;

//   return gcd(mi, ma%mi);
// }

// llong POW(llong a, llong b){
//   if(b == 0) return 1;
//   else{
//     if(b%2 == 0) return POW(a * a % MOD, b / 2) % MOD;
//     else return a * POW(a * a % MOD, b / 2) % MOD;
//   }
// }

int main(){
  int n, m;
  cin >> n >> m;
  cout << (n-1) * (m-1) << endl;
}

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

using namespace std;

using ll = long long;

#define MOD_NUMBER 1000000007

// ベクトル要素の列挙
template <class T> void vector_print(vector<T> vec) {
  for (unsigned int i = 0; i < vec.size(); i++) {
    cout << vec.at(i);
    if (i < vec.size()-1) {
      cout << " ";
    } else if (i == vec.size()-1) {
      cout << endl;
    }
  }
}
// エラトステネスの篩による素数配列の出力
vector<int> Eratosthenes(int N){
  vector<int> p = {2};
  int sqrtN = sqrt(N);
  for(int i = 3; i <= N; i++){
    p.push_back(i);
    for (int j = 0; p.at(j) <= sqrtN; j++) {
      if(i%p.at(j) == 0) {
        p.pop_back();
        break;
      }
    }
  }
  return p;
}

int main() {
  int n;
  cin >> n;
  n = n%10;
  switch (n) {
    case 0:
    case 1:
    case 6:
    case 8:
      cout << "pon" << endl;
      break;
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      cout << "hon" << endl;
      break;
    case 3:
      cout << "bon" << endl;
  }
  return 0;
}


Measured memory_bytes: 3600
INF = 2**120

import copy
import sys

V, E = map(int, input().split())
d = [[INF for i in range(V)] for j in range(V)]
for i in range(E):
    s, t, dis = map(int, input().split())
    d[s][t] = dis

for i in range(V):
    d[i][i] = 0

for k in range(V):
    for i in range(V):
        for j in range(V):
            d[i][j] = min(d[i][j], d[i][k]+d[k][j])

d1 = copy.deepcopy(d)

for k in range(V):
    for i in range(V):
        for j in range(V):
            d1[i][j] = min(d1[i][j], d1[i][k]+d1[k][j])

for i in range(V):
    for j in range(V):
        if d[i][j] != d1[i][j]:
            print('NEGATIVE CYCLE')
            sys.exit()

for i in range(V):
    for j in range(V):
        if d[i][j] > 2**60:
            d[i][j] = 'INF'

for i in range(V):
    print(' '.join([str(j) for j in d[i]]))


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

using namespace std;

using ll = long long;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

template <class T>
inline void chmax(T &a, T b) {
  a = std::max(a, b);
}
template <class T>
inline void chmin(T &a, T b) {
  a = std::min(a, b);
}

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);

  ll n;
  cin >> n;

  vll a(n);
  rep(i, n) {
    cin >> a[i];
    a[i] = mod - a[i];
  }

  vll v;
  v.reserve(n);
  v.push_back(a[0]);

  REP(i, n) {
    auto itr = upper_bound(all(v), a[i]);
    if (itr == v.end()) {
      v.push_back(a[i]);
    } else {
      *itr = a[i];
      // sort(v.begin(), itr + 1);
    }
  }

  cout << v.size() << endl;

  return 0;
}


Measured memory_bytes: 1792
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,child,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

vector<int> v[100001];
vector<int> result;
int visited[100001];
int ans[100001];
void tsort(int x){
  if(visited[x]) return;
  visited[x] = 1;
  for(auto y: v[x]){
    tsort(y);
  }
  result.push_back(x);
}

int main(){
  int N, M;
  cin >> N >> M;
  rep(i, N + M - 1){
    int a, b;
    cin >> a >> b;
    v[a].push_back(b);
  }
  rep(i, N) tsort(i + 1);
  reverse(result.begin(), result.end());
  for(auto parent: result){
    for(auto child: v[parent]){
      ans[child] = parent;
    }
  }
  rep(i, N) cout << ans[i + 1] << endl;
  return 0;
}


Measured memory_bytes: 10740
var n, i, tmp, res: longint;
    a: array [0..100] of longint;
begin
   readln(n);
   for i:=1 to n do read(a[i]);
   for i:=1 to n do 
       begin
       read(tmp);
       if (tmp < a[i]) then res := res + a[i] - tmp;
       end;
   write(res);
end.

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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
  int s,t,cnt=1;
  vector<int> a(10000,0);
  cin>>s;

  a.at(s)=1;

  while(1){
    if(s%2==0){
      cnt++;
      s=s/2;
      if(a.at(s)==1)break;
      else {a.at(s)++;}
    }else{
    cnt++;
    s=3*s+1;
    if(a.at(s)==1)break;
    else {a.at(s)++;}
    }

  }
  cout<<cnt<<endl;


return 0;}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

using ll = long long;

template <class T>
using grid = vector<vector<T>>;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

int main() {
  ll input(a, v, b, w, t);

  if (b < a) {
    swap(b, a);
  }

  if (a - b >= (w - v) * t) {
    print("YES");
  } else {
    print("NO");
  }
}


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

int main() {
  ll n,z,w; cin>>n>>z>>w;
  vector<ll> a(n);
  for (int i=0;i<n;i++) cin>>a[i];
  ll ans=abs(w-a[n-1]);
  if (n!=1) ans=max(ans, abs(a[n-1]-a[n-2]));
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main
{
	public static void main(String args[])
	{
		Scanner s=new Scanner(System.in);
		String str=s.next();
		if(str.charAt(2)==str.charAt(3) && str.charAt(4)==str.charAt(5))
		{
			System.out.print("Yes");
		}
		else
		{
			System.out.print("No");
		}
	}
}

Measured memory_bytes: 22484
//love yjl forever
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int INF=0x3f3f3f3f,N=2e5+5,MAX=1e6+5;
int n;
int a[N];
int b[MAX];
int c[MAX];
int d[MAX];
int main()
{
/*	freopen("","r",stdin);
	freopen("","w",stdout);*/
	int i,j;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
//		b[a[i]]=1;
		c[a[i]]++;
	}
		
	sort(a+1,a+n+1);
	
	int ans=0;
	for(i=1;i<=n;i++)
	{
		if(d[a[i]]) continue;
		if(!b[a[i]]&&c[a[i]]<=1) ans++;
		d[a[i]]=1;
		for(j=1;j*a[i]<=MAX;j++)
			b[j*a[i]]=1;
	}
	cout<<ans<<endl;
}

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

#define MAX_S 8000

using namespace std;

// a[0], a[1] ,..., a[n-1], s: nonnegative integers.
// sum_i a[i] <= 64*m and s <= 64*m.
// If there exists a subset I of {0, 1,..., n-1} s.t.
// sum_{i in I} a[i] == s,
// return true.
// O(nm)
bool subsetSum(vector<int>::iterator a, int n, int s, int m)
{
    if (s == 0) {
        return true;
    }
    uint64_t *d = new uint64_t[m+1]();
    d[0] = 1ULL << 63;
    for (int i = 0; i < n; i++) {
        int q = a[i] >> 6;
        int r = a[i] & 63;
        for (int j = m - q; j > 0; j--) {
            d[j+q] |= (r == 0 ? 0 : (d[j-1] >> (64-r))) | (d[j] << r);
        }
    }
    int q = 1 + ((s-1) >> 6);
    int r = (s-1) & 63;
    if (d[q] & (1ULL << r)) {
        return true;
    } else {
        return false;
    }
}

bool f(vector<int>::iterator a, int n, int x)
{
    int m = 0;
    for (int i = 0; i < n; i++) {
        m += a[i];
    }
    if (m < x || (m-x) % 2 == 1) {
        return false;
    }
    return subsetSum(a, n, (m-x) / 2, MAX_S / 64);
}

int main(void)
{
    string s;
    int x, y;

    cin >> s;
    cin >> x >> y;
    //cout << "s: " << s << ", size: " << s.size() << endl;

    vector<int> dxs;
    vector<int> dys;

    auto it = s.begin();
    while (*it == 'F') {
        it++;
        x--;
    }
    //cout << "skipped " << it - s.begin() << " leading F's" << endl;
    int direction = 1; // 1: parallel to x axis, -1: parallel to y axis
    int distance = 0;
    for (; it <= s.end(); it++) {
        if (it == s.end() || *it == 'T') {
            if (direction == 1) {
                dxs.push_back(distance);
            } else if (direction == -1) {
                dys.push_back(distance);
            }
            direction *= -1;
            distance = 0;
        } else if (*it == 'F') {
            distance++;
        }
    }

    /*
    cout << "dxs:" << endl;
    for (auto it = dxs.begin(); it < dxs.end(); it++) {
        cout << *it << endl;
    }

    cout << "dys:" << endl;
    for (auto it = dys.begin(); it < dys.end(); it++) {
        cout << *it << endl;
    }
    */

    if (f(dxs.begin(), dxs.size(), x) && f(dys.begin(), dys.size(), y)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
    ll n,k;
    cin >> n >> k;
    
    if(k == 1 || n == 0){
        cout << 0 << endl;
        return 0;
    }
    
    ll c = n%k;
    cout << min(c,(c-k)*(-1)) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7;
const int MAX_N=10000;
int n;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	
	cout << n/30 << " " << 2*(n%30) << endl;
	return 0;
}

Measured memory_bytes: 3184
import scala.io.StdIn.readLine

object Main {

  def main(args:Array[String]) = {
    for(i<-1 to 9) {
      val s = readLine.split(" ")
      println(s(0) + " " + (s(1).toInt + s(2).toInt) + " " + (s(1).toInt*200 + s(2).toInt*300))
    }
  }
}

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

void print(ll x[], ll n)
{
	for(int i = 0; i < n; i++)
		cout << x[i] << " ";
	cout << endl;
}
double prob[3009];
int n;
double dp[3005][3005];
int vis[3005][3005];
double func(int curHeads, int i)
{
	if(i == n-1)
	{
		int curTails = i - curHeads;
		double ans = 1;
		if(curHeads-curTails > 1)
			ans = 1;
		else if(curHeads == curTails || curHeads - curTails == 1)
			ans = prob[i];
		else
			ans = 0;

		
		dp[curHeads][i] = ans;
		return ans;
	}
	if(vis[curHeads][i] == 1)
	{
		return dp[curHeads][i];
	}
	dp[curHeads][i] = prob[i]*(func(curHeads+1, i+1)) + (1-prob[i])*(func(curHeads, i+1));
	vis[curHeads][i] = 1;
	return dp[curHeads][i];
	
}

int main()
{
	ios::sync_with_stdio(false);
	memset(dp, -1, sizeof dp);
	memset(vis, 0, sizeof vis);
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> prob[i];
	cout << fixed << setprecision(10);
	cout << func(0, 0) << endl;
	

	return 0;
}

Measured memory_bytes: 106240
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
typedef long long ll;

int N, M;
vector<vector<int>> G;
vector<int> dp(100100, -1);

int rec(int v) {
  if (dp[v] != -1) return dp[v];

  int res = 0;
  for (auto nv : G[v]) res = max(res, rec(nv) + 1);
  return dp[v] = res;
}

int main() {
  cin >> N >> M;
  G.assign(N, vector<int>());

  int x, y;
  REP(i,M) {
    cin >> x >> y;
    G[x-1].push_back(y-1);
  }

  int res = 0;
  REP(i,N) res = max(res, rec(i));
  cout << res << endl;
}

Measured memory_bytes: 8192
def dice_in_line(k, p_list):
    max_line = [0 for i in range(k+1)]
    max_sum = 0
    sum_list = [0]
    for i in range(len(p_list)):
        sum_list.append(p_list[i]+sum_list[i])
    for i in range(len(p_list)-k+1):
        if max_sum < sum_list[i+k]-sum_list[i]:
            max_sum = sum_list[i+k]-sum_list[i]
        
    return (max_sum+k)/2.0

n, k = [int(i) for i in input().split()]
p_list = [int(p) for p in input().split()]

print(float(dice_in_line(k, p_list)))

Measured memory_bytes: 24836
#include <stdio.h>

int main() {
    char c1[5] = {}, c2[5] = {};
    scanf("%s %s", c1, c2);
    if (c1[0] == c2[2] && c1[1] == c2[1] && c1[2] == c2[0])
        puts("YES");
    else
        puts("NO");
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

template<typename T> vector<T> make_vector(size_t sz){
	return vector<T>(sz);
}

template<typename T,typename... Ts> 
auto make_vector(size_t sz, Ts... ts){
	return vector<decltype(make_vector<T>(ts...))>(sz, make_vector<T>(ts...));
}

template<typename T,typename U,typename... V> 
typename enable_if<is_same<T, U>::value!=0>::type 
fill_value(U &u, const V... v){
	u=U(v...);
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_value(U &u, const V... v){
	for(auto &e:u){
		fill_value<T>(e,v...);
	}
}

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

const pid_t pid = getpid();
// Problem Specific Parameter:


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

	ll ans = 0LL;

	for(ll i = 1LL; i * i <= n; ++i){
		if(n % i) continue;
		const ll j = n / i;
		
		{
			const ll m = i - 1;
			if(j < m) ans += m;
		}

		if(i * i == n) break;

		{
			const ll m = j - 1;
			if(i < m) ans += m;
		}
	}

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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	int n; cin >> n;
    vector<int> a(n);
    int res = 1;
    rep(i, n) {
        cin >> a[i];
        if(!(a[i] & 1)) res *= 2;
    }
    cout << (int)pow(3, n) - res << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 256
//ITP1-9-A: Finding a Word
//2019.05.19

#include <stdio.h>
#include <string.h>

int main(void){
  char w[10];
  char t[1000];
  int num, i;
  int count = 0;

  scanf("%s\n", w);
  while (1) {
    scanf("%s", t);
    if (strcmp(t, "END_OF_TEXT") == 0) break;
    num = strlen(t);
    for (i = 0; i < num; i++) {
      t[i] = tolower(t[i]);
    }
    if (strcmp(t, w) == 0) count++;
  }
  printf("%d\n", count);
  return 0;
}



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

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

    vector<int> p(n);
    for(int i = 0; i < n; i++)  cin >> p[i];
    sort(p.begin(), p.end());

    for(int i = p[n-1]; i >= 0; i--){
        int num = p.end() - lower_bound(p.begin(), p.end(), i);
        if(num >= i){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3152
// Generated by CoffeeScript 1.7.1
(function() {
  var i, j, _i, _j;

  for (i = _i = 1; _i <= 9; i = ++_i) {
    for (j = _j = 1; _j <= 9; j = ++_j) {
      console.log(i + "x" + j + "=" + i * j);
    }
  }

}).call(this);

Measured memory_bytes: 7644
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) {
        xmax = x; 
        return true;
    }
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) {
        xmin = x; 
        return true;
    }
    return false;
}
template<typename Val>
bool bitcheck(Val bit, size_t idx) {
    return bit & (1 << idx);
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

void solve() {
    int a, b, c, d, e; cin >> a >> b >> c >> d >> e;
    if (a == 0) {
        cout << 1 << endl;
    } else if (b == 0) {
        cout << 2 << endl;
    } else if (c == 0) {cout << 3 << endl;
    } else if (d == 0) {cout << 4 << endl;}
    else {cout << 5 << endl;}

}

signed main() {
    solve();
    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main(){
	int N,K;
	cin>>N>>K;
	bool A[N+1]={0};
	for(int z=0;z<K;z++){
		int d;
		cin>>d;
		for(int i=0;i<d;i++){
			int t;
			cin>>t;
			A[t]=1;
		}
	}
	int cnt=0;
	for(int i=1;i<=N;i++){
		if(A[i]==0)cnt++;
	}
	cout<<cnt<<"\n";
}

Measured memory_bytes: 3628