akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
int MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

const int DEB = 0;
const int MX = DEB? 1<<5 : 1<<15;
const int MM = 1000000007;

int A[MX], B[MX];

int G[15][15];
int tmp[MX];
int pw2[MX];
int N, M;

void solve(int c, int A[MX]){
	for(int t = 0; t < MX; t++){
		if(~t&c) continue;
		int cnt = tmp[t];
		A[t] = pw2[cnt];
		for(int u = t; u; u = (u-1)&t){
			if(~u&c || u == t) continue;
			int v = t^u, cnt = tmp[v];
			A[t] = (A[t] - (ll)pw2[cnt] * A[u] % MM + MM) % MM;
		}
	}
}

int main()
{
	pw2[0] = 1;
	for(int i = 1; i < MX; i++) pw2[i] = pw2[i-1] * 2 % MM;
	scanf("%d%d", &N, &M);
	for(int i = 1; i <= M; i++){
		int a, b;
		scanf("%d%d", &a, &b); a--, b--;
		G[a][b] = 1;
	}
	if( G[0][1] || G[1][0] ) return !printf("%d\n", pw2[M]);
	for(int m = 1; m < MX; m++){
		for(int i = 0; i < N; i++){
			for(int j = 0; j < N; j++){
				if(m&1<<i&&m&1<<j) tmp[m] += G[i][j];
			}
		}
	}
	solve(1, A);
	solve(2, B);

	ll ans = 0;
	for(int i = 0; i < MX; i++){
		for(int j = i; j; j = (j-1)&i){
			int p = j, q = i^j, r = (MX-1)^i;
			if(~p&1 || ~q&2 ) continue;
			int cnt = 0, tp = 1;
			for(int i = 0; i < N; i++){
				for(int j = 0; j < N; j++){
					if(r&1<<i&&r&1<<j) cnt += G[i][j];
					if(p&1<<i&&q&1<<j && (G[i][j] || G[j][i])) tp = 0;
				}
			}
			ans = (ans + (ll)tp* pw2[cnt] * A[p] % MM * B[q]) % MM;
		}
	}
	printf("%lld\n", (pw2[M] - ans + MM) % MM);
}


Measured memory_bytes: 768
num_list = [int(i) for i in input().split()]
min_list = []

if num_list[0] < num_list[1]:
    if (num_list[1] - num_list[0]) < num_list[0]:
        print(num_list[1] - num_list[0])
    else:
        print(num_list[0])
elif num_list[0] == num_list[1]:
    print(0)
elif num_list[1] % num_list[0] == 0:
    print(0)
else:
    kake_num = num_list[0] // num_list[1]
    check_num = num_list[0] - (num_list[1]*kake_num)
    min_list.append(check_num)
    min_list.append((num_list[1] - check_num))
    print(min(min_list))

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

const double INF = 1e+7;

int n;
double x[50010],r[50010];

bool check(double y){
	vector<pair<double,bool>> vec;
	for(int i = 0;i < n;i++){
		double sq = r[i] * r[i] - y * y / 4;
		if(sq > 0){
			vec.emplace_back(x[i] - sqrt(sq),0);
			vec.emplace_back(x[i] + sqrt(sq),1);
		}
	}
	sort(vec.begin(),vec.end());
	double ma = 0,prv;
	int cnt = 0;
	for(auto p : vec){
		if(!p.second){
			cnt++;
			if(cnt == 1) prv = p.first;
		}else{
			cnt--;
			if(!cnt) ma = max(ma,p.first - prv);
		}
	}
	return ma >= y;
}

void solve(){
	for(int i = 0;i < n;i++) cin >> x[i] >> r[i];
	double ok = 0,ng = INF;
	for(int i = 0;i < 50;i++){
		double mid = (ok + ng) / 2;
		if(check(mid)) ok = mid;
		else ng = mid;
	}
	printf("%.15lf\n",ok);
}

signed main(){
	while(cin >> n,n) solve();
}


