akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define inf 1e17
#define MAX_SIZE 1000005 

void pr(int arr[], int size) 
{ for (ll i=0; i < size; i++) {printf("%d ", arr[i]); }cout << endl;}

int main () {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  
  ll n , k;
  cin >> n >> k;
  ll a[n + 1] = {};
  for(ll i = 0;i < k;i++){
      ll x;
      cin >> x;
      for(ll j = 0;j < x;j++){
          ll y;
          cin >> y;
          a[y]++;
      }
  }
  
  ll cnt = 0;
  for(ll i =1;i <= n;i++){
      if(a[i] == 0){
         cnt++; 
      }
  }
    cout << cnt << endl;
    
  return 0;
}


Measured memory_bytes: 3680
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    ll N, W;
    cin >> N >> W;


    map<ll, vector<ll>> I;
    REP(i, N) {
        ll w, v;
        cin >> w >> v;
        I[w].pb(v);
    }

    debug(I)

    unordered_map<ll, ll> m;
    m[0] = 0;
    for (auto it=I.begin(); it!=I.end(); it++) {
        sort(it->se.begin(), it->se.end(), greater<ll>());

        ll w = it->fi;
        debug(w, m)

        REP(i, it->se.size()) {
            unordered_map<ll, ll> tmp;
            ll v = it->se[i];
            for(auto j=m.begin(); j!=m.end(); ++j) {
                ll nw = j->fi + w;
                if (m.find(nw) != m.end()) tmp[nw] = max(j->se + v, m[nw]);
                else tmp[nw] = j->se + v;
            }

            for(auto j=tmp.begin(); j!= tmp.end(); ++j) {
                m[j->fi] = max(m[j->fi], j->se);
            }
            debug(tmp)
        }
    }

    debug(m)

    ll ans = 0;
    for(auto it=m.begin(); it!=m.end(); ++it) {
        if(it->fi > W) continue;
        ans = max(ans, it->se);
    }

    cout << ans << endl;
    
}


Measured memory_bytes: 896
#include<stdio.h>
#include<string.h>
int main(){
	char a[100];
	scanf("%s",a);
	int len=strlen(a);
	int i;
	int n=(len-1)/2;
	int m=(len+3)/2;
	int flat=0;
	for(i=0;i<n;i++){
		if(a[i]!=a[n-1-i]){
			flat=1;
			break;
		}
	}
	if(flat==1)
		printf("No");
	else{
		for(i=m-1;i<len;i++)
			if(a[i]!=a[len-1-i]){
				flat=1;
				break;
		}
		if(flat==0){
			printf("Yes");
		}
		else
			printf("No");
	}
	 
}

Measured memory_bytes: 128
//*** cfmasterr ***//
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int cur = 1;
	for (int i = 0; i < n; i++) {
		if (a[i] == cur) {
			++cur;
		}
	}
	int ans = n - (cur - 1);
	cout << (ans == n ? -1 : ans) << '\n';
  return 0;
}




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

int main(){
  string S;
  cin >> S;
  for(char a = 'a'; a <= 'z'; a++){
    bool flag = true;
    for(int i = 0; i < S.size(); i++){
      if(S[i] == a){
	flag = false;
	break;
      }
    }
    if(flag){
      cout << a << endl;
      break;
    }
    if(a == 'z'){
      cout << "None" << endl;
    }
  }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int INF = 19191919;

int main(){
    int x,y,z,n,m,s,t;
    cin >>x >>y >>z >>n >>m >>s >>t;
    --s;
    --t;

    s = x+y+z+s;
    t = x+y+z+n+t;
    int V = x+y+z+n+m;
    vector<vector<int>> G(V);

    auto add_edge = [&](int u, int v){
        G[u].pb(v);
        G[v].pb(u);
    };

    int idx = x+y+z;

    rep(i,n){
        int a,b;
        cin >>a >>b;
        --a;
        --b;
        add_edge(idx,a);
        add_edge(idx,x+b);
        ++idx;
    }

    rep(i,m){
        int c,d;
        cin >>c >>d;
        --c;
        --d;
        add_edge(idx,x+c);
        add_edge(idx,x+y+d);
        ++idx;
    }

    vector<int> d(V,INF);
    d[s] = 0;
    queue<int> que({s});
    while(!que.empty()){
        int v = que.front();
        que.pop();
        for(int e:G[v]){
            if(d[e] > d[v]+1){
                d[e] = d[v]+1;
                que.push(e);
            }
        }
    }

    int ans = d[t]/2;
    if(d[t]==INF) ans = -1;
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 29696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007
ll n;
vector<pair<ll,ll>>ch[16];
ll ans;
ll tr[16];
void cal(){
	ll CH=1;
	for(ll i=0;i<n;i++){
		if(tr[i]!=1){
			continue;
		}
		for(ll j=0;j<ch[i].size();j++){
			ll now=ch[i][j].first;
			ll so=ch[i][j].second;
			if(tr[now]!=so){
				CH=0;
			}
		}
	}
	if(CH==1){
		ll cnt=0;
		for(ll i=0;i<n;i++){
			if(tr[i]==1){
				cnt++;
			}
		}
		ans=max(ans,cnt);
	}
}
void dep(ll now){
	if(now==n){
		cal();
		return ;
	}
	tr[now]=0;dep(now+1);
	tr[now]=1;dep(now+1);
}
int main() {
	cin>>n;
	for(ll i=0;i<n;i++){
		ll now;
		cin>>now;
		for(ll j=0;j<now;j++){
			ll x,y;
			cin>>x>>y;
			x--;
			ch[i].push_back(make_pair(x,y));
		}
	}
	dep(0);
	cout <<ans;
	return 0;
}

Measured memory_bytes: 3596
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

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

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

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

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

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

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

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    a: [i64; n],
  }
  let mut dp = vec![-1i64; n+1];
  dp[0] = 1i64 << 60;
  let mut length = 0;
  for &x in &a {
    if dp[length] >= x {
      length += 1;
      dp[length] = x;
      continue;
    }
    // dp[l] >= x > dp[r]
    let mut l = 0;
    let mut r = length;
    while l + 1 != r {
      let m = (l + r) / 2;
      if dp[m] >= x {
        l = m;
      } else {
        r = m;
      }
    }
    dp[r] = cmp::max(dp[r], x);
  }

  puts!("{}\n", length);
}


