akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

//INSERT ABOVE HERE
signed main(){
  Int a,b,q;
  cin>>a>>b>>q;
  vector<Int> s(a),t(b),x(q);
  for(Int i=0;i<a;i++) cin>>s[i];
  for(Int i=0;i<b;i++) cin>>t[i];
  for(Int i=0;i<q;i++) cin>>x[i];

  const Int INF = 1e14;
  s.emplace(s.begin(),-INF);
  s.emplace(s.begin(),-INF*2);
  s.emplace_back(INF);
  s.emplace_back(INF*2);
  
  t.emplace(t.begin(),-INF);
  t.emplace(t.begin(),-INF*2);
  t.emplace_back(INF);
  t.emplace_back(INF*2);

  for(Int i=0;i<q;i++){
    Int u=upper_bound(s.begin(),s.end(),x[i])-s.begin();
    Int v=upper_bound(t.begin(),t.end(),x[i])-t.begin();
    
    Int res=INF;
    for(Int j=-1;j<=1;j++){
      for(Int k=-1;k<=1;k++){
        chmin(res,abs(s[u+j]-x[i])+abs(t[v+k]-s[u+j]));
        chmin(res,abs(t[v+k]-x[i])+abs(s[u+j]-t[v+k]));
      }
    }
    cout<<res<<"\n";
  }
  cout<<flush;
  return 0;
}


Measured memory_bytes: 3680
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int n,a,ans,mm;

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

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
char s[100010];
int n;
int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	for(int i = 1; i <= n; i++) {
		if(i & 1)printf("%c", s[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let mut H = read![[usize]];

    let mut ok = true;
    for i in (0..N - 1).rev() {
        if H[i] > H[i + 1] + 1 {
            ok = false;
            break;
        }
        if H[i] > H[i + 1] {
            H[i] -= 1;
        }
    }

    println!("{}", if ok { "Yes" } else { "No" })
}


Measured memory_bytes: 8444
#include<iostream>
using namespace std;
int main(){
  int N;
  cin>>N;
  int L[N];
  for(int i=0; i<N; i++) cin>>L[i];
  int max=0, sum=0;
  for(int i=0; i<N; i++) {
    if(max<L[i]) max=L[i];
    sum+=L[i];
  }
  cout << (sum-max>max?"Yes":"No") << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int answer = 0;
        int current = 0;
        for (int i = 0; i < N; i++) {
            int h = scan.nextInt();
            if (current <= h) {
                answer += (h - current);
            }
            current = h;
        }
        System.out.println(answer);
    }
}


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

int K, S;

int main(){
    cin >> K >> S;

    int ans = 0;
    for(int x=0;x<=K;x++){
        for(int y=0;y<=K;y++){
            if( 0 <= S-x-y && S-x-y <= K )    ans++;
        }
    }

    cout << ans << endl;
}

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

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
// #define MOD 1000000007
#define MOD 998244353 
#define MEM_SIZE 101010
#define DEBUG_OUT true

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


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  int n; cin>>n;  
  vector<int> vec (n,0);
  for (int i = 0; i < n; i++)
  {
     cin>>vec[i];
  }
  int res = 0;
  int m = 0;
  for (int i = 0; i < n; i++)
  {
    res += max(0LL,m - vec[i]);
    chmax(m,vec[i]);
  }
  cout<<res<<endl;
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 4780
#include <iostream>
#include <algorithm>
#include <map>
#include <math.h>
#include <set>
#include <string>
#include <vector>
typedef long long ll;

using namespace std;

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

    if (K == 0){
	ll res = (ll)N*(ll)N;
	cout << res << endl;
	return 0;
    }

    ll res = 0;
    for (int b = K+1; b <= N; b++){
	int as = b-K;
	int f = (N/b)*b+K;

	res += (N/b)*as+max(0, N-f+1);
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>



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

  vector<int> alp[30];

  string s,t;
  cin>>s>>t;

  rep(i,s.size()){
    alp[s[i]-'a'].PB(i+1);
  }

  int st=0,n=(int)s.size();
  int res=0;
  rep(i,t.size()){
    int k=t[i]-'a';
    if(alp[k].empty()){
      cout<<-1<<endl;
      return 0;
    }

    auto it=upper_bound(all(alp[k]),res);
    if(it==alp[k].end()){
      st++;
      it=upper_bound(all(alp[k]),0);
    }
    res=*it;
    //cout<<res<<endl;
  }


  cout<<st*n+res<<endl;


}

Measured memory_bytes: 1736
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b = LI()
    if a < b:
        a, b = b, a
    ans = a
    a -= 1
    ans += max(a, b)
    print(ans)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


Measured memory_bytes: 39152
#include<bits/stdc++.h>
#define LL long long int
#define f(a,b) for(int i = a;i<=b;i++)
#define df(b,a) for(int i = b;i>=a;i--)
using namespace std;
int arr[60];
int main(){
   int N,n;
    int sum=0;
    cin>>N>>n;
    f(0,N-1){
        cin>>arr[i];
    }
    sort(arr,arr+N);
    df(N-1,N-n){
        sum+=arr[i];
    }
    cout<< sum<<endl;
    return 0;
}

Measured memory_bytes: 256
n, p = map(int, input().split())

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

from collections import Counter
primes_counter = Counter(prime_factorize(p))

ans = 1
for kv in primes_counter.items():
  if kv[1] >= n: ans *= kv[0] ** (kv[1] // n)

print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
   
#define pii pair<int, int>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define ld long double
#define sz(v) int(v.size())
#define all(v) v.begin(), v.end()
#define vec vector<int>
#define dead not_bad
   
#define left not_right
#define y1 what
   
using namespace std;
   
const int N = (int) 333;
const int M = (int) 100 + 11;
const ll LINF = (ll) 1e18;
const double PI = 3.14159265359;
const int INF = (int) 1e9 + 7;
const int mod = 1e9 + 7;
const double EPS = (double) 1e-9;

int n;
int a[N][N], nr[N][N];

int main() {
    #define fn "billboard"
    #ifdef witch  
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #else
    //    freopen(fn".in", "r", stdin);
    //    freopen(fn".out", "w", stdout);
    #endif  
    srand(time(0));
    cin >> n;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        cin >> a[i][j];
      }
    }
    for (int k = 1; k <= n; k++) {
      for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
          if (a[i][k] + a[k][j] < a[i][j]) {
            cout << -1;
            return 0;
          }
          if (i == k || j == k)
            continue;
          if (a[i][k] + a[k][j] == a[i][j]) {
            nr[i][j] = 1;
          }
        }
      }
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= n; j++) {
        if (!nr[i][j])
          ans += a[i][j];
      }
    }
    cout << ans / 2;
    return 0;
} 

Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<string>
#include<math.h>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<time.h>
#include<ctime>
#include<functional>
#define int long long
#define INF (1<<29)
#define f(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

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 mypow(ll a, ll b, ll c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	else return mypow(a, b / 2, c)*mypow(a, b / 2, c) % c;
}

