akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
long long mod=1e9+7;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long T;
  T=1;
  while(T--)
  {
    int n,m;
    cin>>n>>m;
    vector< int > a(n);
    long long sum=0;
    for(int i=0;i<n;i++)
    {
      cin>>a[i];
      sum+=a[i];
    }
    int k=(sum+(4*m)-1)/(4*m);
    int ans=0;
    for(int i=0;i<n;i++)
    {
      if(a[i]>=k)
      {
        ans++;
      }
    }
    if(ans>=m)
    {
      cout<<"Yes"<<endl;
    }
    else
    {
      cout<<"No"<<endl;
    }
  }
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define N 200005
using namespace std;
int main(){
    int i,m1=0,m2=0;
    string s;
    cin>>s;
    for(i=0; i<s.length(); ++i){
        if(i%2==0 && s[i]=='1') ++m1;
        if(i%2==1 && s[i]=='0') ++m1;
        if(i%2==0 && s[i]=='0') ++m2;
        if(i%2==1 && s[i]=='1') ++m2;
    }
    cout<<min(m1,m2);
    return 0;
}


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

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};
constexpr int N_MAX = 1000;

ll fact[N_MAX+1], rfact[N_MAX+1];

ll perm(ll n, ll r){
    return (fact[n] * rfact[r]) % MOD;
}

ll comb(ll n, ll r){
    return (perm(n, r) * rfact[n-r]) % MOD;
}

void init(ll n){
    fact[0] = fact[1] = 1;
    rfact[0] = rfact[1] = 1;
    for(int i=2;i<=n;++i) {
        fact[i] = (fact[i-1] * (ll)i) % MOD;
        rfact[i] = 1;
        ll k = MOD-2;
        ll a = fact[i];
        while(k > 0){
            if(k & 1){
                rfact[i] *= a;
                rfact[i] %= MOD;
            }
            a *= a;
            a %= MOD;
            k  >>= 1;
        }
    }
}

ll modpow(ll a, ll t) {
    ll ret = 1LL;
    while(t){
        if(t & 1LL){
            ret *= a;
            ret %= MOD;
        }
        a *= a;
        a %= MOD;
        t >>= 1;
    }
    return ret;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    init(n);

    vector<vector<ll>> dp(b+1, vector<ll>(n+1, 0));
    dp[a-1][0] = 1;
    for(int i=a-1;i<b;++i) {
        for(int j=0;j<=n;++j) dp[i+1][j] = dp[i][j];
        for(int j=0;j<=n;++j) {
            if(!dp[i][j]) continue;
            ll g = 1;
            for(int gi=1;gi<=d&&j+(i+1)*gi<=n;++gi) {
                (g *= comb(n-j-(i+1)*(gi-1), i+1)) %= MOD;
                (g *= modpow(gi, MOD-2)) %= MOD;
                if(c <= gi) (dp[i+1][j+(i+1)*gi] += (dp[i][j] * g) % MOD) %= MOD;
            }
            // cout << i << ", " << j << ": " << dp[i][j] << endl;
        }
    }

    cout << dp[b][n] << endl;
}


Measured memory_bytes: 9728
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

	int n;
	string s, t;
	cin >> n >> s >> t;

	for (int i = 0; i < n; i++) {
		cout << s[i] << t[i];
	}
	cout << endl;





	return 0;
}

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

#define ll long long 

int main() {
    ios::sync_with_stdio(0); 

    string s; cin >> s;
    int c = 0;
    for (auto x : s) {
        if (x == 'A') c++;
    }

    cout << (c != 0 and c <= 2 ? "Yes" : "No") << "\n"; 


    return 0; 
}



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

// See debug.cc for usage etc
#define DEBUG 0

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#if DEBUG
  #define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DCALL(func, ...)
#endif

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif

  ll N;
  cin >> N;
  cout << 180 * (N-2) << endl;

  return 0;
}



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

int main() {
	int n, m;
	cin >> n >> m;
	string s = "", str = "";
	for(int i = 0; i < n; ++i)
		s += (m + '0');
	for(int i = 0; i < m; ++i)
		str += (n + '0');
	if(s < str)
		cout << s;
	else
		cout << str;
}


Measured memory_bytes: 3584
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

H = int(input())
W = int(input())
N = int(input())

