akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// clang-format off

using LL = long long;
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();i++)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
 
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"["; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
os<<"{"; FOR(it,t) {if(it!=t.begin()) os<<","; os<<*it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// clang-format on

LL MAX_N = 110;
LL MAX_V = 100110;
long long INF = 1LL << 60;
long long dp[110][100110];

// solver code
void solve(long long N, long long W, std::vector<long long> w, std::vector<long long> v) {
  for (int i = 0; i < MAX_N; i++) {
    for (int j = 0; j < MAX_V; j++) {
      dp[i][j] = INF;
    }
  }

  dp[0][0] = 0;

  for (int i = 0; i < N; i++) {
    for (int sum_v = 0; sum_v < MAX_V; sum_v++) {
      if (sum_v - v[i] >= 0)
        chmin(dp[i + 1][sum_v], dp[i][sum_v - v[i]] + w[i]);

      chmin(dp[i + 1][sum_v], dp[i][sum_v]);
    }
  }

  LL ans = 0;

  for (int i = 0; i < MAX_V; i++) {
    if (dp[N][i] <= W) {
      ans = i;
    }
  }
  cout << ans << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  long long W;
  scanf("%lld", &W);
  std::vector<long long> w(N);
  std::vector<long long> v(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &w[i]);
    scanf("%lld", &v[i]);
  }
  solve(N, W, std::move(w), std::move(v));
  return 0;
}


Measured memory_bytes: 86400
#include <iostream>
#include <vector>
#define ll long long
using namespace std;

int main() {
  int N; cin >> N;
  vector<int> num(100001);
  for (int i = 0; i < 100000; i++) num[i] = 0;
  ll sum = 0;
  for (int i = 0; i < N; i++) {
    int A; cin >> A;
    sum += A;
    num[A]++;
  }
  int Q; cin >> Q;
  for (int i = 0; i < Q; i++) {
    int B, C; cin >> B >> C;
    sum += (C-B) * num[B];
    num[C] += num[B];
    num[B] = 0;
    cout << sum << endl;
  }
  return 0;
}

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

const int mod=1012200221;
int ran(){return rand()%1000*1000000+rand()%1000*1000+rand()%1000+1;}

long long ans;
int n,v[9],inv[9];
char s[250010];
struct node{int nw[9];}c,fk[250010],fb[250010],O;

bool operator <(node a,node b)
{
	for (int i=0; i<9; i++)
	{
		if (a.nw[i]<b.nw[i]) return 1;
		if (a.nw[i]>b.nw[i]) return 0;
	}
	return 0;
}

map<node,int> ma;

node f1(node x) 
{
	for (int i=0; i<9; i++) x.nw[i]=(x.nw[i]==mod-1?0:x.nw[i]+1);
	return x;
}

node f2(node x)
{
	for (int i=0; i<9; i++) x.nw[i]=(x.nw[i]==0?mod-1:x.nw[i]-1);
	return x;
}

node f3(node x)
{
	for (int i=0; i<9; i++) x.nw[i]=1ll*x.nw[i]*v[i]%mod;
	return x;
}

node f4(node x)
{
	for (int i=0; i<9; i++) x.nw[i]=1ll*x.nw[i]*inv[i]%mod;
	return x;
}

node operator +(node a,node b)
{
	for (int i=0; i<9; i++) a.nw[i]=(a.nw[i]+b.nw[i]>=mod?a.nw[i]+b.nw[i]-mod:a.nw[i]+b.nw[i]);
	return a;
}

node operator -(node a,node b)
{
	for (int i=0; i<9; i++) a.nw[i]=(a.nw[i]<b.nw[i]?a.nw[i]-b.nw[i]+mod:a.nw[i]-b.nw[i]);
	return a;
}

node operator *(node a,node b)
{
	for (int i=0; i<9; i++) a.nw[i]=1ll*a.nw[i]*b.nw[i]%mod;
	return a;
}

int quickmi(int a,int b)
{
	int t=1;
	for (; b; b>>=1,a=1ll*a*a%mod)
		if (b&1) t=1ll*t*a%mod;
	return t;
}

int main()
{
	srand(114514),O=(node){{0,0,0,0,0,0,0,0,0}};
	for (int i=0; i<9; i++) v[i]=ran(),inv[i]=quickmi(v[i],mod-2);
	scanf("%d%s",&n,s+1),c=O;
	for (int i=n; i; i--)
		if (s[i]=='+') c=f1(c); else
		if (s[i]=='-') c=f2(c); else
		if (s[i]=='>') c=f3(c); else
		if (s[i]=='<') c=f4(c);
	fk[n+1]=f1(O),fb[n+1]=O;
	for (int i=n; i; i--)
		if (s[i]=='+') fb[i]=(fb[i+1]-fk[i+1]),fk[i]=fk[i+1]; else
		if (s[i]=='-') fb[i]=(fb[i+1]+fk[i+1]),fk[i]=fk[i+1]; else
		if (s[i]=='>') fb[i]=fb[i+1],fk[i]=f4(fk[i+1]); else
		if (s[i]=='<') fb[i]=fb[i+1],fk[i]=f3(fk[i+1]);
	ma.clear(),ans=0;
	for (int i=n; i; i--)
	{
		ma[fb[i+1]]++;
		ans+=ma[(fk[i]*c)+fb[i]];
	}
	return printf("%lld\n",ans),0;
}

Measured memory_bytes: 57088
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#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 ll;
typedef long double ld;
using namespace std;

