akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>              
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-------------------------------------------------

int n;
ll a;
int cnt;

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

	cin >> n;
	REP(i, n) {
		cin >> a;
		while(a % 2 == 0) a/=2, cnt++;
	}
	cout << cnt << endl;

	return 0;
}



Measured memory_bytes: 256
h,w = map(int,input().split())
if h%3==0 or w%3==0:
  print(0)
  exit()
ans = min(h,w)
for i in range(1,h):
  yoko = w*i
  x0 = 1
  x3 = w-1
  while x3 - x0 >2:
    x1 = (x0*2+x3)//3
    x2 =  (x0+x3*2)//3
    y1 = max(yoko,(h-i)*x1,(h-i)*(w-x1)) -min(yoko,(h-i)*x1,(h-i)*(w-x1))
    y2 = max(yoko,(h-i)*x2,(h-i)*(w-x2)) -min(yoko,(h-i)*x2,(h-i)*(w-x2))
    if y1 > y2:
      x0 = x1
    else:
      x3 = x2
  ans = min(ans,max(yoko,(h-i)*x0,(h-i)*(w-x0)) -min(yoko,(h-i)*x0,(h-i)*(w-x0)))
  x0 += 1
  if w > x0:
    ans = min(ans,max(yoko,(h-i)*x0,(h-i)*(w-x0)) -min(yoko,(h-i)*x0,(h-i)*(w-x0)))
  x0 += 1
  if w > x0:
    ans = min(ans,max(yoko,(h-i)*x0,(h-i)*(w-x0)) -min(yoko,(h-i)*x0,(h-i)*(w-x0)))

for i in range(1,w):
  yoko = h*i
  x0 = 1
  x3 = h-1
  while x3 - x0 >2:
    x1 = (x0*2+x3)//3
    x2 =  (x0+x3*2)//3
    y1 = max(yoko,(w-i)*x1,(w-i)*(h-x1)) -min(yoko,(w-i)*x1,(w-i)*(h-x1))
    y2 = max(yoko,(w-i)*x2,(w-i)*(h-x2)) -min(yoko,(w-i)*x2,(w-i)*(h-x2))
    if y1 > y2:
      x0 = x1
    else:
      x3 = x2
  ans = min(ans,max(yoko,(w-i)*x0,(w-i)*(h-x0)) -min(yoko,(w-i)*x0,(w-i)*(h-x0)))
  x0 += 1
  if w > x0:
    ans = min(ans,max(yoko,(w-i)*x0,(w-i)*(h-x0)) -min(yoko,(w-i)*x0,(w-i)*(h-x0)))
  x0 += 1
  if w > x0:
    ans = min(ans,max(yoko,(w-i)*x0,(w-i)*(h-x0)) -min(yoko,(w-i)*x0,(w-i)*(h-x0)))
print(ans)



Measured memory_bytes: 63964
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 100
int d[MAX_V][MAX_V];
int V, M;
void warshall_floyd() {
	rep(k, 0, V) rep(i, 0, V) rep(j, 0, V) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    cin >> V >> M;
    rep(i, 0, V) rep(j, 0, V) {
        if(i == j) d[i][j] = 0;
        else d[i][j] = 1e9;
    }

    vector<pair<pair<int, int>, int>  > vp;
    rep(i, 0, M) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        vp.push_back(make_pair(make_pair(a, b), c));
        d[a][b] = c;
        d[b][a] = c;
    }

    warshall_floyd();

    int ans = 0;
    for(auto it = vp.begin(); it != vp.end(); it++) {
        bool flag = false;
        rep(i, 0, V) rep(j, 0, V) {
            if(d[i][j] == d[i][it->first.first] + it->second + d[it->first.second][j]) flag = true;
        }

        if(!flag) {
            ans++;
        }
    }

    cout << ans << endl;
}


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

static const int N = 100;

int main() {

  int i,j;
  int M[N][N];
  int n,u,k,v;

  scanf("%d", &n);

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

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

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

  return 0;
}



Measured memory_bytes: 2056
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>

