akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] h = new int[N];
		int a = 0;
		for(int i=0; i<N; i++) {
			h[i] = sc.nextInt();
			if(h[i]>=K) {
				a++;
			}
		}
		sc.close();
		System.out.println(a);
	}

}

Measured memory_bytes: 51496
def f(i,k):
  for j in range(13):
    dp[i+1][(k*mul+j)%13]+=dp[i][j]
    dp[i+1][(k*mul+j)%13]%=mod
  
mod=10**9+7
s=input()[::-1]
n=len(s)
dp=[[0]*13 for i in range(10**5+1)]
dp[0][0]=mul=1

for i in range(n):
  if s[i]=='?':
    for k in range(10):
      f(i,k)
  else:
    f(i,int(s[i]))
  mul*=10
  mul%=13
  
print(dp[n][5]%mod)


Measured memory_bytes: 89480
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//#include <Windows.h>
#include <math.h>
//#include "Header.h"

int main(){
	int a, b, c, x, y;		// A:a円、B:b円、AB:c円、A:x枚、B:y枚必要
	scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);

	int money = 0;
	// Cの方が安い場合Cを優先して買う
	if (a + b > c * 2)
	{
		money = c * 2 * fminl(x, y);

		int xy = abs(x - y);		// 差分
		// AorBとC2枚の安い方を買う
		if (x > y)
		{
			money += fminl(a, c * 2) * xy;
		}
		else
		{
			money += fminl(b, c * 2) * xy;
		}
	}
	else
	{
		money = a * x + b * y;
	}

	printf("%d", money);
	//system("pause");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
#define MAX_N 8
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

int best = INF_INT;
int t[MAX_N];

void search(int i, int l[], int a, int b, int c, int n){
  if(i == n){
    bool found_a = false, found_b = false, found_c = false;
    int sum_a = 0, sum_b = 0, sum_c = 0;
    int count_a = 0, count_b = 0, count_c = 0;
    for(int j = 0; j < n; j++){
      switch(t[j]){
        case 1:
          found_a = true;
          ++count_a;
          sum_a += l[j];
          break;
        case 2:
          found_b = true;
          ++count_b;
          sum_b += l[j];
          break;
        case 3:
          found_c = true;
          ++count_c;
          sum_c += l[j];
          break;
      }
    }
    if(found_a && found_b && found_c){
      int cost = 10 * (count_a - 1) + abs(a - sum_a);
      cost += 10 * (count_b - 1) + abs(b - sum_b);
      cost += 10 * (count_c - 1) + abs(c - sum_c);
      best = min(best, cost);
    }
    return;
  }
  for(int j = 0; j < 4; j++){
    t[i] = j;
    search(i + 1, l, a, b, c, n);
  }
}

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

  int n, a, b, c;
  cin >> n >> a >> b >> c;
  int l[n];
  for(int i = 0; i < n; i++){
    cin >> l[i];
  }

  search(0, l, a, b, c, n);

  cout << best << endl;

  return 0;
}


Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
int n,a[N];
map<int,int> cnt;
long long ans;
int main() {
	ios::sync_with_stdio(0);
	cin >> n;
	for(int i = 1;i <= n;++i)
		cin >> a[i];
	for(int i = 1;i <= n;++i) {
		ans += cnt[i-a[i]];
		++cnt[i+a[i]];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 21460
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <bitset>
#include <random>
#include <chrono>
#include <complex>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip> 

using namespace std;

#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define RE(i, n) FOR(i,1,n)
#define REP(i,n) FOR(i, 0, (int)(n)-1)
#define fst first
#define snd second

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

string to_string(string s) {
    return '"' + s + '"';
}
    
string to_string(const char* s) {
    return to_string((string) s);
}
    
string to_string(bool b) {
    return (b ? "true" : "false");
}
    
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
    
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void fastIO() {
    cin.sync_with_stdio(false);
    cin.tie(0);
}


int XMOV[4] = {0, 0, 1, -1};
int YMOV[4] = {1, -1, 0, 0};

//#############################
const int MAXN = 1000005;

int main() {
    string s;

    cin >> s;

    cout << (s[2]==s[3] && s[4] == s[5]? "Yes\n" : "No\n");
    
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h> 
using namespace std;

typedef long long ll;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0) 
#define rep(pp,nn) for (int ii = pp; ii < nn; ++ii)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

string int_to_string(int x) {
    stringstream ss;
	ss << x;
	string ni = ss.str();
	return ni;
}
int string_to_int(string x) {
	int n;
	stringstream s(x);
	s >> n;
	return n;
}

int64_t power_mod(ll a, ll b, ll mo) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = (ans % mo * a % mo) % mo;
		}
		a = (a % mo * a % mo) % mo;
		b /= 2;
	}
	return ans;
}
int64_t POW(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = ans * a;
		}
		a = a * a;
		b /= 2;
	}
	return ans;
}

vector<int64_t> INVERSE(int64_t nn, int64_t mo) {
	vector<int64_t> inv(nn + 1);
	vector<int64_t> mul(nn + 1);
	inv[0] = 1;
    inv[1] = 1;
	for (ll i = 2; i <= nn; ++i) {
		inv[i] = (mo - (mo / i) * inv[mo % i] % mo) % mo; 
	}
	mul[0] = 1;
	for (int i = 1; i <= nn; ++i) {
		mul[i] = (mul[i - 1] * inv[i]) % mo;
	}
	return mul;
}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int main() {
	IOS;
	int64_t  n, D;
	cin >> n >> D;
	//vector<int64_t> v(n);
	int cnt = 0;
	for (int i = 0; i < n; ++i) {
		int64_t x, y;
		cin >> x >> y;
		if (x * x + y * y <= D * D) {
			cnt++;
		}
	}
	cout << cnt;
}