signed main(){
	queue<int> q;
	int h,w,a[600][600];
	cin >> h >> w;
	f(i, h) {
		f(j, w) {
			cin >> a[i][j];
		}
	}
	f(i, h) {
		f(j, w) {
			if (a[i][j] % 2) {
				if (j + 1 == w) {
					if (i + 1 != h) {
						a[i][j]--;
						a[i + 1][j]++;
						q.push(i);
						q.push(j);
						q.push(i + 1);
						q.push(j);
					}
				}
				else {
					a[i][j]--;
					a[i][j + 1]++;
					q.push(i);
					q.push(j);
					q.push(i);
					q.push(j + 1);
				}
			}
		}
	}
	cout << q.size() / 4 << endl;
	while (q.size()) {
		cout << q.front()+1 << " ";
		q.pop();
		cout << q.front()+1 << " ";
		q.pop();
		cout << q.front()+1 << " ";
		q.pop();
		cout << q.front()+1 << endl;
		q.pop();
	}
	return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
int dx[5]={-1,1,0,0};
int dy[5]={0,0,1,-1};
int n,m;
string s[1005];
int cnt1=0;
int cnt2=0;
int ans=0;
queue<pair<int,int> > q;
bool check(int x,int y)
{
	if(x>=0 and x<n and y>=0 and y<m and s[x][y]=='.')
	{
		return true;
	}
	return false;
}
int main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)
	{
		cin>>s[i];
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(s[i][j]=='#')
			{
				cnt1++;
				q.push(make_pair(i,j));
			}
		}
	}
	while(cnt1>=1)
	{
		cnt1--;
		int x=q.front().first;
		int y=q.front().second;
		q.pop();
		for(int i=0;i<4;i++)
		{
			int x1=x+dx[i];
			int y1=y+dy[i];
			if(check(x1,y1))
			{
				cnt2++;
				s[x1][y1]='#';
				q.push(make_pair(x1,y1));
			}
		}
		if(cnt1==0)
		{
			cnt1=cnt2;
			cnt2=0;
			ans++;
		}
	}
	cout<<ans-1;
	return 0;
}

Measured memory_bytes: 9488
#include <stdio.h>

static const int N = 100;
int c=0;

void BubbleSort(int A[],int n){
  int i,j,temp;
  for(i=0;i<=n-1;i++){
    for(j=n-1;j>=i+1;j--){
      if(A[j]<A[j-1]){
	temp=A[j];
	A[j]=A[j-1];
	A[j-1]=temp;
	c++;
      }
    }
  }
}

main(){
  int i,j,n;
  int A[N+1];

  scanf("%d",&n);

  for(i=0;i<n;i++) scanf("%d",&A[i]);

  BubbleSort(A,n);

  for(j=1;j<=n;j++){
    if(j>1) printf(" ");
    printf("%d",A[j-1]);
  }
  printf("\n");
  printf("%d\n",c);
  return 0;
}

Measured memory_bytes: 604
n = int(input())
a = list(map(int,input().split()))
boxes = ["mada"] * n

for i in range(n, 0, -1):
    if boxes[i-1] == "mada":
        kokomade = sum((boxes[i-1::i])[1:]) % 2
        if kokomade == a[i-1]:
            boxes[i-1] = 0
        else:
            boxes[i-1] = 1

ans = []
for i in range(n):
    if boxes[i] == 1:
        ans.append(str(i+1))

print(len(ans))
print(" ".join(ans))

Measured memory_bytes: 17204
#include<stdio.h>
#include <iostream>

