akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <map>
#include <algorithm>
#include <cstdio>
using namespace std;

int do_cycle(vector<int> &v,int x){
	int s=0,m=1<<30;
	for(auto &e:v)s+=e,m=min(m,e);
	return min(s+(v.size()-2)*m,s+m+(v.size()+1)*x);
}

int main(){
	int N,x=1<<30,r=0;
	scanf("%d",&N);
	vector<int>v(N),b(N),se(N);
	map<int,int>m;
	vector<vector<int> >cycles;
	for(int i=0;i<N;i++)scanf("%d",&v[i]),x=min(x,v[i]),se[i]=v[i];
	sort(se.begin(),se.end());
	int i=0;for(auto &e:se){m[e]=i++;}
	for(int i=0;i<N;i++)if(!b[i]){
		vector<int>cycle;
		int k=i;
		do{
			cycle.push_back(se[k]);
			b[k]=1;
			k=m[v[k]];
		}while(k!=i);
		r+=do_cycle(cycle,x);
	}
	printf("%d\n",r);
}

Measured memory_bytes: 2912
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <list>
#include <bitset>
#include <vector>
using namespace std;

#define I64d_OJ

//#ifdef I64d_OJ
//#define LL __int64
//#endif // I64d_OJ
#ifdef I64d_OJ
#define LL long long
#endif // I64d_OJ

typedef unsigned LL ULL;
typedef unsigned uint;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;
typedef vector<int> vi;

inline LL read(){
    LL x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-f; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define ls rt<<1
#define rs rt<<1|1
#define MID(a,b) (((LL)(a)+(LL)(b))>>1)
#define absx(a) ((a)<0?-(a):(a))
#define MK(a,b) make_pair(a,b)
#define PB(a) push_back(a)
#define lowbit(x) ((x)&-(x))

template< typename T >
inline void Max(T &a,T &b){if(a<b) a=b;}
template< typename T>
inline void Min(T &a,T &b){if(a>b) a=b;}

const double pi=(double)acos(-1.0);
const double eps=(double)1e-10;
const int INF = (int) 0x3f3f3f3f;
const int MOD = (int) 1e9+7;
const int MAXN =(int) 5e2+10;
const int MAXM = (int) 2e5+10;
const int sigma_size = (int) 26;

///--------------------START-------------------------
int n;
double p[MAXN],q[MAXN];
double f[MAXN][MAXN];
double sump[MAXN],sumq[MAXN];

void work(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%lf",&p[i]);
    for(int i=0;i<=n;i++) scanf("%lf",&q[i]);
    sumq[0]=q[0];
    for(int i=1;i<=n;i++) sump[i]=sump[i-1]+p[i],sumq[i]=sumq[i-1]+q[i];
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            f[i][j]=1.0*INF;
            if(j<i) f[i][j]=0.0;
        }
    }
    for(int len=1;len<=n;len++){
        for(int i=1;i+len-1<=n;i++){
            int j=i+len-1;
            for(int k=i;k<=j;k++){
                double tsum=sump[j]-sump[i-1];
                if(i==1) tsum+=sumq[j];
                else tsum+=sumq[j]-sumq[i-2];
                f[i][j]=min(f[i][j],tsum-p[k]+f[i][k-1]+f[k+1][j]);
            }
        }
    }
    printf("%.8lf\n",f[1][n]+sump[n]+sumq[n]);
}
/*
5
0.1500 0.1000 0.0500 0.1000 0.2000
0.0500 0.1000 0.0500 0.0500 0.0500 0.1000

7
0.0400 0.0600 0.0800 0.0200 0.1000 0.1200 0.1400
0.0600 0.0600 0.0600 0.0600 0.0500 0.0500 0.0500 0.0500
*/
///--------------------END-------------------------
int main(){
#ifdef NNever
//freopen("data.in","r",stdin);
///freopen("out.txt","w",stdout);
#endif // NNever
    work();
    return 0;
}