Measured memory_bytes: 8444
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0; i < int(n); i++)
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)
#define pb push_back
#define all(x) x.begin(), x.end()
#define sz(a) int((a).size())
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
const int mod = 1e9 + 7;
template<class T, class U> inline void add_self(T &a, U b){a += b;if (a >= mod) a -= mod;if (a < 0) a += mod;}
template<class T, class U> inline void min_self(T &x, U y) { if (y < x) x = y; }
template<class T, class U> inline void max_self(T &x, U y) { if (y > x) x = y; }

#define _deb(x) cout<<x;
void _print() {cerr << "]\n";} template <typename T, typename... V>void _print(T t, V... v) {_deb(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
template <class T, class U> void print_m(const map<T,U> &m, int w=3){if(m.empty()){cout<<"Empty"<<endl; return;}for(auto x: m)cout<<"("<<x.first<<": "<<x.second<<"),"<<endl;cout<<endl;}
template<class T, class U>void debp(const pair<T, U> &pr, bool end_line=1){cout<<"{"<<pr.first<<" "<<pr.second<<"}"; cout<<(end_line ? "\n" : ", ");}
template <class T> void print_vp(const T &vp, int sep_line=0){if(vp.empty()){cout<<"Empty"<<endl; return;}if(!sep_line) cout<<"{ ";for(auto x: vp) debp(x,sep_line);if(!sep_line) cout<<"}\n";cout<<endl;}
template <typename T>void print(const T &v, bool show_index = false){int w = 2;if(show_index){for(int i=0; i<sz(v); i++)cout<<setw(w)<<i<<" ";cout<<endl;}for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<endl;}
template <typename T>void print_vv(const T &vv){if(sz(vv)==0) {cout<<"Empty"<<endl; return;} int w = 3;cout<<setw(w)<<" ";for(int j=0; j<sz(*vv.begin()); j++)cout<<setw(w)<<j<<" ";cout<<endl;int i = 0;for(auto &v: vv){cout<<i++<<" {";for(auto &el: v) cout<<setw(w)<<el<<" ";cout<<"},\n";}cout<<endl;}

int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n,m,t;
    while(cin>>n>>m>>t){
        vi row(n+1), col(m+1);
        map<int,map<int,int>> loc;
        while(t--){
            int x, y; cin>>x>>y;
            row[x]++, col[y]++;
            loc[x][y]++;
        }
        int rans = max_element(all(row)) - row.begin();

        int out = 0;
        fore(i,1,m+1){
            int ans = row[rans] + col[i];
            if(loc.count(rans) && loc[rans].count(i))
                ans-=loc[rans][i];
            max_self(out, ans);
            
        }

        int cans = max_element(all(col)) - col.begin();

        fore(i,1,n+1){
            int ans = row[i] + col[cans];
            if(loc.count(i) && loc[i].count(cans))
                ans-=loc[i][cans];
            max_self(out, ans);
        }

        cout<<out<<"\n";
    }
    return 0;
}

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

using namespace std;

int N, K;
char S[100001];

int main()
{
    scanf("%s%d", S, &K);
    N=strlen(S);
    for(int i=0; i<N; i++)
    {
        int x=S[i]-'a';
        int d=(26-x)%26;
        if(K>=d)
        {
            K-=d;
            S[i]='a';
        }
    }
    S[N-1]=(S[N-1]-'a'+K)%26+'a';
    puts(S);
    return 0;
}


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

using namespace std;
using ll = long long;

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

int main() {
  int n, k;
  cin >> n >> k;

  vector<int> s(n, 0);
  rep(i, k){
    int d;
    cin >> d;
    rep(j, d){
      int a; cin >> a;
      --a;
      ++s[a];
    }
  }
  
  int ans = 0;
  rep(i, n) if(s[i] == 0) ++ans;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll ar[500009],br[500009];
int main()
{
    ll a,b,c,i,j,k,x;
    string s,d;
    cin>>a;
    for(i=1; i<=a; i++)
    {
        cin>>b;
        ar[b]=i;
    }
    for(i=1; i<=a; i++)
    {
        cout<<ar[i]<<" ";
    }
}


Measured memory_bytes: 4864
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan=new Scanner(System.in);
    		
    		int a=Integer.parseInt(scan.next());
    		int b=Integer.parseInt(scan.next());
    		
    		if(a%3==0||b%3==0||(a+b)%3==0) {
    			System.out.print("Possible");
    		}else {
    			System.out.print("Impossible");
    		}

    		
    	
  
    				
 
     
    }
    }

