akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define _size(X) (int)((X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 300, MAX_M = 300;
int N, M;
int A[MAX_N][MAX_M];
bool used[MAX_M];
int sum[MAX_M];

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

  cin >> N >> M;
  rep(i, N) {
      rep(j, M) {
          cin >> A[i][j];
          --A[i][j];
      }
  }


  if (M == 1) {
      cout << N << endl;
      return 0;
  }

  ll ans = INFINT;
  memset(used, true, sizeof(used));
  for (int n = 0; n < M-1; ++n) {
      memset(sum, 0, sizeof(sum));
      for (int i = 0; i < N; ++i) {
          for (int j = 0; j < M; ++j) {
              if (used[A[i][j]]) {
                  ++sum[A[i][j]];
                  break;
              }
          }
      }

      ll ma = 0, sport = 0;
      for (int i = 0; i < M; ++i) {
          if (ma < sum[i]) {
              ma = sum[i]; sport = i;
          }
      }
      ans = min(ans, ma);
      used[sport] = false;
  }


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


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repr(i, m, n) for (int (i)(m - 1); (i)>=(n); --(i))
#define repv(i, v) for (unsigned (i)(0); (i)<(v.size()); ++(i))
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define sortgi(v) sort(all(v), greater<int>())
#define sortgd(v) sort(all(v), greater<double>())
#define sortgll(v) sort(all(v), greater<ll>())
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
using pii = pair<int, int>;
using pss = pair<string, string>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;

int main() {
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	vi c = {abs(a[0] - a[1]), abs(a[1] - a[2]), abs(a[2] - a[0])};
	sortv(c);
	cout << c[0] + c[1] << endl;
}


Measured memory_bytes: 888
import sys
input = sys.stdin.readline
n=int(input())
T=1
A=1

for i in range(n):
    t,a=map(int,input().split())
    x=-(-T//t)
    y=-(-A//a)
    bai=max(x,y)
    T=t*bai
    A=a*bai
print(T+A)


Measured memory_bytes: 38256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int[] a = new int[5];
        int min = 10;
        int minMenu = 0;
        int result = 0;
        for(int i=0;i<5;i++){
            a[i] = sc.nextInt();
            int mod = a[i] % 10;
            if(mod < min && mod != 0){
              min=mod;
              minMenu = i;
            }
        }
        for(int i=0;i<5;i++){
            if(i != minMenu){
              result += Math.ceil((float)a[i]/10)*10;
              
            }else{
              result += a[i];
            }
        }
        System.out.println(result);   
	}
}

Measured memory_bytes: 23252
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    private static int[] make_cost = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
    public static void Main()
    {
        int N = NextInt();
        int M = NextInt();
        int[] A = LineInt();
        string[] dp = new string[N + 1];
        dp[0] = "";
        for (int i = 1; i <= N; i++)
        {
            dp[i] = "0";
            foreach (int a in A)
            {
                if (make_cost[a] > i || dp[i - make_cost[a]] == "0") continue;
                int index = LogSearch(dp[i - make_cost[a]], char.Parse(a.ToString()));
                string s = dp[i - make_cost[a]].Substring(0, index) + a + dp[i - make_cost[a]].Substring(index);
                if (Compare(s, dp[i])) { dp[i] = s; }
            }
        }
        Console.WriteLine(dp[N]);
    }
    private static int LogSearch(string s, char c)
    {
        int a = 0, b = s.Length;
        if (s == "") return 0;
        if (s[0] <= c) return 0;
        else if (s[b - 1] >= c) return b;
        while (b - a != 1)
        {
            int x = (a + b) / 2;
            if (s[x] < c) b = x;
            else a = x;
        }
        return b;
    }
    private static bool Compare(string a, string b)
    {
        if (a.Length > b.Length) { return true; }
        else if (a.Length < b.Length) { return false; }
        for (int i = 0; i < a.Length; i++)
        {
            if (a[i] > b[i]) return true;
            else if (a[i] < b[i]) return false;
        }
        return false;
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 96792
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();
		sc.close();

		int y = x;
		for (int i = 0; i < 10; i++) {
			y = r * y - d;
			System.out.println(y);
		}
	}
}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define WATCH(x) cout << (#x) << " is " << (x) << endl

#define PB push_back
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define flash ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);

int main()
{   
    flash
    
    ll n;
    cin >> n;
    ll ar[n];
    for(ll i=0 ; i<n ; i++) {
        cin >> ar[i];
    }
    int mx=0 , cmx=0;

    for(int i=1 ; i<n ; i++) {
        if(ar[i-1] >= ar[i]) {
            cmx++;
        }
        else {
            if(cmx > mx) mx=cmx;
            cmx=0;
        }
        if(cmx > mx) mx=cmx;
    }
    cout << mx;
      
}

Measured memory_bytes: 1024
'use strict'
const Main = (arg) => {
  let input = arg.trim().split('\n');
  let W = input[0].split(' ').map(Number)[0];
  let H = input[0].split(' ').map(Number)[1];
  let x = input[0].split(' ').map(Number)[2];
  let y = input[0].split(' ').map(Number)[3];

  let S = W * H / 2;
  let Judg = 0;
  let CW = W / 2;
  let CH = H / 2;
  
  if (CW === x && CH === y) {
    Judg = 1;
  } 

  console.log(S, Judg);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7628
def main():
    import sys
    input = lambda:sys.stdin.readline().strip()
    
    N,Q = map(int,input().split())
    AB = [list(map(int,input().split())) for _ in range(N-1)]
    PX = [list(map(int,input().split())) for _ in range(Q)]

    from collections import deque

    tree = [[] for i in range(N)]
    for a,b in AB:
        tree[a-1].append(b-1)
        tree[b-1].append(a-1)
    
    score = [0]*N
    for p,x in PX:
        score[p-1]+=x

    queue = deque([0])
    visited = [False]*N
    visited[0] = True

    while queue:
        x = queue.pop()

        for i in tree[x]:
            if not visited[i]:
                queue.append(i)
                score[i]+=score[x]
                visited[i]=True

    print(*score)

if __name__=='__main__':
    main()

Measured memory_bytes: 127900
#include <iostream>
#include <vector>
#include <cstring>
#include <cctype>
#include <string>
#include <cmath>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;

int main(){
	double a, b,r;
	int C;
	double S, L, h;
	cin >> a >> b >> C;
	r = double(C) / 180 * M_PI;
	S = a*b*sin(r)/2;
	h = b*sin(r);
	L = a + b + sqrt(a*a+b*b-2*a*b*cos(r));
	cout <<fixed<< S << endl << L << endl << h << endl;
	return 0;

}

Measured memory_bytes: 1296
def mks(num):
  s=str(num)
  if len(s)<6:
    s='0'*(6-len(s))+s
  return s

n,m=map(int,input().split())
arr=[]
for i in range(m):
  p,y=map(int,input().split())
  arr.append([p,y,i])
ans=[0]*m
arr=sorted(arr,key=lambda x:x[1])
arr=sorted(arr,key=lambda x:x[0])
tmp=arr[0][0]
cnt=1
for i in range(m):
  if arr[i][0]==tmp:
    s1,s2=mks(tmp),mks(cnt)
    ans[arr[i][2]]=s1+s2
    cnt+=1
  else:
    cnt=1
    tmp=arr[i][0]
    s1,s2=mks(tmp),mks(cnt)
    ans[arr[i][2]]=s1+s2
    cnt+=1
for i in range(m):
  print(ans[i])

Measured memory_bytes: 31968
N,T=map(int,input().split())
A=tuple(map(int,input().split()))
x=[0]*N
x[0]=A[0]
for i in range(1,N):
  x[i]=min(x[i-1],A[i])
B={}
for i in range(1,N):
  tmp=A[i]-x[i-1]
  if tmp<0:
    continue
  if tmp not in B:
    B[tmp]=1
  else:
    B[tmp]+=1
d=list(B.items())
d.sort(reverse=True)
print(d[0][1])

Measured memory_bytes: 24968
n=int(input())
a=[list(map(int,input().split()))for _ in range(n)]
def f():
 for i in range(n-1):
  d=a[i][:];d[3],d[4]=d[4],d[3]
  for j in range(i+1,n):
   e=a[j][:];e[3],e[4]=e[4],e[3]
   for p in('012345','152043','215304','302541','410352','514320'):
    f=[d[int(k)]for k in p]
    g=f[1:5]*2
    for k in range(4):
     if g[k:k+4]==e[1:5]:
      if f[0]==e[0]:
       if f[5]==e[5]:return 'No'
 return 'Yes'
print(f())


Measured memory_bytes: 5608
//
//  main.cpp
//  ATcode131
//
//  Created by didi on 2020/1/16.
//  Copyright © 2020年 didi. All rights reserved.
//

#include <iostream>
#include <map>
#include <vector>
#include <set>
using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    string s;
    cin >> s;
    for (int i = 0; i + 1 < s.length(); ++i) {
        if (s[i] == s[i+1]) {
            cout << "Bad";
            return 0;
        }
    }
    cout << "Good";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define int long long
using namespace std;
typedef pair<int,int>P;
#define fi first
#define se second



signed main(){
  int n,a,b,c;
  cin>>n>>a>>b>>c;
  int s=c+(a-c)+(b-c);
  cout<<n-s<<endl;
}


Measured memory_bytes: 3104
#include<stdio.h>
int n,A[50];
int solve(int i,int m){
if(m==0)return 1;
else if(i>=n)return 0;
int res = solve(i+1,m) || solve(i+1,m-A[i]);
return res;
}
int main(){
    int m,q,p;
scanf("%d",&n);
for(int i=0;i<n;i++){
    scanf("%d",&A[i]);
}
scanf("%d",&m);
for(int i=0;i<m;i++){
    scanf("%d",&q);
    if(solve(0,q))printf("yes\n");
    else printf("no\n");
}
return 0;
}

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

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

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

int main() {
    ll a, b;
    cin >> a >> b;
    cout << lcm(a, b) << endl;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i =0; i < N; i++){
        cin >> A.at(i);
    }

    int ans = 0;

    for (int i = 0; i < N; i++){
        if((i+1)%2==1){
            if(A.at(i)%2==1){
                ans++;
            }
        }
    }

    cout << ans << endl; 
}

Measured memory_bytes: 3624
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys

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

sys.setrecursionlimit(2147483647)
INF = float("inf")

# N = int(sys.stdin.readline())
# S = sys.stdin.readline().rstrip()
#
# ans = 0
# for i in range(N):
#     a = set(Counter(S[:i]).keys())
#     b = set(Counter(S[i:]).keys())
#     ans = max(ans, len(a&b))
# print(ans)

X = int(sys.stdin.readline())

beki = {1}
for i in range(2, 1001):
    e = 2
    while i ** e <= X:
        beki.add(i ** e)
        e += 1
print(max(beki))


Measured memory_bytes: 13784
x = input()
y = input()

re = 0

for a in range(0,len(x)-len(y)+1):
  z = 0
  for b in range(0,len(y)):
    if y[b] == x[b+a]:
      z = z+1
      if(z>re):
        re = z
dd = len(y) - re
print(dd)
        
    

Measured memory_bytes: 9076
n = int(input())
if n % 2 == 1:
    print(0)
else:
    p = 1
    t = 5
    n //= 2
    while t <= n:
        p += 1
        t *= 5
    s = 0
    
    for i in range(1,p):
        s += n // (5 ** i)
    print(s)

Measured memory_bytes: 3060
// H - Grid 1
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)
#define MOD 1'000'000'007
#define MAX 1'000
string grid[MAX];
int dp[MAX+1][MAX+1]; // init 0

