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

int main()
{
    ll n;
    cin>>n;
    ll ar[n+1],dp[n+1];
    for(ll i=1; i<=n; i++ )
    {
        cin>>ar[i];
    }
    dp[n]=0;
    dp[n-1]=abs(ar[n-1]-ar[n]);
    for(ll i=n-2;i>=1;i--)
    {
        dp[i]=min(dp[i+1]+abs(ar[i+1]-ar[i]),dp[i+2]+abs(ar[i+2]-ar[i]));
    }
    cout<<dp[1];
}


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

int main(){
  int n,a,b;
  char s[4];
  cin>>s;
  sort(s,s+4);
  if(s[0]==s[1]&&s[2]==s[3]&&s[0]!=s[2])cout<<"Yes";
  else cout<<"No";
}

Measured memory_bytes: 256
def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a%b)
def make_divisors(n):
  lower_divisors , upper_divisors = [], []
  i = 1
  while i*i <= n:
    if n % i == 0:
      lower_divisors.append(i)
      if i != n // i:
        upper_divisors.append(n//i)
    i += 1
  return lower_divisors + upper_divisors[::-1]
A,B,K=map(int,input().split())
c=gcd(A,B)
print(make_divisors(c)[-K])

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

class Ho{
  static void Main(){
    var n = int.Parse(Console.ReadLine());
    var mytable = new Dictionary<string, int>();
    for(var i = 0;i<n;i++){
      var a = Console.ReadLine();
      if(mytable.ContainsKey(a)){
       mytable[a] +=1;
       continue;
      }
      mytable.Add(a,1);
    }
   var said = mytable.Values.Max();;
   var kotae = new List<string>();
   //Console.WriteLine(said);
   foreach(var d in mytable){
       if(d.Value != said){continue;}
       kotae.Add(d.Key);
   }
   
   kotae.Sort(StringComparer.OrdinalIgnoreCase);

//並び替えた結果を表示する
   Console.WriteLine(string.Join("\n", kotae));
  }
}

Measured memory_bytes: 51576
import math

def cal(n):
    if n == 1:
        return 0
    else:
        return (n-1)+cal(n-1)
n = int(input())
x = [None]*n
y = [None]*n
total = 0
for i in range(n):
    x[i], y[i] = map(int, input().split())

for i in range(n):
    for j in range(n):
        total += math.sqrt((x[i]-x[j])**2 + (y[i]-y[j])**2)
total = total/2
ans = total*(n-1)/cal(n)

print(ans)

Measured memory_bytes: 9212
/*
	Name:
	Author: xiaruize
	Date:
*/
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second
#define ll long long
#define fir first
#define sz(a) int((a).size())

signed main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	string s;
	ll cnt=0;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
	   cnt+=s[i]-'0';
	}
	cout<<(cnt%9==0?"Yes":"No")<<endl;
	return 0;
}

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

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