int main(){
	int n;
	int *a;
	int i;
	bool f = true;
	
	scanf("%d", &n);
	
	a=(int *)malloc(sizeof(int)*n);
	
	for(i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
	
	for(i =0; i<n; i++){
		if(a[i]%2==0){
			if(a[i]%3!=0 && a[i]%5!=0){
				f = false;
			}
		}
	}
	
	if(f){
		printf("APPROVED");
	}else{
		printf("DENIED");
	}
	
	free(a);
	
	return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    private static int MOD = 1000000007;
    public static void main(String[] args) throws Exception {
        Main main = new Main();
        main.solve();
    }
    public void solve() throws Exception {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        List<Integer> C = new ArrayList<>();
        int prev = -1;
        for (int i = 1; i <= N; i++) {
            int color = scan.nextInt();
            if (prev == color) {
                continue;
            }
            C.add(color);
            prev = color;
        }
        int len = C.size();
        long[] dp = new long[len+1];
        long[] sum_color = new long[200001];
        dp[0] = 1;
        for (int i = 1; i <= len; i++) {
            int color = C.get(i-1);
            sum_color[color] += dp[i-1];
            sum_color[color] %= MOD;
            dp[i] = sum_color[color];
            dp[i] %= MOD;
        }
        System.out.println(dp[len]);
    }
}


Measured memory_bytes: 92244
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

vector<double> intersect(double x, double y, double r1, double r2){
	vector<double> res(4,inf);
	double a = x*x + y*y;
	double b = (a + r1*r1 - r2*r2) / 2.0;
	double c = a * r1*r1 - b*b;
	if(c < 0) return res;
	res[0] = (b*x + y*sqrt(c)) / a;
	res[1] = (b*y - x*sqrt(c)) / a;
	res[2] = (b*x - y*sqrt(c)) / a;
	res[3] = (b*y + x*sqrt(c)) / a;
	return res;
}

double dist(double x, double y){
	return sqrt(x*x + y*y);
}

int main(){
	int n; cin >> n;
	vd x(n), y(n);
	rep(i,n) cin >> x[i] >> y[i];
	double ok = 1e6, ng = 0.0;
	rep(t,100){
		double mid = (ok+ng) / 2.0;
		vd r(n);
		rep(i,n) r[i] = mid;
		vector<pair<double,double>> p;
		rep(i,n){
			REP(j,i+1,n){
				vd ret = intersect(x[j]-x[i],y[j]-y[i],r[i],r[j]);
				if(ret[0] >= 1e9) continue;
				p.emplace_back(ret[0] + x[i], ret[1] + y[i]);
				p.emplace_back(ret[2] + x[i], ret[3] + y[i]);
			}
			p.emplace_back(x[i],y[i]);
		}
		bool f = false;
		for(auto v : p){
			int cnt = 0;
			rep(i,n){
				if(dist(x[i]-v.first, y[i]-v.second) <= r[i] + eps) cnt++;
			}
			if(cnt == n) f = true;
		}
		if(f) ok = mid;
		else ng = mid;
	}
	printf("%.10f\n",ok);
}

Measured memory_bytes: 3956
n, m = (int(x) for x in input().split())
s = sorted(([int(x) for x in input().split()] for _ in range(n)), key=lambda x: x[0])
ans = 0
for a,b in s:
    if m <= b:
        ans += a*m
        break
    else:
        m -= b
        ans += a*b
print(ans)

Measured memory_bytes: 22756
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    static class APoor
    {
        static void Main(string[] args)
        {
            var abc = Console.ReadLine().Split(' ').ToList();
            Console.WriteLine(abc.Distinct().Count() == 2 ? "Yes" : "No");
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 11348
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-5;
const int inf=1e8;
int main(){
	string s;
	cin>>s;
	reverse(all(s));
	string q[4]={"maerd","remaerd","esare","resare"};
	int t=0;
	while(1){
		rep(i,5){
			if(i==4)goto end;
			bool h=true;
			loop(j,t,t+q[i].size())if(j>=s.size()||q[i][j-t]!=s[j])h=false;
			if(h){
				t+=q[i].size();
				break;
			}
		}
	}
	end:;
	if(t!=s.size())cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
}













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



int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	if (a >= 1 && b >=1 && a<=9 && b<= 9)
	{
		printf("%d\n", a * b);
	}
	else
	{
		printf("-1\n");
	}
	return 0;
}

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

using namespace std;

void DEBUGPrint(unsigned long ary[][100], int row, int col)
{
	printf("*DEBUG:BEGIN*********\n");
	for (int i = 0; i < row; i++)
	{
		for (int j = 0; j < col; j++)
		{
			if (j == col-1)
				printf("%d\n", ary[i][j]);
			else
				printf("%d ", ary[i][j]);
		}
	}
	printf("*DEBUG:END *********\n");
}
void Print(unsigned long ary[][100], int row, int col)
{
	for (int i = 0; i < row; i++)
	{
		for (int j = 0; j < col; j++)
		{
			if (j == col-1)
				printf("%lu\n", ary[i][j]);
			else
				printf("%lu ", ary[i][j]);
		}
	}
}

// ????´???????????????????????????°?????????????????????
int main()
{
	int n,m,l;
	int num;
	
	unsigned long A[100][100] = {0};
	unsigned long B[100][100] = {0};
	unsigned long C[100][100] = {0};
	scanf("%d %d %d", &n, &m, &l);
	
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			int x;
			scanf("%lu", &x);
			A[i][j] = x;
		}
	}
	//DEBUGPrint(A, n, m);
	
	for (int i = 0; i < m; i++)
	{
		for (int k = 0; k < l; k++)
		{
			int x;
			scanf("%lu", &x);
			B[i][k] = x;
		}
	}
	//DEBUGPrint(B, n, m);
	
	//printf("n=%d, l=%d****\n", n, l);
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < l; j++)
		{
			long sum = 0;
			for (int k = 0; k < m; k++)
			{
			//	if (A[i][k] < 0 || A[i][k] > 10000)
			//		goto LABEL;
			//	if (B[i][k] < 0 || B[i][k] > 10000)
			//		goto LABEL;
				
				sum += (A[i][k] * B[k][j]);
			}
			C[i][j] = sum;
			//printf("i,j=%d,%d\n", i,j);
		}
	}
	//DEBUGPrint(C, n, l);
	Print(C, n, l);
	//goto END;