Measured memory_bytes: 5236
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define ll long long
#define N 5010
int read()
{
    int x=0,f=1;char c=getchar();
    while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
    while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
    return x*f;
}
int n,a[N],p[N],g[N],size[N],t;
ll sum[N],f[N][N];
struct data{int to,nxt;
}edge[N<<1];
void addedge(int x,int y){t++;edge[t].to=y,edge[t].nxt=p[x],p[x]=t;}
void dfs(int k,int from)
{
    sum[k]=a[k];
    for (int i=p[k];i;i=edge[i].nxt)
    if (edge[i].to!=from)
    {
        dfs(edge[i].to,k);
        sum[k]+=sum[edge[i].to];
    }
    if (a[k]>0)
    {
        g[k]=0;
        for (int i=p[k];i;i=edge[i].nxt)
        if (edge[i].to!=from)
        {
            int x=g[edge[i].to];
            for (int j=0;j<=n;j++)
            if (f[edge[i].to][j]<0) {x=min(x,j+1);break;}
            g[k]+=x;
        }
    }
    f[k][0]=a[k];
    size[k]=1;
    for (int i=p[k];i;i=edge[i].nxt)
    if (edge[i].to!=from)
    {
        for (int j=size[k]+size[edge[i].to];j>=0;j--)
        {
            f[k][j]+=sum[edge[i].to];if (j-g[edge[i].to]-1>=0) f[k][j]=min(f[k][j],f[k][j-g[edge[i].to]-1]);
            for (int x=max(0,j-size[k]);x<=min(j,size[edge[i].to]);x++)
            {
                if (x) f[k][j]=min(f[k][j],f[k][j-x]+f[edge[i].to][x]);
                if (x<j&&f[edge[i].to][x]<0) f[k][j]=min(f[k][j],f[k][j-x-1]);
            }
        }
        size[k]+=size[edge[i].to];
    }
}
int main()
{
    /*freopen("e.in","r",stdin);
    freopen("e.out","w",stdout);*/
    n=read();
    for (int i=1;i<=n;i++) a[i]=read();
    for (int i=1;i<n;i++)
    {
        int x=read(),y=read();
        addedge(x,y),addedge(y,x);
    }
    memset(g,42,sizeof(g));
    memset(f,42,sizeof(f));
    dfs(1,1);
    /*for (int i=1;i<=n;i++) cout<<a[i]<<' ';cout<<endl;
    for (int i=1;i<=n;i++) cout<<g[i]<<' ';cout<<endl;
    cout<<endl;
    for (int i=1;i<=n;i++)
    {
        for (int j=0;j<n;j++)
        cout<<f[i][j]<<' ';
        cout<<endl;;
    }
    for (int i=1;i<=n;i++) cout<<sum[i]<<' ';cout<<endl;*/
    int ans=g[1];
    for (int i=0;i<=n;i++) 
    if (f[1][i]<0) {ans=min(ans,i);break;}
    cout<<ans;
    return 0;
}

Measured memory_bytes: 196864
#include<iostream>
using namespace std;
typedef long long ll;
int main() {
	ll n,k;
	ll idex=0;
	cin>>n>>k;
	while(n--) {
		ll x,y;
		cin>>x>>y;
		if(x*x+y*y<=k*k) idex++;
	}
	cout<<idex<<endl;
	return 0;
}

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

#define ll long long
#define mtv(kit) cout<<#kit<<" - "<<kit<<"\n";
#define ff first
#define ss second
#define pb push_back
#define rep(i,a,b) for(i=a;i<b;i++)
#define pii pair<ll , ll>
#define all(x) x.begin(),x.end()
#define nl "\n"
#define ump unordered_map

void doit(){
    ll d, t, s;
    cin >> d >> t >> s;
    double r = (1.0 * d) / (1.0 * s);
    if(r <= t){
        cout << "Yes" << nl;
    }
    else cout << "No" << nl;
}

int main() {
#ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
    // cin >> t;
    for(ll i = 1; i <= t; i++){
        doit();
    }
}


Measured memory_bytes: 3688
/**Bismillahir Rahmanir Rahim.**/
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
using ll=long long;
using db=double;
///***************************************************** CONSTANTS ******************************************************///

int const N=1e6+3;
ll MOD=1e9+7,fact[N];
const long long inf=(long long)1e18;
const long double PI=3.14159265358979;

///************************************************ CONTAINER DEFINITIONS ***********************************************///

typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///************************************************ SHORT FORM KEYWORDS *************************************************///

#define PB push_back
#define F first
#define S second
#define MP make_pair
#define I insert
#define lb lower_bound
#define ub upper_bound
#define endl '\n'

///************************************************ SHORT FORM FUNCTIONS ************************************************///

#define loop(a,b) for(ll i=a;i<b;i++)
#define loopr(a,b) for(ll i=a-1;i>=b;i--)
#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sa(v) sort(v.begin(),v.end())
#define sd(v) sort(v.begin(),v.end(),greater<>())
#define rev(s) reverse(s.begin(),s.end())
#define stll(x) stoll(x, nullptr, 10);
#define yes cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define all(a) a.begin(),a.end()
#define mxa(a,N) *max_element(a,a+N)
#define mna(a,N) *min_element(a,a+N)
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define io() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


///************************************************ SOLUTION STARTS HERE ************************************************///
///======================================================================================================================///


void solve(){
	int n; cin>>n;
	if(n==1) cout<<"0"<<endl;
	else cout<<"1"<<endl;
	
}
int main()
{
    io();
    int T=1;//cin>>T;
    while(T--) solve();
    return 0;
}

/****************ALHAMDULILLAH******************/


Measured memory_bytes: 3648
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{BufWriter, Write};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        k: i64, s: i64,
    }
    let mut cnt = 0;
    for i in 0..k + 1 {
        for j in 0..k + 1 {
            if s - (i + j) <= k && 0 <= s - (i + j) {
                cnt += 1;
            }
        }
    }
    puts!("{}\n", cnt);
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

Measured memory_bytes: 8572
#include <bits/stdc++.h>
 
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
 
