akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <numeric>

/* debug macros */
#ifdef WAFDAYO
#define DBG_LINE() {std::cerr<<"\e[2m[L"<<__LINE__<<"]\e[m ";}
#define DBG_PRINT(s,t,u) {std::cerr<<(s)<<" \e[2m=\e[m \e[1m"<<(t)<<"\e[m"<<(u);}
#define SELECT_7TH(x1,x2,x3,x4,x5,x6,x7,...) x7
#define dbg1(x1) DBG_PRINT(#x1,x1,std::endl)
#define dbg2(x1,x2) DBG_PRINT(#x1,x1,", ")dbg1(x2)
#define dbg3(x1,x2,x3) DBG_PRINT(#x1,x1,", ")dbg2(x2,x3)
#define dbg4(x1,x2,x3,x4) DBG_PRINT(#x1,x1,", ")dbg3(x2,x3,x4)
#define dbg5(x1,x2,x3,x4,x5) DBG_PRINT(#x1,x1,", ")dbg4(x2,x3,x4,x5)
#define dbg6(x1,x2,x3,x4,x5,x6) DBG_PRINT(#x1,x1,", ")dbg5(x2,x3,x4,x5,x6)
#define dbg(...) DBG_LINE()\
SELECT_7TH(__VA_ARGS__,dbg6,dbg5,dbg4,dbg3,dbg2,dbg1)(__VA_ARGS__)
#else
#define dbg(...) {}
#endif

/* utility functions */
struct read_item{read_item(){};
template<class T>operator T(){T t;std::cin>>t;return t;}};
char splf(int i,int n){return(i+1<n)?' ':'\n';};
template<bool up>
struct _RI{int i;_RI(int a):i(a){}
int operator*(){return i;}void operator++(){i+=(up?1:-1);}
bool operator!=(const _RI& r){return up?i<r.i:i>=r.i;}};
template<bool up>
struct _RX{_RI<up> x,y;_RI<up> begin(){return x;}_RI<up> end(){return y;}
_RX(int a,int b):x(up?a:(a-1)),y(b){}_RX(int a):_RX(up?0:a,up?a:0){}};
typedef _RX<true> range;
typedef _RX<false> revrange;

/* types and constants */
typedef int64_t i64;
typedef uint64_t u64;
// const i64 inf = (i64)1.05e18;
// const int inf = (int)1.05e9;

using namespace std;

int main() {

	string s = read_item();
	string t;
	for(auto i : range(3)) {
		t.push_back(s[i]);
	}
	printf("%s\n", t.c_str());

	return 0;
}

/* wafdayo~~~ */


Measured memory_bytes: 3628
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define ar array
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
  
  int l,r,d,ans=0;
  cin >> l >> r >> d;
  for(int i=d;i<=1000;i+=d){
    if(i>=l&&i<=r)ans++;
  }
  cout<<ans<<endl;


return 0;
}
///....


Measured memory_bytes: 3584
#include <stdio.h>
int main(void) {
	int n;
	long long int a,b=-1,c=2;
	scanf("%d", &n);
	for (int i = 0;i < n;i++) {
		a = b;
		b = c;
		c = a + b;
	}
	printf("%lld\n", c);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
int main(void){
    int i;
    int n;
    int dev;
    int now;
    int pn;
    int pre;
    dev=0;
    pn=0;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&now);
        if(i==0){
            dev++;
        }else{
            if(pn==0){
                if(now-pre>0){
                    pn=1;
                }else if(now-pre<0){
                    pn=-1;
                }else if(now==pre){
                    pn=0;
                }
            }else if(pn==1){
                if(now-pre>0){
                    pn=1;
                }else if(now-pre<0){
                    dev++;
                    pn=0;
                }else if(now==pre){
                    pn=1;
                }
            }else if(pn==-1){
                if(now-pre>0){
                    dev++;
                    pn=0;
                }else if(now-pre<0){
                    pn=-1;
                }else if(now==pre){
                    pn=-1;
                }
            }else{
                printf("???\n");
            }
        }
        pre=now;
    }
    printf("%d\n",dev);
    return 0;
}



Measured memory_bytes: 128
inpl = lambda: list(map(int,input().split()))
def inv_mod(a, p):
    p = abs(p)
    a %= p
    stack = []
    p0 = p
    while a > 1:
        d, a, p = p//a, p%a, a
        stack.append(d)
    x, y = 1, 0
    while stack:
        d = stack.pop()
        x, y = y-d*x, x
    return x % p0

def comb_mod(n,k,p):
    ans = 1
    k = min(k,n-k)
    if k < 0:
        return 0
    for i in range(k):
        ans = ans * (n-i) * inv_mod(k-i,p) % p
    return ans

