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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  ll n;
  cin >> n;
  string s = to_string(n);
  int naka = (n - (s[0] - '0') * pow(10, s.size() - 1)) / 10;
  // cout << naka << endl;

  ll ans = 0;
  for (int i = 1; i <= n; i++) {
    // 裏返したときの先頭と最後を求める
    int top = i % 10;
    int bottom = i;
    while (bottom / 10) bottom /= 10;

    if (top == 0) continue;  // 先頭が0

    // 1文字も考えれるとき用
    if (top == bottom && top <= n) ans++;

    int len = 2;
    while (len < s.size()) {  // 短い時は中身を単純に000~999のようにできる
      ans += pow(10, len - 2);
      len++;
    }

    // nと同じ長さになった時の話をする
    if (s.size() == 1) continue;  // 間に突っ込むという概念がない
    if (top < s[0] - '0')         // 先頭が既に小さいので数字が自由
      ans += pow(10, len - 2);
    else if (top == s[0] - '0') {               // 先頭が同じ！
      if (n % 10 < bottom) {                    // けつがでかいのでnakaはすこし小さい値まで
        if (naka - 1 > 0) ans += naka + 1 - 1;  // 短すぎ予防
      } else {                                  // 先頭も後ろも同じ
        if (len == 2)
          ans += 1;
        else
          ans += naka + 1;
      }
    }  // 先頭がでかかったら何も出来ないので
    // cout << i << " " << top << " " << bottom << " " << ans << endl;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#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());
#define ALL(v) v.begin(),v.end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n, m;
    cin >> n >> m;
    vll p(m), y(m);
    vvll a(n + 1);
    REP(i, m){
        cin >> p[i] >> y[i];
        a[p[i]].push_back(y[i]);
    }
    REP(i, n + 1) VSORT(a[i]);
    REP(i, m){
        ll s1 = p[i], s2 = lower_bound(ALL(a[p[i]]), y[i]) - a[p[i]].begin() + 1;
        ll ans = 1000000 * s1 + s2, tmp = ans, d = 0;
        while(tmp){
            d++;
            tmp /= 10;
        }
        REP(i, 12 - d) cout << "0";
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 8576
# coding: utf-8
import sys
sysread = sys.stdin.readline
read = sys.stdin.read
sys.setrecursionlimit(10**7)

def run():
    N = list(map(int, list(input())))
    N = N[::-1] + [0]
    count = 0
    seq = 0
    for idx, n in enumerate(N[:]):
        if seq == 1 and (n >= 5 or (n == 4 and N[idx+1] >= 5)):
            count += 9 - n
        elif seq == 0 and (n >= 6 or (n == 5 and N[idx+1] >= 5)):
            count += 10 - n
            seq = 1
        else:
            count += n + seq
            seq = 0
    print(count)

if __name__ == "__main__":
    run()

Measured memory_bytes: 26520
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

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

bool isPrime(int n){
  if(n < 2) return false;
  else if(n == 2) return true;
  else if(n%2==0) return false;

  for(int i=3;i<=sqrt(n);i++){
    if(n%i==0) return false;
  }
  return true;
}

int main(){
  double ans = 0;
  int n;
  cin >> n;
  for(int i=0;i<n;i++){
    double a;
    cin >> a;
    ans += 1/a;
  }
  cout<< 1/ans <<endl;
}


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

int main() {
    int N;
    scanf("%d", &N);
    double *p = malloc((N + 1) * sizeof(double));
    double **DP = malloc((N + 1) * sizeof(double*));
    for (int i = 1; i <= N; i++) {
        scanf("%lf", &p[i]);
    }
    for (int i = 0; i <= N; i++) {
        DP[i] = malloc((N + 1) * sizeof(double));
        for (int j = 0; j <= N; j++) {
            DP[i][j] = 0.0;
        }
    }

    // initialize
    DP[1][0] = 1.0 - p[1];
    DP[1][1] = p[1];

    //DP[i][j]: i枚目まででj枚が面の確率 (jは最大i)
    for (int i = 2; i <= N; i++) {
        DP[i][0] = DP[i-1][0] * (1.0 - p[i]); // i-1枚目で表が一枚も出てない状態で裏が出る
        for (int j = 1; j <= i; j++) {
            DP[i][j] = (DP[i-1][j] * (1.0 -p[i]) + DP[i-1][j-1] * p[i]);  // i-1枚目までで、j枚表が出てる時に裏が出る or j-1枚表が出てる状態で、表が出る
        }
    }

    double ans = 0.0;
    // ansは(N-1)/2 + 1ちょうど一枚表が多い確率からN枚表になる確率を足した値
    for (int i = (N - 1)/2 + 1; i <= N; i++) {
        ans += DP[N][i];
    }
    printf("%1.10lf\n", ans);

    return 0;
}


Measured memory_bytes: 70528
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

s=input()
for i in range(len(s)):
    if i%2==0 and s[i]=="L":
        print("No")
        exit()
    if i%2==1 and s[i]=="R":
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 72728
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();

		long sum=0;
		for (long i=1; i<= N; i++){
			if (i % 3 ==0 || i % 5 == 0)
			{
			} else {
				sum+=i;
			}
		}
		System.out.println(sum);
	}
}

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

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

	int i = 0;
	for (i = 0; i < s.size(); i++) {
		if (s[i] != t[i]) break;
	}
	if (i == s.size()) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 3620