using namespace std;
#define ll long long
#define ull unsigned long long
#define rep(i,n,N) for(int i=n;i<=N;++i)
#define asd(i,n,N) for(int i=n;i< N;++i)
#define rap(i,n,N) for(int i=n;i>=N;--i)
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define fi first
#define se second
#define ff fi.fi
#define fs fi.se
#define sf se.fi
#define ss se.se
#define lc (id<<1)
#define rc ((id<<1)|1)
#define db(x) cout << ">>>> " << #x << " -> " << x << endl
#define mems(x,y) memset(x,y,sizeof x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int> 
#define pll pair<ll,ll>
#define plll pair<pll,ll>
#define piii pair<pii,int>
#define piiii pair<pii,pii>
#define psi pair<string,int>
//#define endl '\n'
const int MAX = 1e6+5;
const ll MAX2 = 11;
const ll MOD = 1000000007;
const ll MOD2 = 1000005329;
const ll INF = 2e18;
const int dr[]={1,0,-1,0,1,1,-1,-1,0};
const int dc[]={0,1,0,-1,1,-1,1,-1,0};
const double pi = acos(-1);
const double EPS = 1e-9;
const int block = 555;

int x;

int main(){
//	cout<<fixed<<setprecision(10);
//	freopen("input.txt", "r", stdin);
//	freopen("astar.out","w",stdout);
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin>>x;
    if(x>=30)cout<<"Yes\n";
    else cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3644
n,m=map(int,input().split())
a=[input() for _ in range(n)]
b=[input() for _ in range(m)]
for i in range(n-m+1):
    if b[0] in a[i]:
        x=a[i].index(b[0])
        st=0
        for j in range(1,m):
            for k in range(m):
                if a[i+j][x+k]!=b[j][k]:
                    st=1
                    break
        if st==0:
            print('Yes')
            exit()
print('No')

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	int count = 0;
	public static void main(String[] args) {
		new Main().runSort();
	}
	
	public void runSort() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] l = new int[n];
		for (int i = 0; i < n; i++) {
			l[i] = sc.nextInt();
		}
		sorting(l, 0, n);
		System.out.print(l[0]);
		for (int i = 1; i < n; i++) {
			System.out.print(" " +l[i]);
		}
		System.out.println();
		System.out.println(count);
	}

	public void sorting(int[] l, int nl, int nr) {
		if (nl + 1 < nr) {
			int nm = (nl + nr) / 2;
			sorting(l, nl, nm);
			sorting(l, nm, nr);
			merging(l, nl, nm, nr);
		}
	}

	public void merging(int[] list, int nl, int nm, int nr) {
		int n1 = nm - nl;
		int n2 = nr - nm;
		int[] l = new int[n1 + 1];
		int[] r = new int[n2 + 1];
		for (int i = 0; i < n1; i++) {
			l[i] = list[nl + i];
		}
		for (int i = 0; i < n2; i++) {
			r[i] = list[nm + i];
		}
		l[n1] = Integer.MAX_VALUE;
		r[n2] = Integer.MAX_VALUE;

		int LEFT = 0;
		int RIGHT = 0;
		for (int i = nl; i < nr; i++) {
			if (l[LEFT] <= r[RIGHT]) {
				list[i] = l[LEFT++];
			} else {
				list[i] = r[RIGHT++];
			}
			count++;
		}
	}

}


Measured memory_bytes: 170608
n = gets.chomp.to_i
m = n.downto(1).to_a.map { |i|
  c = 0
  j = i
  loop {
    k = j / 2
    if j != 2 * k
      break
    end
    j = k
    c += 1
  }
  [c, i]
}.max_by { |t|
  t[0]
}
puts m[1]


Measured memory_bytes: 1788
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def main():
    N = int(input())
    rank, score = -1, -1
    for _ in range(N):
        A, B = map(int, input().split())
        if A > rank:
            rank = A
            score = B

    print(rank + score)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {

int h,w;
while(1)
{
cin>>h>>w;
if(h==0&&w==0)break;
for(int i=0;i<h;i++)
{
for(int j=0;j<w;j++)
{
if(i%2==0&&j%2==1 || i%2==1&&j%2==0)cout<<".";
else cout<<"#";
}
cout<<endl;
}
cout<<endl;
}
}


Measured memory_bytes: 3076
# Nについての全探索でいけそう
n, m, x = map(int, input().split())
cost, A = [0] * n, [[]] * n
for i in range(n):
    line = list(map(int, input().split()))
    cost[i] = line[0]
    A[i] = line[1:]

ans = 10**10

for bit in range(1 << n):
    tmp_cost = 0
    tmp_a = [0] * m
    for i in range(n):
        if bit >> i & 1 == 1:
            tmp_cost += cost[i]
            for j in range(m):
                tmp_a[j] += A[i][j]
        # すべてXを越えてるかチェック filterがどこにあるかわからんw
    if len(list(filter(lambda t: t >= x, tmp_a))) == m:
        ans = min(ans, tmp_cost)
print(ans if ans != 10**10 else -1)

Measured memory_bytes: 9232
import java.util.*;

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

        int N = sc.nextInt();
        int X = sc.nextInt();
        int[] m = new int[N];
        int M = 0;
        int ans = 0;
        int min = X;

        for(int i=0; i<N; i++){
            m[i] = sc.nextInt();
            min = Math.min(min, m[i]);
            M += m[i];
            ans += 1;
        }
        for(int i=0; i<X; i++){
            if(X-M>=min){
                M += min;
                ans += 1;
            }
            else{
                break;
            }
        }
        System.out.println(ans);
    }
}

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