//LABEL:
//	printf("ERROR");
//END:
	
	return 0;
}

Measured memory_bytes: 1440
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n int

	fmt.Scanf("%d", &n)

	var nums = make([]int, n)
	var s = make([]interface{}, n)
	for i := range nums {
		s[i] = &nums[i]
	}
	fmt.Scanln(s...)

	fmt.Println(logic(nums))
}

func logic(nums []int) string {
	result := make([]string, len(nums))

	for i, n := range nums {
		result[n-1] = fmt.Sprintf("%d ", i+1)
	}

	return strings.Join(result, " ")
}

Measured memory_bytes: 7680
from sys import stdin
g1 = [1,3,5,7,8,10,12]
g2 = [4,6,9,11]
a, b = [int(x) for x in stdin.readline().rstrip().split()]
if a == b:
  print('Yes')
elif a in g1 and b in g1:
  print('Yes')
elif a in g2 and b in g2:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const int N = 200005;
int a[N],b[N],n;
priority_queue<pair<int ,int > >q;
int fro(int x){return x==1?n:x-1;}
int bac(int x){return x==n?1:x+1;}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)scanf("%d",&b[i]),q.push(make_pair(b[i],i));
	long long tmp=0;
	while(!q.empty())
	{
		int i=q.top().second;q.pop();if(b[i]==a[i])continue;
		if(b[i]-a[i]<b[fro(i)]+b[bac(i)])return puts("-1"),0;
		int sn = b[fro(i)]+b[bac(i)],lim;
		lim = b[i] - a[i],tmp+=lim/sn,lim%=sn,b[i]=a[i]+lim;
		if(b[i]<a[i])return puts("-1"),0;
		if(b[i]!=a[i])q.push(make_pair(b[i],i));
	}
	printf("%lld\n",tmp);
}


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

int main(){
  char c[3];
  int ans=0;
  rep(i,0,3)cin>>c[i];
  rep(i,0,3){
    if(c[i]=='1'){ans++;}
  }
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 256
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
res = 0
pre = a[0]
for i,x in enumerate(a):
    if i == 0: continue
    if x < pre:
        res += pre-x
    else:
        pre = x
print(res)

Measured memory_bytes: 32908
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	ll ans1 = 0, sum1 = 0;
	rep(i,n){
		sum1 += a[i];
		if(i%2 == 0){
			if(sum1 <= 0){
				ans1 += 1 - sum1;
				sum1 = 1;
			}
		}
		else{
			if(sum1 >= 0){
				ans1 += sum1 + 1;
				sum1 = -1;
			}
		}
	}
	ll ans2 = 0, sum2 = 0;
	rep(i,n){
		sum2 += a[i];
		if(i%2 == 0){
			if(sum2 >= 0){
				ans2 += sum2 + 1;
				sum2 = -1;
			}
		}
		else{
			if(sum2 <= 0){
				ans2 += 1 - sum2;
				sum2 = 1;
			}
		}
	}
	ll ans = min(ans1, ans2);
	cout << ans << endl;
	return 0;
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);  
	
	int n, k;
	cin >> n >> k;
	vector<long long> a(n + 1), b(n + 1);
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		a[i + 1] = a[i] + x;
		b[i + 1] = b[i] + max(0, x);
	}
	long long ans = -1e18;
	for(int i = 0; i < n + 1 - k; i++) {
		long long tmp = b[n] - (b[i + k] - b[i]);
		tmp += max(0LL, a[i + k] - a[i]);
		ans = max(tmp, ans);
	}
	cout << ans << endl;
	return 0;	
}

Measured memory_bytes: 1792
arg = gets
fir = gets.chomp
en = gets.chomp
en.length.times do |i|
  reg = Regexp.new(en[0..(en.length-1-i)] + "$")
  if fir[reg]
    puts fir.length +  i
    break
  end
  if i == (en.length) -1
    puts (fir + en).length
  end