int main()
{
	long long X;
	long long kane = 100;
	double k;
	int nen = 0;

	scanf("%lld", &X);

		while (kane < X)
		{
			kane = kane * 1.01;
			//kane = (double)(int)k;
			nen++;
			//		printf("%lf\n", kane);
		}

	printf("%d",nen);

	return 0;
}

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

sunuke = [0 for i in range(N+1)]

for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for _a in A:
        sunuke[_a] = 1

count = 0
for i in range(1, N+1):
    if sunuke[i] == 0:
        count += 1

print(count)


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

using namespace std;

const int N = 2010;
vector<int > G[N];
int n, maxDist;

int visit(int par, int u, int depth) {
    int ans = 1;
    if(depth == maxDist / 2) return ans;
    for(int v: G[u]) {
        if(v != par)
            ans += visit(u, v, depth + 1);
    }
    return ans;
}

int main() {
    //freopen("a.txt", "r", stdin);
    cin >> n >> maxDist;
    for(int i = 1; i < n; ++i) {
        int u, v;
        cin >> u >> v;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    int ans  = n;
    for(int u = 1; u <= n; ++u) {
        int canKeep = 0;
        if(maxDist % 2 == 0) {
            canKeep = visit(0, u, 0);
            ans = min(ans, n - canKeep);
        }
        else {
            for (int v: G[u]) {
                canKeep = visit(u, v, 0) + visit(v, u, 0);
                ans = min(ans, n - canKeep);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
N = int(input())
a = list(map(int,input().split()))
li = [0]*8
overrate = kind = 0
for i in range(N):
    if a[i]>=3200:
        overrate += 1
        continue
    else:
        li[a[i]//400] += 1

for j in range(8):
    if li[j]!=0:
        kind += 1

if kind==0:
    print(1,kind+overrate)
else:
    print(min(8,kind),kind+overrate)


Measured memory_bytes: 3060
H,W= map(int , input().split())
N = int(input())
A = list(map(int, input().split()))
S = []
for k in range (N):
    for l in range(A[k]):
        S.append(k+1)
for i in range(H):
    if (i % 2)==0:
        print(*S[i*W:i*W+W])
    elif (i % 2)==1:
        print(*S[i*W+W-1:i*W-1:-1])

Measured memory_bytes: 3828
#include "iostream"
#include "math.h"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
using namespace std;

int main() {
	int n, d[105];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	long long ans = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			ans += d[i] * d[j];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,a,n) for(i=a;i<n;++i)
#define irep(i,n,a) for(i=n;i>a;--i)
#define mod 1000000007
#define pb push_back
#define big 9223372036854775807
#define big1 LONG_MAX
#define big2 ll_MAX
#define big3 1000000000
#define sma1 LONG_MIN
#define sma2 ll_MIN
#define sma3 -1000000000
#define mp make_pair
#define dub double
#define ivec vector<ll>
#define lvec vector<long long>
#define cvec vector<char>
#define svec vector<string>
#define mt make_tuple
#define MOD 998244353
#define pi acos(-1.0)/*
#define ss second.second
#define ff first.first
#define f first
#define s second
#define sf second.first
#define fs first.second*/
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)


int main()
{

    int i;
    string s1,s2;

    cin>>s1>>s2;

    if(s2.size()==s1.size()+1)
    {
        for(i=0;i<s1.size();++i)
        {
            if(s1[i]!=s2[i])
                break;
        }

        if(i==s1.size()){
            cout<<"Yes";
            return 0;}
    }

    cout<<"No";



    return 0;
}

Measured memory_bytes: 3632
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

# sum_{i:r1,r2} sum_{c:c1,c2} f(r+c,c)
# sum_{i:r1,r2} (f(r+c2+1,c2) - f(r+c1, c1-1))

def enumfif(n, mod):
    f = [0] * (n+1)
    invf = [0] * (n+1)
    f[0] = 1
    for i in range(1, n+1):
        f[i] = f[i-1] * i % mod

    a = f[n]
    b = mod
    p, q = 1, 0
    while b > 0:
        c = a//b
        d = a; a = b; b = d % b
        d = p; p = q; q = d-c*q
    invf[n] = p + mod if p < 0 else p
    for i in range(n-1,-1,-1):
        invf[i] = invf[i+1] * (i+1) % mod
    return f, invf

def C(n, r, mod, fif):
    if n < 0 or r < 0 or r > n:
        return 0
    return fif[0][n] * fif[1][r] * fif[1][n-r] % mod

mod = 1000000007
fif = enumfif(2000005, mod)
# sum_{i:r1,r2} (f(r+c2+1,c2) - f(r+c1, c1-1))
# (f(r2+1+c2+1,c2+1) ^ f(r1+c2+1,c2+1) - f(r2+1+c1, c1-1+1) +
# f(r1+c1, c1-1+1)
# )
r1, c1, r2, c2 = na()
ans = \
    C(r2+1+c2+1, c2+1, mod, fif) - \
    C(r1 + c2 + 1, c2 + 1, mod, fif) - \
    C(r2 + c1 + 1, c1 - 1 + 1, mod, fif) + \
    C(r1 + c1, c1 - 1 + 1, mod, fif)
ans %= mod
if ans < 0: ans += mod
print(ans)


Measured memory_bytes: 70000
var
    n,i,ans:longint;
    a,b:array[1..1000]of longint;
begin
    readln(n);
    for i:=1 to n do
    begin
        readln(a[i],b[i]);
        inc(ans,b[i]-a[i]+1);
    end;
    writeln(ans);
end.

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <set>
#define MAXN 100010
using namespace std;

int n;
int a[MAXN];
set<int> S;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	for(int i=1;i<=n;i++) S.insert(a[i]);
	if(S.size()==1){
		int x=*S.begin();
		if(n>=2*x || n==x+1) puts("Yes");
		else puts("No");
	}else if(S.size()==2){
		int v1=*S.begin(),v2=*(++S.begin());
		if(v2!=v1+1){
			puts("No");
			return 0;
		}
		int c1=0,c2=0;
		for(int i=1;i<=n;i++)
			if(a[i]==v1) c1++;
			else c2++;
		int x=v2;
		if(c1>x || (c1==x && c2) || c2<2*(x-c1)) puts("No");
		else puts("Yes");
	}else puts("No");
	return 0;
}


Measured memory_bytes: 5248
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
print(int(N**(1/2))**2)


Measured memory_bytes: 5140
// 20151002




#include<stdio.h>
int main() {
  int i, j;





  // ???????????¨???
  for (i = 1; i <= 9; i ++) {
    for (j = 1; j <= 9; j ++) {
      printf("%dx%d=%d\n", i, j, i * j);
    }
  }




  // ??????
  return 0;
}

Measured memory_bytes: 524
import math
k = int(input())
ans = 0
if k < 3:
    for i in range(1,k+1):
        for j in range(1,k+1):
            for n in range(1,k+1):
                ans += math.gcd(i,math.gcd(j,n))
else: 
    #i*j
    for n in range(1,k+1):
        for i in range(1,k+1):
            ans += math.gcd(n,i)
            for j in range(i+1,k+1):            
                ans += 2*(math.gcd(math.gcd(i,j),n))

    '''
        for i in range(1,k+1):
            for j in range(i+1,k+1):
                for k in range(j+1,k+1):
                    ans += math.gcd(i,math.gcd(j,k))
    '''
print(ans)

Measured memory_bytes: 9240
num = int(input())
x_list = [float(i) for i in input().split()]
y_list = [float(i) for i in input().split()]
distance = 0
tmp = 0
sum_dis = 0
for i in range(1, 4):
    for j in range(num):
        tmp = (abs(x_list[j] - y_list[j])) ** i
        distance += tmp
        if sum_dis < tmp and i == 1:
            sum_dis = tmp
    distance = distance ** (1/i)
    print("{:.6f}".format(distance))
    distance = 0
print("{:.6f}".format(sum_dis))

Measured memory_bytes: 7860
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
const long double EPS = 1e-9;
const ll mod = 1e9 + 7;
const ll INF = 1e9;

#define rep(i, n) for(ll i = 0; i < n ; i++ )
#define For(i, a, b) for(ll i = (a); i < (b) ; i++ )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

const ll MAX_N = 3000;

int main(void){
    ll N;
    ll a;
    ll answer = 0;

    cin >> N;
    rep(i, N){
        cin >> a;
        answer += a - 1;
    }         

    cout << answer << endl;

    return 0;
}

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

int main(){
    ll k;
    cin>>k;
    vector<ll>a(50,49);
    rep(i,50){
        a[i]+=k/50;
    }
    k%=50;
    rep(i,k){
        rep(j,50){
            if(i==j)a[j]+=50;
            else a[j]--;
        }
    }
    cout<<50<<endl;
    rep(i,50){
        if(i==49)cout<<a[i]<<endl;
        else cout<<a[i]<<" ";
    }
}

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

using namespace std;

int a[1000001];
int b[1000001];
int g(){
    int cnt=0;
}
int f(int x,int y){
    int cnt=0;
    if(b[x]-b[y]-b[x-y]==0)return 1;
    return 0;
}
int main(){
    int n;

    cin>>n;

    for(int i=0 ; i<n ; i++)scanf("%1d",&a[i]),a[i]--;
    for(int i=0 ; i<n ; i++){
        for(int j=2 ; j<=i  ; j*=2)b[i]+=i/j;
    }
    int s=0;
    for(int i=0 ; i<n ; i++)s+=a[i];
    if(s==0){
        cout<<0;
        return 0;
    }

    int t=0;
    int i;
    int cnt=0;
    for(i=0 ; i<n ; i++){
        t+=a[i]*f(n-1,i);
        t%=2;
        if(a[i]==1)cnt++;
    }
    if(t==1){
        cout<<1;
        return 0;
    }
    if(cnt){
        cout<<0;
        return 0;
    }

    for(i=0 ; i<n ; i++)a[i]/=2;
    s=0;
    for(int i=0 ; i<n ; i++)s+=a[i];
    if(s==0){
        cout<<0;
        return 0;
    }

    t=0;
    cnt=0;
    for(i=0 ; i<n ; i++){
        t+=a[i]*f(n-1,i);
        t%=2;
        if(a[i]==1)cnt++;
    }

    if(t==1){
        cout<<2;
        return 0;
    }
    cout<<0;
    return 0;
}


Measured memory_bytes: 8064
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int N = int.Parse(Console.ReadLine());
		string[] str = Console.ReadLine().Split();
		int ans = 0;
		int[]A = new int[N];
		for(var i=0;i<N;i++){
			A[i] = int.Parse(str[i]);
		}
		Array.Sort(A);
		ans = A[N/2]-A[N/2-1];
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 20704
n = int(input())
h = list(map(int,input().split()))
ans = 0
while any(h):
    f = False
    for i in range(n):
        if h[i] == 0:
            if f:
                f = False
                ans += 1
        else:
            f = True
            h[i] -= 1
    if f:
        ans += 1
print(ans)

Measured memory_bytes: 3060
f = lambda:list(map(int,input().split()))
la = f()+f()+f()
sb = set()
n = int(input())
for i in range(n):
  b = int(input())
  if b in la:
    sb.add(la.index(b))
ls = [{0,1,2},{0,3,6},{0,4,8},{1,4,7},{2,4,6},{2,5,8},{3,4,5},{6,7,8}]
for s in ls:
  if s<=sb:
    print('Yes')
    break
else:
  print('No')

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

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

Measured memory_bytes: 256
import java.util.*
import java.math.*

fun main(args: Array<String>) {
    var (N, K) = readLine()!!.split(" ").map { it.toInt() }
//    var N = readLine()!!.toInt()
//    val S = readLine()!!
//    val D = readLine()!!.split(" ").map { it.toLong() }

    println(if (N>=13) K else if (N>=6) K/2 else 0)
}


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

#define int int64_t


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

    int x, n;
    cin >> x >> n;
    
    vector<int> sequence;
    
    for (int i=0; i<n; i++) {
        int tmp;
        cin >> tmp;
        sequence.push_back(tmp);
    }
    
    sort(sequence.begin(), sequence.end());
    
    if (n==0) {
        cout << x;
        return 0;
    }
    
    
    int dist = abs(x - (-1));
    int result = -1;
    for (int i=0; i<=sequence[n-1]+1; i++) {
        if (count(sequence.begin(), sequence.end(), i)) {
            continue;
        }
        else {
            if (abs(x-i) < dist) {
                dist =x-i;
                result = i;
            }
        }
    }
    
    cout << result;
    
    return 0;
}


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

using namespace std;

typedef long long ll;
const int INF = 0x3f3f3f3f;

int n,k;
double ans;

int main()
{
	cin>>n>>k;
	for(int i = 1;i <= n;i++){
		double tmp = 1.0 / (double)n;
		int x = i;
		while(x < k){
			tmp /= 2.0;
			x *= 2;
		}
		ans += tmp;
	}
	printf("%.12f\n",ans);
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[] arr = new int[n];
        int sum = 0;
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
            sum += arr[i];
        }

        if (sum % 10 != 0) System.out.println(sum);
        else {
            Arrays.sort(arr);
            for (int i : arr) {
                if (i % 10 != 0) {
                    System.out.println(sum - i);
                    return;
                }
            }

            System.out.println(0);
        }
    }
}  
        
        

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repr(i,a,n) for(int i=a;i>n;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int n,t;
  cin >> n >> t;
  int pre = 0;
  int now = 0;
  int ans = 0;
  rep(i,0,n){
    cin >> now;
    ans += min(now-pre,t);
    pre = now;
  }
  ans += t;
  cout << ans << endl;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);

//  freopen("input.txt", "r", stdin);
//  freopen("output.txt", "w", stdout);

    int n, k;
    long long s = 0;
    cin >> n >> k;
    int a[n];
    for(int i = 0; i < n; i++)
        cin >> a[i];
    sort(a, a+n);
    for(int i = 0; i < k; i++)
        s += a[i];
    cout << s;

    return 0;
}


Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>