Measured memory_bytes: 7364
#include <iostream>
using namespace  std;
int n,k,i,j;
int main() 
{
  cin>>n>>k;
  int h;
  for(i=0;i<n;i++)
  {
    cin>>h;
    if(h>=k)
    {
      j++;
    }

  }
  cout<<j;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<unordered_map>
#include<map>
#include<cmath>

using namespace std;

const int w_max=1e9+1;
const int v_max=1e5+10;
const int size=1e2+1;
int memo[v_max][size];
bool vis[v_max][size];
int v[size];
int w[size];

int n,w_tot;

int dp(int vtmp,int i){
  if(vtmp<=0)
    return 0;
  if(i==n)
    return w_max;
  if(vis[vtmp][i])
    return memo[vtmp][i];

  vis[vtmp][i]=1;

  return memo[vtmp][i]=min(dp(vtmp,i+1),w[i]+dp(vtmp-v[i],i+1));

}

int answer(int v_tot){
  int ans=0;
  for(int i=v_tot;i>=0;i--){
    if(dp(i,0)<=w_tot)
      return i;
  }
  return 0;
}

int main(){

  scanf("%d %d",&n,&w_tot);
  int v_tot=0;
  for(int i=0;i<n;i++){
    scanf("%d %d",&w[i],&v[i]);
    v_tot+=v[i];
  }
  printf("%d\n",answer(v_tot));


  return 0;
}


Measured memory_bytes: 49408
s = input()

if int(s[:4]) < 2019:
    print("Heisei")
elif int(s[:4]) > 2019:
    print("TBD")
else:
    if int(s[5:7]) <= 4:
        print("Heisei")
    elif int(s[5:7]) > 4:
        print("TBD")

Measured memory_bytes: 9112
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#define rep(i, l, r) for (register int i = l; i <= r; i++) 
#define LL long long int
#define maxn 500005
using namespace std;
int n;
int num[30];
char s[maxn];
int main(){
    scanf("%s", s);
    n = strlen(s);
    rep(i, 0, n - 1) num[s[i] - 'a']++;
    LL tot = 0;
    rep(i, 0, 25) tot += (LL) num[i] * (n - num[i]);
    printf("%lld", (tot >> 1) + 1);
}

Measured memory_bytes: 384
var lines = [];

var N, M, ans = 0, xyz = []
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', (x) => {
    lines.push(x);
});

rl.on('close', () => {

    N = Number(lines[0].split(" ")[0]);
    M = Number(lines[0].split(" ")[1]);

    lines.shift();

    xyz = lines.map(value => value.split(" ").map(value => Number(value)));

    dfs(0, []);
    console.log(ans);
});

function dfs(n, comb) {
    if (n === 3) { calc(comb); }
    else {
        for (var i = 0; i < 2; i++) {
            comb[n] = i;
            dfs(n + 1, comb);
        }
    }
    return (0);
}

function calc(comb) {

    var result = 0;
    var cake = Array(N).fill(0);

    for (var i = 0; i < N; i++) {
        cake[i] = (comb[0] === 0 ? xyz[i][0] : xyz[i][0] * (-1)) + (comb[1] === 0 ? xyz[i][1] : xyz[i][1] * (-1)) + (comb[2] === 0 ? xyz[i][2] : xyz[i][2] * (-1));
    }
    cake.sort((a, b) => b - a)

    for (var i = 0; i < M; i++) { result += cake[i] }

    ans = Math.max(ans, result);
    return (0)
}

Measured memory_bytes: 11256
n,m = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for j in range(n)]
b = [int(input()) for i in range(m)]

for i in range(n):
    c = 0
    for j in range(m):
        c += A[i][j]*b[j]
    print(c)


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

int main()
{
  int N, X, T;
  cin >> N >> X >> T;

  if(N % X == 0)
  {
    cout << N / X * T << endl;
  }
  else
  {
    cout << ( N / X + 1) * T << endl;
  }
}

Measured memory_bytes: 3620
#include<stdio.h>

int main() {
	int a, b;
	
	//?????¨?¨??????\???
	scanf("%d %d", &a, &b);

	//    ??¢??? = ???*?¨?
	//??¨????????? = 2*(???+?¨?)
	printf("%d %d\n", a*b, 2 * (a + b));
	
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<(int)c;i++)
#define print(var) cout<<var<<endl;
#define DEBUG(var) cerr<<var<<endl;
#define ll long long
// puts("str");

const int inf = 1000000000;//10^9

vector<pair<ll,ll> > prime_factorize(ll N) {
    vector<pair<ll,ll> > res;
    for (ll a = 2; a * a <= N; a++) {
        if (N % a != 0) continue;
        long long ex = 0;


        while (N % a == 0) {
            ex++;
            N /= a;
        }

        res.push_back({a, ex});
    }

    if (N != 1) res.push_back({N, 1});
    return res;
}