MOD = 10**9+7
X, Y = inpl()
if (X+Y) % 3:
    print(0)
    exit()
N = (X+Y)//3
X -= N
Y -= N
Z = X + Y
print(comb_mod(Z,X,MOD))

Measured memory_bytes: 41324
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
 
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
typedef pair< long long int ,long long int > iil;
typedef long long ll;
typedef vector< ll > vl;
 
 
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for( auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define edl '\n'
#define ll long long int
#define forn(i,n) for ( int i=0 ; i<n ; i++ )
#define fornl(i,n) for(ll i=0;i<n;i++)
#define forni(i,j,n) for ( int i=j ; i<n ; i++ )
#define filecode ifstream cin("input.txt");ofstream cout("output.txt");
#define IOFAST ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
#define setPrecision(n) cout << std::setprecision(n) << std::fixed;
#define MOD 998244353
#define PI 3.14159265
#define DEBUG 0
#define g(a,b) a>b?a:b
#define l(a,b) a<b?a:b
bool comp ( ii a, ii b ){ return (a.first==b.first)?a.second<b.second:a.first<b.first; }
ll modInverse(ll a) { ll m = MOD;ll y = 0, x = 1;while (a > 1) {ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0) x += MOD;return x; }

int main(){
    ll x,ans=0;
    cin>>x;
    ans+=((x/500)*1000);
    x=x%500;
    ans+=((x/5)*5);
    cout<<ans;
}


















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

int main()
{
    string s;

    while( cin >> s )
    {
        if( s == "." )
            break;

        string t = "";
        int cnt = 0;
        for( int i = 0; i < s.size(); i++ )
        {
            if( s[i] == '+' )
            {
                cnt++;
                if( cnt > 25 )
                    cnt = 0;
            }
            else if( s[i] == '-' )
            {
                cnt--;
                if( cnt < 0 )
                    cnt = 25;
            }
            else if( s[i] == '[' || s[i] == ']' )
                t += s[i];
            else if( s[i] == '?' )
            {
                cnt = 0;
                t += s[i];
            }
            else
            {
                if( s[i] + cnt > 'Z' )
                    t += s[i] + cnt - 'Z' + 'A' - 1;
                else if( s[i] + cnt < 'A' )
                    t += s[i] + cnt - 'A' + 'Z' + 1;
                else
                    t += s[i] + cnt;
                cnt = 0;
            }
        }

        stack<char> st;
        for( int i = 0; i < t.size(); i++ )
        {
            if( t[i] == ']' )
            {
                string u = "";
                while( st.top() != '[' )
                {
                    u += st.top();
                    st.pop();
                }
                st.pop();
                for( int j = 0; j < u.size(); j++ )
                    st.push(u[j]);
            }
            else
                st.push(t[i]);
        }

        string res = "";
        while( !st.empty() )
        {
            res += st.top();
            st.pop();
        }
        for( int i = res.size() - 1; i >= 0; i-- )
        {
            if( res[i] == '?' )
                cout << 'A';
            else
               cout << res[i];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
typedef long long ll;
const long long INF = 1LL << 60;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    long long N; cin >> N;
    vector<long long> a(N), cum(N+10, 0);
    rep (i, 0, N) {
        cin >> a[i];
        cum[i+1] = a[i] + cum[i];
    }

    long long ans = INF;
    rep (i, 1, N) {
        ans = min(ans, abs(cum[i]-(cum[N]-cum[i])));
    }

    cout << ans << endl;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define intt long long int
#define fr(a,b) for(int i = a; i < b; i++)
#define rep(i,a,b) for(int i = a; i < b; i++)
#define mod 1000000007
#define inf (1LL<<60)
#define all(x) (x).begin(), (x).end()
#define prDouble(x) cout << fixed << setprecision(10) << x
#define triplet pair<ll,pair<ll,ll>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
void go()
{
#ifndef ONLINE_JUDGE
  freopen("inn.txt","r",stdin);
  freopen("o.txt","w",stdout);
  #endif
}
 
int main() {
   fast_io;
   go();
   intt x,k,d;cin>>x>>k>>d;
   intt temp=x/d;
   temp=abs(temp);
   if(temp>k){	
   	if(x>0)
   	cout << abs(x-k*d)<<"\n";
   	else
   	cout << abs(x+k*d) <<"\n";
   }
   else{
   		if(x>0){
	   		intt ans=x-temp*d;
	   		if((k-temp)%2==0)
	   			cout << abs(ans) <<"\n";
	   		else
	   			{
	   				ans=(min(abs(ans-d),abs(ans+d)));
	   				cout << ans <<"\n";
	   			}
	   		}
	   	else{
	   		intt ans=x+temp*d;
	   		if((k-temp)%2==0)
	   			cout << abs(ans) <<"\n";
	   		else
	   			{
	   				ans=(min(abs(ans-d),abs(ans+d)));
	   				cout << ans <<"\n";
	   			}
	   		
	   	}
   }
   
}


Measured memory_bytes: 3636
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1000000000000000LL
#define all(x) x.begin(),x.end()
using pint = pair<int,int>;
using vec = vector<int>;
using ll=long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll k;cin>>k;
    queue<ll> que;
    rep1(i,9) que.push(i);
    rep(i,k-1){
        ll top=que.front();
        que.pop();
        for(int d=-1; d<=1; d++){
            ll add= top%10 + d;
            if(add>=0 && add<=9) que.push(top*10+add);
        }
    }

    cout<<que.front()<<endl;
    return 0;
}

Measured memory_bytes: 4760
from collections import Counter


MOD = 998244353
N = int(input())
D = list(map(int, input().split()))
cnt_D = Counter(D)
if D[0] != 0 or cnt_D.get(0, 0) != 1:
    print(0)
else:
    prev = 1
    ans = 1
    for i in range(1, max(D) + 1):
        v = cnt_D.get(i, 0)
        ans *= pow(prev, v, MOD)
        ans %= MOD
        prev = v
    print(ans)


Measured memory_bytes: 19936
#include<stdio.h>
#define NUM 50

int main(void){
  int N,i,j;
  double tmp,num[NUM];
  double ans=0;
  
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%lf",&num[i]);
  }
  
  for(i=0;i<N-1;i++){
    for(j=N-1;j>i;j--){
      if(num[j-1]>num[j]){
        tmp=num[j-1];
        num[j-1]=num[j];
        num[j]=tmp;
      }
    }
  }
  
  for(i=0;i<N-1;i++){
    num[i+1]=(num[i]+num[i+1])/2;
  }
  
  printf("%f",num[N-1]);
  
  return 0;
  
}

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

int main(){
    int d,g;
    cin >> d >> g;
    int p[d];
    int c[d];
    for(int i=0;i<d;i++){
        cin >> p[i] >> c[i];
    }
    
    int ans=1e9;
    int rest;
    for(int bit=0;bit<(1<<d);bit++){
        int score=0;int sum=0;
        for(int i=0;i<d;i++){
            if(bit&(1<<i)){
                score+=(i+1)*100*p[i]+c[i];
                sum+=p[i];
            }else{
                rest=i; //解かなかった問題セットの最大値
            }
        }
        if(score<g){
            int score_e = 100*(rest+1);
            int need = (g-score+score_e-1)/score_e; // 小数点は切り上げ
            if(need>=p[rest]) continue;
            sum+=need;
        }
        ans=min(ans,sum);
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int x, y;
  int s1 = 0, s2 = 0;
  string a = "No";
  cin >> x >> y;
  s1 = 2*x;
  s2 = 4*x;
  if(s1 <= y && y <=s2){
  	a = "Yes";
  }
  if(y%2 != 0){
  	a = "No";
  }
  cout << a << endl;
}

Measured memory_bytes: 3592
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashMap;

fn main() {
    input!(s: String);

    let vs = vec!["", "A"];

    let mut ok = false;
    for &a in &vs {
        for &b in &vs {
            for &c in &vs {
                for &d in &vs {
                    let target = format!("{}KIH{}B{}R{}", a, b, c, d);
                    if s == target {
                        ok = true;
                    }
                }
            }
        }
    }

    println!("{}", if ok { "YES" } else { "NO" });
}


Measured memory_bytes: 4352
package main

import "fmt"

func main() {
	for {
		var a, b, n int
		fmt.Scanf("%d", &n)

		if n == 0 {
			return
		}

		for i := 0; i < n; i++ {
			var cardA, cardB int
			fmt.Scanf("%d %d", &cardA, &cardB)

			if cardA > cardB {
				a += cardA + cardB
			} else if cardB > cardA {
				b += cardA + cardB
			} else {
				a += cardA
				b += cardB
			}
		}

		fmt.Println(a, b)
	}
}



Measured memory_bytes: 2276
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
int a;
int main(){
	a=read();
	printf("%d\n",a+a*a+a*a*a);
	return 0;
}

Measured memory_bytes: 3760
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>

using namespace std;


/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back


/*---  Type ---*/
typedef long long ll;


/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// 4-direction
int dy4[] = {0,  1, -1,  0};
int dx4[] = {1,  0,  0, -1};

// 8-direction
int dy8[] = {0,  1,  1,  1,  0, -1, -1, -1};
int dx8[] = {1,  1,  0, -1, -1, -1,  0,  1};

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

int main() {
  int a, b;
  char op;

  cin>>a>>op>>b;
  if(op=='+') cout<<a+b<<endl;
  else cout<<a-b<<endl;

  return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)

h = a.group_by(&:itself).map{ |key, value| [key, value.count] }.to_h

ans = 0
0.upto(10**5-1) do |i|
  c = h[i-1].to_i + h[i].to_i + h[i+1].to_i
  ans = c if c > ans
end
p ans


Measured memory_bytes: 25348
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
using namespace std;
#define INF 1000000007
#define LINF 1000000000000000007
#define MOD 1000000007
#define int long long
#define rep(i, n) for (int i = 0; i < n; i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout << #X << ": " << X << " ";
#define ARDEB(i, X) cout << #X << "[" << i << "]: " << X[i] << " ";
#define END cout << endl;
#else
#define DEB(X) \
    {          \
    }
#define ARDEB(i, X) \
    {               \
    }
#define END \
    {       \
    }
#endif
typedef pair<int, int> P;
struct edge{int to,cost;};
typedef long long ll;

int ans,ans2;



signed main(){

    int n,a[111111];
    cin>>n;
    
    rep(i,n)cin>>a[i];
    rep(i,n-2){
        if(a[i+1]!=max({a[i],a[i+1],a[i+2]}) && a[i+1]!=min({a[i],a[i+1],a[i+2]})){
            ans++;
        }
    }
    cout<<ans<<endl;

}


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


using namespace std;

int main(){
    int n;
    string s;
    cin>>n>>s;
    int count=0;
    for(int i=0;i<n;i++){
        if(s[i]=='R')++count;
    }
    int b=n-count;
    int ans=b-count;
    if(ans>=0)cout<<"No"<<endl;
    if(ans<0)cout<<"Yes"<<endl;
    return 0;
}



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

int N, ans = -2147483648;
int F[100][10];
int P[100][11];

int main()
{
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < 10; j++) scanf("%d", &F[i][j]);
	}
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < 11; j++) scanf("%d", &P[i][j]);
	}
	for (int i = 1; i <= 1023; i++)
	{
		int sum = 0;
		for (int j = 0; j < N; j++)
		{
			int cnt = 0;
			for (int k = 0; k < 10; k++)
			{
				if (F[j][k] == 1 && (i&(1 << k)) > 0) cnt++;
			}
			sum += P[j][cnt];
		}
		ans = std::max(ans, sum);
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    



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

   vi a(n);
   
   int tot = 0;
   for(int &x : a){
       cin>>x;

       tot ^= x;
   }

   for(int x : a){
       cout<<(tot^x)<<" ";
   }

   

   




}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1) res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



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

