akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <list>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <numeric>
#include <unordered_set>
#include <unordered_map>
#include <chrono>
#include <random>
#include <bits/stdc++.h>
 
using namespace std;
template <typename T> T max(T a, T b) {return a>b?a:b;}
 
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        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);
    }
};
 
#define ll long long
#define PI 3.14159265358979323846
#define min(a,b) ((a<b)?(a):(b))
#define max(a,b) ((a<b)?(b):(a))
#define abs(a) ((a>0)?a:-(a))

const double eps = (double)1e-6;
const int maxn = 2e5+5;
const ll mod = 1e9+7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



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

    char c; cin >> c;
    cout << (char)(c+1) << endl;
    
}

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

const int MOD = 1000000007;
const int INF = 1e9;

int main(){
  double n,k;
  const int max_n = 1e5;
  cin >> n >> k;

  double ans = 0;
  double prob;
  int a;
  int cnt = 0;
  for(int i = 1; i <= n; i++){
    a = i;
    cnt = 0;
    while(a < k){
      a *= 2;
      cnt ++;
    }
    // prob = 1 / (1 << cnt);
    prob = 1 << cnt;
    ans += 1/prob;
    // cout << 1/prob << endl;
  }
  cout << fixed << setprecision(10) << ans / n << endl;


  return 0;
}

Measured memory_bytes: 3760
#include <limits.h>
#include <stdio.h>

#define MM 2000000

int A[MM], a=0;
int B[MM], b=0;

int n, m, k, i, j;
char S[2*MM+1];

void printS(void){
	int i=MM;
	while((S[i]&1)==0) i--;
	for(; i>=0; i--){
		putchar((S[i]&1)==0?'0':'1');
	}putchar(10);
}

void printT(void){
	int i=MM;
	while((S[i]&2)==0) i--;
	for(; i>=0; i--){
		putchar((S[i]&2)==0?'0':'1');
	}putchar(10);
}

int main(void){
	scanf("%d%d%d\n", &n, &m, &k);
	for(i=n-1; i>=0; i--){
		S[i]=(getchar()=='1')?1:0;
	}
	while(getchar()!=10);
	for(i=m-1; i>=0; i--){
		if(getchar()=='1') S[i]|=2;
	}
	int l = n>m?n:m;
	for(i=l; i>=0; i--){
		if(S[i]==3){
			S[i]=0;
			int z=k; j=i;
			char x=3;
			while(1){
				int p=(a>0?A[--a]:INT_MAX);
				if(p>j+1){
					if(x==3){
						if(p>j+z){
							if(p!=INT_MAX) A[a++]=p;
							S[j+z]=3; break;
						}else{
							z-=p-j-1;
						}
					}else{
						if(p!=INT_MAX) A[a++]=p;
						S[j+1]=x;
						B[b++]=j+1; break;
					}
				}
				if(S[p]==1){
					if(x==3){
						S[p]=2; x=1;
						B[b++]=p;
					}else if(x==1){
						S[p]=0; x=1;
					}else{
						z--;
						if(z>=0){
							S[p]=0; x=3;
						}else{
							S[p]=3; break;
						}
					}
				}else if(S[p]==2){
					if(x==3){
						S[p]=1; x=2;
						B[b++]=p;
					}else if(x==2){
						S[p]=0; x=2;
					}else{
						z--;
						if(z>=0){
							S[p]=0; x=3;
						}else{
							S[p]=3; break;
						}
					}
				}
				j=p;
			}
			while(b) A[a++]=B[--b];
		}else if(S[i]!=0){
			A[a++]=i;
		}
	}
	printS();
	printT();
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n), dp(n, INT_MAX);
  rep(i, n) cin >> h[i];
  dp[0] = 0;
  for (int i = 1; i < n; i++) {
    for (int j = 1; j <= k; j++) {
      if (i >= j) dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
    }
  }
  cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#define N 10001
#define int long long
#define rnt register int
using namespace std;
int n,A,x,ans,sum[N],dp[60][N];
signed main(){
	scanf("%lld%lld",&n,&A);dp[0][0]=1;
	for(rnt i=1;i<=n;i=-~i){
		scanf("%lld",&x);sum[i]=sum[i-1]+x;
		for(rnt j=i;~j;--j) for(rnt k=0;k<=sum[i];k=-~k) dp[j+1][k+x]+=dp[j][k];
	}
	for(rnt i=1;i<=n;i=-~i) ans+=dp[i][i*A];
	printf("%lld",ans);
	return 0;
}

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

const int N = 1e6 + 5;
int bad[N];

void init() {
    for (int i = 3; i < N; i += 3) {
        bad[i] = 1;
    }
    for (int i = 5; i < N; i += 5) {
        bad[i] = 1;
    }
}

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    init();
    int n;
    cin >> n;
    long long sum = 0;
    for (int i = 1; i <= n; i++) {   
        if (!bad[i]) {
            sum += i * 1LL;
        }
    }
    cout << sum << '\n';
}