Measured memory_bytes: 3660
#! /usr/bin/python
# -*- coding: utf-8 -*-

(t, n) = map(int, raw_input().split())
while t != 0 or n != 0:
    M = [[False]*201 for i in range(201)]
    for i in range(n):
        (obx, oby) = map(int, raw_input().split())
        M[oby+100][obx+100] = True
    (sx, sy) = map(int, raw_input().split())
    ST = [] #0:y 1:x 2:turn num
    cnt = 0
    #----above init----#
    #print s
    ST.append([sy+100, sx+100, 0])
    while len(ST) > 0:
        y = ST[0][0]
        x = ST[0][1]
        c = ST[0][2]
        ST.pop(0)
        if y < 0 or 200 < y or x < 0 or 200 < x:
            continue
        if c <= t and M[y][x] == False:
            M[y][x] = True
            cnt += 1
            for dy in [-1, 0, 1]:
                for dx in [-1, 0, 1]:
                    if dx+dy != 0:
                        ST.append([y+dy, x+dx, c+1])
    print cnt
    
    (t, n) = map(int, raw_input().split())

Measured memory_bytes: 4780
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
	public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str=br.readLine();
		System.out.println((str.equals("ABC"))? "ARC":"ABC");
	}
}

Measured memory_bytes: 32368
import std.stdio, std.string, std.conv;
import std.array, std.algorithm, std.range;

void main()
{
    immutable N = 8;
    immutable n = readln().chomp().to!int();
    foreach(i;0..n)
    {
        readln();
        auto m = iota(N).map!(_=>readln.chomp().to!(char[])()).array();
        immutable x = readln().chomp().to!int();
        immutable y = readln().chomp().to!int();
        void dfs(int x, int y)
        {
            if(x<0 || N<=x || y<0 || N<=y || m[y][x]=='0') return;
            m[y][x]='0';
            foreach(d;[[1,0],[-1,0],[0,1],[0,-1]])
                foreach(k;1..4)
                    dfs(x+d[0]*k,y+d[1]*k);
        }
        dfs(x-1,y-1);
        writeln("Data ",i+1,":");
        m.join("\n").writeln();
    }
}

Measured memory_bytes: 1088
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<random>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
typedef vector<vt>vvt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

int MOD=998244353;
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	string s="pphbhhphph";
	int a;
	cin>>a;
	string t=s.substr(a%10,1);
	t+="on";
	cout<<t<<endl;
}


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

const int INF=0x3f3f3f3f;

int dp[200][200][2];
char s[200][200];