ll a, b, c, d;
ll INF = 3000000000000000000;
map<ll, ll> mp;

ll solve(ll n){
  if(mp.find(n)!=mp.end()) return mp.at(n);
  if(n==0) return 0;
  if(n==1) return d;
  mp.emplace(n, INF);
  ll ret = INF;
  if(solve(n/2)<INF){
    ret = min(ret, d*(n%2)+a+solve(n/2));
  }
  if(solve((n/2)+1)<INF){
    ret = min(ret, d*(2 - n%2)+a+solve((n/2)+1));
  }
  if(solve(n/3)<INF){
    ret = min(ret, d*(n%3)+b+solve(n/3));
  }
  if(solve((n/3)+1)<INF){
    ret = min(ret, d*(3-(n%3))+b+solve((n/3)+1));
  }
  if(solve(n/5)<INF){
    ret = min(ret, d*(n%5)+c+solve(n/5));
  }
  if(solve((n/5)+1)<INF){
    ret = min(ret, d*(5-(n%5))+c+solve((n/5)+1));
  }
  if((INF/d)>abs(n)) ret = min(ret, d*abs(n));
  auto itr = mp.find(n);
  (*itr).second = ret;
  return ret;
}

int main(int argc, char const *argv[]) {
  ll T;std::cin >> T;
  re(o, T) {
    mp.clear();
    ll n;std::cin >> n >> a >> b >> c >> d;
    ll ans = solve(n);

    std::cout << ans << '\n';
  }
  return 0;
}


Measured memory_bytes: 4280
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll a[4];
int main(){
	ll n;
	cin  >> a[0] >> a[1] >> a[2] >> a[3] >> n;
	ll N = n;
	ll c = a[3];

	a[0] <<= 3; a[1] <<= 2; a[2] <<= 1;

	sort(a, a + 4);
	if(a[0] == a[1]){
		cout << (a[0] * N)/ 2; return 0;
	}

	else if(a[0] == c && (N & 1)){
		cout << (a[1] + a[0] * (N - 1))/2; return 0;
	}

	cout << (a[0] * N) / 2; return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define pb push_back
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
#define umap unordered_map
#define all(x) x.begin(), x.end()
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x%M;
    while (y > 0) {
        if (y & 1)
            res = (res*x)%M ;
        y = y>>1;
        x = (x*x)%M ;
    }
    return res%M;
}
vector<bool> vis;
vll dp;
lli dfs(lli root, vector<vll>& S){
    vis[root] = true;
    lli ans = 0;
    loop(i, 0, S[root].size()){
        if(vis[S[root][i]]){
            ans = max(dp[S[root][i]], ans);
            continue;
        }
        ans = max(dfs(S[root][i], S), ans); 
    }
    dp[root] = ans + 1;
    return dp[root];
}
lli solve(){
    lli n, m;
    cin>>n>>m;
    vector<vll> S(n+1);
    loop(i, 0, m){
        lli u, v;
        cin>>u>>v;
        S[u].push_back(v);
    }
    dp.clear();
    vis.clear();
    vis.resize(n+1, false);
    dp.resize(n+1, 0);
    loop(i, 1, n+1){
        if(vis[i])
            continue;
        dfs(i, S);
    }
    cout<<*max_element(all(dp)) - 1<<"\n";
    return 0;
}
int main(){
    fastio;
    lli t;
	// cin>>t;
    t = 1;
    while(t>0){ 
        t--;
        solve();
    }
}

Measured memory_bytes: 12888
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		String s = fs.next();
		
		if(s.charAt(0) < 91) {
			System.out.println("A");
		}else {
			System.out.println("a");
		}
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 32624
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <string>

#define reps(i,s,n) for(int (i) = (s); (i) < (n); (i)++)
#define rep(i,n) reps(i,0,n)
using namespace std;
using ll = long long;
using vi = vector<ll>;