end

Measured memory_bytes: 1916
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include<algorithm> // sort
#include<map> // pair
#include<cmath>
using namespace std;
using ll = long long;
const ll mod = 1e9+7;
int main(){
  int a,b,c;
  scanf("%d/%d/%d",&a,&b,&c);
  if(b <= 4){
    cout << "Heisei";
  }else{
    cout << "TBD";
  }
}


Measured memory_bytes: 256
import functools

import os

INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


def inl():
    return list(map(int, input().split()))


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def debug(fn):
    if not os.getenv('LOCAL'):
        return fn

    @functools.wraps(fn)
    def wrapper(*args, **kwargs):
        print('DEBUG: {}({}) -> '.format(
            fn.__name__,
            ', '.join(
                list(map(str, args)) +
                ['{}={}'.format(k, str(v)) for k, v in kwargs.items()]
            )
        ), end='')
        ret = fn(*args, **kwargs)
        print(ret)
        return ret

    return wrapper


a, b, x = inl()
if a <= x and a + b >= x:
    print("YES")
else:
    print('NO')


Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
    int w, h, n;
    cin >> w >> h >> n;

    int x1 = 0, y1 = 0, x2 = w, y2 = h;
    for (int i = 0; i < n; i++) {
        int x, y, a;
        cin >> x >> y >> a;
        switch(a) {
            case 1: x1 = max(x1, x); break;
            case 2: x2 = min(x2, x); break;
            case 3: y1 = max(y1, y); break;
            case 4: y2 = min(y2, y); break;                    
        }
    }

    cout << (max(0, x2 - x1) * max(0, y2 - y1)) << endl;
}

Measured memory_bytes: 256
//#if 1
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
//#endif
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main() {

	int M;
	cin >> M;
	cout << 48 - M << endl;







	return(0);
}

Measured memory_bytes: 256
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = int(sys.stdin.readline().rstrip())
    S = str(sys.stdin.readline().rstrip())
    K = int(sys.stdin.readline().rstrip())
    target = S[K-1]

    for i in range(N):
        if S[i] != target:
            print("*", end="")
        else:
            print(target, end="")


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
x = int(input())
count = 0

if x <= 6:
    count = 1
else:
    a, b = divmod(x, 11)
    a *= 2
    if b == 0:
        a += 0
    elif b > 6:
        a += 2
    else:
        a += 1
    count = a

print(count)

Measured memory_bytes: 3060
import * as fs from 'fs';
// main
function main(input: string[]) {
    // param
    let a, b, c;
    let ans;
    // init
    [a, b, c] = input.shift().split(" ").map(x => Number(x));
    // solve
    ans = "No";
    if (a == b && b != c) ans = "Yes";
    if (b == c && c != a) ans = "Yes";
    if (c == a && a != b) ans = "Yes";
    // answer
    console.log(ans);
}
// entrypoint
function entrypoint() {
    try {
        // linux
        let input = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");
        console.debug = function () { };
        main(input);
    }
    catch (ex) {
        // windows
        const lines: string[] = [];
        // @ts-ignore
        const reader = require('readline').createInterface({
            // @ts-ignore
            input: process.stdin,
            // @ts-ignore
            output: process.stdout
        });
        reader.on('line', function (line: string) {
            lines.push(line);
        });
        reader.on('close', function () {
            let input = lines;
            main(input);
        });
    }
}
entrypoint();


Measured memory_bytes: 29624
#include<bits/stdc++.h>
#define fastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;   
const int inf = (int) 1e9+7;
int main(){
	fastIO;
	int x,y;
	cin>>x>>y;
	for(int i=y-x+1;i<=y;i++)cout<<i<<" ";
	for(int i=y+1;i<=y+x-1;i++)cout<<i<<" ";
	cout<<'\n';      	
	return 0;
}

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

int main(void) {
	string s, t;
	cin >> s >> t;

	sort(s.begin(), s.end());
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());

	if (s < t)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
