akhauriyash/Code-Regression huggingface dataset:
//@formatter:off
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<P>
#define vvp vector<vector<P>>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?"":","); return os<<']'; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << '\n'; }
void YES(bool b) { cout << (b ? "YES" : "NO") << '\n'; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
//@formatter:on

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int x;
    cin >> x;
    cout << 1-x << endl;
}

Measured memory_bytes: 3648
use std::io;
use std::str::FromStr;

fn input_int_tuple() -> (i32, i32) {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    let vec: Vec<i32> = line.split_whitespace().map(|s| s.parse().unwrap()).collect();
    (vec[0], vec[1])
}

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let (h, w) = input_int_tuple();
    let mut matrix: Vec<Vec<char>> = Vec::new();
    for i in 0..h {
        let row_str: String = input();
        let row: Vec<char> = row_str.chars().collect();
        let mut flag = false;
        for c in &row {
            if *c != '.' {
                flag = true;
                break;
            }
        }
        if flag {
           matrix.push(row); 
        }        
    }

    let mut skip_lines: Vec<i32> = Vec::new();
    for i in 0..w {
        let mut flag = false;
        for row in &matrix {            
            if row[i as usize] != '.' {
                flag = true;
                break;
            }
        }
        if !flag {
            skip_lines.push(i);
        }
    }

    for i in 0..matrix.len() {
        for j in 0..w {
            if !skip_lines.contains(&j){
                print!("{}", matrix[i][j as usize]);
            }
        }
        println!();
    }
}


Measured memory_bytes: 4352
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
def ten(n):
    if n % 10 == 0:
        return n // 10
    else:
        return n // 10 + 1
def per(n):
    if n % 10 == 0:
        return 0
    else:
        return 10 - n % 10
print((ten(a) + ten(b) + ten(c) + ten(d) + ten(e))*10 - max(per(a),per(b),per(c),per(d),per(e)))


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

N, Q = map(int, input().split())
S = input()

t = [0] * (N+1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i: i + 2] == 'AC' else 0)

for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Measured memory_bytes: 7748
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

int n;
vector<ll>a;
vector<ll>b;

int main()
{
  ll ans=0;
  ll m;

  cin >> n;
  a.resize(n); b.resize(n);
  for (int i=0; i<n; i++) {
    cin >> a[i];
  }
  m = a[0];
  b[0] = a[0];
  for (int i=1; i<n; i++) {
    if (a[i] < m) {
      b[i] = m;
    } else {
      b[i] = a[i];
    }
    if (a[i] > m) m = a[i];
  }
  for (int i=0; i<n; i++) {
    ans += b[i] - a[i];
  }

  cout << ans << endl;
  return 0;
}


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

const int COMMAX = 400001;
const int MOD = 1000000007;
vector<long long> Power2;

void Power2Init(void){
    long long j=1LL;
    Power2.push_back(1);
    for(int i=1; i<COMMAX; i++){
        j = j*2%MOD;
        Power2.push_back(j);
    }
}

int main(void){

    int N, Cbuf;
    vector<int> C;

    cin >> N;
    for(int i=0; i<N; i++){
        cin >> Cbuf;
        C.push_back(Cbuf);
    }

    Power2Init();

    sort(C.begin(), C.end(), greater<int>());

    long long res = 0LL;
    long long resbuf;

    for(int i=0; i<N; i++){
        if(i==0){
            resbuf = 1LL;
        }else{
            resbuf = i*Power2[i-1]%MOD+Power2[i];
            resbuf %= MOD;
        }
        res += C[i]*resbuf%MOD*Power2[N-i-1]%MOD;
        res %= MOD;
    }

    cout << res*Power2[N]%MOD << endl;

    return 0;
}

Measured memory_bytes: 7280
N,W = map(int,input().split())
w1,v = map(int,input().split())
wv = [[v],[],[],[]]
for i in range(N-1):
    w,v = map(int,input().split())
    wv[w-w1].append(v)
for i in range(4):
    wv[i]=[0] + sorted(wv[i],reverse=True)
# 累積和
for i in range(4):
    for j in range(1,len(wv[i])):
        wv[i][j] += wv[i][j-1]
