akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import sys


def main():
    N_str = sys.stdin.readline().rstrip()

    sum_digit = 0

    for s in N_str:
        sum_digit += int(s)
    
    if (sum_digit % 9 == 0):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 9328
import java.util.Scanner;

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

                int a= sc.nextInt();
                char op=sc.next().charAt(0);
                int b= sc.nextInt();
                if(op !='?'){
                    if(op=='+'){
                    System.out.println(a+b);
                }else if(op=='-'){
                    System.out.println(a-b);
                }else if(op=='*'){
                    System.out.println(a*b);
                }else if(op=='/'){
                    System.out.println(a/b);
                }
            
                }
                else{
                break;    
                }   
            }    
        }
    }


Measured memory_bytes: 26200
// AOJ 1333 Beautiful Spacing
// 2018.4.5 bal4u

#include <stdio.h>
#include <string.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

int  w, n;
int  s[50002];
char dp[50002];

int check(int x)
{
	int i, lim, f, cnt;

	lim = f = n, cnt = 0;
	memset(dp, 0, n);
	i = n; while (i--) {
		while (w-(s[lim]-s[i]) < lim-i-1) cnt -= dp[lim--];
		while (f > lim || f > i+1 && (w-(s[f]-s[i])+f-i-2) / (f-i-1) <= x)
			cnt += dp[f--];
		dp[i] = cnt > 0 || lim == n;
	}
	return dp[0];
}

int main()
{
	int i, lo, mi, hi;

	while (w = in()) {
		n = in();
		for (i = 1; i <= n; i++) s[i] = s[i-1] + in();
		lo = 0, hi = w;
		while (lo + 1 < hi) {
			mi = (lo + hi) >> 1;
			if (check(mi)) hi = mi; else lo = mi;
		}
		printf("%d\n", hi);
	}
	return 0;
}


Measured memory_bytes: 2024
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int d; string s;
int p[11] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 };
int main() {
	while (cin >> d >> s, d) {
		long long v = 0;
		for (int i = 0; i < s.size(); i++) v = v * d + (s[i] <= '9' ? s[i] - 48 : s[i] - 55);
		long long ret = 9191919191919191919;
		for (int i = 0; i < 11 && p[i] <= d; i++) {
			int e = 0, f = d;
			while (f % p[i] == 0) f /= p[i], e++;
			if (e) {
				long long w = v, x = 0;
				while (w) w /= p[i], x += w;
				ret = min(ret, x / e);
			}
		}
		cout << ret << endl;
	}
}

Measured memory_bytes: 3136
var
 s:string;
 i,k:longint;
 j:char;
 a:array['a'..'z'] of longint; 
begin
 readln(s);
 for i:=1 to length(s) do
  if s[i] in ['a'..'z'] then inc(a[s[i]]);
 for j:='a' to 'z' do
  if a[j]=0 then begin writeln(j); halt; end;
 writeln('None');
end.

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define sz(x) (int)(x.size())
using namespace std;

const int N = 1e5 + 5;
const int inf = 1e12;
const int mod = 1e9 + 7;


int32_t main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

	int n, mod2 = 0, mod4 = 0;
	cin >> n;
	for(int i = 0; i < n; i++){
		int v;
		cin >> v;
		mod2 += v % 2 == 0 && v % 4 != 0;
		mod4 += v % 4 == 0;
	}

	int want = 0;
	if(mod4 < n/2)
		want = n - 2*mod4;

	bool ok = false;
	ok |= mod4 >= n/2;
	ok |= mod2 >= want;
	cout << (ok ? "Yes" : "No") << '\n';

}

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

void read(int &x) {
    x=0;int f=1;char ch=getchar();
    for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-f;
    for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';x*=f;
}

void print(int x) {
    if(x<0) putchar('-'),x=-x;
    if(!x) return ;print(x/10),putchar(x%10+48);
}
void write(int x) {if(!x) putchar('0');else print(x);putchar('\n');}

#define lf double
#define ll long long 

#define pii pair<int,int >
#define vec vector<int >

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

#define FOR(i,l,r) for(int i=l,i##_r=r;i<=i##_r;i++)

const int maxn = 1e6+10;
const int inf = 1e9;
const lf eps = 1e-8;
const int mod = 998244353;

char s[maxn];
int vis[maxn],f[maxn],n,t[maxn],cnt[maxn];

int calc(int x) {
    int ans=0;
    for(int i=1;i<=x;i++) ans=((ans<<1)|s[i])%mod,t[i]=s[i];
    for(int i=x+1;i<=n;i++) t[i]=t[i-x]^1;
    for(int i=1;i<=n;i++) {
        if(s[i]>t[i]) return ans+1;
        if(s[i]<t[i]) return ans;
    }return ans+1;
}

int main() {
    read(n);scanf("%s",s+1);
    for(int i=1;i<=n;i++) s[i]-='0';
    for(int i=1;i<=n;i++) if(n%i==0&&((n/i)&1)) vis[n/i]=1,f[n/i]=calc(i);
    //,printf("%d %d\n",i,f[n/i]);puts("OK");
    int ans=0;
    for(int i=n;i;i--) {
        if(!vis[i]) continue;
        for(int j=i<<1;j<=n;j+=i) if(vis[j]) f[i]=(f[i]-f[j]+mod)%mod;
        // printf("%d %d\n",i,f[i]);
        ans=(ans+1ll*n/i*2*f[i]%mod)%mod;
    }write(ans);
    return 0;
}