template<class T> using v = std::vector<T>;
template<class T> using vv = v<v<T>>;

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

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

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin >> n;
    ll ans = 0;

    for(ll i = 1; i <= n; i++) {
        if (i % 3 == 0|| i % 5 == 0) {
            continue;
        }
        ans += i;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define ss second
#define ff first
#define all(x) x.begin(), x.end()
 
using namespace std;
using ll = long long;
using pii = pair<ll, ll>;
 
const ll oo = 1e11 + 7;
const int mod = 1e9 + 7, maxn = 1000010;
const long double PI = acos(-1);


int main (){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n, W, base;
    cin >> n >> W;

    vector<vector<ll>> dp(n+1, vector<ll> ((n+1)*4, -1));
    vector<ll> v(n), w(n);

    for (int i=0; i<n; i++){
        cin >> w[i] >> v[i];
    }
    base = w[0];
    dp[0][0] = 0;

    for (int i=0; i<n; i++){
        ll sobra = w[i] - base;

        for (int j=n; j>=1; j--){
            for (int k=n*4; k>=sobra; k--){
                if (dp[j-1][k-sobra] != -1){
                    dp[j][k] = max(dp[j-1][k-sobra] + v[i], dp[j][k]);
                }
            }
        }
    }

    ll ans = 0;

    for (int i=0; i<=n; i++){
        for (int j=0; j<=n*4; j++){
            if (i*base + j > W) break;
            ans = max(dp[i][j], ans);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3740
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    cin>>a;
    char c;
    vector<int> s(14);
    vector<int> h(14);
    vector<int> cc(14);
    vector<int> d(14);
    for(int i = 0;i<a;i++){
        cin>>c;
        if(c == 'S'){
            cin>>b;
            s.at(b)=b;
        }
     else    if(c == 'H'){
            cin>>b;
            h.at(b)=b;
        }
     else   if(c == 'C'){
            cin>>b;
            cc.at(b)= b;
        }
       else if(c =='D'){
            cin>>b;
            d.at(b)=b;
        }
    }
    for(int i = 1;i<=13;i++){
        if(s.at(i) == 0)cout<<"S "<<i<<endl;
    }
    for(int i = 1;i<=13;i++){
        if(h.at(i) == 0)cout<<"H "<<i<<endl;
    }
    for(int i = 1;i<=13;i++){
        if(cc.at(i) == 0)cout<<"C "<<i<<endl;
    }
    for(int i = 1;i<=13;i++){
        if(d.at(i)==0)cout<<"D "<<i<<endl;
    }
}



Measured memory_bytes: 3084
N,H=map(int, input().split())
ab=[list(map(int,input().split())) for i in range(N)]
ab=sorted(ab,key=lambda x: x[1],reverse=True)
best=0
throw=0
damage=0
for a,b in ab:
    best=max(best,a)
    if b<best:
        break
    throw+=1
    damage+=b
    if damage>=H:
        break
import math
slash=max(0,math.ceil((H-damage)/best))
print(slash+throw)

Measured memory_bytes: 29696
use std::io::*;

fn main(){
    let n : usize = input();
    let p : Vec<usize> = (0..n).map(|_| input()).collect();
    let mut ans = 0;
    for i in 1..(n - 1){
        if (p[i - 1] > p[i] && p[i] > p[i + 1]) || (p[i - 1] < p[i] && p[i] < p[i + 1]){
            ans += 1;
        }
    }
    println!("{}", ans);
}

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

Measured memory_bytes: 4352
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

N = getN()
F = []
for i in range(N):
    # 各数字をstrに変換
    f = list(map(str, input().split()))
    # join
    falta = ''.join(f)
    # 二進数に変換
    F.append(int(falta, 2))
P = []
for i in range(N):
    p = getList()
    P.append(p)
# -10 ** 7ぐらいだとばか小さい数にならずWA
# ばかでかい数、ばか小さい数にするときは思いっきりばかでかく、小さくしよう
ans = -10 ** 24
# bit全探索するため状態を生成
# 0000000000はダメ（必ず店は開く）
for bit in range(1, 1 << 10):
    sum = 0
    # 各お店と照合
    for i in range(N):
        open = F[i] & bit
        # 二進数表記でのフラグの数をカウント
        index = str(bin(open)).count('1')
        sum += P[i][index]
    ans = max(ans, sum)
print(ans)

Measured memory_bytes: 41836
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(){
    int k, x;
    scanf("%d%d", &k, &x);
    if ((500 * k) >= x)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

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

#define FOR(i, a, b) for(int i = a; i < b; i ++)
#define FORS(i, a, b, c) for(int i = a; i < b; i += c)
#define FORN(i, a, b) for(int i = a; i <= b; i ++)
#define FORD(i, a, b) for(int i = a-1; i >= b; i --)
#define FORE(i, b) for(auto &i:b)
#define REP(i, b) FOR(i, 0, b)
#define REPN(i, b) FORN(i, 0, b)
#define SQ(i) (i*i)
#define ALL(a) a.begin(), a.end()
#define ALLA(a,n) a, a+n
#define SORT(a) sort(ALL(a))
#define SORTA(a, n) sort(ALLA(a, n))
#define REV(a) reverse(ALL(a))
#define REVA(a, n) reverse(ALLA(a, n))
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define IN(a, b) (a.find(b) != a.end())
#define BACK(a) a.back(); a.RB()
#define QBACK(a) a.top(); a.pop()
#define PRINT(a) FORE(i, a) cout << i << " "; cout << endl

#define PB  push_back
#define RB  pop_back
#define RF  pop_front
#define INS insert
#define F   first
#define S   second
#define UM  unordered_map
#define US  unordered_set
#define PQ  priority_queue

#define IO ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<ll,ll> pll;
typedef queue<int> qi;
typedef queue<double> qd;
typedef queue<ll> qll;
typedef US<int> si;
typedef US<double> sd;
typedef US<ll> sll;
typedef vector<vi> mi;
typedef vector<vd> md;
typedef vector<vll> mll;
typedef vector<pi> vpi;
typedef vector<pd> vpd;
typedef vector<pll> vpll;


int main(){
  IO; int N, W; cin >> N >> W;
  vll dp(W+1, -1); dp[0] = 0;
  int w, v;
  while(N --){
    cin >> w >> v;
    for(int j = W; j >= w; j --)
      if(dp[j-w] >= 0) MAX(dp[j], dp[j-w] + v);
  }
  ll ans = 0;
  FORE(i, dp) MAX(ans, i);
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

#define access(i) a[i/3][i%3]
//#define random_shuffle(r...)random_shuffle(r,[](int _){return my_rand()%_;})

int main(){

 long long n,k;
 cin>>n>>k;

  vector<int>a(n);

  for(int i=0;i<n;i++) cin>>a[i];

  cout<<ceil((double)(n-k) / (k-1)) + 1<<endl;


return 0;
}

Measured memory_bytes: 3892
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pi pair<int,int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#include "string"
#define int long long

const int inf = 1e18;
int32_t main() { 
   boost;
   int n;
   cin>>n;
   long double ans = 1;
   for(int i=0,x;i<n;i++){
      cin>>x;
      if(ans>0)
         ans*=x;
      if(x == 0)
         ans = 0;
      if(ans > inf)
         ans = -1;
   }
   cout<<(int)ans<<endl;
}

Measured memory_bytes: 3656
#include <iostream>
#include <map>
#include <string>

int main()
{	
	std::multimap<std::string, long long int> M;
	
	int q; std::string sq;
	getline(std::cin, sq); q = std::stoi(sq);
	for (int i=0; i<q; i++) {
		std::string key;
		int op;
		long long int x;
		std::string L, R;
		int sp_pos;
		std::multimap<std::string, long long int>::iterator lb, ub;
		
		std::string buf;
		getline(std::cin, buf);
		op = buf[0] - '0';
		
		if (op==0) {
			sp_pos = buf.find(' ', 2);
			key = buf.substr(2, sp_pos-2);
			x = std::stoll(buf.substr(sp_pos+1));
			M.insert(std::make_pair(key, x));
		} else if (op == 1) {
			key = buf.substr(2);
			if (M.find(key) != M.end()) {
				lb = M.equal_range(key).first;
				ub = M.equal_range(key).second;
				for (std::multimap<std::string, long long int>::iterator it = lb; it != ub; ++it) {
					std::cout << it->second << std::endl;
				}
			}
			// else std::cout << 0 << std::endl;
		} else if (op==2) {
			key = buf.substr(2);
			M.erase(key);
		} else {
			sp_pos = buf.find(' ', 2);
			L = buf.substr(2, sp_pos-2);
			R = buf.substr(sp_pos+1);
			lb = M.lower_bound(L);
			ub = M.upper_bound(R);
			for (std::multimap<std::string, long long int>::iterator it = lb; it != ub; ++it) {
				std::cout << it->first << " " << it->second << std::endl;
			}
		}
	}
	
	return 0;
}



Measured memory_bytes: 24924
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
ll n,ans=0;

int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	ll i,top;
	for(i=1;i<=n;++i){
		top=n/i*i;
		ans+=(i+top)*(n/i)/2;
	}
	cout<<ans;
	
	return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#define MAX 1000010
#include<vector>
using namespace std;
int main(){
	int n,m,ans=0,now=0;
	cin>>n>>m;
	vector<int> vec(MAX);
	for(int i=0;i<n-1;i++){
		cin>>vec[i];
	}
	for(int i=0;i<m;i++){
		int x;
		cin>>x;
		if(x>0){
			for(int j=now;j<now+x;j++){
			ans+=vec[j];
			}
		}else{
			for(int j=now-1;j>=now+x;j--){
				ans+=vec[j];
			}
		}
		now=x+now;
		ans%=100000;
		//cout<<' '<<now<<"   "<<ans<<endl;
	}
	cout<<ans%100000<<endl;
	return 0;
}

Measured memory_bytes: 4804
#include <bits/stdc++.h>
#include <numeric>
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int n;
    cin>>n;
    vector<int> p(n);
    rep(i,n){
        cin>>p[i];
    }
    SORT(p);
    long long int ans=0;
    rep(i,n){
        ans+=(i!=n-1)?p[i]:p[i]/2;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
struct node{//节点结构 
	int key;
	node *next,*prev; 
}; 
node *nil;//表头
node* listsearch(int key){
	node *cur=nil->next;//从表头开始，线性搜索
	while(cur!=nil&&cur->key!=key){
		cur=cur->next;//不符合就搜索下一个 
	} 
	return cur; 
} 
void init(){
	nil=(node*)malloc(sizeof(node));
	nil->next=nil;
	nil->prev=nil;
}
void printlist(){
	node *cur=nil->next;
	int isf=0;
	while(1){
		if(cur==nil) break;
		if(isf++>0) printf(" ");
		printf("%d",cur->key);
		cur=cur->next;
	}
	printf("\n");
}
void deletenode(node *t){
	if(t==nil) return;
	t->prev->next=t->next;
	t->next->prev=t->prev;
	free(t);
}
void deletefirst(){
	deletenode(nil->next);
}
void deletelast(){
	deletenode(nil->prev);
}
void deletekey(int key){
	deletenode(listsearch(key));
}
void insert(int key){
	node *x=(node*)malloc(sizeof(node));
	x->key=key;
	x->next=nil->next;
	nil->next->prev=x;
	nil->next=x;
	x->prev=nil;
}
int main(){
	int key,n,i;
	int size=0;
	char com[20];
	int np=0,nd=0;
	scanf("%d",&n);
	init();
	for(i=0;i<n;i++){
		scanf("%s%d",com,&key);
		if(com[0]=='i') {insert(key);np++;size++;}
		else if(com[0]=='d'){
			if(strlen(com)>6){
				if(com[6]=='F') deletefirst();
				else if(com[6]=='L') deletelast();
			}else{
				deletekey(key);nd++;
			}
			size--;
			
		}
		}
		printlist();
		return 0;
}


Measured memory_bytes: 33824
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define FILE_IO freopen("input.txt","r",stdin)
#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1e18;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
   int n, q;
   cin >> n;
   vector<int> v;
   for (int i = 0; i < n; i++){
	     int x;
	     cin >> x;
	     v.push_back(x); 
	  }
   cin >> q;
   for(int i = 0; i < q; i++){
	    int idx, val;
	    cin >> idx >> val;
	    vector<int> copy = v;
	    idx--;
	    copy[idx] = val;
	    int sum = 0;
	    for(auto it : copy) sum += it;
	    cout << sum << endl;
	 }	
}

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 256
n, k = list(map(int, input().split()))
ans=0
if k==0:
    ans+=n*n
else:
    for b in range(k+1,n+1):
        if n%b<k:
            ans+=n//b*(b-k)
        else:
            ans+=n//b*(b-k)+n%b-k+1
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<memory.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  int n,k;
  cin >> n >> k;
  ll a[n+1]={};
  rep(i,n)cin >> a[i+1];
  ll sum[n+1]={},posisum[n+1]={};
  rep(i,n){
    sum[i+1]=sum[i]+a[i+1];
    posisum[i+1]=posisum[i]+max(0LL,a[i+1]);
  }
  ll ans=-longinf;
  for(int i=0;i+k<=n;i++){
    int left = i, right = i + k;
    ll res = (posisum[left] - posisum[0]) + max(0LL, sum[right] - sum[left]) + (posisum[n] - posisum[right]);
    ans=max(ans,res);
//    ans=max(ans,sum[i+k-1]-sum[i-1]+posisum[i-1]+posisum[n]-posisum[i+k-1]);
//    ans=max(ans,posisum[i+k-1]-posisum[i-1]+sum[i-1]+sum[n]-sum[i+k-1]);
  }
  cout << max((ll)0,ans) << endl;
return 0;}

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

using namespace std;

int main(){

    while(1){
        string s;
        cin>> s;
        if(s=="#") break;

        int sy, sx, gy, gx;
        cin>> sy>> sx>> gy>> gx;
        s+='/';
        int m=0;
        for(int i=0; i<s.size(); i++){
            if(s[i]=='/') m++;
        }
        vector<char> a[m];
        int k=0;
        for(int i=0; i<s.size(); i++){
            if(s[i]=='b'){
                a[k].push_back(s[i]);
            }else if(s[i]=='/'){
                a[k].push_back('b');
                k++;
            }else{
                for(int j=0; j<s[i]-'0'; j++){
                    a[k].push_back('.');
                }
            }
        }
        a[sy-1][sx-1]='.';
        a[gy-1][gx-1]='b';
        string t;
        for(int i=0; i<m; i++){
            int d=0;
            for(int j=0; j<a[i].size(); j++){
                if(a[i][j]=='b'){
                    if(d>0) t+=(char)(d+'0');
                    if(j!=a[i].size()-1) t+='b';
                    d=0;
                }else{
                    d++;
                }
            }
            t+='/';
        }

        t.pop_back();
        cout<< t<< endl;
    }

    return 0;
}

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

int main() { 
    int n, ans = 0;
    cin >> n;
    int a[2][n];
    for(int i = 0; i < 2*n; ++i) {
        cin >> a[i/n][i%n];
    } 
    int ue[n] = {0}, shita[n] = {0};
    ue[0] = a[0][0], shita[n-1] = a[1][n-1];
    for(int i = 1; i < n; ++i) ue[i] = ue[i-1] + a[0][i];
    for(int i = n-2; i >= 0; --i) shita[i] = shita[i+1] + a[1][i];
    for(int i = 0; i < n; ++i) {
        ans = max(ans, ue[i] + shita[i]);
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define cinv(v,n) for(size_t i=0;i<(n);i++){cin>>(v)[i];}
#define nvec(type,v,n) vector<type> v(n);cinv(v,n)
#define npairs(type1,type2,v,n) vector<pair<type1,type2>> v(n);for(size_t i=0;i<(n);i++){cin>>v[i].first>>v[i].second;}
#define ntuples(type1,type2,type3,v,n) vector<tuple<type1,type2,type3>> v(n);for(size_t i=0;i<(n);i++){cin>>get<0>(v[i])>>get<1>(v[i])>>get<2>(v[i]);}

#define min_index(v) size_t(min_element(all(v))-(v).begin())
#define max_index(v) size_t(max_element(all(v))-(v).begin())
#define min_e(v) *min_element(all(v))
#define max_e(v) *max_element(all(v))

#define count_le(v,a) size_t(upper_bound(all(v),a)-(v).begin())
#define count_lt(v,a) size_t(lower_bound(all(v),a)-(v).begin())
#define count_ge(v,a) size_t((v).end()-lower_bound(all(v),a))
#define count_gt(v,a) size_t((v).end()-upper_bound(all(v),a))

#define order(neq_sl) [](const &auto s, const &auto l){return neq_sl;}
#define make_lr(v,type,l,r) vector<type> l(n+1),r(n+1);FOR(i,n){l[i+1]=l[i]+v[i];r[i+1]=r[i]+v[n-1-i];}

#define acm accumulate
#define SUM(v) acm(all(v),0l)

int main() {
  int n;
  cin>>n;
  nvec(int, a, n);
  cout<<SUM(a)-n;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
	int x;
	cin >> x;
	if (x < 600) {
		cout << 8 << endl;
	} else if (x < 800) {
		cout << 7 << endl;
	} else if (x < 1000) {
		cout << 6 << endl;
	} else if (x < 1200) {
		cout << 5 << endl;
	} else if (x < 1400) {
		cout << 4 << endl;
	} else if (x < 1600) {
		cout << 3 << endl;
	} else if (x < 1800) {
		cout << 2 << endl;
	} else {
		cout << 1 << endl;
	}

	return 0;
}

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

typedef long long ll;

int n, m, k, ids;
int a[310][310];
char s[310][310];

//int cnt;
void solve(int sx, int sy, int ex, int ey)
{
	//printf("%d %d %d %d: ", sx, sy, ex, ey);
	//if(cnt == 10) return; ++cnt;
	int pxi = -1, pyi = -1, pxj = -1, pyj = -1;
	for(int i = sx; i <= ex; ++i)
		for(int j = sy; j <= ey; ++j)
			if(s[i][j] == '#')
			{
				if(pxi == -1) pxi = i, pyi = j;
				else if(pxj == -1) pxj = i, pyj = j;
			}
	//printf("%d %d %d %d: ", pxi, pyi, pxj, pyj);
	if(pxj == -1)
	{
		++ids;
		for(int i = sx; i <= ex; ++i)
			for(int j = sy; j <= ey; ++j)
				a[i][j] = ids;
		return;
	}
	if(pxi != pxj)
	{
		int z = min(pxi, pxj);
		solve(sx, sy, z, ey);
		solve(z + 1, sy, ex, ey);
	}
	else
	{
		int z = min(pyi, pyj);
		//printf("%d\n", z);
		solve(sx, sy, ex, z);
		solve(sx, z + 1, ex, ey);
	}
}

int main()
{
	scanf("%d %d %d", &n, &m, &k);
	for(int i = 1; i <= n; ++i) scanf("%s", s[i] + 1);
	solve(1, 1, n, m);
	for(int i = 1; i <= n; ++i, puts(""))
		for(int j = 1; j <= m; ++j) printf("%d ", a[i][j]);
	return 0;
}

Measured memory_bytes: 1280
n,k = gets.chomp.split.map(&:to_i)
#d = gets.chomp.to_i
#puts n,k

i = 0
res = []
k.times do
  a = gets.chomp.to_i
  b = gets.chomp.split.map(&:to_i)
  res << b
  #p res
  
  i += 1
end

res = res.flatten
r2 = res.sort.slice_when(&:!=).map {|x| [x.first, x.size] }
puts n - Hash[r2].count

Measured memory_bytes: 14400
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

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

    string S;
    cin >> S;
    if(S == "keyence"){
                cout << "YES" << endl;
                return 0;
            }
    for(int i=0; i<S.size(); i++){
        for(int j=i; j<S.size(); j++){
            //[i,j]を取り除く
            string T = S.substr(0, i) + S.substr(j+1, S.size()-j-1);
            if(T == "keyence"){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;

    return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    int N; cin >> N;
    string S; cin >> S;
    map<char, ll> m;
    for(int i = 0; i < N; i++){
        m[S[i]]++;
    }
    ll sum = m['R'] * m['G'] * m['B'];
    ll cnt = 0;
    for(int i = 0; i < N; i++){
        // indexの間隔を1ずつふやす
        for(int j = i + 1; j < N; j++){
            // 同じ文字だったらはじく
            if(S[i] == S[j]) continue;
            // 3文字目のindexを計算
            int k = j * 2 - i;
            // 範囲外または同じ文字ならはじく
            if(k >= N || S[k] == S[i] || S[k] == S[j]) continue;
            cnt++;
        }
    }
    cout << sum - cnt << endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <algorithm>
using namespace std;

#define FOR(i,s,t) for(int i=s;i<t;i++)
#define REP(i,n) FOR(i,0,n)
#define LAST(i,n) if(i==n-1)
#define PRINT(s) cout << s << "\n"
#define SORT(A) sort(A.begin(), A.end())
#define EACHPRINT(A, T) for_each(begin(A), end(A), [&](T i){ cout << i << " "; });cout << "\n"

typedef long lint;
typedef pair<lint, lint> P;

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

    vector<lint> A;
    REP(i, N) {
      lint a; cin >> a; A.push_back(a);
    }
    
    lint right = 1;

    lint sum = A[0];
    lint xsum = A[0];

    lint res = 0;
    
    FOR(left, 0, N) {
      while(right < N) {
        if(sum + A[right] == (xsum ^ A[right])) {
          sum += A[right];
          xsum = xsum ^ A[right];
          right += 1;
        }
        else {
          break;
        }
      }
      res += (right-left);
      sum -= A[left];
      xsum = xsum ^ A[left];
    }

    cout << res << "\n";

    return 0;
}


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

#define eps 1e-7


int main(){

    ll n;
    cin>>n;

    ll a[n];
    
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll maxx = a[0];
    ll minn = a[0];
    
    for(int i=0;i<n;i++){
        
        if(a[i]>maxx){
            maxx = a[i];
        }
        if(a[i] <minn){
            minn = a[i];
        }
    }
    
    cout<<maxx-minn<<endl;
}

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

template <
    typename TYPE,
    std::size_t SIZE>
std::size_t a_len(const TYPE (&array)[SIZE])
{
    return SIZE;
}

using namespace std;
using ll = long long int;
using vi = vector<ll>;

#define REPS(a, i, n) for (ll(i) = a; (i) < (n); ++(i))
#define REP(i, n) REPS(0, i, n)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 912345678;
int x, a, b;

int main()
{
    cin >> x >> a >> b;
    cout << (x - a) % b << endl;
}

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

using namespace std;

constexpr static int MAXN = 1e5;

int N;
int64_t a[MAXN], b[MAXN];

bool check() {
    // op: +2 and -1
    int64_t cnt = 0;
    for (int i = 0; i < N; i++)
        cnt += b[i] - a[i];
    if (cnt < 0)
        return false;

    int64_t used = 0;
    for (int i = 0; i < N; i++) {
        if (a[i] > b[i])
            used += a[i] - b[i];
        else if ((b[i] - a[i]) % 2 == 1)
            used += 1;
    }

    return used <= cnt;
}

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

    if (check())
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int x, y;
    cin >> x >> y;
    for (int i = 0; i <= x; ++i) {
        if (i * 2 + (x - i) * 4 == y) {
            cout << "Yes"
                 << "\n";
            return 0;
        }
    }
    cout << "No"
         << "\n";
    return 0;
}

Measured memory_bytes: 3640
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
#include<limits.h>
#include<float.h>

#define MAX_NUM 51

void dfs(int i, bool adj[MAX_NUM][MAX_NUM], bool *visited, int n){
	visited[i] = true;
	for(int j=1; j<n+1; j++){
		if(adj[i][j] && !visited[j]) dfs(j, adj, visited, n);
		if(adj[j][i] && !visited[j]) dfs(j, adj, visited, n);
	}
}

bool connected(bool adj[MAX_NUM][MAX_NUM], int n){
	bool visited[MAX_NUM];
	for(int i=1; i<n+1; i++){
		visited[i] = false;
	}
	dfs(1, adj, visited, n);
	for(int i=1; i<n+1; i++){
		if(visited[i] == false) return false;
	}
	return true;
}

int main(){
	int n, m, a, b, ans = 0;
	bool adj[MAX_NUM][MAX_NUM];
	scanf("%d%d\n", &n, &m);
	for(int i=1; i<n+1; i++){
		for(int j=1; j<n+1; j++){
			adj[i][j] = false;
		}
	}
	for(int i=0; i<m; i++){
		scanf("%d%d\n", &a, &b);
		adj[a][b] = true;
	}
	for(int i=1; i<n+1; i++){
		for(int j=1; j<n+1; j++){
			if(adj[i][j]){
				adj[i][j] = false;
				if(!connected(adj, n)) ans++;
				adj[i][j] = true;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
typedef stack<ll> ST;
typedef queue<ll> QUE;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int main(){
    int K, A, B; scanf("%d %d %d",&K, &A, &B);
    FOR(i, A, B+1){
        if(i % K == 0){
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}

Measured memory_bytes: 3684
import sys
N, Y = map(int, input().split())
for i in range(N + 1):
    if 10000 * i > Y:
        break
    for j in range(N + 1 - i):
        if 10000 * i + 5000 * j > Y:
            break
        k = N - i - j
        if 10000 * i + 5000 * j + 1000 * k > Y:
            break
        if 10000 * i + 5000 * j + 1000 * k == Y:
            print('{0} {1} {2}'.format(i, j, k))
            sys.exit()
print('-1 -1 -1')

Measured memory_bytes: 40812
/*@author hussein zayed ;
    ___  ___
   |\  \|\  \
   \ \  \_\  \
    \ \   ___ \USSEIN
     \ \  \\ \ \
      \ \__\\ \_\
       \|__| \|__|
****************************************
*/

#include <bits/stdc++.h>
using namespace std;
#define fr for(int i=0;i<n;++i)
#define fr1 for(int i=1;i<=n;++i)
#define cinA for(int i=0;i<n;++i){cin>>arr[i];}
#define cinA1 for(int i=1;i<=n;++i){cin>>arr[i];}
#define coutA for(int i=0;i<n;++i){cout<<arr[i]<<" ";}
#define ll long long
#define lnarray sizeof(arr)/sizeof(*arr)
#define vi vector<int>
#define vs vector<string>
void Fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int RD()
{
    int i ;
    cin>>i;
    return i;
}

inline float RF()
{
    float i ;
    cin>>i;
    return i;
}

inline double RDO()
{
    double i ;
    cin>>i;
    return i;
}

inline string RS()
{
    string i ;
    cin>>i;
    return i;
}

inline ll RLL()
{
    ll i ;
    cin>>i;
    return i;
}

int cm[200000];

ll sumSet(ll n)
{
    return (1ll*n*(n+1))/2;
}
string s;


bool isPrime(int n)
{
    if(n==1)
        return false;
    for(int i=2; i*i<=n; ++i)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int sumDigit(int n){
int sum =0;
  while (n != 0)
    {
        sum+= + n % 10;
        n = n / 10;
    }
    return sum;
}

ll power2(int n){
  ll ans=(1<<n);
  return ans;
}

ll sumpow2(ll n){
 ll sum=(n*(n+1)*(2*n-1))/6;
 return sum;
}
map<int ,int> mp;
vi vr;
int main(){
    Fast();
//freopen("output.txt" , "w" , stdout);
//freopen("wall.in" , "r" , stdin);
int n=RD(),a,cont=0,arr[n+3];
fr{
cin>>arr[i];
 mp[arr[i]]++;
}

set<int>st;
fr{
 st.insert(arr[i]);
}
 for (set<int>::iterator it=st.begin(); it!=st.end(); ++it)
   vr.push_back( *it);


for(int i=0;i<vr.size();++i){

if(mp[vr[i]]>0){

 if(mp[vr[i]]>=vr[i])
 cont+=mp[vr[i]]-vr[i];

 else
 cont+=mp[vr[i]];



}
}

 cout<<cont;
}


Measured memory_bytes: 10368
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int x,y;
char name[21];

int main(){
	while(scanf("%s",name)!=EOF){
		scanf("%d %d",&x,&y);
		printf("%s %d %d\n",name,x+y,x*200+y*300);
	}
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)
#define debug(var) cout << "[" << #var << "] " << var << endl

const int INF = 1<<29;
const double EPS=1e-9;
const int MOD=998244353;

signed main() {
    int N;
    cin >> N;
    int a = 1000 - (N % 1000);
    if (a == 1000) {
        cout << 0 << endl;
    }
    else {
        cout << a;
    }
}


Measured memory_bytes: 3628
# coding: utf-8
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = float("inf")
for i in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x-1] + b[y-1] - c)
ans = min(ans, min(a) + min(b))
print(ans)

Measured memory_bytes: 18612
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>
#include <iomanip>
//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

double A;
double B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

double getAngle(double teihen,double takasa){
    return atan(takasa/teihen)*180/M_PI;
}

int main(){

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

    cin >> A;
    cin >> B;
    cin >> N;

    ll V_full = A*A*B;
    ll V_half = V_full/2;
    ll V_enp  = V_full - N;

    double ans;
    if(V_half==N){
        ans = getAngle(B,A);
    }else if(V_half<N){
        double teihen = V_enp / A / A * 2;
        ans = getAngle(teihen,A);
    }else{
        double takasa = N / B / A * 2;
        ans = getAngle(B,takasa);
    }
 
    ans = 90 -ans;
    cout << fixed << setprecision(15) << ans << endl;

}

Measured memory_bytes: 3976
from collections import Counter

n,k=map(int,input().split())
l=list(map(int,input().split()))
a=Counter(l)
c=a.most_common()
m=len(c)
sum=0
if k>m:
  print(0)
else:
  for i in range(k):
    sum+=c[i][1]
  print(n-sum)

Measured memory_bytes: 39312
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

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

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  // startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,j,N,H,W,ans=0;
  cin>>N>>H>>W;
  if(W==1000000000){
    rep(i,H){
      if(i)cout<<" ";
      cout<<W;
    }
    while(i<N){
      cout<<" "<<1;
      i++;
    }
    cout<<endl;
  }else{
    rep(i,H){
      if(i)cout<<" ";
      cout<<W;
    }
    while(i<N){
      cout<<" "<<W+1;
      i++;
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 1280
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] rate = new int[N];
        for (int i = 0; i < N; i++) {
            rate[i] = sc.nextInt();
        }
        int[] order = new int[N];
        boolean buy = true;
        for (int i = 0; i < rate.length-1; i++) {
            int tmp = rate[i];
            if (tmp < rate[i+1]) {
                if (buy) {
                    order[i] = 1;
                    buy = false;
                } else {
                    continue;
                }
            } else if (rate[i+1] < tmp) {
                if (!buy) {
                    order[i] = 2;
                    buy = true;
                } else {
                    continue;
                }
            } else {
                continue;
            }
        }
        long money = 1000l;
        long stock = 0l;
        for (int i = 0; i < order.length; i++) {
            if (order[i] == 1) {
                int cost = rate[i];
                stock = money/cost;
                money -= stock*cost;
            } else if (order[i] == 2) {
                int cost = rate[i];
                money += cost*stock;
                stock = 0;
            } else {
                continue;
            }
        }
        if (!buy) {
            int cost = rate[rate.length-1];
            money += cost*stock;
        }
        System.out.println(money);
    }
}


Measured memory_bytes: 35900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int a,b;
  cin >> a >> b;
  if(a<10 && b<10){
    cout << a*b << endl;
  }
  else cout << -1 << endl;
  
  return 0;
    

}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

int main()
{
    int k, t;
    scanf("%d %d", &k, &t);

    int a[100];
    for (int i = 0; i < t; ++i)
        scanf("%d", &a[i]);

    int ans = 0;
    int l = -1;
    for (int i = 0; i < k; ++i) {
        int ma = -1;
        for (int j = 0; j < t; ++j)
            if (j != l && (ma == -1 || a[j] > a[ma]) && a[j] > 0)
                ma = j;
        if (ma == -1) {
            ma = l;
            ans += 1;
        }
        a[ma] -= 1;
        l = ma;
    }
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var C = new int[N - 1];
            var S = new int[N - 1];
            var F = new int[N - 1];
            for (int i = 0; i < N - 1; i++)
            {
                var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                C[i] = input[0];
                S[i] = input[1];
                F[i] = input[2];
            }

            for (int i = 0; i < N - 1; i++)
            {
                var ans = S[i] + C[i];
                for (int j = i + 1; j < N - 1; j++)
                {
                    if (ans < S[j])
                    {
                        ans = S[j] + C[j];
                    }else
                    {
                        var tmp = ans - S[j];
                        if (tmp % F[j] == 0)
                        {
                            ans = S[j] + F[j] * (tmp / F[j]) + C[j];
                        }else
                        {
                            ans = S[j] + F[j] * (tmp / F[j]) + F[j] + C[j];
                        }
                    }
                }
                Console.WriteLine(ans);
            }

            Console.WriteLine(0);
        }
    }
}

Measured memory_bytes: 13268
///******* In the name of Allah *******///

#include<bits/stdc++.h>

using namespace std;

int main()
{
    int n,a,ans,remain;
    cin>>n>>a;
    ans = a*2;
    remain = n - ans;
    if(remain<=0)
    {
        cout<<"0"<<endl;
    }
    else
    {
        cout<<remain<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

//Mr. Rito Post Office
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int INF = 1<<28;
		for(;;){
			int n = sc.nextInt(), m = sc.nextInt();
			if((n|m)==0)break;
			int[][] wf1 = new int[n][n], wf2 = new int[n][n];
			for(int i=0;i<n;i++)for(int j=0;j<n;j++){
				wf1[i][j] = wf2[i][j] = INF;
			}
			for(int i=0;i<n;i++)wf1[i][i] = wf2[i][i] = 0;
			while(m--!=0){
				int s = sc.nextInt()-1, t = sc.nextInt()-1, cost = sc.nextInt();
				String str = sc.next();
				if("L".equals(str))wf1[s][t] = wf1[t][s] = Math.min(wf1[s][t], cost);
				else wf2[s][t] = wf2[t][s] = Math.min(wf2[s][t], cost);
			}
			for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++){
				wf1[i][j] = Math.min(wf1[i][j], wf1[i][k]+wf1[k][j]);
				wf2[i][j] = Math.min(wf2[i][j], wf2[i][k]+wf2[k][j]);
			}
			int R = sc.nextInt();
			int[][] dp = new int[2][n];
			Arrays.fill(dp[0], INF);
			int X = 1;
			int pre = sc.nextInt()-1;
			dp[0][pre] = 0;
			for(;--R!=0;X=1-X){
				int k = sc.nextInt()-1;
				Arrays.fill(dp[X], INF);
				for(int i=0;i<n;i++)for(int j=0;j<n;j++){
					if(i!=j)
						dp[X][i] = Math.min(dp[X][i], dp[1-X][j]+wf1[pre][j]+wf2[j][i]+wf1[i][k]);
					else
						dp[X][i] = Math.min(dp[X][i], dp[1-X][j]+wf1[pre][k]);
				}
				pre = k;
			}
			int res = INF;
			for(int i=0;i<n;i++)res = Math.min(res, dp[1-X][i]);
			System.out.println(res);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 14000
#include <iostream>
using namespace std;
int n, p[100010], ans;
int main() {
	cin >> n;
	for (int i = 1; i <= n; i++)cin >> p[i];
	for (int i = 1; i <= n; i++) {
		if (p[i] == i) {
			ans++;
			if (p[i + 1] == i + 1)i++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {

	int n, d;
	int ans = 0;
	
	cin >> n >> d;
	
	ans = n / (2*d + 1);
	
	ans += (n % (2*d + 1)) ? 1 : 0;
	
	cout << ans << 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;
int main(){
    int a,b;
    cin>>a>>b;
    vector<string> mo(a,"");
    REP(i,a)cin>>mo[i];
    REP(i,a){
        if(i==0){
            REP(i,b+2)cout<<"#";
            cout<<endl;
        }
        cout<<"#"<<mo[i]<<"#"<<endl;
        if(i+1==a){
            REP(i,b+2)cout<<"#";
            cout<<endl;
        }
    }
}

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

int main() {
    cout << fixed << setprecision(10);
    
    int N, M; cin >> N >> M;

    vector<vector<int>> e(N);
    rep(i, M) {
        int a, b; cin >> a >> b;
        a--; b--;
        e[a].emplace_back(b);
        e[b].emplace_back(a);
    }

    vector<int> al(N, -1);
    queue<int> q;
    q.emplace(0);
    al[0] = 0;

    while (!q.empty()) {
        int cn = q.front(); q.pop();
        for (auto nn: e[cn]) {
            if (al[nn] != -1) continue;

            al[nn] = cn;
            q.emplace(nn);
        }
    }
    rep(i, N) {
        if (al[i] == -1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    rep(i, N-1) {
        cout << al[i+1] +1 << endl;
    }
    return 0;
}

Measured memory_bytes: 10264