using namespace std;

#define USE_IOSTREAM \
{\
	ios::sync_with_stdio(false);\
	cin.tie(0);\
	cout.tie(0);\
}

#define pii pair<int, int>
#define mp make_pair

typedef long long ll;



int main()
{
	// USE_IOSTREAM;
	ll ans, a, b, x;
	cin >> a >> b >> x;
	
	ll start, end;
	start = (a + x - 1) / x;
	end = b / x;
	if (end >= start)
	{
		ans = end - start + 1;
	}
	else
	{
		ans = 0;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
signed main() {
	int h, w;
	cin >> h >> w;
	int a[200][200];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
			a[i][w] += a[i][j];
			a[h][j] += a[i][j];
			a[h][w] += a[i][j];
		}
	}
	for (int i = 0; i <= h; i++) {
		for (int j = 0; j <= w; j++) {
			cout << (j == 0 ? "" : " ") << a[i][j];
		}
		cout << endl;
	}
}


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

int X[100],Y[100];
int W[1024];
int L[100],R[100];
int n;

int getWeight(int pos){
	if(pos > n){ return W[pos]; }
	return getWeight(L[pos]) + getWeight(R[pos]);
}
void refleshTree(int pos , int mult){
	if(pos > n) { W[pos] *= mult; return; }
	refleshTree(L[pos],mult);
	refleshTree(R[pos],mult);
}
void dfs(int pos){
	if(pos > n){
		return;
	}
	dfs(L[pos]);
	dfs(R[pos]);
	
	int S = getWeight(L[pos]) * X[pos]; 
	int T = getWeight(R[pos]) * Y[pos];
	int g = S / __gcd(S,T) * T;
	refleshTree(L[pos],g / S);
	refleshTree(R[pos],g / T);
}