ans = 0
hoge = [0,0,0,0]
for i in range(len(wv[0])):
    hoge[0] = wv[0][i]
    for j in range(len(wv[1])):
        hoge[1] = wv[1][j]
        for k in range(len(wv[2])):
            hoge[2] = wv[2][k]
            for l in range(len(wv[3])):
                hoge[3] = wv[3][l]
                if w1*(i+j+k+l)+j+2*k+3*l > W:
                    break
                else:
                    ans = max(ans,sum(hoge))
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip> // setprecision
#include <cmath>
#include <algorithm>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
const double long PI = acos(-1);

void solve() {
  ll N, i, tmp;
  vector <tuple<ll, ll>> A;

  cin >> N;
  for (i=0;i<N;i++) {
    cin >> tmp;
    A.push_back(make_tuple(i+1, tmp));
  }

  sort(A.begin(), A.end(),
    [](tuple<ll, ll> const &left, tuple<ll, ll> const &right) {
      return get<1>(left) < get<1>(right);
    }
  );

  for (i=0;i<N;i++) {
    cout << get<0>(A[i]) << ' ';
  }
  cout << endl;
}

int main(void) {
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 2544
import java.util.Scanner;
public class Main{
  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);
    String s = sc.next();

    int x = 0;

    for(int i = s.length()-1 ; i>0 ; i--){
      s = s.substring(0,i);
      String s1 = s.substring(0,i/2);
      String s2 = s.substring(i/2,i);

      if(s1.equals(s2)){
        x = i;
        break;
      }
    }
    System.out.println(x);
  }
}


Measured memory_bytes: 22612
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var A_University_point = new List<int>();
            var B_University_point = new List<int>();
            for (int i = 0; i < 10; i++)
            {
                A_University_point.Add(ReadInt());
            }
            for (int i = 0; i < 10; i++)
            {
                B_University_point.Add(ReadInt());
            }
            A_University_point.Sort();
            A_University_point.Reverse();
            B_University_point.Sort();
            B_University_point.Reverse();

            var A_University = A_University_point[0] + A_University_point[1] + A_University_point[2];
            var B_University = B_University_point[0] + B_University_point[1] + B_University_point[2];
            WriteLine(A_University + " " + B_University);
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 17992
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

int main(){
    Init();
    ll r, g; cin >> r >> g;
    cout << 2*g-r << endl;
}

Measured memory_bytes: 256
n=int(input())
a=[list(map(int,input().split())) for _ in range(n)]
t,x,y=0,0,0
for T,X,Y in a:
    if T-t<X-x+Y-y or (T+X+Y)%2==1:
        print("No")
        exit()
    t,x,y=T,X,Y    
print("Yes")  

Measured memory_bytes: 27300
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,stra,straa;
    ll x,y,z;
    char ca,cb,cc;
    cin>>a>>b>>c;
    cout<<a*b/2<<endl;


    

    return 0;
}


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

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define output(x) cout << ( x ? "Yes" : "No" ) << '\n' ;
#define mxn 100005
using namespace std;

void solve(){
	string s;
	cin >> s;
	int ans = 0;
	for(int i = 0; i < (int)s.size(); i++)
		ans += (s[i] - '0');
	output(ans % 9 == 0);
}

int32_t main()
{
	FLASH
	int t = 1;
	// cin >> t;
	while(t--){
		solve();
	}
	return 0;
}



Measured memory_bytes: 3732
#! /usr/bin/env python3

# from math import gcd
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement

import math
N, D = [int(_) for _ in input().split()]
XY = [[int(_) for _ in input().split()] for i in range(N)]

ret = 0
for x, y in XY:
    if math.sqrt(x**2 + y**2) <= D:
        ret += 1
print(ret)

Measured memory_bytes: 43716
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#define re register
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(arr) memset(arr, 0, sizeof(arr))
const int inf = 0x3f3f3f3f;
ll a,b,c;
int main() 
{
    cin>>a>>b>>c;
    if(a%2==0||b%2==0||c%2==0) {
        cout<<0;
        return 0;
    }
    cout<<min(min(a*b,a*c),b*c);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=a;i<int(b);i++)