Measured memory_bytes: 7556
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mem(a) memset(a,0,sizeof a)
const int N=1e5+5;
const int INF=1e9+5;
ll read(ll &a){scanf("%lld",&a);return a;}
int read(int &a){scanf("%d",&a);return a;}
int read(){int a;scanf("%d",&a);return a;}
int read(int &a,int &b){scanf("%d %d",&a,&b);return a;}
#define pii pair<int,int>
struct edge
{
    int w;
    pii u,v;
    edge(pii u=make_pair(0,0),pii v=make_pair(0,0),int w=0):u(u),v(v),w(w){}
}edges[1200000+5];
set<pii>vis;

map<pii,vector<int> >G;
int indx;
void addedges(int p,int q,int c)
{
    pii pc,qc,p0,q0;
    pc=make_pair(p,c);
    qc=make_pair(q,c);
    p0=make_pair(p,0);
    q0=make_pair(q,0);
    if(!vis.count(make_pair(p,c)))
    {
        vis.insert(pc);
        edges[indx]=edge(pc,p0,1);
        G[pc].push_back(indx++);
        edges[indx]=edge(p0,pc,1);
        G[p0].push_back(indx++);
    }
    if(!vis.count(make_pair(q,c)))
    {
        vis.insert(qc);
        edges[indx]=edge(qc,q0,1);
        G[qc].push_back(indx++);
        edges[indx]=edge(q0,qc,1);
        G[q0].push_back(indx++);
    }
    edges[indx]=edge(pc,qc,0);
    G[pc].push_back(indx++);
    edges[indx]=edge(qc,pc,0);
    G[qc].push_back(indx++);
}
int m,n;
int ans;
map<pii,int>dis;
struct node
{
    pii p;
    int d;
    node(pii p=make_pair(0,0),int d=0):p(p),d(d){}
    bool operator <(const node b)const
    {
        return d>b.d;
    }
};
priority_queue<node>pq;
void dij()
{
    ans=INF;
    dis[make_pair(1,0)]=0;
    pq.push(node(make_pair(1,0),0));
    node x;
    pii xp;
    vis.clear();
    int cur,w;
    pii v;
    while(!pq.empty())
    {
        x=pq.top();pq.pop();
        xp=x.p;
        //cout<<"XXX:"<<xp.first<<' '<<xp.second<<' '<<x.d<<endl;
        if(vis.count(xp))
            continue;
        vis.insert(xp);

        if(xp==make_pair(n,0))
        {
            ans=x.d/2;
            break;
        }

        for(int i=0;i<G[xp].size();i++)
        {
            cur=G[xp][i];
            v=edges[cur].v;
            w=edges[cur].w;

            if(vis.count(v))
                continue;

            if(!dis.count(v)||dis[v]>=dis[xp]+w)
            {
                dis[v]=dis[xp]+w;
                pq.push(node(v,dis[v]));
                //cout<<v.first<<' '<<v.second<<' '<<dis[v]<<endl;
            }
        }
    }
    if(dis.count(make_pair(n,0)))
        ans=dis[make_pair(n,0)]/2;
    else
        ans=-1;
}
int main()
{
    read(n,m);
    int p,q,c;
    for(int i=0;i<m;i++)
    {
        read(p,q);
        read(c);
        addedges(p,q,c);
    }
    dij();
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 123572
turn=int(input())
duel=[input().split(" ")for i in range(turn)]
point=[0,0]
for i in duel:
    if i[0]==i[1]:
        point[0],point[1]=point[0]+1,point[1]+1
    if i[0]>i[1]:
        point[0]+=3
    if i[0]<i[1]:
        point[1]+=3
print(" ".join(map(str,point)))


Measured memory_bytes: 5712
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let mut sc = Scanner::new();
    let n = sc.next_usize();

    let mut x = Vec::with_capacity(n);
    for _ in 0..n {
        let xi = sc.next_usize();
        x.push(xi);
    }
    let y = x.clone();
    x.sort();
    let a = x[n / 2 - 1];
    let b = x[n / 2];

    for i in 0..n {
        if y[i] < b {
            println!("{}", b);
        } else {
            println!("{}", a);
        }
    }
}

pub struct Scanner {
    buf: std::collections::VecDeque<String>,
}

impl Scanner {
    pub fn new() -> Self {
        Self {
            buf: std::collections::VecDeque::new(),
        }
    }

    fn scan_line(&mut self) {
        let mut flag = 0;
        while self.buf.is_empty() {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            let mut iter = s.split_whitespace().peekable();
            if iter.peek().is_none() {
                if flag >= 5 {
                    panic!("There is no input!");
                }
                flag += 1;
                continue;
            }

            for si in iter {
                self.buf.push_back(si.to_string());
            }
        }
    }

    pub fn next<T: std::str::FromStr>(&mut self) -> T {
        self.scan_line();
        self.buf
            .pop_front()
            .unwrap()
            .parse()
            .unwrap_or_else(|_| panic!("Couldn't parse!"))
    }

    pub fn next_usize(&mut self) -> usize {
        self.next()
    }

    pub fn next_isize(&mut self) -> isize {
        self.next()
    }

    pub fn next_chars(&mut self) -> Vec<char> {
        self.next::<String>().chars().collect()
    }