int main(){
	while(cin >> n && n){
		int K = 512;
		int used[100]={};
		for(int i = 0 ;  i < n ; i++){
			int a,b,c,d;
			cin >> a >> b >> c >> d;
			c--,d--;
			X[i] = a , Y[i] = b;
			int g = __gcd(a,b);
			X[i] /= g;
			Y[i] /= g;
			if(c == -1) c = K++; else used[c] = true;
			if(d == -1) d = K++; else used[d] = true;
			L[i] = c;
			R[i] = d;
		}
		
		for(int i = 0 ; i < K ; i++) W[i] = 1;
		
		for(int i = 0 ; i < n ; i++){
			if(!used[i]){
				dfs(i);
				cout << getWeight(i) << endl;
			}
		}
	}
}

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

int main() {
  long long int n;
  cin>>n;
  long long int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  long long int money=1000;
  vector<int> s(0);
  vector<int> e(0);
  bool bye=false;
  for(int i=0;i<n;i++){
    
    if(i==0){
      if(a[i]<a[i+1]){
        s.push_back(0);
        bye=true;
      }
      continue;
    }
    if(i==n-1){
      e.push_back(i);
      break;
    }
    if(a[i]<a[i+1]&&bye==false){
      s.push_back(i);
      bye=true;
    }
    if(a[i]>a[i+1]&&bye==true){
      e.push_back(i);
      bye=false;
    }
  }
  int l=s.size();
  for(int i=0;i<l;i++){
    long long int t=money/a[s[i]];
    money%=a[s[i]];
    money+=a[e[i]]*t;
  }
  cout<<money;
}