#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

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; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;}


using namespace std;

int main()
{
    int N;
    string s;
    vector<int> p;
    cin >> N >> s;
    int v[26];
    rep(i, 26){
        v[i] = 0;
    }
    ll MOD = 1000000007;

    string str = "abcdefghijklmnopqrstuvwxyz";
    for(int i=0; i<N; i++){
        int j = int(s[i] - 'a');
        v[j]++;
    }

    rep(i, 26){
        if(v[i] != 0) p.push_back(v[i]);
    }

    ll cnt = 1;
    rep(i, p.size()){
        cnt *= (p[i]+1);
        cnt %= MOD;
    }
    cnt -= 1;
    cnt = cnt%MOD;
    cout << cnt;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

int main() {
    int n;
    int s = 0;
    cin >> n;
    vector<int> v(n);
    vector<int> c(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    for(int i = 0; i < n; i++){
        cin >> c[i];
    }
    for(int i = 0; i < n; i++){
        if (v[i] - c[i] > 0){
            s = s + v[i] - c[i];
        }
    }
    cout << s << endl;
}

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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var As = Console.ReadLine().Split().Select(s=>int.Parse(s)).ToArray();
            var Bs = Console.ReadLine().Split().Select(s=>int.Parse(s)).ToArray();
            long count = 0;
            for(var i = N-1;0<=i;i--)
            {
                if(Bs[i]<=As[i+1])
                {
                    As[i + 1] -= Bs[i];
                    count += Bs[i];
                    continue;
                }
                count += As[i + 1];
                Bs[i] -= As[i + 1];
                As[i + 1] = 0;
                if (Bs[i] <= As[i])
                {
                    As[i] -= Bs[i];
                    count += Bs[i];
                    continue;
                }
                count += As[i];
                As[i] = 0;
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 34204
#include <iostream>

#include <map>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>

using namespace std;

using ll = long long;
using ii = pair<ll, ll>;

const ll MAX { 200010 };
ii xs[MAX];
int medians[MAX];

int main()
{
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    for (int i = 0; i < N; ++i)
    {
        cin >> xs[i].first;
        xs[i].second = i;
    }

    sort(xs, xs + N);

    int limit = (N - 1)/2;

    for (int i = 0; i < N; ++i)
        medians[xs[i].second] = (i <= limit) ? xs[N/2].first : xs[limit].first;

    for (int i = 0; i < N; ++i)
        printf("%d\n", medians[i]);

    return 0;
}


Measured memory_bytes: 6144
def sieve(n):
    """自然数n以下の素数のリストを返す。エラトステネスの篩 n >= 2"""
    prime = [True] * (n+1)
    #res[0] = res[1] = False , res[2a] = False 使わないので省略 
    sn = int(n ** 0.5)
    for num in range(3, sn+1, 2):
        if prime[num]:
            for m in range(num**2, n+1, num*2):
                prime[m] = False
    return [2] + [i for i in range(3, n+1, 2) if prime[i]]

#2を含む組み合わせは絶対偶数となる
#5で割ったあまり1 の素数でこうせいすれば 絶対5で割れる
#素数は奇数なので10で割ったあまり1

prime = sieve(55555)
answer = list(filter(lambda x: x % 10 == 1, prime))

N = int(input())

print(answer[0], end = "")
for i in range(1, N):
    print(" " + str(answer[i]), end = "")

Measured memory_bytes: 3700
//This program is written by Brian Peng.
#pragma GCC optimize("Ofast","inline","no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define Rd(a) (a=rd())
#define Gc(a) (a=getchar())
#define Pc(a) putchar(a)
int rd(){
	int x;char c(getchar());bool k;
	while(!isdigit(c)&&c^'-')if(Gc(c)==EOF)exit(0);
	c^'-'?(k=1,x=c&15):k=x=0;
	while(isdigit(Gc(c)))x=x*10+(c&15);
	return k?x:-x;
}
void wr(int a){
	if(a<0)Pc('-'),a=-a;
	if(a<=9)Pc(a|'0');
	else wr(a/10),Pc((a%10)|'0');
}
signed const INF(0x3f3f3f3f),NINF(0xc3c3c3c3);
long long const LINF(0x3f3f3f3f3f3f3f3fLL),LNINF(0xc3c3c3c3c3c3c3c3LL);
#define Ps Pc(' ')
#define Pe Pc('\n')
#define Frn0(i,a,b) for(int i(a);i<(b);++i)
#define Frn1(i,a,b) for(int i(a);i<=(b);++i)
#define Frn_(i,a,b) for(int i(a);i>=(b);--i)
#define Mst(a,b) memset(a,b,sizeof(a))
#define File(a) freopen(a".in","r",stdin),freopen(a".out","w",stdout)
string s,t;
signed main(){
	cin>>s>>t;
	t.erase(--t.end());
	printf(s==t?"Yes":"No");
	exit(0);
}


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

int main(){
  string s, t;
  cin>>s>>t;
  int x=stoi(s+t);
  for(int i=1; i<1000; i++){
    if(i*i==x){
      cout << "Yes"<< endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long L;
using namespace std;
  
#define U [100005]={}
map<L,L> path U;
L par U,dep U,siz U,hev U,cst U,add U,pos U,hl_par U,bit U,
k,n,a,b,c,p,r;
char s[5];
L dfs(L a){
    siz[a]=1;
    for(map<L,L>::iterator I=path[a].begin();I!=path[a].end();I++){
        L d=I->first;
        if(d-par[a]){
            par[d]=a;
            dep[d]=dep[a]+1;
            cst[d]=I->second;
            dfs(d);
            siz[a]+=siz[d];
            if(!hev[a]|siz[hev[a]]<siz[d])
                hev[a]=d;
        }
    }
}
    
L edgecost(L a){
    r=add[a]+add[par[a]]+cst[a];
    return r%k?r:0;
}
    
L sum(L i){
    for(r=0;i;r+=bit[i],i-=i&-i);
    return r;
}
L S(L i,L x){
    for(x=edgecost(x)-sum(i+1)+sum(i++);
        i<100005;bit[i]+=x,i+=i&-i);
}
  
main(){
    for(cin>>n>>k;p<n-1;p++)
        cin>>a>>b>>c,
        path[a][b]=path[b][a]=c;
    dfs(0);
    
    for(c=p=0;p<n;p++)
        if(!p|hev[par[p]]-p)
        for(a=p;!c|a;a=hev[a])
            pos[a]=c++,
            hl_par[a]=p,
            S(pos[a],hev[a]);
    
    for(cin>>a;cin>>s>>a>>b;)
        if(*s&2){
            for(c=0;p=hl_par[a],n=hl_par[b],p-n;a=par[p])
                dep[p]<dep[n]?swap(p,n),swap(a,b),0:0,
                c+=sum(pos[a])-sum(pos[p])+edgecost(p);
            cout<<c+abs(sum(pos[a])-sum(pos[b]))<<endl;
        }else
            add[a]+=b,
            S(pos[a],hev[a]),
            a?S(pos[a]-1,a):0;
}

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

#define HASH 1000003

typedef struct List {
	struct List *next;
	char *s;
	int l;
} list;

long long div_mod(long long x, long long y, long long z)
{
	if (x % y == 0) return x / y;
	else return (div_mod((1 + x / y) * y - x, (z % y), y) * z + x) / y;
}

long long pow_mod(int n, int k)
{
	if (k == 0 || n == 1) return 1;
	
	int i;
	long long N;
	for (i = 1, N = n; i * 2 <= k; i *= 2) N = N * N % HASH;
	return N * pow_mod(n, k - i) % HASH;
}

int hash_string(char* s)
{
	int i, x = 0;
	for (i = 0; s[i] != 0; i++) x = ((x << 5) + s[i] - 'a') % HASH;
	return x;
}

int lex_smaller(char* s1, char* s2)
{
	int i;
	for (i = 0; s1[i] != 0 && s2[i] != 0; i++) {
		if (s1[i] < s2[i]) return 1;
		else if (s1[i] > s2[i]) return -1;
	}
	if (s1[i] == s2[i]) return 0;
	else if (s1[i] == 0) return 1;
	else return -1;
}

int main()
{
	int i, j, l[200001], N;
	char *S[200001], T[1000001];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%s", T);
		for (l[i] = 0; T[l[i]] != 0; l[i]++);
		S[i] = (char*)malloc(sizeof(char) * (l[i] + 1));
		for (j = 0; j <= l[i]; j++) S[i][j] = T[j];
	}
	
	int h, H;
	list *p, *hash[HASH], d[200001];
	for (i = 1; i <= N; i++) {
		h = hash_string(S[i]);
		d[i].s = S[i];
		d[i].l = l[i];
		d[i].next = hash[h];
		hash[h] = &(d[i]);
	}
	
	int k, dp[26];
	long long ans = 0, tmp;
	for (i = 1; i <= N; i++) {
		if (l[i] <= 1) continue;
		for (j = 0; j <= l[i]; j++) T[j] = S[i][j];
		h = hash_string(&(T[2]));
		tmp = pow_mod(32, l[i] - 2);
		for (j = 0; j < 26; j++) dp[j] = 0;
		dp[S[i][0] - 'a'] = 1;
		for (j = 1; j < l[i]; j++) {
			dp[S[i][j] - 'a'] = 1;
			for (k = 0; k < 26; k++) {
				if (dp[k] == 0) continue;
				T[j] = 'a' + k;
				H = (tmp * k + h) % HASH;
				for (p = hash[H]; p != NULL; p = p->next) if (p->l == l[i] - j && lex_smaller(&(T[j]), p->s) == 0) break;
				if (p != NULL) ans++;
			}
			tmp = div_mod(tmp, 32, HASH);
			h = ((h - tmp * (S[i][j+1] - 'a')) % HASH + HASH) % HASH;
		}
	}
	
	printf("%lld\n", ans);
	fflush(stdout);
	return 0;
}

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

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

    int N;
    cin >> N;
    vector<int> a(N), b(N);
    for(int i = 0; i < N; i++) cin >> a[i];

    int M = 0;
    for(int i = N; i > 0; i--){
        int cnt = 0;
        for(int j = 1; j * i <= N; j++){
            if(b[j*i-1] == 1){
                cnt++;
            }
        }
        if(cnt%2 != a[i-1]){
            b[i-1] = 1;
            M++;
        }
    }

    cout << M << endl;
    for(int i = 0; i < N; i++){
        if(b[i] == 1){
            cout << (i+1) << endl;
        }
    }

    
    return 0;
}



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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
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; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	int n, k;
	char s[11], x;
	cin >> n;
	cin >> s;
	cin >> k;
	x = s[k - 1];
	rep(i, strlen(s)){
		if(s[i] != x) cout << '*';
		else cout << x;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
n, k = gets.split.map(&:to_i)
weights = []
n.times {weights << gets.to_i}

#最大積載量pのとき積める荷物の数
pack_num = ->(p) {
  i = truck_n = 0
  while truck_n < k
    truck_w = 0
    while i < n
      truck_w += weights[i]
      break if truck_w > p
      i += 1
    end
    truck_n += 1
  end
  i
}

left, right = 0.0, 100_000 * 10_000
until right - left < 1
  mid = (left + right) / 2
  num = pack_num.(mid)
  if num >= n
    right = mid
  else
    left  = mid
  end
end
puts right.to_i


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

int
main(){
    string s;
    cin >> s;
    set <char> c;
    for(auto i : s){
        c.insert(i);
    }
    if(c.size() == 3)
        cout << "Yes" << "\n";
    else
        cout << "No" << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
const int N=505;
const LL e9=((LL)(1e9+0.1));

int main(){
  //  freopen("in.txt","r",stdin);
   // freopen("out.txt","w",stdout);
    LL S,x1,y1,x2,y2,x3,y3,dy;
    cin>>S;
    if (S==((LL)(1e18+0.1))){puts("0 0 1000000000 0 0 1000000000");return 0;}
    x1=e9,dy=S/e9,S%=e9;
    y2=1,x3=S,y3=y2+dy;
    x2=y1=0;
    cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<" "<<x3<<" "<<y3<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
//合成数xはx**0.5以下の約数を持つ
int sosu(int x){
    
    bool ans=true;
    
    int y=pow(x, 0.5);
    for (int i=2; i<=y; i++){
        if (x%i==0 && x/i!=1){
            ans=false;
        }
    }
    if (ans){
        return 0; //素数
    }
    else{
        return 1; //合成数
    }
}

int main(){
    int x;
    cin>>x;
    
    int k=2;
    while(true){
        
        if (sosu(k)==0){
            if (k>=x){
                break;
            }
        }
        k++;
    }
    cout<<k<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;

int main(){
    int N; cin >> N;
    vector<int> B(N+1);
    B[0]=INF;B[N]=INF;
    for(int i=1;i<N;i++){
        cin >> B[i];
    }
    int sum=0;
    for(int i=0;i<N;i++){
        //cerr << min(B[i],B[i+1]) << " ";
        sum += min(B[i],B[i+1]);
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[][] A = new int[n][m];
		int[] b = new int[m];
		for(int i = 0; i<n; i++){
			for(int j = 0;j<m;j++){
				int number1 = sc.nextInt();
				 A[i][j] = number1;
			}
		}

		for(int i=0;i<m;i++){
			int number2 = sc.nextInt();
			b[i] = number2;
		}
		int result;
		for(int i = 0;i<n; i++){
		    result=0;
			for(int j = 0; j<m; j++){
				result += A[i][j] * b[j];
			}
		 System.out.printf("%d\n",result);
		}
	
	}
}


Measured memory_bytes: 40476
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pint;

int main(){
    string sa,sb,sc;
    cin>>sa>>sb>>sc;
    int ca,cb,cc;
    ca=cb=cc=0;
    char cur='a';
    while(1){
        if(cur=='a'){
            if(ca==sa.size()){
                cout<<'A'<<endl;break;
            }
            cur=sa[ca];
            ++ca;
        }
        else if(cur=='b'){
            if(cb==sb.size()){
                cout<<'B'<<endl;break;
            }
            cur=sb[cb];
            ++cb;
        }
        else if(cur=='c'){
            if(cc==sc.size()){
                cout<<'C'<<endl;break;
            }
            cur=sc[cc];
            ++cc;
        }
    }
    return 0;
}

Measured memory_bytes: 256
H,W,M = map(int,input().split())
hw = {tuple(map(int,input().split())) for _ in [0]*M}

INF = 3*10**5+10
H_cnt = [0]*INF
W_cnt = [0]*INF
for h,w in hw:
    H_cnt[h] += 1
    W_cnt[w] += 1

H_cnt = sorted(enumerate(H_cnt),key = lambda x:-x[1])
W_cnt = sorted(enumerate(W_cnt),key = lambda x:-x[1])

h1,nh1 = H_cnt[0]
w1,nw1 = W_cnt[0]
H_ans = [hi for hi,nhi in H_cnt if nhi == nh1]
W_ans = [wi for wi,nwi in W_cnt if nwi == nw1]
ans = nh1+nw1 - 1
if len(H_ans)*len(W_ans) >= INF:
    ans += 1
else:
    breakFlg = False
    for h in H_ans:
        for w in W_ans:
            if not ((h,w) in hw):
                ans += 1
                breakFlg = True
                break
        if breakFlg: break
print(ans)

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

int main (){
	int n,k;cin>>n>>k;
	string a;cin>>a;
	for (int i=0;i<k-1;i++)cout<<a[i];
	if (a[k-1]=='A') cout<<'a';
	if (a[k-1]=='B') cout<<'b';
	if (a[k-1]=='C') cout<<'c';
	if (a[k-1]=='D') cout<<'d';
	if (a[k-1]=='E') cout<<'e';
	if (a[k-1]=='F') cout<<'f';
	if (a[k-1]=='G') cout<<'g';
	if (a[k-1]=='H') cout<<'h';
	if (a[k-1]=='I') cout<<'i';
	if (a[k-1]=='J') cout<<'j';
	if (a[k-1]=='K') cout<<'k';
	if (a[k-1]=='L') cout<<'l';
	if (a[k-1]=='M') cout<<'m';
	if (a[k-1]=='N') cout<<'n';
	if (a[k-1]=='O') cout<<'o';
	if (a[k-1]=='P') cout<<'p';
	if (a[k-1]=='Q') cout<<'q';
	if (a[k-1]=='R') cout<<'r';
	if (a[k-1]=='S') cout<<'s';
	if (a[k-1]=='T') cout<<'t';
	if (a[k-1]=='U') cout<<'u';
	if (a[k-1]=='V') cout<<'v';
	if (a[k-1]=='W') cout<<'w';
	if (a[k-1]=='X') cout<<'x';
	if (a[k-1]=='Y') cout<<'y';
	if (a[k-1]=='Z') cout<<'z';
	for (int i=k;i<n;i++)cout<<a[i];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i = 0;i < n; i++)
#define REP(i,n) for(int i = 1;i <= n; i++)
// ----GCC ONLY---- //
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// ----        ---- //
#define ll long long
#define MOD 10000007
#define PB push_back

using namespace std;



int main(){

    int a,b;
    cin >> a >> b;

    if(a > b * 2){
        cout << a - b * 2 <<endl;
    }else{
        cout << 0 <<endl;
    }
    return 0;
    
}

Measured memory_bytes: 256