int main(){
	int H,W; cin>>H>>W;
	rp(h, 0, H) cin>>grid[h];

	irp(i, H-1, -1){ // [H-1,0] dp height
		irp(j, W-1, -1){ // [W-1,0] dp width
			if(grid[i][j] == '#') continue;
			if(i==H-1 && j==W-1){ dp[i][j] = 1; continue; }
			dp[i][j] = (dp[i][j+1] + dp[i+1][j]) % MOD;
		}
	}
	cout<< dp[0][0] <<endl;
}


Measured memory_bytes: 5248
#include<stdio.h>
#include<string.h>
int main(void) {
	char s[100000000], c[3] = "01";
	int ans = 0;
	scanf("%s", &s);
	for (int i = 0;i < strlen(s);i++) {
		if (s[i] == c[i % 2]) {
			ans++;
		}
	}
	if (ans * 2 > strlen(s))ans = strlen(s) - ans;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2304
#include <iostream>

using namespace std;

int main() {
    int N, K, sum = 1;

    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        if ((sum * 2) >= (sum + K)) {
            sum += K;
        }
        else {
            sum *= 2;
        }
    }
    cout << sum << endl;
}


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

#define ll long long
#define NINF -1e9

void In_Out() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}

void display_arr(int dp[100005][3], int n) {
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}
	// cout << endl;
}

