akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>

#define Inf 0x7fffffff

using namespace std;

const int Maxn = 40;
const int Maxm = 510;
int n , c;
int a[Maxm][Maxm];
int d[Maxn][Maxn];
int f[Maxn][Maxn];
int dp[Maxn][Maxn];

int main() {
	
	cin >> n >> c;
	for(register int i=1; i<=c; i++)
		for(register int j=1; j<=c; j++)
			scanf("%d",&d[i][j]);
	for(register int i=1; i<=n; i++)
		for(register int j=1; j<=n; j++)
			scanf("%d",&a[i][j]);
	
	for(register int i=1; i<=c; i++)
		for(register int j=1; j<=c; j++)
			f[i][j] = Inf;
	for(register int k=1; k<=c; k++)
		for(register int i=1; i<=c; i++)
			for(register int j=1; j<=c; j++)
				if(i!=k && i!=j && j!=k)
					f[i][j] = min(f[i][j],f[i][k]+f[k][j]);
	
	for(register int k=1; k<=c; k++)
		for(register int i=1; i<=n; i++)
			for(register int j=1; j<=n; j++)
				if(((i+j)%3) == 0)
					dp[0][k] += d[a[i][j]][k];
	
	for(register int k=1; k<=c; k++)
		for(register int i=1; i<=n; i++)
			for(register int j=1; j<=n; j++)
				if(((i+j)%3) == 1)
					dp[1][k] += d[a[i][j]][k];
	
	for(register int k=1; k<=c; k++)
		for(register int i=1; i<=n; i++)
			for(register int j=1; j<=n; j++)
				if(((i+j)%3) == 2)
					dp[2][k] += d[a[i][j]][k];
	
	register int minl = Inf;
	for(register int i=1; i<=c; i++)
		for(register int j=1; j<=c; j++)
			for(register int k=1; k<=c; k++)
				if(i!=j && i!=k && k!=j)
					minl = min(minl,dp[0][i]+dp[1][j]+dp[2][k]);
	
	cout << minl << endl;
	
	return 0;
	
}

