akhauriyash/Code-Regression huggingface dataset:
def main():
    N = int(input())

    def prime_factorize(n):
        res = []
        while n % 2 == 0:
            res.append(2)
            n //= 2
        f = 3
        while f * f <= n:
            if n % f == 0:
                res.append(f)
                n //= f
            else:
                f += 2
        if n != 1:
            res.append(n)
        return res

    def isqrt(n):
        x = n
        y = (x + 1) // 2
        while y < x:
            x = y
            y = (x + n // x) // 2
        return x

    # N = K^a * (bK + 1)
    # if a == 0


    ans = 1 # i == N-1
    for i in range(2, isqrt(N-1)+1):
        if (N-1) % i == 0:
            ans += 1
            if i != (N-1) // i:
                ans += 1
    
    # if a >= 1:
    divs = [N]
    for i in range(2, isqrt(N)+1):
        if N % i == 0:
            divs.append(i)
            j = N // i
            if i != j:
                divs.append(j)
    
    for div in divs:
        M = N
        while M % div == 0:
            M //= div
        if M % div == 1:
            ans += 1
    
    if N == 2:
        ans = 1
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int k,n;
  cin>>k>>n;
  long long int a[n],i,j=0,m,sum=0;
  vector<long long int>b;
  for(i=0;i<n;i++)
    cin>>a[i];
    for(i=0;i<n-1;i++)
    {
        j=abs(a[i]-a[i+1]);
        b.push_back(j);
    }
   m=abs(k+a[0]-a[n-1]);
   b.push_back(m);
   sort(b.begin(),b.end());
   for(i=0;i<b.size()-1;i++)
   {
       sum+=b[i];
   }
   cout<<sum;


}


Measured memory_bytes: 3956
def solve(n, x_list, y_list):
    # x + y
    xy_1_list = [x + y for x, y in zip(x_list, y_list)]
    # x - y
    xy_2_list = [x - y for x, y in zip(x_list, y_list)]

    res = max(max(xy_1_list) - min(xy_1_list), max(xy_2_list) - min(xy_2_list))
    return res


def main():
    n = int(input())
    x_list = [0] * n
    y_list = [0] * n
    for i in range(n):
        x, y = map(int, input().split())
        x_list[i] = x
        y_list[i] = y
    res = solve(n, x_list, y_list)
    print(res)


def test():
    assert solve(3, [1, 2, 3], [1, 4, 2]) == 4
    assert solve(2, [1, 1], [1, 1]) == 0


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 40792
x = 0
while x == 0:

 m = map(int,raw_input().split())

 if m[0] == 0 and m[1] == 0:
     break


 for i in xrange(m[0]):
    if i % 2 == 0:
        if m[1] % 2 == 0:
            print "#." * (m[1]/2)
        else:
            print "#." * (m[1]/2) + "#"
    else:
        if m[1] % 2 == 0:
            print ".#" * (m[1]/2)
        else:
            print ".#" * (m[1]/2) + "."
 print ""

Measured memory_bytes: 6376
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
// const long long INF = 1LL << 60;
const int INF = 1010101010;
using Graph = vector<vector<int>>;
const int MOD = 1000000007;

int main() {
  ll n, k;
  cin >> n >> k;
  if (n == k)
    cout << 0 << endl;
  else {
    cout << min(n % k, k - n % k) << endl;
  }
}


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