int main(){
    string s;
    cin >> s;
    int slen = s.length();
    vi cnt(slen+1,0);
    rep(i,slen){
        if(s[i] == '<')cnt[i+1] = max(cnt[i]+1,cnt[i+1]);
    }

    for(int i = slen-1; i >= 0 ; i--){
        if(s[i] == '>') cnt[i] = max(cnt[i+1]+1,cnt[i]); 
    }

    // rep(i,slen+1){
    //     cout << cnt[i] << " " ;
    // }
    // cout << endl;
    ll ans = 0;
    rep(i,slen+1){
        ans += cnt[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7604
use proconio::{fastout, input};
#[fastout]
fn main() {
    input! {n:usize,mut a:[usize;n]}
    let mut sum = 0;
    let mut b = 0;
    let mut tmp = 0;
    let mut i = 0;
    while i < a.len() {
        if i != 0 {
            b = a[i - 1];
            while b > a[i] + tmp {
                tmp += 1;
            }
            sum += tmp;
            a[i] += tmp;
            tmp = 0;
        }

        i += 1;
    }
    println!("{}", sum);
}


Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
int n,a[205];
vector<int> ans;
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	for(int i=0;i<n;i++){
		for(int j=1;j<n;j++){
			ans.push_back(1);
			for(int i=1;i<n;i++) swap(a[i],a[i-1]);
			if(a[0]<a[n-1]){
				ans.push_back(n-1);
				swap(a[n-1],a[0]);
			}
		}
		ans.push_back(1);
		for(int i=1;i<n;i++) swap(a[i],a[i-1]);
	}
	printf("%d\n",ans.size());
	for(int i=0;i<ans.size();i++){
		printf("%d\n",ans[i]);
	}
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (int i = m; i < (n); ++i)
using namespace std;
using ll = long long;

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

Measured memory_bytes: 256
#define DEBUG 0

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

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

vi adjList[100000];
int visited[100000];
int doDFS(int u,int p,int del) {
    int i;
    visited[u] = 1;
    for (i = 0; i < adjList[u].size(); i++) {
        int v = adjList[u][i];
        if (v == del) continue;
        if (v != p) {
            if (visited[v]) return 1;
            else if (doDFS(v,u,del)) return 1;
        }
    }
    return 0;
}
int main() {
    int i;
    int N,M,u,v;
    scanf("%d %d",&N,&M);
    for (i = 0; i < M; i++) {
        scanf("%d %d",&u,&v);
        u--,v--;
        adjList[u].pb(v);
        adjList[v].pb(u);
    }

    for (i = 0; i < N; i++) {
        if (adjList[i].size() & 1) {
            printf("No\n");
            return 0;
        }
    }
    for (i = 0; i < N; i++) {
        if (adjList[i].size() >= 6) {
            printf("Yes\n");
            return 0;
        }
    }
    vi cand;
    for (i = 0; i < N; i++) {
        if (adjList[i].size() == 4) cand.pb(i);
    }
    int j;
    for (i = 0; i < cand.size(); i++) {
        fill(visited,visited+N,0);
        for (j = 0; j < N; j++) {
            if (!visited[j] && (j != cand[i])) {
                if (doDFS(j,-1,cand[i])) break;
            }
        }
        if (j < N) {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");

    return 0;
}



Measured memory_bytes: 8832
#![allow(unused_imports)]
#![cfg_attr(feature = "cargo-clippy", allow(redundant_field_names))]

use std::{cmp, fmt};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Write};
use std::ops::{Add, Div, Mul, Sub};
use std::str::{self, FromStr};

fn main() {
    let n: u32 = {
        let mut sc = InputScanOnce::new(io::stdin(), 1024);
        sc.next()
    };
    let m = {
        let mut v = (2..55556).collect::<Vec<u32>>();
        let mut ps = vec![];
        loop {
            let p = v[0];
            if p.pow(2) >= 55555 {
                ps.extend(v);
                break;
            }
            v = v.into_iter().skip(1).filter(|n| n % p > 0).collect();
            ps.push(p);
        }
        let mut m = vec![false; 55555];
        for p in ps {
            m[p as usize] = true;
        }
        m
    };
    let xs = (1..5556)
        .map(|n| 10 * n + 1)
        .filter(|&n| m[n])
        .take(n as usize);
    for (i, x) in xs.into_iter().enumerate() {
        print!("{}{}", if i > 0 { " " } else { "" }, x);
    }
    println!("");
}

struct InputScanOnce {
    buf: Vec<u8>,
    pos: usize,
}

#[allow(dead_code)]
impl InputScanOnce {
    fn new<R: Read>(mut reader: R, estimated: usize) -> Self {
        let mut buf = Vec::with_capacity(estimated);
        let _ = io::copy(&mut reader, &mut buf).unwrap();
        InputScanOnce { buf: buf, pos: 0 }
    }

    #[inline]
    fn next<T: FromStr>(&mut self) -> T
    where
        T::Err: fmt::Debug,
    {
        let mut start = None;
        loop {
            match (self.buf[self.pos], start.is_some()) {
                (b' ', true) | (b'\n', true) => break,
                (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                (_, false) => start = Some(self.pos),
            }
        }
        let target = &self.buf[start.unwrap()..self.pos];
        unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        T::Err: fmt::Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<T1: FromStr, T2: FromStr>(&mut self, n: usize) -> Vec<(T1, T2)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<T1: FromStr, T2: FromStr, T3: FromStr>(&mut self, n: usize) -> Vec<(T1, T2, T3)>
    where
        T1::Err: fmt::Debug,
        T2::Err: fmt::Debug,
        T3::Err: fmt::Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        T::Err: fmt::Debug,
    {
        (0..m).map(|_| self.vec(n)).collect()
    }

    fn strings_as_mat<T, F: FnMut(u8) -> T>(&mut self, h: usize, mut f: F) -> Vec<Vec<T>> {
        (0..h)
            .map(|_| {
                let l = self.next::<String>();
                l.as_bytes().iter().cloned().map(&mut f).collect()
            })
            .collect()
    }
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

int main() {
  int n;
  cin >> n;
  auto f = [](int x, int y, int z) {
    return x * x + y * y + z * z + x * y + y * z + z * x;
  };

  vector<int> ans(n + 1);
  rep(x, 1, sqrt(n) + 1) rep(y, 1, sqrt(n) + 1) rep(z, 1, sqrt(n) + 1) {
    int w = f(x, y, z);
    if (w <= n) ++ans[w];
  }

  rep(i, 1, n + 1) cout << ans[i] << '\n';
  return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

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

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍


int main(){
    string s,t;cin>>s>>t;
    ll cs[26], ct[26];rep(i,0,26)cs[i]=ct[i]=0;
    rep(i,0,s.size()){
        cs[s[i] - 'a']++;
        ct[t[i] - 'a']++;
    }
    ll s1[2*100000+1], t1[2*100000+1];
    rep(i,0,2*100000+1)s1[i]=t1[i]=0;
    rep(i,0,26){
        s1[cs[i]]++;
        t1[ct[i]]++;
    }
    bool f = true;
    rep(i,0,2*100000+1)if(s1[i]!=t1[i])f=false;
    cout<<(f?"Yes":"No")<<endl;
}


Measured memory_bytes: 3848
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    while(n!=0)
    {if(n%10==9)
    {cout<<"Yes"<<endl;
    return 0;
    }
    n/=10;
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
m=input()

n=len(m)

c=int((n-1)/2)
d=int((n+3)/2)
a=[]
b=[]

import sys

for i in range(0,c):

    a.append(m[i])


for k in range(d-1,n):

    b.append(m[k])

for l in range(int(len(a))):

    if a[l]==a[-1-l]:

        pass
    else:
        print("No")

        sys.exit()


if a == b:

    print("Yes")

else:
    print("No")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20;
const int M=2e2+20;
ll v[N];
ll C[M][M]; 
void init()
{
	memset(C,0,sizeof(C));
	C[0][0]=1;
	for(int i=1;i<=50;i++)
	{
		C[i][0]=1;
		for(int j=1;j<=i;j++)
			C[i][j]=C[i-1][j-1]+C[i-1][j];
	}
}
int main()
{
	int n,A,B;
	init();
	while(cin>>n>>A>>B)
	{
		double ave=0;
		for(int i=0;i<n;i++)
			cin>>v[i];
		sort(v,v+n);
		reverse(v,v+n);//大->小
		for(int i=0;i<A;i++) 
			ave+=v[i];
		ave/=A;
		int num=0,k=0;
		for(int i=0;i<n;i++)
		{
			if(v[i]==v[A-1])
			{
				num++;
				if(i<A)
					k++;
			}
		}	
		ll ans=0; 
		if(k==A)//前A个相同,可以增加个数 
		{
			for(int i=A;i<=B;i++)
				ans+=C[num][i];
		}
		else
			ans+=C[num][k];

 		cout.precision(20);
 		cout<<fixed<<ave<<endl;
 		cout<<ans<<endl;
	}
	return 0;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
string ATGC = "ATGC";
vector<int> indexes;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int ans = 0;
    indexes.push_back(-1);
    for(int i = 0; i < S.size(); i++) {
        indexes.push_back(i);
        for(int j = 0; j < 4; j++) {
            if(S[i] == ATGC[j]) indexes.pop_back();
        }
    }
    indexes.push_back((int)S.size());
    ans = 0;
    for(int i = 1; i < indexes.size(); i++) {
        ans = max(ans, indexes[i] - indexes[i-1] - 1);
        cerr << indexes[i] << endl;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from operator import itemgetter


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

a = []
for i in range(N):
    a.append(list(map(int, input().split())))

def main():
    b = sorted(a, key=itemgetter(0))
    # print(b)
    m = 0
    cost = 0
    for i in range(N):
        # print(b[i])
        if (m + b[i][1]) <= M:
            m += b[i][1]
            cost += (b[i][0] * b[i][1])
        else:
            cost += (b[i][0] * (M-m))
            return cost
    return cost

print(main())

Measured memory_bytes: 29864
N, M = map(int, input().split())
a = set([int(input()) for i in range(M)])

dp = [0] * (N+1)
dp[0] = 1
for i in range(1, N+1):
    dp[i] = (dp[i-1] + dp[i-2]) % (10**9+7)
    if i in a:
        dp[i] = 0
print(dp[N])

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

using namespace std;

using i64 = int64_t;
const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

bool solve(){
    int h, w, k;
    cin >> h >> w >> k;
    if(!h)
        return false;

    vector<vector<int>> a(h, vector<int>(w, 0));
    for(int i = 0; i < h; ++i)
        for(int j = 0; j < w; ++j)
            cin >> a[i][j];

    vector<vector<i64>> dp(h, vector<i64>(w, 0));
    dp[0][0] = k - 1;
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            int cnt_1 = dp[i][j] / 2 + (a[i][j] == 0 && dp[i][j] % 2);
            int cnt_2 = dp[i][j] / 2 + (a[i][j] == 1 && dp[i][j] % 2);
            if(i != h - 1)
                dp[i + 1][j] += cnt_1;
            if(j != w - 1)
                dp[i][j + 1] += cnt_2;
        }
    }
    for(int i = 0; i < h; ++i){
        for(int j = 0; j < w; ++j){
            a[i][j] = (dp[i][j] + a[i][j]) % 2;
        }
    }
    int x = 0, y = 0;
    while(x != h && y != w){
        if(a[x][y])
            ++y;
        else
            ++x;
    }
    cout << x + 1 << " " << y + 1 << endl;

    return true;
}

signed main(){

    while(solve());
}



Measured memory_bytes: 14708
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int Max_N(1000050);

int N, Temp[26], Last[Max_N][26];
char S[Max_N], T[Max_N];

void init()
{
	scanf("%d", &N);
	scanf("%s", S + 1);
	scanf("%s", T + 1);
	memset(Temp, -1, sizeof(Temp));
	for (int i = 1;i <= N;++i)
	{
		Temp[S[i] - 'a'] = i;
		for (int j = 0;j < 26;++j)
			Last[i][j] = Temp[j];
	}
}

//只考虑答案不为0的情况。考虑逆变换
//显然对于连续一串相同的字母，只要考虑第一个即可，因为后面的都可以在最后一次操作中直接达到目的
//考虑把S0变换到T的所有串从下到上写到一起，那么对于T的每个连续段的首字母，都是先向下走一格，然后每次只能向下走或向左走，直到走到S0
//每条路径经过的字母相同，并且路径之间两两不相交
//贪心地考虑，肯定是每个点先向下走，直到碰到其他路径再向左走，如此反复，直到到达目的地 
//考虑从后往前维护每个有用的T[i]的路径，记录每个点上最高的路径
//每次找到一个p满足p是最右的，在i的左边（包括i），S[p] = T[i]，并且上方没有路径
//若p = i，那么答案显然是不变的
//若p < i，那么对于所有p <= k <= i - 1，H[k] = H[k + 1] + 1 
 
#define LEFT  (segt[cur].l)
#define RIGHT (segt[cur].r)
#define MID   (segt[cur].mid)
#define MIN   (segt[cur].Min)
#define TAG   (segt[cur].Tag)
#define LCH   (cur << 1)
#define RCH   ((cur << 1) | 1)

struct node
{
	int l, r, mid, Tag, Min;
};
int dt;
node segt[Max_N << 2];

void build_tree(const int &cur, const int &l, const int &r)
{
	LEFT = l, RIGHT = r, MID = l + ((r - l) >> 1), TAG = 0, MIN = 1;
	if (l == r)
		return;
	build_tree(LCH, l, MID), build_tree(RCH, MID + 1, r);
}

inline void pushup(const int &cur)
{
	MIN = min(segt[LCH].Min, segt[RCH].Min);
}

inline void Add(const int &cur, const int &v)
{
	TAG += v, MIN += v;
}

inline void pushdown(const int &cur)
{
	if (TAG)
		Add(LCH, TAG), Add(RCH, TAG), TAG = 0;
}

void insert(const int &cur, const int &l, const int &r, const int &v)
{
	if (LEFT == l && RIGHT == r)
	{
		Add(cur, v);
		return;
	}
	pushdown(cur);
	if (r <= MID)
		insert(LCH, l, r, v);
	else
		if (l > MID)
			insert(RCH, l, r, v);
		else
			insert(LCH, l, MID, v), insert(RCH, MID + 1, r, v);
	pushup(cur);
}

int query(const int &cur, const int &pos)
{
	if (LEFT == RIGHT)
		return MIN;
	pushdown(cur);
	if (pos <= MID)
		return query(LCH, pos);
	else
		return query(RCH, pos);
}

int query(const int &cur, const int &l, const int &r)
{
	if (MIN > 1)
		return -1;
	if (LEFT == l && RIGHT == r)
		if (LEFT == RIGHT)
			return LEFT;
		else
		{
			pushdown(cur);
			if (segt[RCH].Min <= 1)
				return query(RCH, MID + 1, r);
			else
				return query(LCH, l, MID);
		}
	pushdown(cur);
	if (r <= MID)
		return query(LCH, l, r);
	else
		if (l > MID)
			return query(RCH, l, r);
		else
		{
			int v = query(RCH, MID + 1, r);
			if (v == -1)
				return query(LCH, l, MID);
			else
				return v;
		}
}

bool check()
{
	for (int i = 1;i <= N;++i)
		if (S[i] != T[i])
			return false;
	return true;
}

void work()
{
	build_tree(1, 1, N);
	int Ans(1);
	for (int i = N, p, h;i >= 1;--i)
		if (i == 1 || T[i] != T[i - 1])
		{
			if ((p = query(1, 1 + dt, i + dt)) == -1)
			{
				printf("-1");
				return;
			}
			p -= dt;
			if ((p = Last[p][T[i] - 'a']) == -1)
			{
				printf("-1");
				return;
			}
			h = query(1, i + dt);
			if (p <= i - 1)
				Ans = max(Ans, h + 1), ++dt, insert(1, p + dt, (i - 1) + dt, +1);
		}
	printf("%d", Ans);
}

int main()
{
	init();
	if (check())
		printf("0");
	else
		work();
	return 0;
}

Measured memory_bytes: 146944
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  int ans=0;
  cin>>S;
  for(int i=0;i<4;i++){
    if(S[i]=='+'){
      ans++;
    }else{
      ans--;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

int main()
{
    vector< pair<double, int> > pl1, pl2, pl3, pl;
    int id;
    double tm;

    for (int i = 0; i < 24; i++) {
        cin >> id >> tm;
        if (i / 8 == 0)
            pl1.push_back(pair<double, int>(tm, id));
        else if (i / 8 == 1)
            pl2.push_back(pair<double, int>(tm, id));
        else if (i / 8 == 2)
            pl3.push_back(pair<double, int>(tm, id));
    }
    sort(pl1.begin(), pl1.end());
    sort(pl2.begin(), pl2.end());
    sort(pl3.begin(), pl3.end());

    for (int i = 2; i < 8; i++) {
        pl.push_back(pl1[i]);
        pl.push_back(pl2[i]);
        pl.push_back(pl3[i]);
    }
    sort(pl.begin(), pl.end());

    for (int i = 0; i < 2; i++)
        cout << pl1[i].second << " " << pl1[i].first << endl;
    for (int i = 0; i < 2; i++)
        cout << pl2[i].second << " " << pl2[i].first << endl;
    for (int i = 0; i < 2; i++)
        cout << pl3[i].second << " " << pl3[i].first << endl;
    for (int i = 0; i < 2; i++)
        cout << pl[i].second << " " << pl[i].first << endl;

    return 0;
}

Measured memory_bytes: 1304
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
#define sort(a) sort(all(a))
using P = pair<int, int>;
using ll = long long;
using ld = long double;
int dx[4] = { 0, 1, 0,-1 };
int dy[4] = { 1, 0,-1, 0 };

signed main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  if (N%2==1) {
    cout << "No" << endl;
    return 0;
  }
  if (S.substr(0,N/2)==S.substr(N/2,N-1)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 768
x,k,d=map(int,input().split())
if abs(x)>=k*d:
    print(abs(x)-k*d)
else:
    a=abs(x)//d
    if (k-a)%2==0:
        print(abs(x)-d*a)
    else:
        print(d-abs(x)+d*a)

Measured memory_bytes: 61600
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines


# rstrip().decode('utf-8')
# INF=float("inf")
#MOD=10**9+7
# sys.setrecursionlimit(2147483647)
# import math
#import numpy as np
# import operator
# import bisect
# from heapq import heapify,heappop,heappush
#from math import gcd
# from fractions import gcd
# from collections import deque
# from collections import defaultdict
# from collections import Counter
# from itertools import accumulate
# from itertools import groupby
# from itertools import permutations
# from itertools import combinations
# from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
# from scipy.sparse.csgraph import csgraph_from_dense
# from scipy.sparse.csgraph import dijkstra
# map(int,input().split())


def main():
	n=int(input())
	li=[]
	for i in range(n):
		a,b=map(int,input().split())
		li.append((a,b))
	li.sort(key=lambda x:x[1])
	
	ans="Yes"
	now=0
	for a,b in li:
		now+=a
		if now>b:
			ans="No"
			break
	
	print(ans)



if __name__ == '__main__':
	main()


Measured memory_bytes: 31804
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
int main(){
    int A, B;
    int cnt = 0;
    string S;
    cin >> A >> B;
    cin >> S;
    REP(i, A){
        if(S[i] != '-')
            cnt++;
    }
    if(S[A] == '-')
        cnt++;
    FOR(i, A + 1, A + B + 1){
        if(S[i] != '-')
            cnt++;
    }
    if(cnt == A + B + 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(i=0;i<n;i++)
#define ll long long
int main(){
  ll n;
  ll ans;
  
  cin >> n;
  
  if(n<10)
    ans = n;
  else if(10<=n && n<100)
    ans = 9;
  else if(100<=n && n<1000)
    ans = n-90;
  else if(1000<=n && n<10000)
    ans = 909;
  else if(10000<=n && n<100000)
    ans = n-9090;
  else
    ans = 90909;
    
  cout << ans << endl;
    
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>
#include <type_traits>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;

//------------------------------------------
//------------------------------------------

int main() {

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

    vector<int> cnt_s(26, 0);
    vector<int> cnt_t(26, 0);

    for (auto c: s) cnt_s[c - 'a']++;
    for (auto c: t) cnt_t[c - 'a']++;

    for (int i = 0; i < 26; i++) {
        if (cnt_t[i] != 0 && cnt_s[i] == 0) {
            cout << -1 << endl;
            return 0;
        }
    }

    string ss = s + s + s;

    vector<vector<int>> arr(26, vector<int>());
    for (int i = 0; i < ss.size(); i++) {
        char c = ss[i];
        arr[c - 'a'].push_back(i);
    }

    LL pos = -1;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == t[0]) {
            pos = i;
            break;
        }
    }

    for (int i = 0; i < t.size() - 1; i++) {
        LL d = pos % s.size();
        auto to = upper_bound(arr[t[i + 1] - 'a'].begin(), arr[t[i + 1] - 'a'].end(), d);
        pos += *to - d;
    }

    cout << pos + 1 << endl;

}
























Measured memory_bytes: 3124
# coding: utf-8
# Your code here!
N=int(input()) #N==100
H=list(map(int,input().split()))#O(N)

cnt=0
for i in range(max(H)):#O(N)
    flg=0
    for j in range(N):#O(N^2)
        if flg==0:
            if H[j]!=0:
                H[j]-=1
                cnt+=1
                flg=1
            else:  #なくてもいい
                flg=0
        else:
            if H[j]!=0:
                H[j]-=1
            else:
                flg=0
print(cnt)
#O(N^2),N==100で余裕

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

using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N;
  cin >> N;
  for (int i = 0; i < N; i ++) {
    int a, b, c;
    cin >> a >> b >> c;
    int aa = a * a, bb = b * b, cc = c * c;
    if (aa + bb == cc || bb + cc == aa || cc + aa == bb) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
}


Measured memory_bytes: 3024
L,R=map(int,input().split())
mod=2019
ans=2018
if R-L>=mod:
    print(0)
else:
    R%=mod
    L%=mod
    if R<=L:
        R+=mod
    for i in range(L+1,R+1):
        for j in range(L,i):
            ans=min(ans,i*j%mod)
    print(ans)

Measured memory_bytes: 9172
#include<iostream>

using namespace std;

int main(){
  string a,b,c;
  int an,bn;
  cin >> a >> b;
  cin >> an >> bn;
  cin >> c;
  if(a == c){
    an--;
  }else{
    bn--;
  }
  cout << an << " " << bn << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String argd[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int asi[] = new int[N];
        int dp[] = new int[N];
        for(int i = 0; i < N; i++){
            asi[i] = sc.nextInt();
            dp[i] = 2000000000;
        }
        dp[0] = 0;
        for(int i = 0; i < N - 1; i++){
            for(int j = i + 1; j <= K + i && j < dp.length; j++){
                if(dp[j] > dp[i] + Math.abs(asi[i] - asi[j])) dp[j] =  Math.abs(asi[i] - asi[j]) + dp[i];
            }
        }
        System.out.println(dp[N - 1]);
        
    }
    
}

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

int main()
{
    int N;
    cin >> N;
    int A[N];
    long long count[200001] = {0};
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        count[A[i]]++;
    }

    long long totalCount = 0;
    for (int i = 1; i < 200001; i++) {
        if (count[i] > 1) {
            totalCount += (count[i] * (count[i] - 1)) / 2;
        }
    }

    for (int i = 0; i < N; i++) {
        long long ans = totalCount;
        if (count[A[i]] > 1) {
            ans -= ((count[A[i]] * (count[A[i]] - 1)) / 2)
                    - (((count[A[i]] - 1) * (count[A[i]] - 2)) / 2);
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 5872
#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	char s[102];
	scanf("%s",s);
	int x=0;
	int max=0;
	int i;
	for(i=0;i<n;i++)
	{
		if(s[i]=='I')
		  x++;
		else
		  x--;
		if(max<x)
		max=x;
	}
	printf("%d\n",max);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
ll n,m;
char str[1000010];
ll md=1e9+7;
ll inv[2000010];
ll ksm[2000010];
ll ksmi(ll x,ll y)
{
	ksm[0]=x;
	for (int i=1;i<=60;i++) ksm[i]=(ksm[i-1]*ksm[i-1])%md;
	ll res=1;
	for (int i=0;i<=60;i++) if (y & (1ll<<i)) res=(res*ksm[i])%md;
	return res; 
}
int main()
{
	scanf("%lld%s",&n,&str);
	string s=str;
	m=s.size(),n+=m;
	for (int i=1;i<n-(m-1)+1;i++) inv[i]=ksmi(i,md-2);
	vector<ll> com;
	ll t=1;
	for (ll i=m-1;i<n;i++)
	{
		//cout <<t<<" ##\n";
		if (!(m-1)) com.push_back(1);
		else
		{
			com.push_back(t);
			t=(t*inv[i-(m-1)+1])%md;
			t=(t*(i+1))%md;
		}
	}
	//for (int i=0;i<com.size();i++) cout <<com[i]<<" ";
	//cout <<"\n";
	t=1;
	for (int i=0;i<com.size();i++) com[i]=(com[i]*t)%md,t=(t*25)%md;
	ll res=0;
	for (int i=0;i<com.size();i++) res=(((res*26)%md)+com[i])%md; 
	printf("%lld",res);
	return 0;
} 

Measured memory_bytes: 21392
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll n,m,a,b;
    cin>>n>>m;
    vector<bool> s(n,0),g(n,0);
    rep(i,m){
        cin>>a>>b;
        a--; b--;
        if(a==0) s[b]=1;
        if(b==n-1) g[a]=1;
    }
    rep(i,n){
        if(s[i]&&g[i]){
            cout<<"POSSIBLE"<<endl;
            return 0;
        }
    }
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int A, B; cin >> A >> B;
  int result = A + B;
  if (result >= 10) cout << "error" << endl;
  else cout << result << endl;
  return 0;
}

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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

const int mod = 1e9+7;
int main()
{
	cout << setprecision(10);

	cin >> n ;
	cin >> s; 

	int hazi = 0 , tozi = 0 ;
	int T = 0 ;
	string start ="";
	rep(i,n){
		if(s[i] == ')'){
			tozi ++ ;
			T ++ ;
		}
		else hazi ++ ;

		if(s[i] == ')'){
			if(T > hazi){
				start += '(' ;
				T -- ;
			}
		}
	}
	string ans = start + s  ;
	//ここまで作り終わったのを見て、足りない分だけ閉じを足す
	hazi = 0 , tozi = 0;
	rep(i,ans.size()){
		if(ans[i] ==')'){
			tozi ++;
		}else hazi ++;
	}
	int k = hazi - tozi ;
	rep(i,k){
		ans += ')';
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int N;
    cin >> N;
    cout << N/3 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

map<char,int> mp;

int H,W;

int main(){
  cin >> H >> W;
  rep(i,0,H - 1){
    string s;
    cin >> s;
    for(char c : s){
      mp[c]++;
    }
  }

  int one = 0;
  int two = 0;
  int four = 0;

  for(auto p : mp){
    if(p.second % 2 == 1){
      p.second--;
      one++;
    }
    four += p.second / 4;
    if(p.second % 4 == 2){
      two++;
    }
  }


  if(H % 2 == 1 && W % 2 == 1){
    one--;
  }
  if(H % 2 == 1){
    two -= W / 2;
  }
  if(W % 2 == 1){
    two -= H / 2;
  }
  four -= (H / 2) * (W / 2);

  if(four > 0){
    two += four * 2;
    four = 0;
  }
  


  if(one == 0 && two == 0 && four == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
using namespace std; 

int main(){
	/*input*/
	int n;	cin >> n;
	string s;	cin >> s;
	/*calculation*/
	int max = 0;
	vector<int>se(n + 1);
	vector<int>sw(n + 1);
	//se
	for(int i = 0; i < n; i++){
		if(s.at(i) == 'E'){
			se.at(i + 1) = se.at(i) + 1;
		}else{
			se.at(i + 1) = se.at(i);
		}
	}
	//sw
	for(int i = n - 1,  j = 0; i >= 0; i--, j++){
		if(s.at(i) == 'W'){
			sw.at(j + 1) = sw.at(j) + 1;
		}else{
			sw.at(j + 1) = sw.at(j);
		}
	}
	//max
	for(int i = 0; i < n; i++){	//reader
		int tmp = se.at(i) + sw.at(n - i - 1);
		if(max < tmp)max = tmp;
	}
	/*output*/
	cout << n - 1 - max << endl;
}


Measured memory_bytes: 3076
N = int(input())

ans = 0
A = []
for i in range(N):
    a = int(input())
    A.append(a)

button = A[0]

for i in range(N):
    ans += 1

    if button == 2:
        print(ans)
        exit()

    else:
        button = A[button-1]
print(-1)


Measured memory_bytes: 7084
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,sum,a,b;
	cin>>n>>a>>b;
	long long remain=n%(a+b);
	if(remain>a)remain=a;
	sum=n/(a+b)*a+remain;
	cout<< sum;
	return 0;
} 

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

typedef complex<double> P;
#define X real()
#define Y imag()

int N;
vector<P> Poly;

double cpx(P p1, P p2, int y){
    double dy = (p2-p1).Y;
    return ((p2-p1)*(y-p1.Y)/dy + p1).X;
}

void solve(){
    int ans = 0;
    vector<int> ys;
    for(int y=-2000; y<2000; y++){
        vector<pair<int, int>> xs;
        for(int i=0; i<N; i++){
            auto p1 = Poly[i], p2 = Poly[(i+1)%N];
            if(p1.Y == p2.Y or max(p1.Y, p2.Y)<y+1 or min(p1.Y, p2.Y)>y) continue;
            double x1 = cpx(p1, p2, y), x2 = cpx(p1, p2, y+1);
            if(x1 > x2) swap(x1, x2);
            int l = floor(x1), r = ceil(x2);
            xs.emplace_back(l, r);
        }
        if(xs.size() == 0) continue;
        
        sort(xs.begin(), xs.end());
        int xr = -1000000;
        for(int i=0; i<xs.size()-1; i+=2){
            int l = max(xs[i].first, xr), r = xs[i+1].second;
            ans += r-l;
            xr = r;
        }
    }
    cout << ans << endl;
}

int main(){
    while(cin>>N, N){
        Poly.resize(N);
        for(int i=0; i<N; i++){
            int x, y; cin >> x >> y;
            Poly[i] = P(x, y);
        }
        solve();
    }
    return 0;
}

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

int main() {
    ll H;
    cin >> H;

    int cnt = 0;
    while (H>1)
    {
        H /= 2;
        cnt++;
    }
    
    ll ans = 1;
    for (int i = 0; i < cnt; i++)
    {
        ans *= 2;
    }
    
    ans *= 2;
    ans--;
    cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
    int h,w,n;
    int maps[110][110]={};
    int num[10010]={};
    int i,j,k;
    int move_way;
    while (cin>>h>>w)
    {
        cin>>n;
        memset(num,0,sizeof(num));
        for (i=0;i<n;i++)
        {
            cin>>num[i];
        }
        memset(maps,0,sizeof(maps));
        for (k=0,i=0,j=0,move_way=0;k<n;k++)
        {
            while (num[k]--)
            {
                maps[i][j]=k+1;
                if (move_way==0)
                {
                    i++;
                    if(i==h||maps[i][j]!=0)
                    {
                        i--;
                        j++;
                        move_way=1;
                    }
                }
                else if (move_way==1)
                {
                    j++;
                    if(j==w||maps[i][j]!=0)
                    {
                        j--;
                        i--;
                        move_way=2;
                    }
                }
                else if (move_way==2)
                {
                    i--;
                    if(i==-1||maps[i][j]!=0)
                    {
                        i++;
                        j--;
                        move_way=3;
                    }
                }
                else if (move_way==3)
                {
                    j--;
                    if(j==-1||maps[i][j]!=0)
                    {
                        j++;
                        i++;
                        move_way=0;
                    }
                }
            }
        }
        for (i=0;i<h;i++)
        {
            for (j=0;j<w;j++)
            {
                if(j)
                    cout<<" ";
                cout<<maps[i][j];
            }
            cout<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

int N, K, A[100];
bool dp[100001];//dp[i]: falseなら負け　trueなら勝ち確定

int main() {

	cin >> N >> K;
	
	for (int i = 0; i < N; i++)cin >> A[i];
	for (int i = 0; i <= K; i++) {
		int lose = 0;
		for (int j = 0; j < N; j++) {
			int P = i - A[j];
			if (P < 0)continue;
			if (!dp[P])lose++;
		}
		if (lose >= 1)dp[i] = true;
		else dp[i] = false;
		
	}
	if (dp[K])cout << "First" << endl;
	else cout << "Second" << endl;
	return 0;
}

Measured memory_bytes: 384
n = int(input())
a = [int(x) for x in input().split()]
pref = [0]*(n+1)
for i in range(n + 1):
    pref[i] = pref[i - 1] + a[i - 1]
answer = 0
for i in range(n - 1):
    answer += (pref[n] - pref[i + 1]) * a[i]
    answer %= (10 ** 9 + 7)
print(answer)

Measured memory_bytes: 94148