Measured memory_bytes: 1280
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<fstream>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
double n;
int main(){
	scanf("%lf",&n);
	if(sqrt(n)==(int)sqrt(n))printf("%.0lf",n);
	else{
		printf("%d",((int)sqrt(n))*((int)sqrt(n)));
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <cstring>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
typedef long long ll;
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}
struct edge {
    ll to,cost;
};

/*
const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_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;
    }
}
long long COM(int n,int k){
    if(n < k || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
*/

int main(){
    int N; cin >> N;
    vector<pair<ll,ll> > p(N);
    for (int i = 0; i < N; i++){
        cin >> p[i].second >> p[i].first;
    }
    ll t = 0;
    sort(p.begin(),p.end());
    for (int i = 0; i < N; i++){
        t += p[i].second;
        if (t > p[i].first){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

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

const int MAXN = 1e5 + 10;
vector<int> Mat[MAXN];
int n, k, ans;

int dfs(int v, int p) {
	int t = 1;
	for (int i = 0; i < Mat[v].size(); i++)
		t = max(t, dfs(Mat[v][i], v) + 1);
	if (t == k && p != 1) {
		ans++;
		return 0;
	}
	return t;
}

int main() {
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		int a;
		cin >> a;
		ans += (i == 1 && a != 1);
		if (i != 1)
			Mat[a].push_back(i);
	}
	dfs(1, 1);
	cout << ans;
}

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

#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long

#define pi pair < ll , ll >
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";
using namespace std;

int main()
{
	fastIO;
	ll n, ans=0, r=0, b=0;
	string s;
	cin>>n>>s;
	for(auto c:s){if(c=='R')r++;else b++;}
	if(r>b)cout<<"Yes";else cout<<"No";
}

	

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

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

#if DEBUG_ON
    freopen("input", "r", stdin);
#endif

    std::vector<int> nums;
    for (int i = 0; i < 3; ++i) {
        int a;
        std::cin >> a;
        bool add = true;
        for (int num : nums) {
            if (num == a) {
                add = false;
                break;
            }
        }
        if (add) {
            nums.push_back(a);
        }
    }
    std::cout << nums.size() << '\n';
    return 0;
}

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

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

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

A    = set([int(input()) for _ in range(M)])

dp = [0]*(N+3)



for i in range(N+1):

    if i==0:
        if not (i+1) in A:
            dp[i+1] = 1 + dp[i]
        if not (i+2) in A:
            dp[i+2] = 1 + dp[i]
        continue 
    if not i+1 in A:
        dp[i+1] = dp[i] + dp[i+1]
    if not i+2 in A:
        dp[i+2] = dp[i] + dp[i+2]

print(dp[N]%(1000000007))

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

int N, T;
int c[101];
int t[101];

int main() {
    cin >> N >> T;
    for (int i = 0; i < N; i++) {
        cin >> c[i] >> t[i];
    }
    bool can = 0;
    int cost = 1000;
    for (int i = 0; i < N; i++) {
        if (t[i] <= T && c[i] <= cost) {
            cost = c[i];
            can = 1;
        }
    }
    if (can) {
        cout << cost << endl;
    }
    else {
        cout << "TLE" << endl;
    }
}


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

#define REP(i, s, n) for(int i = s; i < n; ++i)
#define rep(i, n)		 REP(i, 0, n)
#define SORT(c)			 sort((c).begin(), (c).end())
#define IINF	INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

typedef long long				ll;
typedef pair <int, int> ii;

int main() {
	string str;
	cin >> str;
	int		 x, y;
	cin >> x >> y;

	int	 s	 = 0, t = 0;
	bool f	 = true;
	bool fx	 = true;
	vector <ll> xx, yy;
	int	 tmp = 0;
	rep(i, str.size()) {
		if(f && str[i] == 'F') s++;
		else {
			if(str[i] == 'F') tmp++;
			else {
				if(!f && tmp != 0) (fx ? xx : yy).push_back(tmp);
				tmp = 0;
				fx	= !fx;
			}
			f = false;
		}
	}
	if(tmp != 0) (fx ? xx : yy).push_back(tmp);

	//cout << "s" << s << "\tt" << t << endl;
	//rep(i, xx.size()) cout << xx[i] << endl;
	//cout << endl;
	//rep(i, yy.size()) cout << yy[i] << endl;

	set<ll> stx, sty;
	stx.insert(s);
	sty.insert(t);

	rep(i, xx.size()){
		set<ll> stmp;
		for(auto it : stx){
			stmp.insert(it + xx[i]);
			stmp.insert(it - xx[i]);
		}
		stx = stmp;
	}
	rep(i, yy.size()){
		set<ll> stmp;
		for(auto it : sty){
			stmp.insert(it + yy[i]);
			stmp.insert(it - yy[i]);
		}
		sty = stmp;
	}

	if(stx.find(x) != stx.end() && sty.find(y) != sty.end()) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 768
#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 - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main(){
	ll a, b;
    cin >> a >> b;
    ll ans = max(2 * a - 1, max(2 * b - 1, a + b));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

v = []
for line in sys.stdin:
  v.append([int(l) for l in line.split()])

m = np.array(v[1])

while len(m) != 1:
  min_m = np.min(m)
  arg_min_m = np.argmin(m)
  for idx, i in enumerate(m):
    if idx != arg_min_m:
      m[idx] %= min_m
  m = m[m!=0]
print(m[0])


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

using namespace std;

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

	for (int i = 0; i < len; i++) {
		result += s[i];
		result += t[i];
	}
	cout << result << endl;

	return 0;
}

Measured memory_bytes: 256
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
int N,A[9];
int main() {

	for(int j=0;j<5;j++){
		cin>>N;
		for(int i=0;i<9;i++){
			cin>>A[i];
			N-=A[i];
		}
		cout<<N<<endl;

	}

	return 0;
}

Measured memory_bytes: 2952
#include <bits/stdc++.h>
using namespace std;
int N,M,K;
int main()
{
	cin>>N>>M>>K;
	int Ans=N;
	for (int a=0;a<=N;++a)
		for (int b=0;b<=M;++b)
			if (a*M+b*N-a*b>=K)
				Ans=min(Ans,a+b);
	cout<<Ans<<endl;
	return 0;
}

Measured memory_bytes: 256
def is_ACGT(c):
    return c == "A" or c == "C" or c == "G" or c == "T"

S = input()

ans = 0
for i in range(len(S)):
    j = 0
    while i+j < len(S) and is_ACGT(S[i+j]):
        j += 1
    ans = max(ans, j)

print(ans)


Measured memory_bytes: 9108
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	list := getStdinIntArr()
	A := list[0]
	B := list[1]
	H := list[2]
	M := list[3]

	aPosM := 60*H + M          // 0～720
	bPosM := M                 // 0～60
	bPosM = bPosM * (720 / 60) // 0～720

	if aPosM == bPosM {
		ans := math.Abs(float64(A) - float64(B))
		fmt.Printf("%.19f", ans)
	} else {
		AFloat := float64(A)
		BFloat := float64(B)
		aPosRad := 2.0 * math.Pi * float64(aPosM) / 720.0
		bPosRad := 2.0 * math.Pi * float64(bPosM) / 720.0
		rad := math.Abs(aPosRad - bPosRad)
		ans := AFloat*AFloat + BFloat*BFloat - 2.0*AFloat*BFloat*math.Cos(rad)
		ans = math.Sqrt(ans)
		fmt.Printf("%.19f", ans)
	}

	fmt.Printf("\n")
}

func getStdin() string {
	sc.Scan()
	return sc.Text()
}
func getStdinInt() int {
	sc.Scan()
	rtn, _ := strconv.Atoi(sc.Text())
	return rtn
}
func getStdinIntArr() []int {
	sc.Scan()
	str := sc.Text()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}


Measured memory_bytes: 1728
import sys
input = sys.stdin.readline
a, b, c, d = map(int, input().split())
t = -float("inf")
if 0 in range(a, b + 1) or (0 in range(c, d + 1)): t = 0
print(max(a * c, b * d, a * d, b * c, t))

Measured memory_bytes: 61796
#include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

int main(){
	while(cin>>L&&L){
		int ans=1;
		for(ll i=2;i*i<=L;i++){
			int n=0;
			while(!(L%i)){
				n++;
				L/=i;
			}
			ans*=2*n+1;
		}
		if(L!=1)ans*=3;
		cout<<ans/2+1<<endl;
	}
}

Measured memory_bytes: 868
#include<bits/stdc++.h>
using namespace std;
const int md=1e9+7;
char s[3][65];
long long ans=1;
int pre=0,n;
int main()
{
	scanf("%d",&n);
	scanf("%s",s[1]+1);
	scanf("%s",s[2]+1);
	
	int p=1;
	while(p<=n)
	{
		if(p<n&&s[1][p]==s[1][p+1])
		{
			if(p==1) ans=ans*6%md;
			else if(pre==2) ans=ans*2%md;
			else ans=ans*3%md;
			pre=1;
			
		}
		else if(s[1][p]==s[2][p])
		{
			if(p==1) ans=ans*3%md;
			else 
			{
				if(pre==2) ans=ans*2%md;
			}
			pre=2;
		}
		if(s[1][p]==s[2][p]) p++;
		else p+=2;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  int a,b,c;
  cin >> a;
  cin >> b;
  cin >> c;
  if(a + b == c){
  cout << "Yes" << endl;
  }
  else if(b + c == a){
  cout << "Yes" << endl;
  }
  else if(a + c == b){
  cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }
  }

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int ch(int a,int b,int c)
{
	return abs(b-a)+abs(c-b);
}

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	printf("%d\n",min(ch(a,b,c),min(ch(a,c,b),min(ch(b,a,c),min(ch(b,c,a),min(ch(c,a,b),ch(c,b,a)))))));
}


Measured memory_bytes: 256
package main

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

func main() {

	// 繰り返し回数
	N, _ := strconv.Atoi(readLine())

	//words := strings.Fields(readLine())

	intWords := make([]int, 0, 99999)
	for i := 0; i < N; {
		intWord, _ := strconv.Atoi(readLine())
		intWords = append(intWords, intWord)
		i++
	}

	//fmt.Println(reduce(intWords))

	// スパン
	span_g := getspan(N)

	fmt.Println(len(span_g))
	fmt.Println(reduce(span_g))

	cnt := 0

	for _, g := range span_g {

		/**
		選択そーと
		 */
		//for index := 0; index < N; {
		for index := g; index < N; {

			// ソート済みエリアで入れ替え
			for indexInSorted := index; indexInSorted-g >= 0 && intWords[indexInSorted-g] > intWords[indexInSorted]; {
				// 交換
				temp := intWords[indexInSorted-g]
				intWords[indexInSorted-g] = intWords[indexInSorted]
				intWords[indexInSorted] = temp

				// カウント
				cnt++
				indexInSorted -= g
			}
			// 1ずつ増やしていく。
			index++
		}
	}

	fmt.Println(cnt)

	for _, value := range intWords {
		fmt.Println(value)
	}
	return
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000)

func readLine() string {
	buf := make([]byte, 0, 100)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func reduce(numArray []int) string {
	reducedString := ""
	for _, num := range numArray {
		reducedString += " " + strconv.FormatInt(int64(num), 10)
	}
	return strings.Trim(reducedString, " ")
}

func getspan(N int) []int {
	var spans []int

	for span := 1; span <= N; {

		spans = append([]int{span}, spans...)
		span = 3*span + 1
	}

	return spans
}



Measured memory_bytes: 32528
import sys
input = sys.stdin.readline
  
def solve():
  n = int(input())
  maxi = -10
  maxi2 = -10
  place = -1
  for i in range(n):
    a = int(input())
    if a>maxi:
      maxi2 = maxi
      maxi = a
      place = i
    else:
      maxi2 = max(maxi2,a)
  for j in range(n):
    if place == j:
      print(maxi2)
    else:
      print(maxi)
  
solve()

Measured memory_bytes: 51804
x1, y1, x2, y2 = map(int, input().split())

delta_x = x2 - x1
delta_y = y2 - y1

x3, y3 = x2 - delta_y, y2 + delta_x
x4, y4 = x1 - delta_y, y1 + delta_x

print(x3, y3, x4, y4)

Measured memory_bytes: 2940
/*
	written by Pankaj Kumar.
	country:-INDIA
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef set<pair<int,int>> spi;
typedef set<pair<ll,ll>> spl;
typedef vector<pair<int,int>> vpi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vpl;
typedef vector<string> vs;
typedef map<int,int>m;
typedef set<string> ss;
typedef set<int> si;
typedef set<ll> sl;
#define pan cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
// define values.
#define mod 1000000007;
#define phi 1.618
/* Bit-Stuff */
#define get_set_bits(a) (__builtin_popcount(a))
#define get_set_bitsll(a) ( __builtin_popcountll(a))
#define get_trail_zero(a) (__builtin_ctz(a))
#define get_lead_zero(a) (__builtin_clz(a))
#define get_parity(a) (__builtin_parity(a))
/*  Abbrevations  */
#define ff first
#define ss second
#define mp make_pair
#define line cout<<endl;
#define pb push_back
// function
ll power(ll x,ll y)
{
	ll res=1;
	while(y>0)
	{
		if(y%2==1)res*=x;
		y/=2; x*=x;
	}
	return res;
}
/* ascii value 
A=65,Z=90,a=97,z=122
*/
/*  ---------------------------------MAIN-------------------------------------------*/


int main()
{
	pan;
	int n,k,count=0;
	cin>>n>>k;
	vector<bool>v(n+1,false);
	for(int i=0;i<k;i++)
	{
		int size,no;
		cin>>size;
		for(int j=0;j<size;j++)
		{
			cin>>no;
			v[no]=true;
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(v[i]==false)
			count++;
	}
	cout<<count<<endl;
}

Measured memory_bytes: 3656
def main():
    length = int(input())
    word = input()
    count = {}
    for i in range(length):
        if word[i] in count:
            count[word[i]] += 1
        else:
            count[word[i]] = 2
    mod = 10 ** 9 + 7
    answer = 1
    for c in count.values():
        answer = (answer * c) % mod
    print(answer - 1)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3188
import sys

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

ans = 'Yes'

li.reverse()

for index, i in enumerate(li):
  if index + 1 > len(li) - 1:
    break

  if i < li[index+1]:
    li[index+1] -= 1

    if i < li[index+1]:
      print("No")
      sys.exit()

print("Yes")

Measured memory_bytes: 14396
import sys
input = sys.stdin.readline
def main():
    n,k = map(int,input().split())
    l = list(map(int,input().split()))
    roop = [1]
    stayed = [0]*n
    for i in range(n):
        next_city = l[roop[-1]-1]
        if stayed[next_city-1]:
            endindex = i
            for j,r in enumerate(roop):
                if r == next_city:
                    startindex = j
            break
        else:
            roop.append(next_city)
            stayed[next_city-1] = 1

    if k < startindex:
        print(roop[k])
    else:
        dis = endindex - startindex + 1
        a = (k - startindex) % dis
        print(roop[a + startindex])
main()

Measured memory_bytes: 31372
N, Y = map(int, input().split())
ans=[]
for i in range(N+1):
  for j in range(N+1-i):
    if Y-i*10000-j*5000==(N-i-j)*1000:
      ans.append([str(i), str(j), str(N-i-j)])
if not ans:
  print(-1, -1, -1)
else:
  print(' '.join(ans[0]))

Measured memory_bytes: 3064
import numpy as np
import itertools
N, M = map(int, input().split())
if M == 0:
  print(0)
else:
  data = []
  for i in range(N):
    data.append(list(map(int, input().split())))
  data = np.array(data, dtype='int64')

  results = []
  for op in itertools.product([-1, 1], repeat=3):
    vals = (data * op).sum(axis=1)
    vals.sort()
    results.append(vals[-M:].sum())

  print(max(results))

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

int main() {
    int a,b;
    cin>>a>>b;
    if(b%a==0){
        cout << b/a << endl;
        return 0;
    }
    for(int i=b/a+1;i>=1;--i){
        if(b%i==0){
            if(b/i>=a){
            cout << i << endl;
            return 0;
            }
        }
    }
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
using LL = long long;
using ULL = unsigned long long;


void solve() {
	int n; cin >> n;
	int a[100]; rep(i, n) cin >> a[i];

	int swaps = 0;
	for (int i = 0; i < n; i++) {
		int mIdx = i;
		for (int j = i; j < n; j++) {
			if (a[j] < a[mIdx]) mIdx = j;
		}
		if (i != mIdx) {
			swaps++;
			swap(a[i], a[mIdx]);
		}
	}

	rep(i, n) {
		if (i != 0) cout << " ";
		cout << a[i];
	} cout << endl;

	cout << swaps << endl;
}

int main() {

	solve();

	return 0;
}



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

using namespace std;


namespace XDYIMCMI0LY {
  inline int s(long long x) {
    int res = 0;
    while (x) {
      res += x % 10;
      x /= 10;
    }
    return res;
  }

  inline double calc(long long x) {
    return (double) x / s(x);
  }

  inline long long merge(long long x, int k) {
    while (k--) {
      x = x * 10 + 9;
    }
    return x;
  }
  
  void main() {
    vector<long long> ans;
    for (int i = 1; i <= 9; ++i) {
      ans.push_back(i);
    }
    long long x = 1;
    int k = 1;
    while (merge(x, k) <= 1e15) {
      long long nw = merge(x, k);
      long long nxt = merge(x + 1, k);
      if (calc(nw) <= calc(nxt)) {
        ans.push_back(nw);
        ++x;
      } else {
        x /= 10;
        ++k;
      }
    }
    int c;
    cin >> c;
    for (int i = 0; i < c; ++i) {
      cout << ans[i] << endl;
    }
    return ;
  }
}

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


Measured memory_bytes: 256
#include <stdio.h>

int MAX(int a, int b){
  if(a < b) return b;
  else return a;
}

int main(void){
  int A, B, C, D;
  int max, min;

  fscanf(stdin, "%d %d %d %d", &A, &B, &C, &D);

  if(B < C || D < A) printf("0\n");
  else{
    max = MAX(-1*B, -1*D) * -1;
    min = MAX(A, C);

    printf("%d\n", max-min);
  }
  return 0;
}


Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"math"
	"os"
	"strconv"
)

func main() {
	n := readInt()
	for l := 1; l <= n; l++ {
		ans := 0
		maxn := int(math.Sqrt(float64(l)))
		for i := 1; i <= maxn; i++ {
			if i*i > l {
				break
			}
			for j := 1; j <= maxn; j++ {
				if i*i+j*j+i*j > l {
					break
				}
				for k := 1; k <= maxn; k++ {
					if i*i+j*j+k*k+i*j+j*k+k*i > l {
						break
					}
					if i*i+j*j+k*k+i*j+j*k+k*i == l {
						ans++
						break
					}
				}
			}
		}
		fmt.Println(ans)
	}
}

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readInt() int {
	return int(readInt64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


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

string int2str(int x) {
  string res = "";
  rep(i, 6) {
    res += x % 10 + '0';
    x /= 10;
  }
  reverse(res.begin(), res.end());
  return res;
}

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(m), y(m);
  rep(i, m) cin >> p[i] >> y[i];

  vector<set<P>> city(n+1);
  rep(i, m) city[p[i]].insert(make_pair(y[i], i));
  
  vector<string> id(m);
  for (int i = 1; i <= n; ++i) {
    int j = 1;
    for (auto itr = city[i].begin(); itr != city[i].end(); ++itr) {
      id[itr->second] = int2str(i) + int2str(j);
      ++j;
    }
  }
  rep(i, m) cout << id[i] << endl;
  return 0;
}

Measured memory_bytes: 16452
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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(){
  ll H, W;
  cin >> H >> W;
  ll ans = 1e9;
  for(int i=1; i<H; i++) {
    ll a = W*i;
    ll b = W*((H-i)/2);
    ll c = W*((H-i+1)/2);
    chmin(ans, max({a, b, c})-min({a, b, c}));
  }
  for(int i=1; i<H; i++) {
    ll a = W*i;
    ll b = W/2*(H-i);
    ll c = (W+1)/2*(H-i);
    chmin(ans, max({a, b, c})-min({a, b, c}));
  }
  swap(H, W);
  for(int i=1; i<H; i++) {
    ll a = W*i;
    ll b = W*((H-i)/2);
    ll c = W*((H-i+1)/2);
    chmin(ans, max({a, b, c})-min({a, b, c}));
  }
  for(int i=1; i<H; i++) {
    ll a = W*i;
    ll b = W/2*(H-i);
    ll c = (W+1)/2*(H-i);
    chmin(ans, max({a, b, c})-min({a, b, c}));
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

#define Q int t, q; scanf("%d", &t); for(q=1; q<=t; q++)
typedef long long int lli;
#define pi pair<int, int>

#define N 100100

vector<int> pp;
bool isp[N];

void sieve()
{
    int i, j;
    for(i=3; i*i<=N; i+=2){
        if(!isp[i]){
            for(j=i*i; j<N; j+= i+i){
                isp[j] = true;
            }
        }
    }
    pp.push_back(2);
    for(i=3; i<N; i+=2){
        if(!isp[i])
            pp.push_back(i);
    }

}

int main()
{
    sieve();
    int x;
    cin >> x;
    int i = lower_bound(pp.begin(), pp.end(), x)- pp.begin();
    cout << pp[i] << "\n";

    return 0;
}


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

int main()
{
  int H, W;
  cin >> H >> W;
  char a;
  for(int i = 0; i < W+2; i++)
    cout << '#';
  cout << endl;
  for(int j = 0; j < H; j++)
  {
    cout << '#';
    for(int i = 0; i < W; i++)
    {
      cin >> a;
      cout << a;
    }
    cout << '#' << endl;
  }
  for(int i = 0; i < W+2; i++)
    cout << '#';
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define rep(i,l,r) for(int i = (int)l;i<(int)r;i++)
#define td(v) v.begin(),v.end()
//#define M   1000000007 // 1e9 + 7
#define MAXN 200100
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
inline int mod(int n, int m){ int ret = n%m; if(ret < 0) ret += m; return ret; }
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
	
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);

}

int is_palin(string s){
	string t=s;
	reverse(t.begin(),t.end());
	return (t==s ? 1 : 0);
}

int32_t main(){
	fastio;
	string s;
	cin>>s;
	int n = s.size();
	string a1 = "";
	string a2 = "";
	for(int i=0;i<(n-1)/2;i++){
		a1+=s[i];
	}
	for(int i=(n+3)/2 - 1;i<n;i++){
		a2+=s[i];
	}
	if(is_palin(s) && is_palin(a1) && is_palin(a2)){
		cout<<"Yes"<<endl;
	}else cout<<"No"<<endl;
	
}

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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;
string s;

int main(void){
  ll A, B;
  IN(N);
  IN(A);
  IN(B);

  ll a = (A-1) / N;
  ll b = B / N;
  PRINT((a==b)?"NG":"OK");
}


Measured memory_bytes: 3632
// AOJ 2170: Marked Ancestor
// 2018.1.2 bal4u@uu

#include <stdio.h>
#include <string.h>

#define INF 0x01010101
typedef struct { int i, v; } T;
T tbl[100003]; int sz;
int p[100003];
int mk[100003];

//#define getchar_unlocked()  getchar()
int in()
{
	int n, c;

	while ((c = getchar_unlocked()) < '0');
	n = 0;
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int find(int v, int i)
{
	if (mk[v] < i) return v;
	return p[v] = find(p[v], i);
}

int main()
{
	int N, Q, i, cmd, v;
	long long ans;

	while (N = in()) {
		Q = in();
		p[1] = 1; for (i = 2; i <= N; i++) p[i] = in();

		memset(mk, INF, sizeof(mk));
		mk[1] = 0;

		sz = 0;
		for (i = 1; i <= Q; i++) {
			if ((cmd = getchar_unlocked()) < ' ') cmd = getchar_unlocked();
			v = in();
			if (cmd == 'M') { if (mk[v] == INF) mk[v] = i; }
			else tbl[sz].i = i, tbl[sz++].v = v;
		}

		ans = 0;
		while (sz--) ans += find(tbl[sz].v, tbl[sz].i);
		printf("%lld\n", ans);
	}
	return 0;
}


Measured memory_bytes: 3052
#include <bits/stdc++.h>
#define MOD 998244353LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

/*
bool flag[5000000];
int dfs(int v){
	int cur=v;
	int cnt=0;
	vector<int> vi;
	while(1){
		if(cur%2==0){
			cur/=2;
			cur+=(1<<(n-1));
		}else{
			cur--;
			cur/=2;
		}
		cnt++;
		flag[cur]=true;
		vi.push_back(cur);
		if(cur==v)break;
	}
	if(cnt!=n*2){
		printf("unko\n");
		for(int i=0;i<vi.size();i++){
			cout << bitset<15>(vi[i]) << endl;
		}
	}
	return cnt;
}
*/

int n;
string x;
ll ans=0;
ll cnt=0;
ll mic[200005];

void calc(int v){
	ll cnt3=0;
	ll cnt4=0;
	for(int i=1;i<v;i++){
		if(v%i==0){
			cnt4+=MOD-mic[i];
			cnt4%=MOD;
		}
	}
	for(int i=0;i<v;i++){
		cnt3*=2LL;
		cnt3%=MOD;
		cnt3+=(x[i]-'0');
	}
	cnt3+=cnt4;
	cnt3%=MOD;
	ans+=(cnt3*v%MOD)*2LL%MOD;
	cnt+=MOD-cnt3;
	cnt%=MOD;
	mic[v]=cnt3;
	//printf("%d %lld %lld\n",v,ans,cnt);
	int fl=0;
	for(int i=0;i<(n/v);i++){
		for(int j=0;j<v;j++){
			int tgt=(x[j]-'0');
			if(i%2==1){
				tgt=1-(x[j]-'0');
			}
			if(fl==0){
				if((x[i*v+j]-'0')>tgt)fl=1;
				if((x[i*v+j]-'0')<tgt)fl=-1;
			}
		}
	}
	if(fl>=0){
		ans+=v*2LL;
		ans%=MOD;
		cnt+=MOD-1;
		cnt%=MOD;
		mic[v]++;
		mic[v]%=MOD;
	}
	//printf("%d %lld %lld %lld\n",v,mic[v],ans,cnt);
}

int main(void){
	scanf("%d",&n);
	cin >> x;
	/*
	for(int i=0;i<(1<<n);i++){
		if(!flag[i]){
			int rec=dfs(i);
			if(rec!=n*2){
				printf("%d %d\n",i,rec);
				cout << bitset<15>(i) << endl;
			}
		}
	}
	*/
	for(int i=1;i<n;i++){
		if(n%i==0 && (n/i)%2==1){
			calc(i);
		}
	}
	ll cnt2=0;
	for(int i=0;i<n;i++){
		cnt2*=2LL;
		cnt2%=MOD;
		cnt2+=(x[i]-'0');
	}
	cnt+=cnt2+1;
	cnt%=MOD;
	ans+=(cnt*n%MOD)*2LL%MOD;
	ans%=MOD;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 644
#include <iostream>

using namespace std;

int N;
int a[10];

bool dfs(int left, int right, int next)
{
	if(next >= 10) return true;
	
	bool ret1 = false, ret2 = false;
	if(left < a[next]) ret1 = dfs(a[next], right, next+1);
	if(right < a[next]) ret2 = dfs(left, a[next], next+1);
	
	return ret1 || ret2;
}

int main(void)
{
	cin >> N;
	for(int i = 0; i < N; i++){
		
		for(int j = 0; j < 10; j++) cin >> a[j];
		bool ans = dfs(0, 0, 0);
		
		if(ans) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3016
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}



int main()
{
	IOS;
	int n,m;
	cin>>n>>m;
	ll a[m],s=0;
	rep(i,0,m)
	{
		ll x;
		cin>>x;
		s+=x;
	}
	if(s>n)
	cout<<-1;
	else
	cout<<n-s;
}

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

int main(){
    ll n,m;
    cin>>n>>m;
    ll d=(m+n-1)/n;
    //from the max possible to coming to the min
    //what a lovely approach
    int ans;
    for(int i=d;i>0;i--){
        if(m%i==0 && m/i >=n){
            ans=i;
            break;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int r, c, s;
	int **a;
	cin >> r >> c;
	a = new int*[r+1];
	for(int i=0; i<r; ++i)
	{
		a[i] = new int[c+1];
		s=0;
		for(int j=0; j<c;++j)		
		{
			cin >> a[i][j];
			s+=a[i][j];
		}
		a[i][c] = s;
	}
	a[r] = new int[c+1];
	for(int j=0; j<c;++j)
	{
		s = 0;
		for(int i=0; i<r; ++i)
			s+=a[i][j];
		a[r][j] = s;
	}

	for(int i=0; i<r; ++i)
	{		
		for(int j=0; j<=c; ++j)
		{
			cout << a[i][j];
			if(j!=c) cout << " ";
		}
		cout << endl;
	}

	s = 0;
	for(int i=0; i<c; ++i)
	{
		s+=a[r][i];
		cout << a[r][i] << " ";
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 3128
#include<iostream>

using namespace std;

int main(){
    int s[10005], t[505];
    int m, n;
    cin >> m;
    for (int i = 0; i < m; i++)
    {
        cin >> s[i]; 
    }
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> t[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            if(t[i] == s[j]){
                ans++; break;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3136
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <utility>
#include <cstring>

using namespace std;
using llong = long long;

vector<int> graph[10000];
vector<int> vs;
vector<int> rgraph[10000];
bool visited[10000];
int cmp[10000];

void add_edge(int from,int to){
  graph[from].push_back(to);
  rgraph[to].push_back(from);
}

void dfs(int v){
  visited[v] = true;
  for(const auto &n:graph[v]){
    if(!visited[n]) dfs(n);
  }
  vs.push_back(v);
}

void rdfs(int v,int k){
  visited[v] = true;
  cmp[v] = k;
  for(const auto &n:rgraph[v]){
    if(!visited[n]) rdfs(n,k);
  }
}

int main(){
  int N,M;
  cin >> N >> M;
  for(int i=0;i<M;++i){
    int s,t;
    cin >> s >> t;
    add_edge(s,t);
  }

  for(int v=0;v<N;++v){
    if(!visited[v]) dfs(v);
  }
  memset(visited,0,sizeof(visited));
  int k = 0;
  for(int i=vs.size()-1;i>=0;--i){
    if(!visited[vs[i]]) rdfs(vs[i],k++);
  }

  int Q;
  cin >> Q;
  for(int i=0;i<Q;++i){
    int u,v;
    cin >> u >> v;
    cout << ((cmp[u] == cmp[v])?1:0) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 4824
#include<iostream>
#include<set>
#include <cstdio>
#include<vector>
#include<algorithm>
#define md 1000000007
#define ll long long

using namespace std;
	int n ;
int main(){
    cin>>n;
    vector<int> x(n);
    for(int i=0; i<n; i++){
	scanf("%d", &x[i]);
    }
    ll res=1; int curpos= 0;
    for(int i=0; i<n; i++){
	if(x[i]<2*(i-curpos)+1){
	    res*=(i+1)-curpos; res%=md;
	    curpos++;
	}
    }
    for(int i=curpos; i<n;i++){
	res*=n-i; res%=md;
    }
    cout<<res<<"\n";
}

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

int main(){
int n,m;
cin >> n >> m;
vector<int> c(n,0);
rep(i,m)
{int a,b;
cin >> a >> b;
 c[a-1]++;
 c[b-1]++;}

rep(i,c.size())
{cout << c[i] << endl;}
return 0;
}
//

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long 
using namespace std;
const int mod=1e9+7ll;
 
int n,a,b,ans1,ans2,ans3,ans;
 
inline int ksm(int x,int y)
{
	int ret=1ll;
	while(y)
	{
		if(y&1) ret=ret*x%mod;
		x=x*x%mod;
		y>>=1ll;
	}
	return ret;
}
 
inline int qpow(int a,int b)
{
    if(b==1) return a;
    int t=qpow(a,b/2);
    t=t*t%mod;
    if(b&1ll) t=t*a%mod;
    return t;
}
 
inline int C(int n,int m)
{
    if(n<m) return 0;
    if(m>n-m) m=n-m;
    int a=1,b=1;
    for(int i=0;i<m;i++)
	{
        a=(a*(n-i))%mod;
        b=(b*(i+1))%mod;
    }
    return a*qpow(b,mod-2ll)%mod;
}
 
inline int Lucas(int n,int m)
{
    if(!m) return 1ll;
    return Lucas(n/mod,m/mod)*C(n%mod,m%mod)%mod;
}
 
signed main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	ans1=ksm(2ll,n); 
	ans2=Lucas(n,a);
	ans3=Lucas(n,b);
	ans=((ans1-ans2-ans3-1ll)%mod+mod)%mod;
	printf("%lld\n",ans); 
    return 0;
}

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


#define SZ(x) ((int)(x).size())


typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
struct Vec{
    double x, y;
};

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

template<class T>
T min(T a, T b)
{
    if (a < b) return a;
    return b;
}

template<class T>
T max(T a, T b)
{
    if (a > b) return a;
    return b;
}

using namespace std;

int main()
{
    int N, a, cnt=0;
    cin >> N;
    rep(i, N){
        cin >> a;
        if (a % 2 && (i+1) % 2) cnt++;
    }
    cout << cnt << endl;
    
    

    return 0;
}


Measured memory_bytes: 3596
a, b, k = map(int, input().split())

if b - a < k*2:
    for j in [i for i in range(a, b+1)]:
        print(j)
else:
    for j in [i for i in range(a, a+k)]:
        print(j)
    for j in [i for i in range(b-k+1, b+1)]:
        print(j)

Measured memory_bytes: 38256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template< typename T >
vector< T > slide_min(const vector< T > &v, int k)
{
	deque< int > deq;
	vector< T > ret;
	ret.reserve(v.size() - k + 1);
	for (int i = 0; i < v.size(); i++) {
		while (!deq.empty() && v[deq.back()] >= v[i]) {
			deq.pop_back();
		}
		deq.push_back(i);
		if (i - k + 1 >= 0) {
			ret.emplace_back(v[deq.front()]);
			if (deq.front() == i - k + 1) deq.pop_front();
		}
	}
	return ret;
}

template< typename T >
vector< T > operator-(const vector< T > &v) {
	vector< T > res(v.size());
	for (int i = 0; i < v.size(); i++) res[i] = -v[i];
	return res;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;

	vector<int> P(N);
	for (int i = 0; i < N; i++) {
		int p; cin >> p;
		P[i] = p;
	}

	auto smin = slide_min(P, K);
	auto smax = -slide_min(-P, K);
	DMP(smin, smax);

	int cnt1 = 0;
	for (int i = 0; i < N - K; i++) if (smin[i] == P[i] && smax[i + 1] == P[i + K]) cnt1++;

	int seq = 0, cnt2 = 0;
	for (int i = 0; i < N - 1; i++) {
		if (P[i] < P[i + 1]) seq++;
		else seq = 0;
		if (seq == K - 1) cnt2++;
	}

	DMP(N - K + 1, cnt1, cnt2);
	cout << N - K + 1 - cnt1 - max(cnt2 - 1, 0) << "\n";

	return 0;
}


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

int main(){
  int N;
  cin >> N;
  if(N%2 == 0){
    double k = (double)N;
    cout << k/2/k <<endl;
  }else{
    double l = (double)N;
    cout << (l+1)/2/l <<endl;
  }
  return 0;
}



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

int main(){
	int n;
	int num[3];
	
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%d", num + i);
	
	sort(num, num + n);
	for(int i = 1; i <= num[0]; i++){
		for(int j = 0; j < n; j++){
			if(num[j] % i != 0) break;
			if(j + 1 == n) printf("%d\n", i);
		}
	}
	
	return 0;
}

Measured memory_bytes: 1040
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

X,Y = map(int,S().split())

if Y % 2 == 1:
    print('No')
    exit()
if 2*X <= Y <= 4*X:
    print('Yes')
else:
    print('No')

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

class E
{
	static void Main()
	{
		var h = Console.ReadLine().Split().Select(int.Parse).ToArray();
		int n = h[0], k = h[1], c = h[2];
		var s = Console.ReadLine();

		var u1 = new bool[n];
		for (int j = 0, i = 0; j < k; j++)
		{
			for (; i < n && s[i] == 'x'; i++) ;
			u1[i] = true;
			i += c + 1;
		}

		var u2 = new bool[n];
		for (int j = 0, i = n - 1; j < k; j++)
		{
			for (; i >= 0 && s[i] == 'x'; i--) ;
			u2[i] = true;
			i -= c + 1;
		}

		var d1 = Enumerable.Range(1, n).Where(i => u1[i - 1]).ToArray();
		var d2 = Enumerable.Range(1, n).Where(i => u2[i - 1]).ToArray();
		Console.WriteLine(string.Join("\n", Enumerable.Range(0, d1.Length).Where(i => d1[i] == d2[i]).Select(i => d1[i])));
	}
}


Measured memory_bytes: 43984
//#pragma warning(disable : 4996)
#include<iostream>
#include<vector>
#include<algorithm>
#include<fstream>
#include<stdio.h>
#include<map>
#include<set>
#include<limits.h>
#include<list>
#include <cassert>
#include<sstream>
#include<locale>
#include <bitset>
using namespace std;
using ll = long long int;

int main() {
	int n, ans = 0, max = 0,c;
	cin >> n;
	while (n--) {
		cin >> c;
		if (c >= max)
			ans++, max = c;
		
	}
	cout << ans;
	return 0;
} 





Measured memory_bytes: 3564
import math
 
def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b, a % b)

A, B = map(int, input().split(" "))
if A >= B:
  C = gcd(A,B)
else:
  C = gcd(B,A)

c = math.ceil(math.sqrt(C)) + 1
l = [1]
f = [1] + [0]*c

for i in range(2,c+1):
  if f[i-1] == 0:
    f[i-1] = 1
    if C % i == 0:
      l.append(i)
      while C % i == 0:
        C //= i
    for j in range(i+i, c+1, i):
      f[j-1] = 1

if C > 1:
  l.append(C)

print(len(l))

Measured memory_bytes: 55024
#include <bits/stdc++.h>
#define LOG(...) printf(__VA_ARGS__)
using namespace std;

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

    long long last = 0;
    map<long long, int> pre;

    for (int i = 0; i < n; ++i) {
        int x;
        cin >> x;
        last += x;
        ++pre[last];
    }

    long long ans = 0;

    for (auto &kv : pre) {
        if (kv.first == 0)
            ans += (long long)kv.second * (kv.second + 1) / 2;
        else
            ans += (long long)(kv.second - 1) * (kv.second) / 2;
    }

    cout << ans << endl;

    return 0;
}


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

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

    int R, G, B, N; cin >> R >> G >> B >> N;

    int ans = 0;
    for (int i = 0; i*R <= N; i++) {
        for (int j = 0; j*G <= N-i*R; j++) {
            if ((N-i*R-j*G) % B == 0) ans++;
            
        }
    } 

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <deque>
#define LL long long
using namespace std;

LL n;
int d[210];
deque<int> S;

int main(){
	scanf("%lld",&n);
	int m=0;
	while(n){
		if(n&1){
			n=(n-1)/2;
			d[++m]=1;
		}else{
			n--;
			d[++m]=0;
		}
	}
	for(int i=m;i>=1;i--)
		if(d[i]) S.push_back(m-i+1);
		else S.push_front(m-i+1);
	printf("%d\n",m<<1);
	for(int i=0;i<m;i++)
		printf("%d ",S[i]);
	for(int i=1;i<=m;i++)
		printf("%d ",i);
}


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

struct UnionFind {
	vector<int> p;
	
	UnionFind(int n) : p(n) {
		for (int i = 0; i < n; i++) p[i] = i;
	}
	
	int root(int x) {
		return p[x] == x ? x : p[x] = root(p[x]);
	}
	
	void unite(int x, int y) {
		x = root(x);
		y = root(y);
		if (x != y) p[x] = y;
	}
	
	bool same(int x, int y) {
		return root(x) == root(y);
	}
};

void dfs(vector<vector<int>> &g, vector<int> &d, int v) {
	d[v] = 1;
	for (auto nv : g[v]) {
		if (d[nv] != 0) continue;
		dfs(g, d, nv);
	}
}

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(m), b(m);
	rep(i, m) {
		cin >> a[i] >> b[i];
		a[i]--, b[i]--;
	}
	int ans = 0;
	rep(i, m) {
		vector<vector<int>> g(n);
		vector<int> d(n);
		rep(j, m) {
			if (i == j) continue;
			g[a[j]].push_back(b[j]);
			g[b[j]].push_back(a[j]);
		}
		dfs(g, d, a[i]);
		if (!d[b[i]]) ans++;
	}
	cout << ans << endl;
	return 0;
}

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




int main(){

	ll N;
	scanf("%lld",&N);

	ll ans = 0;

	for(ll i = 1; i <= N; i++){

		ll num = N/i;
		ll mult = (num*(1+num))/2;

		ans += i*mult;
	}

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

	return 0;
}


Measured memory_bytes: 3792
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Solve.Answer();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var S = ReadLine();
            bool flag = true;
            if (S[0] == S[1] && S[1] == S[2]) flag = false;
            IO_ShortCut.WriteLineYes_or_No(flag);
        }
    }

    public class IO_ShortCut
    {
        #region Input
        public static string ReadString => ReadLine();
        public static int ReadInt => int.Parse(ReadLine());
        public static long ReadLong => long.Parse(ReadLine());
        public static double ReadDouble => double.Parse(ReadLine());

        public static List<string> ReadSplitString => ReadLine().Split().ToList();
        public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList();
        public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList();
        public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");

        #endregion
    }

    /// <summary>
    /// 正の数の四則演算のみ対応
    /// </summary>
    public class Mod
    {
        // 割る数の定義
        private readonly static long M = 1000000007;

        // 足し算
        public static long Add(long a, long b) => (a * b) % M;
        // 引き算
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        // 掛け算
        public static long Multi(long a, long b) => (a * b) % M;
    }

    public class MathLib
    {
    }
}

Measured memory_bytes: 11092