int count(int n){
  int count=0;
  for(int i=1;n>=0;i++){
    n-=i;
    count++;
  }
  return count-1;
}


int main (){
  ll N;
  cin>>N;
  int ans=0;
  vector<pair<ll,ll>> factor;
  factor=prime_factorize(N);
  rep(i,factor.size()){
    ans+=count(factor[i].second);
  }
  print(ans);


  return 0;

}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <math.h>
#include <set>
#include <stack>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <unordered_set>
#include <unordered_map>
#define DEBUG
#define fi first
#define se second
#define pqueue priority_queue
#define pb(x) push_back(x)
#define endl '\n'
#define all(x) x.begin(), x.end()
#define int long long
#define mk(a, b) make_pair(a, b)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ull> vull;
typedef vector<ll> vll;
// typedef tuple<int, int, int> tiii;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector< vector<int> > vvi;
typedef vector<char> vc;

const int INF = 1e9;
const ll INFLL = 1e16;
const int MOD = 1000000007;
const int MAXN = 3e5;
//const ld eps = 1e-6;
const ld eps2 = 1e-9;
const int MOD2 = 998244353;
const int dosz = 5e5;
const int SZ = (1<<18);
const ld PI = atan2l(0, -1);


void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#ifdef DEBUG
        // freopen("a.in", "r",stdin);
#else
       // freopen("mxnl.in", "r", stdin);
       // freopen("mxnl.out", "w", stdout);
#endif
}

void solve(){
    int n, m;
    cin >> n >> m;
    vs kek(n);
    for(string &s:kek)
        cin >> s;
    vvi dp(n, vi(m, INFLL));
    dp[0][0] = (kek[0][0] == '#');
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            if(i<n-1)
                dp[i+1][j] = min(dp[i+1][j], dp[i][j] + (kek[i][j]=='.' && kek[i+1][j]=='#'));
            if(j<m-1)
                dp[i][j+1] = min(dp[i][j+1], dp[i][j] + (kek[i][j]=='.' && kek[i][j+1]=='#'));   
        }
    }
    cout << dp[n-1][m-1];

}