    pub fn next_string(&mut self) -> String {
        self.next()
    }

    pub fn next_char(&mut self) -> char {
        self.next()
    }

    pub fn next_float(&mut self) -> f64 {
        self.next()
    }
}


Measured memory_bytes: 14840
#include <bits/stdc++.h>
#define ll long long
#define eps 1e-7
using namespace std;

#define MAX 100005
#define NIL -1
struct Node { int l, r, p; };
Node T[MAX];
int n, pos;
vector<int> pre, in, post;
void rec(int l, int r) {
	if (l >= r) return;
	int root = pre[pos++];
	int m = distance(in.begin(), find(in.begin(), in.end(), root));
	rec(l, m);
	rec(m + 1, r);
	post.push_back(root);
}

void solve() {
	pos = 0;
	rec(0, pre.size());
	for (int i = 0; i < n; ++i) {
		if (i) cout << " ";
		cout << post[i];
	}
	cout << endl;
}
int main() {
	int k;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> k;
		pre.push_back(k);
	}
	for (int i = 0; i < n; ++i) {
		cin >> k;
		in.push_back(k);
	}
	solve();
	return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int p, q, r;
    cin >> p >> q >> r;
    cout << (p+q+r - max(max(p,q),r)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#define llint long long
#define mod 1000000007

using namespace std;

int N, M;
string s;
vector<pair<int, int> > vec;
int r[3005];
llint dp[3005][3005];

int main(void)
{
	cin >> N >> M;
	cin >> s;
	int a, b;
	for(int i = 0; i < M; i++){
		cin >> a >> b;
		vec.push_back(make_pair(a, b));
	}
	for(int i = 1; i < vec.size(); i++){
		if(vec[i].second <= vec[i-1].second){
			vec.erase(vec.begin() + i);
			i--;
		}
	}
	for(int i = 0; i < vec.size()-1; i++){
		if(vec[i].first == vec[i+1].first){
			vec.erase(vec.begin() + i);
			i--;
		}
	}
	
	int cur = 1, prev = 0;
	for(int i = 0; i < vec.size(); i++){
		for(int j = cur; j < vec[i].first; j++) r[j] = max(j, prev);
		r[vec[i].first] = vec[i].second;
		cur = vec[i].first+1;
		prev = vec[i].second;
	}
	for(int j = cur; j <= N; j++) r[j] = max(j, prev);
	
	//for(int i = 1; i <= N; i++) cout << r[i] << " "; cout << endl;
	
	dp[0][0] = 1;
	for(int i = 0; i <= N; i++){
		int Y = 0;
		for(int j = r[i]+1; j <= r[i+1]; j++) if(s[j-1] == '1') Y++;
		for(int j = 0; j <= N-Y; j++){
			if(j < r[i]-i+1){
				dp[i+1][j+Y] += dp[i][j];
				dp[i+1][j+Y] %= mod;
			}
			if(j > 0){
				dp[i+1][j-1+Y] += dp[i][j];
				dp[i+1][j-1+Y] %= mod;
			}
		}
	}
	
	/*for(int i = 0; i <= N; i++){
		for(int j = 0; j <= 7; j++){
			cout << dp[i][j] << " ";
		}
		cout << endl;
	}*/
	
	cout << dp[N+1][0] << endl;
	return 0;
}

Measured memory_bytes: 70784
#include <stdio.h>

int DP[11][1024][331];

int search(int n,int limit,int bits,int sum){
  int i,res = 0;
  if(sum < 0 || limit > 10 || sum > 331){return 0;}
  
  if(DP[n][bits][sum] >= 0){
    return DP[n][bits][sum];
  }
  
  if(n == limit){
    if((sum / n) < 10 && (sum%n) == 0 && (bits & (1U << sum/n)) == 0){
      res = 1;
    }
  }else{
    for(i = 0; i < 10; i++){
      if((bits & (1U << i)) == 0){
	res += search(n+1,limit,bits | (1U << i),sum - i*n);
      }
    }
  }
  
  DP[n][bits][sum] = res;
  return res;
}

int main(int argc,char* argv[]){
  int n,s,bn = -1;
  int x,y,z;
  
  while(scanf("%d %d",&n,&s) != EOF){
    if(n != bn){
      for(x=0;x<11;x++){
	for(y=0;y<1024;y++){
	  for(z=0;z<331;z++){
	    DP[x][y][z]=-1;
	  }
	}
      }
    }
    printf("%d\n",search(1,n,0,s));
    bn = n;
  }
  
  return 0;
  
}

Measured memory_bytes: 0
def func(n,k):
    SUM = 0
    ans = 0
    A = [int(input()) for _ in range(n)]
    for i in range(k):
        SUM += A[i]
    for i in range(k,len(A)):
        ans = max(ans,SUM+A[i]-A[i-k])
        SUM = SUM+A[i]-A[i-k]
    print(ans)

for _ in range(10):
    n,k = [int(s) for s in input().split()]
    if n == 0 and k ==0:
        break
    else:
        func(n,k)


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

int main(){
  string s, t; cin>>s>>t;
  ll szs = s.length(), szt = t.length();
  ll ans = szs;
  for(ll i=0;i<=szs-szt;i++){
    ll sum = 0;
    for(ll j=0;j<szt;j++)
      sum += (s[i+j] != t[j])? 1 : 0;
    ans = min(ans, sum);
  }
  cout<<ans;
  return 0;
}

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

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

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

    int A,B;
    cin>>A>>B;

    for(int i=1; i<1005; i++){
        int a = i*8;
        int b = i*10;
        if((a/100 == A) && (b/100 == B)){
            cout<<i<<endl;
            return 0;       
        }
    }

    cout<<"-1"<<endl;
    return 0;
}

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