int main() {

    int n;
    cin >> n;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    int m;
    cin >> m;
    vector<string> t(m);
    rep(i, m) cin >> t[i];
    int mx = 0;
    rep(i, n) {
        int cnt = 0;
        rep(j, n) {
            if (s[i] == s[j]) ++cnt;
        }
        rep(k, m) {
            if (s[i] == t[k]) --cnt;
        }
        mx = max(mx, cnt);
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(int, input().split()))

mae = 0
ato = 0
bit = 0
for i in range(n):
    if a[i] != 1 and bit == 0:
        mae += 1
    elif a[i] != 1 and bit == 1:
        ato += 1
    else:
        bit = 1

waru = k-1
ans = (mae+ato+waru-1)//waru
print(ans)

Measured memory_bytes: 52732
#include <iostream>

using namespace std;

typedef long long ll;

#define all(x) (x).begin(), (x).end()

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

#define PRINT(str) printf(#str "\n")

//関数定義
//最大公約数
ll gcd(ll a, ll b);

//最小公倍数
ll lcm(ll a, ll b);

int main() {
  // ========================================================
  int n, r;
  cin >> n >> r;
  cout << (n >= 10 ? r : (r + (100 * (10 - n)))) << endl;
}

//最大公約数
ll gcd(ll a, ll b) {
  if (!b) return a;
  return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

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

    rep2(i,1,10){
        rep2(j,1,10){
            if(i*j==n){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
import math
ini = lambda : int(input())
inm = lambda : map(int,input().split())
inl = lambda : list(map(int,input().split()))
gcd = lambda x,y : gcd(y,x%y) if x%y else y
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([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
mod = 10**9 + 7

#maincode-------------------------------------------------

n = int(input())
ans = 0
for i in range(1,n):
    ans += int((n-1)/i)

print(ans)

Measured memory_bytes: 9264
#!/usr/bin/env python
from collections import deque, defaultdict
import bisect


def comb(a, b):
    result = 1
    for i in range(b):
        result *= (a - i) / (i + 1)
    return result


def main():
    #N = list(input().strip())
    N, K = map(int, input().split())

    k = 1
    while True:
        if N < K ** k:
            break
        k += 1

    print(k)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include<bits/stdc++.h>
        #define ll long long
        #define rep(i,a,b) for(i=a;i<b;i++)
        #define pb push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define CLR(a) memset((a),0,sizeof(a))
        #define mp make_pair
        #define hell 1000000007

        using namespace std;
         //int g[105][105];
        //vector < int > wt(100004);
       // vector < int > a;
        //vector < int > v(30500);
        //int cst[102][100005];
        //int ansr[100005];
     //ll int sum,x=0,c=0,n,m,flag=0,a1,a2,flag1=0,flag2=0;


         /* rep(i,0,50)
          {
              if(ck[i]) cout<<i<< " o"<<endl;
              else cout<<i<<" e"<<endl;
          }*/


        void solve()
        {
           ll int i,j=0,r=200,p,q,k=0,ans=0,d,y=0,h,flag=0,n,m=0,a,b,id,c,h1,h2,a1,b1;
           cin>>n>>a>>b;
           cout<<min(a*n,b);









        }


        int main()
        {
            ios::sync_with_stdio(false);
            cin.tie(0);
            cout.tie(0);
            int t=1;
          //  cin>>t;
            while(t--)
            solve();
        }

           /*

      void bfs( int i , int j)
           {
               vis[i][j]= true;
             queue < int > que;
             que.push(k);
             while(!que.empty())
             {
                int x= que.front();
                que.pop();
                 for ( int i=1;i<=n;i++)
                 {
                     if((!g[1][n] and g[x][i] ) or (g[1][n] and ! g[x][i]))
                     {
                       if(!vis[i])
                       {
                           que.push(i);
                           level[i]=level[x]+1;
                           vis[i]= true;
                       }
                     }
                 }
             }
           }

          ll int por(ll int a,ll int b)
             {
                ll int k=1;
                while(b>0)
                {
                    if(b%2) k=k*a,k%=hell;
                    b/=2;
                    a*=a; a%=hell;
                }
                return k;
             } */


Measured memory_bytes: 256
n,k,s = map(int,input().split())
ans = [s] * k
if s == 1:
    lis = [s+1] * (n-k)
elif s == 10**9:
    lis = [s-1] * (n-k)
else:
    lis = [s+1] * (n-k)
ans += lis
print(' '.join(map(str,ans)))

Measured memory_bytes: 12708
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int tmp;
  cin >> tmp;
  int i;
  int a;
  for(i=1;i<n;i++){
    cin >> a;
    tmp = tmp^a;
  }
  if(tmp==0)cout << "Yes"<<endl;
  else cout << "No"<<endl;

}


Measured memory_bytes: 256
#!/usr/bin/php
<?php
for(;;){
	list($n,$k,$m)=split(" ",fgets(STDIN));
	if(!$n)break;
	for($r=$i=0;++$i<$n;$r%=$i)$r+=$k;
	echo (($r+$m)%$n+1).PHP_EOL;
}
?>

Measured memory_bytes: 6608
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;

long long solveDP1(const vector<long long> &A, vector<long long>& DP1, int i, int shift) {
  int N = A.size();
  if (i >= N)
    return 0;
  if (i == N - 1)
    return shift;
  if (shift >= 40) {
    return solveDP1(A, DP1, i, shift - 2) + (N - i) * 2;
  }
  auto& ret = DP1[i * 40 + shift];
  if (ret >= 0)
    return ret;

  ret = LONG_LONG_MAX;
  long long q0 = A[i];
  long long q = A[i + 1];
  int t = 0;
  while (!(q0 <= q)) {
    q *= 4;
    t += 2;
  }
  while (q0 * 4 <= q) {
    q0 *= 4;
    t -= 2;
  }
  ret = solveDP1(A, DP1, i + 1, max(shift + t, 0)) + shift;
  return ret;
}

long long solve1(const vector<long long> &A) {
  int N = A.size();
  vector<long long> DP1(N * 40, -1);
  vector<long long> revA = A;
  vector<long long> revDP1(N * 40, -1);
  std::reverse(revA.begin(), revA.end());

  long long ans0 = LONG_LONG_MAX;
  for (int i = 0; i <= N; ++i) {
    long long ans = solveDP1(A, DP1, i, 0) + solveDP1(revA, revDP1, N - i, 0) + i;
    ans0 = min(ans, ans0);
  }
  return ans0;
}

int main() {
  int N;
  std::cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; ++i) {
    std::cin >> A[i];
  }
  auto ans0 = solve1(A);
  cout << ans0 << endl;
  return 0;
}


Measured memory_bytes: 140928
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		// TODO ?????????????????????????????????????????????
		int[] arg =new int[100];
        int i=0,sum=0,mono=0,point=0;
        int[] atari=null;
        boolean first=true;

		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            while ((line = br.readLine()) != null) {
            	String[] str=line.split(" ");
            	if(first){
            		point=Integer.parseInt(str[0]);
            		mono=Integer.parseInt(str[1]);
            		atari=new int[mono];
            		first=false;
            	}else{
            		atari[i]=Integer.parseInt(str[0]);
            		i++;
            		if(mono==i){
            			break;
            		}
            	}
            }
            for(int j=0;j<atari.length;j++){
            	int store=j;
            	int max=atari[j];
            	for(int k=j+1;k<atari.length;k++){
            		if(atari[k]>max){
            			max=atari[k];
            			store=k;
            		}
                }
            	int w=atari[j];
            	atari[j]=atari[store];
            	atari[store]=w;
            }
            for(int j=0;j<atari.length-1;j++){
            	if(atari[j]<point){
            		sum+=(point-atari[j]);
            	}
            }
            System.out.println(sum);
        }
	}

}

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

public class Main{

	public static void main(String[] arg) throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");

		double a = Double.parseDouble(str[0]);
		double b = Double.parseDouble(str[1]);
		double degree = Double.parseDouble(str[2]);

		double rad = Math.PI * (degree/180);
		double revrad = Math.PI * ( (180-degree)/180);

		double cx = b * Math.cos(revrad) + a;
		double cy = b * Math.sin(revrad);

		double cc = Math.pow(cx, 2) + Math.pow(cy, 2);

		System.out.printf("%.5f\n",a*b*Math.sin(rad) / 2);
		System.out.printf("%.5f\n",Math.sqrt(cc) + a + b);
		System.out.printf("%.5f\n",cy);
	}
}

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

int main() {
	long long n,m,i,j,k,ans,cur;
	cin >> n >> k;
	vector<long long> p(n);
	
	for(i=0; i<n; i++){
		cin >> p[i];
		p[i]++;
	}
	
	ans=0; cur=0;
	for(i=0; i<k; i++){
		cur+=p[i];
		ans=cur;
	}
	for(i=k; i<n; i++){
		cur=cur-p[i-k]+p[i];
		ans=max(cur,ans);
	}
	cout << setprecision(9) << double(ans/2.0);
}

Measured memory_bytes: 1792
a = []
for i in range(3):
    a.append(list(map(int,input().split())))

tmp = []

n = int(input())
for i in range(n):
    b = int(input())
    for j in range(3):
        for k in range(3):
            if a[j][k] == b:
                tmp.append((j,k))

ans = [[(0,0),(1,1),(2,2)],[(0,2),(1,1),(2,0)],[(0,0),(0,1),(0,2)],[(1,0),(1,1),(1,2)],[(2,0),(2,1),(2,2)],[(0,0),(1,0),(2,0)],[(0,1),(1,1),(2,1)],[(0,2),(1,2),(2,2)]]

for i in ans:
    count = 0
    for j in tmp:
        if j in i:
            count += 1
    if count == 3:
        print('Yes')
        exit()
print('No')

Measured memory_bytes: 3064
def gcd(a,b):
    while b:
        a,b = b,a % b
    return a
def monsters(li,n):
    t = temp
    for i in range(n-1):
        t = gcd(li[i+1],t)
    return t

n = int(input())
li_a = list(map(int,input().split()))
temp = li_a[0]
print(monsters(li_a,n))

Measured memory_bytes: 14252
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::io::{stdout, Write, BufWriter};

fn main() {
    input! {
        n: usize,
        s: String,
    }
    let s: Vec<_> = s.bytes().map(|c| c - b'a').collect();
    let lefts: Vec<_> = s.iter().take(n - 1).scan(0i32, |state, i| {
        *state |= 1 << i;
        Some(*state)
    }).collect();
    let rights: Vec<_> = s.iter().rev().take(n - 1).scan(0i32, |state, i| {
        *state |= 1 << i;
        Some(*state)
    }).collect();
    println!("{}", lefts.iter().zip(rights.iter().rev()).map(|(l, r)| (l & r).count_ones()).max().unwrap());
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <tuple>

const std::vector<int> dx{-1, 0, 1, 0}, dy{0, -1, 0, 1};

void solve() {
    int h, w, n;
    std::cin >> h >> w >> n;

    std::vector<std::pair<int, int>> pos(n + 1);
    std::vector<std::string> ss(h);
    for (int i = 0; i < h; ++i) {
        auto& s = ss[i];
        std::cin >> s;

        for (int j = 0; j < w; ++j) {
            auto& c = s[j];

            if (c == 'S') c = '0';
            if (std::isdigit(c)) {
                pos[s[j] - '0'] = std::make_pair(i, j);
                c = '.';
            }
        }
    }

    int ans = 0;
    for (int i = 0; i + 1 <= n; ++i) {
        int sx, sy, gx, gy;
        std::tie(sx, sy) = pos[i];
        std::tie(gx, gy) = pos[i + 1];

        std::vector<std::vector<int>> dist(h, std::vector<int>(w, -1));
        dist[sx][sy] = 0;
        std::queue<std::pair<int, int>> que;
        que.emplace(sx, sy);

        while (!que.empty()) {
            int x, y;
            std::tie(x, y) = que.front();
            que.pop();

            for (int d = 0; d < 4; ++d) {
                int nx = x + dx[d],
                    ny = y + dy[d];

                if (nx < 0 || h <= nx ||
                    ny < 0 || w <= ny ||
                    ss[nx][ny] == 'X' ||
                    dist[nx][ny] != -1) continue;

                dist[nx][ny] = dist[x][y] + 1;
                que.emplace(nx, ny);
            }
        }

        ans += dist[gx][gy];
    }

    std::cout << ans << "\n";
}

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

    solve();

    return 0;
}



Measured memory_bytes: 7732
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>
#include <cassert>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

void cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i = 1; i <= n; i++){
        ll ma = i * (n / i);
        ans += (i + ma) * (n / i) / 2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 10000000000000000;
const ll mod = 1000000007;
ll test[12345678];
ll ans[12345678];
signed main() {
	ll n, m, cnt = 0, z = 0; cin >> n;
	map<ll, ll> kosuu, saishou;
	vector<ll> v, kari; v.push_back(0);
	for (int h = 1; h <= n; h++) {
		cin >> test[h];
		kosuu[test[h]]++; kari.push_back(test[h]);
		if (saishou[test[h]] == 0) {
			saishou[test[h]] = h;
		}
	}
	sort(kari.begin(), kari.end());
	for (int h = 0; h < kari.size(); h++) {
		if (h == 0) { v.push_back(kari[h]); continue; }
		if (kari[h - 1] != kari[h]) { v.push_back(kari[h]); }
	}
	for (int h = v.size() - 1; h > 0; h--) {
		ans[saishou[v[h]]] += kosuu[v[h]] * (v[h] - v[h - 1]);
		kosuu[v[h - 1]] += kosuu[v[h]];
		saishou[v[h - 1]] = min(saishou[v[h - 1]], saishou[v[h]]);
	}
	for (int h = 1; h <= n; h++) {
		
		cout << ans[h] << endl;
	}
	return 0;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


vector<int> seen;
vector<vector<int>> G;
queue<int> q;

void bfs(int from){
    while (!q.empty()){
        int pos = q.front();
        q.pop();
        for(auto next: G[pos]){
            if(seen[next] != -1){
                continue;
            }
            if(seen[next] == -1){
                seen[next] = pos;
                q.push(next);
            }   
        }
    }
}

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

    G.assign(N,vector<int>());
    seen.assign(N,-1);
    
    REP(i,M){
        int a,b;
        cin >>a>>b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    q.push(0);
    seen[0] = 0;
    bfs(-1);

    FOR(i,1,N){
        if (seen[i] == -1){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    FOR(i,1,N){
        cout << seen[i]+1 << endl;
        
    }


    return 0;
}

Measured memory_bytes: 10316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const double eps = 1e-8;

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

class UnionFind {
public:
    int n;
    vector<int> par, rank, sz;
    UnionFind(int n) : n(n), par(n), rank(n), sz(n) {
        for (int i=0; i<n; ++i) {
            par[i] = i; rank[i] = 0; sz[i] = 1;
        }
    }
    int find(int x) {
        if (par[x] == x) return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x != y) {
            if (rank[x] > rank[y]) swap(x, y);
            par[x] = y;
            sz[y] += sz[x];
            if (rank[x] == rank[y]) ++rank[y];
        }
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        return sz[find(x)];
    }
};

int main() {
    int N, M, K;
    cin >> N >> M >> K;

    vector<int> A(M), B(M), C(K), D(K);
    UnionFind uf(N);

    for (int i=0; i<M; ++i) {
        cin >> A[i] >> B[i];
        A[i]--; B[i]--;
        uf.unite(A[i], B[i]);
    }
    for (int i=0; i<K; ++i) {
        cin >> C[i] >> D[i];
        C[i]--; D[i]--;
    }

    vector<ll> ca(N, 0);
    for (int i=0; i<N; ++i) {
        ca[i] = uf.size(i) - 1;
    }
    for (int i=0; i<M; ++i) {
        if (uf.same(A[i], B[i])) {
            ca[A[i]] --;
            ca[B[i]] --;
        }
    }
    for (int i=0; i<K; ++i) {
        if (uf.same(C[i], D[i])) {
            ca[C[i]] --;
            ca[D[i]] --;
        }
    }
    
    for (int i=0; i<N; ++i) cout << (i==0 ? "" : " ") << ca[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

const int INF = 1e9 + 1;
int N;
vector<int> h, dp;

int main() {
  cin >> N;
  h.resize(N), dp.resize(N, INF);
  rep(i, N) cin >> h[i];

  dp[0] = 0;

  rep(i, N - 1) {
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i + 1] - h[i]));
    if (i + 2 < N) dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i + 2] - h[i]));
  }

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

  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String s = sc.next();
		String t = sc.next();
		for (int i=0;i<N;i++) {
			System.out.print(s.charAt(i));
			System.out.print(t.charAt(i));
		}
	}
}


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