#![allow(non_snake_case)]

use std::io;
use std::io::prelude::*;

fn main() {
    let sin = io::stdin();
    let mut lines = sin.lock().lines();

    let mut word: String = lines.next().unwrap().unwrap();
    let _n: u32 = lines.next().unwrap().unwrap().parse().unwrap();

    for line in lines {
        let l = line.unwrap();
        let mut ws = l.split_whitespace();

        let com = ws.next().unwrap();
        let a: usize = ws.next().unwrap().parse().unwrap();
        let b: usize = ws.next().unwrap().parse::<usize>().unwrap() + 1;

        match com {
            "print" => {
                println!("{}", &word[a..b]);
            },
            "reverse" => {
                let trg = word[a..b].chars().rev().collect::<String>();
                // word.replace_range(a..b, trg);  // from 1.27
                for _ in a..b {
                    word.remove(a);
                }
                word.insert_str(a, &trg);
            },
            "replace" => {
                let trg = ws.next().unwrap();
                // word.replace_range(a..b, trg);   // from 1.27
                for _ in a..b {
                    word.remove(a);
                }
                word.insert_str(a, &trg);
            },
            _ => {
                panic!();
            }
        }
    }
}



Measured memory_bytes: 5056
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int n, a[200010];
int main(){
    while (scanf("%d",&n)!=EOF) {
        for (int i=0;i<n;i++)
            scanf("%d",&a[i]);
        sort(a,a+n);
        bool flag=true;
        for (int i=1;i<n;i++){
            if (a[i]==a[i-1])
                flag=false;
        }
        printf("%s\n",flag==true?"YES":"NO");
    }
    return 0;
}


Measured memory_bytes: 1024
import sys
import math
import itertools
import collections
from collections import deque
from collections import defaultdict

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
MOD2 = 998244353
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

def main():
    N = NI()
    
    ls = []
    
    for n in range(1,55556):
        if is_prime(n):
            if n%5 == 1:
                ls.append(n)
                if len(ls) == N:
                    print(" ".join(list(map(str,ls))))
                    break
        

if __name__ == '__main__':
    main()

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

const int64_t MOD = 1'000'000'007;

int64_t mpow(int64_t x, int64_t y){
    if(y==0) return 1;
    if(y==1) return x%MOD;
    if(y%2==0) return mpow(x*x%MOD, y/2)%MOD;
    return mpow(x*x%MOD, y/2)%MOD*x%MOD;
}