using namespace std;
int main(){
    int n;
    cin>>n;
    int ans;
    for(int i=1;i<=n;i*=2){
        ans=i;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
N, M = map(int, input().split())

S = [list(map(int, input().split())) for _ in range(M)]
p = list(map(int, input().split()))

ans = 0
temp = [0]*N
for i in range(2**N):
    for j in range(N):
        if((i >> j) & 1):
            temp[j] = 1

    for k in range(M):
        count = 0
        for l in range(1, len(S[k])):
            if temp[S[k][l] - 1] == 1:
                count += 1
        if count % 2 != p[k]:
            break
    else:
        ans += 1
    temp = [0]*N

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

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

long long helper(long long a, long long b, long long c) {
	long long res = b / c - a / c;
	if (a % c == 0)
		++res;
	
	return res;
}

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	long long a, b, c, d;
	cin >> a >> b >> c >> d;

	long long t = c * d / gcd(c, d);
	long long ans = b-a+1 - helper(a, b, c) - helper(a, b, d) + helper(a, b, t);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <math.h>
#include <cmath>
#include <ctime>
#include <stdlib.h>

using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define m_t make_tuple
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
typedef pair<int, int> P;

const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 1000000021;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];


//x未満の要素数を返す二分探索関数
int b_s(vector<int>& vec, int xx) {
	return lower_bound(all(vec), xx) - vec.begin();
}
template<typename T>void vecout(vector<T>& vec) { for (T t : vec) cout << t << " "; cout << endl; }
template<typename TT>void vecin(vector<TT>& vec) {
	for (int i = 0; i < vec.size(); i++) {
		cin >> vec[i];
	}
}

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
long long modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

bool chmax(int& xx, int yy) {
	if (xx < yy) {
		xx = yy;
		return true;
	}
	return false;
}
bool chmin(int& xx, int yy) {
	if (xx > yy) {
		xx = yy;
		return true;
	}
	return false;
}
double dist(int x, int y) {
	return sqrt(x * x + y * y);
}
double dist(int xx1, int xx2, int yy1, int yy2) {
	return sqrt(abs(xx1 - xx2) * abs(xx1 - xx2) + abs(yy1 - yy2) * abs(yy1 - yy2));
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	if (xx <= 1) {
		return 0;
	}
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int w,h,n,xmax=0, xmin, ymax=0, ymin,x,y,a;
	cin >> w >> h >> n;
	xmin = w;
	ymin = h;
	rep(i, n) {
		cin >> x >> y >> a;
		if (a == 1) {
			chmax(xmax, x);
		}
		if (a == 2) {
			chmin(xmin, x);
		}
		if (a == 3) {
			chmax(ymax, y);
		}
		if (a == 4) {
			chmin(ymin, y);
		}
	}
	cout << max(0ll, xmin - xmax) * max(0ll, ymin - ymax) << endl;
}

Measured memory_bytes: 3500
n = int(input())
c1 = 0
c2 = 0
c3 = 0
c4 = 0
for i in range(n):
    verd = input()
    if verd == "AC":
        c1 += 1
    elif verd == "WA":
        c2 += 1
    elif verd == "TLE":
        c3 += 1
    else:
        c4 += 1
print("AC x " + str(c1))
print("WA x " + str(c2))
print("TLE x " + str(c3))
print("RE x " + str(c4))


Measured memory_bytes: 74064
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}

var mod int

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	h1 := intScanner()
	m1 := intScanner()
	h2 := intScanner()
	m2 := intScanner()
	k := intScanner()
	dh := h2 - h1
	dm := m2 - m1
	if dm < 0 {
		dh -= 1
		dm += 60
	}
	fmt.Println(dh*60 + dm - k)
}


Measured memory_bytes: 1760
#include<stdio.h>
int main()
{
	int a,b,c,d=0,i=0;
	scanf("%d %d %d",&a,&b,&c);
	while(1){
		i++;
		d=d+a;
		if(i%7==0){
			d=d+b;
		}
		if(c<=d){
			printf("%d\n",i);
			break;
		}
	}
		return 0;
}
	
	


Measured memory_bytes: 2052
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <cmath>
using namespace std;

string S;
bool tappable;

int main() {
  	cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> S;
    for (int i = 0; i < S.length(); ++i) {
        if (i % 2 == 0) { 
            if (S[i] == 'R' || S[i] == 'U' || S[i] == 'D') {
                tappable = true;
            } else {
                tappable = false;
                break;
            }
        }
        else { 
            if (S[i] == 'L' || S[i] == 'U' || S[i] == 'D') {
                tappable = true;
            } else {
                tappable = false;
                break;
            }
        }
    }
    if (tappable == true) {
      cout << "Yes";
    } else {
      cout << "No";
    }
}

Measured memory_bytes: 256
object Main extends App {
  val Array(n, y) = readLine.split(" ").map(_.toInt)
  
  val patterns = for {
    a <- (0 to n).toSeq
    b <- (0 to n).toSeq
    c = n - a - b
    if c >= 0
    if 10000 * a + 5000 * b + 1000 * c == y
  } yield Seq(a, b, c)
  
  val pattern = patterns.headOption.getOrElse(Seq(-1, -1, -1))
  
  println(pattern.mkString(" "))
}

Measured memory_bytes: 100440
K, N = map(int, input().split())
A = list(map(int, input().split()))

l = []
# [0, 1] -> [0]
for i in range(N - 1):
    x = A[i + 1] - A[i]
    l.append(x)

x_last = (K - A[-1]) + A[0]
l.append(x_last)
#print(x_last)

max_value = max(l)
#max_index = l.index(max_value)

