akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int r,g,b,n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    int nr=0;
    while(nr*r<=n){
        int rm = n-nr*r;
        int ng = 0;
        while(ng*g<=rm){
            if((rm-ng*g)%b==0){
                ans++;
            }
            ng++;
        }
        nr++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
//09-4 薄氷渡り
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<time.h>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<set>
#include<stack>
#include<cstdlib>
#include<algorithm>
#include<random>
#include<cassert>
using namespace std;
#define LL long long
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define ROOP() while(true)

int m,n;
bool save[90][90];
bool mp[90][90];
int ans;

void reset(){
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            mp[j][i] = save[j][i];
        }
    }
}

void move(int x, int y, int c){
    c++;
    ans = max(ans,c);

    if(x-1>=0 && mp[x-1][y]==true){
        mp[x-1][y] = false;
        move(x-1,y,c);
        mp[x-1][y] = true;
    }
    if(x+1<=m-1 && mp[x+1][y]==true){
        mp[x+1][y] = false;
        move(x+1,y,c);
        mp[x+1][y] = true;
    }
    if(y-1>=0 && mp[x][y-1]==true){
        mp[x][y-1] = false;
        move(x,y-1,c);
        mp[x][y-1] = true;
    }
    if(y+1<=n-1 && mp[x][y+1]==true){
        mp[x][y+1] = false;
        move(x,y+1,c);
        mp[x][y+1] = true;
    }
}

int main(){
    ROOP(){
        cin >> m >> n;
        if(m==0 || n==0) break;

        ans = 0;

        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                int tmp;
                cin >> tmp;
                if(tmp==0) save[j][i] = false;
                else save[j][i] = true;
            }
        }

        reset();
        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                if(save[j][i]){
                    mp[j][i] = false;
                    move(j,i,0);
                    mp[j][i] = true;
                }
            }
        }
        cout << ans << endl;
    }
    return 0;
}



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

public class Main {

	public static void main(String[] args) throws NumberFormatException,
			IOException {
		BufferedReader reader = new BufferedReader(new InputStreamReader(
				System.in));
		StringBuilder builder = new StringBuilder();
		int max = 50000;
		boolean[] primes = new boolean[max + 1];
		int count = 1;
		for (int i = 3; i <= max; i += 2) {
			if (!primes[i]) {
				count++;
				if (i <= Math.sqrt(max)) {
					for (int j = i; j <= max / i; j += 2) {
						primes[(int) (i * j)] = true;
					}
				}
			}
		}
		int[] prime = new int[count];
		prime[0] = 2;
		int count2 = 1;
		for (int i = 3; i <= max; i += 2) {
			if (!primes[i]) {
				prime[count2] = i;
				count2++;
			}
		}
		int[] g = new int[max + 1];
		for (int i = 0; i <= prime.length; i++) {
			for (int j = i; j < prime.length && prime[i] + prime[j] <= max; j++) {
				g[prime[i] + prime[j]]++;
			}
		}

		while (true) {
			int n = Integer.parseInt(reader.readLine());
			if (n == 0) {
				break;
			}
			builder.append(g[n]).append('\n');
		}
		System.out.print(builder);

	}
}

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

int main() {
	int n, m, Matrix[100][100], Vector[100], Scalar[100];

	cin >> n >> m;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)cin >> Matrix[i][j];
	for (int i = 0; i < m; i++)cin >> Vector[i];

	for (int i = 0; i < n; i++) {
		Scalar[i] = 0;
		for (int j = 0; j < m; j++) {
			Scalar[i] += Matrix[i][j] * Vector[j];
		}
	}

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


Measured memory_bytes: 3136
n, u, v = map(int, input().split())
u, v = u-1, v-1
reach = [[] for _ in range(n)]
for i in range(n-1):
    a, b = map(lambda x: int(x)-1, input().split())
    reach[a].append(b)
    reach[b].append(a)

def x_route(x, reach):
    x_route = [-1] * n
    check = [0] * n
    stack = [x]
    check[x] = 1
    x_route[x] = 0
    while len(stack) > 0:
        tmp = stack.pop(-1)
        tmp_list = reach[tmp]
        for i in tmp_list:
            if check[i] != 1:
                stack.append(i)
                check[i] = 1
                x_route[i] = x_route[tmp]+1
    return x_route

a_route = x_route(v, reach)
t_route = x_route(u, reach)
ans = 0
for i in range(len(a_route)):
    if t_route[i] < a_route[i]:
        ans = max(ans, a_route[i]-1)

print(ans)

Measured memory_bytes: 29776
#include <iostream>
#include <stdio.h>
#define llint long long

using namespace std;

llint n, m, d;

int main(void)
{
	cin >> n >> m >> d;
	
	llint n2 = max(0LL, n - 2*d);
	llint n1 = n - n2;
	llint s = n2*2 + n1;
	
	if(d == 0) s = n;
	
	double ans = s * (m-1) / (double)(n*n);
	printf("%.11f\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<unordered_set>
#include<unordered_map>
#include<random>
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

const ll INF = 1'000'000'000'000'000'000LL;

int N;
ll A[200000];

ll memo[200000][3];
bool visited[200000][3] ={};
ll solve(int n, int nokori){
    if(nokori < 0) return -INF;
    if(n >= N) return 0;
    if(n+2 >= N && nokori == 2) return 0;
    if(visited[n][nokori]) return memo[n][nokori];
    visited[n][nokori] = true;
    return memo[n][nokori] = max(solve(n+2, nokori)+A[n], solve(n+1, nokori-1));
}

signed main(){
    cin >> N;
    rep(i, N) cin >> A[i];
    if(N%2 == 0) cout << solve(0, 1) << endl;
    else cout << solve(0, 2) << endl;
}

Measured memory_bytes: 16720
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int[][] num = new int[10000][10000];
		for(int i = 0; i < num.length; i++) {
			for(int j = 0; j < 2; j++) {
				num[i][j] = scan.nextInt();
			}
			if(num[i][0] == 0 && num[i][1] ==0) break;
		}
		for(int i = 0; i < num.length; i++) {
			if(num[i][0] == 0 && num[i][1] == 0) break;
			if(num[i][0] > num[i][1]) {
				int tmp = num[i][0];
				num[i][0] = num[i][1];
				num[i][1] = tmp;
			}
			System.out.println(num[i][0] + " " + num[i][1]);
		}
	}
}