Measured memory_bytes: 21844
#include<stdio.h>

int main(void){
    int N,i;
    char color[101];
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%s",&color[i]);
    }
    for(i=0;i<N;i++){
        if(color[i]=='Y'){
            printf("Four\n");
            return 0;
        }
    }
    printf("Three\n");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    int r,d;
    long long x;
    cin>>r>>d>>x;
    rep(i,10)
    {
        x=r*x-d;
        cout<<x<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
use std::io;

fn gets() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

fn main() {
    let line = gets();
    let n = line.trim().parse::<f32>().ok().unwrap();
    let ans = (n / 2.0).ceil();
    println!("{}", ans);
}


Measured memory_bytes: 2628
from collections import defaultdict

cnt=defaultdict(int)

N, M=map(int, input().split())
A=list(map(int, input().split()))

for i in range(N):
  cnt[A[i]]+=1

tmp=[0]*M
for i in range(M):
  B, C=map(int, input().split())
  cnt[C]+=B
  tmp[i]=C
A+=tmp

tmp=list(cnt.keys())
tmp.sort()
j=-1
out=0
while N>0:
  if cnt[tmp[j]]<=N:
    out+=tmp[j]*cnt[tmp[j]]
    N-=cnt[tmp[j]]
  else:
    out+=tmp[j]*N
    N=0
    
  j-=1
print(out)

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

using namespace std;

int main()
{
	int N, Q;
	cin >> N >> Q;
	string S;
	cin >> S;
	
	// 文字列はN個、ACの数を数えるための配列
	vector<int> ACCount(N, 0);
	for (int i = 0; i < N - 1; i++)
	{
		// 各パラメータ0～Nまでの間にACが見つかった時点で1増やし、見つかるたびに1増やす
		// i = 0～N - 1
		// 現在のindexの配列におけるACカウントの数を次のindexに代入していく
		if (S[i] == 'A' && S[i + 1] == 'C')
		{
			ACCount[i + 1] = ACCount[i] + 1;
		}
		else {
			ACCount[i + 1] = ACCount[i];
		}
	}
	vector<int> answer(Q);
	for (int i = 0; i < Q; i++)
	{
		int l, r;
		cin >> l >> r;
		// indexアクセスするために-1する
		l--;
		r--;
		
		// l文字目からr文字目の "AC" の数の算出
		answer[i] = ACCount[r] - ACCount[l];
		// 出力
		cout << answer[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1792
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include "bits/stdc++.h"

using namespace std;

typedef unsigned long long ll;
typedef int                     integer;
#define int                     long long
#define ii                      pair<int,int>
#define vii                     vector<pair<int,int>>
#define vi                      vector<int>
#define vvi                     vector<vector<int>>
#define f(a,b,c)                for(int a=b;a<c;a++)
#define s(x)                    in>>x
#define s2(x,y)                 in>>x>>y
#define s3(x,y,z)               in>>x>>y>>z
#define s4(x,y,z,w)             in>>x>>y>>z>>w
#define p(x)                    out<<x<<endl
#define p2(x,y)                 out<<x<<" "<<y<<endl
#define pl(x)                   out<<x
#define p2l(x,y)                out<<x<<" "<<y
#define range(v)                v.begin(),v.end()
#define rst(x)                  memset(x, -1, sizeof(x))
#define UNVISITED               -1
#define VISITED                 0
#define EXPLORED                2

void ssolve(std::istream& in, std::ostream& out){
    int n;
    s(n);
    string st;
    s(st);
    int sz = (int)st.size();
    int ans = 0;
    for(int lidx = 0, ridx = sz - 1; lidx < ridx;){
        if (st[lidx]=='W'&&st[ridx]=='R'){swap(st[lidx], st[ridx]); lidx++; ridx--;ans++;}
        else if(st[lidx]=='R'){lidx++;}
        else if(st[ridx]=='W'){ridx--;}
//        p(st);
    }
    p(ans);
    return;
}

class DAlterAltarEditorial {
public:
void solve(std::istream& in, std::ostream& out) {
    ios_base::sync_with_stdio(false);
    in.tie(0);out.tie(0);
    int t;
    int READ = 0;
    if(READ) s(t);
    else t = 1;
    while(t--){
        ssolve(in, out);
    }
}
};

integer main() {
    DAlterAltarEditorial solver;
    std::istream& in(std::cin);
     std::ostream& out(std::cout);
     solver.solve(in, out);
}

Measured memory_bytes: 3748
#include <stdio.h>

int main()
{
    int i, month, day, dayFromJan1st, dayNum[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    char week[7][10] = {"Wednesday", "Thursday", "Friday", "Saturday", "Sunday", "Monday", "Tuesday", };
    
    scanf("%d %d", &month, &day);
    
    while (month != 0) {
        dayFromJan1st = day;
        
        for (i = 0; i <= month - 2; i++) {
            dayFromJan1st += dayNum[i];
        }
        
        printf("%s\n", week[dayFromJan1st % 7]);
        scanf("%d %d", &month, &day);
    }
    
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
const ll INF = 1e16;

void solver1(int N, int K, vector<int> &A, int &ans){

    ans = (N-1)/(K-1);
  	if((N-1)%(K-1) != 0) ans += 1;

    return;
}

int main(){

    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(auto iter = A.begin(); iter != A.end(); ++iter) cin >> *iter;

    int ans1;
    solver1(N, K, A, ans1);

    cout << ans1 << endl;

    return 0;
}

Measured memory_bytes: 3688
import java.util.*;
public class Main{
  public static void main(String[] args) {
    int a,b;
    Scanner sc=new Scanner(System.in);
    a=sc.nextInt();
    b=sc.nextInt();
    if(a<10&&b<10){
      System.out.println(a*b);
    }else{
      System.out.println(-1);
    }
  }
}


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

using namespace std;

typedef long long ll;

int main()
{
  ll T, N;
  cin >> T >> N;
  ll s[100010], t[100010];
  vector<ll> st;
  st.clear();
  ll sum[100010] = {0};
  for(int i = 0; i < N; i++) {
    cin >> s[i] >> t[i];
    st.push_back(s[i]);
    st.push_back(t[i]);
    if(i) sum[i] = sum[i-1] + s[i] - t[i-1];
  }
  ll ans = 0;
  for(int i = 0; i < N; i++) {
    int idx = lower_bound(st.begin(), st.end(), s[i] + T) - st.begin() - 1;
    ans = max(ans, (idx % 2 ? st[idx] : s[i] + T) - sum[idx/2] + sum[i] - s[i]);
  }
  cout << ans << endl;
  return 0;
}

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


int main(){
    int n,l;
    cin >>n>>l;
    int all=0;
    for(int i=0;i<n;i++){
        all += l+i;
    }
    if(l*(l+n-1)<=0) cout << all << endl;
    else if(l+n-1<0) cout << all - (l+n-1) << endl;
    else if(l>0) cout << all - l << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
//const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

const int N=3005;
ll f[N][N],c[N][N],ans = 0;
long long modpow(long long a, long long n, ll mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, mod;
    cin >> n >> mod;
    f[0][0] = c[0][0] = 1;
    for(int i=1;i<=n+1;i++){
    	for(int j=0;j<=i;j++){
    		f[i][j] = ( j ? (f[i-1][j-1] + f[i-1][j] * j)%mod : 0 );
    		c[i][j] = ( j ? (c[i-1][j-1] + c[i-1][j])%mod : 1);
    	}
    }
    for(int i=0;i<=n;i++){
    	ll ret = 0, maki = modpow(2LL, n-i, mod), k = 1;
    	for(int j=0;j<=i;j++){
    		ret += (f[i+1][j+1] * k)%mod;
    		ret %= mod;
    		(k *= maki) %= mod;
    	}
    	if(i&1) ans -= (((c[n][i] * modpow(2LL, modpow(2LL,n-i,mod-1), mod))%mod) * ret) %mod;
    	else ans += (((c[n][i] * modpow(2LL, modpow(2LL,n-i,mod-1), mod))%mod) * ret) %mod;
    	ans %= mod;
    }
    cout << (ans+mod)%mod << endl;
    return 0;
}

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

using namespace std;

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

const ll linf = 1LL << 62;
const int inf = 999999;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

#define Endl endl
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define all(x) x.begin(),x.end()
#define atcoder(int)1e9+7
#define rep(i,n) for(int i = 0;i<n;i++)
#define pb(x) push_back(x)


ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

int  main() {
	
	string s, t;
	cin >> s;
	cin >> t;
	bool jud = true;

	rep(i, 3) {
		if (s[i] != t[2 - i])jud = false;
	}

	if (jud) pr("YES");
	else pr("NO");

	return 0;

}

Measured memory_bytes: 256
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

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

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define divceil(a, b) ((a) + (b)-1) / (b)
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    ll a,b;cin>>a>>b;
    ll x;cin>>x;

    ll ans = 0;
    if (a==0){
        a++;
        ans++;
    }

    ans += b/x - (a-1)/x;
    cout << ans << endl;
    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt();
	    int M = sc.nextInt();
        int i;
	    for(i = 0; i < M; i++){
	      N -= sc.nextInt();
	    }
	    if(N<0){
	      System.out.println(-1);
	    } else {
	      System.out.println(N);
	    }
	}
}


Measured memory_bytes: 46180
my $n = <STDIN>;
my ($k, $c, $d) = (15, 0, 0);

foreach $i (split //, $n)
{
    if($i eq "o"){ $c = $c + 1;}
    $d = $d + 1;
}

if($k-$d+1 >= 8-$c){print "YES\n";}
else {print "NO\n";}


Measured memory_bytes: 512
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

ll a[1010];
signed main(void)
{
	while(true) {
		int n;
		cin >> n;
		if(!n) break;
		fill(a, a+1010, LLINF);
		bool xx = false, ng = false;
		REP(i, n) {
			string s;
			cin >> s;
			if(s == "x") {
				if(xx) ng = true;
				xx = true;
				continue;
			}
			a[i] = stoi(s);
			xx = false;
		}
		if(ng) {cout << "none" << endl; continue;}

		ll ma = LLINF, mi = -LLINF;
		bool conf = false;
		REP(i, n) {
			if(a[i] == LLINF) {
				if((i+1)%2) {
					if(i != 0) ma = min(ma, a[i-1]-1);
					if(i != n-1) ma = min(ma, a[i+1]-1);
				} else {
					mi = max(mi, a[i-1] + 1);
					if(i != n-1) mi = max(mi, a[i+1]+1);
				}
			} else {
				ng = false;
				if((i+1)%2) {
					if(i && a[i-1] != LLINF) ng |= (a[i] >= a[i-1]);
					if(i != n-1 && a[i+1] != LLINF) ng |= (a[i] >= a[i+1]);
				} else {
					if(a[i-1] != LLINF) ng |= (a[i] <= a[i-1]);
					if(i != n-1 && a[i+1] != LLINF) ng |= (a[i] <= a[i+1]);
				}
				if(ng) {
					cout << "none" << endl;
					conf = true;
					break;
				}
			}
		}
		if(conf) continue;

		if(ma < mi) cout << "none" << endl;
		else if(ma == mi) cout << ma << endl;
		else cout << "ambiguous" << endl;
	}

	return 0;
}

Measured memory_bytes: 3148
N, x = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in range(N-1):
    if x < a[i]:
        ans += a[i]-x
        a[i] = x
    
    if x < a[i+1] + a[i]:
        ans += a[i+1] + a[i] - x
        a[i+1] =  x- a[i]
print(ans)

Measured memory_bytes: 14252
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

int H, A;

int main()
{
    cin >> H >> A;
    if (H % A == 0)
    {
        cout << H / A << endl;
        return 0;
    }
    else
    {
        cout << H / A + 1 << endl;
        return 0;
    }
}


Measured memory_bytes: 256
K,A,B = map(int, input().split())
eh = 1
eAB = (B-A)/2
if eh >= eAB:
    print(K+1)
else:
    bis = A
    bis += (K-(A-1))//2*(B-A) + (K-(A-1))-(K-(A-1))//2*2
    print(bis)




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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

ll N,M;
vector<ll> A;

int main(){
    cin>>N>>M;
    A.resize(N);
    rep(i,N)cin>>A[i];
    vector<ll> V(N);
    V[0] = A[0]%M;
    rep1(i,N-1)V[i] = (V[i-1] + A[i])%M;
    sort(V.begin(),V.end());
    map<ll,ll> r;;;;
    rep(i,N) r[V[i]]++;
    ll res = 0;
    for(auto p:r){
        ll amari = p.first;
        ll cnt = p.second;
        if(amari==0){
            res += cnt;
            res += cnt*(cnt-1)/2;
        }else{
            res += cnt*(cnt-1)/2;
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 8784
#include <bits/stdc++.h>
using namespace std;
int dep[100010];
int par[100010][19];
vector<int> g[100010];
void dfs(int v,int u,int d){
  dep[v]=d;
  for(int i=0; i<g[v].size(); i++){
    int w=g[v][i];if(w==u) continue;
    par[w][0]=v;dfs(w,v,d+1);
  }
}
int lcp(int a,int b){
  if(dep[a]<dep[b]) swap(a,b);
  for(int i=0; i<19; i++){
    if((dep[a]-dep[b])&(1<<i)) a=par[a][i];
  }
  if(a==b) return a;
  for(int i=18;i>=0;i--){
    if(par[a][i]!=par[b][i]) a=par[a][i],b=par[b][i];
  }
  return par[a][0];
}
int n,m;
void init() {
  memset(par,0,sizeof(par));
  dfs(0,-1,0);
  for(int i=0; i<18; i++)for(int j=0; j<n; j++) par[j][i+1]=par[par[j][i]][i];
}

string r[111111];
int main() {
  while(cin >> n >> m && n) {
    for(int i=0; i<n; i++) g[i].clear();
    string s;
    getline(cin,s);
    map<string,int> ma;
    for(int i=0; i<n; i++) {
      getline(cin,s);
      stringstream ss;
      string t;
      ss << s;
      ss >> t;
      ma[t]=i;
      int c=0;
      for(int j=0; j<s.size(); j++) {
        if(s[j]==' ') c++;
        else break;
      }
      if(c) {
        g[ma[t]].push_back(ma[r[c-1]]);
        g[ma[r[c-1]]].push_back(ma[t]);
      }
      r[c]=t;
    }
    init();
    while(m--) {
      getline(cin,s);
      stringstream ss;
      ss << s;
      string x,y,z;
      ss >> x;
      ss >> z;ss >> z;ss >> z;
      ss >> y;ss >> y;
      y=y.substr(0,y.size()-1);
      int xx=ma[x],yy=ma[y];
      bool f=0;
      if(z=="parent") {
        if(lcp(xx,yy)==xx&&dep[yy]-dep[xx]==1) f=1;
      } else if(z=="child") {
        if(lcp(xx,yy)==yy&&dep[xx]-dep[yy]==1) f=1;
      } else if(z=="sibling") {
        if(dep[xx]==dep[yy]&&dep[xx]-dep[lcp(xx,yy)]==1) f=1;
      } else if(z=="descendant") {
        if(lcp(xx,yy)==yy&&dep[xx]-dep[yy]>=1) f=1;
      } else {
        if(lcp(xx,yy)==xx&&dep[yy]-dep[xx]>=1) f=1;
      }
      if(f) cout << "True" << endl;
      else cout << "False" << endl;
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 13916
// #define LOCAL
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll  = long long;
using vi  = vector<int>;
using  vii = vector<vi>;
 
int main() {
	string s1,s2;
	cin>>s1>>s2;
	int m=s1.size(),n=s2.size();

	vii dp(m+1,vi(n+1));
	for(int i=0;i<=m;i++){
		for(int j=0;j<=n;j++){
			if(i==0||j==0)
				dp[i][j]==0;
			else if(s1[i-1]==s2[j-1])
				dp[i][j]=dp[i-1][j-1]+1;
			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
		// debug()<< imie(dp[i]);
	}
	
	 vector<char> trace;
	 int i=m,j=n;
	 while(i>0 && j>0){
	 	if(dp[i-1][j]==dp[i][j-1] && dp[i][j-1]==dp[i-1][j-1]){
	 		if(dp[i-1][j-1]!=dp[i][j])
	 			trace.push_back(s1[i-1]);
	 			i--; j--;
	 		}
	 	else if(dp[i-1][j]==dp[i][j-1] && dp[i][i-1]!=dp[i-1][j-1]){
	 		if(i>=1)i--;
	 			else j--;
	 		}
	 	else if(dp[i][j-1]>dp[i-1][j])
	 		j--;
	 	else
	 		i--;
	 	}
	 	if(trace.empty()){
	 		cout<<endl;
	 	}
	 	else{
			for(int k=trace.size()-1;k>=0;k--){
	 			cout<<trace[k];
	 		}cout<<endl;
		}
}

Measured memory_bytes: 38616
from collections import deque
import re
s = input()
t = input()

d = deque()
for i, ch in enumerate(s[::-1]):
    d.appendleft('.' if ch == '?' else ch)
    if len(d) < len(t):
        continue
    if re.match(''.join(list(d)[:len(t)]), t):
        ans = s[:len(s) - i - 1] + t + s[len(s) - i - 1 + len(t):]
        print(ans.replace('?', 'a'))
        exit()
print('UNRESTORABLE')

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

using namespace std;
using ll = long long int;

int main()
{
  ll N;
  cin >> N;
  vector<ll> A(N);
  for (ll i = 0; i < N; i++) cin >> A[i];

  ll cash = 1000;
  for (ll i = 0; i < N - 1; i++)
  {
    ll stock = 0;
    if (A[i] < A[i + 1]) {
      stock = cash / A[i];
    }

    cash += (A[i + 1] - A[i]) * stock;
  }
  cout << cash << endl;
}

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

using namespace std;

#define int long long

int32_t main(){

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	string s;
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5])
		cout<<"Yes";
	else
		cout<<"No";

	return 0;
}

Measured memory_bytes: 256
# abc174_a.py
# https://atcoder.jp/contests/abc174/tasks/abc174_a

global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    X = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    # values = list(map(int, lines[0].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    if X >= 30:
        result = 'Yes'
    else:
        result = 'No'

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['25']
        lines_export = ['No']
    if pattern == 2:
        lines_input = ['30']
        lines_export = ['Yes']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9180
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <cassert>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

struct segtree{
  ll M=1, INIT;
  vector<ll> dat;
  segtree(ll N, ll num):INIT(num){
    while(M<N) M*=2;
    dat.resize(M*2-1, num);
  }
  void update(ll x, ll k){
    k+=M-1;
    dat[k] = x;
    while(k>0) k = (k-1)/2, dat[k] = max(dat[k*2+1],dat[k*2+2]);
  }
  ll query(ll a, ll b=-1, ll k=0, ll l=0, ll r=-1){
    if(r==-1) r = M;
    if(b==-1) b = M;
    if(r<=a || b<=l) return INIT;
    if(a<=l && r<=b) return dat[k];
    ll A = query(a, b, k*2+1, l, (l+r)/2);
    ll B = query(a, b, k*2+2, (l+r)/2, r);
    return max(A, B);
  }
};


int main(){
  ll INF = 10000000000;
  ll n, q;scanf("%lld %lld", &n, &q);
  segtree seg(n, -INF);
  for(int i=0;i<n;i++){
    ll a;scanf("%lld", &a);
    seg.update(a, i);
  }
  for(int i=0;i<q;i++){
    ll t, a, b;scanf("%lld %lld %lld", &t, &a, &b);
    a--;

    if(t==1) seg.update(b, a);
    else if(t==2) printf("%lld\n", seg.query(a, b));
    else{
      if(seg.query(a, n)<b){
        printf("%lld\n", n+1);
        continue;
      }
      ll l = a-1, r = n-1;//l:ない　
      while(r-l>1){
        ll mid = (l + r)/2;
        if(seg.query(a, mid+1)<b) l = mid;
        else r = mid;
      }
      printf("%lld\n", r+1);
    }
  }
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  int n;cin>>n;
  vector<ll> a(n+1),limit(n);
  rep(i, n+1)cin>>a[i];

  if(n==0){
    if(a[0]==1)cout<<1<<endl;
    else cout<<-1<<endl;
    return 0;
  }

  limit[n-1]=a[n]+a[n-1];
  rrep(i, n-1){
//cout<<limit[i+1]<<' '<<a[i]<<endl;
    limit[i] = limit[i+1]+a[i];
  }
  limit.push_back(a.back());

//  for(auto c:limit)cout<<c<<' ';cout<<endl;

  ll result = 1;
  ll l=1;

  if(a[0]==1 && n>0) { cout<<-1<<endl; return 0; }

  rep(i, n){
    ll c=(ll)a[i];

    ll nl = min<ll>((l-c)*2LL, limit[i+1]);
    if(l-c<0 || nl-a[i+1]<0) { 
//cout<<nl<<'-'<<a[i+1]<<endl;
cout<<-1<<endl; return 0;}
    if(l==0 && a[i]>0) { cout<<-1<<endl; return 0;}

    if(i<n-1)result += nl;
//cout<<l<<' '<<c<<' '<<l-c<<' '<<nl<<' '<<result<<endl;
    swap(l, nl);
  }
//cout<<l<<endl;
//  if(a.back()>limit.back() || a.back()>l) { cout<<-1<<endl; return 0; }

  cout<<result+a.back()<<endl;

  return 0;
}


Measured memory_bytes: 5592
short*p,v[][99];main(c,n,m,i,y){for(;m=scanf("%d %[^\n] %[^\n]",&n,v,v+1)*n;printf(m>n?"NA\n":"%d\n",m))for(i=2;i--;m=c)for(c=0,y=n;c<m&y-->1;y+=y==n|*p&2?2:*p&p[-1]&1?0:!++c-1)p=y+v[c+i&1];}

Measured memory_bytes: 0
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 100000000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define endl "\n"
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   string s;
   cin>>s;
   if(s[s.length()-1]=='s')s+="es";
   else
    s+="s";
   cout<<s<<endl;
}


Measured memory_bytes: 3660
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

int main(void) {
	int N;
	cin >> N;
	vector<int> A(N);
	vector<long long> B(N + 1);
	for (int i = 0; i < N; i++) cin >> A.at(i);
	for (int i = 0; i < N; i++) B.at(A.at(i))++;
	long long tmp = 0;
	for (int i = 1; i <= N; i++) tmp += B.at(i)*(B.at(i) - 1) / 2;
	for (int i = 0; i < N; i++) {
		long long ans = 0;
		int a = A.at(i);
		ans = tmp - B.at(a)*(B.at(a) - 1) / 2 + (B.at(a) - 1)*(B.at(a) - 2) / 2;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
#define pb push_back

typedef long long ll;
using namespace std;
int MOD = (1e9+7);
const int idxMax = (9e5+1);
int powMod(int a, int n, int m){
  ll pro = 1, tmp = a;
  for(; n > 0; n >>= 1){
    if(n & 1) pro = (pro * tmp) % m;
    tmp = tmp * tmp % m;
  }
  if (pro < 0) cout << "pro < 0" << a << "," << n << endl;
  return pro;
}

int A[idxMax], R[idxMax];
int comb(int n, int c){
  return int(ll(A[n + c]) * R[n] % MOD * R[c] % MOD);
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M, K;
  cin >> N >> M >> K;

  ll t = 1;
  A[0] = 1;
  FOR(i, 1, N + M + K + 1){
    t = t * i % MOD;
    A[i] = t;
  }
  t = powMod(t, MOD - 2, MOD);
  R[N + M + K] = t;
  FORR(i, N + K + M, -1){
    R[i] = t;
    t = t * i % MOD;
  }
  int sum = M + K;
  ll pre = 1, p3 = powMod(3, sum, MOD), ret = p3, r3 = powMod(3, MOD - 2, MOD);
  if(M > K) swap(M, K);

  FOR(i, 1, sum + 1){
    pre <<= 1;
    p3 = p3 * r3 % MOD;
    if(i > M){
      pre += MOD - comb(M, i - M - 1);
      if(i > K) pre += MOD - comb(K, i - K - 1);
    }
    pre %= MOD;
    ret += pre * comb(N - 1, i) % MOD * p3 % MOD;
    ret %= MOD;
  }
  cout << ret << endl;
}


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

typedef long long ll;

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,l,n) for(int i=(l);i<(n);i++)

int main(){
    int K;
    queue<ll> runrun;
    cin >> K;
    for(int i=1;i<10;i++) {
        runrun.push(i);
    }
    ll p;
    for(int i=0;i<K;i++)
	{
		p = runrun.front();
		runrun.pop();
        int last = p % 10;
		if(last!=0)
		{
			runrun.push(p*10+last-1);
		}
		runrun.push(p*10+last);
		if(last!=9)
		{
			runrun.push(p*10+last+1);
		}
	}
    cout << p;
    return 0;
}


Measured memory_bytes: 1792
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

n=n0()
x=n1()
ans=999999999
for y in range(min(x),max(x)+1):
    s=0
    for i in range(n):
        s+=(x[i]-y)**2
    ans=min(ans,s)
print(ans)

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

int main()
{
	int n,a[25],b[25],c[25];
	scanf("%d",&n);
	for(int i = 1;i <= n;i++) scanf("%d",&a[i]);
	for(int i = 1;i <= n;i++) scanf("%d",&b[i]);
	for(int i = 1;i <= n-1;i++) scanf("%d",&c[i]);
	
	int ans = 0;
	ans += b[a[1]];
	for(int i = 2;i <= n;i++){
		if(a[i] == a[i-1]+1) ans += b[a[i]]+c[a[i-1]];
		else ans += b[a[i]];
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

//#define FILE_IO

typedef long long LL;

LL N, ans;

void solve(LL N, LL a)
{
    if(a < 1 || a > N)  return;

    LL cat = N / a;
    LL rest = N % a;
    if(cat == rest) ans += a;
}

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    cin >> N;
    for(LL i = 1; i * i <= N; i++)
        if(N % i == 0)
        {
            solve(N, i - 1);
            if( (N / i) != i )
                solve(N, (N / i) - 1);
        }
    cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > piii;
#define pb push_back
#define debug(x) cout << x << endl
#define fastio ios_base::sync_with_stdio(0), cin.tie(0)
#define PI acos(-1)
#define all(c) c.begin(), c.end()
#define SET(x, y) memset((x), y, sizeof(x))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const LL INF64 = 1e18;

const int N = 1e5 + 5;

LL dp[N][2]; //0 = white, 1 black
bool vis[N];
vector<int> adjList[N];

pair<LL, LL> dfs(int now) {
	vis[now] = 1;
	LL cnt = 0LL;
	LL w = 1, b = 1;
	for (auto it : adjList[now]) {
		if (!vis[it]) {
			cnt++;
			auto cur = dfs(it);
			w = (w * (cur.first + cur.second) % MOD) % MOD;
			b = (b * (cur.first) % MOD) % MOD;
		}
	}
	if (cnt == 0) {
		return {1, 1};
	}
	return {w, b};
}

int main() {
	SET(dp, 0);
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		adjList[a].pb(b);
		adjList[b].pb(a);
	}
	auto ans = dfs(1);
	printf("%lld\n", (ans.first + ans.second) % MOD);
	return 0;
}
		

Measured memory_bytes: 12928
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a < b && b < c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}

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

using namespace std;
typedef long long ll;
#define a first
#define b second
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)

int main(){
	ll N; cin>>N;
	map<ll,ll> m;
	rep(i,N){
		ll tmp; cin>>tmp;
		m[tmp]++;
	}
	m[0];
	ll cnt=2,ans=1;
	for(auto itr=--m.ed;itr!=--m.bg;itr--){
		while(itr->b>=2){
			if(cnt>0){
				ans*=itr->a;
				cnt--;
			}
			if(cnt==0){
				cout<<ans;
				return 0;
			}
			itr->b-=2;
		}
	}
	cout<<0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int get() { int r; cin >> r; return r; }
map<char, int>m;
int n, k, p, ans; string s;
bool b[123456];
signed main() {
	cin >> n >> k;
	cin >> p; m['s'] = p;
	cin >> p; m['p'] = p;
	cin >> p; m['r'] = p;
	cin >> s;
	for0(i, n) {
		if (i >= k && s[i] == s[i - k]) {
			if (b[i % k] == 1)b[i % k] = 0;
			else {
				b[i % k] = 1; ans += m[s[i]];
			}
		}
		else { ans += m[s[i]]; b[i % k] = 1; }
	}
	cout << ans << endl;
}

Measured memory_bytes: 512