ans = K - max_value

print(ans)

Measured memory_bytes: 87244
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int X, Y; cin >> X >> Y;
	if (Y % 2 != 0) {
		cout << "No" << endl;
		return;
	}
	int b = Y / 2 - X;
	int a = X - b;
	if (a >= 0 && b >= 0) {
		cout << "Yes" << endl;
		return;
	}
	cout << "No" << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string w; cin >> w;
    rep(i, 26){
        if(count(all(w), 'a'+i) %2 != 0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes";
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
#include <set> 
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> v(n);
    vector<int> used(n + 1, -1), num(n + 1, -1);
    for(int i = 0; i < n; i++) cin >> v[i];
    ll ans = 0;
    for(int i = 0; i < n; i++)
    {
        int nv = i, cnt = 0;
        while(used[nv] == -1)
        {
            used[nv] = cnt;
            num[nv] = i;
            nv = (nv + v[nv]) % n;
            cnt++;
        }
        if(num[nv] == i) ans += cnt - used[nv];
    }
    cout << ans << endl;
    return 0;
}




Measured memory_bytes: 4128
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
S = input()
T = input()

ls = len(S)
lt = len(T)
ans = []
for i in range(ls -lt, -1, -1):
    ss = list(S)
    ok = True
    for j in range(lt):
        if S[i + j] != '?' and S[i + j] != T[j]:
            ok = False
            break
        if S[i + j] == '?':
            ss[i + j] = T[j]
    if not ok:
        continue

    for j in range(ls):
        if ss[j] == '?':
            ss[j] = 'a'
    print("".join(ss))
    break
else:
    print("UNRESTORABLE")


Measured memory_bytes: 65528
/*input
2
ip cc
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define eb emplace_back
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define EL cout<<'\n'
#define BS(a,x) binary_search(ALL(a),x)
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
template<typename T>
ostream& operator<<(ostream& out,vector<T> V){
	REP(i,SZ(V)) out<<V[i]<<((i!=SZ(V)-1)?" ":"");
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=20;
const ll INF64=1e18;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

int a[maxn];
int main(){
	IOS;
	int n;
	cin>>n;
	REP(i,n) cin>>a[i];
	int ans=0;
	REP(i,n) for(int j=i+1;j<n;j++){
		ans+=a[i]*a[j];
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;

#define ll long long
const long long llINF = 1LL << 60;
const int iINF = 0x20000000;
template<class T> inline bool chmin(T& a, T b) { if (b < a) { 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; }

void execute();
int main() 
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);// cin と scanfの併用禁止
    cout << fixed << setprecision(15);
    execute();
    return 0;
}


void execute()
{
    ll x[5];
    cin >> x[0] >> x[1] >> x[2] >> x[3] >> x[4];

    for(int i = 0; i < 5; i++){
        if(0==x[i]){ cout << i+1 << endl; }
    }
}


Measured memory_bytes: 3648
use std::io::*;
use std::str::FromStr;

fn parse_line<T: FromStr>() -> T {
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn parse_line_vec<T: FromStr>() -> Vec<T> {
    let line = parse_line::<String>();
    line.split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn println<T: ToString>(s: T) {
    println!("{}", s.to_string());
}

// ------------------------------------------------------------------------

fn main() {
    let n = parse_line::<usize>();
    let w = parse_line_vec::<i32>();

    let mut set = std::collections::BTreeSet::new();

    for i in 1..n {
        let former: i32 = w[0..i].into_iter().sum();
        let latter: i32 = w[i..n].into_iter().sum();
        set.insert((former - latter).abs());
    }

    println(set.into_iter().next().unwrap());
}


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


class SegmentTrees:
    def __init__(self, target, no_effect):
        target_size = len(target)
        leaves_size = 1
        while leaves_size < target_size:
            leaves_size *= 2
        self.tree_size = leaves_size * 2 - 1
        self.tree = [no_effect] * self.tree_size
        self.no_effect = no_effect
        self.initialize_tree(target, no_effect)

    @classmethod
    def initialize_func(cls, value):
        return 1 << (ord(value) - ord('a'))

    @classmethod
    def merge_func(cls, a, b):
        return a | b

    def merge_child_data(self, node):
        child1 = node * 2 + 1
        child2 = node * 2 + 2
        merged = self.merge_func(self.tree[child1], self.tree[child2])
        return merged

    def initialize_tree(self, target: list, no_effect=0):
        initial_leaf = self.tree_size // 2
        leaves = range(initial_leaf, initial_leaf+len(target))
        for value, leaf in zip(target, leaves):
            self.tree[leaf] = self.initialize_func(value)

        for parent in range(initial_leaf-1, -1, -1):
            self.tree[parent] = self.merge_child_data(parent)

    def update(self, new_value, index):
        leaf = self.tree_size//2 + index
        new_data = self.initialize_func(new_value)
        if self.tree[leaf] == new_data:
            return
        self.tree[leaf] = new_data

        parent = (leaf-1) // 2
        while parent >= 0:
            new_data = self.merge_child_data(parent)
            if self.tree[parent] == new_data:
                break
            self.tree[parent] = new_data
            parent = (parent-1) // 2

    def resolve_query(self, _from, to):
        def is_in_query(left, right):
            if _from <= left and right <= to:
                return 1
            elif to < left or right < _from:
                return 0
            else:
                return -1

        node = 0
        left, right = 0, self.tree_size//2
        todo = [[node, left, right]]

        result = self.no_effect
        while todo:
            node, left, right = todo.pop()
            if is_in_query(left, right) == 1:
                data = self.tree[node]
                result = self.merge_func(result, data)

            elif is_in_query(left, right) == 0:
                continue

            else:
                child1 = node * 2 + 1
                child2 = node * 2 + 2
                center = (left+right)//2
                todo.append([child1, left, center])
                todo.append([child2, center+1, right])

        return bin(result).count('1')


n = int(input())
S = input().replace('\n', '')
seg_tree = SegmentTrees(target=S, no_effect=0)

Q = int(input())
for _ in range(Q):
    query = input().split()
    if query[0] == '1':
        index, new = int(query[1])-1, query[2]
        seg_tree.update(new, index)

    elif query[0] == '2':
        _from, to = int(query[1])-1, int(query[2])-1
        print(seg_tree.resolve_query(_from, to))


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

const int mod = 998244353;

const int N = 7e5 + 2;

int n, p2[N], fa[N];
long long a, b, k;
int inv(int x) {
   int pw = mod - 2;
   int sol = 1;
   for(; pw; pw /= 2) {
      if(pw & 1) {
         sol = 1LL * sol * x % mod;
      }
      x = 1LL * x * x % mod;
   }
   return sol;
}
int comb(int x, int y) {
   if(x <y)return 0;
   int v1 = fa[x];
   v1 = 1LL * v1 * inv(fa[y]) % mod;
   v1 = 1LL * v1 * inv(fa[x - y]) % mod;
   return v1;
}
int32_t main() {
//ifstream cin("aa.in");
   cin >> n >> a >> b >> k;
   p2[0] = 1;
   fa[0] = 1;
   for(int i = 1; i <= 2*n; ++i)p2[i] = p2[i - 1] * 2 % mod, fa[i] = 1LL * fa[i - 1] * i % mod;
   long long ans = 0;

   for(int ca = 0; ca <= n; ++ca) {
      long long cb = (k - ca * a) / b;
      if(cb<0)continue;
      if((k - ca * a) % b)continue;
      if(ca>n||cb>n)continue;
      ans = (ans + 1LL * comb( n, ca) * comb(n, cb)) % mod;
   }
   cout << ans;

}



Measured memory_bytes: 10496
#include<bits/stdc++.h>
using namespace std;
#define FASTIO std::ios::sync_with_stdio(false);
#define MAXN 200005
int main(){
  FASTIO
  int n;
  cin>>n;
  long long int ans=1;
  for(int i=1;i<=3;i++)ans*=n;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int n,k;
	cin >> n >> k;
	double ans = 0;
	for (int i = 1; i <= n; i++) {
		double tmp = 1.0 / n;
		int now = i;
		while (now < k) {
			now *= 2;
			tmp /= 2;
		}
		ans += tmp;
	}
	printf("%.12f\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>
#include <math.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define repf(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define repr(i, a, b) for (ll i = (ll)a; i > (ll)b; i--)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int infi = 2147483600;
const ll infl = 1e17;

int main()
{
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;
    bool sunuke=true, funuke = true, futari = false;
    a--;
    b--;
    c--;
    d--;
    repf(i,a,c){
        if (s[i]=='#' && s[i+1]=='#'){
            sunuke = false;
            break;
        }
    }
    repf(i,b,d){
        if (s[i] == '#' && s[i + 1] == '#')
        {
            sunuke = false;
            break;
        }
    }
    if (d<c){
        repf(i,b,d+1){
                if (s[i-1]=='.' && s[i]=='.' && s[i+1]=='.'){
                    futari = true;
                    break;
                }
        }
        if (sunuke && funuke && futari){
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    else if (sunuke && funuke){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
     
int main() {
  string s;
  cin >> s;
  int C = s.size();
  
  int D = 0;
  
  for(int i = 0; i < C - 2; i++){
  if(s.at(i) == s.at(i + 1)){
    cout << i + 1 << " " << i + 2 << endl;
    D ++;
    break;
  }
    else if(s.at(i) == s.at(i + 2)){
      cout << i + 1 << " " << i + 3 << endl;
      D ++;
    break;
    }
  }
     if(s.at(C - 2) == s.at(C - 1) && D == 0){
    cout << C - 1 << " " << C << endl;
    D ++;
     }
  
  if(D == 0){
    cout << "-1 -1" << endl;
  }

}

Measured memory_bytes: 512
n = gets.to_i
as = gets.split.map(&:to_i).sort
bs = gets.split.map(&:to_i).sort
cs = gets.split.map(&:to_i).sort

# puts as.inspect
# puts bs.inspect
# puts cs.inspect
ans = 0
bs.each do |b|
  ai = as.bsearch_index { |a| a >= b }
  ci = cs.bsearch_index { |c| c > b }

  # puts "ai:#{ai} ci:#{ci}"

  ai = n if ai.nil?
  ci = n if ci.nil?

  ans += ai * (n - ci)
end

puts ans

Measured memory_bytes: 24680
#include <stdio.h>

int main(){
    int n,i,a[10000],b[10000],p,q;
    while(1){
    scanf("%d",&n);
        if (n==0) break;
    p=0;
    q=0;
    for (i=0;i<n;i++) {
        scanf("%d %d",&a[i],&b[i]);
        if (a[i]>b[i]) {
            p=p+a[i]+b[i];
        }
        if (a[i]<b[i]) {
            q=q+a[i]+b[i];
        }
        if (a[i]==b[i]) {
            p+=a[i];
            q+=b[i];
        }
    }
    printf("%d %d\n",p,q);
    }
    return 0;
}

Measured memory_bytes: 1104
#!/usr/bin/python3
import sys
input = lambda: sys.stdin.readline().strip()
h, w = [int(x) for x in input().split()]
g = [input() for i in range(h)]
dirs = [(-1, 0), (1, 0), (0, -1), (0, 1)]
hit = [[[0 for j in range(w)] for i in range(h)] for dire in dirs]
for d, dire in enumerate(dirs):
    di, dj = dire
    for i in range(h) if di < 0 else reversed(range(h)):
        for j in range(w) if dj < 0 else reversed(range(w)):
            if g[i][j] != '#':
                hit[d][i][j] = (hit[d][i + di][j + dj] if 0 <= i + di < h and 0 <= j + dj < w else 0) + 1
print(max(sum(hit[d][i][j] for d in range(len(dirs))) - 3 for i in range(h) for j in range(w) if g[i][j] != '#'))

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

using namespace std;
typedef long long ll;

int main() {
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  ll sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  int ma = 0;
  for (int i = 1; i < n; ++i) {
    sum += (a[i] - a[i - 1]);
    ma = max(ma, a[i] - a[i - 1]);
  }
  sum += ((k - a[n - 1]) + a[0]);
  ma = max(ma, (k - a[n - 1]) + a[0]);
  sum -= ma;
  cout << sum << '\n';
  return 0;
}



Measured memory_bytes: 1024
"use strict"

function Main(input) {
  input = input.trim().split('\n');
  const N = Number(input[0].trim());
  const B = input[1].trim().split(' ').map(Number);

  let cnt = N-2;
  let ret = B[0];
  for(let i=0; i<cnt; i++){
    ret += Math.min(B[i], B[i+1])
  }
  ret += B[cnt];
  console.log(ret);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<iostream>
#include<cstdio>
#define ll long long
using namespace std;
const ll mod=1e9 +7;
int n,k;
ll f[2020][2020],jc[4040404],jc_n[4040404];
ll C(int x,int y)
{
	if (y<0 || y>x) return 0;
	if (y==0 || x==y) return 1;
	ll sss=jc[x];
	sss=sss*jc_n[x-y]%mod*jc_n[y]%mod;
	return sss;
}
int main()
{
	jc[1]=1;
	jc_n[1]=1;
	for (int i=2;i<=4000010;++i)
	{
		jc[i]=jc[i-1]*i%mod;
		jc_n[i]=(mod-mod/i)*jc_n[mod%i]%mod;
	}
	for (int i=2;i<=4000010;++i)
		jc_n[i]=jc_n[i]*jc_n[i-1]%mod;

	//printf("%lld\n",C(5,1));
	scanf("%d%d",&n,&k);
	if (k==1)
	{
		printf("1\n");
		return 0;
	}
	f[0][0]=1;
	for (int i=0;i<=n;++i)
		for (int j=n;j>=0;--j)
		if (f[i][j])
		{
			if (j) f[i][j-1]=(f[i][j-1]+f[i][j])%mod;
			f[i+1][j+1]=(f[i+1][j+1]+C(i*k-j+k-2,k-2)*f[i][j]%mod)%mod;
		}
	printf("%lld\n",f[n][0]*jc[n]%mod);
	return 0;
}

Measured memory_bytes: 94976