Measured memory_bytes: 457848
JUMP = [
  [-1, -2], [0, -2], [1, -2],
  [2, -1], [2, 0], [2, 1],
  [1, 2], [0, 2], [-1, 2],
  [-2, 1], [-2, 0], [-2, -1]
]

def dfs(x, y, splinklers, n, depth = 0)
  return true if depth == n

  for i in 0...JUMP.size
    _x = x + JUMP[i][0]
    _y = y + JUMP[i][1]
    d = (_x - splinklers[depth][0])**2 + (_y - splinklers[depth][1])**2
    if 0 <= _x && _x < 10 && 0 <= _y && _y < 10 && d <= 2
      return true if dfs(_x, _y, splinklers, n, depth + 1)
    end
  end

  false
end

while line = gets
  x, y = line.chomp.split.map(&:to_i)
  break if x == 0 && y == 0
  n = gets.chomp.to_i
  data = gets.chomp.split.map(&:to_i)
  splinklers = []
  for i in 0...n
    splinklers << data.slice(i * 2, 2)
  end

  puts (dfs(x, y, splinklers, n)) ? :OK : :NA
end

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

int main()
{
    int N; cin >> N;
    string S(N, 'a'), T(N, 'a');
    string ans(2*N, 'a');

    cin >> S >> T;
    //cout << S << ' ' << T << endl;
    for (int i=0; i<N; i++) {
        ans[2*i] = S[i];
        ans[2*i+1] = T[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import deque
n = int(input())
deq = deque([])
for i in range(n):
    A = input().split()
    a = A[0]
    if len(A) == 2:
        b = A[1]
    if a == "insert":
        deq.appendleft(b)
    elif a == "deleteFirst":
        deq.popleft()
    elif a == "deleteLast":
        deq.pop()
    else:
        try:
            deq.remove(b)
        except:
            continue
print(" ".join(list(deq)))


Measured memory_bytes: 69624
int a,b,c,d,s;main(n){for(;~scanf("%d",&n);printf("%d\n",s))for(a=b=c=d=s=0;d<=9;b+=++a/10,a%=10,c+=b/10,b%=10,d+=c/10,c%=10)s+=a+b+c+d==n;}

Measured memory_bytes: 0
using System;
using System.Collections;
using System.Collections.Generic;

class Program
{
    static int GCD(int a,int b)
    {
        if (a < b)
            return GCD(b, a);
        else
        {
            if (b == 0)
                return a;
            else
                return GCD(b, a % b);
        }
    }
    
    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        var S = Console.ReadLine().Split(' ');
        int[] A = new int[N];

        for (int i = 0; i < N; i++)
            A[i] = int.Parse(S[i]);
        int[] gcdf = new int[N];
        int[] gcdb = new int[N];
        gcdf[0] = A[0];
        for (int i = 1; i < N; i++)
            gcdf[i] = GCD(gcdf[i - 1], A[i]);
        
        gcdb[N - 1] = A[N - 1];
        for (int i = N - 2; i >= 0; i--)
            gcdb[i] = GCD(gcdb[i + 1], A[i]);
        
        int m = Math.Max(gcdb[1], gcdf[N - 2]);
        for (int i = 1; i <= N - 2; i++)
            m = Math.Max(m, GCD(gcdf[i - 1], gcdb[i + 1]));

        Console.WriteLine(m);
    }
}

Measured memory_bytes: 25820
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
#define ll long long
using namespace std;
void put(int x){
	if(x<0) {
		putchar('-');
		x*=-1;
	}
	if(x==0) {
		putchar('0');
	}
	int num=0;
	char c[15];
	while(x) {
		c[++num]=(x%10)+48;
		x/=10;
	}
	while(num) {
		putchar(c[num--]);
	}
	putchar('\n');
}
inline void in(int &x){
	char ch=getchar();
	int flag=1;
	while(!(ch>='0'&&ch<='9')) {
		if(ch=='-')
			flag*=-1;
		ch=getchar();
	}
	x=ch-'0';
	ch=getchar();
	while(ch>='0'&&ch<='9') {
		x=((x<<3)+(x<<1))+ch-'0';
		ch=getchar();
	}
	x*=flag;
}
unsigned ll ans=1,a[200005],last;int n; 
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	in(n);
	for(int i=1;i<=n;i++){
		cin>>a[i];if(a[i]==0){
			cout<<0<<endl;return 0;
		}
	}
	for(int i=1;i<=n;i++){
		ans=ans*(1ull)*a[i];
		if(ans>1000000000000000000||ans<0||ans<last){
			cout<<-1<<endl;return 0;
		}
		last=ans;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4404
from sys import exit, setrecursionlimit, stderr
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

N = read()
A = reads()

B = [A[i] - i for i in range(N)]
B.sort()

med = B[N//2]
ans = sum(abs(b - med) for b in B)

print(ans)


Measured memory_bytes: 27004
n=int(input())
l=[]
for i in range(n):
	b,f,r,v=[int(x) for x in input().split()]
	l.append([b,f,r,v])


count=[[[0 for i in range(10)] for j in range(3)] for k in range(4)]

#input
for i in l:
	b,f,r,v=i[0],i[1],i[2],i[3]
	count[b-1][f-1][r-1] += v


for s,m in enumerate(count):
	for n in m:
		for o in n:
			print(f" {o}",end="")
		print()
	if s<3:
		print("####################")



Measured memory_bytes: 5636
#include<stdio.h>
int main(void){
	int sum[4] = {0};
	int ticket;
	int many;
	int i;
	for(i = 0;i < 4;i++){
		scanf("%d %d",&ticket,&many);
		if(ticket == 1){
			sum[i] += 6000 * many;
		}
		else if(ticket == 2){
			sum[i] += 4000 * many;
		}
		else if(ticket == 3){
			sum[i] += 3000 * many;
		}
		else{
			sum[i] += 2000 * many;
		}
	}
	for(i = 0;i < 4;i++){
		printf("%d\n",sum[i]);
	}
	return 0;
}

Measured memory_bytes: 600
N = int(input())
s = {}
for _ in range(N):
    input_s = list(input())
    input_s = sorted(input_s)
    input_s = "".join(input_s)
    if input_s not in s.keys():
        s[input_s] = 0
    s[input_s] += 1
ans = 0
for key, value in s.items():
    if value >= 2:
        ans += value * (value - 1) // 2
print(ans)

Measured memory_bytes: 17808
import java.util.*

fun gcd(x: Int, y: Int): Int {
    var a = x
    var b = y
    if (b > a) {
        a = y
        b = x
    }
    var c = a % b
    while (c != 0) {
        a = b
        b = c
        c = a % b
    }
    return b
}

fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val a = cin.nextInt()
    val b = cin.nextInt()
    val k = cin.nextInt()
    
    var count = 0

    for (i in 0..99) {
        val j = 100 - i
        if (a % j == 0 && b % j == 0) {
            count += 1
        }
        if (count == k) {
            println(j)
            return
        }
    }
}

Measured memory_bytes: 29352
#include <iostream>

int main(){
  int N,K,X,Y;
  std::cin >> N >> K >> X >> Y;

  int fee = 0;

  if (N <= K)
    fee = X*N;
  else
    fee = X * K + Y * (N-K);

  std::cout << fee << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES    
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define quickIO()   {cin.tie(0);    cout.sync_with_stdio(false);}
#define rep(i,n)    for(ll i=0; i<(ll)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define fcout cout << fixed << setprecision(10) 
const ll inf = 1e18;
const ll mod = 1e9 +7;
     
ld sqrtld(ld x){
    ld left = 0, right = x;
    rep(i, 100){
        ld mid = (left + right)/2;
        if (mid*mid <= x)   left =mid;
        else    right = mid;
    }
    return left;
}

ll gcd(ll a, ll b){
    if(b>a){
        ll c =b; b=a;   a=c;
    }
    ll d = a%b;
    if(d==0){
        return b;
    }else if(d==1){
        return 1;
    }else{
        gcd(b,d);
    }
}


ll cul(ll n){
    return (n-1)*n/2;
}

ll a[200010];
ll b[200010];
int main (){
    ll n;  cin >> n;
    rep(i,n) cin >> a[i] >> b[i];
    ll ans=0;
    rep(i,n){
        if(a[i]!=b[i])  break;
        if(i==n-1){
            cout << ans << endl;
            return 0;
        }
    }
    ll m=inf;
    rep(i,n){
        ans += a[i];
        if(a[i]> b[i]){
            m = min(m, b[i]);
        }
    }
    ans -= m;
    cout << ans << endl;
}




Measured memory_bytes: 512
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200005
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main()
{
		//set<int>s;
		int n;
		cin >> n;
		set<int>s;
		for (int i=0 ; i<n ; i++)
		{
			int x;
			cin >> x;
			s.insert(x);
		}
		(int)s.size()==n? cout << "YES" << endl : cout << "NO" << endl;
		return 0;
}


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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)
#define repb(i, ed, st) for(int i=ed; i>=st; i--)

typedef long long ll;
typedef unsigned long long int llt;
typedef long double ld;

const long double PI  =3.141592653589793238463;
const int N = 5e5 + 10;
const ll INF = 1LL << 60;

template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}


vector<int> g[N];
bool viss[N];
int vis[N];

// Normal DFS
void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

// DFS with visiting status
void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

// DFS with strongly connected component
void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0 || vis[x] > (num+1))
      dfs2(x, curr, num+1);
}