int main (){
    int A, B, C, D, E;
    cin>>A>>B>>C>>D>>E;
    if(A%10==0&&B%10==0&&C%10==0&&D%10==0&&E%10==0){
        cout<<A+B+C+D+E<<endl;
    }
    else{
        int UnzeroMin=9;
        int UnzeroCount=0;
        if(A%10>0){
            UnzeroMin=min(A%10,UnzeroMin);
            UnzeroCount ++;
        }
         if(B%10>0){
            UnzeroMin=min(B%10,UnzeroMin);
             UnzeroCount ++;
        }
         if(C%10>0){
            UnzeroMin=min(C%10,UnzeroMin);
             UnzeroCount ++;
        }
         if(D%10>0){
            UnzeroMin=min(D%10,UnzeroMin);
             UnzeroCount ++;
        }
         if(E%10>0){
            UnzeroMin=min(E%10,UnzeroMin);
             UnzeroCount ++;
        }
        cout<<(A/10)*10+B/10*10+C/10*10+D/10*10+E/10*10+(UnzeroCount-1)*10+UnzeroMin<<endl;

    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair
#define pb push_back

using namespace std;

typedef pair< int, int > P;
typedef pair< int, P > iP;
typedef long long LL;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const int MOD = (10^9 + 7);

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

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

    int a, b;
    cin >> a >> b;
    if( b % a ) cout << b - a << endl;
    else cout << a + b << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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;}

vector<int> divisor(int n){
    vector<int> ret;
    for(int i=1; i*i<=n; i++){
        if(n%i==0){
            ret.push_back(i);
            if(i*i!=n) ret.push_back(n/i);
        }
    }
    sort(begin(ret),end(ret));
    return(ret);
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    int cnt=0;
    rng(i,1,N+1){
        if(i%2==1){
            if(divisor(i).size()==8) cnt++;
        }
    }
    cout << cnt << endl;
}

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

int main() {
	int n; cin >> n;
	string s; cin >> s;
	vector<int>west(n + 1, 0), east(n + 1, 0);
	for (int i = 0; i < n; i++) {
		west[i + 1] += west[i] + (s[i] == 'W' ? 1 : 0);
		east[i + 1] += east[i] + (s[i] == 'E' ? 1 : 0);
	}

	int ans = 1e10;
	for (int i = 0; i <=n; i++) {
		ans = min(ans, west[i] + east[n] - east[i]);
	}
	cout << ans << endl;

	return 0;
}

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


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)		idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)	for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)		idp p2((x).F, (x).S)
#define dump(x,n)	idp{rep(iii,n){cout<<x[iii]<<" ";}puts("");}
#define dump2(x,n)	idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)	idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)	idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)	rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)	rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;


// table for [n][split point of last 17 numbers]
li dp[44][bit(17)];


int main() {
	li n, a[3];
	cin >> n;
	rep(i, 3)cin >> a[i];
	li sum = a[0] + a[1] + a[2];

	// (2,3,4) => 101001000
	li ok = bit(a[2] - 1) +
	        bit(a[2] + a[1] - 1) +
	        bit(a[2] + a[1] + a[0] - 1);

	rep(i, bit(sum)) {
		dp[0][i] = 0;
	}
	dp[0][0] = 1;
	rin {
		rep(j, bit(sum)) {
			dp[i + 1][j] = 0;
		}
		rep(j, bit(sum)) {
			repp(k, 1, 11) {
				li new_number = (j << k) + bit(k - 1);
				new_number &= bit(sum) - 1;
				if (new_number >= bit(17)) {
					puts("oops");
					return 0;
				}
				if ((new_number & ok) != ok) {
					dp[i + 1][new_number] = (dp[i + 1][new_number] + dp[i][j]) % MOD;
				}
			}
		}
	}

	li res = 1;
	rin{res = (res * 10) % MOD;}
	rep(i, bit(sum)) {
		res = (res + MOD - dp[n][i]) % MOD;
	}
	cout << res << endl;


	return 0;
}

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

using namespace std;

#define i64 int64_t
#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define fore(i,a) for (auto &i : a)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

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;}

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    string S;
    cin >> S;
    int cnt = 0;
    int ans = -1;
    rep(i, S.size()) {
        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') ++cnt;
        else ans = max(ans, cnt), cnt = 0;
    }

    ans = max(ans, cnt);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
h,w,k = map(int, input().split())
c = [list(input()) for _ in range(h)]