int c[100000];
int main(void){
    string S;
    cin >> S;
    for (int i = 0; i < S.size(); i++) c[i] = 0;
    
    int count = 0;
    char flag = 'R';
    for (int i = 0; i < S.size(); i++) {
        if (flag == S[i])
            count++;
        else {
            c[i-1] += count - (count / 2);
            c[i] += count / 2;
            count = 0;
        }
    }
    
    flag = 'L';
    count = 0;
    for (int i = S.size()-1; i >= 0; i--) {
        if (flag == S[i])
            count++;
        else {
            c[i+1] += count - (count / 2);
            c[i] += count / 2;
            count = 0;
        }
    }
    
    for (int i = 0; i < S.size(); i++) {
        if (i != S.size()-1)
            cout << c[i] << " ";
        else
            cout << c[i] << endl;
    }
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N,K; cin >> N >> K;
    ll ans = 0;
    FOR(b,K+1,N+1){
        ans += (N+1) / b * (b-K);
        ans += max(0, (N+1)%b - K);
    }

    if(K==0) ans -= N;//コーナーケース、あまりが0のときはa=0を除外

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

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int n; cin >> n;
    double sum = 0;
    rep(i,n){
        double a; cin >> a;
        sum += 1/a;
    }
    double ans = 1/sum;
    cout << fixed << setprecision(10) << ans << endl;
}

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
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            char[] s = in.nextLine().toCharArray();
            int k = in.nextInt();
            for (int i = 0; i < s.length; i += k) {
                out.print(s[i]);
            }
            out.println();
        }

    }

    static class InputReader {
        StringTokenizer st;
        BufferedReader br;

        public InputReader(InputStream is) {
            BufferedReader br = new BufferedReader(new InputStreamReader(is));
            this.br = br;
        }

        public String next() {
            if (st == null || !st.hasMoreTokens()) {
                String nextLine = null;
                try {
                    nextLine = br.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
                if (nextLine == null)
                    return null;
                st = new StringTokenizer(nextLine);
            }
            return st.nextToken();
        }

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

        public String nextLine() {
            String str = null;
            try {
                str = br.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            return str;
        }

    }
}



Measured memory_bytes: 23252
s = list(raw_input())
k = input()
for i in xrange(len(s)-1):
    if s[i] == 'a':
        continue
    need = ord('z') - ord(s[i]) + 1
    if need <= k:
        k -= need
        s[i] = 'a'
s[-1] = chr(((ord(s[-1]) + k - ord('a')) % 26) + ord('a'))
print ''.join(s)


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int c[3][3];
  rep(i, 3) {
    rep(j, 3) {
      cin >> c[i][j];
    }
  }

  int a[2], b[2];
  rep(i, 2) a[i] = c[i][0] - c[i + 1][0];
  rep(j, 2) b[j] = c[0][j] - c[0][j + 1];

  rep(j, 3) {
    rep(i, 2) {
      if (c[i][j] - c[i + 1][j] != a[i]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  rep(i, 3) { 
    rep(j, 2) {
      if (c[i][j] - c[i][j + 1] != b[j]) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;




  
  return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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


fn main () {
    input! {
        n: usize,
        s: [chars; n],
    }
    for c in s {
        if c[0] == 'Y' {
            println!("Four");
            return ;
        }
    }
    println!("Three");
}


Measured memory_bytes: 4352
def read_input():
    n, m = map(int, input().split())

    max_l = 0
    min_r = 10**5 + 1

    for i in range(m):
        l, r = map(int, input().split())

        if l > max_l:
            max_l = l

        if r < min_r:
            min_r = r

    return max_l, min_r



def submit():
    l, r = read_input()

    if r < l:
        print(0)
    else:
        print(r - l + 1)




if __name__ == '__main__':
    submit()


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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let nk = read_vec::<i64>();
    let (n,k) = (nk[0],nk[1]);
    let ans = k * double(k-1,n-1);
    println!("{}", ans);
}
fn double(x:i64,c:i64) -> i64{
    if c == 0 {
        1
    } else {
        x * double(x, c-1)
    }
}

Measured memory_bytes: 4352
using System;

namespace Sample101
{
    class Program
    {
        static void Main(string[] args)
        {
            int daikin = int.Parse(Console.ReadLine());
            int ichien = int.Parse(Console.ReadLine());

            if (daikin % 500 <= ichien) {
                Console.WriteLine("Yes");
            } else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
//cout << fixed << setprecision(20) << *** << endl;
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;
//ユークリッド
ll gcd(ll a,ll b){
	ll t;
	if(a<b){
		t=a;
		a=b;
		b=t;
	}
	if(a%b==0)return b;
	return gcd(b,a%b);
}
//階乗
ll Factorial(ll a){
	ll b=1;
	for(ll i=a;i>=1;i--){
		b=b*i;
	}
	return b;
}
//素数判定
bool prime(ll n){
	for(ll i=2;i*i<=n;i++){
		if(n%i==0) return false;
	}
	return true;
}
int main()
{
	string s;
	ll A,B,C,D;
	cin>>s;
	A=(int)s[0]-48;
	B=(int)s[1]-48;
	C=(int)s[2]-48;
	D=(int)s[3]-48;
	if(A+B+C+D==7)cout<<A<<"+"<<B<<"+"<<C<<"+"<<D<<"=7"<<endl;
	else if(A+B+C-D==7)cout<<A<<"+"<<B<<"+"<<C<<"-"<<D<<"=7"<<endl;
	else if(A+B-C+D==7)cout<<A<<"+"<<B<<"-"<<C<<"+"<<D<<"=7"<<endl;
	else if(A+B-C-D==7)cout<<A<<"+"<<B<<"-"<<C<<"-"<<D<<"=7"<<endl;
	else if(A-B-C-D==7)cout<<A<<"-"<<B<<"-"<<C<<"-"<<D<<"=7"<<endl;
	else if(A-B-C+D==7)cout<<A<<"-"<<B<<"-"<<C<<"+"<<D<<"=7"<<endl;
	else if(A-B+C-D==7)cout<<A<<"-"<<B<<"+"<<C<<"-"<<D<<"=7"<<endl;
	else if(A-B+C+D==7)cout<<A<<"-"<<B<<"+"<<C<<"+"<<D<<"=7"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

const int MAX_N = 100010;
//Quick Find Weighted
class QuickFindWeighted{
    public:
        int i2g[MAX_N];//i2g[i] := 頂点iが所属するグループ
        vector<int> g2i[MAX_N];//g2i[g]:= グループgに所属する頂点番号
        void init(int n){
            for (int i = 0; i < n; ++i){
                i2g[i] = i;
                g2i[i].push_back(i);
            }
        }
        // 座標iaと座標ibは同じグループに所属しているか？
        bool issame(int ia, int ib){
            return i2g[ia] == i2g[ib];
        }
        // 座標iaの所属するグループと座標ibの所属するグループを1つにする(異なるグループに属するものに)
        void merge(int ia, int ib){
            if(issame(ia, ib)) return;
            //iaの所属するグループがibの所属するグループより小さくならないようにする(一般的マージテク)
            if(g2i[i2g[ia]].size() < g2i[i2g[ib]].size()){
                swap(ia, ib);
            }
            int ga = i2g[ia], gb = i2g[ib];//グループgbの方が要素数が少ない
            for(auto u : g2i[gb]){//uには頂点の番号はいる
                i2g[u] = ga;//グループの番号を更新
            }
            g2i[ga].insert(g2i[ga].end(), g2i[gb].begin(), g2i[gb].end());//つなげる
            g2i[gb].clear();
        }
};

int main(int argc, char const *argv[])
{
	ll n; int m; cin >> n >> m;
	vector<int> a(m), b(m);
	rep(i, m) cin >> a[i] >> b[i];
	rep(i, m) a[i]--, b[i]--;

	QuickFindWeighted uf;
	uf.init(n);

	ll ans = 0;
	vector<ll> memo;
	memo.push_back(n * (n - 1) / 2);

	for (int i = m - 1; i >= 1; --i) {
		if (!uf.issame(a[i], b[i])) {
			int va = uf.i2g[a[i]], vb = uf.i2g[b[i]];
			ll cnta = uf.g2i[va].size();
			ll cntb = uf.g2i[vb].size();
			// printf("%d %d\n", cnta, cntb);
			ans += cnta * cntb;
		}
		uf.merge(a[i], b[i]);
		memo.push_back(n * (n - 1) / 2 - ans);
	}
	reverse(memo.begin(), memo.end());
	for (auto u : memo) printf("%lld\n", u);
	return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;


int main(){
    int n;cin >>n;
    vector<P>red(n);
    vector<P>blue(n);
    for (int i = 0; i < n; ++i) {
        int a,b;cin >>a>>b;
        red[i]={a,b};
    }
    for (int i = 0; i < n; ++i) {
        int c,d;cin >>c>>d;
        blue[i]={c,d};
    }
    sort(all(red));
    sort(all(blue));
    int k=0;
    int ans=0;
    vector<bool>ch(n,true);
    for (int i = 0; i < n; ++i) {
        vector<P>que;
        for (int j = 0; j <n; ++j) {
            if(red[j].first<blue[i].first&&red[j].second<blue[i].second){
                if(ch[j]){
                    que.push_back({red[j].second,j});
                }
            }
        }
        if(!que.empty()) {
            sort(all(que));
//            cout <<que.back().first<<" "<<blue[i].first<<" "<<blue[i].second<<endl;
            ch[que.back().second]=false;
            ans++;
        }
    }
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
//for(int i = 0; i < n; i++)

int main() {
  int a = 0, b, n;
  cin >> n;
  vector<int> d(n);
  for(int i = 0; i < n; i++) cin >> d.at(i);
  for(int i = 0; i < n; i++){
    for(int j = i + 1; j < n; j++){
      a += d.at(i) * d.at(j);
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b, c := iScan(), iScan(), iScan()
	x, y := iScan(), iScan()
	ans := mod * mod
	for i := 0; i <= larger(x, y); i++ {
		ans = smaller(ans, c*2*i+larger(a*(x-i), 0)+larger(b*(y-i), 0))
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1772
#include<stdio.h>
#include<stdlib.h>
#include<limits.h>

 
int count=0;


/*????????????????????????A[left]*/
void merge(int *A,int left,int mid,int right){
  int i,n1,n2;
  n1=mid-left;
  n2=right-mid;
  int L[n1+1],R[n2+1];
  for(i=left;i<=mid-1;i++) L[i-left]=A[i];
  for(i=mid;i<=right-1;i++) R[i-mid]=A[i]; 
  L[n1]=INT_MAX;
  R[n2]=INT_MAX;
  int l=0,r=0;
  for(i=left;i<right;i++){
    count++;
    if(L[l]<R[r]){
      A[i]=L[l];
      l++;
    }
    else{
      A[i]=R[r];
      r++;
    }
  }
}


void m_sort(int *A,int left,int right){
  if(right <= left+1) return;
  int mid;
  mid=(left+right)/2;
  m_sort(A,left,mid);
  m_sort(A,mid,right);
  merge(A,left,mid,right);
}
    




int main(){
  int n,*A,i;
  scanf("%d",&n);
  A=malloc(n*sizeof(int));
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  m_sort(A,0,n);
  for(i=0;i<n-1;i++) printf("%d ",A[i]);
  printf("%d\n",A[n-1]);
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 4504
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;

int n, a[3][N];
int p[N], v[N], to[N];
int b[N], tr[N * 3];

void Add(int x) {
	while (x <= n * 3) {
		tr[x] ^= 1;
		x += x & -x;
	}
}

int Query(int x) {
	int ans = 0;
	while (x) {
		ans ^= tr[x];
		x -= x & -x;
	}
	return ans;
}

int inv(int *a, int n) {
	memset(tr, 0, sizeof tr);
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		ans ^= Query(n * 3) ^ Query(a[i]);
		Add(a[i]);
	}
	return ans;
}

int main() {
	cin >> n;
	for (int i = 0; i < 3; ++i) {
		for (int j = 1; j <= n; ++j)
			scanf("%d", &a[i][j]);
	}
	for (int i = 1; i <= n; ++i) {
		if (a[0][i] % 3 == 1) {
			if (a[1][i] != a[0][i] + 1) return 0 * puts("No");
			if (a[2][i] != a[1][i] + 1) return 0 * puts("No");
			p[i] = (a[0][i] - 1) / 3 + 1;
			v[i] = 0;
		}
		if (a[0][i] % 3 == 0) {
			if (a[1][i] != a[0][i] - 1) return 0 * puts("No");
			if (a[2][i] != a[1][i] - 1) return 0 * puts("No");
			p[i] = a[0][i] / 3;
			v[i] = 1;
		}
		if (a[0][i] % 3 == 2) return 0 * puts("No");
	}
	for (int i = 1; i <= n; ++i)
		to[p[i]] = i;
	for (int i = 1; i <= n; ++i) {
		if ((i + to[i]) & 1) return 0 * puts("No");
	}
	
	int m = (n + 1) / 2;
	for (int i = 1; i <= m; ++i)
		b[i] = p[i * 2 - 1];
	int tmp = inv(b, m);
	for (int i = 1; i <= n; ++i)
		if (i % 2 == 0)
			tmp ^= v[i];
	if (tmp) return 0 * puts("No");

	m = n / 2;
	for (int i = 1; i <= m; ++i)
		b[i] = p[i * 2];
	tmp = inv(b, m);
	for (int i = 1; i <= n; ++i)
		if (i & 1)
			tmp ^= v[i];
	if (tmp) return 0 * puts("No");
	return 0 * puts("Yes");
}


Measured memory_bytes: 3968
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<map>
using namespace std;

int main()
{
	int n,m;
	string s;

	cin >> n >> s;

	for (int i = 0;i < s.length();i++)
	{
		m = n;
		if (s[i] + n > 'Z')
		{
			m = n - ('Z' - s[i])-1;
			s[i] = 'A';
		}
		s[i] += m;
	}
	cout << s;

	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] p = new int[N];
        for (int i = 0; i < N; i++) {
            p[i] = scan.nextInt();
        }
        Arrays.sort(p);
        int sum = 0;
        for (int i = 0; i < N; i++) {
            sum += p[i];
        }
        sum -= p[N-1]/2;
        System.out.println(sum);
    }
}


Measured memory_bytes: 21844
import java.util.*

data class State(val x: Int, val y: Int)

fun main(args: Array<String>) {
  val (h, w, k) = readLine()!!.split(" ").map { it.toInt() }
  val a = Array<String>(h) { readLine()!! }
  val INF = 1000000000
  val q: Queue<State> = LinkedList<State>()
  var dist = Array<IntArray>(h) { IntArray(w) { INF } }
  for (i in 0 until h) {
    for (j in 0 until w) {
      if (a[i][j] == 'S') {
        q.add(State(i, j))
        dist[i][j] = 0
      }
    }
  }
  val dx = arrayOf(1, 0, -1, 0)
  val dy = arrayOf(0, 1, 0, -1)
  var ans = INF
  while (!q.isEmpty()) {
    val s = q.remove()
    if (s.x == 0 || s.x == h - 1 || s.y == 0 || s.y == w - 1) {
      ans = arrayOf(ans, (dist[s.x][s.y] + k - 1) / k).min()!!
      continue
    }
    for (i in 0 until 4) {
      val tx = s.x + dx[i]
      val ty = s.y + dy[i]
      if (dist[tx][ty] <= dist[s.x][s.y] + 1) continue
      dist[tx][ty] = dist[s.x][s.y] + 1
      if (a[tx][ty] == '#') dist[tx][ty] = arrayOf(dist[tx][ty], k + 1).max()!!
      q.add(State(tx, ty))
    }
  }
  println(ans)
}


Measured memory_bytes: 125772
from collections import defaultdict

n = int(input())
line = defaultdict(list)  # R,L
row = defaultdict(list)  # U,D
A = defaultdict(list)  # U,R
B = defaultdict(list)  # L,D
C = defaultdict(list)  # U,L
D = defaultdict(list)  # R,D

for i in range(n):
    x, y, u = input().split()
    x = int(x)
    y = int(y)
    if u == "U":
        row[x].append((y, u == "U"))
        A[y + x].append((y - x, u == "U"))
        C[y - x].append((y + x, u == "U"))
    elif u == "D":
        row[x].append((y, u == "U"))
        B[y + x].append((y - x, u == "L"))
        D[y - x].append((y + x, u == "R"))
    elif u == "L":
        line[y].append((x, u == "R"))
        B[y + x].append((y - x, u == "L"))
        C[y - x].append((y + x, u == "U"))
    else:
        line[y].append((x, u == "R"))
        A[y + x].append((y - x, u == "U"))
        D[y - x].append((y + x, u == "R"))

ans = 10**18
for Z in (line, row, A, B, C, D):
    for z_list in Z.values():
        z_list.sort()
        for (v1, flag1), (v2, flag2) in zip(z_list, z_list[1:]):
            if flag1 and not flag2:
                ans = min(ans, abs(v1 - v2) * 5)

if ans == 10**18:
    print("SAFE")
else:
    print(ans)

Measured memory_bytes: 239048
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime> 

using namespace std;
const int INF=10000000;

int g[6]={2,3,5,10,12,15},p[6]={380,550,850,1520,1870,2244};

int main(void){
	int n;
	int a,b;
	int dp[51];
	for(a=0;a<=50;a++)dp[a]=INF;
	dp[0]=0;
	for(a=0;a<6;a++){
		for(b=0;b+g[a]<=50;b++){
			dp[b+g[a]]=min(dp[b+g[a]],dp[b]+p[a]);
		}
	}
	dp[1]=380;
	while(1){
		cin >> n;
		if(n==0)break;
		cout << dp[n/100] <<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

int main(void){
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	cout << (((abs(a-c)<=d) || ((abs(a-b)<=d) && abs(b-c)<=d))?"Yes":"No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
int main(){
    int N;
    cin >> N;
    vector<vector<int>> G(N);
    vector<int> cnt(N), score(N);
    for(int i = 0; i < N - 1; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        cnt[a]++;
        cnt[b]++;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<int> c(N);
    for(int i = 0; i < N; i++) cin >> c[i];
    sort(c.begin(), c.end());
    vector<int> ind(N);
    for(int i = 0; i < N; i++) ind[i] = i;
    sort(ind.begin(), ind.end(), [&](int i, int j){
        return cnt[i] < cnt[j];
    });
    priority_queue<P> q;
    vector<int> used(N, 0);
    q.push(P(cnt[ind[N - 1]], ind[N - 1]));
    int now = N - 1;
    while(!q.empty()){
        P v = q.top();
        used[v.second] = 1;
        q.pop();
        score[v.second] = c[now];
        now--;
        for(int j: G[v.second]){
            if(used[j] != 1){
                q.push(P(cnt[j], j));
            }
        }
    }
    queue<int> pq;
    pq.push(0);
    used.assign(N, 0);
    int ans = 0;
    while(!pq.empty()){
        int v = pq.front();
        pq.pop();
        used[v] = 1;
        for(int j: G[v]){
            if(used[j] == 0){
                ans += min(score[v], score[j]);
                pq.push(j);
            }
        }
    }
    cout << ans << endl;
    for(int i = 0; i < N; i++){
        if(i != N - 1) cout << score[i] << ' ';
        else cout << score[i] << endl;
    }
}

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

using namespace std;
# define rep(i, a, b) for(int i = a; i < (b); ++i)
# define trav(a, x) for(auto& a : x)
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vi a(n);
    vi b(n);
    rep(i, 0, n){
        cin >> a[i];
        cin >> b[i];
    }
    for(int i = 0; i < n - 2; i++){
        if(a[i] == b[i] && a[i+1] == b[i+1] &&a[i+2] == b[i+2]){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 3652
N = int(input())
S = list(input())
ans_list = []

ans = S[1:].count("E")
ans_list.append(ans)

for i in range(1,N):
  if S[i-1] == "W":
    ans += 1
  if S[i] == "E":
    ans -= 1
  ans_list.append(ans)

print(min(ans_list))

Measured memory_bytes: 23148
#include <bits/stdc++.h>
using namespace std;
#define ff        first
#define ss        second
#define ll        long long
#define int       long long
#define inf       ((ll)1e18)
#define mod       1000000007
#define double    long double
#define ull       unsigned long long
#define vi        vector<ll>
#define ppi       pair<int,int>
#define pii       pair<pair<int,int>,int>
#define pb        push_back
#define pi        2*acos(0.0)
#define rev       greater<int>()
#define pr(a,x,y) for(int i=x;i<y;i++){cout<<a[i]<<" ";}
#define sp(x,y)   fixed<<setprecision(y)<<x
#define w(x)      ll x; cin>>x; while(x--)
#define all(v)    v.begin(), v.end()
#define rall(v)   v.rbegin(), v.rend()
#define test      cout<<"This is test"<<endl;
#define str       string
#define endl      '\n'
#define e         cout<<'\n';
void kehsihba(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif*/
}
void solve(){
	ll n;cin>>n;
	ll ans=0;
	if(n<1){cout<<ans;return;}
	if(n==2){cout<<2;return;}
	ll x=1,y=1,z=1;
	for(int i=0;i<n;i++){
		(x*=10)%=mod;
		(y*=9)%=mod;
		(z*=8)%=mod;
	}
	(y*=2)%=mod;
	ans=(x-y+z+mod)%mod;
	cout<<ans;
}
int32_t main(){
	kehsihba();
	//init();
	ll t=1;
	//cin>>t;
	for(int k=1;k<=t;k++){
		//cout<<"Case "<<k<<": ";
		solve();
		//e;
	}
}


Measured memory_bytes: 3624
main :: IO ()                                                                                                                          
main = do                                                                                                                              
  n <- getLine                                                                                                                         
  let f = replicate (length n) [('7':),('5':),('3':)]                                                                                  
  print $ length . filter (<=(read n :: Int)) . map read . filter (\x -> all (flip elem x) "357") . concat . scanr (<*>) [[]] $ f

Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define tl 1'000'000'007
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REREP(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
#define REFOR(i, n, a) for (ll i = n; i >= a; i--)
//kが奇数ならa,b,cはkで割り切れる
//　　偶数ならa,b,cはk/2で割り切れる
// priority que
//bit全探索
// mod_gcd

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false); 
    ll n,k;
    cin >> n >> k;
    ll cnt1= 0;
    ll cnt2= 0;
    if(k&1){ //奇数
        FOR(i,1,n+1){
            if(i%k==0) cnt1++;
        }
    } else{ //偶数
        FOR(i,1,n+1){
            cnt1 += (i%k == 0);
            cnt2 += (i%k == k/2);
        } 
    }
    cout << ll(powl(cnt1,3)+powl(cnt2,3)) << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;

using namespace std;


int main()
{
   string s;
   cin>>s;

    vector<int> cnt(2019,0);

    ll sum = 0, p =1;
    for(int i=s.size() - 1; i>=0; i--) {
        sum = ((s[i]-'0') * p + sum) % 2019;
        p = ( p*10 ) % 2019;
        cnt[sum]++;
    }

    ll ans = cnt[0];
    for(int i=0; i<2019; i++) {
        ans+= cnt[i] * (cnt[i]-1)  /2;

    }

    cout<<ans<<endl;


}


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

typedef long long ll;

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

//--------------------
#define MAX_N 200000

vector<int> V;
int a[MAX_N];

int main() {

  int n, k;
  cin >> n >> k;
  rep(i, n) cin >> a[i];
  sort(a, a+n);

  int num = a[0];
  int cnt = 1;
  for(int i=1; i<n; ++i) {
    if(num==a[i]) {
      ++cnt;
    }else {
      V.push_back(cnt);
      cnt = 1;
      num = a[i];
    }
  }

  V.push_back(cnt);

  if(V.size()<=k) {
    cout << 0 << endl;
  }else {
    ll res = 0;
    sort(V.begin(), V.end());
    for(int i=0; i<V.size()-k; ++i) {
      res += V[i];
    }
    cout << res << endl;
  }

  return 0;
}


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

#define ll long long

using namespace std;

int n,k;

int main()

{

    int b[3];

    scanf("%d%d%d",&b[0],&b[1],&b[2]);

    sort(b,b+3);

    printf("%d\n",b[0]+b[1]);

    return 0;

}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {	
	private static void solve(){
		//Implement solution here.
		int n = ni();
		List<Robot> rl = new ArrayList<Main.Robot>();
		for(int i = 0; i < n; i++) {
			long x = nl();
			long l = nl();
			rl.add(new Robot(x - l, x + l));
		}
		Comparator<Robot> comparator = Comparator.comparing(Robot::getRight);
		rl.sort(comparator);
		//rl.stream().forEach(v -> System.out.println(v.getLeft() + " " + v.getRight()));
		long maxRight = Long.MIN_VALUE;
		int result = 0;
		for(int i = 0; i < n; i++) {
			Robot a = rl.get(i);
			if(a.getLeft() >= maxRight) {
				result++;
				maxRight = a.getRight();
			}
		}
		System.out.println(result);
	}

	static class Robot{
		private long left;
		private long right;
		public Robot(long left, long right) {
			this.left = left;
			this.right = right;
		}
		public long getLeft() {
			return this.left;
		}
		public long getRight() {
			return this.right;
		}
	}
	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


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

int main (void) {
	char s[16];
	int tama=0;

	memset (&s[0], 0, sizeof (s));
//	scanf ("%s%s%s", &s[0], &s[1], &s[2]);
	scanf ("%s", &s[0]);

	for (int ii=0; ii < 3; ii++) {
		if (s[ii] == '1') {
			tama++;
		}
	}

	printf ("%d", tama);

	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <string>
#include <iostream>

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

using namespace std;

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

    string S = "";
    cin >> S;
    if(S.length() == 3){
        reverse(S.rbegin(),S.rend());
        cout << S;

    }
    else cout << S <<endl;
    return 0;

}

Measured memory_bytes: 256