a = max(H, W)
print((N + a - 1) // a)



Measured memory_bytes: 7880
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll s;
int main(){
	cin>>s;
	printf("0 0 1000000000 1 %lld %lld",(int)1e9-1-(s-1)%1000000000,(s-1)/(int)1000000000+1);
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
N,*A = map(int, open(0).read().split())
Cnt = Counter(A)
for i in range(1,N+1):
  if Cnt[i]==2:
    p = i
    break
a = A.index(p)
b = A[::-1].index(p)
for i in range(1,N+2):
  print((cmb(N+1,i,mod)-cmb(a+b,i-1,mod))%mod)

Measured memory_bytes: 138480
p=(2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997)
r=[1]*168
n=int(input())
for i in range(n):
  x=i+1
  for j in range(168):
    while x%p[j]==0:x//=p[j];r[j]+=1
ans=1
for i in r:ans*=i;ans%=10**9+7
print(ans%(10**9+7))

Measured memory_bytes: 3192
#include <iostream>
#include <cmath>
using namespace std;
int main(void)
{
    int a, b, c, d;
    
    cin >> a >> b >> c >> d;
    
    if(abs(a - b) <= d && abs(b - c) <= d || abs(a - c) <= d)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    return 0;
}


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

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(int _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(int _##i = (t), i = (f); i <  _##i; i++)
#define downto(f, t, i)  for(int _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(int _##i = (t), i = (f); i >  _##i; i--)
typedef long double ld;
#define long long long

#if defined(EBUG) && !defined(ONLINE_JUDGE)
    #define debug true
    #define ln << endl
#else
    #define debug false
    #define ln << '\n'
#endif
#define tb << '\t'
#define sp << ' '

const int MOD = 1e9+7;

int N;
set<int> P[100010];

int pyon(int i, int q) {
    int x = 0;
    for(int j: P[i]) if(j != q) {
        x ^= pyon(j, i);
    }
    return x + 1;
}

signed main() { // long: 64bit
    if(!debug) {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }

    scanf("%d",&N);
    times(N-1, i) {
        int x, y; scanf("%d%d", &x, &y);
        P[x-1].insert(y-1);
        P[y-1].insert(x-1);
    }

    cout << (pyon(0, 0) != 1 ? "Alice" : "Bob") ln;

    return 0;
}


Measured memory_bytes: 19072
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

struct Tmp
{
public:
  Tmp(int N);
};

Tmp::Tmp(int N){}

void solve(void)
{
  int N; cin >> N;
  ll M; cin >> M;
  
  vector<int> A(N);
  for (auto& a : A) { cin >> a; }
  
  set<int> s{};
  ll t{1};
  ll ans{};
  for (const auto& a : A) {
    int l = 1;
    int b0 = a / 2;
    int b{b0};
    while (b % 2 == 0) { b /= 2; ++l; }
    s.emplace(l);
    t = boost::lcm(t, (ll)b0);
    if (t > M) {
      goto err;
    }
  }
  if (s.size() != 1) {
    goto err;
  }
  ans = (M - t) / (t * 2) + 1;

err:
  cout << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
#include<queue>
#include <iomanip>
using namespace std;
typedef long long ll;
#define rep(i,k) for(i=0;i<k;i++)
#define P pair<ll,ll>
ll n, p, k, b, c, i, j, x, y, z = 0, m = 0, q,d;
ll a[100] = {}, yy[100] = {}, aa[100] = {};
double xx, zz = 0;
string s, t;
vector<ll> v[100];
int main() {
	cin >> m >> d;
	if (d < 22) {
		cout << 0;
		return 0;
	}
	for (i = 22; i <= d; i++) {
		if ((i % 10) < 2)continue;
		c = i / 10;
		b = i % 10;
		if (b * c <= m)z++;
	}


	cout << z;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
ll multbig(ll a,ll b,ll mod){
    if(a==0 or b==0) return 0;
    if(a==1 or b==1) return (a*b)%mod;
    ll cur=multbig(a,b/2,mod);
    cur=(2*cur)%mod;
    if(b%2) cur=(cur+a)%mod;
    return cur;
}
ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
ll fpow(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = MOD) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = MOD){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}


#define N 	100*1000+5
void solve(){	
	ll n;
	cin>>n;
	map<string, ll>m;
	rep(i,0,n){
		string s;
		cin>>s;
		sort(all(s));
		m[s]++;
	}
	ll ans = 0;
	for(auto it : m)
		ans += (it.y)*(it.y-1);
	cout << ans/2 << endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 11264
import fractions

n = int(input())
a = list(map(int, input().split()))

l = a[0]
for i in range(1, n):
    l = l * a[i] // fractions.gcd(l, a[i])

count = 0


for i in a:
  count += l//i
count %= (10**9+7)

print(count)

Measured memory_bytes: 6200
#include<stdio.h>
#include<stdlib.h>
#define M 100
#define A 0
#define B 1
#define C 2

int n;
int T[M][M];
int Alph[M],d[M];
int Q[M],head = 0,tail = 0;

void enqueue(int x){
  Q[tail] = x;
  tail = (tail+1)%M;
}

int dequeue(void){
  int x;
  x = Q[head];
  head = (head+1)%M;
  return x;
}

void bfs(int s){
  int i,u,v;

  for(i = 0 ; i < n ; i++){
    Alph[i] = A;
    d[i] = 1000000;
  }

  Alph[s] = B;
  d[s] = 0;
  enqueue(s);

  while(head != tail){
    u = dequeue();
    for(v = 0; v < n ; v++){
      if(T[u][v] == 1 && Alph[v] == A){
	Alph[v] = B;
	d[v] = d[u]+1;
	enqueue(v);
      }
    }
    Alph[u] = C;
  }

}

int main(){
  int i,j;
  int u,k,v;

  scanf("%d",&n);
  if(n < 1 || n > 100)exit(1);

  for(i = 0 ; i < n ; i++){
    for(j = 0 ;  j < n ; j++){
      T[i][j] = 0;
    }
  }

  for(i = 0 ; i < n ; i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j = 0 ; j < k ; j++){
      scanf("%d",&v);
      v--;
      T[u][v] = 1;
    }
  }

  bfs(0);

  for(i = 0; i < n ; i++){
    if(d[i] == 1000000) d[i] = -1;
    printf("%d %d\n",i+1,d[i]);
  }

  return 0;
}



Measured memory_bytes: 2148
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

int N, M;
const int MAX_M = 100000;
int x[MAX_M], y[MAX_M]; 

int main(){
  cin >> N >> M;
  REP(i, M) cin >> x[i] >> y[i];

  bool red[N];
  int num[N];
  REP(i, N) {
    red[i] = false;
    num[i] = 1;
  }
  red[0] = true;

  REP(i, M) {
    int from = x[i] - 1, to = y[i] - 1;
    if(red[from]) {
      red[to] = true;
    }
    num[from]--;
    num[to]++;
    if(num[from] == 0) red[from] = false;
  }

  int ans = 0;
  REP(i, N) if(red[i]) ans++;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1536
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <iostream>
#include <set>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define PRIME1 99999883
#define PRIME2 99999893
#define EPS 0.00000001
#define NUM 48
using namespace std;

struct Info{
	Info(){
		leftWall = false;
		underWall = false;
	}
	bool leftWall,underWall;
};

struct Data{
	int row,col,count;
};

int W,H;
int div_row[4] = {-1,0,0,1},div_col[4] = {0,-1,1,0};

bool rangeCheck(int row,int col){
	if(row >= 0 && row <= H-1 && col >= 0 && col <= W-1)return true;
	else{
		return false;
	}
}

void func(){
	int tmp;

	Info table[H][W];
	int firstTime[H][W];

	for(int i = 0; i < H; i++){
		for(int k = 0; k < W; k++)firstTime[i][k] = BIG_NUM;
	}

	for(int i = 0; i < H-1; i++){
		for(int k = 0; k < W-1; k++){
			scanf("%d",&tmp);
			if(tmp == 1)table[i][k+1].leftWall = true;
		}
		for(int k = 0; k < W; k++){
			scanf("%d",&tmp);
			if(tmp == 1)table[i][k].underWall = true;
		}
	}
	for(int k = 0; k < W-1; k++){ //?¨?????????±?????????1?????????
		scanf("%d",&tmp);
		if(tmp == 1)table[H-1][k+1].leftWall = true;
	}

	Data first;
	first.row = 0;
	first.col = 0;

	firstTime[0][0] = 0;

	first.count = 0;

	queue<Data> Q;
	Q.push(first);

	int ans = -1,next_row,next_col;

	bool FLG;

	while(!Q.empty()){

		if(Q.front().row == H-1 && Q.front().col == W-1){
			ans = Q.front().count;
			break;
		}

		for(int i = 0; i < 4; i++){
			next_row = Q.front().row+div_row[i];
			next_col = Q.front().col+div_col[i];
			FLG = false;
			if(rangeCheck(next_row,next_col) == true && firstTime[next_row][next_col] > Q.front().count+1){

				switch(i){
				case 0: //???
					if(table[next_row][next_col].underWall == false)FLG = true;
					break;
				case 1: //???
					if(table[Q.front().row][Q.front().col].leftWall == false)FLG = true;
					break;
				case 2: //???
					if(table[next_row][next_col].leftWall == false)FLG = true;
					break;
				case 3: //???
					if(table[Q.front().row][Q.front().col].underWall == false)FLG = true;
					break;
				}
			}

			if(FLG){
				Data new_data;
				new_data.row = next_row;
				new_data.col = next_col;
				new_data.count = Q.front().count+1;
				firstTime[next_row][next_col] = new_data.count;
				Q.push(new_data);
			}
		}
		Q.pop();
	}

	printf("%d\n",ans+1);
}

int main(){

	while(true){
		scanf("%d %d",&W,&H);
		if(W == 0 && H == 0)break;

		func();
	}

    return 0;
}

Measured memory_bytes: 3156
using System;

namespace ConsoleApp21
{
    class Program
    {
        static void Main(string[] args)
        {
            var h = long.Parse(Console.ReadLine());
            long aCount = 0;
            long bCount = 1;                        
            while (true)
            {               
                if (h == 1)
                {
                    aCount += 1;   
                    break;
                }
                    h /= 2;                   
                    bCount*= 2;
                    aCount+= bCount;
                }
                Console.WriteLine(aCount);
            }
        }
    }

Measured memory_bytes: 27488
#include <stdio.h>

int main(void)
{
	int a, b;
	int len, n;
	
	while ( scanf("%d %d", &a, &b) != EOF ){
		
		a = a + b;
		len = 1;
		
		for (n = 0; a > 9; n++){
			
			a /= 10;
			len++;
		}
		
		printf("%d\n", len);
		
	}
	
	return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  
int main() {
  ll n;
  cin >> n;
  vl a(n);
  rep(i,n){
    cin >> a[i];
  }
  ll ans=INF;
  ll cnt=0;
  ll k;
  vl sum(n,0);
  sum[0]=a[0];
  if(a[0]==0){
    cnt++;
    sum[0]=1;
  }
  FOR(i,1,n){
    sum[i]=a[i]+sum[i-1];
    if(sum[i]*sum[i-1]>=0){
      k=sum[i];
      sum[i]=-sum[i-1]/abs(sum[i-1]);
      cnt+=abs(k-sum[i]);
    }
  }
  ans=min(ans,cnt);
  cnt=0;
  if(a[0]==0){
    sum[0]=-1;
    cnt++;
  }
  else{
    k=a[0];
    sum[0]=-abs(a[0])/a[0];
    cnt+=abs(sum[0]-k);
  }
  FOR(i,1,n){
    sum[i]=sum[i-1]+a[i];
    if(sum[i]*sum[i-1]>=0){
      k=sum[i];
      sum[i]=-abs(sum[i-1])/sum[i-1];
      cnt+=abs(k-sum[i]);
    }
  }
  ans=min(ans,cnt);
  cout << ans << endl;
}

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

const int MX=2e5+5;
const ll mod=1e9+7;

ll ara[MX];

void show(ll l, ll r){
     ll i, j, k;
     ll ans=1;
     for(i=l; i<=r; ++i) ans=(ans*ara[i])%mod;
     cout << (ans+mod)%mod << endl;
     exit(0);
}

int main(){
     ll i, j, k;
     ll n;
     cin >> n >> k;
     ll tk=k;
     for(i=0; i<n; ++i) cin >> ara[i];

     sort(ara, ara+n);
     if(ara[n-1]<0 || n==k){
          if(k%2) show(n-k, n-1);
          else show(0, k-1);
     }

     vector< ll > positive, negative, ans;
     for(i=0; i<n; ++i){
          if(ara[i]>=0) positive.push_back(ara[i]);
          else negative.push_back(ara[i]);
     }
     sort(positive.begin(), positive.end());
     sort(negative.begin(), negative.end(), greater<ll>());

     if(k%2){
          ans.push_back(positive.back());
          positive.pop_back();
          k--;
     }
     while(k>0){
          ll t1=-1, t2=-1;
          if(positive.size()>=2){
               t1=positive[positive.size()-1]*positive[positive.size()-2];
          }
          if(negative.size()>=2){
               t2=negative[negative.size()-1]*negative[negative.size()-2];
          }
          if(t1>t2){
               ans.push_back(positive.back());
               positive.pop_back();
               ans.push_back(positive.back());
               positive.pop_back();
          }
          else{
               ans.push_back(negative.back());
               negative.pop_back();
               ans.push_back(negative.back());
               negative.pop_back();
          }
          k-=2;
     }
     ll tot=1;
     for(i=0; i<ans.size(); ++i){
          tot=(tot*ans[i])%mod;
     }
     tot=(tot+mod)%mod;
     cout << tot << endl;
}


Measured memory_bytes: 9552
#include <iostream>
#include <map>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
    int n;
    cin >> n;
    map<string, int> mp;
    rep(i, n) {
        string tmp;
        cin >> tmp;
        sort(tmp.begin(), tmp.end());
        mp[tmp]++;
    }
    long long ans = 0;
    for (auto& p : mp) {
        int s = p.second;
        ans += (long long)s*(s-1)/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11136
x=[int(input()) for _ in range(5)]
y=[x[_]%10 for _ in range(5)]
y.sort()
s=0
a=0
for _ in range(5):
  if y[_]!=0:
    a=y[_]
    s=-1
    break
for _ in range(5):
  s=s-(-x[_] // 10)
print((s)*10+a)


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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a[3];
	for(int i = 0; i < 3; i++) cin >> a[i];
	sort(a, a + 3);
	if(a[0] == 5 and a[1] == 5 and a[2] == 7) {
		cout << "YES" << endl;
	}
	else cout << "NO" << endl;
	return 0;
}

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

using namespace std;

int main(){
 string s;
  cin >> s;
  
  
  for(int i=1;i<s.length()-1;i++){
   if(s[i-1]==s[i]) {
     cout << i << " " << i+1 << endl;
     return 0;
   }
   if(s[i-1]==s[i+1]){
     cout << i << " " << i+2 << endl;
     return 0;
   } 
  }
  if(s[s.length()-2]==s[s.length()-1]) {
     cout << s.length()-1 << " " << s.length() << endl;
     return 0;
   }
  
  

   cout << -1 << " " << -1 << endl;
}

Measured memory_bytes: 512
#20:45



num = int(input())

for i in range(num):
    def count_pattern(prefix,suffix):

        answer.add(prefix + suffix)
        answer.add(prefix[::-1] + suffix)
        answer.add(prefix + suffix[::-1])
        answer.add(prefix[::-1] + suffix[::-1])

        answer.add(suffix + prefix)
        answer.add(suffix[::-1] + prefix)
        answer.add(suffix + prefix[::-1])
        answer.add(suffix[::-1] + prefix[::-1])
    
    target = input()
    answer = set()
    for j in range(1,len(target)):
        target_prefix = target[:j]
        target_suffix = target[j:]
        count_pattern(target_prefix,target_suffix)
    print(len(answer))







Measured memory_bytes: 5636
#include <bits/stdc++.h>
#define dcout cout << fixed << setprecision(15)
#define rep(i, a) for(int i = 0; i < a; i++)
#define arep(i, x) for(auto i : x)
#define all(v) v.begin(), v.end()
#define int long long
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
using namespace std;
signed main() {
    int k, n;
    cin >> k >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    int diff;
    int max = min(a[n - 1] - a[0], k - a[n - 1] + a[0]);
    rep(i, n - 1) {
        diff = a[i + 1] - a[i];
        if(max < diff) max = diff;
    }
    cout << k - max << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
const int INF = 0x3f3f3f3f;
const int N = 100005;
#define ll long long
int cmp(int a,int b){
	return a>b;
}	
int gcd(int x, int y)
{
    while(y^=x^=y^=x%=y);
    return x;
}
int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int f=0;
	while(a>0 && c >0){
		if(f%2){
			a-=d;
			f++;			
		}else{
			c-=b;
			f++;
		}
	}
	if(a<=0) {
		cout << "No";
	}else{
		cout <<"Yes";
	}
	return 0;
}



Measured memory_bytes: 3596
// D - XOR World
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll f0(ll n){//f(0,n)
	ll c = 0;
	for(int bit=0; (n>>bit)>0; ++bit){
		ll T = 1LL<<(bit + 1);//cycle
		ll H = T>>1LL;//half cycle
		ll a = (n+1)/T*H;
		ll b = max(0LL, (n+1)%T-H);
		if((a+b)&1LL) c |= 1LL<<bit;//odd -> bit on
	}
	return c;
}

ll f(ll A, ll B){
	return f0(B) ^ f0(A-1);
}

int main(){
	ll A,B; cin>>A>>B;
	cout<<  f(A,B) <<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<char> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
     if(a[i]=='Y'){
       cout<<"Four"<<endl;
       return 0;
     }
  }
  cout<<"Three"<<endl;
}


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

int main()
{
	long long int N;

	cin >> N;

	long long int d[N];

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

	long long int ans = 0;

	for (long long int i = 0; i < N; i++)
	{
		for (long long int j = i + 1; j < N; j++)
		{
			ans += d[i] * d[j];
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
// Starting with the name of Allah

#include <bits/stdc++.h>
#define ll long long
#define nl endl
#define pi 3.14159265358979323846264338
#define flash_all ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

using namespace std;

const int mxN=2e5;
const int Max=1000000000000000000;

int main()
{
	ll n,i;
	long double sum=1;
	cin>>n;
	ll t;
	for(i=0;i<n;i++){
		cin>>t;
		if(sum!=-1){
			sum=sum*t;
		}
		if(sum>1000000000000000000 || sum<0){
			sum=-1;
		}
		if(t==0){
			sum=0;
		}
	}
	cout<<(ll)sum<<nl;
	return 0;
}
//Happy Coading.....


Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
typedef long long ll;

int main()
{
	int n; cin >> n;
	vector<int > A(n);
	rep(i,n)cin >> A[i];
	sort (A.begin(),A.end());
	int count =0;
	vector<int >a;
	rep(i,n)
	{
		int l=1;
		while(A[i]==A[i+1])
		{
			
			l++;
			i++;
		}
		//cout<<l<<endl;
		a.push_back(l);
	}
	rep(i,a.size())
	count+=a[i]%2;
	cout<<count<<endl;


	return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
    	int N, M; cin >> N >> M;
     
    	vector<vector<int>> vec(M);
     
    	for (int i = 0; i < M; ++i) {
    		int k; cin >> k;
    		vec[i].resize(k);
    		for (int j = 0; j < k; ++j) {
    			cin >> vec[i][j];
    			--vec[i][j];
    		}
    	}
     
    	vector<int> p(M);
    	for (int i = 0; i < M; ++i) cin >> p[i];
     
    	int ans = 0;
    	for (int i = 0; i < (1 << N); ++i) {
    		bool ok = true;
    		for (int j = 0; j < M; ++j) {
    			int c = 0;
    			for (int id : vec[j]) {
    				if ((i >> id) & 1) {
    					++c;
    				}
    			}
    			c %= 2;
    			if (c != p[j]) {
    				ok = false;
    			}
    		}
    		if (ok) {
    			++ans;
    		}
    	}
     
    	cout << ans << endl;
     
    	return 0;
    }

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

signed main(){

  string s,t;
  char tmp;

  cin >> s  >> t;

  for(int i=0; s[i]!=0; i++){
    for(int j=i+1; s[j]!=0; j++){
      if(s[i]>s[j]){
        tmp = s[i];
        s[i] = s[j];
        s[j] = tmp;
      }
    }
  }

  for(int i=0; t[i]!=0; i++){
    for(int j=i+1; t[j]!=0; j++){
      if(t[i]<t[j]){
        tmp = t[i];
        t[i] = t[j];
        t[j] = tmp;
      }
    }
  }

  int l;

  if(s.length() > t.length()){
    l = s.length();
  }else{
    l = t.length();
  }

  for(int i=0;i<l;i++){
    if(s[i] == t[i]){
    }else if(s[i] > t[i]){
      cout << "No" << endl;
      break;
    }else if(s[i] < t[i]){
      cout << "Yes" << endl;
      break;
    }
    if(i == l-1){
      if(s.length() >= t.length()){
        cout << "No" << endl;
      }else{
        cout << "Yes" << endl;
      }
    }
  } 

    

//  cout << s << "\n"<< t<< endl;






}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
const int maxx = 12497505;
int n;
string st;
char a[maxx];
int num[maxx];
vector<int> adjlist[maxx];
int ct = 1;
int ans = 0;
void process(string s){
    //cout << s << endl;
    int len = s.size();
    int cur = 0;
    for (int i = 0; i < len; i++){
        //printf("%c\n",a[cur]);
        int found = -1;
        for (auto x : adjlist[cur]){
            if (a[x] == s[i]){
                found = x; break;
            }
        }
        if (found != -1){
            cur = found;
        }
        else{
            a[ct] = s[i];
            adjlist[cur].push_back(ct);
            cur = ct;
            ct++;
        }
        if (num[cur] != -1 && len-num[cur] >= i+1){
            //printf("%d %d %d can\n",num[cur],len,i+1);
            ans = max(ans,i+1);
        }
        else if (num[cur] == -1) num[cur] = len;
    }
}
int main(){
    memset(num,-1,sizeof(num));
    num[0] = 0;
    int n;
    scanf("%d",&n);
    string st;
    cin >> st;
    a[0] = '$';
    for (int i = n-1; i >= 0; i--){
        string x = st.substr(i,n);
        process(x);
    }
    printf("%d\n",ans);
    return 0;

}


Measured memory_bytes: 744448
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;

int main(){
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    int cnt = 0;
    for(int i = 0; i < N; i++){
        if(S[i] == 'I')cnt++;
        else cnt--;
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n=int(input())
X=[[] for _ in range(n)]
for i in range(n-1):
    u,v,w=map(int,input().split())
    X[u-1].append([v-1,w])
    X[v-1].append([u-1,w])
C=[-1]*n
q=[[0,0]]


while q:
    v,w=q.pop()
    if w%2==0:
        C[v]=0
    else:
        C[v]=1
    for pv,pw in X[v]:
        if C[pv]==-1:
            q.append([pv,pw+w])

for c in C:
    print(c)
    

Measured memory_bytes: 45012
#include <stdio.h>
int main (){
	int a,b,c,satu,dua;
	scanf ("%d %d %d", &a,&b,&c);
	satu=b-a;
	dua=c-b;
	if (satu==dua){
		printf ("YES\n");
	}else printf ("NO\n");
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>

int main(){
  int *a,*b,*c;
  int n,i,j,max=-1;
  scanf("%d",&n);
  a=(int *)malloc((n+1)*sizeof(int));
  b=(int *)malloc((n+1)*sizeof(int));
 
  
  for(i=1;i<n+1;i++){
    scanf("%d",&a[i]);
    if(a[i]>=max)max=a[i]; 
  }
  c=(int *)malloc((max+1)*sizeof(int));
   for(i=0;i<max+1;i++){
     c[i]=0;
   }
   for(j=1;j<=n;j++){
   c[a[j]]++;
   }   
   for(i=1;i<max+1;i++){
     c[i]=c[i]+c[i-1];
   }
   for(j=n;j>=1;j--){
     b[c[a[j]]]=a[j];
     c[a[j]]--;
   }
   for(i=1;i<=n-1;i++){
     printf("%d ",b[i]);
   }
   printf("%d\n",b[i]);
   free(a);
   free(b);
   free(c);
   return 0;
}
     

  



Measured memory_bytes: 17124
#include<iostream>


using namespace std;
int n;
int M[100][100];

int prim() {
	int u;
	int color[100];
	int d[100];
	int p[100];
	int mincost;
	for (int i = 0;i < n;i++) {
		color[i] = 0;
		d[i] =2001;
		p[i] = -1;
	}
	d[0] = 0;
	

	while (true) {
		mincost = 2001;
		for (int i = 0;i < n;i++) {
			if (color[i] != 2 && d[i] < mincost) {
				mincost = d[i];
				u = i;
			}
		}
		if (mincost== 2001) {
			break;
		}

		color[u] = 2;
		for (int v = 0;v < n;v++) {
			if (color[v] != 2 && M[u][v] != -1) {
				if (M[u][v] < d[v]) {
					d[v] = M[u][v];
					p[v] = u;
					color[v] = 1;
				}
			}
		}
	}
	int sum = 0;
	for (int i = 0;i < n;i++) {
		if (p[i] != -1) {
			sum += M[i][p[i]];
		}
	}
	return sum;

}

int main() {
	cin >> n;
	for (int i = 0;i < n;i++) {
		for (int j = 0;j < n;j++) {
			int e;
			cin >> e;
			M[i][j] = e;
		}
	}
	cout << prim() << endl;

	return 0;
}




Measured memory_bytes: 3128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
#define PI 3.14159265359
#define MOD 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

int main(){

    int a,b;
    cin >> a >> b;
    cout << a*b sp 2*(a+b) << endl;
    return 0;
}


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

using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 2e5 + 5;
const ll MOD = 1e9+7;

int parent[N];

int gcd(int a, int b) { 
    if (a == 0) 
        return b;  
    return gcd(b%a, a);  
} 
   
int lcm(int a, int b) {  
    return (a*b)/gcd(a,b);  
} 

ll pow(ll x, ll y, ll p) {
    if(y == 0) return 1;
    ll res = 1;
    x %= p;
    if(x == 0) return 0LL;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y >>= 1;
        x = (x*x) % p;
    }
    return res;
}

int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}

void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}

void solve() {
    int n;
    cin >> n;
    int d = n % 1000;
    if(d == 0) {
        cout << 0 << endl;
        return;
    }
    cout << (1000 - d) << endl;
    return;
} 

int main()
{
    IOS
    //int t;
    //cin >> t;
    //while(t--) 
    solve();
    return 0; 
}


Measured memory_bytes: 3620
N = input()
# N, M = map(int, input().split())
# X = [[] for _ in range(N)]
# for i in range(N):
#     X[i] = list(map(int, input().split()))

if N[-1] == '3':
    print('bon')
elif N[-1] == '0' or  N[-1] == '1' or N[-1] == '6' or  N[-1] == '8':
    print('pon')
else:
    print('hon')

Measured memory_bytes: 9100
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

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

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


int main() {
    ll N;
    cin >> N;
    vector<ll> a(N);
    rep(i,N){
        cin >> a[i];
    }

    ll count=0,index=1;
    rep(i,N){
        if(a[i] == index){
            index++;
        }else{
            count++;
        }
    }
    if(index == 1){
        cout << -1 << endl;
    }else{
        cout << count << endl;
    }

    
}



Measured memory_bytes: 4840
n,k=[int(i) for i in input().split()]
d=[int(i) for i in input().split()]

def check(num):
    for i in range(len(num)):
        for j in d:
            if int(num[i])==j:
                return False
    return True

while(not check(str(n))):
    n+=1
print(n)

Measured memory_bytes: 3064
def main():
    import math
    a, b, h, m = map(int, input().split())

    ht = (h/12+m/12/60)*2*math.pi
    mt = 2*math.pi*m/60
    if ht > mt:
        t = ht-mt
    else:
        t = mt-ht
    if t > math.pi:
        t = 2*math.pi-t
    c = a**2+b**2-2*a*b*math.cos(t)
    print(c**0.5)


main()

Measured memory_bytes: 9512
Imports System.Collections.Generic
Imports System.Console
Imports System.Math  
Module Program
    Function primeFactor(n As Long) As Dictionary(Of Long, Integer)
    Dim res As New Dictionary(Of Long, Integer)
        Dim i As Long = 2
        While i*i<=n 
            While (n Mod i) = 0
                If res.ContainsKey(i) Then
                    res(i) = res(i)+1
                Else
                    res.Add(i,1)
                End If
                n/=i
            End While
            i+=1
        End While
        If n <> 1 Then
                If res.ContainsKey(n) Then
                    res(n) = res(n)+1
                Else
                    res.Add(n,1)
                End If
        End If
        Return res
    End Function

 	Sub Main()
        Dim input() As String = Console.ReadLine().Split(" ")
        Dim N As Long = input(0)
        Dim P As Long  = input(1)
        Dim maxd As Long = 1
        Dim pf As Dictionary(Of Long, Integer) = primeFactor(P)
        For Each d As Long in pf.Keys
            Dim count As Integer = pf(d)
            While count >= N
                maxd *= d
                count -=N
            End While
        Next
        Console.WriteLine(maxd)
    End Sub
End Module


Measured memory_bytes: 13280
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

struct P
{
	int x, y;
	P() : x(0), y(0) {}
	P(int x, int y) : x(x), y(y){}
};
P operator + (P& a, P& b)
{	return P(a.x + b.x, a.y + b.y);	}

P dp[] = {P(-2, -1), P(-2, 0), P(-2, 1), P(-1, 2), P(0, 2), P(1, 2), P(2, 1), P(2, 0), P(2, -1), P(1, -2), P(0, -2), P(-1, -2)};
int n;

inline bool range(P& s, P& p)
{
	return (0 <= p.x && p.x < 10 && 0 <= p.y && p.y < 10) && (s.x - 1 <= p.x && p.x <= s.x + 1 && s.y - 1 <= p.y && p.y <= s.y + 1);
}

bool rec(vector<P>& s, int ns, P p)
{
	if(ns == n) return true;
	
	
	bool res = false;
	
	rep(i, 12)
	{
		P np = p + dp[i];
		
		if(range(s[ns], np))
		{
			res |= rec(s, ns + 1, np);
		}
	}
	
	return res;
}

int main()
{
    P p;
	while(cin >> p.x >> p.y && (p.x || p.y))
	{
		cin >> n;
		
		vector<P> s(n);
		rep(i, n) cin >> s[i].x >> s[i].y;
		
		cout << (rec(s, 0, p) ? "OK" : "NA") << endl;
	}
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int k = 0;
		int l = s.length();
		for(int j = 0; j < l; j++ ) {
			s = s.substring(0, s.length() - 1);
				if (s.substring(0, s.length() / 2).equals(s.substring(s.length() / 2))){
					k = s.length();
					break;
				}
		}
		System.out.println(k);
	}
}

Measured memory_bytes: 23124
#include<iostream>
#include<cstdio>
#define Lens 105
using namespace std;
int N;
int A[Lens][Lens];

int main()
{
	cin >> N;
	for (int i = 1; i <= N; i++)
	{
		int k, n;
		cin >> k >> n;
		for (int i = 0; i < n; i++)
		{
			int j;
			cin >> j;
			A[k][j] = 1;
		}
	}
	for (int i = 1; i <= N; i++)
	{
		for (int j = 1; j <= N; j++)
		{
			if (j > 1)
				cout << ' ';
			cout << A[i][j];
		}
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;
int n;
long long x;
long long p[60];
long long num[60];

long long cal(long long k,long long j){
    if(k==0){
        if(j<=0){
            return 0;
        }else{
            return 1;
        }
    }else if(j==1){
        return 0;
    }else if(j>1&&j<=num[k-1]+1){
        return cal(k-1,j-1);
    }else if(j==num[k-1]+2){
        return p[k-1]+1;
    }else{
        return p[k-1]+1+cal(k-1,j-2-num[k-1]);
    }
}

int main(){
    cin >> n >> x;
    p[0] = 1;
    num[0] = 1; 
    for(int i=1;i<50;i++){
        p[i] = p[i-1]*2+1;
        num[i] = num[i-1]*2+3;
    }
    cout << cal(n,x) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  
  int n,ans;
  scanf("%d",&n);
  
  if(n <= 111) ans = 111;
  else if(n > 111&&n <= 222) ans = 222;
  else if(n > 222&&n <= 333) ans = 333;
  else if(n > 333&&n <= 444) ans = 444;
  else if(n > 444&&n <= 555) ans = 555;
  else if(n > 555&&n <= 666) ans = 666;
  else if(n > 666&&n <= 777) ans = 777;
  else if(n > 777&&n <= 888) ans = 888;
  else if(n > 888&&n <= 999) ans = 999;
  
  printf("%d",ans);
  
  return 0;
  
}
  

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int n,i,j,f[(1<<26)+5],ans,c[212345];
string s;
int main()
{
	cin>>s;
	s=" "+s;
	n=s.size();
	for (i=1;i<n;i++)
	{
		c[i]=c[i-1]^(1<<(s[i]-'a'));
	}
	if (!c[n-1]){cout<<"1\n";return 0;}
	memset(f,50,sizeof(f));
	f[0]=0;
	for (i=1;i<n;i++)
	{
		ans=n+n+n+n+345;
		for (j=0;j<26;j++)
		{
			ans=min(ans,f[c[i]^(1<<j)]+1);
		}
		f[c[i]]=min(f[c[i]],ans);
	}
	cout<<f[c[n-1]]<<endl;
	return 0;
}

Measured memory_bytes: 263616
#include <stdio.h>
#include <string.h>

char s[101];

int main()
{
    fgets(s, 100, stdin);

    int i=0, cnt=0;

    while(s[i]!='\0' && cnt<1)
    {
        if(s[i+1]==32){ i ++; cnt++; }
        i++;
    }

    printf("A%cC\n", s[i]);

    return 0;

}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
using namespace std;

int GCD(int x,int y){
	if( y == 0){
		return x;
	}
	return GCD(y, x % y);
}

bool isPrime(int N){
	if( N == 2 ) true;
	if( N % 2 == 0) false;
	for(int i = 2; i*i <= N; i++){
		if(GCD(N,i) != 1) return false;
	}
	return true;
}

int main()
{
	int n;
	cin >> n ;
	int primeNumberCount = 0;
	for(int i = 0; i < n ; i++){
		int num;
		cin >> num;
		if( isPrime(num) == true) primeNumberCount++;
	}
	cout << primeNumberCount<<endl;
	return 0;
}





Measured memory_bytes: 3084
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            new Main().solve(sc);
        }
    }

    void solve(Scanner sc) {
        int n = sc.nextInt();
        int currentT = 0;
        int currentX = 0;
        int currentY = 0;
        for (int i = 0; i < n; i++) {
            int t = sc.nextInt();
            int x = sc.nextInt();
            int y = sc.nextInt();

            int timeDistance = t - currentT;
            int manhattanDistance = Math.abs(x - currentX) + Math.abs(y - currentY);

            if (manhattanDistance > timeDistance || timeDistance % 2 == 0 && manhattanDistance % 2 == 1
                    || timeDistance % 2 == 1 && manhattanDistance % 2 == 0) {
                System.out.println("No");
                return;
            }

            currentT = t;
            currentX = x;
            currentY = y;
        }
        System.out.println("Yes");
    }
}


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

int main() {

	string s; cin >> s;
	int left = stoi(s.substr(0, 2));
	int right = stoi(s.substr(2));
	string ans;
	if (left == 0) {
		if (right == 0) ans = "NA";
		else if (right <= 12) ans = "YYMM";
		else ans = "NA";
	}
	else if (left <= 12) {
		if (right == 0) ans = "MMYY";
		else if (right <= 12) ans = "AMBIGUOUS";
		else ans = "MMYY";
	}
	else {
		if (right == 0) ans = "NA";
		else if (right <= 12) ans = "YYMM";
		else ans = "NA";

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

Measured memory_bytes: 3480
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
ll oo = 0x3f3f3f3f3f3f3f3f;

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  int n, A = 0, B = 0, C = 0;
  cin >> n;
  
  for(int i = 0, a, b, c; i < n; ++i)
  {
  	cin >> a >> b >> c;
    a = a + max(B,C);
    b = b + max(A,C);
    c = c + max(A,B);
    A = a, B = b, C = c;
  }
  
  cout << max(A,max(B,C)) << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
//#include <stdlib.h>
#define NOT_FOUND -1

int linearSearch(int *,int );

int n,q;

int main(){
  int i,x=0,z;
  int s[10000],t[500];

  scanf("%d",&n);
  //s = (int *)malloc(sizeof(int)*n);

  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
 
  scanf("%d",&q);
  //t = (int *)malloc(sizeof(int)*q);

  for(i=0;i<q;i++){
    scanf("%d",&t[i]);
  }

  for(i=0;i<q;i++){
    z = linearSearch(s,t[i]);
    if(z != NOT_FOUND) x++;
  }

  printf("%d\n",x);
  
  //free(s);
  //free(t);
  
  return 0;
}

int linearSearch(int *s,int t)
{
  int i = 0;

    s[n] = t;
    while(s[i] != t){
      i++;
    }
      if(i == n) return NOT_FOUND;
      else return i;
}

Measured memory_bytes: 640