ans = 0
for ib in range(1<<h):
    for jb in range(1<<w):
        black = 0
        for i in range(h):
            if ib & (1<<i): continue
            for j in range(w):
                if jb & (1<<j): continue
                black += c[i][j]=="#"
        if black == k: ans += 1
print(ans)

Measured memory_bytes: 9224
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vint b(n-1);
    rep(i, n-1) cin >> b[i];
    int ans = b[0];
    rep(i, n-2) ans += min(b[i], b[i+1]);
    ans += b[n-2];

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

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DModSum solver = new DModSum();
        solver.solve(1, in, out);
        out.close();
    }

    static class DModSum {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            int n = sc.nextInt();
            out.println(((long) n * (n - 1)) / 2);
        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 21460
import math
N, K = map(int, input().split())
A = list(map(int, input().split()))
start = 0
end = max(A)
ans = abs(end + start) // 2 + 1
while abs(start - end) > 1:
    ans = abs(end + start) // 2
    cnt = 0
    for i in range(N):
        cnt += math.floor(A[i]/ans - 0.0000000001)
        if cnt > K: #ダメだったら
            start = ans
            break
    else: #オッケーだったら
        end = ans
        continue

cnt = 0
for i in range(N):
    cnt += math.floor((A[i] / ans) - 0.000000000001)

if cnt > K:  # ダメだったら
    print(ans + 1)
else:  # オッケーだったら
    print(ans)


Measured memory_bytes: 93700
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
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; }

signed main(){
  int a,b;
  cin >> a >> b;
  cout << a * b << endl;
}

Measured memory_bytes: 3636
ANS=[0]*4
ans='NO'
for i in range(3):
    a,b=map(int,input().split())
    if a==1:
        ANS[0]+=1
    elif a==2:
        ANS[1]+=1
    elif a==3:
        ANS[2]+=1
    elif a==4:
        ANS[3]+=1

    if b==1:
        ANS[0]+=1
    elif b==2:
        ANS[1]+=1
    elif b==3:
        ANS[2]+=1
    elif b==4:
        ANS[3]+=1

if ANS.count(1)==2 and ANS.count(2)==2:
    ans='YES'

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
	int n,data[11][11];
	while(1){
		cin>>n;
		if(n==0)break;
		for(int i=0;i<n;i++){
			data[n][i]=0;
			for(int j=0;j<n;j++){
				cin>>data[j][i];
				data[n][i]+=data[j][i];
			}
		}
		for(int i=0;i<=n;i++){
			data[i][n]=0;
			for(int j=0;j<n;j++){
				data[i][n]+=data[i][j];
			}
		}
		for(int i=0;i<=n;i++){
			for(int j=0;j<=n;j++){
				printf("%5d",data[j][i]);
			}
			cout<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1192
#pragma GCC optimize("Ofast")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx")
#import <atcoder/all>
int T, n, m, a, b;
class FastIO
{
    static const int rdata_sz = (1 << 25), wdata_sz = (1 << 25);
    char rdata[rdata_sz], wdata[wdata_sz], *rb, *wb;
    char tmp_s[20];

public:
    FastIO()
    {
        fread(rdata, 1, rdata_sz, stdin);
        rb = rdata;
        wb = wdata;
    }
    ~FastIO()
    {
        fwrite(wdata, 1, wb - wdata, stdout);
    }

    template <typename T>
    inline void read(T &x)
    {
        bool neg = false;
        x = 0;
        while ((*rb < '0' || *rb > '9') && *rb != '-')
            ++rb;
        if (*rb == '-')
        {
            neg = true;
            ++rb;
        }
        while ('0' <= *rb && *rb <= '9')
        {
            x = 10 * x + (*rb - '0');
            ++rb;
        }
        if (neg)
            x = -x;
    }

#define pc(x) *(wb++) = x
    template <typename T>
    inline void write(T x)
    {
        if (x == 0)
        {
            pc('0');
            pc('\n');
            return;
        }
        if (x < 0)
        {
            pc('-');
            x = -x;
        }
        char *t = tmp_s;
        while (x)
        {
            T y = x / 10;
            *(t++) = (x - y * 10) + '0';
            x = y;
        }
        while (t != tmp_s)
            pc(*(--t));
        pc('\n');
    }
#undef pc
};
main()
{
    FastIO io;
    io.read(T);
    for (int i = 0; i < T; i++)
    {
        io.read(n);
        io.read(m);
        io.read(a);
        io.read(b);
        io.write(atcoder::floor_sum(n, m, a, b));
    }
}

Measured memory_bytes: 7448
#include <stdio.h>
int main(int argc, char const *argv[])
{
	int H,W,h,w,sum;
	scanf("%d %d",&H,&W);
	scanf("%d %d",&h,&w);
	sum = H * W;
	sum -= h * W + (H - h) * w;
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
n=int(input())

def count_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return len(lower_divisors + upper_divisors[::-1])


ans=0
for i in range(1,n+1):
    if i%2==1:
        c=count_divisors(i)
        if c==8:
            ans+=1
            #print(i)
print(ans)

Measured memory_bytes: 61892
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
   
  vector<string>S(N);
  for(int i=0; i<N; i++) cin >> S[i];
  sort(S.begin(),S.end());///文字列定義~並び替え
  
  vector<int>I(N);///文字数を取得する配列
  vector<string>Ss(N);///文字列取得の配列
  
  int count=0;
  int MAX=0;
  
  for(int i=0; i<N; i++){
    Ss[i]=S[count];
    
   for(int j=count; j<N-1; j++){
     if(S[j]==S[j+1]){
       I[i]++;
       count++;
     } 
     else{
       count++;
       break;
     } 
   }
    MAX = max(MAX,I[i]);
  }
  
  for(int i=0; i<N; i++){
    if(I[i]==MAX) cout << Ss[i] << endl;
  }
  
}


Measured memory_bytes: 16640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n,d,x;
	cin >> n >> d >> x;
	vector<vector<int> > p(d,vector<int>(n));
	REP(i,d)REP(j,n)cin >> p[i][j];
	int maxsize = x;
	vector<int> dp(1e5 + 1,0);
	for(int i = 0;i < d - 1;i++){
		REP(l,maxsize+1)dp[l] = l;
		for(int j = 0;j < n;j++){
			for(int k = 0;k <= maxsize;k++){
					if(k-p[i][j] >= 0)dp[k] = max(dp[k - p[i][j]] + p[i+1][j], dp[k]);
				}
			}
			maxsize = *max_element(dp.begin(), dp.end());
	}
	cout << maxsize << endl;
  return 0;
}

Measured memory_bytes: 3404
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<vector<int> > Graph;
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; }

