akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod 100000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(),v.end()
#define PI acos(-1)

const ll INF = 10010001010;
const int inf = 2000000000;
ll lcm(ll a, ll b)
{
    return a * b / __gcd(a, b);
}

typedef tuple<string, int, int> TUP;

bool tuplesort(const TUP &right, const TUP &left)
{
    if (get<0>(right) != get<0>(left))
    {
        return get<0>(left) < get<0>(right);
    }
    if (get<1>(left) != get<1>(right))
    {
        return get<1>(left) > get<1>(right);
    }
    return get<2>(left) < get<2>(right);
}

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main(){
    int H,W;
    int ans = 0;
    cin >> H >> W;
    int motokuro = 0;
    vector<vector<char>> S(H,vector<char> (W));
    for(int i = 0;i <H;i++){
        for (int j = 0; j < W;j++)
        {
            cin >> S[i][j];
            if(S[i][j] == '#'){
                motokuro++;
            }
        }
    }
    vector<vector<int>> dist(H,vector<int> (W,-1));
    queue<int> que;
    que.push(0);
    que.push(0);
    dist[0][0] = 0;
    while(!que.empty()){
        int h = que.front();
        que.pop();
        int w = que.front();
        que.pop();
        for (int dir = 0; dir < 4;dir++)
        {
            int nh = h + dy[dir];
            int nw = w + dx[dir];
            if(nh >= 0 && nw >= 0 && nh < H && nw < W){
                if(S[nh][nw] == '.' && dist[nh][nw] == -1){
                    que.push(nh);
                    que.push(nw);
                    dist[nh][nw] = dist[h][w] + 1;
                }
            }
        }
    }
    if(dist[H-1][W-1] == -1){
        cout << -1 << endl;
        return 0;
    }
    ans = H * W - motokuro - dist[H - 1][W - 1] - 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		int[] a = new int[n];
		
		long sum = 0;
		
		for(int i = 0; i < n; i++) {
			a[i] = stdIn.nextInt();
			sum += a[i];
		}
		
		long sum2 = 0;
		int index = 0;
		for(int i = 0; i < n; i++) {
			sum2 += a[i];
			if(sum2*2 > sum) {
				index = i;
				break;
			}
		}
		
		long sum3 = 0;
		long ans = 0;
		for(int i = 0; i < index; i++) {
			sum3 += a[i];
		}
		if(sum3 < sum - sum3 - a[index]) {
			ans = sum3+a[index] - (sum-sum3-a[index]);
		}else {
			ans = (sum - sum3) - sum3;
		}

		System.out.println(ans);

		
		
		
		
		
		
		
		
	}

}


Measured memory_bytes: 65276
import numpy as np
import itertools
N = int(input())
p = [list(map(int,input().split())) for _ in range(N)]
print(sum(np.sqrt((p[i][0] - p[j][0])**2 + (p[i][1] - p[j][1])**2) for i, j in itertools.combinations(range(N), 2)) * np.math.factorial(N - 1) * 2 / np.math.factorial(N))

