akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long
#define pii pair < int, string >
using namespace std;

int main()
{
    ll n, m;

    cin >> n >> m;

    vector < string > contest[n + 5];
    bool a[n + 5];
    ll ac = 0, wa = 0, s = 0;

    memset(a, 0, sizeof(a));

    for(ll i = 1; i <= m; i++){
        ll x;
        string y;

        cin >> x >> y;

        contest[x].push_back(y);
    }

    for(int i = 1; i <= n; i++){
        s = 0;

        for(int j = 0; j < contest[i].size(); j++){
            if(contest[i][j] == "AC"){
                ac++;
                wa += s;
                s = 0;
                break;
            }
            else s++;
        }
    }

    cout << ac << ' ' << wa << endl;

    return 0;
}


Measured memory_bytes: 10496
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstring>
const int N=2e5+1;
int n, b[N], ch[N];
long long a[N], c[N];
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, c!=253&c>9);
	b=c==253;
	for(a=b?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int main() {
	n=read<int>();
	std::generate(a, a+n, read<long long>);
	std::generate(b, b+n, read<int>);
	int pos=std::max_element(a, a+n)-a;
	std::rotate(a, a+pos, a+n);
	std::rotate(b, b+pos, b+n);
	a[n]=a[0];
	for(int i=1; i<n; ++i) c[i+1]=2*c[i]-c[i-1]-2*b[i];
	for(int i=0; i<=n; ++i) a[i]+=c[i];
	int *top=ch;
	*top++ = 0;
	for(int i=1; i<=n; ++i) {
		while(top-ch>=2 && 1.0L*(top[-1]-top[-2])*(a[i]-a[top[-1]])>=1.0L*(i-top[-1])*(a[top[-1]]-a[top[-2]])) --top;
		*top++ = i;
	}
	int size=top-ch;
	long double sum=0;
	for(int i=1; i<size; ++i) {
		int l=ch[i-1], r=ch[i];
		sum+=1.0L*(r-l)*a[l]+(a[r]-a[l])*(r-l-1.0L)/2;
	}
	for(int i=0; i<n; ++i) sum-=c[i];
	printf("%.12Lf\n", sum/n);
	return 0;
}


Measured memory_bytes: 6300
#include <stdio.h>
#include <queue>
#include <vector>
#include <string>

int main(){

    int r,g,b;
    scanf("%d%d%d", &r,&g,&b);

    int ans = r*100 + g*10 + b;

    if( ans % 4 ) printf ("NO\n");
    else printf ("YES\n");


    return 0;

}


Measured memory_bytes: 128
import sys
input = sys.stdin.readline


def read():
    S = input().strip()
    return S,


def solve(S):
    ans = 0
    rain = 0
    for s in S:
        if s == "R":
            rain += 1
        else:
            ans = max(ans, rain)
            rain = 0
    ans = max(ans, rain)
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 9060
h = int(input())
heap = list(map(int, input().split()))


def max_heapify(a, i):
    li, ri = i * 2 + 1, i * 2 + 2
    if li < h:
        largest = li
        if ri < h and a[ri] > a[li]:
            largest = ri
        if a[largest] > a[i]:
            a[i], a[largest] = a[largest], a[i]
            max_heapify(a, largest)


def build_max_heap(a):
    for i in range((h - 1) // 2, -1, -1):
        max_heapify(a, i)


build_max_heap(heap)

print(' ', end='')
print(*heap)

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

using namespace std;

#define MAX 300

int main()
{
    int mx, n;
    while (cin >> mx, mx) {
        cin >> n;
        vector<int> v(n+2, 0);
        for (int i = 1; i <= n; i++) {
            cin >> v[i];
        }
        bool visited[MAX] = {0};
        visited[0] = 1;
        queue<int> Q;
        Q.push(0);

        while (!Q.empty()) {
            int now = Q.front(); Q.pop();
            if (now == n+1) {
                continue;
            }

            for (int i = 1; i <= mx; i++) {
                int next = min(n+1, now+i);
                next += v[next];
                if (next < 0) {
                    next = 0;
                } else if (next > n+1) {
                    next = n+1;
                }
                if (!visited[next]) {
                    visited[next] = 1;
                    Q.push(next);
                }
            }
        }
        bool reachable = 1;
        for (int i = 0; i <= n; i++) {
            if (!visited[i]) {              
                continue;
            }
            bool ng = 1, visited2[MAX] = {0};
            queue<int> Q2; Q2.push(i);
            visited2[i] = 1;
            while (!Q2.empty()) {
                int now = Q2.front(); Q2.pop();
                if (now == n+1) {
                    ng = 0;
                    break;
                }
                for (int i = 1; i <= mx; i++) {
                    int next = min(n+1, now+i);
                    next += v[next];
                    if (next < 0) {
                        next = 0;
                    } else if (next > n+1) {
                        next = n+1;
                    }
                    if (!visited2[next]) {
                        visited2[next] = 1;
                        Q2.push(next);
                    }
                }
            }
            if (ng) {
                reachable = 0;
                break;
            }
        }
        cout << (reachable && visited[n+1] ? "OK" : "NG") << endl;
    }
    return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    double n,m,d;cin >>n>>m>>d;
    double p;
    if(d==0){
        p=1/n;
    }
    else {
        p=2*(n-d)/(n*n);
    }
//    cout <<p<<endl;
    p*=(m-1);
    cout <<setprecision(20)<<p<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int search(int n, vector<int>& arr)
{
  for(auto &m:arr)
  {
    if(m==n)
      return 0;
  }
  return 1;
}
int main()
{
  vector<int> arr;
  int x,n;
  cin>>x>>n;
  int h;
  for(int i=0;i<n;i++)
  {
    cin >>h;
    arr.push_back(h);
  }
  for(int i=0;i<200;i++)
  {
    if(search(x-i,arr)==1)
    {
      cout <<x-i;
      return 0;
    }
    if(search(x+i,arr)==1)
    {
      cout <<x+i;
   	  return 0;
    }     
  }
}


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

namespace ABC110_AA
{
    class Program
    {
        static void Main(string[] args)
        {
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(a);
            Array.Reverse(a);
            Console.WriteLine(a[0]*10 + a[1] +a[2]);
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

int main() {
	string s; cin >> s;

	ll a[26] = {};
	rep(i, 0, 4)a[s[i] - 'A']++;

	ll count = 0;
	rep(i, 0, 26) {
		if (a[i] == 2) {
			count++;
		}
	}
	cout << ((count == 2) ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main() {
    LL A,B,C,X,Y;cin >> A >> B >> C >> X >> Y;
    LL sum = 0;

    if(A+B >= 2*C){
        if(X > Y){
            sum += 2*Y*C;
            if(2*C <= A){
                sum += 2*C*(X-Y);
            }
            else{
                sum += (X-Y)*A;
            }
        }
        else{
            sum += 2*X*C;
            if(2*C <= B){
                sum += 2*C*(Y-X);
            }
            else{
                sum += (Y-X)*B;
            }
        }
    }
    else{
        sum += (A*X)+(B*Y);
    }

    cout << sum << endl;
}

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

int main()
{
  string s;
  cin >> s;
  int i;
  vector<bool> check(4, false);
  for(i = 0; i < s.size(); i++)
  {
    if(s.at(i) == 'N') check.at(0) = true;
    if(s.at(i) == 'S') check.at(1) = true;
    if(s.at(i) == 'W') check.at(2) = true;
    if(s.at(i) == 'E') check.at(3) = true;
  }
  if(check.at(0)==check.at(1)&&check.at(2)==check.at(3))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<utility>
#include<array>
#include<set>
#include <numeric>
#include <stdio.h>
#include <map>
#include <iomanip>
#include <sstream>
//#include <boost/math/common_factor_rt.hpp>
#include<fstream>
#define EPS (1e-7)
using namespace std;
#define ll long long



class Employee {
public:
	int id;
	int parent;
	vector<int> children;
	int salary;

	Employee() {
		
	}

	Employee(int num, int nparent) {
		id = num;
		parent = nparent;
		salary = -1;
	}



};



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;
}



int main() {

	int N;
	cin >> N;
	vector<int> cost(N, 2000000000);
	vector<int> h(N);

	for (auto i = 0; i < N; i++) {
		cin >> h[i];

	}
	cost[0] = 0;
	cost[1] = abs(h[0] - h[1]);
	for (auto i = 2; i < N; i++) {
		cost[i] = min(cost[i-1] + abs(h[i]-h[i-1]), cost[i - 2] + abs( h[i] - h[i - 2]));

	}

	cout << cost[N - 1] << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.io.*;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.function.LongUnaryOperator;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(FastScanner sc) {
		int N = sc.nextInt();
		LongUnaryOperator[] ops = new LongUnaryOperator[N - 1];
		for (int i = 0; i < N - 1; i++) {
			int C = sc.nextInt();
			int S = sc.nextInt();
			int F = sc.nextInt();
			ops[i] = t -> {
				if (S >= t) return C + S;
				else {
					long wait = (t - S) % F;
					if (wait == 0) return t + C;
					return t + (F - wait) + C;
				}
			};
		}
		StringJoiner joiner = new StringJoiner("\n");
		for (int i = 0; i < N; i++) {
			long t = 0;
			for (int j = i; j < N - 1; j++) {
				t = ops[j].applyAsLong(t);
			}
			joiner.add(String.valueOf(t));
		}
		System.out.println(joiner.toString());
	}
}

final class FastScanner extends BufferedReader {
	private StringTokenizer tokenizer;

	FastScanner(InputStream in) {
		super(new InputStreamReader(in));
	}

	String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(readLine());
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
		return tokenizer.nextToken();
	}

	int nextInt() {
		return Integer.parseInt(next());
	}

	//10^10~
	long nextLong() {
		return Long.parseLong(next());
	}
}

class Main {
	public static void main(String... args) {
		FastScanner in = new FastScanner(System.in);

		Solver.INSTANCE.solve(in);

		try {
			in.close();
		} catch (IOException e) {
			throw new UncheckedIOException(e);
		}
	}
}

Measured memory_bytes: 27732
n = int(input())
vn = list(map(int, input().split()))

odd_cnt = {}
even_cnt = {}

for i,vi in enumerate(vn):
    if i % 2 == 0:
        if vi in even_cnt:
            even_cnt[vi] += 1
        else:
            even_cnt[vi] = 1
    else:
        if vi in odd_cnt:
            odd_cnt[vi] += 1
        else:
            odd_cnt[vi] = 1

# print(sorted(even_cnt.items(), key=lambda x: -x[1])[0:2])
# print(sorted(odd_cnt.items(), key=lambda x: -x[1])[0:2])


even_max = 0
even_max_num = 0
even_sum = 0
odd_max = 0
odd_max_num = 0
odd_sum = 0
ans = 0
for k,v in sorted(even_cnt.items(), key=lambda x: -x[1]):
    even_sum += v
    if v > even_max:
        even_max = v
        even_max_num = k

for k,v in sorted(odd_cnt.items(), key=lambda x: -x[1]):
    odd_sum += v
    if v > odd_max:
        odd_max = v
        odd_max_num = k

if len(even_cnt) > 1:
    even_2nd = sorted(even_cnt.items(), key=lambda x: -x[1])[1][1]
else:
    even_2nd = 0
if len(odd_cnt) > 1:
    odd_2nd = sorted(odd_cnt.items(), key=lambda x: -x[1])[1][1]
else:
    odd_2nd = 0

if odd_max_num == even_max_num:
    if odd_max == even_max:
        if len(odd_cnt) == 1 and len(even_cnt) == 1:
            ans = even_sum
        elif len(odd_cnt) == 1:
            ans = even_sum - even_2nd
        elif len(even_cnt) == 1:
            ans = odd_sum - odd_2nd
        else:
            if even_2nd > odd_2nd:
                ans = odd_sum - odd_max + even_sum - even_2nd
            else:
                ans = odd_sum - odd_2nd + even_sum - even_max
    elif odd_max > even_max:
        ans = odd_sum - odd_max + even_sum - even_2nd
    else:
        ans = odd_sum - odd_2nd + even_sum - even_max
else:
    ans = odd_sum - odd_max + even_sum - even_max
print(ans)


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

using namespace std;
typedef long long ll;

#define rep(i, N) for (int i = 0; i < (int)N; i++)
const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,29)-1;


int main() {
  int N; cin >> N;
  ll K; cin >> K;
  ll A[N], B[N]; rep(i,N) cin >> A[i] >> B[i];

  ll result = 0;
  rep(i,32) {
    if (i!=0 && !(K&(1<<i))) continue;
    ll tk = (i==0) ? K : K-K%(1<<i)-1;
    ll tr = 0;
    rep(j,N) if ((tk|A[j])==tk) tr += B[j];
    result = max(result, tr);
    // cout << tk << " " << i << endl;
    // rep(j,N) cout << (tk|A[j]) << " "; cout << endl;
  }

  cout << result << endl;
  return 0;
}

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

int main(void)
{
    int i, N, M;
    scanf("%d %d", &N, &M);
    int p[M];
    char str[M][2];
    int error[N + 1];
    int judge[N + 1];
    int c1 = 0;
    int c2 = 0;

    for (i = 0; i <= N; i++)
    {
        error[i] = 0;
        judge[i] = 0;
    }

    for (i = 0; i < M; i++)
    {
        scanf("%d %s", &p[i], str[i]);
        if (strcmp(str[i], "WA") == 0 && judge[p[i]] == 0)
        {
            error[p[i]] += 1;
        }
        else if (strcmp(str[i], "AC") == 0 && judge[p[i]] == 0)
        {
            c1 += 1;
            c2 += error[p[i]];
            judge[p[i]] += 1;
        }
    }
    printf("%d %d\n", c1, c2);
    return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int descending_compare(const void *a, const void *b){
    if (*(int*)a > *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}

int ascending_compare(const void *a, const void *b){
    if (*(int*)a < *(int*)b){
        return -1;
    }else if (*(int*)a == *(int*)b){
        return 0;
    }else{
        return 1;
    }
}


int lower_bound(int *a, int n, int key){
    int left, mid, right;
    left = 0, right = n;
    mid = (left + right)/2;
    while ((left+1 != mid || mid+1 != right) && mid != left){
        if (key > a[mid]){
            left = mid;
        }else{
            right = mid+1;
        }
        mid = (left + right)/2;
    }
    if (a[left] >= key)return left;
    if (a[mid] >= key)return mid;
    if (a[right] >= key)return right;
    return n;
}

unsigned long  gcd(unsigned long x, unsigned long y)
{
        if (y == 0) {
                return x;
        } else {
                return gcd(y, x % y);
        }
}



long long calc(int x){
    long long rtn = 1;
    int i;
    for (i = x; i > 1; i--){
        rtn = (rtn*i);
    }
    return rtn;
}

int s[105];
int dp[10005] = {0};

int main(void){
    int n;
    scanf("%d", &n);
    int i, j;
    for (i = 0; i < n; i++){
        scanf("%d", &s[i]);
    }
    dp[0] = 1;
    for (i = 0; i < n; i++){
        for (j = 10004; j >= 0; j--){
            if (dp[j-s[i]] == 1){
                dp[j] = 1;
            }
            if (j-s[i] == 0){
                break;
            }
        }
    }

    for (i = 10004; i >= 0; i--){
        if (dp[i] == 1 && i % 10 != 0){
            printf("%d\n", i);
            return 0;
        }
    }

    printf("0\n");
    







    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=100000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u];i;i=sq[i].nxt)
#define fir first
#define sec second
#define mp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

namespace My_Math{
	#define N 100000

	int fac[N+100],invfac[N+100];

	int add(int x,int y) {return x+y>=maxd?x+y-maxd:x+y;}
	int dec(int x,int y) {return x<y?x-y+maxd:x-y;}
	int mul(int x,int y) {return 1ll*x*y%maxd;}
	ll qpow(ll x,int y)
	{
		ll ans=1;
		while (y)
		{
			if (y&1) ans=mul(ans,x);
			x=mul(x,x);y>>=1;
		}
		return ans;
	}
	int inv(int x) {return qpow(x,maxd-2);}

	int C(int n,int m)
	{
		if ((n<m) || (n<0) || (m<0)) return 0;
		return mul(mul(fac[n],invfac[m]),invfac[n-m]);
	}

	int math_init()
	{
		fac[0]=invfac[0]=1;
		rep(i,1,N) fac[i]=mul(fac[i-1],i);
		invfac[N]=inv(fac[N]);
		per(i,N-1,1) invfac[i]=mul(invfac[i+1],i+1);
	}
	#undef N
}
using namespace My_Math;
int n,m,dis[5050],cost[5050][210],sta[210][5050],tp[210];
ll val[5050];

void insert(int pos,int id,int sta[5050],int &tp)
{
	//cout << "id=" << id << endl;
	//rep(i,1,tp) cout << sta[i] << " ";cout << endl;
	while ((tp) && (cost[pos][id]>=cost[sta[tp]][id]))
	{
		val[sta[tp]]-=cost[sta[tp]][id];
		if (tp>1)
			val[sta[tp-1]]+=cost[sta[tp]][id];
		tp--; 
	}
	sta[++tp]=pos;
	val[pos]+=cost[pos][id];
	if (tp>1)
		val[sta[tp-1]]-=cost[pos][id];
	//rep(i,1,tp) cout << sta[i] << " ";cout << endl;
}
		

int main()
{
	n=read();m=read();
	rep(i,1,n-1) dis[i]=read();
	rep(i,1,n) rep(j,1,m) cost[i][j]=read();
	ll ans=-1e18;
	per(i,n,1)
	{
		rep(j,1,m) insert(i,j,sta[j],tp[j]);
		ll now=0;
		rep(j,i,n)
		{
			now+=val[j];
			ans=max(now,ans);
			now-=dis[j];
		}
	}
	printf("%lld",ans);
	return 0;
}



Measured memory_bytes: 6912
using System;

namespace AOJ_Intro_Rectangle
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			int x, y;
			string[] inputdata;
			inputdata = Console.ReadLine ().Split(" ".ToCharArray());
			x = int.Parse (inputdata [0]);
			y = int.Parse (inputdata [1]);

			Console.WriteLine ("{0} {1}",x * y, 2*x + 2*y);
		}
	}
}

Measured memory_bytes: 5620
#include <iostream>
#include <string>
int main() {
	std::string str;
	std::cin >> str;
	auto a = str.begin();
	for (; a != str.end() && (*a) != 'A'; ++a) {}
	auto z = str.end() - 1;
	for (; z != str.begin() && (*z) != 'Z'; --z) {}
	std::cout << (z - a + 1) << std::endl;
	return 0;
}

Measured memory_bytes: 640
fun main(args: Array<String>) {
    var (N, W) = pairIntLong()
    val WV = Array(N) { pairIntLong() }
    val WVs = Array(4) { mutableListOf<Long>() }
    val baseW = WV[0].first.toLong()
    WV.forEach { wv -> WVs[wv.first - WV[0].first].add(wv.second) }
    WVs.forEach {
        it.sortDescending()
        it.add(0, 0)
    }
    var ans = 0L
    for (n0 in (0 until WVs[0].size).reversed())
    for (n1 in (0 until WVs[1].size).reversed())
    for (n2 in (0 until WVs[2].size).reversed())
    for (n3 in (0 until WVs[3].size).reversed()) {
        val w0 = (baseW + 0) * n0
        val w1 = (baseW + 1) * n1
        val w2 = (baseW + 2) * n2
        val w3 = (baseW + 3) * n3
        if (w0 + w1 + w2 + w3 > W) continue
        val v0 = WVs[0].subList(0, n0 + 1).sum()
        val v1 = WVs[1].subList(0, n1 + 1).sum()
        val v2 = WVs[2].subList(0, n2 + 1).sum()
        val v3 = WVs[3].subList(0, n3 + 1).sum()
        ans = Math.max(ans, v0 + v1 + v2 + v3)
    }
    println(ans)
}
fun pairIntLong(offset: Pair<Int, Long> = Pair(0, 0L)) = listOfLong().let { Pair(it[0].toInt() + offset.first, it[1] + offset.second) }

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)
fun listOfLong() = listOfString().map(String::toLong)


Measured memory_bytes: 48520
using System;

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var rn = getRoot(n);
            var dp = new int[rn + 1, n + 1];
            for (int i = 0; i <= rn; i++) dp[i, 0] = 1;
            for (int i = 0; i <= n; i++) dp[1, i] = 1;
            for (int i = 1; i <= rn; i++)
                for (int j = 1; j <= n; j++)
                {
                    var w = i * i;
                    if (j - w >= 0) dp[i, j] = dp[i, j - w];
                    dp[i, j] += dp[i - 1, j];
                }
            Console.WriteLine(dp[rn,n]);
        }
    }
    public static int getRoot(int n)
    {
        for (int i = 1; i <= 18; i++)
            if (i * i == n) return i;
            else if (i * i > n) return i - 1;
        return 0;
    }
}




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