Measured memory_bytes: 14592
#include <bits/stdc++.h>
using namespace std;
 
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
 
int main() {
	FASTIO
	int x;
	for(int i=0; i<5; i++)
	{
		cin >> x;
		if(x == 0) 
		{
			cout << i+1;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3588
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long a = sc.nextLong();
        long b = sc.nextLong();
        long ans = (b-a)*(n-2)+1;
        if(a > b || ans < 0){
            System.out.println(0);
            return;
        }
        if(n > 1){
            System.out.println(ans);
        }
        else{
            if(a != b){
                System.out.println(0);
            }
            else{
                System.out.println(1);
            }
        }
    }
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    unordered_map<ll, ll> mp;
    for (ll i = 0; i < N; i++) {
        ll a;
        cin >> a;
        ++mp[a - 1];
        ++mp[a];
        ++mp[a + 1];
    }
    ll ans = 0;
    for (const auto& p : mp) {
        ans = max(ans, p.second);
    }
    cout << ans << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 4260
#include <bits/stdc++.h>
using namespace std;
#define int long long int
vector <int> wt;
vector <int> val;
int n,w;
vector <vector <int> > dp;
int func(int cwt,int index)
{
    if(cwt > w) return INT_MIN;
    if(index == n)
        return 0;
    if(dp[cwt][index] != -1) return dp[cwt][index];
    int result = 0;
    if(cwt+wt[index] <= w)
    {
        result = max(func(cwt+wt[index],index+1)+val[index],func(cwt,index+1));
    }
    else
    {
        result = func(cwt,index+1);
    }
    return dp[cwt][index] = result;
}
signed main()
{
    cin>>n>>w;
    wt.clear();
    val.clear();
    wt.resize(n);
    val.resize(n);
    dp.clear();
    dp.resize(w+1,vector <int> (n+1,-1));
    for(int i=0;i<n;i++)
    {
        cin>>wt[i]>>val[i];
    }
    cout<<func(0,0);
    return 0;
}

Measured memory_bytes: 82304
a, b = [int(i) for i in input().split()]

# 雪に埋もれていない部分の高さがbの塔の高さは(1+2+...+ b-a)
# 1+2+...+X = X(X+1)/2 より、解は (b-a)(b-a+1)/2 - b
print((b-a)*(b-a+1)//2 - b)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N;
    cin >> N;
    vector<long long> a(N);
    long long sum = 0;
    for(int i = 0; i < N; i++) {
        cin >> a[i];
        a[i] -= i + 1;
        sum += a[i];
    }
    sort(a.begin(), a.end());
    long long res;
    if(N % 2 == 1) res = a[N / 2];
    else res = (a[N / 2] + a[N / 2 - 1]) / 2;
    long long ans = 0;
    for(int i = 0; i < N; i++) ans += abs(a[i] - res);
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
# define N 150
using namespace std;
typedef long long LL;
char s[N];
int ans[N];
int main(){
  scanf ("%s", s + 1);
  int len = strlen(s + 1);
   for (int i = 1; i <= len; ++i)
      ans[s[i] - 'a' + 1] ++;
   for (int i = 1; i <= 26; ++i)
      if (ans[i] % 2 == 1){
         printf("No\n");
          return 0;
       }
   printf("Yes\n");
   return 0;
}


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

int main ()
{
	string s;  cin>>s;
	
    if(s=="SUN") cout<<"7"<<endl;
    if(s=="MON") cout<<"6"<<endl;
    if(s=="TUE") cout<<"5"<<endl;
    if(s=="WED") cout<<"4"<<endl;
    if(s=="THU") cout<<"3"<<endl;
    if(s=="FRI") cout<<"2"<<endl;
    if(s=="SAT") cout<<"1"<<endl;
	

  return 0;
}



Measured memory_bytes: 3596
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));
const int mod = 1e9+7;
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};


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

    int a,b;
    cin >> a >> b;
    cout << a * b << endl;

    cout << endl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 25, M = 1e6 + 25, oo = 1e9+7, mxmsk = 1 << 16;
const long long OO = 1e18+25;
    
#define f first
#define s second

int n, m, u, v,x,cnt, vis[N];
vector <int> g[N];

void visit_it(int node)
{
    if(vis[node]) return;
    vis[node] = 1;
    for(int to : g[node])
    {
        visit_it(to);
    }
}

int main() {
    scanf("%d%d",&n,&m);
    while(m--)
    {
        scanf("%d%d%d",&u,&v,&x);
        g[u].push_back(v);
        g[v].push_back(u);
    }
    for(int i=1; i<=n ;i++)
    {
        if(vis[i]) continue;
        cnt++;
        visit_it(i);
    }
    printf("%d",cnt);
    return 0;
}

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

int K,S;