Measured memory_bytes: 14476
function Main(input) {
    var l = 1;
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});    
    var q = parseInt(input[0][0], 10);

    for (var k = 0; k < q; k++){
        var X = input[l][0].split("");
        var Y = input[l + 1][0].split("");

        var arr_dp = [];
        for (var j = 0; j <= Y.length; j++){
            arr_dp.push([]);
            arr_dp[j][0] = 0;
        }
        for (var i = 0; i <= X.length; i++){
            arr_dp[0][i] = 0;
        }
        for (var j = 0; j < Y.length; j++){
            for (var i = 0; i < X.length; i++){
                if (X[i] === Y[j]) arr_dp[j + 1][i + 1] = arr_dp[j][i] + 1;
                else arr_dp[j + 1][i + 1] = Math.max(arr_dp[j + 1][i], arr_dp[j][i + 1]);
            }
        }
        console.log(arr_dp[j][i]);
        l+= 2;
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8")); 


Measured memory_bytes: 142688
=begin
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0568
dp[i][j][k]:i??\???????????????k??\???????????????j
????????\????????????????±??????£???????????¨???
  <=> h[i] != -1, j = h[i]
  ??¬??\???1??\???????????????j dp[i][j][1]
    = i-1??\???????????????j?????????1,2??\???????????????
    = dp[i-1][j_][k_] sum for j_:x!=j, k_:[1,2]
  ??¬??\???2??\???????????????j dp[i][j][2]
    = i-1??\???????????????1??\???????????????j
????????\????????????????±??????£??????????????¨???
  ?±??????£???????????¨?????????????????????????????±????????????????????????
    <=> j = 0, 1, 2
=end

def mod n, i, m=3
  (n + i) % m
end

MOD = 10000
n, k = gets.split.map(&:to_i)

h = Hash.new(-1)
k.times{ 
  a, b = gets.split.map{|x| x.to_i.pred}
  h[a] = b
}

dp = Array.new(n.succ).map{Array.new(3).map{Array.new(3, 0)}}
3.times { |j|
  dp[0][j][1] = 1 if h[0] == -1 || h[0] == j
}

n.pred.times { |i|
  3.times { |j|
    b = h[i.succ] == -1 || h[i.succ] == j
    for j_ in (1..2)
      for k in (1..2)
        dp[i.succ][j][1] += dp[i][mod(j, j_)][k] % MOD if b
      end     
    end     
    dp[i.succ][j][2] += dp[i][j][1] % MOD if b
  }
}
p dp[n.pred].map{|arr| arr.inject :+}.inject(:+) % MOD

Measured memory_bytes: 8784
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
int mypow(int x,int n){
    if(n==0)
        return 1;
    if(n%2==1)
        return mypow(x,n-1)*x%mod;
    int tmp=mypow(x,n/2);
    return tmp*tmp%mod;
}
int inv(int n){
    return mypow(n,mod-2);
}
int fact[2000];
int comb(int n,int r){
    return fact[n]*inv(fact[r]*fact[n-r]%mod)%mod;
}
signed main(){
    fact[0]=1;
    for(int i=1;i<2000;i++)
        fact[i]=i*fact[i-1]%mod;
    int s;
    cin>>s;
    int ans=0;
    for(int i=1;3*i<=s;i++)
        (ans+=comb(s-2*i-1,i-1))%=mod;
    cout<<ans<<endl;
}


Measured memory_bytes: 3648
#include<stdio.h>
int main(void)
{
    int i,n,pm,pe,pj,ave1,ave2;
    for(;;){
        scanf("%d",&n);
        if(n==0){
            return 0;
        }
        for(i=0;i<n;i++){
            scanf("%d %d %d",&pm,&pe,&pj);
            ave1=(pm+pe)/2;
            ave2=(pm+pe+pj)/3;
            if(pm==100 || pe==100 || pj==100 || ave1>=90 || ave2>=80){
                printf("A\n");
            }
            else if(ave2>=70 || (ave2>=50 && (pm>=80 || pe>=80))){
                printf("B\n");
            }else{
                printf("C\n");
            }
        }
    }
    return 0;
}

Measured memory_bytes: 580
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append(cnt)

    if temp!=1:
        arr.append(1)



    return arr

N=int(input())
count_list=factorization(N)
ans=0
for k in range(0,len(count_list)):
    dlt=1
    c=count_list[k]
    while (c-dlt)>=0:
        c=c-dlt
        dlt+=1
        ans+=1
print(ans)


Measured memory_bytes: 9472
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long N;
	int ans=1<<30;
	scanf("%lld",&N);
	for(long long i=1;i*i<=N;i++) {
		if(N%i==0) {
			long long j=N/i;
			ans=min(ans,(int)to_string(j).size());
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007
flush = sys.stdin.flush()

def solve():
    n = I()
    print(0)
    flush
    s = input()
    l = 0
    r = n
    s0 = s
    while s != "Vacant":
        m = (l+r) >> 1
        print(m)
        flush
        s = input()
        if m&1:
            if s == s0:
                r = m
            else:
                l = m
        else:
            if s != s0:
                r = m
            else:
                l = m
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 39108
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (int i=0;i<N;i++)
#define loop(i,N,M) for(int i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

//変数
ll N;
vector<ll> a;

//解法
void solve() {

	ll sum = 0;
	rep(i, N) {
		sum += a[i];
	}
	double ave = (double)sum / N;

	double s = 101;
	ll frame = 0;
	rep(i, N) {
		if (abs(ave - a[i]) < s) {
			s = abs(ave - a[i]);
			frame = i;
		}
	}

	cout << frame;

	return;
}

int main() {
	//入力

	cin >> N;
	a.resize(N);
	rep(i, N) cin >> a[i];

	solve();
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
n,m = gets.split.map(&:to_i)

con_1 = []
con_n = []
m.times do
    a,b = gets.split.map(&:to_i)

    con_1 << b if a == 1
    con_n << a if b == n
end

puts con_1 & con_n != [] ? "POSSIBLE" : "IMPOSSIBLE"

Measured memory_bytes: 9868
N,K = map(int,input().split())

a = 0
for i in range(1,N+1):
    if i % K == 0:
        a += 1

if K % 2 == 0:
    b = 0
    for i in range(1,N+1):
        if i % K == (K/2):
            b += 1
    print(a**3 + b**3)
else:
    print(a**3)


Measured memory_bytes: 3060
# inputを取得
N, A, B = map(int, input().split())

# メインの処理

# 繰り返される組の1組当たりの個数
t = A + B

# Nの中に何組あるか
kumi = N // t

# はみ出た個数
amari = N % t

# はみ出た青の数チェック
if amari >= A:
  amari_ao = A
else:
  amari_ao = amari

# 結果に応じてoutput
print(A * kumi + amari_ao)

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

int main() {
  string S;
  cin>>S;
  if(S.at(1)=='B'){
    cout<<"ARC"<<endl;
  }
  else{
    cout<<"ABC"<<endl;
  }
  
}

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

#define ll long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int MAX =510000;

ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    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;
    }
}
ll 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;
}

ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
int main() {
    //COMint();
    string alphabet;alphabet="abcdefghijklmnopqrstuvwxyz";
    vector<char> S;
    string s=in<string>();
    REP(i,s.size()){
        S.push_back(s[i]);
    }
    sort(S.begin(),S.end());
    int j;j=0;
    if(S[0]=='a'){
        for(int i=1;i<S.size();i++){
            if(S[i]!=alphabet[j]){
                j++;
                if(S[i]!=alphabet[j]){
                    print(alphabet[j]);
                    return 0;
                }
            }
            if(j==25){
                print("None");
                return 0;
            }
            if(i==S.size()-1){
                print(alphabet[j+1]);
                return 0;
            }
        }
    }else{
        print("a");
        return 0;
    }
    

}

Measured memory_bytes: 640
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int MAXN = 100010;

int main()
{

	string s;
	cin >> s;
	vector<char> q;
	int ans = 0;
	for (auto c : s)
	{
		if (!q.empty())
		{
			if (q.back() != c)
			{
				ans += 2;
				q.pop_back();
			}
			else
				q.push_back(c);
		}
		else
			q.push_back(c);
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
		int x, y;
		x = sc.nextInt();
		y = sc.nextInt();
		System.out.println(a[x] == a[y] ? "Yes" : "No");
	}
}



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

int main()
{
    string weather;
    cin >> weather;
    if (weather == "Sunny")
    {
        cout << "Cloudy" << endl;
    }
    else if (weather == "Cloudy")
    {
        cout << "Rainy" << endl;
    }
    else if (weather == "Rainy")
    {
        cout << "Sunny" << endl;
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String args[]) {
      Scanner read = new Scanner(System.in);
      String s = read.nextLine();
      if(s.equals ("Sunny")){
          System.out.println("Cloudy");
      }
      else if(s.equals( "Cloudy")){
          System.out.println("Rainy");
      }
      else{
          System.out.println("Sunny");
      }
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
// please, read the question correctly (do you need set or multiset)???
const int N=200010; //check the limits, dummy
int a[N];
int n, m;
int main(){
	int t;
		scanf("%d",&n);
		int x, y;
		vector<int> v1,v2;
		for(int i=0; i<n; ++i){
			cin>>x>>y;
			v1.push_back(x);
			v2.push_back(y);
		}
		bool l=0;
		for(int i=0; i+2<n; ++i){
			if(v1[i] == v2[i] && v1[i+1]==v2[i+1] && v1[i+2] == v2[i+2]){
				l=1;
				break;
			}
		}
		if(l){
			cout<<"Yes"<<endl;
		}
		else{
			cout<<"No"<<endl;
		}
}

Measured memory_bytes: 3684
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func gcd(x, y int) int {
	for y > 0 {
		x, y = y, x%y
	}
	return x
}

func main() {
	n, k := scanInt(), scanInt()
	g := scanInt()
	mx := g
	for i := 0; i < n-1; i++ {
		a := scanInt()
		mx = max(mx, a)
		g = gcd(g, a)
	}

	if k <= mx && k%g == 0 {
		fmt.Println("POSSIBLE")
	} else {
		fmt.Println("IMPOSSIBLE")
	}
}


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

int main() {
  int n,count;
  count=0;
  cin>>n;
  vector<int>vec(n);
  for(int i=0;i<n;i++){
    int l;
    cin>>l;
    vec.at(i)=l;
  }
  for(int i=0;i<n;i++){
    if(vec.at(i)%2==0){
      if(vec.at(i)%3!=0&&vec.at(i)%5!=0){
        count++;
      }
    }
  }
  if(count==0)cout<<"APPROVED"<<endl;
  else cout<<"DENIED"<<endl;
}


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

void printArr(int n, int arr[]) {
        for (int i = 0; i < n; ++i) cout << arr[i] << ", ";
        cout << "\n";
}

int main() {
        int N; cin >> N;
        int A[N];
        for (int i = 0; i < N; ++i) {
                cin >> A[i];
        }

        int L[N+1], R[N+1];
        L[0] = 0;
        for (int i = 1; i <=N; ++i) {
                L[i] = __gcd(L[i-1], A[i-1]);
        }
        R[N] = 0;
        for (int i = N; i >=0; --i) {
                R[i-1] = __gcd(R[i], A[i-1]);
        }
        // cout << "left" << "\n";
        // printArr(N+1, L);
        // cout << "Right" << "\n";
        // printArr(N+1, R);
        int maxGcd = 0;
        for (int i = 1; i <=N; ++i) {
                maxGcd = max(maxGcd, __gcd(L[i-1], R[i])); 
        }
        cout << maxGcd << "\n";
        return 0;
}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
const int MOD=1000000007;
const int INF=LLONG_MAX/2;

signed main() {cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    k=k*2+1;
    cout<<RUP(n,k)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[55],p[55];
ll ans(ll i,ll nowx){
	if(nowx<=1){
		if(i==0)return 1;
		else return 0;
	}
	if(nowx<=a[i-1]+1)return ans(i-1,nowx-1);
	if(nowx==a[i-1]+2)return p[i-1]+1;
	if(nowx<=2*a[i-1]+2)return p[i-1]+1+ans(i-1,nowx-a[i-1]-2);
	return p[i];
}
int main(){
	ll n,x;
	cin>>n>>x;
	a[0]=p[0]=1;
	for(int i=1;i<=n;i++){
		a[i]=2*a[i-1]+3;
		p[i]=2*p[i-1]+1;
	}
	cout<<ans(n,x);
	return 0;
}


Measured memory_bytes: 3608
// Created by new_sm
//
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
	si s;
	int x;
	cin>>x;
	s.insert(x);
	cin>>x;
	s.insert(x);
	cin>>x;
	s.insert(x);
	if(size(s)==2)
		cout<<"Yes";
	else
		cout<<"No";
}
int main()
{
//code
	
fastio	
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


Measured memory_bytes: 3580
import Data.Functor( (<$>))
import Data.Map.Strict( fromListWith, findWithDefault)
import Data.List( unfoldr, intercalate)
import Control.Monad( replicateM)


main = do
    n <- read <$> getLine
    infos <- replicateM n $ (read <$>) . words <$> getLine
    let
	mp = fromListWith (+) $	t <$> infos
	  where
	    t [b,f,r,v] = ((b,f,r),v)

	queries = [(b,f,r) | b<-[1..4], f<-[1..3], r<-[1..10]]

	ansRawData::[Int]
	ansRawData = (\r-> findWithDefault 0 r mp) <$> queries

	sausage size list = unfoldr pack list
	  where
	    pack [] = Nothing
	    pack minced_meat = Just $ splitAt size minced_meat

	buildings = sausage 3 $
			((' ':) . unwords . (show <$>)) <$>
							    sausage 10 ansRawData

    putStrLn `mapM_` intercalate [replicate 20 '#'] buildings



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

int main() {
  int k, s, o = 0;
  cin >> k >> s;
  for(int i = 0; i <= k; i++)
    for(int j = 0; j <= k; j++)
      if(0 <= s - i - j && s - i - j <= k)
        o++;
  cout << o << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("%s = %d\n", #x, x)
#define debug2(x, y) printf("%s = %d, %s = %d\n", #x, x, #y, y)
#define debug3(x, y, z) printf("%s = %d, %s = %d, %s = %d\n", #x, x, #y, y, #z, z)
#define debug4(x, y, z, t) printf("%s = %d, %s = %d, %s = %d, %s = %d\n", #x, x, #y, y, #z, z, #t, t)
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

const int MAXN = 100005;

int n, k, q, x, A[MAXN];

int main() {
    scanf("%d%d%d", &n, &k, &q);

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

    for (int i = 0; i < n; i++) {
        if (k - q + A[i] > 0) {
            printf("Yes\n");
        } else {
            printf("No\n");
        }
    }
    return 0;
}

Measured memory_bytes: 896
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    long N =sc.nextLong();
    long K =sc.nextLong();
    long C =N%K;
    long D =K/2;
    if(C<=K/2){System.out.println(C);}
    else{System.out.println(K-C);}
  }
}


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

#define int long long

signed main() {
	int n; cin >> n;
//	vector<int> v;
	double ans = 0;
	double p = 1;
	for(int i = 0; i < n; i++) {
		double x; cin >> x;
		ans += (p/x);
//		v.push_back(x);
	}
	cout << (p/ans) << endl;
	return 0;
}

Measured memory_bytes: 256
from itertools import product as p

n,k=map(int,input().split())
e={i for i in range(10)}
d=e^set(map(int,input().split()))
f=lambda x:int("".join(map(str,x)))
g=lambda x:x>=n
h=sorted(filter(g,map(f,p(d,repeat=len(str(n))))))
if h:
  print(h[0])
else:
  h=sorted(filter(g,map(f,p(d,repeat=len(str(n))+1))))
  print(h[0])

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

namespace attocoda
{
    class Program
    {
        static void Main(string[] args)
        {
            int x,a;
            var word = Console.ReadLine().Split(' ');
            x = int.Parse(word[0]);
            a = int.Parse(word[1]);
            if (x < a)
                Console.WriteLine(0);
            else
                Console.WriteLine(10);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#include <bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;
using P = pair<int, int>;


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	rep(i, 10) {
		c = c * a - b;
		cout << c << endl;
	}
	return 0;
}

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

int main() {
  int N,D;  
  cin >> N >> D;
  int ans;
  int x = D*2+1;
  int a = N/x;
  int b = N%x;
  if(b==0){
    ans = a;
  } else {
    ans = a+1;
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
const int INF = 1<<28;

int main() {
	string s1, s2; cin >> s1 >> s2;
	int dp[1001][1001] = {};
	REP(i, s1.size()+1) dp[i][0] = i;
	REP(i, s2.size()+1) dp[0][i] = i;

	FOR(i, 1, s1.size()+1) FOR(j, 1, s2.size()+1) {
		int cost = !(s1[i-1] == s2[j-1]);
		dp[i][j] = min(dp[i][j-1] + 1, min(dp[i-1][j] + 1, dp[i-1][j-1] + cost));
	}
	cout << dp[s1.size()][s2.size()] << endl;
	return 0;
}

Measured memory_bytes: 5112
#include<stdio.h>

int main(){
	
	int a,b,i,j,aa,c,k,flagg,ans;
	int mem[100][100];
	int flag[100];
	
	while(1){
	
	
	
	ans=0;
	for(i=0;i<100;i++){
		for(j=0;j<100;j++){
			mem[i][j] = 0;
			flag[i] = 0;
		}
	}
	
	scanf("%d",&a);
	if(a==0) break;
	
	for(i=0;i<a;i++){
		
		flag[i]=1;
		
		scanf("%d",&b);
		
		for(j=0;j<b;j++){
			
			scanf("%d" ,&mem[i][j]);
			
		}
		
	}
	
//	printf("check");
	
	scanf("%d" , &aa);
	
	for(k=0;k<aa;k++){
		
//		printf("%d周目",k);
		
		scanf("%d",&c);
		
		for(i=0;i<100;i++){
			
			flagg = 1;
			
			for(j=0;j<100;j++){
			
				if(mem[i][j] == c){	
				 flagg = 0 ;
				}
				
			}
			
			if(flagg ==1)flag[i]=0;
			
		}
		
		
		
	}
	
	for(i=0;i<a;i++){
		if(flag[i]==1){
			
			if(ans==0)ans=i+1;
			
			else {
				ans=-1;
				break;
			}
			
		}
		
	}
	
	if(ans==0) ans=-1;
	
	
	printf("%d\n",ans);
		
		
		
		
	}
		
	
	return 0;
	
}

Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <utility>

using namespace std;

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

int main()
{
	int a[11];
	REP(i, 10) cin >> a[i];
	sort(a, a+10);
	cout << a[9] << endl << a[8] << endl << a[7] << endl;
	return 0;
}

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

#define ll long long
#define vi vector<int>
#define vc vector<char>
#define vt vector<string>
#define si set<int>
#define sc set<char>
#define st set<string>
#define pii pair<int,int>
#define fi first
#define se second
#define pb pushback;

using namespace std;
int main()
{
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        int tmp=0;
        int tmp2=i;
        while(tmp2)
        {
            tmp2/=10;
            tmp++;
        }
        if(tmp&1)ans++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
class aoj
{
    static void Main()
    {
        int a = int.Parse(Console.ReadLine());
        int[] b = new int[a];
        for (int i = 0; i < a*(a-1)/2; i++)
        {
            int[] c = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            if (c[2] < c[3])
                b[c[1] - 1] += 3;
            else if (c[2] > c[3])
                b[c[0] - 1] += 3;
            else
            {
                b[c[0] - 1] += 1;
                b[c[1] - 1] += 1;
            }
        }
        int d = 0, e = 1, k = 0; 
        bool[] f = new bool[a];
        int[] g = new int[a];
        while(true)
        {
            int h = 0;
            d = 0;
            for (int i = 0; i < a; i++)
            {
                if (b[i] > d&&f[i]==false)
                    d = b[i];
            }
            for(int i = 0; i < a; i++)
            {
                if (b[i] >= d && f[i] == false)
                {
                    h++;
                    f[i] = true;
                    g[i] = e;k++;
                }
            }
            e += h;
            if (k == a) break;
        }
        foreach (int i in g)
            Console.WriteLine(i);
    }
}

Measured memory_bytes: 9520
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,K,S = map(int,read().split())

if S > N:
    A = [S] * K + [1] * (N-K)
else:
    A = [S] * K + [S+1] * (N-K)

print(*A)


Measured memory_bytes: 6500
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
// #pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

bool solve(){
  ll h,w;cin>>h>>w;
  ll ans=((h+1)/2)*((w+1)/2);
  ans+=(h/2)*(w/2);
  if(h==1)cout<<1<<endl;
  else if(w==1)cout<<1<<endl;
  else cout<<(h*w+1)/2<<endl;
  // if(sum%2)cout<<"Yes"<<endl;
  // else cout<<"No"<<endl;
  return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
  // ll Q;cin>>Q;
	// while(Q--)solve();
  solve();
}


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

int N, K, L;
int par[2][200010];

int root(int idx, int x) {
  return par[idx][x] == x ? x : par[idx][x] = root(idx, par[idx][x]);
}

void merge(int idx, int x, int y) {
  x = root(idx, x);
  y = root(idx, y);
  if (x == y) return;
  par[idx][y] = x;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> K >> L;
  for (int i = 0; i < N; i++) {
    par[0][i] = par[1][i] = i;
  }
  for (int i = 0; i < K; i++) {
    int p, q;
    cin >> p >> q;
    p--, q--;
    merge(0, p, q);
  }
  for (int i = 0; i < L; i++) {
    int r, s;
    cin >> r >> s;
    r--, s--;
    merge(1, r, s);
  }
  map<pii, int> mp;
  for (int i = 0; i < N; i++) {
    mp[pii(root(0, i), root(1, i))]++;
  }
  for (int i = 0; i < N; i++) {
    cout << mp[pii(root(0, i), root(1, i))] << " \n"[i + 1 == N];
  }

  return 0;
}

Measured memory_bytes: 13568
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vii;
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()

const ll INF = 1e18;
const int N = 101;
const int V = 1e5 + 1;
int n, w;
int wt[N], vl[N];
ll dp[N][V];

void min_self(ll &a, ll b) {
	a = min(a, b);
}

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n, w;
	scanf("%d%d", &n, &w);
	for (int i = 1; i <= n; i++) scanf("%d%d", &wt[i], &vl[i]);

	for (int i = 0; i <= n; i++)
		for (int j = 1; j < V; j++)
			dp[i][j] = INF;

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < V; j++) {
			min_self(dp[i][j], dp[i-1][j]);
			if (j >= vl[i]) min_self(dp[i][j], dp[i-1][j-vl[i]] + wt[i]);
		}
	}

	/*
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= 30; j++) printf("%lld ", dp[i][j]==INF? -1 : dp[i][j]);
		puts("");
	}
	*/
	int ans = 0;
	for (int i = 0; i < V; i++)
		if (dp[n][i] <= w) ans = i;
	printf("%d\n", ans);
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define int long long
#define double long double
#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,sse")
using namespace std;

int n;
vector<int> x(n);
vector<int> y(n);
vector<char> c(n);

double calc(double steps) {
    double ax = 1e15;
    double bx = -1e15;
    double ay = 1e15;
    double by = -1e15;
    for (int i = 0; i < n; i++) {
        double X = x[i];
        double Y = y[i];
        if (c[i] == 'L') X -= steps;
        if (c[i] == 'R') X += steps;
        if (c[i] == 'D') Y -= steps;
        if (c[i] == 'U') Y += steps;
        ax = min(ax, X);
        bx = max(bx, X);
        ay = min(ay, Y);
        by = max(by, Y);
    }
    return (by - ay) * (bx - ax);
}

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

    cin >> n;
    x.resize(n);
    y.resize(n);
    c.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i] >> y[i] >> c[i];
    }
    int s = 0;
    int e = 2e8;
    while (e - s > 5) {
        int a = (s * 2 + e) / 3;
        int b = (s + e * 2) / 3;
        double fa = calc(a);
        double fb = calc(b);
        if (fa <= fb) {
            e = b;
        } else {
            s = a;
        }
    }
    double res = LLONG_MAX;
    for (double i = s; i <= e; i += 0.5) {
        res = min(res, calc(i));
    }
    cout << fixed << setprecision(3) << res << '\n';

    fflush(stdout);
    return 0;
}


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

class MainClass
{
    public static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int N = int.Parse(s[0]);
        int Y = int.Parse(s[1]);

        List<int> list = new List<int>();

        for (int i = 0; i <= N;i++)
        {
            for (int j = 0; j <= N;j++)
            {
                if (i + j > N) break;
                int k = N - i - j;

                if(i * 10000 + j * 5000 + k * 1000 == Y)
                {
                    Console.WriteLine("{0} {1} {2}",i,j,k);
                    return;
                }
            }
        }


        Console.WriteLine("-1 -1 -1");
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
#define dup(x,y) (((x)+(y)-1)/(y))
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const int INTMAX = 2147483647;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    int n,m,q;cin >> n >> m >> q;
    vl s(n+2), t(m+2), x(q);
    s[0] = -LINF, t[0] = -LINF;
    s[n+1] = LINF, t[m+1] = LINF;
    rep(i,n) cin >> s[i+1];
    rep(i,m) cin >> t[i+1];
    rep(i,q) cin >> x[i];

    for(auto& r : x){
        ll ans = LINF;
        int ns[2], nt[2];
        ns[0] = lower_bound(s.begin(),s.end(),r) - s.begin();
        nt[0] = lower_bound(t.begin(),t.end(),r) - t.begin();
        ns[1] = ns[0] -1;
        nt[1] = nt[0] -1;

        rep(i,2) rep(j,2){
            chmin(ans, abs(r - s[ns[i]]) + abs(s[ns[i]] - t[nt[j]]));
        }

        rep(j,2) rep(i,2){
            chmin(ans, abs(r - t[nt[j]]) + abs(t[nt[j]] - s[ns[i]]));
        }
        cerr << "ans is ";
        cout << ans << endl;
    }
}

Measured memory_bytes: 3712
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<algorithm>
#include<iterator>
#include<sstream>
#include<iomanip>
#include<map>
#include<queue>
#include<deque>
#include<fstream>
#include<random>

#define rep(i, n) for (ll i = 0; i < n; i++) 
#define rrep(i, n) for(ll i = n-1; i>=0; i--)
#define range(i, n, m) for (ll i = n; i < m; i++) 
#define rrange(i, n, m) for (ll i = n - 1; i => m; i--) 
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vp vector<pair<ll, ll> >
#define vvp vector<vector<pair<ll, ll> > >
#define First first
#define Second second.first
#define Third second.second
#define Sort(X) sort(X.begin(), X.end())
#define RSort(X, T) sort(X.begin(), X.end(), greater<T>())
//#define MOD 998244353
#define MAX 100000

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

template<class T> inline bool chmax(T & a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T & a, T b) { if (a > b) { a = b; return true; } return false; }

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

	string S, T;
	cin >> S >> T;

	ll cnt = 0;
	rep(i, 3) {
		if (S[i] == T[i])cnt++;
	}

	cout << cnt << endl;


	return 0;
}



Measured memory_bytes: 764
#include <stdio.h>
int main(void){
  int n,k,t=1;
  scanf("%d%d",&n,&k);
  while (t<k&&n>0){
    t*=2;
    n--;
  }
  while (n>0){
    t+=k;
    n--;
  }
  printf("%d\n",t);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, n) for(int i = 1; i <= (int)(n); i++)
const long long INF = 1LL << 60;
const double PI=3.14159265358979323846;
int main() 
{
    int x,y,z;
    cin >> x >> y >> z;

    if(x==y && y==z){
        cout << "No" << endl;
    }else if(x!=y && y!=z && z!=x){
        cout << "No" <<endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define ii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
#define output(x) for (auto a:x) cout<<a<<" ";cout<<endl;
#define output2(x) for (auto a:x) cout<<a.fi<<" "<<a.se<<endl;
#define PI 3.14159265

// DEBUG TEMPLATE
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
  *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
  
// DEBUG TEMPLATE ENDS

#define MOD 1000000007
int power(int x,int y,int mod = MOD) 
{ 
  int ret = 1;
  x = x % mod;
  while (y){
    if(y&1) ret = (ret*x)%mod;
    y = y>>1;
    x = (x*x)%mod;
    } 
    return ret%mod; 
}

void solve()
{ 
  string inp;
  cin>>inp;
  int ans = 0;
  char prev = '#';
  for (auto &x:inp){
    if (x == 'D') ans++;
    if (x == 'D' and prev == 'P') ans++;
    if (x == '?') prev = 'D',ans++ , x = 'D';
    else prev = x; 
  }
  cout<<inp<<endl;
  // cout<<ans<<endl;

}

signed main(){
  // int t;
  // cin>>t;
  // while (t--)
  solve();
}
// Check MOD values plox :(



Measured memory_bytes: 3756
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n, m;
vector<int> res;
void divisor(int a) {
  for(int i=1; i*i<=a; i++) {
    if(a % i == 0) {
      res.push_back(i);
      if(i != a / i) res.push_back(a / i);
    }
  }
}

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

  cin >> n >> m;
  divisor(m);

  int ans = 1;
  REP(i, res.size()) {
    if(m / res[i] >= n) ans = max(ans, res[i]);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll INF = 1'000'000'000'000'000'000;
namespace utils{
#define ALL(x) begin(x), end(x)
#define RALL(x) rbegin(x), rend(x)
    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool up_min(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool up_max(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }

    ll operator"" _64(unsigned long long x){ return ll(x); }
    ull operator"" _64u(unsigned long long x){ return ull(x); }

    template<class T>
    vector<T> make_mdvector(int n, T t){
        return vector<T>(n, t);
    }
    template<class ...Ts>
    auto make_mdvector(int n, Ts ... ts){
        return vector<decltype(make_mdvector(ts...))>(n, make_mdvector(ts...));
    }

    inline ll bit(int x){
        return 1ll << x;
    }

    template<class T>
    istream& operator>>(istream& is, vector<T>& v){
        for (auto &&x : v) { is >> x; } return is;
    }

    template<class T>
    ostream& operator<<(ostream& os, const vector<T>& v){
        for (auto &&x : v) { os << x << ' '; } cout << endl; return os ;
    }
}
using namespace utils;

class solver{
    istream& is;
    ostream& os;

public:
    solver(istream& I, ostream& O) :is(I), os(O) {}
    ll N;
    void run();
};

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef XELMH
    string test_cases = "test_A.txt";
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int loop = 0;
    while(fs) {
        loop++;
        cout << '#' << loop << "#------\n";
        solver(fs, cout).run();
    }
    if(loop <= 1) {
        cout << "===" << endl;
        while(cin) solver(cin, cout).run();
    }
#else
    solver(cin, cout).run();
#endif
    return 0;
}


void solver::run(){
    is >> N;
    if(!is) return;
    ll ans = 0;
    for (int i = 1; i <= N / 2; ++i) {
        if(i != N-i) ans++;
    } // end i
    os << ans << endl;
}


Measured memory_bytes: 256
from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))

d = defaultdict(int)
s = 0
d[0] += 1
for i in range(N):
	s += A[i]
	d[s] += 1

ans = 0
for key in d:
	if d[key] <= 1:
		pass
	else:
		ans += int(d[key] * (d[key] - 1) / 2)

print(ans)


Measured memory_bytes: 39276
#include <bits/stdc++.h>
using namespace std;
int par[1410]; 
int depth[1410]; 
int size[1410] = {}; 
bool seen[1410] = {}; 
int cnt[1410] = {}; 
int N, M; 
void init(){
	for(int i = 0; i < N * 2; i++){
		par[i] = i; depth[i] = 0; size[i] = 1; 
	}
}
int find(int x){
	if(par[x] == x){
		return x;
	}
	else{
		return par[x] = find(par[x]); 
	}
}
void unite(int x, int y){
	x = find(x); 
	y = find(y); 
	if(x == y) return;
	else if(depth[x] < depth[y]){
		par[x] = y; 
		size[y] += size[x]; 
	}else{
		par[y] = x; 
		size[x] += size[y];  
		if(depth[x] == depth[y]) depth[x] ++; 
	}
}
bool same(int x, int y){
	return find(x) == find(y); 
}
int siz(int x){
	return size[find(x)]; 
}
int main(){
	cin >> N >> M; init(); 
	bool A[710][710] = {}; 
	bool checked[1410] = {}; 
	for(int i = 0; i < M; i++){
		int a, b; cin >> a >> b; 
		a--; b--; 
		A[a][b] = true; A[b][a] = true;
	}
	for(int i = 0; i < N; i++){
		for(int j = i+1; j < N; j++){
			if(!A[i][j]){
				unite(i, N + j); unite(j, N + i); 
			}
		}
	}
	for(int i = 0; i < N; i++){
		if(find(i) == find(N + i)){
			cout << -1 << endl; return 0; 
		}
	}
	int freq[1410] = {};  
	for(int i = 0; i < N; i++){
		freq[find(i)] ++; 
	}
	vector<int> S; 
	vector<int> T; 
	for(int i = 0; i < N; i++){
		if(checked[find(i)]) continue; 
		S.push_back(freq[find(i)]);
		T.push_back(freq[find(N+i)]); 
		checked[find(i)] = true; 
		checked[find(N+i)] = true; 
	}
	bool dp[710][710] = {}; 
	dp[0][0] = true;
	for(int i = 0; i < S.size(); i++){
		for(int j = 0; j <= N; j++){
			if(dp[i][j]){
				dp[i+1][j+S.at(i)] = true; 
				dp[i+1][j+T.at(i)] = true; 
			}
		}
	}
	int ans = 1145141919; 
	for(int i = 0; i <= N; i++){
		if(dp[S.size()][i]) ans = min(ans, i*(i-1)/2 + (N-i)*(N-i-1)/2); 
	}
	cout << ans << endl;
}

Measured memory_bytes: 1280
let () =
  let s = read_line () in
  let t = read_line () in
  Printf.printf "%d\n" @@
  Array.fold_left min max_int @@
  Array.init (String.length s - String.length t + 1) @@ fun i ->
    Array.fold_left ( + ) 0 @@
    Array.init (String.length t) @@ fun j ->
      if s.[i + j] = t.[j] then 0 else 1



Measured memory_bytes: 5684
N,K = map(int,input().split())
V = list(map(int,input().split()))
KK = K
K = min(N,K)

ans = 0
for k in range(1,K+1):
    for i in range(k+1):
        R = V[-(k-i):]
        if len(R) == N:
            R = []
        # print(R)
        L = V[:i]+R+[0]
        L.sort()
        zero_index = min(L.index(0),KK-k)
        res = sum(L[zero_index:])
        ans = max(ans,res)
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
	int data[4],time=0;
	int x,y;
	for(x=0; x<4; x++)
	{
		scanf("%d",&data[x]);
		time += data[x];
	}
	printf("%d\n%d\n",time/60,time%60);
	return 0;
}

Measured memory_bytes: 596