int main() {
  
    long long x;
    cin >> x;

    bitset<32> bs(x);

    cout << bs << endl;
    cout << ~bs << endl;
    cout << (bs << 1) << endl;
    cout << (bs >> 1) << endl;

    return 0;
}


Measured memory_bytes: 3152
import java.util.Scanner;

class Main{

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int OffHouse[][][] = new int[4][3][10];
		for(int i=0; i<n; i++){

			int b = scan.nextInt();
			int f = scan.nextInt();
			int r = scan.nextInt();
			OffHouse[b-1][f-1][r-1] += scan.nextInt();
		}
		scan.close();
		for(int i=0; i<4; i++){ //棟
			for(int s=0; s<3; s++){ //階
				for(int t=0; t<10; t++){ //部屋
						System.out.print(" " + OffHouse[i][s][t]);
					}
				System.out.print("\n");
				if(i != 3 && s == 2)
					System.out.println("####################");
			}
		}
	}

}

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

const string YES = "YES";
const string NO = "NO";

void solve(long long a, long long b, long long c) {
    cout << ((b-a == c - b) ? YES : NO) << endl;
}

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

  long long a;
  scanf("%lld", &a);
  long long b;
  scanf("%lld", &b);
  long long c;
  scanf("%lld", &c);
  solve(a, b, c);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (int)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll H,W;
    cin >> H >> W;
    ll ans = 0;

    if(H == 1 || W == 1) ans = 1;
    else{
        ans += devc(W,2) * devc(H,2) + (W / 2) * (H / 2);
    }
    print(ans);

    return 0;
}

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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "YES"
#define FALSE__ "NO"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