Measured memory_bytes: 3628
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int D = 0;
    int N = 0;
    int result = 0;
    
    scanf("%d %d",&D,&N);
    
    if (D == 0) {
        if (N == 100) {
            result = 101;
        }else{
            result = N;
        }
        printf("%d\n",result);
    }else if (D == 1) {
        if (N == 100) {
            result = 10100;
        }else{
            result = N * 100;
        }
        printf("%d\n",result);
    }else if (D == 2) {
        if (N == 100) {
            result = 1010000;
        }else{
            result = N * 10000;
        }
        printf("%d\n",result);
    }
    return 0;
}

Measured memory_bytes: 128
//From Naruto to Hokage
//#include <RJ>
#include<bits/stdc++.h>
using namespace std;

#define ll          long long
#define pb          push_back
#define eb          emplace_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    string s;
    cin>>s;
    ll curr=0,ans=0;
    rep(i,0,sz(s)-1){
        if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
            curr++;
        }
        else {
            ans=max(ans,curr);
            curr=0;
        }
    }
    ans=max(ans,curr);
    cout<<ans;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位

ll n;
string a;
vector<string> ans;
string c = "abcdefghijklm";

int main(void) {
    ll n, k;
    cin >> n >> k;
    ll a[n];
    for(ll i = 0; i < n; i++)
        cin >> a[i];
    ll ans = 0;
    if(a[0]>k) {
        ans += a[0]-k;
        a[0]=k;
    }
    for(ll i = 0; i < n-1; i++){
        if(a[i]+a[i+1]>k){
            ll b = a[i]+a[i+1]-k;
            ans+=b;
            a[i+1]-=b;
            if(a[i+1]<0) a[i+1] = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	int k; cin >> k;
	if(k < 10) {
		cout << k << '\n';
		return 0;
	}
	set<string> st;
	int cnt = 9;
	for(int i = 1; i < 10; ++i) {
		string s; s += (char)(i + '0');
		st.insert(s);
	}
	while(true) {
		set<string> nxt;
		for(string s : st) {
			int f = s.front() - '0';
			for(int d = -1; d <= 1; ++d) {
				if(f + d <= 0) continue;
				if(9 < f + d) continue;
				nxt.insert((char)(f + d + '0') + s);
			}
			int b = s.back() - '0';
			for(int d = -1; d <= 1; ++d) {
				if(b + d < 0) continue;
				if(9 < b + d) continue;
				nxt.insert(s + (char)(b + d + '0'));
			}
		}
		if(cnt + nxt.size() >= k) {
			for(string s : nxt) {
				++cnt;
				if(cnt == k) {
					cout << s << '\n';
					return 0;
				}
			}
		}
		cnt += nxt.size();
		st = nxt;
	}
	return 0;
}

Measured memory_bytes: 18304
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;


int main(){
	int N;
	cin >> N;
	vector<pair<int, int>> AB(N);
	for(int i = 0; i < N; i++){
		cin >> AB.at(i).second >> AB.at(i).first;
	}
	
	int time = 0;
	int DeadLine;
	bool judge = true;
	
	sort(AB.begin(), AB.end());
	
	for(int i = 0; i < N; i++){
		time += AB.at(i).second;
		DeadLine = AB.at(i).first;
		if(time > DeadLine){
			judge = false;
			break;
		}
	}
	
	if(judge) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define TYPE int
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}

int main(void){
	int n=in();
	print(n*(n+1)/2);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> mp;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)

/*
*/

ll n,q,d[200010]={},u[200010]={};
vector<ll> v[200010];

void init(){
	cin>>n>>q;
	rep(i,n-1){
		ll a,b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	rep(i,q){
		ll p,x;
		cin>>p>>x;
		d[p]+=x;
	}
}

int main(void){
	init();
	queue<ll> Q;
	Q.push(1);
	u[1]=1;
	while(!Q.empty()){
		ll p = Q.front();Q.pop();
		for(ll p2:v[p]){
			if(u[p2]==0){
				d[p2]+=d[p];
				u[p2]=1;
				Q.push(p2);
			}
		}
	}
	reg(i,1,n)cout<<d[i]<<" ";
	cout<<endl;
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> cnt;
    rep(i, 0, n){
        cin >> a[i];
        if (cnt.count(a[i]) == 0){
            cnt[a[i]] = 0;
            if(cnt.count(a[i]-1) == 0) cnt[a[i]-1] = 0;
            if(cnt.count(a[i]+1) == 0) cnt[a[i]+1] = 0;
        }
        cnt[a[i]] ++;
        cnt[a[i]-1] ++;
        cnt[a[i]+1] ++;
    }
    int out = 0;
    int mx = 0;
    for (auto ai:a){
        if (max(cnt[ai], mx) > mx){
            mx = max(cnt[ai], mx);
            out = cnt[ai];
        }
    }
    cout << out << endl;
    return 0;
}

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

int main(){
	int a,b,c,d,e;
	cin >>a>>b>>c>>d>>e;
	int ans=0;
	if(a < 0){
		ans += abs(a)*c +d;
		a = 0;
	}
	ans += (b-a)*e;
	cout << ans << endl;
	return 0;
}


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

class Main{
	static int N;
	static int[] a;

	static long[][] dp;
	static long[][] cost;
	static boolean[][] memo;
	static int hash = (int)1e+9 + 7;

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

		a = new int[N];
		dp = new long[N][N];
		cost = new long[N][N];
		memo = new boolean[N][N];

		for(int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
			Arrays.fill(memo[i],false);
		}

		dp(0, N - 1);
		System.out.println(cost[0][N - 1]);
		sc.close();
	}

	static long dp(int l, int r){
		if(memo[l][r]) {
			return dp[l][r];
		}

		memo[l][r] = true;

		if(l == r) {
			cost[l][r] = 0;
			return dp[l][r] = a[l];
		}

		long min = Long.MAX_VALUE;
		int index = 0;
		for(int i = l; i < r; i++) {
			long c = dp(l, i) + dp(i + 1, r) + cost[l][i] + cost[i + 1][r];
			if(c < min) {
				min = c;
				index = i;
			}
		}
		cost[l][r] = min;
		return dp[l][r] = dp(l, index) + dp(index + 1, r);
	}
}

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

template<typename T>
istream& operator >> (istream& istr, vector<T>& vec){
    for(T& x: vec) istr >> x;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& vec){
    if(!vec.empty()){
        ostr << vec.front();
        for(auto itr = ++vec.begin(); itr != vec.end(); itr++)
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

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

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& mat){
    if(!mat.empty()){
        ostr << mat.front();
        for(auto itr = ++mat.begin(); itr != mat.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
// vll x(n); x[i]=a;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
// vvll x(m,vi(n)); x[i][j]=a;
typedef pair<ll,ll> pll;
typedef vector<pair<ll,ll>> vpll;
// vpll x(n); x[i]={a,b}; x[i].first/second;

#define PI 3.1415926535897932
#define EPS 1e-12
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()
// sort(all(x));

int main(){
    ll n, ans = 0;
    cin >> n;
    vll a(n);
    cin >> a;
    REP(i,n-1){
        FOR(j,i+1,n){
            ans += a[i]*a[j];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define sz(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define rep(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

struct BIT
{ // 0 indexed
    int n;
    vector<ll> bit;
    BIT(int n) : n(n) { bit.resize(n); }
    BIT(vector<ll> v)
    {
        n = sz(v);
        bit.resize(n);
        rep(i, n) add(i, v[i]);
    }
    void add(int a, ll w)
    {
        for (int x = a; x < n; x |= x + 1)
            bit[x] += w;
    }
    ll sum(int a)
    { // [0, a)
        ll ret = 0;
        for (int x = a - 1; x >= 0; x = (x & (x + 1)) - 1)
            ret += bit[x];
        return ret;
    }
    ll sum(int a, int b) { return sum(b) - sum(a); } // [a, b)
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    lint n;
    cin >> n;
    lint ans=0;
    vector<lint> a(n);
    REP(i, n) { cin >> a[i]; }
    BIT bit(n);
    REP(i, n){
        int index = i + a[i];
        if(index>n-1){
            continue;
        }
        //cout << index << " ";
        bit.add(index-1, 1);
    }
    //cout << "\n";
    REP(i, n)
    {
        int index = i - a[i];
        if (index < 0)
        {
            continue;
        }
        //cout << index << " ";
        int tmp = bit.sum(index)-bit.sum(index-1);
        ans += tmp;
    }
    //cout << "\n";

    cout << ans <<"\n";
    REP(i,n){
        //cout << bit.sum(i) << " ";
    }

    return 0;
}

Measured memory_bytes: 6336
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int main()
{
	long long x,aim;
	cin>>x>>aim;
	if(aim>=x&&x>=0)
	{
		cout<<aim-x;
		return 0;
	}
	if(x==-aim)
	{
		cout<<1;
		return 0;
	}
	if(aim==0)
	{
		if(x<0){
			cout<<abs(x);
			return 0;
		}
		else
		{
			cout<<x+1;
			return 0;
		}
	}
	if(x==0)
	{
		if(aim>0)
		{
			cout<<aim;
			return 0;
		}
		else
		{
			cout<<abs(aim)+1;
			return 0;
		}
	}
	if(x<0&&aim>0&&abs(x)<=aim)
	{
		cout<<aim-abs(x)+1;
		return 0;
	}
	if(x<0&&aim>0&&abs(x)>aim)
	{
		cout<<abs(x)-aim+1;
		return 0;
	}
	if(aim>=x&&aim<=0)
	{
		cout<<aim-x;
		return 0;
	}
	if(aim<x&&x<0)
	{
		cout<<abs(aim)-abs(x)+2;
		return 0;
	}
	if(aim<0&&x>=0&&x<abs(aim))
	{
		cout<<abs(aim)-x+1;
		return 0;
	}
	if(aim<0&&x>abs(aim))
	{
		cout<<x-abs(aim)+1;
		return 0;
	}
	if(x>aim&&aim>0)
	{
		cout<<x-aim+2;
		return 0;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;
const ll infl = 1e17;

typedef unsigned long long ull;

int main()
{
    ll n, m;
    cin >> n >> m;
    if (m == 0)
    {
        cout << "Yes" << endl;
        return 0;
    }
    map<ll, set<pll>> branch;
    ll l, r, d;
    set<ll> point;
    rep(i, m)
    {
        cin >> l >> r >> d;
        branch[l - 1].insert(mp(r - 1, d));
        branch[r - 1].insert(mp(l - 1, -d));
        point.insert(l - 1);
        point.insert(r - 1);
    }
    vector<ll> X(n, -infl);
    queue<ll> check;
    vector<bool> visited(n, false);
    for (auto x:point){
        if (X[x]!=-infl)
            continue;
        X[x] = 0;
        queue<ll> check;
        check.push(x);
        while (!(check.empty()))
        {
            ll now = check.front();
            check.pop();
            visited[now] = true;
            for (auto p : branch[now])
            {
                ll nex = p.F;
                ll d = p.S;
                if (X[nex] == -infl)
                {
                    X[nex] = X[now] + d;
                    check.push(nex);
                }
                else if (X[nex] != X[now] + d)
                {
                    cout << "No" << endl;
                    return 0;
                }
            }
    }}
    ll MIN = infl, MAX = -infl;
    rep(i, n)
    {
        //cout << X[i] << " ";
        if (X[i] > -infl)
        {
            MIN = min(MIN, X[i]);
            MAX = max(MAX, X[i]);
        }
    }
    if (MAX - MIN <= 1e9)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 40960
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
def cnt(str):
    r_num = str.count('r') - str.count('rr')
    s_num = str.count('s') - str.count('ss')
    p_num = str.count('p') - str.count('pp')
    return P*r_num + R*s_num + S*p_num
sum = 0
for i in range(K):
  str = ''
  for j in range(N//K+1):
    if i+K*j < N:
      str = str + T[i+K*j]
  sum = sum + cnt(str)
print(sum)

Measured memory_bytes: 3444
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>

using namespace std;
using ull = unsigned long long;


void moving(ull& src, ull& dest, ull sekisai) {
	if (src != 0) {
		const auto move_count = (src > sekisai) ? sekisai : src;
		src -= move_count;
		dest+= move_count;
	}
}

int main() {
	ull N, a,b,c,d,e;
	cin >> N >> a >> b >> c >> d >> e;

	vector<ull> v{N, 0, 0, 0, 0, 0};

	ull count = 0;
	while (v[5] == 0) {
		count++;
		moving(v[4], v[5], e);
		moving(v[3], v[4], d);
		moving(v[2], v[3], c);
		moving(v[1], v[2], b);
		moving(v[0], v[1], a);
	}
	if (v[5] != N) {
		count += (N - v[5]) / v[5] + (N % v[5] == 0 ? 0 : 1);
	}

	cout << count << endl;
	return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
//////////////
int keta(int n) {
	int ans = 0;
	if (n == 0) {
		return 1;
	}
	while (n) {
		n /= 10;
		++ans;
	}
	return ans;
}

int cal(int N,int S, int ter) {
	int a = N - S;
	while (a) {
		ter /= 10;
		a--;
	}
	return ter%10;
}
void solve() {
	int N, M;
	cin >> N >> M;
	vector<int> S(M), C(M);
	for (int i = 0; i < M; ++i) {
		cin >> S[i] >> C[i];
	}
	vector<int> start{ 0,0,10,100 };
	vector<int> end{ 0,9,99,999 };
	if (M == 0) {
		cout << start[N] << endl;
		return;
	}
	
	for (int num = start[N]; num <= end[N]; ++num) {
		bool flag = true;
		for (int i = 0; i < M; ++i) {
			int res = cal(N, S[i], num);
			if (res != C[i]) {
				flag = false;
				break;
			}
		}
		if (flag == true) {
			cout << num << endl;
			return;
		}
	}
	cout << -1 << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


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

int main(){
string str;
getline(cin, str);

for(int i=0;i<str.size();i++){
    if(isupper(str[i])){
        str[i]=tolower(str[i]);
        
    }else if(islower(str[i])){ 
          str[i]=toupper(str[i]);     
       
    }
    
}  
cout<<str<<endl;
 return 0;  
}


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

void Main()
{
  ll N; cin >> N;
  ll slen = 0;
  string ans = "";
  ll num = N;
  
  if (N%(ll)26 > 0) {
    ans += (char)(N%(ll)26 + 'a' - 1);
    num -= N%(ll)26;
  } else {
    ans += 'z';
    num -= 26;
  }
  ll p = 1;
  
  while (pow((ll)26,p) <= N) {
    //cout << num << endl;
    if (num/(ll)pow((ll)26,p) > 0) {
      if ((num/(ll)pow((ll)26,p)) % ((ll)26) > 0) 
      {  ans += (char)( (num/(ll)pow((ll)26,p)) % ((ll)26) + 'a' - 1);
        num = num - ((num/(ll)pow((ll)26,p)) % ((ll)26))*(ll)pow((ll)26,p);
      } else {
        ans += 'z';
        num = num - (ll)pow((ll)26,p);
      }
      
    } 
    p++;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 4012
#include <stdio.h>
int main() {int RideBack[5],i,j,k;for (i=0;i<5;i++) {scanf("%d",&j);for (k=0;k<i;k++) if (RideBack[k]<j) break;for (int s=4;s>k;s--) RideBack[s]=RideBack[s-1];RideBack[k]=j;} for (i=1,printf("%d",RideBack[0]);i<5;printf(" %d",RideBack[i++]));puts("");return 0;}

Measured memory_bytes: 0
#include <stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head=1, tail, n;

int main(void){
  int i, q;
  int time=0;
  scanf("%d %d", &n, &q);
  tail=n+1;

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  i=1;

  while(head!=tail){
    if(tail==LEN)
      tail=1;
    else if(head==LEN)
      {
	head=1;
	i=1;
      }
    if(Q[i].t-q <= 0){
      time += Q[i].t;
      printf("%s %d\n",Q[i].name,time);
    }
    else{
      time += q;
      Q[i].t -= q;
      Q[tail]=Q[i];
      tail++;
    }
    head++;
    i++;
  }
  return 0;
}

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

int main() {
  ll n,k;
  cin >> n >> k;
  vector<ll> h(n);
  for(int i=0;i<n;i++) {
    cin >> h[i];
  }
  sort(h.begin(), h.end());
  if(n<=k) {
    cout << 0 << endl;
  }
  else {
    ll hsum=0; 
    for(int i=0;i<n-k;i++) {
      hsum+=h[i];
    }
    cout << hsum << endl;
  }
}

Measured memory_bytes: 1792