using namespace std;
int main()
{
    int a, b, c, d;
    string s;
    cin >> s;
    a = s[0] - '0';
    b = s[1] - '0';
    c = s[2] - '0';
    d = s[3] - '0';
    char pm[] = { '+', '-' };
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            for (int k = 0; k < 2; k++) {
                int sum = a;
                if (i == 0) sum += b; else sum -= b;
                if (j == 0) sum += c; else sum -= c;
                if (k == 0) sum += d; else sum -= d;
                if (sum == 7) {
                    cout << a << pm[i] << b << pm[j] << c << pm[k] << d << "=7" << endl;
                    return 0;
                }
            }
        }
    }
}


Measured memory_bytes: 256
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int d[6];
void roll(char c){
	int t;
	if(c=='s')rep(i,3)roll('n');
	if(c=='w')rep(i,3)roll('e');
	if(c=='n')t=d[0],d[0]=d[4],d[4]=d[5],d[5]=d[1],d[1]=t;
	if(c=='e')t=d[0],d[0]=d[2],d[2]=d[5],d[5]=d[3],d[3]=t;
}
int main(){
	int n;char buf[9];
	while(cin>>n,n){
		rep(i,6)d[i]=i+1;
		rep(i,n)cin>>buf,roll(buf[0]);
		cout<<d[0]<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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 N,M,sum;

int main(){
    cin>>N;
    int T[N];
    rep(i,N)cin>>T[i];
    cin>>M;
    int P[M],X[M];
    rep(i,M)cin>>P[i]>>X[i];
    rep(i,N)sum+=T[i];
    rep(i,M)out(sum-(T[P[i]-1]-X[i]));
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void) {
	int a, b, d, r;
	double f;
	
	scanf("%d%d", &a, &b);
	
	d = a / b;
	r = a % b;
	f = (double)a / b;
	
	printf("%d %d %.8lf\n", d, r, f);
	return 0;

}


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

#define ln '\n'
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VI a(n), b(n), c(n - 1);
    REP(i, n) {
        cin >> a[i];
        a[i]--;
    }
    REP(i, n) cin >> b[i];
    REP(i, n - 1) cin >> c[i];

    int ans = 0;
    REP(i, n) ans += b[a[i]];
    REP(i, n - 1) {
        if (a[i + 1] == a[i] + 1) ans += c[a[i]];
    }
    cout << ans << ln;
    return 0;
}


Measured memory_bytes: 3616
#include <vector>
#include <iostream>
using namespace std;
int main() {
	int N; long long X;
	cin >> N >> X;
	vector<long long> a(N + 1), b(N + 1);
	a[0] = 1, b[0] = 1;
	for (int i = 1; i <= N; ++i) {
		a[i] = 2 * a[i - 1] + 3;
		b[i] = 2 * b[i - 1] + 1;
	}
	long long ans = 0;
	for (int i = N - 1; i >= 0 && X > 0; --i) {
		--X;
		if (X >= a[i]) {
			X -= a[i];
			ans += b[i];
			if (X >= 1) {
				--X;
				++ans;
				if (X >= a[i]) {
					X -= a[i];
					ans += b[i];
					if (X >= 1) --X;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

class Progaram
{
    static void Main(string[] args)
    {
        var n = Int32.Parse(Console.ReadLine());
        var res = 0;
        for (var i = 0; n > i; i++)
        {
            var sit = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
            res += sit[1] - sit[0] + 1;
        }
        Console.WriteLine(res);
    }
}

Measured memory_bytes: 13268
import java.util.Scanner;
 
class Main{
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double r = scanner.nextDouble();
        System.out.printf("%.6f %.6f\n", r * r * Math.PI, r * 2 * Math.PI);
        scanner.close();
        
    }
}





Measured memory_bytes: 28108
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//ngcd n個の最大公約数
ll ngcd(vector<ll> a){
  ll res;
  res = a[0];
  for(ll i = 1; i < a.size() && res != 1; i++) {
    res = gcd(a[i], res);
  }
  return res;
}
//nlcm n個の最小公倍数
ll nlcm(vector<ll> a) {
  ll res;
  res = a[0];
  for (ll i = 1; i < a.size(); i++) {
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(ll x){
  ll i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
ll digsum(ll x){
  ll res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int n;
  int ans = 0;
  cin >> n;
  for(int i = 1; i*i <= n; i++){
    ans = max(ans, i*i);
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int N;

    scanf("%d", &N);

    int i;

    for(i = 9; i >= 1; i--){
        if(N % i == 0){
            break;
        }
    }
    if(i == 0){
        printf("No\n");
    }else if(N / i <= 9){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}

Measured memory_bytes: 128
import sys
input = sys.stdin.readline
import numpy as np
N, W = map(int, input().split())
w, v = [], []
for i in range(N):
    a, b = map(int, input().split())
    w += [a]
    v += [b]

DP = np.zeros(W+1, dtype=int)
# i 円以下で買える商品の最大価値
for i in range(N):
    DP[w[i]:] = np.maximum(DP[:-w[i]]+ v[i], DP[w[i]:])
print(DP[-1])

Measured memory_bytes: 15496
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	map<int, int> vmap;
	int N;
	cin >> N;
	int A;
	int ans = 0;
	rep(i, 0, N)
	{
		cin >> A;
		vmap[A]++;
	}
	for (auto p : vmap)
	{
		if (p.first < p.second)
		{
			ans += p.second - p.first;
		}
		if (p.first > p.second)
		{
			ans += p.second;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6272
#include<iostream>
#include<vector>
#include<string>
#include<set>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<functional>
#include<numeric>
 
using namespace std;
  
int main() {	
	int n;
	cin >> n;
	vector<int> a(n);
	long long sum{ 0 };
	for (auto& e : a) {
		cin >> e;
		sum += e;
	}
	long long p, q, r, s;
	long long dif, ans;
	ans =1000000000000;
	int i, j, k;
	i = 0;
	j = 1;
	k = 2;
	p = a[0];
	q = 0;
	r = a[1]+a[2];
	s = sum - (p+q+r);
	for (j=1; j < n - 1; j++) {
		q += a[j];
		r -= a[j];
		while (i<j-1&&q - p >= a[i+1]) {
			i++;
			p += a[i];
			q -= a[i];
		}
		while (k<n-1&&s - r >= a[k+1]) {
			k++;
			r += a[k];
			s -= a[k];
		}
		dif = max(max(p, q), max(r, s)) - min(min(p, q), min(r, s));
		ans = min(dif, ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, K = mapint()
Ps = list(mapint())

def segfunc(x, y):
    return min(x, y)

def segfunc_2(x, y):
    return max(x, y)

class SegTree:
    """
    init(init_val, ide_ele): 配列init_valで初期化 O(N)
    update(k, x): k番目の値をxに更新 O(logN)
    query(l, r): 区間[l, r)をsegfuncしたものを返す O(logN)
    """
    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

if N==K:
    print(1)
    exit()
seg_min = SegTree(Ps, segfunc, 10**18)
seg_max = SegTree(Ps, segfunc_2, -1)

str_set = set()
cnt = 1
old = 10**18
is_increase = [0]*N
for i in range(N):
    p = Ps[i]
    if p>old:
        cnt += 1
        is_increase[i] = cnt
    else:
        cnt = 1
        is_increase[i] = cnt
    old = p

original = 0
ans = N-K+1
for i in range(N-K):
    mini = Ps[i]
    maxi = Ps[i+K]
    if is_increase[i+K-1]>=K:
        original = 1
        ans -= 1
    elif (seg_min.query(i, i+K+1)==mini and seg_max.query(i, i+K+1)==maxi):
        ans -= 1
if is_increase[-1]>=K:
    original = 1
    ans -= 1
print(ans+original)

Measured memory_bytes: 99060
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 1000000000
#define InfLL 1000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=(n-1);(i)>=(0);(i)--)
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

int main() {
	int N, M;
	cin >> N >> M;
	vi A(N);
	int Asum = 0;
	rep(i, N) {
		cin >> A[i];
		Asum += A[i];
	}
	int count = 0;
	rep(i, N) {
		if (A[i] * 4 * M >= Asum)
			count++;
	}
	string ans = (count >= M) ? "Yes" : "No";


	cout << ans << endl;
	return 0;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define ALL(name) name.begin(),name.end()
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

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

    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    REP(i, N) {
        cin >> A[i];
        A[i]--;
    }
    REP(i, N) { cin >> B[i]; }
    REP(i, N - 1) { cin >> C[i]; }

    int ans = 0;
    int prev = INF;
    for(auto& i : A) {
        ans += B[i];
        if(prev == i - 1) {
            ans += C[prev];
        }
        prev = i;
    }

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

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}

signed main(void) {
    int n,t;
    cin >> n >> t;
    vi a(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    vi num(n);
    int l = 0;
    loop(r,1,n){
        while(a[l] < a[r] - t)l++;
        num[r] = r-l;
    }
    vi dp(n+1);
    dp[0] = 1;
    rep(i,n)dp[i+1] = dp[i] * (num[i]+1) % MOD;
    cout << dp[n] << endl;
}



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

ll Ep(int a){
  if(a == 0) return 1;
  if(a == 1) return 2;
  ll num = Ep(a/2);
  if(a%2) return num *num *2;
  else return num *num;
}

int main(){
  int n;
  ll k, ai;
  cin >> n >> k;
  vector<int> cnt(45,0);
  for(int i=0; i<n; ++i){
    cin >> ai;
    int keta = 0;
    while(ai > 0){
      cnt[keta] += ai%2;
      ai /= 2;
      ++keta;
    }
  }
  vector<vector<ll>> dp(45, vector<ll>(2,0));
  for(int i=43; i>=0; --i){
    ll num = Ep(i);
    if(dp[i+1][0]){
      dp[i][0] = dp[i+1][0] +num *max(cnt[i],n-cnt[i]);
    }
    if(k >= num){
      dp[i][1] = dp[i+1][1] +num *(n-cnt[i]);
      dp[i][0] = max(dp[i][0],dp[i+1][1] +num *cnt[i]);
    }else{
      dp[i][1] = dp[i+1][1] +num *cnt[i];
    }
    if(k >= num) k -= num;
  }
  ll ans = max(dp[0][0], dp[0][1]);
  cout << ans << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}


int main(void) {
  ll N, M;
  cin >> N >> M;
  ll k[11], s[11][11], p[11];
  ll i, j, l, m, n;
  
  for(i=0; i<M; i++) {
    cin >> k[i];
    for(j=0; j<k[i]; j++) {
      cin >> s[i][j];
      s[i][j]--;
    }
  }
  
  for(i=0; i<M; i++) {
    cin >> p[i];
  }
  
  ll ans=0;
  for(i=0; i<1<<N; i++) {
    vector<ll> v;
    for(j=0; j<N; j++) {
      if(1&i>>j) {
        v.pb(j);
      }
    }
    
    ll flag=1;
    for(l=0; l<M; l++) {
      ll cnt=0;
      
      for(m=0; m<k[l]; m++) {
        ll a=s[l][m];
        
        ll f=0;
        for(n=0; n<v.size(); n++) {
          if(a==v[n]) f=1;
        }
        
        if(f) cnt++;
      }
      
      if(cnt%2!=p[l]) {
        flag=0;
      }
    }
    
    if(flag) ans++;
    
  }
  
  
  pt(ans);
  
}












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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os<<"("<<p.first<<","<<p.second<<")";
    return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os<<"{";
    rep(i, v.size()) {
        if (i) os<<",";
        os<<v[i];
    }
    os<<"}";
    return os;
}

const int maxn = 200010;
bool f[maxn];

int main() {
    int N; cin >> N;
    for (int i = 1; i <= N; ++i) {
        int x; cin >> x;
        f[i] = x;
    }
    V<int> ans;
    for (int i = N; i >= 1; --i) {
        for (int j = i * 2; j <= N; j += i) {
            f[i] ^= f[j];
        }
        if (f[i]) ans.pb(i);
    }
    cout << ans.size() << endl;
    rep(i, ans.size()) cout << ans[i] << (i + 1 == ans.size() ? "\n" : " ");

    return 0;
}

Measured memory_bytes: 1912
#!/usr/bin/env python3
import sys


def solve(N: int, M: int, X: int, A: "List[int]"):
    l, r = 0, 0
    for a in A:
        if a < X:
            l += 1
        else:
            r += 1
    ret = min(l, r)
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(M) ]  # type: "List[int]"
    solve(N, M, X, A)

if __name__ == '__main__':
    main()


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

int main() {
  int64_t n, k;
  std::cin >> n >> k;
  std::set<int64_t> a;
  std::multiset<int64_t> b;

  for (int64_t i = 0; i < n; i++) {
    int64_t p;
    std::cin >> p;
    a.insert(p);
    b.insert(p);
  }

  if (a.size() <= k) {
    std::cout << 0 << std::endl;
  } else {
    std::vector<int64_t> c;
    c.reserve(a.size());
    for (const auto i : a) {
      c.push_back(b.count(i));
    }
    std::sort(c.begin(), c.end());

    int64_t count = 0;
    for (int64_t i = 0; i < a.size() - k; i++) {
      count += c[i];
    }
    std::cout << count << std::endl;
  }
  return 0;
}


Measured memory_bytes: 20608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int d, t, s;
  cin >> d >> t >> s;
  if (s*t >= d)
  {
    cout << "Yes" << endl;
  }else
  {
    cout << "No" << endl;
  }
  
  
  return 0;
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

void solve ( int test_case )
{
    int n ;
    cin >> n ;

    string a , b ;
    cin >> a >> b ;

    for ( int i=0 ; i < n ; i ++ )
        cout << a[i] << b[i] ;
    line
}

int main()
{
    int t = 1;
    // cin >> t;

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


Measured memory_bytes: 256
s = int(input())
ans = [s]
fr = 0
for i in range(1,10**4):
    if s == 1:
        print(4)
        break
    if s  == 2:
        print(4)
        break
    if fr > 0:
        break
    if ans[i-1] % 2 == 0:
        for j in ans:
            if j == ans[i-1]/2:
                print(i)
                fr += 1
                break
        ans.append(ans[i-1]//2)
    else:
        for j in ans:
            if j == ans[i-1]/2:
                print(i)
                fr += 1
                break
        ans.append(3*ans[i-1]+1)

Measured memory_bytes: 38640
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int N=105;
int a[N];
int main (){
	int n,ans=0;
	scanf ("%d",&n);
	for (int i=1;i<=(n<<1);i++) scanf ("%d",&a[i]);
	sort(a+1,a+(n<<1)+1);
	for (int i=1;i<=n;i++) ans+=a[(i-1)<<1|1];
	printf ("%d",ans);
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define dump(x) cerr << #x << " = " << (x) << endl;
typedef long long LL;
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = (int)1e9;
const long long mod = (long long)1e9 + 7;
const double pi = acos(-1.0);

template <class T>void Sort(vector<T> & a) { sort(a.begin(), a.end()); }
template <class T>void ReSort(vector<T>& a) { sort(a.rbegin(), a.rend()); }
template <class T>void Reverse(vector<T>& a) { reverse(a.begin(), a.end()); }
template <class T>void Unique(vector<T>& a) { a.erase(unique(a.begin(), a.end()), a.end()); }
template <class T>T Sum(vector<T> a, T init = 0) { return accumulate(a.begin(), a.end(), init); }

//INPUT//
void CINPUT() {}
template<class H, class ...T> void CINPUT(H&& h, T&& ...t) { cin >> h; CINPUT(forward<T>(t)...); }
#define in(...) int __VA_ARGS__; CINPUT(__VA_ARGS__);
#define In(T,...) T __VA_ARGS__; CINPUT(__VA_ARGS__);
#define Vin(T,name,n) int n; cin>>n; vector<T> name(n); rep(i,n)cin>>name[i];
#define VIn(T,name,n) vector<T> name(n); rep(i,n)cin>>name[i];
#define VIn2(T,name,name2,n) vector<T> name(n),name2(n); rep(i,n)cin>>name[i]>>name2[i];

//OUTPUT//
void print() { cout << endl; }
template <class H> void print(H&& h) { cout << h << endl; }
template <class H, class... T> void print(H&& h, T&& ... t) { cout << h << " "; print(forward<T>(t)...); }
template<class T>void out(T n) { cout << n << endl; }
template<class T>void out(vector<T> a, string sep = " ", string end = "\n") { for (int i = 0; i < (int)a.size(); ++i)cout << a[i] << (i == (int)a.size() - 1 ? end : sep); }
void yes(bool f) { puts(f ? "yes" : "no"); }
void Yes(bool f) { puts(f ? "Yes" : "No"); }
void YES(bool f) { puts(f ? "YES" : "NO"); }
void poss(bool f) { puts(f ? "possible" : "impossible"); }
void Poss(bool f) { puts(f ? "Possible" : "Impossible"); }
void POSS(bool f) { puts(f ? "POSSIBLE" : "IMPOSSIBLE"); }

int main() {
	VIn(LL, a, 3);
	if (a[0] % 2 == 0 || a[1] % 2 == 0 || a[2] % 2 == 0) {
		out(0);
	}
	else {
		Sort(a);
		out(a[0] * a[1]);
	}
}


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

#define endl '\n'
#define pb push_back
#define mod 1000000007
typedef int integer;
#define int long long
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 0
#endif
using namespace std;

template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << ": " << arg1 << endl;
}

template<typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int powmod(int a, int b) {
    int res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1)res = res * a % mod;
        a = a * a % mod;
    }
    return res;
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

const integer NN = (int) 5e5 + 2;
int ar[NN];
int n, m;


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

    cin >> n;
    if (n >= 30){
        cout << "Yes\n";
    } else cout << "No\n";

}


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

sum = [0 for i in range(n+1)]
for i in range(n - 1, -1, -1):
    sum[i] = sum[i + 1] + a[i]
ans = 0
for i in range(n):
    ans = (ans+(a[i]*sum[i+1])) % 1000000007
print(ans)


Measured memory_bytes: 31520
import java.util.*;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        char alphabet[] = new char[26];

        char c = 'a';

        for(int i = 0; i < 26; i++){
            alphabet[i] = c++;
        }

        long n = sc.nextLong();

        List<Integer> list = new ArrayList<>();

        int k = 0;
        while(true){
            k++;
            long p = n % 26;

            if(p == 0) {
                list.add(26);
                if((n / 26) - 1 == 0){
                    break;
                }
                n = (n / 26) - 1;
            }else{
                list.add((int)p);
                if(n / 26 == 0){
                     break;
                }
                n /= 26;
            }
        }

        StringBuilder sb = new StringBuilder();

        for(int j = 0; j < k ; j++){
            sb.append(alphabet[list.get(j) - 1]);
        }

        System.out.println(sb.reverse());

    }
}


Measured memory_bytes: 35852
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<vector>
#include<set>
#include<iomanip>
#include<cmath>
using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912
const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int N;
int a,b,c;
int main(){
    cin >> N;
    vector<int> adp(N+1,0),bdp(N+1,0),cdp(N+1,0);
    cin >> a >> b >> c;
    adp[0] = a; bdp[0] = b; cdp[0] = c;
    for(int i = 1; i < N; i++){
        cin >> a >> b >> c;
        adp[i] = a + max(bdp[i-1],cdp[i-1]);
        bdp[i] = b + max(adp[i-1],cdp[i-1]);
        cdp[i] = c + max(adp[i-1],bdp[i-1]);
    }
    cout << max(adp[N-1],max(bdp[N-1],cdp[N-1])) << endl;
}



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

int main() {
    int h, w;
    cin >> h >> w;

    vector<string> s(h);
    for (auto& e : s) cin >> e;
    
    vector<vector<int>> left(h, vector<int>(w)), right(h, vector<int>(w)), up(h, vector<int>(w)), down(h, vector<int>(w));
    
    for (int y=0; y<h; y++) {
        left[y][0] = (s[y][0] == '.' ? 1 : 0);
        for (int x=1; x<w; x++) {
            left[y][x] = (s[y][x] == '.' ? left[y][x-1] + 1 : 0);
        }
    }

    for (int y=0; y<h; y++) {
        right[y][w-1] = (s[y][w-1] == '.' ? 1 : 0);
        for (int x=w-2; x>=0; x--) {
            right[y][x] = (s[y][x] == '.' ? right[y][x+1] + 1 : 0);
        }
    }

    for (int x=0; x<w; x++) {
        up[0][x] = (s[0][x] == '.' ? 1 : 0);
        for (int y=1; y<h; y++) {
            up[y][x] = (s[y][x] == '.' ? up[y-1][x] + 1 : 0);
        }
    }

    for (int x=0; x<w; x++) {
        down[h-1][x] = (s[h-1][x] == '.' ? 1 : 0);
        for (int y=h-2; y>=0; y--) {
            down[y][x] = (s[y][x] == '.' ? down[y+1][x] + 1 : 0);
        }
    }

    vector<vector<int>> sum(h, vector<int>(w));
    for (int y=0; y<h; y++) {
        for (int x=0; x<w; x++) {
            sum[y][x] = left[y][x] + right[y][x] + up[y][x] + down[y][x];
        }
    }

    int ans = 0;
    for (auto& e : sum) {
        ans = max(ans, *max_element(e.begin(), e.end()));
    }

    cout << ans - 3 << endl;
}


Measured memory_bytes: 82944
#include <bits/stdc++.h>
using namespace std;
//*******************
// Mahmoud Magdy    *
//*******************
#define ll long long
#define endl "\n"

void fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int D()
{
    int m ;
    cin>>m;
    return m ;
}
inline ll lD()
{
    ll m ;
    cin>>m;
    return m ;
}
inline double dD()
{
    double m ;
    cin>>m;
    return m ;
}
int main()
{
        string a,b;
        cin>>a>>b;
        a+=b;
        int n=atoi(a.c_str());
        int flag=true;
        for(int i=1 ; i <= 1000 ; ++i){
            if(i*i==n){
                flag=false;
                break;
            }
        }
if(flag==false){
	cout<<"Yes\n";

}else{
	cout<<"No\n";
}
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define int long long
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
#define INF 1000000000000000000
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
unsigned day;

// day ← (最初の dow 曜日の日付)－１
if(dow < dow1) dow += 7;
day = dow - dow1;

// day ← ｎ回目の dow 曜日の日付 (day + 7 * (n - 1) + 1)
day += 7 * n - 6;
return day;
}
unsigned DayToWeekNumber(unsigned day)
{
  return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
  return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main(){
  int N;
  cin>>N;
  vector<double>A(N);
  vector<int>B(N);
  long double answer=0;
  for(int i=0;i<N;i++){
    cin>>A[i];
    B[i]=A[i];
    if(A[i]==0){
      cout<<0<<endl;
      return 0;
    }
    answer+=log10(A[i]);
  }
  int ans=1;
  if(answer>18)cout<<-1<<endl;
  else{
    rep(i,N)ans*=B[i];
    if(ans>INF)cout<<-1<<endl;
    else cout<<ans<<endl;
  }
}

Measured memory_bytes: 4872
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i, c) for(long long i=0; i<(long long)c; i++)
const ll INF=1000000000000001;
int main() {
	int n;
	int ans=0;
	cin >> n;
	ans = 1000-(n %1000);
	if (ans==1000)ans=0;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3628
console.log((args=>{
  const [S,T] = args.trim().split('\n');
  const L = S.length, a = 'a'.charCodeAt(0);
  const m = Array(26).fill('');
  for ( let i = 0; i < L; i++ ) {
    const s = S.charCodeAt(i) - a;
    if ( !m[s] ) m[s] = T[i];
    else if ( m[s] !== T[i] ) return 'No';
    const t = T.charCodeAt(i);
    if ( !m[t] ) m[t] = S[i];
    else if ( m[t] !== S[i] ) return 'No';
  }
  return 'Yes';
})(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 33904
import numpy as np

D, G, *pc = map(int, open(0).read().split())
pc = list(zip(*[iter(pc)]*2))
p, c = np.array([]), np.array([])
for (x,y) in pc:
    p = np.append(p, x)
    c = np.append(c, y)
    
import numpy as np
import math

base_points = np.array([i*100 for i in range(1, D+1)])

ans = []

for i in range(2**D):
    bit_flag = np.array(list(map(int, format(i, '0%db' %D))))
    points = sum(bit_flag * (c + p*base_points))
    solved_num = sum(bit_flag * p)
    
    if points >= G:
        ans.append(solved_num)

    else:
        remained = G - points
        remained_problems = sorted((bit_flag==False) * np.array(range(1, D+1)), reverse=True)
        i = 0

        while True:
            if remained <= 0:
                break
                
            highest_p = remained_problems[i]

            if math.ceil(remained / (highest_p * 100)) <= p[highest_p - 1]:
                solved_num += math.ceil(remained / (highest_p * 100))
                remained -= (math.ceil(remained / (highest_p * 100)) * highest_p * 100)
            else:
                solved_num += p[highest_p - 1]
                remained -= (highest_p * 100 * p[highest_p - 1] + c[highest_p - 1])
                i += 1

        ans.append(solved_num)
        
print(int(min(ans)))

Measured memory_bytes: 27276