int max_happiness(vector<vector<int>> &v, int n) {
	int dp[100005][3] = {0};
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			dp[i][j] = v[i][j] + max((i - 1) >= 0 and (j + 1) < 3 ? dp[i - 1][j + 1] : 0,
			                         max((i - 1) >= 0 and (j + 2) < 3 ? dp[i - 1][j + 2] : 0,
			                             max((i - 1) >= 0 and (j - 1) >= 0 ? dp[i - 1][j - 1] : 0,
			                                 (i - 1) >= 0 and (j - 2) >= 0 ? dp[i - 1][j - 2] : 0)));
		}
	}
	int ans = NINF;
	for (int i = 0; i < 3; i++) {
		ans = max(ans, dp[n - 1][i]);
	}
	// display_arr(dp, n);
	return ans;
}

int main() {
	// In_Out();
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n;
	cin >> n;
	std::vector<vector<int>> happy_arr(n, vector<int> (3));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> happy_arr[i][j];
		}
	}
	cout << max_happiness(happy_arr, n) << endl;
}

Measured memory_bytes: 9736
while true do
	h,w = gets.split.map(&:to_i)
	if h == 0 && w == 0
		break
	end
	i = 0
	while i < h do
		r = ""
		if i % 2 == 0 or i == 0
			for num in 1..w do
				if num == 1 or num % 2 == 1 
					r = r + "#" 
				else
					r = r + "." 
				end
			end
		else
			for num in 1..w do
				if num == 0 or num % 2 == 0 
					r = r + "#" 
				else
					r = r + "." 
				end
			end
		end
	puts r
	i = i + 1
	end

	puts ""
end