// XOR from 0 to n
ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

// Power in logn with mod 1000000007
llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

// Factorial with dp
llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != 0) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}
// Combination
ll modcomb(ll n, ll r)
{
  if(n < r) return 0;
  ll res = fact(n);
  (res *= ppow(fact(r), M-2)) %= M;
  (res *= ppow(fact(n-r), M-2)) %= M;
  return res;
}

// String return to base b
string ansConv ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ansConv += to_string(x);
     return;
}

// Convert string to num wiht base b
llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

// Union Find
// Find()
int parent[N], ran[N];
int find(int x)
{
    if(parent[x]==x)return x;
    else return parent[x]=find(parent[x]);
}
// Union()
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y)return;

    if(ran[x]<ran[y])
        parent[x]=y;
    else{
        parent[y]=x;
        if(ran[x]==ran[y])ran[x]++;
    }
}

// Main Code

int main()
{
  int n;
  cin>>n;
  int f, t, nn;
  f=t =nn = 0;
  rep(i, 0, n)
  {
    ll a;
    cin>>a;
    if(a % 4 == 0)f++;
    else if(a%2 == 0) t++;
    else nn++;
  }
  if(t == 0)
  {
    if(nn <= (f+1))
    {
      puts("Yes");
    }
    else
    {
      puts("No");
    }
  }
  else
  {
    if(nn <= f)
    {
      puts("Yes");
    }
    else puts("No");
  }
  return 0;
}


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

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

    // dp[i][j]：品物i番目まで, 重量制限jのときの価値の最大値
    ll dp[101][100000] = {};

    for(int i=1;i<=N;i++){   // N個の品物(N:1~100)
        for(int j=0;j<=W;j++){  // 容量W(W:1~100000)
            if(w[i] > j){   // wi > jのとき(wiを入れることができない場合)
                dp[i][j] = dp[i-1][j];  // i-1番目まで
            }else{          // wi <= jのとき
                ll a, b;
                a = v[i] + dp[i-1][j-w[i]]; // wiを入れる場合
                b = dp[i-1][j];             // wiを入れない場合
                dp[i][j] = max(a, b);       // a, bのうち大きいほうを採用
            }
        }
    }

    cout << dp[N][W] << endl;

}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int x;cin >> x;
    int ans = 1;
    inc(i, 2, 1001){
        int y = i;
        inc(j, 2, 11){
            y *= i;
            if(y <= x) ans = max(ans, y);
            else break;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using ll = long long;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll n, a[201][201], ans = 0;
	cin >> n;
	for (int i=1; i<=n; i++) {
		for (int j=1; j<=n; j++) {
			a[i][j] = __gcd(i, j);
		}
	}
	for (int i=1; i<=n; i++) {
		for (int j=1; j<=n; j++) {
			for (int k=1; k<=n; k++) {
				ans += a[a[i][j]][k];
			}
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3928
n = int(input())
x = [0]
y = [0]
t = [0]
fl = True
def judge(a,b,c,d,e,f):
    if abs(b-a)+abs(d-c) <= f-e and abs(b+d-a-c)%2 == abs(f-e)%2:
        return False
    return True
for i in range(n):
    tt,xx,yy = map(int,input().split())
    x.append(xx)
    y.append(yy)
    t.append(tt)
    if judge(x[i],x[i+1],y[i],y[i+1],t[i],t[i+1]):
        fl = False
if(fl):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 11816
a = input()
ans = []

for i in list(a):
    tmp = ord(i)
    if tmp==65: ans.append(chr(88))
    elif tmp==66: ans.append(chr(89))
    elif tmp==67: ans.append(chr(90))
    else: ans.append(chr(tmp-3))
    
print(*ans,sep="")
    



Measured memory_bytes: 5716
#include <iostream>
#include <vector>
#include <valarray>
#include <algorithm>
#include <utility>
using namespace std;

int main() {
	int n;
	double ans = 0;
	cin >> n;
	vector<int>u(n);
	for (auto& i : u)
	{
		cin >> i;
	}
	sort(u.begin(), u.end());
	ans = u[0];
	for (int i = 1; i < n; i++)
	{
		ans += u[i];
		ans /= 2;
	}
	cout << ans << endl;
}

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

signed main() {
  string S; cin >> S;
  vector<int> ans(S.size(), 0);
  S += 'R';
  
  char now = 'R';
  int n = 0;
  int k = 0;
  rep(i, S.size()) {
    if(S[i] == now) {
        n++;
    } else {
      if(now == 'R') {
        now = 'L';
        k = i;
        ans[k-1] += (n+1)/2;
        ans[k] += n/2;
        n = 1;
      } else {
        now = 'R';
        ans[k-1] += n/2;
        ans[k] += (n+1)/2;
        n = 1;
      }
    }
  }
  
  
  rep(i, S.size()-1) cout << ans[i] << " ";
  cout << endl;

}

Measured memory_bytes: 1408
function count(i,A)
	ret=0
	for a=A
		ret+=(a>>i)%2
	end
	ret
end
function main()
	N=parse(Int,readline())
	A=map(x->parse(Int,x),split(readline()))
	ans=0
	mod=10^9+7
	for i=59:-1:0
		c=count(i,A)
		ans=(ans*2+c*(N-c))%mod
	end
	println(ans)
end
main()


Measured memory_bytes: 170656
macro_rules! scan_sub {
    ( $itr:ident, $t:ty ) => {
        let mut buf = String::new();
        let $itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
    };
}

macro_rules! scan {
    ( $x:ident; Vec<$t:ty> ) => {
        scan_sub!(itr, $t);
        let $x = itr.collect::<Vec<_>>();
    };
    ( $( $x:ident ),*; $t:ty ) => {
        scan_sub!(itr, $t);
        let mut itr = itr;
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

fn main() {
    scan!(n; usize);

    let mut res = 0;
    for x in 1..=n {
        let y = n / x;
        res += y * (y + 1) / 2 * x;
    }

    println!("{}", res);
}


Measured memory_bytes: 2108
n = int(input())
s = input()
all = s.count("R")*s.count("G")*s.count("B")
for x in range(n-1):
    for y in range(1,(n-1-x)//2+1):
        if s[x] != s[x+y] and s[x]!= s[x+2*y]\
        and s[x+y]!=s[x+2*y]:
            all -=1
print(all)

Measured memory_bytes: 68040
#include <string>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <math.h>
 
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
 
	int x,y;
	cin >> x >> y;
      cout << x*y << "\n";
   
  
}

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

int main() {
  
  int N;
  string A, R = "Three";
  cin >> N;

  for (int i = 0; i < N; i++) {
    cin >> A;
    if (A == "Y") {
      R = "Four";
      break;
      }
   }
  
   cout << R << endl;
}



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

int main() {
  int m, n;
  int num;

  while(1) {
    cin >> m >> n;
    if(m == 0)
      break;

    int count = 0;
    for(int i = m; i <= n; i++) {
      num = i;
      while(1) {
        if(num == 1) {
          count++;
          break;
        }
        if(num % 2 == 0)
          num =	num / 2;
        else if(num % 3 == 0)
          num =	num / 3;
        else if(num % 5 == 0)
          num = num / 5;
	else
          break;
      }
    }
    cout << count << endl;
  }
  return 0;
}




Measured memory_bytes: 2976
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int loc_x = 0;
		int loc_y = 0;
		int loc_t = 0;
		for(int i = 0; i < n; i++) {
			int t = sc.nextInt();
			int x = sc.nextInt();
			int y = sc.nextInt();
			
			int dis = Math.abs(loc_x-x) + Math.abs(loc_y-y);
			
			if(dis - (t - loc_t) > 0 || ((t - loc_t) - dis) % 2 != 0) {
				System.out.println("No");
				return;
			}
			loc_x = x;
			loc_y = y;
			loc_t = t;
		}
		System.out.println("Yes");
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 85044
import java.util.*;
import java.io.*;
import java.lang.*;
public class Main{
public static void main(String[] args) throws FileNotFoundException, IOException{
        Scanner s = new Scanner(System.in);
        StringBuilder sb=new StringBuilder();
       int n=s.nextInt();
       double[] arr=new double[n+1];
       for(int i=1;i<=n;i++){arr[i]=s.nextDouble();}
        double[][] dp=new double[n+1][n+1];
      dp[0][0]=1;
      for(int i=1;i<=n;i++){
        dp[0][i]=dp[0][i-1]*(1-arr[i]);
      }
      for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
          if(i<=j){
            dp[i][j]=dp[i][j-1]*(1-arr[j])+dp[i-1][j-1]*arr[j];
          }
        }
      }
       double res=0;
       for(int i=n/2 +1;i<=n;i++){
        res+=dp[i][n];
       }
       System.out.println(res);
        }
    }


Measured memory_bytes: 124620
#include <iostream>

int main(void)
{
  unsigned short int L, R, d, count = 0;
  std::cin >> L >> R >> d;
  for (unsigned int i = L; i <= R; ++i)
  {
    if(i % d == 0)
    {
      ++count;
    }
  }
  std::cout << count << std::endl;
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
 
using namespace std;
 
#define ss second
#define ff first
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define all(a) (a).begin(),(a).end()
#define rep(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define debug(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<ll>;
using vii = vector<pair<int,int>>;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3fLL;
const int maxn = 1e2+10;

int main(int argc,const char** argv){

	fastio;

	int n,k;

	cin >> n >> k;

	vi v(n),dp(n,INF);

	dp[0] = 0;

	for(int &x:v) cin >> x;

	rep(i,0,n){
		for(int j=i+1;j <= i+k && j < n ;j++){
			if(j < n) dp[j] = min(dp[j],dp[i] + abs(v[i]-v[j]));
		}
	}

	cout << dp[n-1] << '\n';

	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>

using namespace std;

int main() {
  int N;
  string s;

  cin >> N >> s;

  int b, r;
  b = r = 0;
  for (auto c : s) {
    if (c == 'R') r++;
    if (c == 'B') b++;
  }

  if (r > b) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
from operator import itemgetter
 
N, M = map(int,input().split())
data = [[int(i) for i in input().split()] for j in range(M)]
 
# 市iの(i-1)を先頭に追加
for i in range(M):
    data[i].insert(0,i)
 
# 県でソートしてから誕生年でソート
data.sort(key=itemgetter(1,2))
 
# answer[0]: 市iの(i-1)
# answer[1]: 認識番号
answer = [[0,0] for i in range(M)]
x = 1
# 認識番号を割り当てる
for i in range(M):
    answer[i][0] = data[i][0]
    if data[i][1] != data[i-1][1]:
        x = 1
    answer[i][1] = data[i][1]*1000000 + x
    x += 1
 
# 入力順に出力する
answer.sort(key=itemgetter(0))
for _,i in answer:
    print(str(i).rjust(12,"0"))

Measured memory_bytes: 40564
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int M = sc.nextInt();
            int Q = sc.nextInt();
            int[] a = new int[Q];
            int[] b = new int[Q];
            int[] c = new int[Q];
            int[] d = new int[Q];
            for (int i = 0; i < Q; i++) {
                a[i] = sc.nextInt();
                b[i] = sc.nextInt();
                c[i] = sc.nextInt();
                d[i] = sc.nextInt();
            }
            int[] A = new int[N + 1];
            A[0] = 1;

            int max = dfs(1, N + 1, M, Q, a, b, c, d, A);

            System.out.println(max);
        }
    }

    private static int dfs(int index, int N, int M, int Q, int[] a, int[] b, int[] c, int[] d, int[] A) {
        if (index >= N) {
            return calculateScore(Q, a, b, c, d, A);
        }

        int max = 0;
        for (int j = A[index - 1]; j <= M; j++) {
            A[index] = j;
            max = Math.max(max, dfs(index + 1, N, M, Q, a, b, c, d, A));
        }
        return max;
    }

    private static int calculateScore(int Q, int[] a, int[] b, int[] c, int[] d, int[] A) {
        int sum = 0;
        for (int i = 0; i < Q; i++) {
            if (A[b[i]] - A[a[i]] == c[i]) {
                sum += d[i];
            }
        }
        return sum;
    }
}


Measured memory_bytes: 28064
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int X, A, B;
    io.read(X, A, B);
    string ans = "dangerous";
    if(B <= A){
        ans = "delicious";
    }
    else if(B <= A + X){
        ans = "safe";
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int n;
int main(){
    scanf("%d",&n);
    if(n==1<<(31-__builtin_clz(n)))return puts("No"),0;
    puts("Yes");
    printf("%d %d\n%d 3\n3 1\n1 2\n2 %d\n",1+n,2+n,2+n,3+n);
    for(int i=4;i+1<=n;i+=2)
    printf("%d %d\n%d 1\n1 %d\n%d %d\n",i+n,i+1,i+1,i,i,i+1+n);
    if(n%2==0){
        int x=__builtin_ctz(n);
        printf("%d %d\n%d %d\n",n,1<<x,n^1^(1<<x),2*n);
    }
    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i)
#define REP(i,k,n) for (int i = k; i <= n; ++i)
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define I insert
#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define debug1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define debug2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define debug3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define debug4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"
#define INF (int)10000000000000000
#define PI (double)3.14159265358979
// #define M 421412341324321
#define MOD 1000000007

const int p = 1e5+5;
int fact[p];

int modpower(int n, int k)
{
	int res=1;
	while (k>0)
	{
	if (k&1)
	res=(res*n)%MOD;
	k>>=1;
	n=(n*n)%MOD;
    }
    return res;
}
void pre()
{
	fact[0] = 1;
	for (int i=1;i<p;++i)
	{
		fact[i] = (fact[i-1]*i)%MOD;
	}
}
int comb(int n, int r)
{
    int a=fact[n];
    int b=(fact[n-r]*fact[r])%MOD;
    int x= (a*(modpower(b, MOD-2)))%MOD;
    return x;
}

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

	pre();
	int n, k;
	cin>>n>>k;
	int a[n];
	for (int i=0;i<n;++i)
	{
		cin>>a[i];
	}
	sort(a, a+n);
	int ans = 0;
	for (int i=n-1;i>=1;--i)
	{
		if (i>=k-1)
			ans+= (comb(i, k-1)*a[i])%MOD;
		ans%=MOD;
	}

	for (int i=0;i<n-1;++i)
	{
		if (n-1-i>=k-1)
			ans =  (ans + MOD - (comb(n-1-i, k-1)*a[i])%MOD)%MOD;
	}
	cout<<ans<<"\n";
	return 0;
}

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

ll ab(int x){
	if(x<0)x *= -1;
	return x;
}
int main(){
	ll n,x,y; cin >> n >> x >> y;
	x--; y--;
	vl ans(n-1,0);
	rep(i,n){
		for(int j = i+1;j<n;j++){
			ll r = min(j-i-1,ab(x-i)+ab(y-j));
			ans[r]++;
		}
	}
	rep(i,n-1)cout << ans[i] << endl;
}

Measured memory_bytes: 256
def findlcs(x, y):
    dp = [0]*(len(y)+1)
 
    for c in x:
        tmp = dp[:]
        for j in range(len(y)):
            if c == y[j]:
                dp[j+1] = tmp[j] + 1
            elif dp[j+1] < dp[j]:
                dp[j+1] = dp[j]
 
    return dp[-1]
 
 
q = int(input())
for k in range(q):
    X = input()
    Y = input()
    print(findlcs(X, Y))

Measured memory_bytes: 7724
#include <iostream>
#include <string>
#include <vector>

int main()
{
	std::vector<std::vector<int>> c(3, std::vector<int>(3));
	std::vector<int> x(3, 0);
	std::vector<int> y(3, 0);

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			std::cin >> c[i][j];
		}
	}

	x[0] = 0;

	for (int i = 0; i < 3; i++) {
		y[i] = c[0][i] - x[0];
	}

	for (int i = 1; i < 3; i++) {
		x[i] = c[i][0] - y[0];
	}

	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			if (x[i] + y[j] != c[i][j]) {
				std::cout << "No" << std::endl;
				return 0;
			}
		}
	}

	std::cout << "Yes" << std::endl;
	return 0;
}