int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n){
        cin >> a[i];
    }
    int ans =0;
    int now = 1;
    int temp = 0;
    rep(i,n){
        if(a[i]==now){
            now++;
            ans += temp;
            temp = 0;
        }
        else{
            temp++;
        }
    }
    ans += temp;
    if(now==1)cout<<-1<<endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<string>
 
using namespace std;
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define reps(i,n) for(int i=1;i<=int(n);i++)
#define sint(i) scanf("%d",&i);
#define sintt(i,j) scanf("%d%d",&i,&j);
#define sinttt(i,j,k) scanf("%d%d%d",&i,&j,&k);
#define sintttt(i,j,k,m) scanf("%d%d%d%d",&i,&j,&k,&m);
 
#define INF 1010000000
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
 
class S{
    public:
    int a,b,c,d;
    int n;
    S(int p,int n,int t,int k,int i):a(p),b(n),c(t),d(k),n(i){}
     
};
 
char visit[51][51][51][51];
 
int main(){
    while(1){
        int n,m;
        sintt(n,m);
        if(n==0)break;
        int a,b,c,d;
        sintttt(a,b,c,d);
         
        int masu[51][51];
         
        rep(i,51)rep(j,51)masu[j][i]=0;
        reps(i,m){
            reps(j,n){
                sint(masu[j][i]);
            }
        }
         
        queue<S> que;
        que.push(S(a,b,c,d,0));
        rep(i,51)rep(j,51)rep(k,51)rep(p,51)visit[i][j][k][p]=0;
        int ans=0;
        while(1){
            if(que.empty()==1){
                break;
            }
             
             
            S u=que.front();
            que.pop();
             
            //printf("%d %d  %d %d  %d\n",u.a,u.b,u.c,u.d,u.n);
             
            if(visit[u.a][u.b][u.c][u.d]==1){
                continue;
            }
            visit[u.a][u.b][u.c][u.d]=1;
             
            if(u.a==u.c && u.b==u.d){
                ans=u.n;
                break;
            }
             
            rep(i,4){
                int dx1=u.a+dx[i];
                int dy1=u.b+dy[i];
                 
                int dx2=u.c+dx[i]*-1;
                int dy2=u.d+dy[i]*-1;
                 
                //printf("push %d %d %d %d\n",dx1,dy1,dx2,dy2);
                 
                if(dx1<=0 || dy1<=0 || dx1>n ||dy1>m|| masu[dx1][dy1]==1){
                    dx1-=dx[i];
                    dy1-=dy[i];
                }
                if(dx2<=0 || dy2<=0 || dx2>n ||dy2>m|| masu[dx2][dy2]==1){
                    dx2-=dx[i]*-1;
                    dy2-=dy[i]*-1;
                }
                 
                //printf("push %d %d %d %d\n",dx1,dy1,dx2,dy2);
                que.push(S(dx1,dy1,dx2,dy2,u.n+1));
            }
        }
        if(ans==0){
            puts("NA");
        }else{
            printf("%d\n",ans);
        }
    }
}

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

using namespace std;

#define vec vector
typedef long long ll;
typedef pair<ll,ll> pll;

bool cmp(pll a,pll b)
{
    return a.first*b.second>a.second*b.first;
}