signed main() {
    fast_io();
    int q = 1;
    // cout << fixed << setprecision(6);
    // cin >> q;
    // cout << 1 << endl;
    while(q--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 892
#include"stdio.h"

int main(void)
{
    int a,b,c;
    int answer[3];

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

    if(a>=b&&a>=c&&b>=c)
    {
        answer[0]=c,answer[1]=b,answer[2]=a;
    }
    if(a>=b&&a>=c&&c>=b)
    {
        answer[0]=b,answer[1]=c,answer[2]=a;
    }
    if(b>=a&&b>=c&&a>=c)
    {
        answer[0]=c;answer[1]=a;answer[2]=b;
    }
    if(b>=a&&b>=c&&c>=a)
    {
        answer[0]=a;answer[1]=c;answer[2]=b;
    }
    if(c>=a&&c>=b&&a>=b)
    {
        answer[0]=b;answer[1]=a;answer[2]=c;
    }
    if(c>=a&&c>=b&&b>=a)
    {
        answer[0]=a;answer[1]=b;answer[2]=c;
    }

    printf("%d %d %d\n",answer[0],answer[1],answer[2]);


    return 0;

}


Measured memory_bytes: 2732
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint A, B, C, K; cin >> A >> B >> C >> K;
    lint num_As = min(K, A);
    lint num_Bs = min(K - num_As, B);
    lint num_Cs = K - num_As - num_Bs;
    cout << num_As - num_Cs << "\n";
}

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

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

Measured memory_bytes: 3624
import sys
input=sys.stdin.readline
s=input().rstrip()
n=len(s)
for i in range(n):
    if i%2==0:
        if s[i]=='L':
            print('No')
            sys.exit()
    else:
        if s[i]=='R':
            print('No')
            sys.exit()
print('Yes')




            



Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int H, W, res;
char c;
vector<int>v[1000];

int main() {
	cin >> H >> W;
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cin >> c;
			if (c == 'B') {
				v[i].push_back(j);
			}
		}
	}
	for (int i = 0; i < H; ++i) {
		if (!v[i].empty()) {
			for (int j = 0; j < H; ++j) {
				if (!v[j].empty()) {
					res = max(res, abs(i - j) + max(abs(v[i].front() - v[j].back()), abs(v[i].back() - v[j].front())));
				}
			}
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define forn(i,n) for(int i=0;i<(int) n;i++)
#define Forn(i,n) for(int i=1;i<=(int) n;i++)
#define M 100005

int main()
{
int n,i,c=0,AC=0,WA=0,TLE=0,RE=0;
cin>>n;
 for(i=0;i<n;i++)
 {
     string s;
     cin>>s;
     if(s=="AC") AC++;
     else if(s=="WA") WA++;
     else if(s=="TLE") TLE++;
     else if(s=="RE") RE++;

 }
 printf("AC x %d\n",AC);
  printf("WA x %d\n",WA);
   printf("TLE x %d\n",TLE);
    printf("RE x %d\n",RE);


}






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

using namespace std;

#define REP(a, b, c) for (register int a = b, _n = c; a <= _n; ++a)
#define DREP(a, b, c) for (register int a = b, _n = c; a >= _n; --a)
#define FOR(a, b, c) for (register int a = b, _n = c; a < _n; ++a)
#define DFOR(a, b, c) for (register int a = b, _n = c; a > _n; --a)
#define EREP(a, b) for (register int a = head[b]; a; a = edge[a].nxt)

inline int rd () {
	int x = 0; char IO = getchar();
	bool f = 0;
	while ((IO < '0' || IO > '9') && IO != '-') IO = getchar();
	if (IO == '-') f = 1, IO = getchar();
	while (IO >= '0' && IO <= '9') x = (x << 3) + (x << 1) + (IO ^ 48), IO = getchar();
	return f ? -x : x;
}

long long n;

int main () {
   cin >> n;

   cout << n * (n - 1) / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
function Main(input) {
  const S = input.split("\n")[0]
  var result = ''
  if (S.length === 2) {
    for (var i = 0; i < S.length; i++) {
      result += S[i]
    }
  } else {
    for (var i = S.length - 1; i >= 0; i--) {
      result += S[i]
    }
  }
  console.log(result)
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"))

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

int main() {
  int a,b;
  cin >> a >> b;
   
  int c = a * b;
  
  if(c % 2 ==0){
    cout << "Even" << endl;
  }else{
  	cout << "Odd" << endl;
  } 
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main() {
  int a, b;
  int result = scanf("%d %d", &a, &b);
  
  if (result) {
    if (b % a == 0) {
      // aはbの約数
      printf("%d", a+b);
    } else {
      printf("%d", b-a);  
    }
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){

  int x, c_1, c_2, sum;
  scanf("%d", &x);
  c_1=x/500;
  c_2=(x-500*c_1)/5;
  sum=1000*c_1+5*c_2;
  printf("%d", sum);

  return 0;
}


Measured memory_bytes: 128
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a > mod)a %= mod;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	int a,b,c;
	cin>>a>>b>>c;
	cout<<c<<" "<<a<<" "<<b;	
	return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: String,
    }
    if s == "Sunny" {
        println!("Cloudy");
    } else if s == "Cloudy" {
        println!("Rainy");
    } else {
        println!("Sunny");
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<algorithm>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a - c) <= d) {
		cout << "Yes" << endl;
		return 0;
	}
	else if (abs(a - b) <= d && abs(b - c) <= d) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
//using System.Text;
//using System.Text.RegularExpressions;
//using System.Globalization;
//using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;
//using pair = Pair<int, int>;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;
    void chmax<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? b : a; }
    void chmin<T>(ref T a, T b) where T : IComparable<T> { a = a.CompareTo(b) < 0 ? a : b; }

    void solve()
    {
        int N = cin.nextint;
        var A = cin.scanint;
        var B = new long[N];

        for (int i = 0; i < N; i++)
        {
            while(A[i] % 2 == 0)
            {
                A[i] /= 2;
                B[i]++;
            }
        }
        WriteLine(B.Sum());
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 13268
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader buff = null;
		buff = new BufferedReader(new InputStreamReader(System.in));

		String[] box = buff.readLine().split(" ");
		long N = Long.parseLong(box[0]);
		long Y = Long.parseLong(box[1]);
		boolean flag = true;
		for (int i = 0; i <= N; ++i) {
			for (int j = 0; j <= N - i; ++j) {
				long tmp = 10000 * i + 5000 * j + 1000 * (N - i - j);
				if (Y == tmp) {
					flag = false;
					System.out.println(i + " " + j + " " + (N - i - j));
					break;
				}
			}
			if (flag == false) {
				break;
			}
		}
		if (flag) {
			System.out.println("-1 -1 -1");
		}
	}

	static long f() {
		long ans = 0;

		return ans;
	}
}

Measured memory_bytes: 23248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = ll(1e8+7);
const ll MAX_N = ll(1e5 + 5);
#define REP(i, n) for (int i = 0; i < n; i++)

//階乗と逆元を保持
ll factrial[MAX_N], inverse[MAX_N];

//繰り返し二乗法
ll mod_power(ll x, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % MOD;
        x = x * x % MOD;
        n >>= 1;
    }
    return res;
}
//前処理
void init(ll n) {
    factrial[0] = 1;
    inverse[0] = 1;
    for (ll i = 1; i <= n; i++) {
        //階乗を求める
        factrial[i] = (factrial[i - 1] * i) % MOD;
        //フェルマーの小定理で逆元を求める
        inverse[i] = mod_power(factrial[i], MOD - 2) % MOD;
    }
}
//クエリ
ll nCk(ll n, ll k) {
    if(n < 0 || k < 0 || n < k) return 0;
    return factrial[n] * inverse[k] % MOD * inverse[n - k] % MOD;
}