int N, A, B;
vector<int> h;

void init()
{
	cin >> N >> A >> B;
	CINV(h, N);
}

bool isok(ll x)
{
	ll cnt = 0;
	rep(i, N) {
		ll a = h[i] - x * B;
		if (a <= 0) continue;
		cnt += (a + (A - B) - 1) / (A - B);
	}
	return cnt <= x;
}

void solve()
{
	ll ok = 1e9;
	ll ng = 0;
	while (abs(ok - ng) > 1) {
		ll mid = (ok + ng) / 2;
		if (isok(mid)) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
}




Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){fastio
    ll n;cin>>n;
    ll a=n%10;
    if(a==2 || a==4 || a==5 || a==7 || a==9){
        cout<<"hon"<<endl;
    }else if(a==0 || a==1 || a==6 || a==8){
        cout<<"pon"<<endl;
    }else if(a==3){
        cout<<"bon"<<endl;
    }
    
    return 0;
}



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

using namespace std;

int n,i,j;
int dp[22][(1<<22)];
bool graph[22][22];

int main()
{
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    for(i=1;i<=n;i++){
        for(j=1;j<=n;j++){
            cin >> graph[i][j];
        }
    }
    dp[0][0]=1;
    for(i=1;i<(1<<n);i++)
    {
        for(j=0;j<n;j++){
            if(((i>>j)|1)==(i>>j) && graph[__builtin_popcount(i)][j+1]){
                (dp[__builtin_popcount(i)][i]+=dp[__builtin_popcount(i)-1][(i^(1<<j))])%=1000000007;
            }
        }
    }
    cout << dp[n][(1<<n)-1];
    return 0;
}