Measured memory_bytes: 7280
#include<iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	int i;
	for (i = 0; i < n; i++) {
		cout << s[i];
		cout << t[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N; cin >> N;
    vector<int> A, B;
    rep (i, 0, N+1) {
        int a; cin >> a;
        A.push_back(a);
    }
    rep (i, 0, N) {
        int b; cin >> b;
        B.push_back(b);
    }

    long long ans = 0;
    rep (i, 0, N) {
        ans += min(A[i], B[i]);
        B[i] -= min(A[i], B[i]);
        A[i] -= min(A[i], B[i]);

        ans += min(A[i+1], B[i]);
        A[i+1] -= min(A[i+1], B[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 200000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* struct for mod Calculation*/
struct mint {
    ll x;
    mint(ll x = 0):x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
/* global variables */
/* function */
struct combination {
    // vector size : n + 1
    vector<mint> fact, ifact;
    // precaliculation O(n)
    combination(int n):fact(n+1), ifact(n+1) {
        assert(n < mod);
        // 0! = 1;
        fact[0] = 1;
        // 1! = 0! * 1 ... n! = (n-1)! * n
        for (int i = 1; i <= n; i++) fact[i] = fact[i-1] * i;
        // 1/n! = n!^(-1)
        ifact[n] = fact[n].inv();
        // (n-1)!^(-1) = n!^(-1) * n ... 0!^(-1) = 1!^(-1) * 1
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i] * i;
    }
    // combination O(1)
    // nCk = n! / (k! * (n-k)!)
    //     = n! * k!^(-1) * (n-k)!^(-1)
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n-k];
    }
};
/* global variables */
/* function */
/* main */
int main(){
    ll N, K;
    cin >> N >> K;
    combination c = combination(MAX);
    mint ans = 0;
    K = min(K, N - 1);
    for (int i = 0; i <= K; i++) {
        ans += c(N, i) * c(N - 1, i);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3328
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int N = 0;

bool is_753(int s) {
  bool seven = false, five = false, three = false;
  while (s>0) {
    switch (s%10) {
      case 3:
        three = true;
        break;
      case 5:
        five = true;
        break;
      case 7:
        seven = true;
        break;
      default:
        break;
    }

    if (seven && five && three) return true;
    s /= 10;
  }

  return false;
}

int dfs(long s) {
  if (s > N) return 0;

  int ret = 0;
  if (is_753(s)) ++ret;
  for (long d : {7, 5, 3}) {
    ret += dfs(s*10+d);
  }
  return ret;
}

int main() {
  std::cin >> N;
  std::cout << dfs(0) << std::endl;
}


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

using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll (i) = 0; i < n; i++)
#define FORN(i, a, b) for (ll (i) = a; i < b; i++)
#define FORE(i, l) for (auto (i) : l)

#define pb push_back
#define pob pop_back
#define emp emplace

#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    	
    ll n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string move;
    cin >> move;
    ll c = 0;
    FOR(i, n)
    {
        if (i < k || move[i - k] != move[i])
        {
            if (move[i] == 'r') c += p;
            else if (move[i] == 'p') c += s;
            else c += r;
        }
        else if (i >= k && move[i - k] == move[i]) move[i] = ' ';
    }
    cout << c << '\n';
}



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

int main() {
string S;
cin >> S;
if(S == "ooo"){
    cout << 1000 <<endl;
}
else if(S == "oox"||S == "oxo"||S == "xoo"){
    cout << 900 <<endl;
}
else if(S == "oxx"||S == "xox"||S == "xxo"){
    cout << 800 <<endl;
}
else if(S == "xxx"){
    cout << 700 <<endl;
}
}

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

int main() {
  int n;
  cin >> n;
  vector<int> x(n), l(n);
  vector<tuple<int, int, int>> r(n);
  for(int i = 0; i < n; i++){
    cin >> x.at(i) >> l.at(i);
    r.at(i) = {x.at(i) + l.at(i), l.at(i), i};
  }
  
  sort(r.begin(), r.end());
  int lastr = -2 * pow(10, 9), ans = 0;
  for(int i = 0; i < n; i++){
    int len = get<1>(r.at(i)), lef = get<0>(r.at(i)) - 2 * len, num = get<2>(r.at(i));
    if(lastr > lef) continue;
    ans++, lastr = lef + len * 2;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 5088
#include <stdio.h>
#include <math.h>

int main(void){
	double x1,x2,y1,y2;
	double distance=0;

	scanf("%lf %lf %lf %lf", &x1,&y1,&x2,&y2);
	distance = (double)sqrt(pow((x2-x1),2) + pow((y2-y1),2));

	printf("%f\n",distance);
	return 0;
}

Measured memory_bytes: 652
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<ll, P> E;
#define MOD (1000000007ll)
#define l_ength size
#define PI 3.14159265358979
#define TAU (2.0*PI)
#define N 5000000

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int n,i,j,cnt[123],t;
	double x[123],y[123],cs,sn,mx;
	fill(cnt,cnt+123,0);
	cin >> n;
	for(i=0; i<n; ++i){
		cin >> x[i] >> y[i];
	}
	for(i=0; i<N; ++i){
		cs = cos(TAU*i/N);
		sn = sin(TAU*i/N);
		mx = -INFLL;
		for(j=0; j<n; ++j){
			if(mx < (cs*x[j]+sn*y[j])){
				t = j;
				mx = (cs*x[j]+sn*y[j]);
			}
		}
		++cnt[t];
	}
	for(i=0; i<n; ++i){
		printf("%.10lf\n",((double)(cnt[i])/N));
	}
	return 0;
}



Measured memory_bytes: 896
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=int_fast64_t;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

void dfs(vector<vector<int>>&v,vector<int>&vis,vector<bool>&u,vector<int>&ans,int i){
    vis.emplace_back(i);
    u[i]=true;
    for(auto j:v[i]){
        if(u[j]){
            if(vis[0]!=j){
                vis.pop_back();
                return;
            }
            if(ans.empty()||ans.size()>vis.size()) ans=vis;
        }
        else dfs(v,vis,u,ans,j);
    }
    u[i]=false;
    vis.pop_back();
}

class FPure {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        pair<int,int> z(0,0);
        int n,m,a,b;
        in>>n>>m;
        vector<vector<int>> v(n);
        fr(i,m) in>>a>>b,v[--a].emplace_back(--b);
        vector<int> vis,ans;
        vector<bool> u;
        fr(i,n){
            vis.clear();
            u.assign(n,false);
            dfs(v,vis,u,ans,i);
        }
        if(ans.empty()) out<<-1<<endl;
        else{
            out<<ans.size()<<endl;
            for(auto i:ans) out<<i+1<<endl;
        }
    }
};

int main() {
    FPure solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main {
	public static void main(String[] args) {
		for(Scanner sc = new Scanner(System.in);sc.hasNext();){
			String l=sc.next();
			int c=0, t=1;
			for(int p=0;p<l.length();p++, t=t*(9-p+1)/p)c=(t*(l.charAt(p)-'0')+c)%10;
			System.out.println(c);
		}
	}
}

Measured memory_bytes: 17120
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template <typename T> using V = vector<T>;
constexpr int Mod = 998244353;
constexpr int mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
template <typename T> constexpr bool chmax(T &a, const T &b) {
    if(a >= b) return false;
    a = b;
    return true;
}
template <typename T> constexpr bool chmin(T &a, const T &b) {
    if(a <= b) return false;
    a = b;
    return true;
}

/*-------------------------------------------*/

template <int M> class ModInt {
    int x;

  public:
    constexpr ModInt() : x(0) {}
    constexpr ModInt(int64_t y) : x(y >= 0 ? y % M : (M - (-y) % M) % M) {}
    constexpr ModInt &operator+=(const ModInt p) {
        if((x += p.x) >= M) x -= M;
        return *this;
    }
    constexpr ModInt &operator-=(const ModInt p) {
        if((x += M - p.x) >= M) x -= M;
        return *this;
    }
    constexpr ModInt &operator*=(const ModInt p) {
        x = (int)(1LL * x * p.x % M);
        return *this;
    }
    constexpr ModInt &operator/=(const ModInt p) {
        *this *= p.inverse();
        return *this;
    }
    constexpr ModInt operator-() const { return ModInt(-x); }
    constexpr ModInt operator+(const ModInt p) const {
        return ModInt(*this) += p;
    }
    constexpr ModInt operator-(const ModInt p) const {
        return ModInt(*this) -= p;
    }
    constexpr ModInt operator*(const ModInt p) const {
        return ModInt(*this) *= p;
    }
    constexpr ModInt operator/(const ModInt p) const {
        return ModInt(*this) /= p;
    }
    constexpr bool operator==(const ModInt p) const { return x == p.x; }
    constexpr bool operator!=(const ModInt p) const { return x != p.x; }
    constexpr ModInt inverse() const {
        int a = x, b = M, u = 1, v = 0, t = 0;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }
    constexpr ModInt pow(int64_t k) const {
        ModInt ret(1), mul(x);
        while(k > 0) {
            if(k & 1) ret *= mul;
            mul *= mul;
            k >>= 1;
        }
        return ret;
    }
    constexpr friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }
    constexpr friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t = 0;
        is >> t;
        a = ModInt(t);
        return (is);
    }
};
using modint = ModInt<mod>;

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

    ll n, k;
    cin >> n >> k;
    modint ans;
    FOR(i, k, n + 2) {
        modint mn(i * (i - 1) >> 1), mx((2 * n - i + 1) * i >> 1);
        ans += mx - mn + 1;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
#define intt long long int 
void solve(){
    intt a,b,c,d;
    cin>>a>>b>>c>>d;
    intt ar[4];
    
    ar[0]= a*c;
    ar[1]= b*c;
    ar[2]= a*d;
    ar[3]= b*d;
    intt pmax= ar[0];
    for(int i=0;i<4;i++){
        if(ar[i]>pmax)
            pmax=ar[i];
    }
    
    cout<<pmax;
}
int main(){
    // int t;
    // cin>>t;
    // while(t--)
        solve();
}

Measured memory_bytes: 3632
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N, L;
    cin >> N >> L;
    vector<string> S(N);
    for (ll i = 0; i < N; i++) {
        cin >> S[i];
    }
    sort(S.begin(), S.end());
    for (ll i = 0; i < N; i++) {
        cout << S[i];
    }
    cout << endl;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.Bits
import Data.List

bsReadInts :: B.ByteString -> [Int]
bsReadInts = map (fst . fromJust . B.readInt) . B.words


solve :: Int -> [Int] -> Int
solve valN as = head [i | i <- [half..], testBit set i]
  where
    half = ((sum as) + 1) `div` 2
    set :: Integer
    set = foldl' op (bit 0) as
      where op x a = x .|. (shiftL x a)

main :: IO ()
main = do
  conts <- B.getContents
  let valN : as = bsReadInts conts
      answer = solve valN as
  putStrLn $ show $ answer


Measured memory_bytes: 4476
#include<cstdio>
#include<cstring>
int main(){
	char a[25];
	int l;
	scanf("%s",&a);
	l=strlen(a);
	a[5]=' ';
	a[13]=' ';
	for(int i=0;i<l;i++){
		printf("%c",a[i]);
	}
	return 0;
}

Measured memory_bytes: 256
#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,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define len(s) (int)s.size()

template<class T> inline bool chmin(T &a, T b){
	if(a>b){a=b;return true;}
	return false;
}
template<class T> inline bool chmax(T &a, T b){
	if(a<b){a=b;return true;}
	return false;
}
constexpr int mod = 1e9+7;
constexpr int inf = 3e18;

signed main(){
	int K;cin>>K;
	int now=7;
	REP(i,1e7){
		if(now%K==0){
			cout<<i<<endl;return 0;
		}
		now=now*10+7;
		now%=K;
	}
	cout<<"-1\n";
}

Measured memory_bytes: 3668
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int i = 2;
		System.out.print(n+":");
		for(int j=2;j<=31622;j++){
			if(n%j==0){
				break;
			}
			if(j==31622){
				System.out.println(" "+n);
				return;
			}
		}
		while(true){
			if(n%i==0){
				System.out.print(" "+i);
				n = n / i;
			}
			else{
				i++;
			}
			
			if(n==1){
				break;
			}
		}
		System.out.println();
	}

}

Measured memory_bytes: 17304
#include <bits/stdc++.h>
#define F first
#define S second
#define dq deque
#define vc vector
#define InF ((int)(1e9))
#define LInF ((int)(1e18))
#define out cout <<
#define ln  << endl
#define pb push_back
#define mp make_pair
#define _tp template
#define _tyn typename
#define pf push_front
#define itor iterator
#define mp make_pair
#define sint short int
#define ull unsigned long long
#define pq priority_queue
#define pii pair<int,int>
#define uint unsigned int
#define ll long long
#define B out "BreakPoint" ln;
#define read(_nowans) scanf("%d",&_nowans)
#define ms(_data) memset(_data,0,sizeof(_data))
#define fin(_filename) freopen(_filename,"r",stdin)
#define fout(_filename) freopen(_filename,"w",stdout)
#define read2(_nowans1,_nowans2) scanf("%d %d",&_nowans1,&_nowans2)
#define msn(_data,_nowans) memset(_data,_nowans,sizeof(_data))
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define read3(_nowans1,_nowans2,_nowans3) scanf("%d %d %d",&_nowans1,&_nowans2,&_nowans3)
#define lb( _x , _y ) ( lower_bound( _x.begin() , _x.end() , _y ) - _x.begin() + 1 )
using namespace std;
_tp<_tyn T>void mymax( T &_a , T _b ){ if( _a < _b ) _a = _b; }
_tp<_tyn T>void mymin( T &_a , T _b ){ if( _a > _b ) _a = _b; }
void print( int _x ){ printf("%d\n",_x); }
_tp<_tyn T>void print( T _data[] , int _size ){
	for( int i = 1 ; i <= _size ; i++ )
		cout << (_data[i]?'X':' ') << " ";
	cout << endl;
}

double div( int x ){
	return 1.0/(double(x));
}
#define MX 8000

ll n;
int main(){
	cin >> n;
	bool f = 0;
	if( n == 2 ){
		printf("1 2 2\n");
		return 0;
	}
	if( n == 4 ){
		printf("3 3 3\n");
		return 0;
	}
	for( ll i = 1 ; i <= MX  &&  !f ; i++ )
		for( ll j = 1 ; j <= MX  &&  !f ; j++ )
			if( (4LL*j*i-n*j-n*i) > 0LL  &&  !( (n*i*j) % (4LL*j*i-n*j-n*i) ) ){
				printf("%lld %lld %lld\n",i,j,(n*i*j) / (4LL*j*i-n*j-n*i));
				f = 1;
				break;
			}
	if(!f) while(1);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl; }}