int main(){
    int n, x;
    cin >> n >> x;
    int s[200];
    for(int i=0;i<n;i++) cin >> s[i];
    sort(s, s+n, greater<int>());

    static int64_t dp[201][100001];
    dp[0][x] = 1;
    for(int i=0;i<n;i++){
        for(int j=0;j<=x;j++){
            if(dp[i][j]==0) continue;
            int64_t p = mpow(n-i, MOD-2), q = (1+MOD-p)%MOD;
            dp[i+1][j%s[i]] += dp[i][j]*p%MOD;
            dp[i+1][j%s[i]] %= MOD;
            dp[i+1][j] += dp[i][j]*q%MOD;
            dp[i+1][j] %= MOD;
        }
    }

    int64_t ans = 0;
    for(int j=0;j<=x;j++) ans = (ans + dp[n][j]*j%MOD) % MOD;
    for(int i=1;i<=n;i++) ans = ans * i % MOD;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 154240
teams={}
scores_uniq={}
while line = STDIN.gets
  if line == "0,0\n" then break end
  p, s = line.chomp.split(',').map { |item| item.to_i }
  teams[p] = s
  scores_uniq[s]=1
end

scores = scores_uniq.keys.sort.reverse

rank={}
scores.each_with_index { |e, i| rank[e] = i+1 }

while q = STDIN.gets
  q = q.chomp.to_i
  puts rank[teams[q]]
end

Measured memory_bytes: 8612
#include<bits/stdc++.h>
using namespace std;
string s1,s2;
int main(){
  while(cin >> s1 && s1!="."){
    cin >> s2;
    int counter=0;
    vector<string> s1word,s2word;
    for(int i=0;i<s1.size();i++){
      if(s1.size()!=s2.size()){
        counter=114514;
        break;
      }
      if(s1[i]==s2[i]);
      else counter++;
    }
    if(counter==0) cout << "IDENTICAL" << endl;
    else{
      //int mojicounter1,mojicounter2,mojicounter3,mojicounter4;
      for(int i=0;i<s1.size();i++){
        if(s1[i]=='"'){
          int j=1;
          while(i+j<s1.size()){
            if(s1[i+j]=='"'){
              string l=s1.substr(i+1,j-1);
              s1.erase(i+1,j);
              i--;;
              s1word.push_back(l);
              break;
            }
            j++;
          }
          i++;
        }
      }
      for(int i=0;i<s2.size();i++){
        if(s2[i]=='"'){
          int j=1;
          while(i+j<s2.size()){
            if(s2[i+j]=='"'){
              string l=s2.substr(i+1,j-1);
              s2.erase(i+1,j);
              i--;
              s2word.push_back(l);
              break;
            }
            j++;
          }
          i++;
        }
      }
      //cout << "s1:" <<s1 << " " << "s2:" << s2 << endl;
      counter=0;
      int flag=0;
      for(int i=0;i<s1.size();i++){
        if(s1.size()!=s2.size()){
          //cout << "DIFFERENT" << endl;
          flag++;
          break;
        }
        if(s1[i]!=s2[i]) counter++;
      }

      if(counter!=0){
        //cout << "DIFFERENT" << endl;
        flag++;
      }
      //cout << "flag;" << flag << endl;
      int counter2=0;
      if(s1word.size()!=s2word.size()){
        cout << "DIFFERENT" << endl;
      }
      else{
        for(int i=0;i<s1word.size();i++){
          //cout << s1word[i] << " " << s2word[i] << endl;
          if(s1word[i]!=s2word[i]) counter2++;
        }
        if(flag>0) cout << "DIFFERENT" << endl;
        else if(counter2<=1) cout << "CLOSE" << endl;
        else cout << "DIFFERENT" << endl;
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+1;
const int mod = 998244353;
int main() {
//	freopen(".in","r",stdin);freopen(".out","w",stdout);
	ll gg=1000000000000000000,ans=1,inp;
	bool is0=false;
	int n;
	sd(n);
	for(int i = 1; i <= n; i++){
		slld(inp);
		ans*=inp;
		if(inp) gg/=inp;
		else is0=true;
	}
	if(is0) pd(0);
	else if(! gg) pd(-1);
	else plld(ans);
	return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int d = a + b;

  int ans;
  if (c > d) {
    ans = d + b + 1;
  } else {
    ans = c + b;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<math.h>
using namespace std;

int main() {
	int N;
	int d[100];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> d[i];
	}
	sort(d, d + N);
	int ans=1;
	for (int i = 0; i < N-1; i++) {
		if (d[i] < d[i + 1])ans++;
	}
	cout << ans;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
A=list(map(int,input().split()))
ng=0
ok=10**10
while ok-ng>1:
  mid=(ok+ng)//2
  c=0
  for i in range(n):
    c=c+(A[i]+mid-1)//mid
  if c>k+n:
    ng=mid
  else:
    ok=mid
print(ok)

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

int abs( int a )
{
    return a < 0 ? -a : a;
}

int min( int a, int b )
{
    return a < b ? a : b;
}

int max( int a, int b )
{
    return a > b ? a : b;
}

long long int dp[105][100005];
// void calcMin( int* a, int n, int k )
// {
//     dp[1] = fabs( a[0] - a[1] );

//     for( int i = 2; i < n; i++ )
//     {
//         int min = 10000;
//         for( int j = i - 1; j >= 0 && j >= i - k; j-- )
//         {
//             int b = dp[j] + fabs( a[j] - a[i] );
//             if( b < min )
//                 min = b; 
//         }
//         dp[i] = min;
//     }
// }

void get_res( int *weight, long long int *value, int N, int W )
{
    //dp[0] = 0;
    for( long long int i = 1; i <= N; i++ ){
        for( int j = 0; j <= W; j++ ){
	    if(weight[i-1] > j){
            dp[i][j] = dp[i-1][j];
	    } else {
		    //int p = dp[i-1][j];
		    //int q = dp[i-1][j-weight[i-1]] ;
		    //int r = dp[i-1][j-weight[i-1]] + value[i-1];
		    //int s = value[i-1];
		    dp[i][j] = max(dp[i-1][j], dp[i-1][j-weight[i-1]]+value[i-1]);
		    //cout << i << " " << j << " : " << p << " " << q << " " <<  r << " " << s << " " << dp[i][j] << endl;
            }
	    // cout << i << " " << j << " : " << weight[i-1] << " " << value[i-1] << " " << dp[i][j] << endl;
	}
    }	
}


int main()
{
    int N, W;

    cin >> N >> W;

    int weight[N];
    long long int value[N];

    for( int i = 0; i < N; i++ )
        cin >> weight[i] >> value[i];

    for( int j = 0; j <=W; j++ ){
        dp[0][j] = 0;
	}
    for( int i=0; i<=N; i++){
	    dp[i][0] = 0;
       }

    get_res( weight, value, N, W );
    cout << dp[N][W] << endl;
    // for( int i = 0; i < n; i++ )
    //     cout << dp[i] << " ";
    // cout << endl;

    return 0;
}



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

typedef  long long int ll;
typedef  vector<int> vi;
#define  IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define  pb push_back
#define  fn for(int i=0;i<n;i++)
#define  all(x) x.begin(), x.end()
#define  endl "\n"


void solve()
{
	// write your code here :
string s;
	cin>>s;
	if(s[0]==s[1] and s[1]==s[2])
		cout<<"No";
	else cout<<"Yes";
}

int main()
{
	IOS
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
	// int t;
	// cin>>t;
	// while(t--)
	solve();
}

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

template<typename T>
void show_vec(const vector<T>& v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << i << ": " << v[i] << endl;
	}
}

int main() {
	const ll INF = 1e18;
	ll N, x;
	cin >> N >> x;
	vector<ll> a(N);
	for (int i = 0; i < N; ++i) { cin >> a[i]; }

	vector<vector<ll>> b(N, vector<ll>(N + 1, INF));
	for (int j = 0; j <= N; ++j) {
		for (int i = 0; i < N; ++i) {
			if (j == 0) {
				b[i][j] = a[i];
			} else {
				b[i][j] = min(b[i][j - 1], a[(i - j + N) % N]);
			}
		}
	}

	ll res = 1e18;
	for (int j = 0; j <= N; ++j) {
		ll tmp = j * x;
		for (int i = 0; i < N; ++i) {
			tmp += b[i][j];
		}
		res = min(res, tmp);
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 32896
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int32_t, int32_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

int32_t f(const int32_t n) {
  return (n % 2 == 0) ? n / 2 : 3 * n + 1;
}

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

  int32_t N, D, X;
  cin >> N >> D >> X;
  vector<int32_t> A(N);
  int32_t count = 0;
  for (int32_t i = 0; i < N; ++i) {
    cin >> A[i];
    count += (D - 1)/A[i] + 1;
  }
  const int32_t num = count + X;
  cout << num << endl;

  return 0;
}


Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
import std.container;

alias sread = () => readln.chomp();
alias route = Tuple!(long, "From", long, "To");
long bignum = 1_000_000_007;
auto dp = new long[](100_100);

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long n, m;
    scan(n, m);
    auto fromto = new long[](0);
    foreach (_; 0 .. m)
    {
        long f, t;
        scan(f, t);
        if (f == 1)
            fromto ~= t;
        if (t == n)
            fromto ~= f;
    }
    if (fromto.canGo)
        writeln("POSSIBLE");
    else
        writeln("IMPOSSIBLE");
}

auto canGo(T)(T a)
{
    a.sort();
    foreach (i, _; a)
    {
        if(i > 0)
            if(a[i - 1] == a[i])
                return true;
    }
    return false;
}

Measured memory_bytes: 3324
class Player:
    def __init__(self, name):
        # 名前
        self.name = name
        self._cards = []

    
    def setcards(self, cards):
        # 手札
        for card in cards:
            self._cards.insert(0, card)

    def getcards(self):
        return self._cards

    cards = property(getcards, setcards)

    def putDown(self):
        """
        カードがある場合はカードを出します。
        ない場合はNoneを返します。
        """
        if len(self.cards) != 0:
            return self._cards.pop()
        else:
            return None

class Game:
    def __init__(self, players):
        self.players = players

    def start(self):
        ret = self.play(self.players[0].name)
        return ret

    def play(self, name):
        target = self.searchTarget(name)
        card = target.putDown()
        if card != None:
            return self.play(card)

        # 勝者を返す
        return name

    def searchTarget(self, name):
        for player in self.players:
            if player.name == name:
                return player



if __name__ == '__main__':
    a = Player("a")
    a.cards = input()

    b = Player("b")
    b.cards = input()

    c = Player("c")
    c.cards = input()

    g = Game([a, b, c])
    winner = g.start()
    print(winner.upper())


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

ll ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) ++res[i], n /= i;
  }
  if (n != 1) res[n] = 1;
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  
  vb flg(n);
  vll cnt(n);
  ll ans=0;
  rrep(i,n){
    auto v=divisor(i+1);
    if(cnt[i]%2!=a[i]){
      flg[i]=true;
      ans++;
      for(auto e: v){
        cnt[e-1]++;
      }
    }
  }
  cout<<ans<<endl;
  if(ans){
    rep(i,n){
      if(flg[i]) cout<<i+1<<endl;
    }
  }
}


Measured memory_bytes: 4096
def f_knapsack_for_all_subsets_power_series(MOD=998244353, MAX=3010):
    # 参考: https://maspypy.com/atcoder-参加感想-2020-05-31abc-169
    import numpy as np
    N, S = [int(i) for i in input().split()]
    A = [int(i) for i in input().split()]

    f = np.zeros(MAX + 1, np.int64)  # 次数が S より大きな項には興味ないため、こうする
    f[0] = 1  # f_{0}(x) = 1
    for a in A:
        # f_{n+1} = f_{n} * (2 + x**a) = 2 * f_{n} + x**a * f_{n}
        f_next = 2 * f  # 第一項
        f_next[a:] += f[:-a]  # 第二項
        f_next %= MOD
        f = f_next
    return f[S]

print(f_knapsack_for_all_subsets_power_series())

Measured memory_bytes: 27360
#include<iostream>
#include<math.h>
#include <algorithm>
#include<float.h>
#include <limits>
#include <vector> 
#include <numeric>
using namespace::std;
int main(){

  int N;
  cin>>N;
  vector<int> d(N);
  for(int i=0;i<N;i++){
    cin>>d[i];
  }
  sort(d.begin(), d.end());
  if(N%2){
    cout<<0;
  }else{
    cout<<d[N/2]-d[N/2-1];

  
  
  
  
  }
}


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

using namespace std;

const int N = 1e5 + 10;

int n, m;
int a[N], h[N];

int main() {
    if (fopen("A.inp", "r"))
    freopen("A.inp", "r", stdin),
    freopen("A.out", "w", stdout);
    cin >> n >> m;
    for (int i = 1; i <= n; i++)
        cin >> h[i];
    while (m--) {
        int x, y;
        cin >> x >> y;
        if (h[x] == h[y])
            a[x] = a[y] = 1;
        else {
            if (h[x] > h[y]) swap(x, y);
            a[x] = 1;
        }
    }
    cout << n - accumulate(a + 1, a + 1 + n, 0);
}


Measured memory_bytes: 4420
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    long long int N, T, X = 0; cin >> N >> T;
    vector<long long int> t(N, 0);
    for(long long int i=0; i<N; i++)
    {
        cin >> t[i];
    }
    X = 0;
    for(long long int i=1; i<t.size(); i++)
    {
        long long int temp = t[i]-t[i-1];
        if ( temp <= T) X += temp;
        else X += T;
    }

    X += T;

    cout << X << endl;
    
    return 0;
}

Measured memory_bytes: 4764
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    int n; cin >> n;
    vector<int> a(n); rep(i,n) cin >> a[i];
    int ax = 0;
    rep(i,n) ax ^= a[i];
    rep(i,n){
        cout << (a[i]^ax) << endl;
    } 
    return 0;
}

Measured memory_bytes: 4048
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<iostream>
using namespace std;
typedef long long LL;
const int maxn = 1e6 + 5;
string s;
int main()
{
	cin>>s;
	if(s[0] == s[1] && s[0] == s[2]){ cout<<"Yes"<<endl; return 0; }
	if(s[2] == s[1] && s[1] == s[3]){ cout<<"Yes"<<endl; return 0; }
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <map>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,z,w,a;
    cin >> n >> z >> w;
    vector<int> q;
    for(int i=0;i<n;i++){
        cin >> a;
        q.emplace_back(a);
    }
    if(n==1){
        cout << abs(q[0]-w) << endl;
        return 0;
    }
    else {
        cout << max(abs(q[n-1]-w),abs(q[n-2]-q[n-1])) << endl;
        return 0;
    }

    return 0;
}

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

int main()
{
  int n;
  cin>>n;
  set < string > d;
  for(int i=0; i<n; i++){
    string s;
    cin>>s;
    d.insert(s);
  }
  cout<<d.size();
	return 0;
}


Measured memory_bytes: 19260
//https://atcoder.jp/contests/abc177/tasks/abc177_c
#include <iostream>
using namespace std;

const int MAXN = 2e5+4;
unsigned long long a[MAXN];
unsigned long long qz[MAXN];//前缀和
const int MO = 1e9+7;

int main() {
    int n;
    cin>>n;
    for (int i=1; i<=n; i++) {
        cin>>a[i];
        qz[i]=qz[i-1]+a[i];
    }

    unsigned long long ans=0;
    for (int i=1; i<=n; i++) {
#if 1
        ans += (a[i]%MO)*((qz[n]-qz[i])%MO);
        ans %= MO;
#else
        for (int j=i+1; j<=n; j++) {
            ans += (a[i]*a[j])%MO;
            ans %= MO;
        }
#endif
    }

    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 6760
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int N;
  ll K;
  int a[SIZE];

  cin >> N >> K;

  int sum[2020] = {};
  int s[2020] = {};

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

  for(int i=0; i<=2000; i++)
    s[i] = sum[i];

  for(int i=0; i<=2000; i++) {
    sum[i+1] += sum[i];
  }

  ll counter = 0;

  for(int i=0; i<N; i++) {
    for(int j=0;j<i; j++) {
      counter += a[j] > a[i];
    }
  }

  debug(counter);

  ll ans = counter * K % mod;

  debug(ans);

  for(int i=0; i<=2001; i++) {
    debug(sum[i]);
    debug(s[i+1]);
    ans += K * (K - 1) / 2 % mod * (s[i+1] * sum[i] % mod) % mod;
  }

  cout << ans % mod << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int K,N,A[200002],M;
  scanf("%d %d",&K,&N);
  for(int i=1;i<=N;i++){
    scanf("%d",A+i);
  }
  M=K-(A[N]-A[1]);
  for(int i=1;i<N;i++){
    if(M<A[i+1]-A[i]) M=A[i+1]-A[i];
  }
  printf("%d\n",K-M);
  return 0;
}

Measured memory_bytes: 2480
S = input()
lmax = len(S)
modulo = list([0]*2019)
mod10 = 10%2019
mod = int(S[-1])%2019
modulo[mod] += 1
for s in reversed(S[:-1]):
    mod = (mod + mod10*int(s))%2019
    modulo[mod] += 1
    mod10 = (mod10*10)%2019
ans = sum(list(map(lambda x: x*(x-1)//2, modulo)))+modulo[0]
print(ans)

Measured memory_bytes: 9352
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <queue>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <sstream>
#include <cassert>
#include <functional>
#include <cfloat>
#include <climits>
#include <cstring>
#include <stack>
#include <time.h>
#include <complex>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a+b>=24)
    cout<<a+b-24;
    else cout<<a+b; 
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define REL

#pragma GCC target ("avx2")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <iomanip>
#include <cstdio>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <string>
#include <set>
#include <bitset>
#include <cstdint>
#include <cstring>
#include <cassert>
#include <complex>
#include <stack> 
#include <random>

using namespace std;

typedef int64_t i64;
typedef long long LL;
typedef long long ll;
typedef long double LD;
typedef complex <LD> cld;
typedef unsigned int uint;
typedef complex <double> cd;
typedef unsigned long long ULL;

//#define endl "\n"
#define dendl "\n\n"
#define mp make_pair
#define mt make_tuple
#define size(v) (int)v.size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

/////////////////////////////////////////////////////////////////////

template <typename T>
T sqr(T a) {
	return a * a;
}

template <typename T>
int sign(T a) {
	if (a == 0)
		return 0;
	return (a > 0 ? 1 : -1);
}

template <typename T>
bool uax(T& a, const T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T>
bool uin(T& a, const T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template <typename T1, typename T2>
istream& operator >> (istream& in, pair<T1, T2>& p) {
	in >> p.first >> p.second;
	return in;
}

template <typename T1, typename T2>
ostream& operator << (ostream& out, pair<T1, T2>& p) {
	out << p.first << ' ' << p.second;
	return out;
}

mt19937_64 rnd(0);

const int LOG = 64;
const int N = (int)3e3 + 7;
const int MAXN = (int)4e5 + 7;
const int MOD = (int)998244353;
const int INF = (int)2e9 + 7;
const int CONST = 450;
const LL LINF = (i64)1e18;
const LD PI = 3.1415926535897932384626433832795;
const LD EPS = 1;

/////////////////////////////////////////////////////////////////////

int n, s, a[N];
int cnt[N][N];

int bin_pow(int a, int p) {
	int res = 1;
	while (p) {
		if (p & 1)
			res = 1LL * res * a % MOD;
		a = 1LL * a * a % MOD;
		p >>= 1;
	}
	return res;
}

void solve() {
	cin >> n >> s;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	cnt[0][0] = bin_pow(2, n);
	int mul = bin_pow(2, MOD - 2);
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= s; j++) {
			cnt[i][j] = cnt[i - 1][j];
			if (j < a[i])
				continue;
			cnt[i][j] = (cnt[i][j] + 1LL * cnt[i - 1][j - a[i]] * mul) % MOD;
		}
	}
	cout << cnt[n][s];
}

int main() {
	double start = clock();
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	cout << fixed << setprecision(20);
	cerr << fixed << setprecision(20);
#else
	cout << fixed << setprecision(20);
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	rnd.seed(time(0));
#endif

	int t = 1;
	for (int i = 0; i < t; i++) {
		solve();
	}

#ifdef _DEBUG
	cout << endl << "Time is " << (clock() - start) / 1000.0;
#endif
}

Measured memory_bytes: 38904
x1,y1,x2,y2=input().split()

x1=int(x1);y1=int(y1);x2=int(x2);y2=int(y2)

a=x2-x1
b=y2-y1

x3=x2-b
y3=y2+a
x4=x1-b
y4=y1+a

print(x3,y3,x4,y4)

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

double EXP(vector<double> p, int j, int K){
    double e=0;
    for(int i=j;i<j+K;i++){
        e+=(p.at(i)+1.0)/2.0;
    }
    return e;
}

int main(){
   int N,K;
   cin >> N >> K;
   vector<double> p(N);
   for(int i=0;i<N;i++){
       cin >> p.at(i);
   }
   double E=EXP(p,0,K);
   double M=E;
   for(int i=1;i<N-K+1;i++){
       E=E+(p.at(i+K-1)+1.0)/2.0-(p.at(i-1)+1.0)/2.0;
       if(M<E){
           M=E;
       }
   }
   cout << fixed << setprecision(12) << M << endl;
}

Measured memory_bytes: 3328
sx,sy,tx,ty=map(int,input().split())

dx=tx-sx
dy=ty-sy
r="U"*dy+"R"*dx
r=r+"D"*dy+"L"*dx
r=r+"L"+"U"*(dy+1)+"R"*(dx+1)+"D"
r=r+"R"+"D"*(dy+1)+"L"*(dx+1)+"U"

print(r)

Measured memory_bytes: 3060
def solve(n, y, b):
  b.sort()
  s = 0
  for i in range(n):
    s = s + b[i]
    if s == y:
      return i + 1
    if s > y:
      return i
  return n - 1
N, x = map(int, input().split())
a = list(map(int, input().split()))
print(solve(N, x, a))
      

Measured memory_bytes: 2940
#![allow(non_snake_case)]

use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let N: usize = read();
    let M: usize = read();
    if N == M {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
def binary_search(v, l, r, key):
    left = l
    right = r
    while left<right:
        mid = (left + right)//2
        if v[mid] == key:
            return True
        elif v[mid]<key:
            left = mid+1
        else:
            right = mid
    return False


n = int(input())
v = list(map(int,input().split()))
q = int(input())
w = list(map(int,input().split()))
cnt = 0
for i in w:
    if binary_search(v,0,n,i):
        cnt+=1
print(cnt)


Measured memory_bytes: 16716
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_6_B&lang=jp
#  Includes : python3
#  2018.11.26 yonezawa

import sys
input = sys.stdin.readline

def binsearch(d,l):
    max = len(l) -1
    min = 0
    mid = max // 2
    while True:
        if (l[mid] > d ):
            max = mid
        elif (l[mid] == d ):
            return True
        else:
            min = mid
        mid =  (max + min ) // 2 
        if ( mid == max or mid == min ):
            if ( l[mid] == d or l[max] == d):
                return True
            return False

def main():
    n1 = int(input())
    l1 = list(map(int,input().split()))
    n2 = int(input())
    l2 = list(map(int,input().split()))
    for i in l2:
        result = binsearch(i,l1)
#        print ("test:",result,i,l1)
        if ( result == False ):
            print (0)
            return
    else:
        print (1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 36504
# 「C[i][0]から1を引くのを別のループでやらない」「大きい値にはinfでなく10**16を使う」
# この2つはTLEしないために必須。それでも数回に1回、TLEすることがある

import sys
input = sys.stdin.readline
n, m, s, t = map(int,input().split())
C = [list(map(int,input().split())) for i in range(m)]

s -= 1
t -= 1

# O((V + E)log(V))
# Cは [[スタート頂点, ゴール頂点, 重み], ...] のリスト

# M = [[] for i in range(n)]
# for i in range(len(C)):
#     M[C[i][0]-1].append([C[i][1]-1, C[i][2]])  # 無向グラフなら両方追加
#     M[C[i][1]-1].append([C[i][0]-1, C[i][2]])  # 無向グラフなら両方追加

# N = [[] for i in range(n)]
# for i in range(len(C)):
#     N[C[i][0]-1].append([C[i][1]-1, C[i][3]])  # 無向グラフなら両方追加
#     N[C[i][1]-1].append([C[i][0]-1, C[i][3]])  # 無向グラフなら両方追加

M = [[] for i in range(n)]
for i in range(len(C)):
    M[C[i][0]-1].append([C[i][1]-1, C[i][2], C[i][3]])  # 無向グラフなら両方追加
    M[C[i][1]-1].append([C[i][0]-1, C[i][2], C[i][3]])  # 無向グラフなら両方追加

import heapq

# def dijkstra(s, M):
#     D = [10**16] * n  # 頂点0からの距離
#     P = [-1] * n  # 頂点0からの最短距離において、そこの直前の頂点(経路復元に利用)
#     D[s] = 0
#     V = [0] * n  # その頂点のD[i]が最短距離と確定したら1
#     Q = []  # 優先度付きキュー
#     for v in range(n):
#         heapq.heappush(Q, [D[v], v])

#     le = len(Q)
#     while le > 0:
#         q = heapq.heappop(Q)
#         u = q[1]
#         du = q[0]
#         if V[u] == 0:
#             V[u] = 1
#             le -= 1
#             for i in range(len(M[u])):
#                 v = M[u][i][0]
#                 luv = M[u][i][1]
#                 if V[v] == 0:
#                     alt = du + luv
#                     if D[v] > alt:
#                         D[v] = alt
#                         P[v] = u
#                         heapq.heappush(Q, [alt, v])
#     return D, P

def dijkstra(a,in_connect_list,v,money_kind):
 
    out_shortest_list = [10**15 for i in range(v)]
    out_shortest_list[a] = 0
    searching_list = [a]
    
    while searching_list != []:
    
        new_search_list = []
        for i in searching_list:
            for j in in_connect_list[i]:
                c = j[0]
                p = j[money_kind] 
                if out_shortest_list[c] > p + out_shortest_list[i]:
                    out_shortest_list[c] = p + out_shortest_list[i]
                    new_search_list.append(j[0])
        searching_list = new_search_list
 
    return out_shortest_list

# Ds, _ = dijkstra(s, M)
# Dt, _ = dijkstra(t, N)

Ds = dijkstra(s, M, n, 1)
Dt = dijkstra(t, M, n, 2)

ANS = [0] * n

# print(Ds,Dt)

ans = 10**16
for i in range(n-1, -1, -1):
    ans = min(ans, Ds[i] + Dt[i])
    ANS[i] = ans

for i in range(n):
    print(10**15 - ANS[i])

Measured memory_bytes: 97500
#include <bits/stdc++.h>
using std::cout;
using std::endl;
using std::cin;

int main(){
	int d, n; cin >> d >> n; int pos = 1;
	for(int i = 0; i < d; i++) pos *= 100;
	
	if(n == 100) pos *= 101;
	else pos *= n;
	cout << pos << endl;
	return 0;
}


Measured memory_bytes: 256
public class Range {

  static void Main (string[] args) {
    
    var line = System.Console.ReadLine().Trim().Split(' ');

    int a = int.Parse(line[0]);
    int b = int.Parse(line[1]);
    int c = int.Parse(line[2]);

    string str = "No";
    if (a < b && b < c) {
      str = "Yes";
    }

    System.Console.WriteLine(str);
  }
}

Measured memory_bytes: 8880
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL, LL> PII;

// chmax, chmin
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 <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail
{
  template <typename T, std::size_t NDIMS>
  struct vector_builder
  {
    using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

    static type make(std::vector<std::size_t> dims, const T &v = {})
    {
      const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
      if (!dims.empty())
        dims.pop_back();
      return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
    }
  };

  template <typename T>
  struct vector_builder<T, 1>
  {
    using type = std::vector<T>;

    static type make(std::vector<std::size_t> dims, const T &v = {})
    {
      return type(dims.empty() ? 0 : dims.back(), v);
    }
  };
} // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T &v, SIZE_T... dims)
{
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T &data, vector<int> &iter)
{
  cout << data << " ";
}
template <typename T>
void dump(const vector<T> &data, vector<int> &iter)
{
  for (auto elem : data)
    dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>> &data, vector<int> &iter)
{
  for (auto elem : iter)
  {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++)
  {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T> &data, int dummy)
{
  for (int i = 0; i < data.size(); i++)
  {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T &data)
{ // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////

void solve(long long N)
{
  cout << (N + 1) / 2 << endl;
}

int main()
{
  cout << setprecision(10);
  long long N;
  scanf("%lld", &N);
  solve(N);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;


int main () {
  int n, i;
  int *num;
  long long  ret = 0;
  map<int, int> mp;
	
  cin >> n;
  
  num = (int*)calloc(n, sizeof(int));
  
  for ( i = 0; i< n; i++ ) {
    cin >> num[i];
    mp[num[i]] += 1;
  }
  
  /* コンビネーション算出 */
  for (auto itr = mp.begin(); itr != mp.end(); ++itr ) {
    ret += (long long)itr->second * (itr->second - 1) / 2;
  }

  /* n回繰り返す */
  for ( i = 0; i < n; i++ ) {
  	cout << ret - (mp[num[i]] - 1) << "\n" << endl;
  }
  
	return 0;
}


Measured memory_bytes: 8448
import sys


if __name__ == "__main__":
    n = int(input())
    a = list(map(int,input().split()))
    pref = [a[0]]
    cost = 10**18
    for  i in range(1,n):
        pref.append(pref[i-1] + a[i])
    for i in range(n):
        d1 = pref[i]
        d2 = pref[-1] - pref[i]
        cost = min(cost,abs(d1-d2))
    print(cost)

Measured memory_bytes: 26220
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<tuple>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

const ll mod = 1e9+7;
const ll INF = ll(1e18)+1;
const ll MAXN = 1e6;

int main()
{
    int a[3];
    rep(i,3)
    {
        cin>>a[i];
    }
    sort(a,a+3);
    cout<<a[0]+a[1];
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
 
int main()
{
  long int N,sqrt_N,tmp;
  int j,k,count=0;
  int* test;
  bool* prime;
  
  cin>>N;
  sqrt_N=sqrt(N)+2;
  prime=new bool[sqrt_N];
  for(int i=0;i<sqrt_N;i++)
    prime[i]=true;
  
  for(int i=2;i<sqrt_N;i++)
  {
    if(!prime[i])
      continue;
    if(N%i==0&&N!=0)
    {
      N=N/i;
      count++;
    }
    j=2;
    k=i*i;
    tmp=i*j;
    while(tmp<sqrt_N)
    {
      if(k==tmp)
      {
        if(N%tmp==0 && N!=0)
        {
          N=N/tmp;
          count++;
        }
        k=k*i;
      }
      prime[tmp]=false;
      j++;
      tmp=i*j;
    }
  }
  if(N>=sqrt_N)
    count++;
  
  cout<<count;
  
  delete[] prime;
}

Measured memory_bytes: 3908
#include <stdio.h>

int main(){

  int a[4]={};
  for(int i = 0; i < 4; i++){
    scanf("%d", &a[i]);
  }
  int cost = 0;
  if(a[0] < a[1]){
    cost = cost + a[0];
  }else{
    cost = cost + a[1];
  }

  if(a[2]<a[3]){
    cost = cost + a[2];
  }else{
    cost = cost + a[3];
  }
  printf("%d", cost);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int yeah(int a){
int sum = 0 ;
  while(a > 0){
  sum += a % 10;
    a /= 10;
  }
  return sum;
}


int main() {
int N;
  cin >> N;
  if (N % yeah(N) == 0){
  cout << "Yes" << endl;
  }
  else{
  cout << "No" << endl;
  }
  
  
}


Measured memory_bytes: 256
import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,W = LI()
wv = [LI() for _ in range(N)]
dp = [collections.defaultdict(int) for _ in range(N+1)] #1_indexed
dp[0][0] = 0
for i in range(1,N+1):
    w,v = wv[i-1]
    for dw,dv in dp[i-1].items():
        dp[i][dw] = max(dp[i][dw],dv)
        if dw+w<=W:
            dp[i][dw+w] = max(dp[i][dw+w],dv+v)
print(max(dp[-1].values()))


Measured memory_bytes: 654572
#include<iostream>
#include<vector>
#include<string>
#include<queue>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    if (S.front() == '0' || S.back() == '1') {
        cout << -1 << endl;
        return 0;
    }
    int N = (int)S.size() - 1;
    rep(i, 0, N / 2) {
        if (S[i] != S[N - i - 1]) {
            cout << -1 << endl;
            return 0;
        }
    }
    queue<int> que;
    que.push(1);
    rep(i, 1, N) {
        if (S[i] == '1') {
            while (!que.empty()) {
                cout << i + 1 << ' ' << que.front() << endl;
                que.pop();
            }
        }
        que.push(i + 1);
    }
    while (!que.empty()) {
        cout << N + 1 << ' ' << que.front() << endl;
        que.pop();
    }
    return 0;
}

Measured memory_bytes: 2000