int main() {
    ll r,c,ai,aj,bi,bj;
    cin >> r >> c >> ai >> aj >> bi >> bj;
    vector<P> bs, mins;
    for(int i = -1; i<=1; ++i){
        for(int j = -1; j<=1; ++j){
            bs.push_back({bi+r*i,bj+c*j});
        }
    }
    ll dmin = 99999999;
    for(auto p : bs){
        if(abs(p.first - ai) + abs(p.second - aj) < dmin){
            mins.clear();
            mins.push_back({abs(p.first - ai), abs(p.second - aj)});
            dmin = abs(p.first - ai) + abs(p.second - aj);
        }
        else if(abs(p.first - ai) + abs(p.second - aj) == dmin){
            mins.push_back({abs(p.first - ai), abs(p.second - aj)});
        }
    }
    init(dmin);
    ll ans = 0;
    for(auto p : mins){
        ans += nCk(dmin, p.first);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3116
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

#define INF LLONG_MAX / 5
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define enld endl

signed main() {
	int X, N;
	cin >> X >> N;
	vector<int>P(N);
	rep(i, N) {
		cin >> P[i];
	}
	set<int>S;
	rep(i, N) {
		S.insert(P[i]);
	}
	int m = 100000;
	int ans = 0;
	for (int i = -1000; i <= 1000; i++) {
		if (!S.count(i)) {
			m = min(m, abs(X - i));
		}
	}
	for (int i = -1000; i <= 1000; i++) {
		if (abs(X - i) == m) {
			if (!S.count(i)) {
				cout << i << enld;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 3620
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

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;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
//#define int long long

signed main() {
    int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
        cout << *max_element(a.begin(), a.end()) -
                    *min_element(a.begin(), a.end())
             << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    for(int i = 0; i < s.size() - 1; i++){
        if(s[i] == 'A' && s[i + 1] == 'C')
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double ans[4747];
int main(){
  int n;
  cin>>n;
  double r[n],m;
  for(int i=0;i<n;i++){
    cin>>r[i];
    m=r[i];
    for(int j=0;j<i;j++){
      double s=r[i]+r[j],h=r[i]-r[j];
      m=max(m,ans[j]+sqrt(s*s-h*h));
    }
    ans[i]=m;
    //cout<<ans[i]<<endl;
  }
  double a=0;
  for(int i=0;i<n;i++)
    a=max(a,ans[i]+r[i]);
  printf("%.10f\n",a);
}

Measured memory_bytes: 3292
#include <stdio.h>

int main(void)
{
int h, w, i, j;
int a = 0;

while(a == 0){

 scanf("%d", &h);
 scanf("%d", &w);

if(h == 0)
break;

for(i = 0; i < h; i++){
 for(j = 0; j < w; j++){

if(i % 2 == 0 && j % 2 == 0 || i % 2 != 0 && j % 2 != 0)
 printf("#");
else
 printf(".");
}
 printf("\n");

}
 printf("\n");
}


return 0;

}




Measured memory_bytes: 1924
#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
#define MOD 1000000007
#define ull unsigned long long int
#define newline cout<<endl
 
 
/* TYPE DEFINITIONS */
typedef     long long int        ll;
typedef     vector<ll>     vi;
typedef     pair<ll,ll>   pi;
 
 
 
/* MATH */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 
 
ll pow(ll a,ll b)
{
   ll res=1;
    while(b>0)
    {
        if(b&1)res=(res*a);
        a=(a*a);
        b>>=1;
    }
    return res;
}
 
  
//
/* MACROS */
 
#define  all(A)         (A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)        (A).rbegin() , (A).rend()
#define  sz(A)          (int)(A).size()
#define  pb             push_back
#define  ppb            pop_back
#define  mp             make_pair
#define  ln(X)          (int)(X).length()
#define  square(X)      ((X)*(X))
#define  cube(X)        ((X)*(X)*(X))
#define  forn(i, n)     for (int i = 0; i < int(n); i++)
#define  forr(i, n)     for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)    for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)  
#define  deb(x)       cout << '>' << #x << ':' << x << endl;
vi pp;
void SieveOfEratosthenes(int n) 
{ 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          pp.pb(p);
} 
void solve()
{
    SieveOfEratosthenes(1000000);
    ll a;
    cin>>a;
    cout<<*lower_bound(all(pp),a)<<endl;

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

Measured memory_bytes: 2424
f ::Int -> Int
f x = if (length (filter (0/=) (map (x`mod`) [2..(ceiling (fromIntegral x/fromIntegral 2))]))) == ((ceiling (fromIntegral x/fromIntegral 2))-1)  then x else f (x+1)
main = do
 n<-readLn
 print$f (n)

Measured memory_bytes: 508
package main

import (
	"bufio"
	"errors"
	"fmt"
	"log"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

// キュー
type queue struct {
	wpos, rpos int
	len        int
	maxlen     int
	val        []interface{}
}

func (q *queue) init(v int) {
	q.maxlen = v
	q.len = 0
	q.wpos = 0
	q.rpos = 0
	q.val = make([]interface{}, v)
}

func (q *queue) push(v interface{}) {
	if q.len == q.maxlen {
		log.Fatal("queue is overflow")
	}
	q.val[q.wpos] = v
	q.wpos++
	q.len++
	if q.wpos == q.maxlen {
		q.wpos = 0
	}
}

func (q *queue) pop() (interface{}, error) {
	if q.len == 0 {
		return nil, errors.New("empty")
	}
	ret := q.val[q.rpos]
	q.len--
	q.rpos++
	if q.rpos == q.maxlen {
		q.rpos = 0
	}
	return ret, nil
}

func (q *queue) empty() bool {
	if q.len == 0 {
		return true
	}
	return false
}

func (q *queue) full() bool {
	if q.len == q.maxlen {
		return true
	}
	return false
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	K := getInt()

	var q queue
	q.init(300000)
	for i := 1; i < 10; i++ {
		q.push(i)
	}
	last := 0
	for i := 0; i < K; i++ {
		v, _ := q.pop()
		x := v.(int)
		// out(x)
		t := x % 10
		if t != 0 {
			q.push(x*10 + t - 1)
		}
		q.push(x*10 + t)
		if t != 9 {
			q.push(x*10 + t + 1)
		}
		last = x
	}
	out(last)
}


Measured memory_bytes: 7552
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	string topping;
	cin >> topping;
	int price = 700;
	for (int i = 0; i < 3; i++) {
		if (topping[i] == 'o') price += 100;
	}
	cout << price << endl;
	return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	pair<pair<string, int>, int> v[100];
	string s;
	int t;
	for (int i = 0; i < n; i++) {
		cin >> s >> t;
		v[i] = make_pair(make_pair(s, -t), i + 1);
	}
	sort(v, v + n);
	for (int i = 0; i < n; i++)
		cout << v[i].second << endl;
	return 0;
}


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

int n;
int d[100000];

int main()
{
	cin >> n;

	for (int i = 0; i < n; i++)
		cin >> d[i];

	sort(d, d + n);

	int m = n / 2;

	cout << d[m] - d[m - 1] << endl;

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}

void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main(){
  ll N,M;
  cin>>N>>M;
  vector<ll> P[N+1];
  ll A[M];
  ll B[M];
  rep(i,M){
    ll p,q;
    cin>>p>>q;
    A[i]=p;
    B[i]=q;
    P[p].push_back(q);
  }
  
  rep1(i,N){
    sort(P[i].begin(),P[i].end());
  }
  
  rep(i,M){
    ll an1=A[i];
    ll an2;
    ll pr=0;
    ll left=-1;
    ll right=P[an1].size();
    
    while(right-left>1){
      ll mid=left+(right-left)/2;
      if(P[an1][mid]>=B[i]) right=mid;
      else left=mid;
    }
    
    an2=right+1;
    
    string str1;
    while(an1>0){
      char c='0'+an1%10;
      str1=c+str1;
      an1/=10;
    }
    
    while(str1.size()<6){
      str1='0'+str1;
    }
    
    string str2;
    while(an2>0){
      char c='0'+an2%10;
      str2=c+str2;
      an2/=10;
    }
    
    while(str2.size()<6){
      str2='0'+str2;
    }
    
    string ans=str1+str2;
    cout<<ans<<endl;
  }
}
      
  
  
  
    
    

Measured memory_bytes: 8576
let solve a b =
  let c = int_of_float (ceil @@ sqrt (float_of_int (a * b)) -. 1.) in
  if abs (a-b) <= 1 then 2 * (min a b) - 2
  else if c * (c+1) >= a*b then 2*c - 2
  else 2*c - 1

let () =
  Scanf.scanf "%d" @@ fun q ->
  Array.init q (fun _ -> Scanf.scanf " %d %d" solve)
  |> Array.iter (Printf.printf "%d\n")

Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  ll t,s[SIZE],e[SIZE],r[SIZE] = {};
  int n;
  
  scanf("%lld%d",&t,&n);

  for(int i=0;i<n;i++){
    scanf("%lld%lld",s+i,e+i);
  }

  for(int i=1;i<n;i++){
    r[i] = s[i] - e[i-1] + r[i-1];
  }
  
  ll ans = 0;
  
  for(int i=0;i<n;i++){

    ll* it = upper_bound(s,s+n,s[i]+t);

    if(it == s){
      ans = max(ans,min(t,e[0]-s[0]));
    }else{
      it--;
      
      if(s[i]+t >= e[it-s])
        ans = max(ans, e[it-s]-s[i]-(r[it-s]-r[i]));
      else
        ans = max(ans, t-(r[it-s]-r[i]));
    }
  }

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

Measured memory_bytes: 5560
N = int(input())
ans = 1
*a, = map(int, input().split())
mod = 10**9+7

l = [[0,0,0] for _ in range(N+1)]
r, g, b = 0, 0, 0

for i, j in enumerate(a):
    if i:
        if j==0:
            if g==0:
                g += 1
            else:
                b += 1
        else:
            if r==j:
                r += 1
            elif g==j:
                g += 1
            elif b==j:
                b += 1
    else:
        r += 1
     
    l[i+1][0] = r
    l[i+1][1] = g
    l[i+1][2] = b

ans = 1
for i,j in zip(a, l):
    ans *= j.count(i)
    ans %= mod

print(ans)

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

int main(void){

  string s;
  cin >> s;

  if(s == "Sunny"){
    cout << "Cloudy" << endl;
  }

  else if(s == "Cloudy"){
    cout << "Rainy" << endl;
  }
  else{
    cout << "Sunny" << endl;
  }
  
  return 0;

}


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

using namespace std;

//#define int long long
#define sz(x) ((int) (x).size())

using ll = long long;

const int maxn = (int) 1e6 + 10;

int go[maxn][26];
int last = 0;
int counts[maxn][26];
int leaves[maxn];

void add(const string& s) {
    vector<int> b(26, -1);
    for (int i = 0; i < sz(s); ++i) {
        b[s[i] - 'a'] = i;
    }
    int node = 0;
    for (int i = 0; i < sz(s); ++i) {
        for (int j = 0; j < 26; ++j) {
            if (i <= b[j]) {
                ++counts[node][j];
            }
        }
        int c = s[i] - 'a';
        if (!go[node][c]) {
            go[node][c] = ++last;
        }
        node = go[node][c];
    }
    ++leaves[node];
}

ll ans = 0;

void solve() {
    for (int node = 0; node <= last; ++node) {
        for (int c = 0; c < 26; ++c) {
            if (!go[node][c]) continue;
            int to = go[node][c];
            ans += (ll) leaves[to] * (counts[node][c] - 1);
        }
    }
}

signed main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false); cin.tie(0);

    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        reverse(s.begin(), s.end());
        add(s);
    }
    solve();
    cout << ans << '\n';
}



Measured memory_bytes: 208788
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
    public static void main(String[] a) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		List<Integer> iList = new ArrayList<Integer>();

		// ????????????
		for (int i = 0 ; i < 10; i++) {
			iList.add(Integer.valueOf(br.readLine()));
		}

		// ????????????????????????
		Collections.sort(iList);
		for (int i = iList.size() - 1; i > iList.size() - 4; i--) {
			System.out.println(iList.get(i));
		}
    }
}

Measured memory_bytes: 24192
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
const int N1=1e9+1;


int32_t main()
{

    
    IOS;
    int N,W,ans=-1,v_max=0;

    cin>>N>>W;

    int w[N+1],v[N+1];
    for(int i=1;i<=N;i++)
    {
        cin>>w[i]>>v[i];
        v_max+=v[i];
    }      
    // cout<<v_max;
    int dp[N+1][v_max+1];

    for(int i=v_max;i>=0;i--)
    {
        dp[0][i]=N1;
    }
    dp[0][0]=0;
    for(int i=1;i<=N;i++)
    {
        for(int j=0;j<=v_max;j++)
        {
            if(v[i]>j)
            {
                dp[i][j]=dp[i-1][j];
            }
            else
            {
                    dp[i][j]=min(dp[i-1][j],dp[i-1][j-v[i]]+w[i]);
            }
        }
    }

    for(int i=v_max;i>=0;i--)
    {
        if(dp[N][i]<=W)
        {
            ans=i;
            break;
        }
    }

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



Measured memory_bytes: 79232
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    s = set([x for x in input()])
    n = len(s)
    if n == 4 or (n == 2 and ('S' in s and 'N' in s or 'W' in s and 'E' in s)):
        print("Yes")
    else:
        print("No")



t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()




"""

4
1 2
2 4
1 3
3
2 2 4
4 5 6

6
1 2
2 3
3 4
4 5
4 6
3
3 5 6
2 17 31 5 11

"""





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

vector<int> v;

long eval(long b){
  long sum = 0;
  for(int i=0;i<v.size();i++)sum += abs(v[i]-b);
  return sum;
}

int main(){
  long n, m, t=0;
  cin >> n;
  v.resize(n);
  for(int i=0;i<n;i++){ cin >> v[i]; v[i] -= i+1; }
  sort(v.begin(), v.end());
  t = v[n/2];
  
  
  while(true){
    long a = eval(t), am = eval(t-1), ap = eval(t+1);
    if(am>=a && a<=ap){cout << a << endl; return 0;}
    else if(a >= am){ t--;}
    else if(a >= ap){ t++;}
  }
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
#include <string>
#include <set>
#include <random>
using namespace std;

int main() {
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  for (int r = 0; r < 1000; r++) {
	  char m[3] = { '0' + r / 100, '0' + (r % 100) / 10, '0' + r % 10 };
	  int j     = 0;
	  for (int i = 0; i < N; i++) {
		  if (m[j] == S[i]) {
			  j++;
			}
		  if (j == 3) {
			  ans++;
			  break;
			}
		}
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll n, i, ans;
string s[2];

int main()
{
	cin >> n >> s[0] >> s[1];
	ans=1;
	while(i<n){
		if(s[0][i]==s[1][i]){
			if(i==0){
				ans*=3;
				ans%=MOD;
			}
			else{
				if(s[0][i-1]==s[1][i-1]){
					ans*=2;
					ans%=MOD;
				}
			}
			i++;
		}
		else{
			if(i==0){
				ans*=6;
			}
			else{
				if(s[0][i-1]==s[1][i-1]){
					ans*=2;
					ans%=MOD;
				}
				else{
					ans*=3;
					ans%=MOD;
				}
			}
			i+=2;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line;
        while (!(line = br.readLine()).equals("0 0 0")) {
            String[] input = line.split(" ");

            int d = Integer.parseInt(input[0]);
            int w = Integer.parseInt(input[1]);
            int h = Integer.parseInt(input[2]);

            double diagonal = Math.min(Math.sqrt(d * d + w * w), Math.sqrt(w * w + h * h));
            diagonal = Math.min(diagonal, Math.sqrt(h * h + d * d));

            int n = Integer.parseInt(br.readLine());

            for (int i = 0; i < n; i++) {
                int r = Integer.parseInt(br.readLine());
                if (diagonal < r * 2) {
                    System.out.println("OK");
                } else {
                    System.out.println("NA");
                }
            }
        }

    }
}


Measured memory_bytes: 24244