akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll   long long int
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define inf 1000000000000000000LL
#define fast_io	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mod 1000000007
#define range 500005
#define lg 22
using namespace std;

ll prod(ll a,ll x)
{
	if(x==0)
	return 1;
	if(a==0)
	return 1;
	ll val=prod(a,x/2)%mod;
	
	return ((val%mod*val%mod)*(x%2==1?a:1))%mod;
}
int main()
{
	ll n,x;
	cin>>n;
	x=(prod(10,n)-2*prod(9,n)+prod(8,n)+(4LL)*mod)%mod;
	cout<<x<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
using namespace std;

int main(void)
{
	int N, M; cin >> N >> M;
	vector<pair<int, int>> S(N), P(M);
	rep(i, 0, N)cin >> S[i].first >> S[i].second;
	rep(i, 0, M)cin >> P[i].first >> P[i].second;

	rep(i, 0, N) {
		int place_to_gather = 0;
		int M_D = abs(S[i].first - P[0].first) + abs(S[i].second - P[0].second);
		rep(j, 1, M) {
			if (M_D > (abs(S[i].first - P[j].first) + abs(S[i].second - P[j].second))) {
				M_D = abs(S[i].first - P[j].first) + abs(S[i].second - P[j].second);
				place_to_gather = j;
			}
		}
		cout << place_to_gather + 1 << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

const int N = 1001000;
bool prime[1001000];
void eratosthenes(){
    rep(i,N) prime[i] = 1;
    prime[0] = prime[1] = 0;
    rep(i,N){
        if(prime[i]){
            for(int j = i + i; j < N; j+=i){
                prime[j] = 0;
            }
        }
    }
}

ll n,now=1,p=0;

int main(){
    eratosthenes();
    cin>>n;
    rep(i,sqrt(n)+2){
        if(prime[i]){
            if(n%i!=0)continue;
            ll cnt=0;
            while(n%i==0){
                cnt++;
                n/=i;
            }
            now*=(cnt+1);
            p++;
        }
    }
    if(n!=1){
        now*=2;
        p++;
    }
    if(now==1)cout<<"1 1"<<endl;
    else cout<<p<<" "<<now-1<<endl;
    
    
}



Measured memory_bytes: 4096
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(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_v(U& u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
template<class T> bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T & a, const T & b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	// 0 1 2 3 4 5
	vi sum(N + 1);
	REP(i, M) {
		int l, r;
		cin >> l >> r;
		l--; r--;
		sum[l]++;
		sum[r + 1]--;
	}
	int ans = 0;
	int s = 0;
	REP(i, N) {
		s += sum[i];
		if (s == M) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
N,M = map(int,input().split())

wa_cnt = [0]*N
ac_flag = [False]*N

for _ in range(M):
    p,S = input().split()
    p = int(p)-1

    if not ac_flag[p]:
        if S == 'WA':
            wa_cnt[p] += 1
        else:
            ac_flag[p] = True


print(sum(ac_flag), sum(c for c,f in zip(wa_cnt,ac_flag) if f))

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

int main() {
    int N;
    cin >> N;
    vector<int> V(N),C(N);
    for(int i = 0;i<N;i++){
        cin >> V.at(i);
    }
    for(int i = 0;i<N;i++){
        cin >> C.at(i);
    }
    int result = 0;
    for(int i = 0;i<N;i++){
        result += max(V.at(i)-C.at(i),0);
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  V<> res(1001);
  for (int s = 1; s < 500; ++s) {
    for (int l = 2; ; ++l) {
      int sum = (2 * s + l - 1) * l / 2;
      if (sum > 1000) break;
      ++res[sum];
    }
  }
  while (true) {
    int n; cin >> n;
    if (n == 0) break;
    cout << res[n] << '\n';
  }
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
const int N=200005;
int W,H,n,x,y;
set<int > S[N];
map<pair<int ,int>  ,int> Map;
int main(){
	scanf("%d%d%d",&W,&H,&n);
	while (n--){
		scanf("%d%d",&x,&y);
		S[y].insert(x);
		Map[mp(x,y)]=1;
	}
	for (int i=1;i<=H;i++)S[i].insert(W+1);
	x=1;y=1;int ans=*S[x].upper_bound(1);
	while (1){
		if (x==W||Map.count(mp(x+1,y)))break;
		x++;
		if (y+1<=H&&!Map.count(mp(x,y+1)))y++;
		ans=min(ans,*S[y].upper_bound(x));
	}
	printf("%d\n",ans-1);
}

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

using namespace std;

int main()
{
    int N, arr[101], cnt, i;

    cin >> N;

    for(i = 0; i < N; i++) {
        cin >> arr[i];
    }

    for(i = 0, cnt = 0; i < N; i++) {
        if(arr[i] == arr[i+1]) {
            cnt++;
            i++;
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#define INF 100000000000005
using namespace std;

typedef long long ll;


int main(){
    int N,W;
    ll w[100005],v[100005],dp[100005];
    cin>>N>>W;
    dp[0]=0;
    for(int i = 1;i <= W;i++){
        dp[i]=0;
    }

    for(int i = 0;i < N;i++){
        cin>>w[i]>>v[i];
    }

    for(int i = 0;i < N;i++){
        for(int j = W;j >= 0;j--){
            if(j+w[i]<=W){
                dp[j+w[i]]=max(dp[j+w[i]],dp[j]+v[i]);
            }
        }
    }
    ll ans = 0;
    for(int i = 0;i <= W;i++){
        ans = max(ans,dp[i]);
    }
    cout<<ans<<endl;
}


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

using namespace std;
int sx,sy,tx,ty;
char w[4] = {'U','R','D','L'};

int main() {
  cin >> sx >> sy >> tx >> ty;

  int i = ty - sy;
  int j = tx - sx;
  int k = i;
  int l = j;


  while(i--)cout <<'U';
  i = k + 1;
  while(j--)cout <<'R';
  j = l + 1;
  while(k--)cout <<'D';
  k = i;
  while(l--)cout <<'L';
  l = j;

  cout <<'L';
  while(i--)cout <<'U';
  while(j--)cout <<'R';
  cout << "DR";
  while(k--)cout <<'D';
  while(l--)cout <<'L';
  cout <<'U'<<endl;
}
  
  


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(i = 0; i < n; i++)
#define Rep(i, n) for(i = 1; i < n; i++)
#define ANS(s) cout << s << endl;

const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

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

typedef long long ll;

// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
//int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
//int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

int main()
{
	int n;
	cin >> n;
	ANS(n / 3);
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np

MOD = 998244353

N = int(input())
S = np.array(list(input().rstrip()),dtype='U1')

counter = {x:0 for x in 'RGB'}
answer = 1
for s in S:
    counter[s] += 1
    x = counter[s]
    y,z = [counter[t] for t in 'RGB' if t != s]
    if y>z:
        y,z = z,y
    if y<x<=z:
        answer *= x*(x-y)*(z-x+1)
        answer %= MOD
print(answer)

Measured memory_bytes: 16220
#include<iostream>

using namespace std;

int main(){
 int n;
   cin >> n;
 bool res=false;
  
  for(int i=0;i<=n/4;i++){
     if((n-4*i)%7==0) res=true;
     } 
  if(res) cout << "Yes" << endl;
  else cout << "No" << endl;
  }

Measured memory_bytes: 256
import math
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)

N = ni()
D = nl()
# D = nl()
D.sort()

s1 = D[N//2 -1 ]
s2 = D[N//2]

print(s2 - s1)


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

int main(void)
{
	int ch;
	char str[1201];
	int i = 0, num, ret;
	int alpha[26] = {0};
	
	while (1) {
		ret = scanf("%c", &ch);
		if (ret == EOF){
			break;
		}
		
		str[i] = ch;
		if (isupper(str[i])) {
			num = str[i] - 'A';
			alpha[num]++;
		} else if (islower(str[i])) {
			num = str[i] - 'a';
			alpha[num]++;
		}
		i++;
	}
	
	for (i = 0; i < 26; i++) {
		printf("%c : %d\n", 'a' + i, alpha[i]);
	}
	
	return 0;
}

Measured memory_bytes: 544
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;

int main(){
    int n, m, a;
    cin >> n >> m;
    int A[100] = {0};
    for (int i = 0; i < 2*m; i++) {
        cin >> a;
        A[a]++;
    }
    for (int i = 1; i <= n; i++) {
        cout << A[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//




int main() {

    int N; cin >> N;
    vector<ll> a(N), b(N), c(N);
    rep(i,N) cin >> a[i];
    rep(i,N) cin >> b[i];
    rep(i,N) cin >> c[i];
    Sort(a);
    Sort(c);

    ll ans = 0;
    rep(i,N) {
        ll num_a = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        ll num_c = c.end() - upper_bound(c.begin(), c.end(), b[i]);
        ans += num_a * num_c;
    }
    out(ans);

    
    return 0;
}










Measured memory_bytes: 2816
# coding: utf-8
# Your code here!
N, K = map(int,input().split())

link = [[] for i in range(N)]
link[0] = [i for i in range(1,N)]
for i in range(1,N):
    link[i].append(0)

def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

if N == 2 and K == 0:
    print(1)
    print("1 2")
elif N == 2 and K == 1:
    print(-1)
elif comb(N-1,2) < K:
    print(-1)
else:
    maxnum = comb(N-1,2)
    for i in range(1,N):
        for j in range(1,N):
            if i < j:
                if maxnum != K:
                    link[i].append(j)
                    link[j].append(i)
                    maxnum -= 1
                else:
                    continue
    print(sum([len(l) for l in link])//2)
    for i in range(N):
        for j in link[i]:
            if i < j:
                print(i+1, j+1)

                
        
    


Measured memory_bytes: 3736
#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,l;cin>>n>>l;
  vector<int> vec(n);
  int ans=0,x=1e9;
  rep(i,n){
    vec[i]=i+l;
    ans+=vec[i];
    x=min(x,abs(vec[i]));
  }
  if(ans>0)cout<<ans-x<<endl;
  else cout<<ans+x<<endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define rep(n) for(int i=0;i<n;i+=1)
#define fill(c,v) memset(c,v,sizeof(c));
#define prarr(a,n) rep(n) cout<<a[i]<<" \n"[i==n-1]; 
#define sc(a) scanf("%d",&a);
#define scl(a) scanf("%lld",&a);
#define scf(a) ascanf("%f",&a);
#define ff first
#define ss second
#define pu push_back
#define inf 1000000001
#define MOD 1000000007 
#define INF 100000000000001
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    // int a[5];
    ll a;
    ll mi = 1e18+1;	
    cin>>n;
    
    rep(5) 
    {
    	cin>>a;
    	mi = min({mi,a});
    }
    if(n>mi)
    {
    	if(n%mi)
    		cout<<n/mi + 5ll<<endl;
    	else
    	{
	    	cout<<n/mi + 4ll<<endl;

    	}
    }
	else
		cout<<5<<endl;
    return 0;

}


Measured memory_bytes: 256
#58c
import collections

n = int(input())

#初回分だけ別処理
s = str(input()) 
s_counted = collections.Counter(s)
alphabet_times_dict = dict(s_counted)

#初回分以降を読み込んで、重なっている文字と回数を絞っていく
for i in range(n-1):
    s = str(input()) 
    s_counted = collections.Counter(s)
    
    for alphabet_times in alphabet_times_dict.items():
        alphabet = alphabet_times[0]
        times = alphabet_times[1]
        
        if alphabet in s_counted:
            alphabet_times_dict[alphabet] = min(alphabet_times_dict[alphabet],s_counted[alphabet])
        else:
            alphabet_times_dict[alphabet] = 0

#重なっていた文字＊回数のリスト作成
string_list = []

for alphabet_times in alphabet_times_dict.items():
    alphabet = alphabet_times[0]
    times = alphabet_times[1]
    
    if times != 0:
        string_list += [alphabet for i in range(times)]
        
#辞書順に並び替えて表示
string_list.sort(reverse = False)
print(''.join(map(str,string_list)))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i=0; i<N; ++i) {
    cin >> S.at(i);
  }
  int M;
  cin >> M;
  vector<string> T(M);
  for (int j=0; j<M; ++j) {
    cin >> T.at(j);
  }
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N);
  for (int i=0; i<N; ++i) {
    int a = 0;
    for (int j=0; j<N; ++j) {
      if (S.at(i) == S.at(j)) {
        ++a;
      }
    }
    A.at(i) = a;
  }
  for (int i=0; i<N; ++i) {
    int a = 0;
    for (int j=0; j<M; ++j) {
      if (S.at(i) == T.at(j)) {
        ++a;
      }
    }
    B.at(i) = a;
  }
  for (int i=0; i<N; ++i) {
    C.at(i) = A.at(i)-B.at(i);
  }
  int d=0;
  for (int i=0; i<N; ++i) {
    d = max(d,C.at(i));
  }
  cout << d << endl;
}
  
  
  

Measured memory_bytes: 256
Z = [0,1,2,3,4,5,5,4,3,2,1,1]
X=[0,1,2,3,4,5,6,7,8,9]
def solve_dp(s):
    n = len(s)
    s = [int(c) for c in s]
    inf = 10**9

    dp = [[inf] * 2 for _ in range(n)]

    d0 = s[0]
    dp[0][0] = Z[d0]
    dp[0][1] = Z[d0+1]

    for i in range(1, n):
        for j in range(2):
            d = s[i] + j
            for k in range(10):
                if d + X[k] >= 10:
                    dp[i][j] = min(dp[i][j], dp[i-1][1] + X[k] + Z[d + X[k] - 10])
                else:
                    dp[i][j] = min(dp[i][j], dp[i-1][0] + X[k] + Z[d + X[k]])

    return dp[n-1][0]

if __name__ == '__main__':
    s = input()
    print(solve_dp(s))


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

#define FAST_IO                       \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;

const int MOD = 1e9 + 7;

void add_self(int& a, int b)
{
	a += b;
	if (a >= MOD)
	{
		a -= MOD;
	}
}

void sub_self(int& a, int b)
{
	a -= b;
	if (a < 0)
	{
		a += MOD;
	}
}

const int MAXN = 1e3 + 5;

char c[MAXN][MAXN];
ll dp[MAXN][MAXN];

int main()
{

	FAST_IO;
	int h, w;
	cin >> h >> w;
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			cin >> c[i][j];
		}
	}
	dp[1][1] = 1;
	for (int i = 1; i <= h; ++i) {
		for (int j = 1; j <= w; ++j) {
			if(c[i][j] == '#') {
				dp[i][j] = 0;
				continue;
			}
			if (i > 1)
				dp[i][j] += dp[i - 1][j];
			if (j > 1)
				dp[i][j] += dp[i][j - 1];
			dp[i][j] %= MOD;
		}
	}
	cout << dp[h][w];
	return 0;
}


Measured memory_bytes: 9088
class Observatory:
    def __init__(self, height):
        self.height = height
        self.connected_observatories = []

    def add_connected_observatories(self, observatory):
        self.connected_observatories.append(observatory)

    def compare_height_with_connected_observatories(self):
        for i in self.connected_observatories:
            if self.height <= i.height:
                return False

        return True

N, M = map(int, input().split())

observatories = []

for i in list(map(int, input().split())):
    observatories.append(Observatory(i))

for i in range(M):
    A, B = map(int, input().split())

    observatories[A - 1].add_connected_observatories(observatories[B - 1])
    observatories[B - 1].add_connected_observatories(observatories[A - 1])

count = 0

for i in observatories:
    if i.compare_height_with_connected_observatories():
        count += 1

print(count)

Measured memory_bytes: 39540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0; i<n; i++)
int main()
{
	int x;
	cin >> x;
	if(x == 0)
		cout << 1;
	else
		cout << 0;

	cin >> x;
	
	return 0;	
}


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

int main() {
	int s;
	cin >> s;
	
	if((s/100)==0){
		if(((s%100)<13)&&((s%100)>0)){
			cout << "YYMM" << endl;
		}
		else cout << "NA" << endl;
	}
	else if((s%100)==0){
		if(((s/100)<13)&&((s/100)>0)){
			cout << "MMYY" << endl;
		}
		else cout << "NA" << endl;
	} 
	else if((s/100)<13){
			if((s%100)<13){
				cout << "AMBIGUOUS" << endl;
			}
			else cout << "MMYY" << endl;
	}
	else if((s%100)<13){
		cout << "YYMM" << endl;
	}
	else cout << "NA" << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{
	static void Main()
	{
  int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
  int n = nums[0];
  int m = nums[1];
  int x = nums[2];
  int y = nums[3];
	int[] lefts = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
  int[] rights = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
  Array.Sort(lefts);
  Array.Sort(rights);
	//出力
    if(lefts[n-1] < y && x < rights[0] - 1 && lefts[n-1] < rights[0])
    {
    Console.WriteLine("No War");
    }
    else Console.WriteLine("War");
	}
}


Measured memory_bytes: 13268
#include <iostream>


using namespace std;

int main(){

    int A, B;
    cin >> A >> B;
    
    
    if (A >= 13) {
        
        cout << B << endl;
    }else if(A <= 5){
        
        
        cout << 0 << endl;
    }else{
        
        cout << B/2 << endl;
        
    }
    
    
    
    
    return 0;
    
}

Measured memory_bytes: 256
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N, K = read_ints()
P = read_ints()


def ret_mean(X):
    return (X + 1) / 2


P_mean = [ret_mean(p) for p in P]

from itertools import accumulate
P_accum = [0] + list(accumulate(P_mean))

ans = 0
# print(P_accum)
for i in range(N - K + 1):
    j = i + K
    ans = max(ans, P_accum[j] - P_accum[i])
print(ans)


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;



class trie{
public:
    trie* next[26];
    trie(){
        fill(next,next+26,(trie*)0);
    }
    void insert(const string &str){
        insert(str,0);
    }
    bool find(const string &str){
        return find(str,0);
    }
    void insert(const string &str,const int idx){
        if(idx==str.size()) return;
        if(this->next[str[idx]-'a']==NULL) this->next[str[idx]-'a']=new trie();
        this->next[str[idx]-'a']->insert(str,idx+1);
    }
    bool find(const string &str,const int idx){
        if(idx==str.size()) return true;
        if(this->next[str[idx]-'a']==NULL) return false;
        return this->next[str[idx]-'a']->find(str,idx+1);
    }
};

void solve(){
    int n;
    cin >> n;
    set<string> st;
    rep(i,0,n){
        string s;
        cin >> s;
        rep(j,0,s.size()){
            rep(k,1,5){
                if(j+k>s.size()) break;
                st.insert(s.substr(j,k));
            }
        }
    }

    queue<string> que;
    rep(i,0,26) que.push(string(1,'a'+i));
    while(true){
        auto s=que.front();
        que.pop();
        if(st.find(s)==st.end()){
            cout << s << endl;
            return;
        }
        if(s.size()==4) continue;
        rep(i,0,26){
            s.push_back('a'+i);
            que.push(s);
            s.pop_back();
        }
    }
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

Measured memory_bytes: 67204
fun main(arr:Array<String>) {
    val itemCount = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map{it.toInt()}
    val bList = mutableListOf<Int>()
    if(aList.size >= 2) {
        for(i in (1 until aList.size)) {
            bList.add(Math.min(aList[i-1], aList[i]))
        }
    }
    bList.add(0, aList.first())
    bList.add(aList.last())
    val ans = bList.sum()
    println(ans)
}




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

int main() {
  int N,K;
  cin>>N>>K;
  double ans=0;
  for(int i=1;i<N+1;i++){
    int index;
    double num=i/2.0;
    int j=0;
    while(true){
      num*=2;
      if(num>=K){
        index=j;
        break;
      }
      j++;
    }
    double x=1.0/N;
    for(int l=0;l<index;l++) x/=2.0;
    ans+=x;
  }
  cout<<setprecision(10)<<ans<<endl;      
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
typedef long long ll; 
typedef vector<ll> vi; 
typedef pair<int, int> ii; 
typedef vector<ii> vii; 
typedef vector<vi> vvi;
#define F first
#define S second
#define pb emplace_back
#define M 1000000007
#define watch(x) cout << (#x) << " is " << (x) << endl
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr(i,a,b) for(int i = a; i<= b; i++)
#define all(c) c.begin(), c.end()
 

 
main() {
IOS;
    
    int n;
    map<string, int> Map;
    cin >> n;
    fr (i,1,n) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        Map[s]++;
    }

    int sum = 0;
    for (auto i: Map) {
        int v = i.second;
        sum += ((v) * (v - 1)) / 2;
    }
    cout << sum;

}
 
/*  Check for base cases such as n == 1
and cases like it where code can fail */

Measured memory_bytes: 11264
import collections
a = int(input())
ar = list(map(int,input().split(" ")))
br = collections.Counter(ar)
cr = []
for k,v in br.items():
    if v >= 4:
        cr.append(k)
        cr.append(k)
    elif v >= 2:
        cr.append(k)
cr = sorted(cr,reverse=True)
if len(cr) < 2:
    print(0)
else:
    print(cr[0] * cr[1])

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, t, a, h[1000];

int main() {
	cin >> n >> t >> a;
	inc(i, n) { cin >> h[i]; }
	
	pair<int, int> p = MP(1e9, -1);
	inc(i, n) {
		setmin(p, MP(abs(1000 * a - (1000 * t - 6 * h[i])), i));
	}
	
	cout << p.SE + 1 << endl;
	
	return 0;
}


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

class main{
  public static void Main(string[] args){
    int num = int.Parse(Console.ReadLine());
    int bY = int.Parse(Console.ReadLine());
    var ballsY = System.Console.ReadLine().Split(' ').Select(v => System.Int32.Parse(v)).ToArray();
    int dists = 0;
    
    foreach(int ballY in ballsY){
      int dist = Math.Min(bY-ballY, ballY);
      dists += 2*dist;
    }
    Console.WriteLine(dists);
  }
}

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

int a[100];
int n;

int main() {
	cin >> n;
	cin >> a[0];
	int max = a[0];
	int min = a[0];
	for (int i = 1; i < n; i++) {
		cin >> a[i];
		if (a[i] > max)max = a[i];
		if (a[i] < min)min = a[i];
	}
	cout << max - min << endl;
	return 0;
}

Measured memory_bytes: 256
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)


def lcm(a, b):
    g = gcd(a, b)
    return (a * b) // g


N = int(input())
lst_T = [int(input()) for _ in range(N)]
ans = 1


for t in lst_T:
    ans = lcm(ans, t)


print(ans)

Measured memory_bytes: 3060
n = int(input())
registerd = [input() for _ in range(n)]

door_open = False

m = int(input())
for _ in range(m):
    ic = input()
    if ic in registerd:
        if door_open:
            print("Closed by {0}".format(ic))
            door_open = False
        else:
            print("Opened by {0}".format(ic))
            door_open = True
    else:
        print("Unknown {0}".format(ic))

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

int main() {
    vector<char> s(19);
    
    for(int i = 0; i < 19; i++){
        cin >> s.at(i);
    }

    s.at(5) = ' ';
    s.at(13) =  ' ';

    for(int i = 0; i < 19; i++){
        cout << s.at(i);
    }
    cout << endl;
}

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

double sign;
double ans;

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

  for (ll i = 0; i <= 1000; i++)
  {
    for (ll j = 0; j < i; j++)
    {
      if (pow(i, 5) - pow(j, 5) == n)
      {
        cout << i << " " << j << endl;
        return 0;
      }
      if (pow(i, 5) + pow(j, 5) == n)
      {
        cout << i << " " << -j << endl;
        return 0;
      }
    }
  }
}


Measured memory_bytes: 4012
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
struct UnionFind
{
    vector<ll> par;
    vector<ll> rank;
    vector<ll> sz;
    UnionFind(ll n) : par(n), rank(n), sz(n)
    {
        for(ll i = 0; i < n; i++)
        {
            par[i] = i;
            rank[i] = 0;
            sz[i] = 1;
        }
    }
    ll root(ll x)
    {
        if(par[x] == x) return x;
        else return par[x] = root(par[x]);
    }
    void unite(ll x, ll y)
    {
        x = root(x);
        y = root(y);
        if(x == y) return;
        if(rank[x] < rank[y])
        {
            par[x] = y;
            sz[y] += sz[x];
        }
        else
        {
            par[y] = x;
            sz[x] += sz[y];
            if(rank[x] == rank[y]) rank[x]++;
        }
    }
    bool same(ll x, ll y)
    {
        return root(x) == root(y);
    }
    ll size(ll x)
    {
        x = root(x);
        return sz[x];
    }
};

int main()
{
    ll n, m;
    cin >> n >> m;
    vector<int> a(m);
    vector<int> b(m);
    for(int i = 0; i < m; i++)
    {
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
    }
    UnionFind tree(n);
    vector<ll> ans(m);
    ll con = n * (n-1) / 2;
    for(int i = m-1; i >= 0; i--)
    {
        ans[i] = con;
        if(tree.same(a[i], b[i])) continue;
        ll asize = tree.size(a[i]);
        ll bsize = tree.size(b[i]);
        tree.unite(a[i], b[i]);
        ll size = tree.size(a[i]);
        con = con - size * (size-1) / 2 + asize * (asize-1) / 2 + bsize * (bsize-1) / 2;
    }
    for(int i = 0; i < m; i++)
    {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 5248
/**
 *    author:  tourist
 *    created: 25.01.2020 00:11:05       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int init, cnt;
  cin >> init >> cnt;
  vector<long long> st(1, init);
  while (cnt--) {
    long long x;
    cin >> x;
    while (!st.empty() && st.back() >= x) {
      st.pop_back();
    }
    st.push_back(x);
  }
  map<long long, long long> mp;
  mp[st.back()] += 1;
  while (true) {
    auto it = prev(mp.end());
    long long x = it->first;
    long long cc = it->second;
    if (x <= st[0]) {
      break;
    }
    int pos = (int) (lower_bound(st.begin(), st.end(), x) - st.begin());
    long long y = st[pos - 1];
    long long times = x / y;
    mp[y] += times * cc;
    long long rm = x - times * y;
    if (rm > 0) {
      mp[rm] += cc;
    }
    mp.erase(x);
  }
  vector<long long> bal(init + 1);
  for (auto& p : mp) {
    bal[p.first] += p.second;
  }
  for (int i = init; i >= 2; i--) {
    bal[i - 1] += bal[i];
  }
  for (int i = 1; i <= init; i++) {
    cout << bal[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 9076
/** Seek God..Trust God..Praise God..**/

#include<bits/stdc++.h>
using namespace std;


#define fRead(x)        freopen("x.txt","r",stdin)
#define fWrite(x)       freopen ("x.txt","w",stdout)

#define mt              make_tuple
#define ld              long double
#define ll              long long
#define ull             unsigned long long
#define ff              first
#define ss              second
#define pb              push_back
#define INF             2e16
#define PI              acos(-1.0)
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>
#define endl            "\n";

#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(a,min(b,min(c,d)))
#define max4(a,b,c,d)   max(a,max(b,max(c,d)))
#define SQR(a)          ((a)*(a))
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define MEM(a,x)        memset(a,x,sizeof(a))
#define ABS(x)          ((x)<0?-(x):(x))

#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())


#define FASTIO        ios_base::sync_with_stdio(0);cin.tie(nullptr);




///..................Sort by second element in a pair in decending order............. ///
bool SortbySecDesc(const pair<long long,long long > &a, const pair<long long,long long > &b)
{
    return a.second>b.second;
}

///.........................first element of pair in descending order..........................//////
bool sortinrev(const pair<int,int> &a,
               const pair<int,int> &b)
{
       return (a.first > b.first);
}



///.............................................................TEMPLATE................................................./////



/*
long long  Prime[3000000],nPrime;
long long  mark[10000002];

void seive(long long int n)
{
	long long int i,j,limit=sqrt(n*1.0)+2;
	mark[1]=1;
	for(i=4; i<=n ;i+=2)
	mark[i]=1;
	Prime[nPrime++]=2;
	for(i=3; i<=n; i+=2)
	{
		if(!mark[i])
		{
			Prime[nPrime++]=i;
			if(i<=limit)
			{
				for(j=i*i; j<=n ;j+=i*2)
				{
					mark[j]=1;
				}
			}
		}
	}
}
*/


int main()
{
    FASTIO;

    ll d , s , t;

    cin >> d >> s >> t;




    ll ans = s*t;


    if(ans>=d)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;

    }








    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll; 
ll rec(int i,ll cur,ll sum,const string &S) {
	if(i==S.size()) {
		return sum;
	}
	int d=S[i]-'0';
	ll res=0;
	if(i+1!=S.size())
		res+=rec(i+1,cur*10+d,sum,S);
	res += rec(i+1,0,sum+cur*10+d,S);
	return res;
}
 
int main() {
	string S;
	while(cin>>S) {
		ll ans = rec(0, 0, 0, S);
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

int main(){
	int a,b;
	
	cin >> a >> b;
	
	if(a>b){
		cout << a-1 << endl;
	}else{
		cout << a << endl;
	}
	

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin >> s;

  int cnt = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'p') cnt++;
  }

  cout << s.size() / 2 - cnt << endl;
  return 0;
}


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

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >
#define smaller_queue_p  priority_queue <pll, vector<pll>, greater<pll> >
//------------------------------------------------------

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

    smaller_queue front;
    priority_queue<ll> back;
    int n;
    cin >> n;
    ll a[3 * n];
    rep(i, 3 * n) cin >> a[i];

    map<ll, ll> best_f, best_b;
    ll now_sum = 0;

    rep(i, n) {
        front.push(a[i]);
        now_sum += a[i];
    }

    for (int i = n; i <= 2 * n + 1; ++i) {
        best_f[i] = now_sum;
        front.push(a[i]);
        now_sum += a[i];
        now_sum -= front.top();
        front.pop();
    }
    now_sum = 0;

    for (int i = 3 * n - 1; i >= 2 * n; --i) {
        back.push(a[i]);
        now_sum += a[i];
    }

    for (int i = 2 * n - 1; i >= n - 1; --i) {
        best_b[i] = now_sum;
        back.push(a[i]);
        now_sum += a[i];
        now_sum -= back.top();
        back.pop();
    }

    ll Max = -LINF;
    for (int i = n; i <= 2 * n; ++i) {
        Max = max(Max, best_f[i] - best_b[i - 1]);
    }

    cout << Max << endl;
    return 0;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
// #define map unordered_map
// #define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

int main() {
  // std::cout << std::fixed << std::setprecision(10);

  ll N, K;
  scanf("%lld %lld", &N, &K);

  map<ll, ll> m;

  for (ll i = 0; i < K; i++) {
    ll d;
    scanf("%lld", &d);

    for (ll j = 0; j < d; j++) {
      ll s;
      scanf("%lld", &s);

      m[s]++;
    }
  }

  ll ans = 0;
  for (ll i = 1; i <= N; i++) {
    if (m[i] == 0) {
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3696
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <bitset>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()

#pragma region UnionFind
struct UnionFind
{
	vector<int> par;

	UnionFind(int n) : par(n, -1) {}
	void init(int n) { par.assign(n, -1); }

	int root(int x)
	{
		if (par[x] < 0) return x;
		else return par[x] = root(par[x]);
	}

	bool issame(int x, int y)
	{
		return root(x) == root(y);
	}

	bool merge(int x, int y)
	{
		x = root(x); y = root(y);
		if (x == y) return false;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}

	int size(int x)
	{
		return -par[root(x)];
	}
};
#pragma endregion
#pragma region GCD
int gcd(int a, int b)
{
	if (a%b == 0)return b;
	return gcd(b, a%b);
}
#pragma endregion
#pragma region chmin
template<class T> inline bool chmin(T& a, T b)
{
	if (a > b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma region chmax
template<class T> inline bool chmax(T& a, T b)
{
	if (a < b)
	{
		a = b;
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main()
{
	string s, t; cin >> s >> t;
	int cnt = 0;
	int n = s.size();
	rep(i, n)if (s[i] != t[i])++cnt;
	cout << cnt << endl;
}

Measured memory_bytes: 3856
#include <iostream>
#include <string>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <iomanip>
#include <vector>
#include <functional>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <cstdlib>
#include <unordered_map>
#include <string.h>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string s;
    cin >> s;
    int N = s.size();
    int a = 0, b = 0, c = 0, d = 0;
    rep(0, i, N)
    {
        if (s.at(i) == 'N')
        {
            a = 1;
        }
        if (s.at(i) == 'W')
        {
            b = 1;
        }
        if (s.at(i) == 'S')
        {
            c = 1;
        }
        if (s.at(i) == 'E')
        {
            d = 1;
        }
    }
    if (a == c && b == d)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

// constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
// constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    LL a,b,c,d;
    cin >> a >> b >> c >> d;
    if (a <= 0LL && b >= 0LL && c <= 0LL && d >= 0LL) cout << max({0LL,a*c,a*d,b*c,b*d}) << endl;
    else cout << max({a*c,a*d,b*c,b*d}) << endl;
}

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

Measured memory_bytes: 3632
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        int n = stdin.nextInt();
        int l = stdin.nextInt();
        List<String> s = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            s.add(stdin.next());
        }
        
        String ans = s.stream().sorted().collect(Collectors.joining());
        System.out.println(ans);
    }

}


Measured memory_bytes: 27092
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    long long int ans = 0;
    int n; cin >> n;
    for(int i=1;i<=n;i++){
        if((i%3!=0)&&(i%5!=0)) ans = ans + i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP2(i, n) for (Int i = 0, max_i = (n); i < max_i; i++)
#define REP3(i, a, b) for (Int i = (a), max_i = (b); i < max_i; i++)
#define OVERLOAD2(_1, _2, _3, name, ...) name
#define REP(...) OVERLOAD2(__VA_ARGS__, REP3, REP2)(__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: Sat Feb 22 21:00:01 JST 2020
 **/

signed main() {
    Int K, Q;
    cin >> K >> Q;
    vector<Int> d(K);
    REP(i, K) cin >> d[i];
    REP(q, Q) {
        Int n, x, m;
        cin >> n >> x >> m;
        x %= m, n--;
        vector<Int> tmp = d;
        REP(k, K) tmp[k] = tmp[k] % m == 0 ? m : tmp[k] % m;
        Int acc = x + accumulate(tmp.begin(), tmp.end(), 0LL) * (n / K);
        REP(k, n % K) acc += tmp[k];
        Int ans = n - acc / m;
        cout << ans << endl;
    }
}


Measured memory_bytes: 384
s = input()
k = int(input())
if (s[0] != '1'):
  print(s[0])
else:
  count1 = 0
  for i in range(len(s)):
    if (s[i] == '1'):
      count1 += 1
    else:
      break
  if (k <= count1):
    print(1)
  else:
    print(s[count1])
  

Measured memory_bytes: 2940
k = int(input())
s = input()
n = len(s)
MOD = 10**9+7
ans = 0

fact = [1] * 2200000
invfact = [1] * 2200000
 
for i in range(1, 2200000):
    fact[i] = fact[i-1] * i % MOD
 
invfact[2200000 - 1] = pow(fact[2200000 - 1], MOD-2, MOD)
 
for i in range(2200000-1, 0, -1):
    invfact[i-1] = invfact[i] * i % MOD

def comb(n, k):
    return fact[n] * invfact[k] * invfact[n-k] % MOD

for i in range(k+1):
    b = pow(26, k-i, MOD)
    b *= pow(25, i, MOD)
    b *= comb(i+n-1, n-1)
    ans += (b % MOD)
    
print(ans%MOD)

Measured memory_bytes: 125736
n,k = map(int,raw_input().split())
dic = {}
for a in range(k):
  x = raw_input()
  x = map(int,raw_input().split())
  for z in x:
    dic[z] = 1
x = [1]*(n+1)
x[0] = 0
for a in dic:
  x[a] = 0
print x.count(1)


Measured memory_bytes: 69000