int main()
{
    int N,W;
    vec<pll> stuff;

    cin>>N>>W;

    stuff.resize(N);

    for(int i=0;i<N;i++)
    {
        cin>>stuff[i].first>>stuff[i].second;
    }

    sort(stuff.begin(),stuff.end(),cmp);

    double value=0;
    for(int i=0;i<N&&W>=0;i++)
    {
        if(stuff[i].second<=W){
            value+=stuff[i].first;
        }else
        {
            value+=1.0*stuff[i].first*W/stuff[i].second;
        }
        W-=stuff[i].second;
    }

    cout<<fixed<<setprecision(8)<<value<<endl;

    return 0;
}



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

// ----------- define --------------
#define int long long
#define vi vector<int>
#define ii pair<int,int>
#define fi first
#define sc second
#define stoi stoll
#define popcnt __builtin_popcount
#define getBit(x, k) ((x >> k) & 1)
#define all(x) (x).begin(),(x).end()
// ---------------------------------

void Main() {
  int n; cin >> n;
  vector<ii> a(n);
  for (auto &i : a) cin >> i.fi >> i.sc;
  for (int i = 0; i < n - 2; i++) {
    bool b = 1;
    for (int j = i; j <= i + 2; j++) {
      if (a[j].fi != a[j].sc) b = 0;
    }
    if (b) {
      cout << "Yes" << '\n';
      return;
    }
  }
  cout << "No" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  cerr << "i love ------- <3 \n";
#endif
  cin.tie(0)->sync_with_stdio(0);
  int T = 1;
  // cin >> T;
  while (T--) Main();
}


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