int main()
{
        cin >> K >> S;
        int ans = 0;

        for(int x=0;x<=K;++x){
                for(int y=0;y<=K;++y){
                        if(0<=S-x-y&&S-x-y<=K){
                                ans+=1;
                        }
                }
        }
        cout << ans;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<algorithm>
#include<string.h>
using namespace std;
int main() {
	int n,m;
	cin >> n >> m;
	if (m > 4 * n||m%2||m<2*n)cout << "No";
	else {
		int x = (4 * n - m) / 2;
		if (2 * x + 4 * (n - x) == m)cout << "Yes";
		else cout << "No";
	}
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define vl          vector<ll>
#define vi          vector<int>
#define pi          pair<int,int>
#define pl          pair<ll,ll>
#define all(a)      a.begin(),a.end()
#define mem(a,x)    memset(a,x,sizeof(a))
#define pb          push_back
#define mp          make_pair
#define F           first
#define S           second
#define endl 		"\n"
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define fast_io     std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define trace(...) ZZ(#__VA_ARGS__, __VA_ARGS__);
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1) {std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " : " << arg1;
	ZZ(comma, args...);
}

void solve() {
	int a, b;
	cin >> a >> b;
	cout << a*b;

}
int main() {
	fast_io;
	int t = 1;
	// cin>>t;
	while (t--) {
		solve();
	}
	// cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}

Measured memory_bytes: 3644
N = input()
def moji_list(*args):
    moji = []
    for i in range(len(args)):
        moji.extend([chr(j) for j in range(args[i][0], args[i][1])])
    return moji

I=moji_list((97, 123))
T = I.index(N) + 1
print(I[T])

Measured memory_bytes: 2940
N,x=map(int,input().split())
a=list(map(int,input().split()))

ans=0
for i in range(N-1):
    if(a[i]+a[i+1]>x):
        s=(a[i]+a[i+1]-x)
        a[i+1]=max(a[i+1]-s,0)
        ans+=s
print(ans)

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

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

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

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

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

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

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

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

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

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

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

fn main() {
    input! {
        s: usize,
    }
    let mut s = s;
    let mut result = 753;
    while s >= 100 {
        let d = (s % 1000) as i64;
        let diff = (d - 753).abs();
        if diff < result {
            result = diff;
        }
        s /= 10;
    }
    println!("{}", result);
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


ll dp[4][3010][3010];
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll r,c,k;
  cin>>r>>c>>k;

  vvll field(r, vll(c));
  REP(i,k){
    ll x,y,v;
    cin>>y>>x>>v;
    y--;
    x--;
    field[y][x]=v;
  }

  REP(i,4)REP(j,r)REP(k,c)dp[i][j][k]=0;

  dp[1][0][0]=field[0][0];
  REP(y,r){
    REP(x,c){
      if(x!=c-1){
        dp[1][y][x+1]=max(max(dp[1][y][x+1],dp[1][y][x]), dp[0][y][x]+field[y][x+1]);
        dp[2][y][x+1]=max(max(dp[2][y][x+1],dp[2][y][x]), dp[1][y][x]+field[y][x+1]);
        dp[3][y][x+1]=max(max(dp[3][y][x+1],dp[3][y][x]), dp[2][y][x]+field[y][x+1]);
      }
      ll dd=0;
      dd=max(dd,dp[0][y][x]);
      dd=max(dd,dp[1][y][x]);
      dd=max(dd,dp[2][y][x]);
      dd=max(dd,dp[3][y][x]);
      if(y!=r-1){
        dp[0][y+1][x]=max(dp[0][y+1][x],dd);
        dp[1][y+1][x]=max(dp[0][y+1][x],dd)+field[y+1][x];
      }
    }
  }

  ll ans=0;
  ans=max(ans,dp[0][r-1][c-1]);
  ans=max(ans,dp[1][r-1][c-1]);
  ans=max(ans,dp[2][r-1][c-1]);
  ans=max(ans,dp[3][r-1][c-1]);
  cout<<ans<<endl;

//  REP(y,r){
//    REP(x,c)cout<<dp[0][y][x]<<" ";
//    cout<<endl;
//  }
//    cout<<endl;
//  REP(y,r){
//    REP(x,c)cout<<dp[1][y][x]<<" ";
//    cout<<endl;
//  }
//    cout<<endl;
//  REP(y,r){
//    REP(x,c)cout<<dp[2][y][x]<<" ";
//    cout<<endl;
//  }
//    cout<<endl;
//  REP(y,r){
//    REP(x,c)cout<<dp[3][y][x]<<" ";
//    cout<<endl;
//  }




}



Measured memory_bytes: 355572
#include<stdio.h>
#include<string.h>
int main(void)
{
	int n;
	int i,j,temp,len;
	int sum[11],jun;
	int ba;
	char str[101];
	
	scanf("%d",&n);
	while(n!=0){
		for(i=0;i<n;i++){
			sum[i]=0;
		}
		jun=0;
		ba=0;
		scanf("%s",str);
		len=strlen(str);
		for(i=0;i<len;i++){
			if(str[i]=='M'){
				sum[jun]++;
				jun++;
				if(jun==n){
					jun=0;
				}
			}
			else if(str[i]=='S'){
				ba=ba+sum[jun]+1;
				sum[jun]=0;
				jun++;
				if(jun==n){
					jun=0;
				}
			}
			else if(str[i]=='L'){
				sum[jun]=sum[jun]+ba+1;
				ba=0;
				jun++;
				if(jun==n){
					jun=0;
				}
			}
		}
		for(i=0;i<n-1;i++){
			for(j=i+1;j<n;j++){
				if(sum[i]>sum[j]){
					temp=sum[i];
					sum[i]=sum[j];
					sum[j]=temp;
				}
			}
		}
		for(i=0;i<n;i++){
			printf("%d ",sum[i]);
		}
		printf("%d\n",ba);
		scanf("%d",&n);
	}
	return 0;
}

Measured memory_bytes: 604
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 1000000007
#define testcases() int t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
 //----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
	int n;
	cin>>n;
	cin.ignore();
	string str;
	cin>>str;
	if(n>=3200)
		cout<<str;
	else
		cout<<"red";
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  string color;
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> color;
    if (color == "Y") {
      sum++;
    }
  }
  if (sum == 0) {
    cout << "Three" << endl;
  }
  else {
    cout << "Four" << endl;
  }  
}


Measured memory_bytes: 3556
#include<stdio.h>

int main()
{
	int c1,c5,c10,c50,c100,c500;
	scanf("%d %d %d %d %d %d",&c1,&c5,&c10,&c50,&c100,&c500);

	c1   *= 1;
	c5   *= 5;
	c10  *= 10;
	c50  *= 50;
	c100 *= 100;
	c500 *= 500;

	if( ( c1 + c5 + c10 + c50 + c100 + c500 ) >= 1000 )
		printf("1\n");
	else
		printf("0\n");
	return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換
int keta(ll n){int ans=0;while(n>0){n /= 10; ans++;}return ans;}
ll _pow(ll a,ll b){ll ans = 1;rep(i,b){ ans *= a;}return ans;}

int main() {
int n,m;cin>>n>>m;
ll a[n],b[n],c[m],d[m];
rep(i,n){
    cin>>a[i]>>b[i];
}
rep(i,m){
    cin>>c[i]>>d[i];
}
rep(i,n){
    int ans = 0;
    int M = INF;
    rep(j,m){
        int D = abs(a[i]-c[j])+abs(b[i]-d[j]);
        if(D<M){
            ans = j+1;
            M=D;
        }
    }
    cout<<ans<<endl;
}

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int n;
int nxt[200010];
vector<int> cyc;
bool oc[200010];
bool v[200010];
vector<int> edge[200010];

int col[200010];

void DFS(int x){
	vector<int> v;
	for(int y:edge[x]){
		if(oc[y]) continue;
		DFS(y);
		v.pb(col[y]);
	}
	sort(all(v));
	int i;
	for(i=0;;++i){
		if(int(v.size()) == i) break;
		if(i != v[i]) break;
	}
	col[x]=i;
}
const char* Q = "IMPOSSIBLE";
int cand[200010][2];
int main()
{
	read(n);
	for(int i=1; i<=n; ++i){
		int p; read(p);
		nxt[i]=p;
		edge[p].pb(i);
	}
	stack<int> s;
	int i=1;
	while(true){
		if(v[i]){
			while(true){
				cyc.pb(s.top());
				if(s.top() == i) break;
				s.pop();
			}
			break;
		}
		v[i]=1;
		s.push(i);
		i = nxt[i];
	}
	for(int x:cyc) oc[x]=1;
	int cn = cyc.size();
	for(int i=0; i<cn; ++i){
		int x=cyc[i];
		vector<int> v;
		for(int y:edge[x]) if(!oc[y]){
			DFS(y);
			v.pb(col[y]);
		}
		sort(all(v)); v.pb(-1); v.pb(-1);
		int fi=0;
		for(int j=0;;++j) if(v[j]!=j){
			cand[i][fi++]=j;
			if(fi == 2) break;
		}
	}
	bool dekiru = 0;
	for(int si=0; si<2; ++si){
		bool ca=0, cb=0;
		(si?cb:ca) = 1;
		for(int i=0; i<cn; ++i){
			bool na=0, nb=0;
			if(ca){
				if(cand[(i+1)%cn][0] != cand[i][0]) na=1;
				if(cand[(i+1)%cn][1] != cand[i][0]) nb=1;
			}
			if(cb){
				if(cand[(i+1)%cn][0] == cand[i][0]) na=1;
				if(cand[(i+1)%cn][1] == cand[i][0]) nb=1;
			}
			ca=na; cb=nb;
		}
		if(si?cb:ca){
			dekiru=1; break;
		}
	}
	puts(Q + 2*dekiru);
	return 0;
}


Measured memory_bytes: 14752
import qualified Data.IntMap as M
import           Data.List

main :: IO ()
main = do
  getLine
  as <- map read . words <$> getLine
  print $ solve as

solve :: [Int] -> Int
solve = M.foldl' (+) 0
    . fmap (\x -> x * (x - 1) `div` 2)
    . foldl' (\mp x -> M.insertWith (+) x 1 mp) (M.singleton 0 0)
    . scanl' (+) 0

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

long long int N;
long long int a[100007];
long long int pt[100007];

int main(){
    cin >> N;
    for(int i = 1;i < N+1;i++){
        cin >> a[i];
        
        // ポイントを代入
        pt[a[i]] += 1;
        pt[a[i]+1] += 1;
        if(a[i] >= 1){
            pt[a[i]-1] += 1;
        }
    }

    int ans = -1;
    for(int i = 0;i < 100001;i++){
        if(pt[i] > pt[ans]){
            ans = i;
        }
    }

    cout << pt[ans]  << endl;


}

Measured memory_bytes: 1792
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    int N;
    cin >> N;
    map<int, vector<int>> limit2powersMap;
    for (int i = 0; i < N; ++i)
    {
        int power, limit;
        cin >> power >> limit;
        limit2powersMap[limit].push_back(power);
    }
    int powerSum = 0;
    for (const auto &limit2powers : limit2powersMap)
    {
        const int limit = limit2powers.first;
        const auto powers = limit2powers.second;
        powerSum += accumulate(powers.begin(), powers.end(), 0);
        if (powerSum > limit)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 22144
s = gets.chomp.split("")
s = s.unshift(" ")
s.each_with_index do |item,i|
    if i % 2 != 0 && item == "L"
            puts "No"
        exit
    elsif i % 2 == 0 && item == "R"
        puts "No"
        exit
    end
end
puts "Yes"

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

int main(){
    ll  n;
    cin>>n;
    V h(n);
    rep(i,n)cin>>h[i];
    V ans(n,0);
    ans[1]=abs(h[0]-h[1]);
    for(int i=2;i<n;i++){
        ans[i]=min(ans[i-1]+abs(h[i]-h[i-1]), ans[i-2]+abs(h[i]-h[i-2]));
    }
    cout<<ans[n-1]<<endl;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef pair<int, int>pii;
typedef pair<int, pii>pi3;
bool flag[2020][2020];
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int main()
{
	int mx, my;
	scanf("%d%d", &mx, &my);
	queue<pi3>que;
	for (int i = 1; i <= mx; i++)
	{
		for (int j = 1; j <= my; j++)
		{
			char z;
			scanf(" %c", &z);
			if (z == '#')que.push(make_pair(0, make_pair(i, j)));
		}
	}
	int maxi = 0;
	for (;;)
	{
		if (que.empty())break;
		pi3 z = que.front();
		que.pop();
		int x = z.second.first, y = z.second.second;
		if (flag[x][y])continue;
		flag[x][y] = true;
		maxi = max(maxi, z.first);
		for (int i = 0; i < 4; i++)
		{
			int nx = x + dx[i], ny = y + dy[i];
			if (1 <= nx&&nx <= mx && 1 <= ny&&ny <= my)que.push(make_pair(z.first + 1, make_pair(nx, ny)));
		}
	}
	printf("%d\n", maxi);
}

Measured memory_bytes: 49408
#include <cstdio>
using namespace std;
const long long NR=110;
long long n,sum,minx=0x3f3f3f3f,a[NR];
int main()
{
	scanf("%lld",&n);
	for(long long i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	for(long long i=-1000;i<=1000;i++)
	{
		sum=0;
		for(long long j=1;j<=n;j++)
		{
			sum+=(a[j]-i)*(a[j]-i);
		}
		if(sum<minx)
		{
			minx=sum;
		}
	}
	printf("%lld",minx);
	return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  int lenS = sz(s);
  int lenT = sz(t);
  vector<vector<int>> alpha(26);
  rep(i, lenS) {
    int c = s[i] - 'a';
    alpha[c].push_back(i);
  }
  rep(i, lenS) { // 2周目
    int c = s[i] - 'a';
    alpha[c].push_back(i+lenS);
  }
  ll ans = 0;
  int cur = 0;
  for (char c : t) {
    c = c - 'a';
    if (sz(alpha[c]) == 0) {
      puts("-1"); return 0;
    }
    cur = *lower_bound(alpha[c].begin(), alpha[c].end(), cur) + 1;
    if (cur >= lenS) {
      cur -= lenS;
      ans += lenS;
    }
  }
  ans += cur;
  cout << ans << '\n';
  return 0;
}

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

using namespace std;

typedef long long ll;
#define MAX 51
#define INF 1234567890LL

inline bool range(ll l, ll r, ll x) { return l<=x && x<=r; }

int main() {
    int n, k;
    cin >> n >> k;
    ll xs[MAX], ys[MAX];
    ll xl[MAX], yl[MAX];
    for(int i=0; i<n; i++) {
        cin >> xs[i] >> ys[i];
        xl[i] = xs[i];
        yl[i] = ys[i];
    }
    sort(xl, xl+n);
    sort(yl, yl+n);
    
    ll res= INF * INF * 4;
    
    for(int a=0; a<n; a++) for(int b=a+1; b<n; b++)
    for(int c=0; c<n; c++) for(int d=c+1; d<n; d++){
        int ct = 0;
        ll s = (yl[b]-yl[a])*(xl[d]-xl[c]);
        if(s>=res) continue;
        for(int i=0; i<n; i++) {
            if(range(yl[a], yl[b], ys[i]) && range(xl[c], xl[d], xs[i])) ct++;
        }
        if(ct>=k) res = s;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long h,w,now,k,ans=0,cnt=0,tmp;
int main(){
  cin >> h >> w;
  long long a[h][w],x1[h*w],x2[h*w],y1[h*w],y2[h*w];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> a[i][j];
      cnt+=a[i][j]%2;
    }
  }
  if(cnt==0){
    cout << 0 << endl;
    return 0;
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w-1;j++){
      if(a[i][j]%2==1){
        a[i][j]--;
        a[i][j+1]++;
        x1[ans]=i+1;
        y1[ans]=j+1;
        x2[ans]=i+1;
        y2[ans]=j+2;
        ans++;
      }
    }
  }
  for(int i=0;i<h-1;i++){
    if(a[i][w-1]%2==1){
      a[i][w-1]--;
      a[i+1][w-1]++;
      x1[ans]=i+1;
      y1[ans]=w;
      x2[ans]=i+2;
      y2[ans]=w;
      ans++;
    }
  }
  cout << ans << endl;
  for(int i=0;i<ans;i++){
    cout << x1[i] << " " << y1[i] << " " << x2[i] << " " << y2[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 11904
N = int(input())
A =list(map(int, input().split()))
minus = [i for i in A if i < 0]
max_num = [abs(i) for i in A]
if len(minus) % 2 == 0:
  print(sum(max_num))
else:
  print(sum(max_num) - (2*min(max_num)))

Measured memory_bytes: 14332
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) {
            int n = in.nextInt();
            int ans = 0;
            for (int i = 0; i < n; i++) {
                ans++;
                ans += Math.abs(in.nextInt() - in.nextInt());
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

    }
}



Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int[] num = new int[n];
			for (int i = 0; i < n; i++) {
				num[i] = scanner.nextInt();
			}
			int count = 0;
			for (int i = 0; i < n - 1; i++) {
				for (int j = 0; j < n - 1 - i; j++) {
					if (num[j] > num[j + 1]) {
						count++;
						int tmp = num[j];
						num[j] = num[j + 1];
						num[j + 1] = tmp;
					}
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 20860
using CompLib.Util;
using System;

public class Program
{
    char[] N;
    int K;
    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextCharArray();
        Array.Reverse(N);
        K = sc.NextInt();
        int l = N.Length;
        // 9999
        var dp = new long[l + 1, K + 1];
        dp[0, 0] = 1;
        // 
        var dp2 = new long[l + 1, K + 1];
        dp2[0, 0] = 1;
        for (int i = 1; i <= l; i++)
        {
            // dp[i]が0以外
            for (int j = 0; j < K; j++)
            {
                dp[i, j + 1] += dp[i - 1, j] * 9;
            }
            // dp[i] が0
            for (int j = 0; j <= K; j++)
            {
                dp[i, j] += dp[i - 1, j];
            }

            if (N[i - 1] == '0')
            {
                // 0
                for (int j = 0; j <= K; j++)
                {
                    dp2[i, j] += dp2[i - 1, j];
                }
            }
            else
            {
                // dp2[i]が0以外 N[i] 未満
                for (int j = 0; j < K; j++)
                {
                    dp2[i, j + 1] += dp[i - 1, j] * (N[i - 1] - '1');

                    // N[i]
                    dp2[i, j + 1] += dp2[i - 1, j];
                }

                for(int j = 0; j <= K; j++)
                {
                    dp2[i, j] += dp[i - 1, j];
                }
            }
        }

        Console.WriteLine(dp2[l, K]);
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;
    class Scanner
    {
        private int _index;
        private string[] _line;
        const char separator = ' ';

        public Scanner()
        {
            _index = 0;
            _line = new string[0];
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(separator);
                _index = 0;
            }
            return _line[_index++];
        }
        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(separator);
            _index = _line.Length;
            return _line;
        }
        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
    }
}

Measured memory_bytes: 13140
import java.io.{BufferedReader, InputStreamReader}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val s = in.readLine()

    System.out.println(
      s.toCharArray.zip(s.toCharArray.reverse).count {
        case (a,b) => a != b
      } / 2
    )
  }
}


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

int main(){
	int n;
	long long a;
	long long minValue = 1000000;
	long long maxValue = -1000000;
	long long sum = 0;

	cin >> n;

	for(int i=0;i<n;i++){
		cin >> a;
		if(a < minValue) minValue = a;
		if(a > maxValue) maxValue = a;
		sum += a;
	}

	cout << minValue << " " << maxValue << " " << sum << endl;

		return 0;

}

Measured memory_bytes: 3108
import math

EPS = 1e-10

def equals(a, b):
    return abs(a - b) < EPS


class Point:
    def __init__(self, x=0, y=0):
        self.x = x
        self.y = y

    def __add__(self, p):
        return Point(self.x + p.x, self.y + p.y)

    def __sub__(self, p):
        return Point(self.x - p.x, self.y - p.y)

    def __mul__(self, a):
        return Point(self.x * a, self.y * a)

    def __rmul__(self, a):
        return self * a

    def __truediv__(self, a):
        return Point(self.x / a, self.y / a)

    def norm(self):
        return self.x * self.x + self.y * self.y

    def abs(self):
        return math.sqrt(self.norm())

    def __lt__(self, p):
        if self.x != p.x:
            return self. x < p.x
        else:
            return self.y < p.y

    def __eq__(self, p):
        return equals(self.x, p.x) and equals(self.y, p.y)


class Segment:
    def __init__(self, p1, p2):
        self.p1 = p1
        self.p2 = p2


def dot(a, b):
    return a.x * b.x + a.y * b.y


def cross(a, b):
    return a.x * b.y - a.y * b.x


def ccw(p0, p1, p2):
    COUNTER_CLOCKWISE = 1
    CLOCKWISE = -1
    ONLINE_BACK = 2
    ONLINE_FRONT = -2
    ON_SEGMENT = 0
    a = p1 - p0
    b = p2 - p0
    if cross(a, b) > EPS:
        return COUNTER_CLOCKWISE
    if cross(a, b) < -EPS:
        return CLOCKWISE
    if dot(a, b) < -EPS:
        return ONLINE_BACK
    if a.norm() < b.norm():
        return ONLINE_FRONT
    return ON_SEGMENT


def intersect(s1, s2):
    p1 = s1.p1
    p2 = s1.p2
    p3 = s2.p1
    p4 = s2.p2
    return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 and
            ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0)


if __name__ == '__main__':
    q = int(input())
    ans = []
    for i in range(q):
        x0, y0, x1, y1, x2, y2, x3, y3 = [int(v) for v in input().split()]
        s1 = Segment(Point(x0, y0), Point(x1, y1))
        s2 = Segment(Point(x2, y2), Point(x3, y3))
        ans.append(intersect(s1, s2))

    for v in ans:
        print(int(v))


Measured memory_bytes: 5828
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define rep(i,n) for(int i=0;i<n;i++)
#define mod 1000000007 // 10^9+7
#define INF 99999999999 //10^12-1
#define P pair<int,int>
#define prique priority_queue
int n,m;
signed main(){
    cin>>n>>m;
    int ans=min(n,m/2);
    m=max((int)(0),m-2*n);
    n=0;
    ans+=m/4;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
#define rep(i,n) for (int i = 0; i< (n); i++)
using namespace std;
 
int main() {
  int N;
  cin >> N;
 
  if(N%2==0) cout<<N/2<<endl;
 
  else cout<<(N/2) +1<<endl;
  
  return 0;
}

Measured memory_bytes: 256
N, A, B, C = map(int, input().split())
l = [int(input()) for i in range(N)]
INF=10**9

def dfs(cur, a, b, c):
    if cur == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) > 0 else INF
    ret0 = dfs(cur + 1, a, b, c)
    ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
    ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
    ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
    return min(ret0, ret1, ret2, ret3)

print(dfs(0, 0, 0, 0))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb(x) push_back(x)
#define all(x) x.begin(), x.end()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;

struct coins{ll A, B, C;};

bool comp(const coins &p, const coins &q){
    return p.A-p.B < q.A-q.B;
}

int main(){
    int X, Y, Z;
    cin >> X >> Y >> Z;
    int N = X+Y+Z;
    coins S[N];
    rep(i, N){
        cin >> S[i].A >> S[i].B >> S[i].C;
    }
    sort(S, S+N, comp);
    //Bを[0,i)から取る場合
    ll lb[N+1], lc[N+1];
    priority_queue<pii, vector<pii>, greater<pii> > que1, que2;
    //BをB-Cが大きいものから順にY個取る
    lb[0] = 0, lc[0] = 0;
    rep(i, N){
        que1.push(pii(S[i].B - S[i].C, i));
        lb[i+1] = lb[i] + S[i].B;
        lc[i+1] = lc[i];
        if(i >= Y){
            int j = que1.top().second;
            que1.pop();
            lb[i+1] -= S[j].B;
            lc[i+1] += S[j].C;
        }
    }
    //Aを[i,N)から取る場合
    ll ra[N+1], rc[N+1];
    //AをA-Cが大きいものから順にX個取る
    ra[N] = 0, rc[N] = 0;
    rep3(i, N-1, 0){
        que2.push(pii(S[i].A - S[i].C, i));
        ra[i] = ra[i+1] + S[i].A;
        rc[i] = rc[i+1];
        if(i < N-X){
            int j = que2.top().second;
            que2.pop();
            ra[i] -= S[j].A;
            rc[i] += S[j].C;
        }
    }
    ll ans = 0;
    rep2(i, Y, Y+Z){
        ans = max(ans, lb[i]+lc[i]+ra[i]+rc[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
const int inf = 1 << 30;
const ll linf = 1e18;
const ll mod = 1e9 + 7;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}

int N, K;
ll sum = 0;

ll modpow(ll x, int y){
    if(y == 0) return 1;
    ll e = modpow(x, y / 2);
    e = e * e % mod;
    return e * (y % 2 == 0 ? 1 : x) % mod;
}

ll cnt[100010];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> K;
    for(int i = 1; i <= K; i++){
        ll c = K / i;
        cnt[i] = modpow(c, N);
    }
    for(int i = K; i >= 1; i--){
        for(int j = i + i; j <= K; j += i){
            cnt[i] -= cnt[j];
            if(cnt[i] < 0) cnt[i] += mod;
        }
        sum += cnt[i] * i;
        sum %= mod;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4420
n=int(input())
cost=list(map(int,input().split()))
 
ashiba=[0]*n
ashiba[1]=abs(cost[1]-cost[0])
#print(ashiba)
i=2
result=0
while i<n:
  ashiba[i]=min(abs(cost[i]-cost[i-1])+ashiba[i-1],abs(cost[i]-cost[i-2])+ashiba[i-2])
  #print(i,ashiba)
  i=i+1
  
print(ashiba[n-1])


Measured memory_bytes: 13928
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

LL dist(pl p1, pl p2) {
	return abs(p1.X-p2.X) + abs(p1.Y-p2.Y);
}

void solve() {
	int n;
	in(n);
	LL x, y;
	vector<pl> v;
	if(n == 1) finish(0);
	
	LL m1 = INT_MIN, m2 = INT_MIN, m4 = INT_MIN, m3 = INT_MIN;
	pl p1, p2, p3, p4;
	for(int i=0;i<n;i++) {
		inl2(x, y);
		v.PB(MP(x, y));
	}
	for(int i=0;i<n;i++) {
		if(m1 < v[i].X+v[i].Y) {
			m1 = v[i].X + v[i].Y;
			p1 = v[i];
		}
		if(m2 < -1*v[i].X + v[i].Y) {
			p2 = v[i];
			m2 = -1*v[i].X + v[i].Y;
		}
		if(m3 < v[i].X - v[i].Y) {
			p3 = v[i];
			m3 = v[i].X - v[i].Y;
		}
		if(m4 < -1*v[i].X - v[i].Y) {
			p4 = v[i];
			m4 = -1*v[i].X - v[i].Y;
		}
	}
	
	LL ans = INT_MIN;
	for(int i=0;i<n;i++) {
		ans = max(ans, dist(p1, v[i]));
		ans = max(ans, dist(p2, v[i]));
		ans = max(ans, dist(p3, v[i]));
		ans = max(ans, dist(p4, v[i]));
	}
	cout<<ans<<en;
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 7456
n,m = map(int,input().split())
a = []
b = []
for i in range(n):
	ii = list(map(int,input().split()))
	a.append(ii)
for k in range(m):
	kk = int(input())
	b.append(kk)
for s in range(n):
	ans = 0
	for ss in range(m):
		ans += a[s][ss]*b[ss]
	print(ans)


Measured memory_bytes: 6012
class Node
  # property parent : Int32
  # property s : Int32
  attr_accessor :parent, :s # Ruby
    
  def initialize(n)
    @parent = n
    @s = 0
  end
end

class UnionFindTree
  
  # property nodes : Array(Node) # Crystal
  attr_accessor :nodes        # Ruby

  def initialize(n)
    @nodes = (0..n).to_a.map{ |i| Node.new(i) }
  end

  def root(x)
    return x if x == nodes[x].parent
    nodes[x].parent = root(nodes[x].parent)
  end
  
  def unite(a, b)
    a = root(a)
    b = root(b)
    return false if a == b
    a, b = b, a if nodes[a].s < nodes[b].s
    nodes[b].parent = a
    # nodes[a].s += 1 if nodes[a].s == nodes[b].s # by rank
    nodes[a].s += nodes[b].s                    # by size
    true
  end
  
  def unite_by_size(a, b)
    a = root(a)
    b = root(b)
    return false if a == b
    a, b = b, a if nodes[a].s < nodes[b].s
    nodes[b].parent = a
    nodes[a].s += nodes[b].s
    true
  end
  
  def unite_by_rank(a, b)
    a = root(a)
    b = root(b)
    return false if a == b
    a, b = b, a if nodes[a].s < nodes[b].s
    nodes[b].parent = a
    nodes[a].s += 1 if nodes[a].s == nodes[b].s
  end

  def same?(a, b)
    root(a) == root(b)
  end

  def size(node)
    nodes[root(node)]
  end
end

n, m = gets.to_s.chomp.split.map{|i| i.to_i}
perm = gets.to_s.chomp.split.map{|i| i.to_i - 1 }
xys  = Array.new(m){ gets.to_s.chomp.split.map{|i| i.to_i - 1 } }

uf = UnionFindTree.new(n)
xys.each{|x,y| uf.unite(x,y) }
ans = (0...n).count{ |i| uf.same?(i, perm[i]) }

puts ans

Measured memory_bytes: 17732
s = gets.chomp
a = Array.new(s.size + 1, 0)

n = s.size + 1
n.times do |i|
  if i != 0 && s[i - 1] == "<"
    a[i] = a[i - 1] + 1
  end
end
(n - 1).downto(0) do |i|
  if i != n - 1 && s[i] == ">"
    a[i] = [a[i + 1] + 1, a[i]].max
  end
end
p a.inject(&:+)


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

int main(void){
  int N;
  cin >> N;
  vector<double> vec(N);
  double kati=0;
  for(int i=0;i<N;i++){
    cin >> vec[i];
  }
  sort(vec.begin(), vec.end());
  for(int i=0;i<N-1;i++){
    vec[i+1]=(vec[i]+vec[i+1])/2;
  }
  cout << vec[N-1] << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int c1=0,c2=0,c3=0,c0=0;
int n;
string s;
cin>>n;
for(int i=0;i<n;i++){
	cin>>s;
	if(s=="AC")c0++;
	else if(s=="WA")c1++;
	else if(s=="TLE")c2++;
	else c3++;
}
cout<<"AC x "<<c0<<endl;
cout<<"WA x "<<c1<<endl;
cout<<"TLE x "<<c2<<endl;
cout<<"RE x "<<c3<<endl;
}

Measured memory_bytes: 3240
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<long double,long double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const long double eps=1e-10;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n;
vl a;

vl f(){
	vl b(n+1);
	ll res=0;
	stack<pair<pdd,int>> st;
	st.push({{INF,INF},0});
	for(int i=1;i<=n;i++){
		ll tmp=a[n-i];
		if(tmp<0){
			res++;
			tmp*=-2;
		}
		long double x=log2(tmp),y=x;
		int num=1;
		while(1){
			pair<pdd,int> p=st.top();
			pdd q=p.first;
			if(y>q.first+eps){
				st.pop();
				long double L=q.first,R=q.second;
				ll tmp=(ll)(y-L+2-eps)/2;
				res+=tmp*p.second*2;
				y=R+2*tmp;
				num+=p.second;
			}
			else break;
		}
		st.push({{x,y},num});
		b[i]=res;
	}
	return b;
}

int main(){
	cin>>n;
	a=vl(n);
	for(auto &i:a) cin>>i;
	vl R=f();
	reverse(a.begin(),a.end());
	for(int i=0;i<n;i++) a[i]*=-1;
	vl L=f();
	ll res=INF;
	for(int i=0;i<=n;i++) res=min(res,R[i]+L[n-i]);
	cout<<res<<endl;
}

Measured memory_bytes: 14736
//P3B
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll s;
	cin >> s;
	ll a = 0,b = s;
	while(s){
		a += s%10;
//		cout << s;
		s/=10;
	}
//	cout << s%a;
	if(b%a == 0)cout << "Yes";
	else cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S; string T;
  cin>>S>>T;
  int L=S.size(); int R=T.size();
  if(S.size()==T.size()){
  for(int i=0; i<L; i++){
    cout<<S.at(i)<<T.at(i);
  }
  }
  else{
    for(int i=0; i<R; i++){
      cout<<S.at(i)<<T.at(i);
    }
    cout<<S.at(S.size()-1);
  }
}


Measured memory_bytes: 3576