using namespace std;

int main() {
    int n,k,q;
    cin >> n >> k >> q;
    vector<int> a(q);
    for (int i = 0; i < q; i++) {
        cin >> a.at(i);
    }

    map<int,int> x;
    for (int i = 1; i <= n; i++) {
        x.emplace(i,0);
    }

    for (int i = 0; i < q; i++) {
        x.at(a.at(i))++;
    }

    for (int i = 1; i <= n; i++) {
        if (x.at(i) > q - k) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

 
int main(){
  int x,a,b;
  cin >> x >> a >> b;
  if(a>=b){cout << "delicious" << endl; return 0; }
  if(a+x>=b){cout << "safe" << endl; return 0; }

  cout << "dangerous" << endl; 
  return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
# import math
# from string import ascii_lowercase, ascii_upper_case, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)


def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1               # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    n = ii()
    for i in range(26):
        for j in range(15):
            if 4 * i + 7 * j == n:
                print('Yes')
                exit()
    print('No')


if __name__ == "__main__":
    main()


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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

int main() {
  string s;
  cin >> s;
  int count = 0;
  if (s.at(0) == '1') {
    count++;
  }
  if (s.at(1) == '1') {
    count++;
  }
  if (s.at(2) == '1') {
    count++;
  }
  cout << count << endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    //--<for debugging>
    #define whatis(x) cout << #x << " is " << x<<" ";
    #define whatisl(x) cout << #x << " is " << x<<"\n";
    #define parr(array,end)for(ll loop=0;loop<end;loop++)cout<<array[loop]<<" ";cout<<"\n";
    #define lline cout<<"\n";
    #define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"\n";}
    #define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"___";}
        
    void err(istream_iterator<string> it) {}
    template<typename T, typename... Args>
    void err(istream_iterator<string> it, T a, Args... args) {
        cout << *it << " = " << a <<" , ";
        err(++it, args...);
    }
    //--</for debugging> 
    #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
    #define testcase ll tt; cin >> tt; while(tt--)
    #define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
    #define pb push_back 
    #define vars ll h,i,j,k,d,l,p,q,r,x,y,a,b,c,v,var,n,m,z,s,ans,ind1,ind2,flag,limit1,limit2,limit3,mod;
    #define vll vector<ll>
    #define pll pair<ll,ll>
    #define sll set<ll>
    #define pint pair<int,int>
    const ll INF=1e9+7;
    const ll MOD=1e9+7;
    int main()
    {
        boost vars
        cin>>k>>s;
        ans=0;
        for(i=0;i<=k;i++)
        {
            v=s-i;
            ans=ans+max(0ll,min(v,k)-max(0ll,v-k)+1);
        }
        cout<<ans;
    }

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

int N;
int arr[100005];
int ans[100005];

void solve()
{
    ans[1] = 0;
    ans[2] = abs(arr[2] - arr[1]);
    for(int i = 3 ; i <= N ; i++){
        ans[i] = min(ans[i - 2] +  abs(arr[i] - arr[i-2])   ,  ans[i - 1] + abs(arr[i] - arr[i - 1]) );
    }

}

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

    cin >> N;
    for(int i = 1 ; i <= N ; i++){
        cin >> arr[i];
    }
    solve();
    cout << ans[N] << '\n';
    return 0;

}


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

#define ull unsigned long long
#define ll long long
#define pb push_back
#define pii pair<int, int>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

const int INF = 1e9 + 7;


int main(void)
{
	FAST
	
	int a, b; cin >> a >> b;
cout << a*b << '\n';	
	
	return 0;
}


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

      bool maze[101][101];

      int main(){
         int w,h,n;
         cin >> w >> h >> n;
         rep(q,n){
            int x,y,a;
            cin >> x >> y >> a;
            x--;y--;
            
            if (a == 1){
               for (int i = 0;i <= x;i++){
                  for (int j = 0;j < h;j++){
                     maze[i][j] = true;
                  }
               }
            }
            else if(a == 2){
               for (int i=x+1;i < w;i++){
                  for (int j = 0;j < h;j++){
                     maze[i][j] = true;
                  }
               }
            }
            else if (a == 3){
               for (int i = 0;i < w;i++){
                  for (int j = 0;j <= y;j++){
                     maze[i][j] = true;
                  }
               }
            }
            else if(a == 4){
               for (int i = 0;i < w;i++){
                  for (int j = y+1;j < h;j++){
                     maze[i][j] = true;
                  }
               }
            }
            //for (int i=0;i < w;i++){
            //for (int j = 0;j < h;j++){
            //   if (maze[i][j] == false) {
            //      //ans++;
            //      cout << 'x';
            //   }
            //   else cout << 'o';
            //}
            //cout << endl;
            //}
            //cout << endl;
         }
         int ans = 0;
         for (int i=0;i < w;i++){
            for (int j = 0;j < h;j++){
               if (maze[i][j] == false) {
                  ans++;
                  //cout << 'x';
               }
               //else cout << 'o';
            }
            //cout << endl;
         }

         cout << ans << endl;
         

   

         
         return 0;
         
      }



Measured memory_bytes: 256
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;

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

int main(){
	ll a,b;
	scanf("%lld %lld",&a,&b);
	printf("%lld\n",(a-1)*(b-1));
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e4+10;

int n,k,L[N];
string s;

int main() {
	cin>>n>>k>>s;
	char mn=*min_element(s.begin(),s.end());
	string t=s;reverse(t.begin(),t.end());t=s+t;
	for(int i=0;i<n+n;i++) {
		if(i&&t[i]==mn) L[i]=L[i-1]+1;
		else L[i]=0;
	}
	int mx=*max_element(L,L+n+n),len=mx;
	while(k>1&&len<n) --k,len<<=1;
	if(len>=n) cout<<string(n,mn);
	else {
		string ans;
		for(int i=n-1;i<n+n;i++)
			if(L[i]==mx) {
				string tmp=string(len,mn)+t.substr(n+n-1-i+mx,n-len);
				if(ans.empty()||ans>tmp) ans=tmp;
			}
		cout<<ans;
	}
	return 0;
}


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

bool pal(string s, int q = 1){
    int n = s.size();
    if(n == 1 || n == 0) return true;

    for(int i = 0; i < n/2; i++)
        if(s[i]!=s[n-i-1])
            return false;

    if(q == 0) return true;
    return pal(s.substr(0,n/2), q-1) && pal(s.substr(n/2+1, n), q-1);
}

int main(){
    string s;
    cin >> s;
    cout << (pal(s) ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"
#include "string"

using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i = 0; i < n; i++)

ll f(ll n) {
	ll ret = 0;
	while (ret * ret <= n) ret++;
	return ret;
}

ll g(ll p, ll q) {
	ll ret = 0;
	while (p % q == 0) {
		p /= q;
		ret++;
	}
	return ret;
}

int main() {
	int n; cin >> n;
	vector<ll> a(n);
	rep(i, n) {
		ll p; cin >> p;
		if (p == 0) {
			cout << 0 << endl;
			return 0;
		}
		a[i] = p;
	}
	sort(a.begin(), a.end());
	reverse(a.begin(), a.end());
	ll ans = 1;
	for (auto c : a) {
		ans *= c;
		if (ans > 1000000000000000000 || ans <= 0) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans << endl;
	return 0;

}

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

int main() {
    // 制約見て！！！デカかったらlong longにすること！
    int n, k;
    cin >> n >> k;

    long ans = k;
    if(n >= 2)
        ans = ans * pow(k-1,n-1);
    cout << ans << endl;
}

Measured memory_bytes: 4016
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  string s;
  cin>>s;
  ll si=sz(s);
  ll ans=0;
  ll a,z;
  cin>>a>>z;
  a=0;
  z=0;
  rep(i,si){
    if(s[i]=='0') a++;
    else z++;
  }
  ans=min(a,z);
  COUT(2*ans);
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstring>

const int MAXN = 500;

int n, m;
char a[MAXN + 2][MAXN + 2], b[MAXN + 2][MAXN + 2];

int main() {
  // freopen("code.in", "r", stdin);
  // freopen("code.out", "w", stdout);
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", a[i] + 1);
    for (int j = 1; j <= m; ++j) b[i][j] = a[i][j];
  }
  for (int i = 1; i <= n; i += 2) for (int j = 1; j < m; ++j) a[i][j] = '#';
  for (int i = 1; i <= m; ++i) a[i][1] = '#';
  for (int i = 2; i <= n; i += 2) for (int j = 2; j <= m; ++j) b[i][j] = '#';
  for (int i = 1; i <= m; ++i) b[i][m] = '#';
  for (int i = 1; i <= n; ++i) printf("%s\n", a[i] + 1);
  printf("\n");
  for (int i = 1; i <= n; ++i) printf("%s\n", b[i] + 1);
  return 0;
}


Measured memory_bytes: 4080
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC165
{
    class A
    {
        static void Main(string[] args)
        {
            var K = long.Parse(Console.ReadLine());
            var AB = Console.ReadLine().Split().Select(long.Parse).ToArray();

            for (long i = AB[0]; i <= AB[1]; i++)
            {
                if (i % K == 0) { Console.WriteLine("OK"); return; }
            }
            Console.WriteLine("NG");
        }
    }
}


Measured memory_bytes: 28172
#include<stdio.h>
#include<stdlib.h>
void bubbleSort(int *A,int N);
int main(){
  int *A,i,N;
  scanf("%d\n",&N);
  A=(int *)malloc(N*sizeof(int));
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  bubbleSort(A,N);
  return 0;
}
void bubbleSort(int *A,int N){
  int flag=1,i,count=0,j,v;
  while(flag){
    flag=0;
    for(j=N-1;j>=1;j--){
      if(A[j]<A[j-1]){
	count++;
	v=A[j];
	A[j]=A[j-1];
	A[j-1]=v;
	flag=1;
      }
    }
  }

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






Measured memory_bytes: 2144
s=[0]*24
s[12]=1
n=int(input())
a=list(map(int,input().split()))
d=[a.count(i)for i in range(13)]
d[0]+=1
if max(d[0],d[12])<2 and max(d[1:-1])<3:
    if d[12]==1:
        s[0]=1
    t=[]
    for i in range(1,12):
        if d[i]==2:
            s[12-i]=1
            s[12+i]=1
        elif d[i]==1:
            t.append(i)
    k=0
    for i in range(2**len(t)):
        p=bin(i)[2:]
        p="0"*(len(t)-len(p))+p
        r=s[:]
        for j in range(len(t)):
            if p[j]=="0":
                r[12-t[j]]=1
            else:
                r[12+t[j]]=1
        h=0
        q=0
        ans=30
        for j in 2*r:
            if j==1:
                if h==0:
                    q=1
                    h=1
                else:
                    ans=min(q,ans)
                    q=1
            else:
                q+=1
        k=max(ans,k)
    print(k)
else:
    print(0)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
//#define int long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (10);   小数点以下１０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//string s = to_string(int数);
//int n = stoi(string文字列);

int main() {
  int a,b;
  cin >>a>>b;
  
  cout << a*(a-1)/2+b*(b-1)/2 << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
typedef vector<vector<ll> > Graph;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1e18;

int main(){
    ll n;
    cin >> n;
    ll c = 0;
    ll t = 1;
    while(1){
        t *= 26;
        c++;
        if(t>=n)break;
        n -= t;
    }
    n -= 1;
    string ans = "";
    rep(i,c){
        char m = 'a' + n%26;
        ans += m;
        n /=26;
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3612
function main(input) {
    var h = input[0].split(" ")[0]-0;
    var w = input[0].split(" ")[1]-0;
    var map = [];
    for(var i=1;i<=h;i++){
        map.push(input[i].split(""));
    }
    for(var i=0;i<h;i++){
        for(var j=0;j<w;j++){
            if(map[i][j] == "#"){
                if(map[i] && (map[i][j-1] == '#' || map[i][j+1] == '#')){
                    continue;
                }
                if((map[i-1] && map[i-1][j] == '#' )|| (map[i+1] && map[i+1][j] == '#')){
                    continue;
                }
                console.log("No");
                return;
            }
        }
    }
    console.log("Yes");
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').trim().split("\n"));


//1 2 3 4 5 6


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



#define SIZE 100005

ll N;
ll S[SIZE];
set<ll> SET;

int main(){

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

		scanf("%lld",&S[i]);
	}

	ll ans = 0;
	ll L,R;

	for(ll diff = 1; diff <= N-2; diff++){

		ll tmp = 0;
		SET.clear();

		L = 0,R = N-1;
		SET.insert(L);
		SET.insert(R);

		while(true){

			L += diff;
			R -= diff;
			if(R <= diff)break;

			if(L <= N-1 && SET.count(L)){
				break;
			}
			if(L == R)break;
			if(SET.count(R)){
				break;
			}
			if(L <= N-1){
				SET.insert(L);
				tmp += S[L];
			}
			SET.insert(R);
			tmp += S[R];
			ans = max(ans,tmp);
		}
	}

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

	return 0;
}


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

int M;
int a[7];
int s, g;
int N[301];

bool isChecked[301];
vector<int> milestone[301];  //そのマスで出せばゴールにたどり着ける目を格納する

int iabs(int x){ return x >= 0 ? x : -x; }

bool search(int now){
	if (isChecked[now]) return false;
	else if (now == g)  return true;

	isChecked[now] = true;
	for (int dice = 1; dice <= 6; dice++){
		if (now + a[dice] <= M && search(now + a[dice] + N[now + a[dice]])){
			milestone[now].push_back(a[dice]);
		}
		if (now - a[dice] >= 1 && search(now - a[dice] + N[now - a[dice]])){
			milestone[now].push_back(-a[dice]);
		}
	}

	return milestone[now].size() > 0 ? true : false;
}

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

	cin >> M;
	for (int i = 1; i <= 6; i++){
		cin >> a[i];
	}
	cin >> s >> g;
	for (int i = 1; i <= M; i++){
		cin >> N[i];
	}
	bool canGoal = search(s);

	int now = s; //自分が今いるマスの番号
	for (;;){
		int dice;
		cin >> dice;

		bool found = false;
		for (vector<int>::iterator it = milestone[now].begin(); it != milestone[now].end(); it++){
			if (iabs(*it) == a[dice]){
				if (*it > 0){
					now = now + a[dice] + N[now + a[dice]];
					cout << 1 << endl;
				}
				else{
					now = now - a[dice] + N[now - a[dice]];
					cout << -1 << endl;
				}
				found = true;
				break;
			}
		}
		if(!found) cout << 0 << endl;
		cout.flush();

		if (now == g) return 0;
	}
	
	return 0;
}

Measured memory_bytes: 1308
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
n,a,b=map(int,input().split())
v=sorted(list(map(int,input().split())),reverse=1)
tmp=sum(v[:a])
ans=(tmp,a)
x=[a-1]
for i in range(a,b):
    tmp+=v[i]
    if ans[0]*(i+1)<=ans[1]*tmp:
        if ans[0]*(i+1)==ans[1]*tmp:
            x.append(i)
        else:
            x=[i]
print(ans[0]/ans[1])
ans=0
for i in x:
    a,b=v.count(v[i]),v[i+1:].count(v[i])
    ans+=comb(a,b)
print(ans)

Measured memory_bytes: 3064
import math

N = int(input())

minimum = None
for i in range(1, int(math.sqrt(N) + 1)):
    is_dividable = N % i == 0
    if is_dividable:
        j = int(N / i)
        foo = i + j - 2
        minimum = foo if minimum is None else min(minimum, foo)

print(minimum)


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

int n;
bool udah[11];
int a[11];

void p(int digitke) {
	if (digitke>n) {
		for (int i=1; i<=n; i++) {
			if (i==1) cout<<a[i];
			else cout<<" "<<a[i];
		}
		cout<<endl;
	}
	else {
		for (int i=1; i<=n; i++) {
			if (udah[i]==false) {
				udah[i]=true;
				a[digitke]=i;
				p(digitke+1);
				udah[i]=false;
			}
		}
	}
}
int main() {
	cin>>n;
	p(1);
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a;
	string dizi;
	cin>>a>>dizi;
	int t=0;
	for(int i=0;i<a-2;i++){
		if(dizi[i]=='A' && dizi[i+1]=='B' &&dizi[i+2]=='C' )
		{
			t++;
		}
	}
	cout<<t;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define FIND(c, n)      std::find((c).begin(), (c).end(), (n));
#define BSEARCH(c, n)   std::binary_search((c).begin(), (c).end(), (n))
#define LLPOW(p1,p2)    ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)       fgets((p), sizeof(p), stdin)
#define CHOMP(p)        do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)

typedef long long ll;
typedef unsigned long long ull;

#ifdef _DEBUG
#define pf printf
#define pr(n) do { cout << #n " = " << (n) << endl; } while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif

#define X real()
#define Y imag()
typedef double D;
typedef complex<D> P;
#define EPS (1e-9)

inline D inprd(const P &a, const P &b){ return (conj(a) * b).X; }
inline D outprd(const P &a, const P &b){ return (conj(a) * b).Y; }

int main(){
    double xA,yA,xB,yB,xC,yC,xD,yD;
    while(cin >> xA >> yA >> xB >> yB >> xC >> yC >> xD >> yD){
        P ab(xB-xA, yB-yA), cd(xD-xC, yD-yC);
        pr(ab);pr(cd);

        if(inprd(ab, cd) == 0){
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1220
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#define int long long
#ifndef FAST_IO
  #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
#endif
#define ff first
#define ss second
#define endl "\n"
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" "; cout<<endl;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void solve(){
   int n;
   string s;
   cin>>n>>s;
   int c1=count(all(s),'R');
   int c2=count(all(s),'B');
   cout<<(c1>c2?"Yes":"No")<<endl;
}
int32_t main(){
   IOS;
   solve();
   //debug();
  #ifdef LOCAL_DEFINE
   cerr<<"time elapsed "<<(double)clock()/CLOCKS_PER_SEC<<endl;
  #endif	
}


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

int main() 
{
	int nagasa, make=0;
	string a;
	cin >> a;
	nagasa = a.size();
	for (int i = 0; i < nagasa; i++) {
		if (a.at(i) == 'x') {
			make = make + 1;
		}
	}
	if (make > 7) {
		cout << "NO" << endl;
	}
	else {
		cout << "YES" << endl;
	}
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define ft first
#define sd second
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

const ll MOD=1e9+7;

ll ad(ll x,ll y=0){
  return (x+y)%MOD;
}

ll hiku(ll x,ll y=0){
  return ad(x,2*MOD-y);
}

ll mlt(ll x,ll y=1){
  return (x*y)%MOD;
}

ll pwr(ll x,ll y){
  ll pw[32]={},w=1;
  pw[0]=x;
  fr(i,31) pw[i+1]=mlt(pw[i],pw[i]);
  fr(i,32){
    w=mlt(w,1+(y%2)*(pw[i]-1));
    y/=2;
  }
  return w;
}

ll inv(ll x){
  return pwr(x,MOD-2);
}

ll fc[200010]={1};
ll fct(ll x){
  if(fc[x]==0) fc[x]=mlt(x,fct(x-1));
  return fc[x];
}

ll ifc[200010]={1};
ll ifct(ll x){
  if(ifc[x]==0) ifc[x]=inv(fct(x));
  return ifc[x];
}

ll comb(ll n,ll r){
  if(n<0 || r<0 || n<r) return 0;
  return mlt(fct(n),mlt(ifct(r),ifct(n-r)));
}

int main(){
  ll b,w,kari,s=0,t=0,u,sp=0;
  cin>>b>>w;
  fr(i,b+w){
    s=ad(s,mlt(pwr(500000004,i),hiku(comb(i,i-w),comb(i-1,i-1-w))));
    t=ad(t,mlt(pwr(500000004,i),hiku(comb(i,i-b),comb(i-1,i-1-b))));
    u=hiku(1,ad(s+t));
    cout<<ad(s,500000004*u)<<endl;
  }
}

Measured memory_bytes: 6144