int vtoi(int a, int b, int c, int d){
    int v1 = a + 1000 * b + 1000000 * c + 1000000000 * d;
    int v2 = b + 1000 * c + 1000000 * d + 1000000000 * a;
    int v3 = c + 1000 * d + 1000000 * a + 1000000000 * b;
    int v4 = d + 1000 * a + 1000000 * b + 1000000000 * c;
    return min(min(v1, v2), min(v3, v4));
}
int vtoi(vec v){
    return vtoi(v[0], v[1], v[2], v[3]);
}
int symmetry(vec v){
    if(v[0] == v[1] && v[1] == v[2] && v[2] == v[3]) return 4;
    else if(v[0] == v[2] && v[1] == v[3]) return 2;
    else return 1;
}

signed main(){

    int N; cin >> N;
    mat C(N, vec(4));
    map<int, int> m;
    REP(i, N){
        readv(C[i]);
        m[vtoi(C[i])] += 1;
    }
    

    int ans = 0;
    mat side(4, vec(4));
    REP(i, N){
        m[vtoi(C[i])] -= 1;
        FOR(j, i + 1, N){
            m[vtoi(C[j])] -= 1;

            REP(r, 4){
                int tmp = 1;
                REP(s, 4){
                    side[s][0] = C[i][(4 - s) % 4];
                    side[s][1] = C[i][3 - s];
                    side[s][2] = C[j][(1 + s + r) % 4];
                    side[s][3] = C[j][(s + r) % 4];
                }
                int s0 = 0;
                REP(s, 4){
                    if(m[vtoi(side[s])] > 0){
                        tmp *= m[vtoi(side[s])] * symmetry(side[s]);
                        m[vtoi(side[s])] -= 1;
                        s0++;
                    }else break;
                }
                REP(s, s0) m[vtoi(side[s])] += 1;
                if(s0 == 4) ans += tmp;
            }

            //cout << i << "," << j << "," << ans << endl;

            m[vtoi(C[j])] += 1;
        }
        m[vtoi(C[i])] += 1;
    }
    cout << ans / 3;
    
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int M = 0;
  for (int i = 1; i <90000; i++) {
    M += i;
    if (N <= M) {
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
import sys

N, K = map(int, input().split())
hito = [0] * K
if N == 0:
    print(0)
    sys.exit()
while True:
    for i in range(len(hito)):
        hito[i] += 1
        N -= 1
        if N == 0:
            break
    if N == 0:
        break
print(hito[0] - hito[len(hito) - 1])

Measured memory_bytes: 3064
from collections import Counter, defaultdict
import sys
sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools


def main():
    month, day = map(int, input().split())

    ans = 0
    for i in range(1, month + 1):
        for j in range(1, day + 1):
            aaa = j % 10
            bbb = j % 100
            if bbb < 10:
                continue
            bbb = str(bbb)[0]
            bbb = int(bbb)
            if aaa < 2 or bbb < 2:
                continue

            if aaa * bbb == i:
                ans += 1

    print(ans)






if __name__ == '__main__':
    main()



Measured memory_bytes: 40304
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
ll x,y,z,k;
vector<ll> a,b,c;
int cmp(ll x,ll y){
	return x>y;
}
int main()
{
	cin>>x>>y>>z>>k;
	for(int i=0;i<x;i++){
		ll w;
		cin>>w;
		a.push_back(w);
	}
	for(int i=0;i<y;i++){
		ll w;
		cin>>w;
		b.push_back(w);
	}
	for(int i=0;i<z;i++){
		ll w;
		cin>>w;
		c.push_back(w);
	}
	vector<ll> d;
	sort(a.begin(),a.end(),cmp);
	sort(b.begin(),b.end(),cmp);
	sort(c.begin(),c.end(),cmp);
	for(int i=0;i<a.size();i++){
		for(int j=0;j<b.size();j++){
			d.push_back(a[i]+b[j]);
		}
	}
	sort(d.begin(),d.end(),cmp);
	vector<ll> e;
	ll t=min((ll)d.size(),k);
	for(int i=0;i<t;i++){
		for(int j=0;j<c.size();j++)
		{
			e.push_back(c[j]+d[i]);
		}
	}
	sort(e.begin(),e.end(),cmp);
	for(int i=0;i<k;i++){
		cout<<e[i]<<endl;
	}
}

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

#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

typedef long long ll;

int main(){
  int N;
  cin >> N;
  vector<int> x(N), y(N);
  int ans = 1;
  REP(i, N){
    cin >> x[i] >> y[i];
  }
  vector<vector<pair<int, int>>> graph(N, vector<pair<int, int>>(N,make_pair(0,0)));
  REP(i, N){
    REP(j, N){
      graph[i][j].first = x[j] - x[i];
      graph[i][j].second = y[j] - y[i];
    }
  }
  int cnt = 0;
  FOR(i, 0, N){
    FOR(j, 0, N){
      if(i == j){
        continue;
      }
      cnt = 0;
      FOR(k, 0, N){
        FOR(l, 0, N){
          if(i != k || j!=l){
            if((graph[i][j].first == graph[k][l].first) && (graph[i][j].second == graph[k][l].second)){
              cnt++;
            }
          }
        }
      }
      ans = max(cnt+1, ans);
    }
  }
  if(N <= 2){
    cout << 1 << endl;
  }
  else{
  cout << N - ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
def so(x):
    a=[]
    b=[True]*(n+1)
    b[0]=False
    b[1]=False
    for i in range(2,int(x**0.5)+1):
        if not b[i]:
            continue
        for j in range(i*2,n+1,i):
            b[j]=False
    for k in range(len(b)):
        if b[k]:
            a.append(k)
    print(len(a))
while True:
    try:
        n = int(input())
    except:
        break
    so(n)



Measured memory_bytes: 16820
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s = "";
  int cnt = 0;
  
  cin >> s;
  for (int i = 0; i <= 2; i++) {
  	if (s[i] == '1') {
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# Generated by https://github.com/kyuridenamida/atcoder-tools
from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')
YES = "Yes"  # type: str
NO = "No"  # type: str


def is_palindrome(s: str):
    return s[:len(s)//2] == s[::-1][:len(s)//2]


def solve(S: str):
    return [NO, YES][is_palindrome(S) and is_palindrome(S[:(len(S)-1)//2-1+1]) and is_palindrome(S[(len(S)+3)//2-1:])]


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    print(f'{solve(S)}')


if __name__ == '__main__':
    main()


Measured memory_bytes: 75140
main :: IO ()
main = do
  n <- readLn
  print $ g n

f :: Int -> [(Int,Int)]
f n = [(x, n-x) | x <- [1..(n `div` 2)]]

sod
  :: Int -> Int
sod n
  | n `elem` [10^p | p <- [1..5]] = 10 -- 100 = 50+50 case 
  | otherwise = sum $ sod' n

sod' 
  :: Int -> [Int]
sod' n
  | q == 0 = [r] 
  | otherwise = r : sod' q
  where
    (q,r) = divMod n 10

sod2 :: Int -> Int -> Int
sod2 x y = sod x + sod y

g :: Int -> Int
g = minimum . map (uncurry sod2) . f

Measured memory_bytes: 892
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan = new java.util.Scanner(System.in);
        String s = scan.next();
        if(s.matches("[a, e ,i , o, u]")){
            System.out.println("vowel");
        }else{
            System.out.println("consonant");
        }
    }
}

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

typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)

int divisors(int n) {
	int div = 0;
	rep1(i, int(sqrt(n)) + 1) {
		if (n % i == 0) {
			div += 1;
			if (i != n / i) {
				div += 1;
			}
		}
	}
	return div;
}

int N;
int dp[1100000];
int ass[1100000];

int main() {

	cin >> N;

	rep1(i, 1000001) dp[i] = divisors(i);
	rep1(i, 1000001) ass[i] = ass[i - 1] + dp[i];

	cout << ass[N - 1] << endl;

}


Measured memory_bytes: 11492
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif

int main() {
    cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(20);
    
    ll x, y;
    cin >> x >> y;

    ll b = (y - 2*x) / 2;
    ll a = x - b;

    if(a >= 0 && b >= 0 && a + b == x && 2*a + 4*b == y) cout << "Yes" << endl;
    else cout << "No" << endl;
    
}


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

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

    int N, K; cin >> N >> K;
    list<char> S;
    rep(i, N) {
        char c; cin >> c;
        S.push_back(c);
    }
    int n = 0;
    char A = 'A', B = 'B';

    auto go = [&] () {
        if(S.front() == A) {
            S.front() = B;
        } else if(S.front() == B) {
            S.pop_front();
            S.push_back(B);
            swap(A, B);
        } else assert(false);
    };
    
    rep(i, min(K, 2 * N)) {
        go();
        n++;
    }   
    if(n < K and (K - n) % 2 == 1) go();
    map<char, char> mp;
    mp['A'] = A;
    mp['B'] = B;
    
    for(auto s : S) cout << mp[s];
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
#define mp(a, b) make_pair(a, b)
typedef long long ll;
typedef pair<int, int> pii;
const int maxn = 2e5 + 10;
char s[maxn], t[maxn];
int main()
{
	scanf("%s%s", s + 1, t + 1);
	int n = strlen(s + 1), m = strlen(t + 1), ans = m;
	for(int i = 1; i + m - 1 <= n; ++i)
	{
		int tmp = 0;
		for(int j = 1; j <= m; ++j) tmp += (s[i + j - 1] != t[j]);
		ans = min(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3764
def solve(n, a):
    ans, r, v = 0, 0, 0
    for l in range(n):
        while (r < n) and ((v+a[r]) == (v^a[r])):
            v += a[r]
            r += 1
        ans += r-l
        v ^= a[l]
    return ans

n = input()
a = map(int, raw_input().split())
print solve(n, a)

Measured memory_bytes: 20020
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    N = int(input())
    A = list(map(int, input().split()))
    s = sum(A)**2
    t = 0
    for a in A:
        t += a**2
    
    ans = (s - t) // 2
    print(ans % 1000000007)


if __name__ == '__main__':
    main()

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

int main() {
  string s;
  cin>>s;
  reverse(s.begin(),s.end());
  vector<string> S={"maerd","remaerd","esare","resare"};
  bool flag=true;
  for(int i=0;i<s.size();){
    bool flag2=true;
    for(int j=0;j<4;j++){
      string d=S[j];
      if(d==s.substr(i,d.size())){
        flag2=false;
        i+=d.size();
        break;
      }
    }
     if(flag2) {cout<<"NO"<<endl;flag=false; break;}
  }
 if(flag) cout<<"YES"<<endl;
}

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

int n;
vector<int> h(100000);
vector<int> dp(100000);

int main(){
    cin>>n;
    rep(i,n) cin>>h.at(i);
    dp.at(0)=0;
    dp.at(1)=abs(h[1]-h[0]);
    for(int i=2;i<n;++i){
        dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

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

using namespace std;
//FILE *fi=freopen("1.txt","r",stdin);
int n,m;
int cnt[200001];
int a[200001];
int main()
{
    cin>>n;
    for(int i=1;i<n;i++)
    {
        int x;
        cin>>x;
        cnt[x]++;
    }
    for(int i=1;i<=n;i++)
    {
        cout<<cnt[i]<<"\n";
    }
    return 0;
}


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

int main(int argc, char *argv[]) {
  int n, k, q;
  std::cin >> n >> k >> q;
  std::vector<int> a(n);
  for (int i = 0; i < n; ++i)
    a.at(i) = k - q;

  for (int i = 0; i < q; ++i) {
    int qs;
    std::cin >> qs;
    ++a.at(qs - 1);
  }

  for (int i = 0; i < n; ++i) {
    std::cout << (a.at(i) > 0 ? "Yes" : "No") << std::endl;
  }
}


Measured memory_bytes: 1024
S = input()
N = len(S)
x = [0] * N
ans = 0
for i in range(N):
  x[i] = int(S[i])
for i in range(N):
  for j in range(N-i):
    if i+j == N-1:
      ans = ans + x[i] * pow(10, j) * pow(2,(N-j-1))
    elif i + j >= N:
      pass
    else:
      ans = ans + x[i] * pow(10, j) * pow(2,(N-j-2))
print(ans)

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

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

    int l, r;
    int count = 0;

  	for(int i = 0; i < N; i++) {
      	cin >> l >> r;
      	
    	count += (r - l + 1); 
    }
  	cout << count << endl;
}

Measured memory_bytes: 3556