int main(){
	int h,w;cin>>h>>w;
	rep(i,h)scanf("%s",s[i]);
	memset(dp,0x3f,sizeof(dp));
	dp[0][0][s[0][0]=='.'?0:1]=(s[0][0]=='#');
	rep(i,h)rep(j,w)rep(k,2){
		if(dp[i][j][k]==INF)continue;
		if(i+1<h){
			int t=(s[i+1][j]=='.'?0:1);
			dp[i+1][j][t]=min(dp[i+1][j][t],dp[i][j][k]+(k==0&&t==1));
		}
		if(j+1<w){
			int t=(s[i][j+1]=='.'?0:1);
			dp[i][j+1][t]=min(dp[i][j+1][t],dp[i][j][k]+(k==0&&t==1));
		}
	}
	cout<<min(dp[h-1][w-1][0],dp[h-1][w-1][1])<<endl;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main()
{
    int count[100000];
    fill_n((int *)count, 100000, 0);

    int n;
    cin >> n;
    int is_odd = n % 2;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        if (a%2 == is_odd) {
            cout << 0 << endl;
            exit(0);
        }
        count[a]++;
    }

    if (count[0] != is_odd) {
        cout << 0 << endl;
        exit(0);
    }

    unsigned long long ans = 1;
    int idx = is_odd ? 2 : 1;
    for (; idx < n; idx+=2) {
        if (count[idx] != 2) {
            cout << 0 << endl;
            exit(0);
        }
        ans *= 2;
        ans %= 1000000007;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1272
let input = readLine()!.characters.split(" ").map{Int(String($0))!}
let (N, M) = (input[0], input[1])
var steps = (0...N).map{_ in 0}
(0..<M).forEach{_ in steps[Int(readLine()!)!] = 1}
var dp = (0...N+1).map{_ in 0}
dp[N] = 1
for i in (0..<N).reverse() {
    if steps[i] == 0 {
        dp[i] = (dp[i+1] + dp[i+2]) % 1000000007
    }
}
print(dp[0])

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

int main(void) {
    int i;
    int64_t La,Lb,L;
    int N;

    cin >> N;
    
    La = 2;
    Lb = 1;
    L = 1;

    for(i=2;i<=N;i++) {
        L = La + Lb;
        La = Lb;
        Lb = L;
    }
    
    cout << L << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
using namespace std;
struct node
{
    int x,y;
} a[200009];
int n,ans=0,tmp,tmp1;
int cmp(node a,node b)
{
    return a.x<b.x;
}
int main()
{
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
        scanf("%d%d",&a[i].x,&a[i].y);
    sort(a+1,a+n+1,cmp);
    tmp=a[1].y-a[1].x,tmp1=-a[1].x-a[1].y;
    for(int i=2; i<=n; i++)
    {
        ans=max(ans,a[i].x-a[i].y+tmp);
        ans=max(ans,a[i].x+a[i].y+tmp1);
        tmp=max(tmp,a[i].y-a[i].x);
        tmp1=max(tmp1,-a[i].x-a[i].y);
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 5384
import itertools

N = int(input())
P = tuple(map(lambda x: int(x) - 1, input().split()))
Q = tuple(map(lambda x: int(x) - 1, input().split()))

a = None
c = 0
for x in itertools.permutations(range(N), N):
    c += 1
    if x == P:
        if a is None:
            a = c
        else:
            print(abs(a - c))
            exit()
    if x == Q:
        if a is None:
            a = c
        else:
            print(abs(a - c))
            exit()

Measured memory_bytes: 3064
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	int m_module = 1000000007;
	vector<struct Memo> memo;
public:
	int calculate(int, int);
	Combination1(int, int);
};
int Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, int module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_Curtain(void) {

	int A, B; cin >> A >> B;
	
	cout << ((A > B * 2) ? A - B * 2 : 0) << flush;
	return;
}

void B_TAKOYAKI_FESTIVAL(void) {

	int N; cin >> N;
	vector<int> d(N); for (int& it : d)cin >> it;

	int sum = 0;
	sum = (int)pow(accumulate(d.begin(), d.end(), 0), 2);
	for (int it : d) sum -= it * it;
	sum /= 2;

	cout << sum << flush;
	return;
}

int main(void) {

	//A_Curtain();
	B_TAKOYAKI_FESTIVAL();
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner

fun main(args: Array<String>) {

    val oppai = Scanner(System.`in`)
    val a = oppai.next().toInt()
    val b = oppai.next().toInt()
    var joined: Int = 0
    
    if (b < 10) {
        joined = a * 10 + b
    } else if (b < 100) {
        joined = a * 100 + b
    } else {
        joined = a * 1000 + b
    }
    
    when (joined) {
        1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900, 961, 1024, 1089, 1156, 1225, 1296, 1369, 1444, 1521, 1600, 1681, 1764, 1849, 1936, 2025, 2116, 2209, 2304, 2401, 2500, 2601, 2704, 2809, 2916, 3025, 3136, 3249, 3364, 3481, 3600, 3721, 3844, 3969, 4096, 4225, 4356, 4489, 4624, 4761, 4900, 5041, 5184, 5329, 5476, 5625, 5776, 5929, 6084, 6241, 6400, 6561, 6724, 6889, 7056, 7225, 7396, 7569, 7744, 7921, 8100, 8281, 8464, 8649, 8836, 9025, 9216, 9409, 9604, 9801, 10000, 10201, 10404, 10609, 10816, 11025, 11236, 11449, 11664, 11881, 12100, 12321, 12544, 12769, 12996, 13225, 13456, 13689, 13924, 14161, 14400, 14641, 14884, 15129, 15376, 15625, 15876, 16129, 16384, 16641, 16900, 17161, 17424, 17689, 17956, 18225, 18496, 18769, 19044, 19321, 19600, 19881, 20164, 20449, 20736, 21025, 21316, 21609, 21904, 22201, 22500, 22801, 23104, 23409, 23716, 24025, 24336, 24649, 24964, 25281, 25600, 25921, 26244, 26569, 26896, 27225, 27556, 27889, 28224, 28561, 28900, 29241, 29584, 29929, 30276, 30625, 30976, 31329, 31684, 32041, 32400, 32761, 33124, 33489, 33856, 34225, 34596, 34969, 35344, 35721, 36100, 36481, 36864, 37249, 37636, 38025, 38416, 38809, 39204, 39601, 40000, 40401, 40804, 41209, 41616, 42025, 42436, 42849, 43264, 43681, 44100, 44521, 44944, 45369, 45796, 46225, 46656, 47089, 47524, 47961, 48400, 48841, 49284, 49729, 50176, 50625, 51076, 51529, 51984, 52441, 52900, 53361, 53824, 54289, 54756, 55225, 55696, 56169, 56644, 57121, 57600, 58081, 58564, 59049, 59536, 60025, 60516, 61009, 61504, 62001, 62500, 63001, 63504, 64009, 64516, 65025, 65536, 66049, 66564, 67081, 67600, 68121, 68644, 69169, 69696, 70225, 70756, 71289, 71824, 72361, 72900, 73441, 73984, 74529, 75076, 75625, 76176, 76729, 77284, 77841, 78400, 78961, 79524, 80089, 80656, 81225, 81796, 82369, 82944, 83521, 84100, 84681, 85264, 85849, 86436, 87025, 87616, 88209, 88804, 89401, 90000, 90601, 91204, 91809, 92416, 93025, 93636, 94249, 94864, 95481, 96100, 96721, 97344, 97969, 98596, 99225, 99856 -> {
            println("Yes")
        }
        else -> {
            println("No")
        }
    }
}

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

typedef long long ll;
typedef pair<ll, ll> P;

const ll mod =  1000000007;  //出力は (ans % mod + mod) % mod  (負の剰余を正にする)
const int inf = 1e9;
const long long INF = 1LL << 60;   // INF = 1152921504606846976
const double PI = 3.1415926535897932;

bool v[200005];
int a[200005];
int x = 0;
vector<int> p;


ll dfs(int now){
    //cout << now << ' ';
    p.push_back(now);
    if(v[now]) return now;
    else{
        
        v[now] = true;
        return dfs(a[now]);
    }
}
ll cnt(int now){
    if(v[now]) return x;
    else{
        x++;
        v[now] = true;
        return cnt(a[now]);
    }
}

int main()
{
    vector<int> q;
    vector<int> r;
    ll n,k; cin >> n >> k;
    rep(i,n){
       cin >> a[i];
       a[i]--;
    }
    ll last = dfs(0);
    rep(i,n) v[i] = false;
    ll x = cnt(last);
    //cout << last << ' ' << x << endl;
    if(k < p.size()-1){
        cout << p[k]+1 << endl;
    }else{
        ll id = (p.size()-1-x) + (k-(ll)p.size())%x;
        cout << p[id+1]+1 << endl;
    }
}


Measured memory_bytes: 11136
import java.io.*;
import java.util.*;
import java.math.*;
import java.util.concurrent.ThreadLocalRandom;
public class Main 
{
	
	static long gcd(long a, long b) 
	{
		if (b == 0)
		{	
			return a;
		}
		
		else
		{
			 return gcd(b, a % b);
		}
	}
	public static void main(String[] args) throws Exception
	{

		
		   PrintWriter out = new PrintWriter(System.out);
		   Scanner in = new Scanner(System.in);
		 // long n , k , q;
		  
	int k = in.nextInt();
	  int n = in.nextInt();
	  long cnt = 0;
	//long cnt = 0;
	for(int a = 0; a <= k ; a++)
		for(int b = 0; b <=k ; b++)
		{
			if( n - a - b <= k && n - a - b >= 0) cnt++;
		}

	out.println(cnt);
	   out.close();
	}
}

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

ll N;
int ans = 0;

int a[3] = {3, 5, 7};
void dfs(int depth, ll buf) {
    if (buf > N) {
        return;
    }

    if (buf >= 357) {
        int flg = 0, tmp = buf;
        while (tmp > 0) {
            flg |= (1 << (tmp % 10 - 1));
            tmp /= 10;
        }
        if (flg == 84 /* 84(2) = 01010100 */) {
            ans++;
        } 
    }
    REP (i, 3) {
        ll tmp = a[i] * pow(10, depth);
        dfs(depth+1, buf+tmp);
    }
}


int main(void) {
    cin >> N;
    dfs(0, 0);
    cout << ans << endl;
}

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

using namespace std;

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

int d[105], f[105];
bool seen[105];

void dfs(vector<vector<int> > &G, int n, int &x){
    if(seen[n]) return;
    x++;
    d[n] = x;
    seen[n] = true;

    rep(i, G[n].size()){
        int p = G[n][i];
        if(seen[p]) continue;
        dfs(G, p, x);
    }

    x++;
    f[n] = x;
}

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

    vector<vector<int> > G(n);
    rep(i, n){
        int u, k;
        cin >> u >> k;
        rep(j, k){
            int v;
            cin >> v;
            v--;
            G[i].push_back(v);
        }
    }

    rep(i, n){
        seen[i] = false;
    }
    int x = 0;
    rep(i, n){
        dfs(G, i, x);
    }

    rep(i, n){
        cout << i+1 << " " <<  d[i] << " " << f[i] << "\n";
    }


    return 0;
}


Measured memory_bytes: 3172
S = input()

count = 0

if S[0] == 'A' and S[0].isupper():
    count = count + 1

num_loop = len(S) - 3
count_ = 2
c_num = 0
for i in range(num_loop):
    if S[count_] == 'C' and S[count_].isupper():
        c_num = c_num + 1
    count_ = count_ + 1
if c_num == 1:
    count = count + 1


if count == 2:
    up_count = 0
    for i in range(len(S)):
        if S[i].islower():
            continue
        else:
            up_count = up_count + 1

    if up_count == 2:
        count = count + 1

if count == 3 :
    print('AC')
else:
    print('WA')


Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

typedef pair<int, int> P;
typedef pair<int, P> E;

struct UnionFind {
	vector<int> par;
	vector<int> size;

	UnionFind(int n) {
		par = vector<int>(n);
		for (int i = 0; i < n; i++) par[i] = i;
		size = vector<int>(n, 1);
	}

	int find(int x) {
		if (x == par[x]) return x;
		return par[x] = find(par[x]);
	}

	bool same(int x, int y) {
		return find(x) == find(y);
	}

	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (size[x] < size[y]) {
			par[x] = y;
			size[y] += size[x];
		}
		else {
			par[y] = x;
			size[x] += size[y];
		}
	}
};

int main() {
	int N, H, W;
	cin >> N >> H >> W;
	vector<E> edge;
	for (int i = 0; i < N; i++) {
		int R, C;
		int A;
		cin >> R >> C >> A;
		R--; C--;
		edge.emplace_back(A, P(R, C + H));
	}
	sort(edge.begin(), edge.end(), greater<E>());
	UnionFind U(H + W + 1);
	ll ans = 0;
	for (E e : edge) {
		int x = e.second.first, y = e.second.second;
		if (!U.same(x, y)) {
			U.unite(x, y);
			ans += e.first;
		}
		else if (!U.same(x, H + W) && !U.same(y, H + W)) {
			U.unite(x, y);
			U.unite(x, H + W);
			ans += e.first;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        string s;
        cin >> s;
        cout << ((s[2] == s[3] and s[4] == s[5]) ? "Yes\n" : "No\n");
    }
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n, m;
int x[MAX_N];

map<int, vector<int>> container;
map<int, int> consume;
map<int, int> whole;
set<int> visited;

int ans;

int main(void) {
  // Here your code !
  scanf("%d %d", &n, &m);

  for (int i = 0; i < n; ++i) {
    scanf("%d", &(x[i]));
  }

  for (int i = 0; i < n; ++i) {
    container[x[i] % m].push_back(x[i]);
  }

  for (auto &e : container) {
    whole[e.first] = e.second.size();

    map<int, int> cnt;

    for (auto &d : e.second) {
      cnt[d] += 1;
    }

    for (auto &d : cnt) {
      consume[e.first] += d.second / 2;
    }
  }

  // for (auto &e : consume) {
  //   printf("p %d: %d\n", e.first, e.second);
  // }

  // for (auto &e : whole) {
  //   printf("c %d: %d\n", e.first, e.second);
  // }

  ans = 0;

  for (auto &e : whole) {
    int key = e.first;
    int opposite_key = (m - key) % m;

    // if (opposite_key > key) continue;
    if (visited.find(key) != visited.end() ||
        visited.find(opposite_key) != visited.end())
      continue;

    visited.insert(key);
    visited.insert(opposite_key);

    if (opposite_key == key) {
      ans += whole[key] / 2;
    } else {
      // if (whole.find(opposite_key) == whole.end()) {
      //   ans += 2 * consume[key];
      //   continue;
      // }

      int x = key;           // bigger
      int y = opposite_key;  // smaller

      if (whole[x] < whole[y]) {
        swap(x, y);
      }

      int diff = abs(whole[x] - whole[y]);
      int actual_consumed_pair = min(diff / 2, consume[x]);

      ans += actual_consumed_pair;  // duplicate pair consume
      ans += whole[y];
    }
  }

  // for (auto &e : container_pair) {
  //   map<int, int> cnt;

  //   for (auto &d: e.second) {
  //     cnt[d.second] += 1;
  //   }

  //   for (auto &d: cnt) {
  //     ans += d.second / 2;
  //   }
  // }

  // for (auto &e : container_pair) {
  //   printf("%d: ", e.first);
  //   for (auto &d : e.second) {
  //     printf("(%d %d) ", d.first, d.second);
  //   }
  //   printf("\n");
  // }

  printf("%d\n", ans);

  return 0;
}


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

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

using ll = long long;
using lb = long double;
using P = pair<ll,ll>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<62;
const ll mod = 1000000007LL;

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

template<class T>struct dijkstra{//T=int or ll
  struct Node{
    vector<T> edges_to;
    vector<T> edges_cost;
    bool done;
    T cost=-1;
  };
  vector<Node> graph;
  void init(int N){
    graph.resize(N);
  }
  void add(int from, int to, T cost){
    graph[from].edges_to.push_back(to);
    graph[from].edges_cost.push_back(cost);
  }
  void shortest(T start){
    priority_queue<pair<T,T>,vector<pair<T,T>>,greater<pair<T,T>>> d;
    d.push(make_pair(0,start));
    while(!d.empty()){
      pair<T,T> p = d.top();
      d.pop();
      Node &point = graph[p.second];
      if(point.done) continue;
      point.done = true;
      point.cost = p.first;
      for(T i = 0; i < (T)point.edges_to.size(); i++){
        if(graph[point.edges_to[i]].done)continue;
        d.push(make_pair(point.cost+point.edges_cost[i],point.edges_to[i]));
      }
    }
  }
};

int main() {
  P s,t;
  cin>>s.first>>s.second>>t.first>>t.second;
  ll N;
  cin>>N;
  vector<vector<lb>> v(N,(vector<lb>(3)));
  rep(i,N){
    rep(j,3) cin>>v[i][j];
  }
  vector<vector<lb>> g(N+2,vector<lb>(N+2,INF));
  rep(i,N){
    rep(j,N){
      if(i==j) g[i][j] = 0;
      else {
        lb X = v[i][0]-v[j][0],Y = v[i][1]-v[j][1];
        g[i][j] = max((lb)sqrt(X*X+Y*Y)-v[i][2]-v[j][2],(lb)0);
      }
    }
  }
  rep(i,N+2){
    if(i<N){
      lb X = s.first - v[i][0],Y = s.second - v[i][1];
      g[N][i] = g[i][N] = max((lb)sqrt(X*X+Y*Y)-v[i][2],(lb)0);
    }
    else if(i==N) g[N][i]=g[i][N]=0;
    else if(i==N+1) {
      lb X = s.first-t.first,Y = s.second-t.second;
      g[N][i] = g[i][N] = (lb)sqrt(X*X+Y*Y);
    }
  }
  rep(i,N+2){
    if(i<N){
      lb X = t.first - v[i][0],Y = t.second - v[i][1];
      g[N+1][i] = g[i][N+1] = max((lb)sqrt(X*X+Y*Y)-v[i][2],(lb)0);
    }
    else if(i==N+1) g[N+1][i]=g[i][N+1]=0;
  }
  dijkstra<lb> D;
  D.init(N+2);
  rep(i,N+2){
    rep(j,N+2){
      D.add(i,j,g[i][j]);
    }
  }
  D.shortest(N);
  cout<<fixed<<setprecision(10);
  cout<<D.graph[N+1].cost<<endl;
}

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

int main(){
  int N;cin>>N;
  int dp[N][3];
  
  int A,B,C;cin>>A>>B>>C;
  dp[0][0]=A;
  dp[0][1]=B;
  dp[0][2]=C;
  
  for(int i=1;i<N;i++){
    int x[3];
    cin>>x[0]>>x[1]>>x[2];
    for(int k=0;k<3;k++){
      dp[i][k]=x[k]+max(dp[i-1][(k+1)%3],dp[i-1][(k+2)%3]);
    }
  }
  
  int res=0;
  for(int i=0;i<3;i++)
    res=max(res,dp[N-1][i]);
  cout<<res;
}

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

int main(){
	long long n;
	int ans=0;
	cin>>n;
	long long now=100;
	for(int i=1;i<=4000;i++){
		if(now>=n)break;
		now+=now/100;
		ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3608
import sys


def solve():
    sys.setrecursionlimit(2000)
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    n = int(input().rstrip('\n'))
    for i in range(1, 10):
        for j in range(1, 10):
            if n == i * j:
                print("Yes")
                exit()
    print("No")


if __name__ == '__main__':
    solve()


Measured memory_bytes: 39856
# ABC050B - Contest with Drinks Easy
n = int(input())
lst = list(map(int, input().rstrip().split()))
m = int(input())
drinks = [list(map(int, input().rstrip().split())) for _ in range(m)]
total = sum(lst)

for i in drinks:
    print(total - lst[i[0] - 1] + i[1])

Measured memory_bytes: 3060
n,m = map(int,input().split())
x = []
c = 0
for i in range(n):
    a = list(map(int,input().split()))
    a.pop(0)
    x.extend(a)

for j in range(1,m+1):
    if x.count(j) == n:
        c += 1

print(c)

Measured memory_bytes: 3444
n,m=map(int,input().split())
a=[tuple(map(int,input().split()))for i in range(m)]
a.sort()
l,r=0,n+1
x=1
for i,j in a:
  if j<=l or r<=i:
    x+=1
    l,r=i,j
  else:
    l,r=max(l,i),min(r,j)
print(x)

Measured memory_bytes: 16996
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans;
char c;

int main(void) {
    scanf("%c", &c);
    if (c=='z') c = 'a';
    else c +=1;

  
    printf("%c\n", c);

	  return 0;
}


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

#define st first
#define nd second
#define ll long long
#define ld long double
#define pb push_back
#define emp emplace_back
#define pii pair<int, int>
#define usg unsigned
#define sg signed
#define mp make_pair

using namespace std;

void setIO(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

const ld PI = 4*atan((ld)1);
const int INF = 1e9+7;
const int mxa = 1e6+7;
const int mxn = 2e5+7;

int a[mxn], fq[mxa];

int main(){
	setIO();
	int n; cin >> n;
	int ans = n;
	for (int i = 0; i < n; i++){
		cin >> a[i];
		fq[a[i]]++;
	}
	for (int i = 0; i < n; i++){
		fq[a[i]]--;
		for (ll j = 1; j*j <= a[i]; j++){
			if (a[i] % j == 0){
				if (fq[j]) {ans--; break;}
				if (fq[a[i]/j]) {ans--; break;}
			}
		}
		fq[a[i]]++;
	}
	cout << ans << endl;
}

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

int n, l;
string s[105];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	
	cin >> n >> l;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}

	sort(s, s+n);
	string ans = "";
	for (int i = 0; i < n; i++) {
		ans += s[i];
	}
	cout << ans << '\n';

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;
const int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
const int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};
const int Mod = 1000000000 + 0;
//{{{ templates
#define TT_ template<typename T>inline
#define TTF_ template<typename T,typename F>inline
TT_ T sq(T x){return x*x;}
TT_ T In(){T x;cin>>x;return x;}
TT_ void Out(T&x){cout<<x;}
TT_ void sort(T&v){sort(begin(v),end(v));}
TT_ void revs(T&v){reverse(begin(v),end(v));}
TT_ void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT_ int ubnd(T&v,typename T::value_type x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT_ int lbnd(T&v,typename T::value_type x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF_ void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF_ void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
TT_ typename T::iterator minel(T&v){return min_element(begin(v),end(v));}
TT_ typename T::iterator maxel(T&v){return max_element(begin(v),end(v));}

inline void fast_io(){ios_base::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}
//}}} priority_queue queue deque front stringstream max_element min_element insert count make_tuple

double sq(double x){ return x * x; }
double sqs(double x, double y){ return sq(x) + sq(y); }

// ax + by = c
// dx + ey = f
void F(double *x, double *y, double a, double b, double c, double d, double e, double f)
{
  *y = (c * d - f * a) / (d * b - e * a);
  *x = (b * f - e * c) / (d * b - e * a);
}

int main()
{
  int n = in();
  while (n--){
    double x0, y0, x1, y1, x2, y2;
    cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2;
    // (x - a)^2 + (y - b)^2 = r^2
    // x^2 + y^2 + lx + my + n = 0
    // -a = l / 2
    // -b = m / 2
    double l, m;
    F(&l, &m, x0 - x1, y0 - y1, sqs(x1, y1) - sqs(x0, y0), x0 - x2, y0 - y2, sqs(x2, y2) - sqs(x0, y0));
    double px = -l / 2, py = -m / 2;
    double r = sqrt(sq(x0 - px) + sq(y0 - py));
    printf("%.3lf %.3lf %.3lf\n", px, py, r);
  }
  return 0;
}

Measured memory_bytes: 1264
/**
 * Contest : AtCoder Beginner Contest 160
 * Contest URL : https://atcoder.jp/contests/abc160
 * Problem : C - 
 * Problem URL : https://atcoder.jp/contests/abc160/tasks/abc160_c
 */

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair < int, int >;

// This section is for Policy Based Data Structure, more precisely Ordered Set.
// All Functions of set works here, in addition we have order_of_key() and find_by_order() function. find_by_order() returns iterator
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<functional>
using namespace __gnu_pbds;

// 1. Custom Set
template < class T, class COMP >
using custom_set = tree < T, null_type, COMP, rb_tree_tag, tree_order_statistics_node_update >;

// 2. Ordered Set
template < class T >
using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;

// 3. Ordered Multi Set
// For storing multiple occurance of same value we need to use pair. In pair first value is our key and second is useless count variable.
// order_of_key(make_pair(key, 0)) returns first occurance of a value, order_of_key(make_pair(key, INT_MAX)) returns last occurance.
template < class T >
using ordered_multiset = tree < pair < T, int >, null_type, less < pair < T, int > >, rb_tree_tag, tree_order_statistics_node_update >;

// 4. Ordered Map
template < class T, class U >
using ordered_map = tree < T, U, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
// Policy End

void solve() {
	int k, n;
	cin >> k >> n;
	vector < int > a (n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	if (n == 1) {
		cout << 0 << endl;
		return;
	}
	int ans = k;
	for (int i = 0; i < n; i++) {
		int dist = a[(i + 1) % n] - a[i];
		if (dist < 0) {
			dist = k + dist;
		}
		ans = min (ans, k - dist);
	}
	cout << ans << endl;
}

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



Measured memory_bytes: 1024
n=int(input())
a,b=map(int,input().split())
p=list(map(int,input().split()))
li1 = [i for i in p if i<=a]
li2 = [i for i in p if a<i<=b]
li3 = [i for i in p if b<i]
a,b,c=len(li1),len(li2),len(li3)
print(min(a,b,c))

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

/**
 *    author:  knshnb
 *    created: Sun Mar  8 21:00:01 JST 2020
 **/

signed main() {
    string s;
    cin >> s;
    if (s.size() % 2) {
        cout << "No" << endl;
        return 0;
    }
    REP(i, s.size()) {
        if (s[i] != (i % 2 ? 'i' : 'h')) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {
	long long N, M;
	cin >> N >> M;
	if (M >= 2 * N) {
		cout << ((M-2*N) / 4)+N << endl;
	}
	else {
		cout << (M) / 2 << endl;
	}
}



Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=[]
ave=int(sum(A)/N)
te=ave+1
C=[]
for i in range(N):
  B.append((ave-A[i])**2)
  C.append((te-A[i])**2)
print(sum(B) if sum(B)<sum(C) else sum(C))

Measured memory_bytes: 3064
#include<iostream>
using namespace std;
int main() {
	int n; cin >> n;
	unsigned long long a[20010], b[20010];
	for (int i = 1; i <= n; i++) {
		a[i] = 30000 * i;
		b[n + 1 - i] = a[i];
	}
	for (int i = 0; i < n; i++) {
		int p; cin >> p;
		a[p] += i;
		b[p] += i;
	}
	for (int i = 1; i <= n; i++) {
		cout << a[i];
		if (i == n)cout << endl; else cout << ' ';
	}
	for (int i = 1; i <= n; i++) {
		cout << b[i];
		if (i == n)cout << endl; else cout << ' ';
	}
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h> 
using namespace std;
typedef long long int ll;
#define MOD 1000000007
ll dp[25][2100000];
bool mat[25][25];
unsigned long long int popcount(unsigned long long int n){
    if(n==0) return 0;
    return 1+popcount(n&(n-1));
}
void solve(){
	ll i,j,k,n;
    cin>>n;
    for(i=1;i<=n;i++){
        for(j=0;j<n;j++) cin>>mat[i][j];
    }
    const ll MX = pow(2,n)-1;
    for(i=0;i<=MX;i++) dp[0][i]=0;
    dp[0][0]=1;
    for(i=1;i<=n;i++){
        //i is the man
        for(j=0;j<=MX;j++){
            //j is the mask
            dp[i][j]=0;
            ll ppc=popcount(j);
            if(ppc==i){//only if numbers of women left is equal to i(=no of men)
                for(k=0;k<n;k++){
                    //kth woman is to be matched
                    if( (j&(1<<k)) && mat[i][k]) //if kth women present in j && is kth women allowed by question
                        dp[i][j]+=dp[i-1][j-(1<<k)];
                    dp[i][j]%=MOD;
                }
            }
        }
    }
    cout<<dp[n][MX]<<endl;
}
int main(){
    solve();
	return 0;
}


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

const int N = 505;
int n, x[N], ans[N * N], rk[N];

int main() {
	std::ios::sync_with_stdio(0), std::cin.tie(0);
	std::cin >> n;
	for (int i = 1; i <= n; ++i) std::cin >> x[i], rk[i] = i, ans[x[i]] = i;
	std::sort(rk + 1, rk + n + 1, [] (int a, int b) {return x[a] < x[b];});
	int k = 1;
	for (int i = 1; i <= n; ++i) {
		for (int t = 1; t < rk[i]; ++t) {
			while (k <= x[rk[i]] && ans[k]) ++k;
			if (k > x[rk[i]]) return std::cout << "No\n", 0;
			ans[k] = rk[i];
		}
	}
	k = n * n;
	for (int i = n; i >= 1; --i) {
		for (int t = rk[i]; t < n; ++t) {
			while (k >= x[rk[i]] && ans[k]) --k;
			if (k < x[rk[i]]) return std::cout << "No\n", 0;
			ans[k] = rk[i];
		}
	}
	std::cout << "Yes\n"; 
	for (int i = 1; i <= n * n; ++i)
		std::cout << ans[i] << ' ';
	std::cout << '\n';
	return 0;
}

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

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

    int n;
    cin >> n;

    vector<int> A(n);
    cin >> A[n/2];
    int ptr = n/2;
    int minus;
    
    if(n%2) minus = 1;
    else minus = -1;
    rep1(i, n){
        int a;
        cin >> a;
        ptr += i * minus;
        minus *= -1;
        A[ptr] = a;
    }

    rep(i, n) cout << A[i] << " ";
    cout << endl;
    

}

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

int main(void)
{
    int N;

    cin >> N;

    long long int tn = 1, an = 1;
    for(int i = 0; i < N; ++i)
    {   
        int T, A;
        cin >> T >> A;
        long long int p = max(max(tn/T, an/A),(long long int)1);
        if(T*p >= tn && A*p >= an)
        {
            tn = T*p;
            an = A*p;
        }
        else
        {
            tn = T*(p+1);
            an = A*(p+1);            
        }
        
    }

    cout << (long long int)tn + (long long int)an << endl;

    return 0;
}



Measured memory_bytes: 3600
n=int(input())
s=input()
w=[0]*n
e=[0]*n
if s[0]=="E":
    e[0]=1
if s[n-1]=="W":
    w[n-1]=1
for i in range(1,n):
    if s[i]=="E":
        e[i]=e[i-1]+1
    else:
        e[i]=e[i-1]
for i in range(2,n+1):
    if s[n-i]=="W":
        w[n-i]=w[n-i+1]+1
    else:
        w[n-i]=w[n-i+1]
ans=max(w[1],e[n-2])
for i in range(1,n-1):
    ans=max(ans,w[i+1]+e[i-1])
print(n-1-ans)

Measured memory_bytes: 45788
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
  double x1,x2,y2,y1,dist;
  cin>>x1>>y1>>x2>>y2;
  printf("%.8lf\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
  return 0;
}

Measured memory_bytes: 3192
N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))
A = []

cnt = 0
for _ in range(N):
    A = list(map(int, input().split()))
    score = C
    for a, b in zip(A, B):
        score += a*b
    if score > 0:
        cnt += 1

print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll gcd(ll a,ll b){
	return (b==0 ? a : gcd(b,a%b));
}
int main () {
	ll a,b,c,ans=0;
	cin>>a>>b;
	c=gcd(a,b);
	
	bool s[1000000];
	memset (s,1,1000000);
	s[0]=0;
	s[1]=0;
	for (ll i=2;i<1000;i++) {
		if (s[i]) {
			for (ll j=2;j*i<1000000;j++) {
				s[j*i]=0;
			}
		}
	}
	for (ll i=2;i<1000000;i++) {
		if (s[i]==1&&c%i==0) {
			ans++;
			while (c%i==0) {
				c/=i;
			}
		}
	}
	if (c!=1) {
		ans++;
	}
	ans++;
	cout<<ans;
	
	/*
	ll i=3,j=0;
	if (c%2==0) {
		j++;
		while (c%2==0) {
			c/=2;
		}
	}
	while (c!=1) {
		if (c%i==0) {
			j++;
			while (c%i==0) c/=i;
		}
		i+=2;
	}
	cout<<j+1;*/
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int N;
int X[105];

int main(){

	scanf("%d",&N);
	for(int i = 0; i < N; i++){

		scanf("%d",&X[i]);
	}

	int ans = BIG_NUM;

	for(int i = 0; i <= 100; i++){
		int tmp_sum = 0;
		for(int k = 0; k < N; k++){

			tmp_sum += (X[k]-i)*(X[k]-i);
		}
		ans = min(ans,tmp_sum);
	}

	printf("%d\n",ans);

	return 0;
}


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

vector<bool> solve(int n, vector<bool> const & s) {
    REP (t_0, 2) {
        REP (t_1, 2) {
            vector<bool> t(n);
            t[0] = t_0;
            t[1] = t_1;
            REP3 (i, 2, n) {
                t[i] = (t[i - 2] ^ t[i - 1] ^ s[i - 1]);
            }
            if (s[n - 1] == (t[n - 2] ^ t[n - 1] ^ t[0]) and
                    s[0] == (t[n - 1] ^ t[0] ^ t[1])) {
                return t;
            }
        }
    }
    return vector<bool>();
}

int main() {
    int n; cin >> n;
    vector<bool> s(n);
    REP (i, n) {
        char s_i; cin >> s_i;
        s[i] = (s_i == 'o');
    }
    vector<bool> result = solve(n, s);
    if (result.empty()) {
        cout << -1 << endl;
    } else {
        for (bool p : result) cout << (p ? 'S' : 'W');
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3652
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
dic_s = {}
for i in range(N):
    s = "".join(sorted(input()))
    if s in dic_s:
        dic_s[s] += 1
    else:
        dic_s[s] = 1
counter = 0
for key,value in dic_s.items():
    if value >1:
        counter += combinations_count(value,2)
print(counter)


Measured memory_bytes: 22212
//
// Created by admin on 2020/6/27.
//
#include <bits/stdc++.h>
using namespace std;
string s,t;
int main()
{
    cin>>s>>t;
    int ans=0;
    for(int i=0;i<s.size();i++)
        if(s[i]!=t[i])
            ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 3828
def check_pow_2(a,cnt):
  if a % 2 == 1:
    return cnt
  else:
    return check_pow_2(a/2,cnt) + 1

n = int(input())
a_lst = map(int, input().split())
min_ope = float("inf")
for a in a_lst:
  min_ope = min(min_ope, check_pow_2(a,0))
if min_ope == float("inf"):
  min_ope = 0
print(min_ope)

Measured memory_bytes: 9240