Measured memory_bytes: 178560
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int N;
int H[200];

int C = 0;
int ans = 0;

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

	for (int i = 0; i < N; i++)
	{
		if (C <= H[i])
		{
			C = H[i];
			ans++;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
from collections import Counter
from itertools import accumulate

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    _ = rl()
    A = tuple(map(int, rl().split()))
    
    acc = [0] + list(accumulate(A))
    counter = Counter(acc)
    ans = 0
    for key, val in counter.items():
        ans += val * (val - 1) // 2
    print(ans)


if __name__ == '__main__':
    solve()


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

using namespace std;

void solve(long long N, long long M, std::vector<long long> x,
           std::vector<long long> y) {
    vector<int> counter(N, 1);
    vector<int> red(N, 0);
    red[0] = 1;

    for (int i = 0; i < M; i++) {
        x[i]--;
        y[i]--;
        if (red[x[i]]) {
            red[y[i]] = true;
        }
        counter[y[i]]++;
        counter[x[i]]--;
        if( counter[x[i]] == 0 ){
            red[x[i]] = false;
        }
    }
    cout << count(red.begin(), red.end(), 1) << endl;
}

// Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You
// use the default template now. You can remove this line by using your custom
// template)
int main() {
    long long N;
    scanf("%lld", &N);
    long long M;
    scanf("%lld", &M);
    std::vector<long long> x(M);
    std::vector<long long> y(M);
    for (int i = 0; i < M; i++) {
        scanf("%lld", &x[i]);
        scanf("%lld", &y[i]);
    }
    solve(N, M, std::move(x), std::move(y));
    return 0;
}


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

#define rep(i, n) for(int i=0; i<n; ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
#define ll long long int

int main(){
    int k, a, b;
    cin>>k>>a>>b;
    if(a%k==0 || b%k==0 || (a/k<b/k)) cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

int main()
{
    int a, b, x;
    cin >> a >> b >> x;

    if(a <= x && x <= a + b)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

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

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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 T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }



string str;

int main() {
    while ( cin >> str ) {
        if (str.size() < 6) { puts("INVALID"); continue; }
        
        bool num = false, big = false, small = false;
        for (int i = 0; i < str.size(); ++i) {
            if (str[i] >= '0' && str[i] <= '9') num = true;
            if (str[i] >= 'a' && str[i] <= 'z') small = true;
            if (str[i] >= 'A' && str[i] <= 'Z') big = true;
        }
    
        if (num && big && small) puts("VALID");
        else puts("INVALID");
    }
    
    return 0;
}


Measured memory_bytes: 1156
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<iostream>
using namespace std;

int main()
{
    int n;
    while(cin>>n)
    {
        int b,c,d,e,f,g,h,i,j;
        b=c=d=e=f=g=h=i=j=0;
        int a;
        while(n--)
        {
            cin>>a;
            if(a>=1&&a<=399&&!b)
                b=1;
            else if(a>=400&&a<=799&&!c)
                c=1;
            else if(a>=800&&a<=1199&&!d)
                d=1;
            else if(a>=1200&&a<=1599&&!e)
                e=1;
            else if(a>=1600&&a<=1999&&!f)
                f=1;
            else if(a>=2000&&a<=2399&&!g)
                g=1;
            else if(a>=2400&&a<=2799&&!h)
                h=1;
            else if(a>=2800&&a<=3199&&!i)
                i=1;
            else if(a>=3200)
                j++;
        }
        int k=b+c+d+e+f+g+h+i;
        if(j==0)
            printf("%d %d\n",k,k);
        else if(j!=0&&k==0)
            printf("%d %d\n",1,j);
        else if(j!=0&&k!=0)
            printf("%d %d\n",k,k+j);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
	int n,k;
	cin >> n >> k;
	string s;
	cin >> s;

	s[k-1]=s[k-1]-'A'+'a';
	
	cout << s << endl;




}

Measured memory_bytes: 256
#include <iostream>
#include <limits.h>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main() {
    int n, m, x, a[110], ansa, ansb;
    cin >> n >> m >> x;
    for (int i = 1; i <= m; i++) {
        cin >> a[i];
    }
    
    for (int i = x; i > 0; i--) {
        for (int j = 1; j <= m; j++) {
            if (a[j] == i) ansa++;
        }
    }
    
    for (int i = x; i < n; i++) {
        for (int j = 1; j <= m; j++) {
            if (a[j] == i) ansb++;
        }
    }
    if (ansa < ansb) cout << ansa;
    else cout << ansb;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/ruby
#encoding: utf-8

n,a,b = gets.split.map(&:to_i)

tmpsum = 0
ans = 0

(1..n).each do |i|
  tmpsum = 0
  (0..i.to_s.size-1).each do |j|
    tmpsum += i.to_s[j].to_i
  end

  if tmpsum >= a and tmpsum <= b
    #puts "i = #{i}"
    ans += i
  end
end

puts ans

Measured memory_bytes: 3836
N,A,B = list(map(int,input().split()))
total = A+B
outsea = 0
passer = 0
for s in input():
    if s == "c":
        print('No')
        continue
    elif s == "a":
        if passer < total:
            passer += 1
            print('Yes')
        else:
            print('No')
    else:
        outsea += 1
        if passer < total and outsea <= B:
            passer += 1
            print('Yes')
        else:
            print('No')

Measured memory_bytes: 53336
#include<iostream>
#define int long long
using namespace std;
int a[1000001],n,ans;
int s[1000001],c[5000001];
int lowbit(int x)
{
	return x&(-x);
}
void add(int x,int d)
{
	for (;x<=n*4;x+=lowbit(x))
		c[x]+=d;
	return;
}
int sum(int x)
{
	ans=0;
	for (;x>=1;x-=lowbit(x))
		ans+=c[x];
	return ans;
}
bool check(int x)
{
	for (int i=1;i<=n*4;++i)
		c[i]=0;
	s[0]=0;
	int res=0;
	for (int i=1;i<=n;++i)
	{
		if (a[i]>=x)
			s[i]=s[i-1]+1;
		else
			s[i]=s[i-1]-1;
	}
	for (int i=0;i<=n;++i)
	{
		res+=sum(s[i]+n+1);
		add(s[i]+n+1,1);
	}
	return res>=(n+1)*n/4;
}
signed main()
{
	int first,last,mid,ans=-(1e+9),minn=1e+9,maxn=-(1e+9);
	cin>>n;
	for (int i=1;i<=n;++i)
	{
		cin>>a[i];
		maxn=max(maxn,a[i]);
		minn=min(minn,a[i]);
	}
	first=minn;
	last=maxn;
	ans=minn;
	while (first<=last)
	{
		mid=(first+last)/2;
		if (check(mid))
		{
			ans=max(ans,mid);
			first=mid+1;
		}
		else
			last=mid-1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10496
/**********WRITTEN BY ALMOREX***********/
/*
CodeChef:almorex
CodeForces:almorex011
*/
#include<bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define pop pop_back
#define test unsigned long long int test; cin >> test; while(test--)
#define show(x) cout<<(#x)<<"is"<<(x)<<"\n";
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;
int main(int argc, char const *argv[])
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin >> n;
    set<string> s;
    for (int i = 0; i < n; ++i)
    {
    	string str;
    	cin >> str;
    	s.insert(str);
    }
    ll var = s.size();
    cout << var << endl;
    return 0;
}
/***********WRITTEN BY ALMOREX***********/

Measured memory_bytes: 19208
from itertools import combinations

S = input()

pllst = [i for i in range(1, len(S))]
exp = []
for i in range(len(pllst)+1):
    exp.extend(list(combinations(pllst, i)))

ans = ''
for lst in exp:
    if len(lst) == 0:
        ans += S
    else:
        pivot = 0
        for order in lst:
            ans += '+' + S[pivot:order]
            pivot = order
        ans += '+' + S[pivot:]
print(eval(ans))

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n,m;
  cin >> n >> m;
  int a,ans=0;
  for(int i=0;i<m;i++){
    cin >> a;
    if(a>m) ans++;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

    int n;cin>>n;
    map<string,int> mp;
    vector<string> ans;
    rep(i,n){
        string s;cin>>s;
        mp[s]++;
    }
    int mx=0;
    for(auto x:mp){
        chmax(mx,x.second);
    }
    for(auto x:mp){
        if(x.second==mx) ans.push_back(x.first);
    }

    sort(ALL(ans));
    for(auto x:ans){
        cout<<x<<endl;
    }
    return 0;
}


Measured memory_bytes: 25584
open Batteries
module EnumL = Enum.Labels
module ListL = List.Labels
module ArrayL = Array.Labels

let dbg0 x = Printf.eprintf "[debug]%s\n" @@ dump x
let dbg1 x = dbg0 x; x

let id = identity

let (++) n m = List.range n `To m
let (++-) n m = if n >= m then List.range n `Downto m else []
let (++^) n m = if n < m then List.range n `To (pred m) else []

let scan fmt = Scanf.sscanf (read_line ()) fmt

let scan_lines n fmt f =
  if n = 0 then []
  else List.map (fun _ -> scan fmt f) (1 ++ n)

let scan_list ?sep cnv =
  let line = read_line () in
  (match sep with
   | None -> List.map String.of_char @@ String.to_list line
   | Some sep -> String.split_on_char sep line)
  |> List.map cnv

let scan_array ?sep cnv = Array.of_list @@ scan_list ?sep cnv

let scan_matrix n m e ?sep conv =
  let arr = Array.make_matrix n m e in
  ListL.iter (0 ++^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list ?sep conv);
  arr

let rec powerset e =
  match Enum.get e with
  | None -> Enum.singleton @@ Enum.empty ()
  | Some v ->
    let f = powerset e in
    let g = Enum.clone f in
    EnumL.map f ~f:(fun x -> let y = Enum.clone x in push y v; y)
    |>  Enum.append g

let permutations l =
  let rec aux l =
    let rec interleave x = function
      | [] -> [[x]]
      | (hd::tl) as lst ->
        (x::lst) ::
        (ListL.map ~f:(List.cons hd)  @@ interleave x tl)
    in
    match l with
    | [] -> [[]]
    | hd::tl -> List.concat @@ List.map (interleave hd) @@ aux tl in
  let l = List.sort (List.compare Int.compare) @@ aux @@ List.of_enum l in
  List.enum % ListL.map ~f:List.enum @@ l

let intersection l =
  EnumL.filter ~f:(fun x -> EnumL.exists ~f:((=) x) @@ Enum.clone l)

let zip l m =
  let n = min (List.length l) (List.length m) in
  List.combine (List.take n l) (List.take n m)

let lower_bound n f =
  let rec aux l u =
    if u - l > 1 then
      let m = (l + u) / 2 in
      if f m then aux l m
      else aux m u
    else u in aux (-1) n

let between n x m = n <= x && x < m

let n = scan "%d" id

exception Found of int

let () =
  try
    ListL.iter (1 ++ 1_000) ~f:(fun i ->
        if i * (pred i) / 2 = n then raise @@ Found i);
    Printf.printf "No\n"
  with
  | Found k ->
    let arr = Array.make_matrix k k 0  in
    let m = ref 1  in
    ListL.iter (0 ++^ k) ~f:(fun i ->
        ListL.iter (0 ++^ k) ~f:(fun j ->
            if i <> j && i < j then
              begin
                arr.(i).(j) <- !m;
                arr.(j).(i)  <- !m;
                m := succ !m;
              end
          )
      );
    Printf.printf "Yes\n";
    Printf.printf "%d\n" k;
    ListL.iter (0 ++^ k) ~f:(fun i ->
        Printf.printf "%d" (pred k);
        ListL.iter (0 ++^ k) ~f:(fun j ->
            if i <> j then
              (Printf.printf " ";
               Printf.printf "%d" arr.(i).(j);)
          );
        Printf.printf "\n")


Measured memory_bytes: 7040
#include <iostream>

using namespace std;
long long sums,n,x;


int main() {
	sums=0;
	cin>>n;
	for(long long i=0;i<n;i++)
	{
		cin>>x;
		sums+=x%2;
	}
	if(sums%2==0)
		cout<<"YES";
	else cout<<"NO";
	return 0;
}

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

int main() {
  int x,submit[31]= {0};
  for(int i=0;i<28;i++) {
    cin >> x;
    submit[x] = 1;
  }
  for(int i=1;i<31;i++) {
    if(submit[i] == 0)
      cout << i << endl;
  }
}

Measured memory_bytes: 0
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;

int main() {
    int N, K, d, a;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, K) {
        cin >> d;
        rep(j, d) {
            cin >> a;
            A[a-1]++;
        }
    }
    int ret = 0;
    rep(i, N) {
        if(A[i] == 0)
            ret++;
    }
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 3600
/*
phu lki ...
*/

#include<bits/stdc++.h>
#define mod 1000000007
#define pp pair<long long,long long>
#define ll long long
#define ff first
#define ss second
#define horse_power ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;
ll n,k,w;

void solve(){
   cin>>n>>w;
   ll h[n+1][2],dp[w+1]={0};
   for(int i=1;i<=n;i++){
    cin>>h[i][0]>>h[i][1];
   }
   for(int i=1;i<=n;i++){
    for(int j=w;j>=h[i][0];j--){
        dp[j]=max(dp[j],h[i][1]+dp[j-h[i][0]]);
    }
   }
   cout<<dp[w]<<"\n";


}

int main(){
horse_power
int t=1;
//cin>>t;
while(t--){
solve();
}


}


Measured memory_bytes: 1024
def GetBitStands(val):
    i = 0
    while val > 0 :
        if (val & 1) != 0 : yield i
        i += 1
        val >>= 1

def GetBitCount(val):
    cnt = 0
    while val > 0 :
        if (val & 1) != 0 :
            cnt += 1
        val >>= 1
    return cnt

def IsAllHonest(bit_map,peaple):
    for index in GetBitStands(bit_map):
       if not peaple[index].is_honest(bit_map) :
           return False
    return True

def Honests(peaple):
    for i in range(1 << len(peaple)):
        if IsAllHonest(i,peaple):
            yield i

class UserWord:
    def __init__(self):
        self.has_word = 0
        self.word = 0
    def is_honest(self,bit):
        return (bit ^ self.word)&self.has_word == 0



num = int(input())

peaple = []


for i in range(num):
    p = UserWord()
    a = int(input())
    for j in range(a):
        x,y = map(int,input().split())
        #i番目の人が「x番目の人はyである」と証言
        mask = 1 << (x-1)
        p.has_word |= mask
        if y != 0:
            p.word |= mask
    peaple.append(p)

max = 0
for kouho in Honests(peaple):
    temp = GetBitCount(kouho)
    if max < temp:
        max = temp

print(max)


Measured memory_bytes: 3064
#include <algorithm> 
#include <iostream> 
using namespace std; 
 
long long int a,b,c;
int main(){
cin>>a>>b;
c=a+b;
for(int i=0;i<2;i++){
if(c>=24){
c-=24;
}
}
cout<<c<<endl;
return 0;
}

Measured memory_bytes: 256