int main() {
    int n, k;
    cin >> n >> k;
    long long int res = 0;
    for(int i = k + 1; i <= n; i++){
        res += (i - k) * (n / i) + max((n % i - (k - 1) * (k != 0)), 0);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
def d_wall(H, W, C, A):
    import scipy.sparse
    # cost[i][j]:数字iからjに移行するための最小コスト(float64で格納される)
    cost = scipy.sparse.csgraph.floyd_warshall(C)
    # 壁の各数字ごとに、その数字から1へ変えるための最小コストを計算し、和を取る
    return int(sum(cost[A[h][w]][1] for h in range(H) for w in range(W) if A[h][w] != -1))

H, W = [int(i) for i in input().split()]
C = [[int(i) for i in input().split()] for j in range(10)]
A = [[int(i) for i in input().split()] for j in range(H)]
print(d_wall(H, W, C, A))

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

const ll INF = 1ll<<60;

typedef pair<ll,ll> P;

int main() {
  ll n, x, d;
  cin >> n >> x >> d;

  if (d == 0) {
    if (x == 0) {
      cout << 1 << endl;
    } else {
      cout << n+1 << endl;
    }
    return 0;
  }

  map<int,vector<P>> mp;
  rep(i,n+1) {
    ll s = x*i;
    ll l = (ll)i*(i-1)/2;
    ll r = (ll)i*(n-i);
    s += l*d;
    mp[(s+(d<<30))%d].emplace_back(s,r);
  }

  ll ans = 0;
  for (auto p : mp) {
    auto a = p.second;
    int m = a.size();
    rep(i,m) a[i].first = (a[i].first-p.first)/d;
    vector<P> ev;
    rep(i,m) {
      ev.emplace_back(a[i].first, 1);
      ev.emplace_back(a[i].first+a[i].second+1, -1);
    }
    sort(ev.begin(), ev.end());
    ll cnt = 0, pre = -INF;
    for (auto e : ev) {
      ll len = e.first-pre;
      if (cnt) ans += len;
      cnt += e.second;
      pre = e.first;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 22144
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		System.out.println(s.subSequence(0, 4)+" "+s.subSequence(4, 12));
		//char a='A';
		//System.out.println(Integer.valueOf(a));
	}
}



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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new ABC125().SolveA(new ConsoleInput(Console.In, ' '));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
  class ABC125
  {
    public void SolveA(ConsoleInput cin)
        {
            var a = cin.ReadInt;
            var b = cin.ReadInt;
            var t = cin.ReadInt;
            WriteLine((t/a)*b);
            ReadLine();
        }
  }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
typedef int64_t Int;
#define dump(x) cout << (x) << '\n'
Int mod = 1e9+7;

int main() {
    Int a, b, t;
    cin >> a >> b >> t;
    dump(b * (t / a));
    return 0;
}

Measured memory_bytes: 764
#include <stdio.h>

int main(void)
{
	int i, n, x;
	
	scanf("%d", &n);
	
	for(i = 1; i <= n; i++){
		if(i % 3 == 0){
			printf(" %d", i);
		} else {
			for(x = i; x; x /= 10){
				if(x % 10 == 3){
					printf(" %d", i); break;
				}
			}
		}
	}
	printf("\n");
	return 0;
}



Measured memory_bytes: 2124
#include<stdio.h>

int main(){
    int N,A,B;
    scanf("%d", &N);
    if(N==1){
        printf("Hello World\n");
        return 0;
    }
    scanf("%d", &A);
    scanf("%d", &B);
    printf("%d\n", A+B);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <set>
#include <string>
using namespace std;
int main() {
	string s;
	set<char> c{};
	cin >> s;
	for (int i = 0; i < s.size(); i++) {
		c.insert(s[i]);
	}
	cout << (s.size() == c.size() ? "yes" : "no") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdint>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

int main(void)
{
    int64_t N, M;

    std::cin >> N >> M;

    std::vector<int64_t> As(N);
    int64_t total = 0;
    for (auto& A : As) {
        std::cin >> A;
        total += A;
    }

    int64_t count = 0;
    for (auto A : As) {
        if (A < (total/(4.0*M))) continue;
        count++;
    }

    std::cout << (count >= M ? "Yes" : "No") << std::endl;

    return 0;
}

Measured memory_bytes: 256
S = input()

if S == "MON":
  print(6)
elif S == "TUE":
  print(5)
elif S == "WED":
  print(4)
elif S == "THU":
  print(3)
elif S == "FRI":
  print(2)
elif S == "SAT":
  print(1)
else :
  print(7)


Measured memory_bytes: 2940
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		try (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: 26240
#include <bits/stdc++.h>
using namespace std;

int main()
{
	int64_t n;
	cin >> n;
	vector<int64_t> as(n);
	for (auto &&a : as)
	{
		cin >> a;
	}

	vector<pair<int64_t, int64_t>> dpy(n + 1), dps(n + 1);

	dpy[0] = {1000, 0};

	for (int64_t i = 0; i < n; i++)
	{
		dpy[i + 1] = max({dpy[i + 1], dpy[i], {dps[i].second + as[i] * dps[i].first, 0}});
		dps[i + 1] = max({dps[i + 1], dps[i], {dpy[i].second + dpy[i].first / as[i], dpy[i].first % as[i]}});
	}

	cout << dpy[n].first << endl;

	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	ll n;
	cin >> n;
	ll ans=1;
	ll res[1001]={0};
	for(int num=2; num<=n; num++){
		int c = num;
		for(int i=2; i<=num; i++){
			while(c%i==0){
				res[i]++;
				c/=i;
			}
		}
	}
	for(int i=2; i<=n; i++){
		if(res[i]){
			ans*=res[i]+1;
			ans%=1000000007;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a, b;
	while(scanf("%d %d", &a, &b)) {
		if(a==0 && b == 0)
			return 0;
			
		if(a > b) {
			printf("%d %d\n", b, a);
		} else {
			printf("%d %d\n", a, b);
		}
	}
	
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define Rep(i,n) for(int i=1;i<=(n);++i)
using LL = long long;
using ULL = unsigned long long;

const int N = 200123;

int ans[N], a[N], s[N], top;
vector<int> vv[N];

void dfs(int u) {
	int tmp = top;
	while(a[u] <= s[tmp]) --tmp;
	int y = s[++tmp];
	s[tmp] = a[u];
	if(top < tmp) top = tmp;
	ans[u] = top;
	for(int v: vv[u]) if(ans[v] == 0) dfs(v);
	s[tmp] = y;
	if(y == 0 && tmp == top) --top;
}

int main()
{
	int n;
	int u, v;
	cin >> n;
	Rep(i, n) scanf("%d", a+i);
	rep(i, n-1) {
		scanf("%d%d", &u, &v);
		vv[u].push_back(v);
		vv[v].push_back(u);
	}
	dfs(1);
	Rep(i, n) cout << ans[i] << endl;
	return 0;
}


Measured memory_bytes: 30540
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <vector>

#define PI (3.14159265358979323846)
#define INF (1e+9)
#define DV_NUM (100000007)

using namespace std;
 
int main()
{
    int A,B,C;
    cin >> A >> B >> C;

    string Answer;

    if(    ( A == B && B!=C )
        || ( A == C && B!=C )
        || ( A != B && B==C )) {
      Answer = "Yes";
    }else{
      Answer = "No";
    }

    cout << Answer << endl;
 
    return 0;
 
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int x[3], y[3], a, b;
	scanf("%d %d %d %d", &x[0], &y[0], &x[1], &y[1]);
	a = x[1] - x[0];
	b = y[1] - y[0];
	printf("%d %d %d %d\n", x[1] - b, y[1] + a, x[0] - b, y[0] + a);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
 
 
int main() {
  int n;
  cin >> n;
  
  int counter = 0;
  bool flag = false;
  
  for(int i = 0; i < n; i++){
    int d1, d2;
    cin >> d1 >> d2;
    
    if(d1 == d2) {
      counter++;
      if(counter == 3)
        flag = true;
    }
    else
      counter = 0;
  }
  
  if(flag == true)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int M, D;
    cin >> M >> D;

    ll ans = 0;
    FOR(i, 1, M + 1) FOR(j, 1, D + 1) {
        if ((j / 10) < 2 || (j % 10) < 2) continue;
        if (i == (j / 10) * (j % 10)) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
fn main() {
    let s = read::<String>();
    let s: Vec<char> = s.chars().into_iter().collect();
    let t = read::<String>();
    let t: Vec<char> = t.chars().into_iter().collect();
    for i in 0..s.len() {
        if s[i] != t[i] {
            println!("No");
            return;
        }
    }
    println!("Yes");
}

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


Measured memory_bytes: 2140