Measured memory_bytes: 256
#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;

  vector<int> dic[mx];

int main(){
  ll n,k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> jmp(n,-1);
  rep(i,n){
    cin >> a[i];
    dic[a[i]].emplace_back(i);
  }
  vector<int> ch(n,0);
  rep(i,n){
    if(jmp[i]!=-1) continue;
    int m = dic[a[i]].size();
    rep(j,m){
      jmp[dic[a[i]][j]] = (dic[a[i]][(j+1)%m]+1)%n;
      if(j==m-1){
        ch[dic[a[i]][j]]++;
      }
      if(jmp[dic[a[i]][j]]==0){
        ch[dic[a[i]][j]]+=2;
      }
    }
  }

  int idx = 0;
  int lp = 0;
  while(1){
    int nxt = jmp[idx];
    while(!ch[idx]){
      idx = nxt;
      nxt = jmp[idx];
    }
    lp+=ch[idx];
    if(ch[idx]>=2) lp--;
    nxt = jmp[idx];
    idx = nxt;
    if(idx==0) break;
  }
  k %= lp;
  if(k==0) return 0;
  k -= 1;

  vector<int> b;
  while(k){
    int nxt = jmp[idx];
    while(!ch[idx]){
      idx = nxt;
      nxt = jmp[idx];
    }
    idx = nxt;
    k--;
  }
  REP(i,idx,n){
    int nxt = jmp[i];
    if(ch[i]%2==1){
      b.emplace_back(a[i]);
    } else {
      i = nxt-1;
      if(nxt==0) i = n-1;
    }
  }

  for(auto ans:b){
    cout << ans << " ";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 15736
#include<cstdio>
using namespace std;
#define MAX_N 999999+10
int prime[MAX_N];
bool is_prime[MAX_N+1];

int sieve(int n){
    int p=0;
    for(int i=0;i<=n;i++)is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    for(int i=2;i<=n;i++){
        if(is_prime[i]){
            prime[p++]=i;
            for(int j=2*i;j<=n;j+=i)is_prime[j]=false;
        }
    }
    return p;
}

int main(){
    int n;
    while(~scanf("%d",&n)){
        printf("%d\n",sieve(n));
    }
}

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

int main() {
  string s;
  cin >> s;
  
  vector<int> a(s.size()+1,0);
  int x=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='<'){
      x++;
      a.at(i+1)=x;
    }else{
      x=0;
      a.at(i+1)=x;
    }
  }
  for(int i=s.size()-1;i>=0;i--){
    if(s.at(i)=='>'){
      x++;
      a.at(i)=max(a.at(i),x);
    }else{
      x=0;
      a.at(i)=max(x,a.at(i));
    }
  }
  
  long long int ans=0;
  for(int i=0;i<s.size()+1;i++){
    ans+=a.at(i);
  }
  cout << ans << endl;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換

int main() {
 int n,k;
 cin>>n>>k;
 ll a[n];
 rep(i,n){
     cin>>a[i];
 }

for(int i = k ;i < n ; i++){
    if(a[i - k] < a[i]) cout<<"Yes"<<endl;
    else
    {
        cout<<"No"<<endl;
    }
    

}

 
 
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  set<int> s;
  set<int> db;
  set<int>::iterator ite;
  rep(i, n) {
    cin >> a[i];

    ite = s.find(a[i]);
    if (ite != s.end()) db.insert(a[i]);
    else s.insert(a[i]);
  }

  int ans = 0;
  rep(i, n) {
    bool flug = true;
    ite = db.find(a[i]);
    if (ite != db.end()) continue;
    ite = s.find(1);
    if (a[i] != 1 && ite != s.end()) continue;
    for (int j=2; j*j<=a[i]; j++) {
      if (a[i] % j == 0) {
        ite = s.find(j);
        if (ite != s.end()) {flug = false; break;}
        ite = s.find(a[i] / j);
        if (ite != s.end()) {flug = false; break;}
      }
    }
    if (flug) ans++;
  }

  cout << ans << endl;

  return 0;
}

/*
*/


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

int main()
{
    int A, B, C;
    scanf("%d %d %d", &A, &B, &C);
    if(A+B>=C)
    {
        printf("Yes");
    }
    else 
    {
        printf("No");
    }
    return 0;
}


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

int main() {
  int k, s, ans = 0;
  cin >> k >> s;
  for (int x=0; x<=k; x++) {
    for (int y=0; y<=k; y++) {
      if (0 <= s-x-y && s-x-y <=k) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
    int n;
    string s;
    cin >> n >> s;
    char x;
    bool m;
    bool nn;
    int count;
    int ans = 0;
    for (int i = 1; i < n; i++)
    {
        x = 'a';
        count = 0;
        for (int j = 0; j < 26; j++)
        {
            m = false;
            nn = false;
            for (int k = 0; k < i; k++)
            {
                if (s[k] == x)
                {
                    m = true;
                }
            }
            for (int k = i; k < n; k++)
            {
                if (s[k] == x)
                {
                    nn = true;
                }
            }
            if (m == true && nn == true)
            {
                count++;
            }
            x++;
        }
        ans = max(ans, count);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>

#define ll long long

using namespace std;

const ll MOD = 1e9 + 7;
int N, K;

ll factorial[100005] = { 1, };
ll inv_factorial[100005];
int input[100005];

ll get_mod_inv(ll num)
{
	ll ret = 1;
	ll mul = MOD - 2;

	while (mul)
	{
		if (mul & 1) ret = (ret*num) % MOD;
		num = (num*num) % MOD;
		mul >>= 1;
	}

	return ret;
}

inline ll MUL(ll A, ll B)
{
	return (A*B) % MOD;
}

inline ll ADD(ll A, ll B)
{
	return (A + B) % MOD;
}

int main()
{
	scanf("%d %d", &N, &K);
	
	for (int i = 0; i < N; ++i) scanf("%d", &input[i]);
	sort(input, input + N);

	for (int i = 1; i <= N; ++i) factorial[i] = MUL(factorial[i - 1], i);
	inv_factorial[N] = get_mod_inv(factorial[N]);
	for (int i = N - 1; i >= 0; --i) inv_factorial[i] = MUL(inv_factorial[i + 1], i + 1);
	ll ans = 0;

	for (int i = 0; i < N; ++i)
	{
		if (input[i] < 0) input[i] += MOD;
		if (i >= K - 1) ans = ADD(MUL(MUL(MUL(factorial[i], inv_factorial[K - 1]), inv_factorial[i - K + 1]), input[i]), ans);
		if (N - i >= K) ans = ADD(ans, (MOD - MUL(MUL(MUL(factorial[N - i - 1], inv_factorial[K - 1]), inv_factorial[N - i - K]), input[i]) % MOD));
	}

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

	return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <cmath>
#include <stdio.h>

using namespace std;

int main(){
	int n,m;
	int a[1000];
	int sum;
	double large_sum ;
	double stdev[1000];
	
	for (int j = 0; j < 1000; j++){
		sum = 0;
		large_sum = 0;
		cin >> n;
		if (!n) { m = j; break; }
		for (int i=0; i<n; i++){
			cin >> a[i];
			sum += a[i];
		}
		double avg = (double)sum / n;
		
		for (int i=0; i<n; i++){
			large_sum += (a[i] - avg) *  (a[i] - avg);	
		}
		
		stdev[j] = sqrt(large_sum / n);
	}
	for (int i=0; i<m; i++){	
		printf("%.8lf\n", stdev[i]);
	}
	return 0;
}

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

N, M = list(map(int, input().split()))
sc_list = []
for _ in range(M):
    s, c = list(map(int, input().split()))
    sc_list.append((s, c))

sc_set = set(sc_list)
start = 10 ** (N - 1)
end = 10 ** N
start = 0 if N == 1 else start

is_ok = True

if len(sc_set) > N:
    is_ok = False

answer = -1
if is_ok:
    if M == 0:
        answer = start
    else:
        for i in range(start, end):
            is_sub_ok = True
            str_number = str(i)
            for sc in sc_set:
                s, c = sc
                if str_number[s - 1] != str(c):
                    is_sub_ok = False
                    continue
            if is_sub_ok:
                answer = i
                break
ans = answer
print(ans)


Measured memory_bytes: 9228
import sys

input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def main():
    P = []
    B = [True] * 56000
    for i in range(2, 55555):
        if B[i]:
            if i % 5 == 1:
                P.append(str(i))
            for j in range(56000 // i):
                B[i * j] = False
    print(" ".join(P[: int(input())]))


if __name__ == "__main__":
    main()


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

long long int MOD = static_cast<long long int>(1e9) + 7LL;

long long int my_pow(long long int x,long long int multiplier){

    if(multiplier==1){
        return x%MOD;
    }

    if(multiplier%2 == 1){
        return (my_pow(x,multiplier-1)*x)%MOD;
    }

    return (my_pow(x*x,multiplier/2))%MOD;

}

int a[100000];

int comp_array[100000];

int main(){

    int n;

    cin >> n;

    for(int i=0; i<n; i++){
        cin >> a[i];
        comp_array[i] = abs(n-1-2*i);
    }

    sort(a,a+n);
    sort(comp_array,comp_array+n);

    for(int i=0; i<n; i++){
        if(a[i] != comp_array[i]){
            cout << 0 << endl;
            return 0;
        }
    }

    //cout << my_pow(2,n/2) << endl;

    long long int ans = 1;

    for(int i=0; i<n/2; i++){
        ans *= 2;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h> 
#define N 36
 
typedef struct{
  char suit;
  int value;
}Card;
 
int main(){
  int i, j, n, min, flag=0;
  Card a[N], b[N], a1, a2;
   
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf(" %c%d", &a[i].suit, &a[i].value);
    b[i].suit = a[i].suit;
    b[i].value = a[i].value;
  }
 
  for(i = 0; i < n-1; i++){
    for(j = n-1; j > i; j--){
      if(a[j].value < a[j-1].value){
	a1 = a[j];
	a2 = a[j-1];
	a[j] = a2;
	a[j-1] = a1;
      }
    }
  }

  for(i = 0; i < n; i++){
    min = i;
    for(j = i; j < n; j++){
      if(b[j].value < b[min].value){
	min = j;
      }
    }
    a1 = b[i];
    a2 = b[min];
    b[i] = a2;
    b[min] = a1;
  }

  for(i = 0; i < n-1; i++){
    printf("%c%d ", a[i].suit, a[i].value);
  }
  printf("%c%d\n", a[n-1].suit, a[n-1].value);
  printf("Stable\n");
  
  for(i = 0; i < n-1; i++){
    printf("%c%d ", b[i].suit, b[i].value);
  }
  printf("%c%d\n", b[n-1].suit, b[n-1].value);
    
  for(i = 0; i <= n-1; i++){
    if(a[i].suit != b[i].suit){
      flag = 1;
    }
  }
  
  if(flag == 1) 
    printf("Not stable\n");
  else
    printf("Stable\n");
   
  return 0;
}

Measured memory_bytes: 608
import java.util.Scanner;

public class Main {

	static Scanner scanner;
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);

	    int N=gi();
	    long[] A=new long[N];

	    long sum=0;
	    for(int i=0; i<N; i++) {
	        A[i]=gl();
	        sum+=A[i];
	    }

	    long x=0;
	    long y=sum;
	    long min=Long.MAX_VALUE;
	    for(int i=0; i<N-1; i++) {
	    	long a=A[i];
	    	x+=a;
	    	y-=a;
	    	long v=Math.abs(y-x);
	    	if(min>v)min=v;
	    }

		System.out.println(min);
	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}

	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 61436
import math

n, m = map(int, input().split())
ans = None
if abs(n - m) >= 2:
    ans = 0
elif abs(n-m) == 1:
    ans = math.factorial(m) * math.factorial(n)
else:
    ans = math.factorial(m) * math.factorial(n) * 2
print(ans % (10 ** 9 + 7))


Measured memory_bytes: 11056