akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>


using namespace std;



int main() {
    int n;
    cin >> n;
    vector<pair<int,int>> points(n);
    vector<int> perm(n);
    for (int i = 0; i < n; i++) {
        int x, y; cin >> x >> y;
        points[i] = {x, y};
        perm[i] = i;
    }
    int fact = 1;
    for (int i = 1; i <= n; i++) {
        fact *= i;
    }
    vector<double> all;
    for (int i = 0; i < fact; i++) {
        double l = 0;
        for (int j = 0; j < n - 1; j++) {
            auto p1 = points[perm[j]];
            auto p2 = points[perm[j + 1]];
            l += sqrt((p1.first - p2.first) * (p1.first - p2.first) + (p1.second - p2.second) * (p1.second - p2.second));
        }
        all.push_back(l);
        next_permutation(perm.begin(), perm.end());
    }
    double avg = 0;
    for (int i = 0; i < fact; i++) {
        avg += all[i];
    }
    avg /= fact;
    cout << fixed <<  setprecision(7)  << avg;
}

Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,g;
    cin>>a>>b;
    g=__gcd(a,b);
    long long ans=0;
    if(g%2==0)
    {
        ans++;
        while(g%2==0)
            g/=2;
    }
    for(long long i=3;i*i<=g;i+=2)
        if(g%i==0)
    {
        ans++;
        while(g%i==0)
            g/=i;
    }
    if(g>2)
        ans++;
    cout<<++ans<<endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <queue>
#include <string.h>

using namespace std;

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

int main() {

	for (;;) {
		int n, k, c[112345], a = 0;
		scanf("%d %d", &n, &k);
		if (!(n + k)) break;
		rep(i, k) scanf("%d", &c[i]);
		sort(c, c + k);
		if (c[0]) {
			int prev = -114514;
			int t = 1;
			rep(i, k) {
				if (c[i] == prev + 1) t++;
				else t = 1;
				prev = c[i];
				a = max(a, t);
			}
		}
		else {
			int prev = -114514;
			int t = 1;
			bool zero = false;
			rep(i, k) {
				if (c[i] == prev + 1) {
					t++;
					prev = c[i];
				}
				else if (!zero) {
					t++;
					zero = true;
					i--;
					prev = c[i] + 1;
				}
				else {
					t = 1;
					zero = false;
					prev = c[i];
				}
				a = max(a, t);
			}
		}
		printf("%d\n", a);
	}

	return 0;
}

Measured memory_bytes: 3060
use std::io::*;
use std::str::FromStr;
 
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
 
use std::collections::VecDeque;
#[allow(non_snake_case, unused_variables)]
fn main() {
    let mut S: VecDeque<char> = read::<String>().chars().collect();
    let T: VecDeque<char> = read::<String>().chars().collect();
    let mut ans = "No";
    for i in 0..S.len() {
        let s = S.pop_back().unwrap();
        S.push_front(s);
        if S==T {
            ans = "Yes";
            break;
        }
    }
    println!("{}", ans);
}



Measured memory_bytes: 4352
#include<stdio.h>
#include<ctype.h>
#include<string.h>

#define limit 1200
#define alpnum 26

int main(void) {
	int alpCount[alpnum] = { 0 };
	char ch;

	while ( scanf("%c", &ch) != EOF ){
		if (isalpha(ch)) {
			for (int j = 0; j < alpnum; j++) {
				if ((ch == 'a' + j) || (ch == 'A' + j) ){
					alpCount[j]++;
					break;
				}
			}
		}
	}


	for (int j = 0; j < alpnum; j++) {
		printf("%c : %d\n", 'a' + j, alpCount[j]);
	}

	return 0;
}



Measured memory_bytes: 2052
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    n = I()
    x = LI()
    ans = 0
    p = round(sum(x)/n)
    for i in range(n):
        ans += ((x[i]-p)**2)
    print(ans)
    return


# Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38384
n = int(input())
c = input()

cnt = 0

W = 0
R = c.count('R')

min_operation = max(W, R)

if min_operation == 0:
    print(0)
    exit()

for i in range(n):
    if c[i] == 'W':
        W += 1
    else:
        R -= 1

    min_operation = min(min_operation, max(W, R))
    if min_operation == 0:
        print(0)
        exit()

print(min_operation)

Measured memory_bytes: 68932
n = int(input())
a = []
b = []
for i in range(n):
    A,B = map(int,input().split())
    a.append(A)
    b.append(B)
a.sort()
b.sort()

if n%2==1:
    ans = b[n//2]-a[n//2]+1
else:
    x1 = a[n//2]+a[n//2-1]
    x2 = b[n//2]+b[n//2-1]
    ans = x2-x1+1
print(ans)

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

const int N=1e5+5;
int a[N];

int main()
{
    int n;
    cin>>n;
    while(n--){
        int t;
        cin>>t;
        a[t]++;
        a[t+1]++;
        if(t>0){
            a[t-1]++;
        }
    }
    int maxn=0;
    for(int i=0;i<100005;i++){
        if(a[i]>maxn){
            maxn=a[i];
        }
    }
    cout<<maxn;
    return 0;
}

Measured memory_bytes: 3892
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  int ans=1000;
  string s;
  cin >> s;
  for(char c='a'; c<='z'; c++) {
    int n=0,k=s.size();
    for(int i=s.size()-1; i>=0; i--) {
      if(s[i]==c) {
        k=i;
      }
      n=max(n,k-i);
    }
    ans=min(ans,n);
  }
  cout << ans << endl;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define all(v) (v).begin(),(v).end()
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define pb push_back
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

int main(){
    int n,m,X,Y;
    cin>>n>>m>>X>>Y;
    vint x(n),y(m);
    rep(i,n)cin>>x[i];
    rep(i,m)cin>>y[i];
    sort(all(x));
    sort(all(y));
    if(x[n-1]<y[0] && x[n-1]<Y && X<y[0])cout<<"No War"<<endl;
    else cout<<"War"<<endl;
}

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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[],int n){
    for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
    }
    cout<<endl;
}
int disum(int n){
	int sum=0;

	while(n){

		sum+=n%10;
		n/=10;





	}
	return sum;




}
int main() {
    int i,n,m,k,c=0,sum=0;
    c_p_c();
  	cin>>n;
  	int a[n];
  	fo(i,n) cin>>a[i];
  	sort(a,a+n);
  	cout<<a[n-1]-a[0]<<endl;
    return 0;
}



Measured memory_bytes: 3592
n=gets.to_i
p=gets.split
q=gets.split

a=0
b=0
c=0
[*1..n].permutation.each do |perm|
  if p.join==perm.join
    a=c
  end
  if q.join==perm.join
    b=c
  end
  c+=1
end
puts (a-b).abs


Measured memory_bytes: 14388
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <string>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define IREP(it,array) for(vector<int>::iterator it=array.begin(); it!=array.end(); ++it)
#define SREP(it,array) for(vector<string>::iterator it=array.begin(); it!=array.end(); ++it)


int main()
{
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(6);

  int INF = 1000000;

  int n=0;
  while(cin >> n){
    if(n==0) break;

    int res=0;
    int d = 5;
    while(d<=n){
      res += (n / d);
      d *= 5;
    }

    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 1160
#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 all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
ull solve(ll x, int level, vll P, vll Len)
{
    if (x == 1)
    {
        return 0;
    }
    if (level == 1)
    {
        return min(3LL, x - 1);
    }
    if (x <= Len[level] / 2)
    {
        return solve(x - 1, level - 1, P, Len);
    }
    if (x == Len[level] / 2 + 1)
    {
        return P[level - 1] + 1;
    }
    else
    {
        return solve(x - Len[level - 1] - 2, level - 1, P, Len) + P[level - 1] + 1;
    }
}
int main()
{
    ll N, X;
    cin >> N >> X;
    vll P(N + 1), B(N + 1), Len(N + 1);
    P[0] = 1;
    Len[0] = 1;
    rep(i, N)
    {
        P[i + 1] = 2 * P[i] + 1;
        B[i + 1] = 2 * B[i] + 2;
        Len[i + 1] = P[i + 1] + B[i + 1];
    }
    ll x = X, level = N, ans = 0;

    cout << solve(X, N, P, Len);
    return 0;
}

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

int main(void){
	int n;
	scanf("%d",&n);
	int a;
	int odd=0;
	for(int i=0;i<n;i++){
		scanf("%d",&a);
		if(a%2==1)odd++;
	}
	if(odd%2==1)printf("NO");
	else printf("YES");
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    int n,a,b,c,d,cnt = 0,memo = 1;
    cin >> n;
    int pts[n] = {0},rank[n];
    
    rep(i,0,n*(n-1)/2){
        cin >> a >> b >> c >> d;
        
        if(c > d) pts[a-1] += 3;
        else if(c < d) pts[b-1] += 3;
        else{
            pts[a-1]++;
            pts[b-1]++;
        }
        
        
    }
    
    for(int i = 300; i >= 0;i--){
        cnt = 0;
        
        rep(j,0,n){
            if(pts[j] == i){
                rank[j] = memo;
                cnt++;
            }
        }
        
        memo += cnt;
        
    }
    
    rep(i,0,n){
        
        cout << rank[i]  << endl;
    }
    
    
    
    
    return 0;   
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vb=vector<bool>;
using pii=pair<int,int>;
using vpii=vector<pair<int,int>>;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

//pow(llpow,modpow)
template<class T> ll llpow(ll x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
long long modpow(long long a, long long n, long long mod) {long long res = 1;while (n > 0) {if (n & 1) res = res * a % mod;a = a * a % mod;n >>= 1;}return res;}
//最大公約数
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
//最小公倍数
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}
//逆元
long long modinv(long long a, long long m) {long long b = m, u = 1, v = 0;while (b) {long long t = a / b;a -= t * b; swap(a, b);u -= t * v; swap(u, v);}u %= m;if (u < 0) u += m;return u;}

#define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)
//試験導入
#define irep(i, end_i, begin_i) for (ll i = (ll)begin_i-1; i >= (ll)end_i; i--)

long long INF = 1LL<<60;
int main( ){
    int n; cin>>n;
    ll res=1;
    ll mod=1e9+7;
    rep(i,1,n+1){
        res*=i;
        res%=mod;
    }
    cout<<res<<endl;
    return 0;
}




Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let mut ans = 0;
    let x: usize = sc.read();
    if x == 0 {
        ans = 1;
    }
    let x: usize = sc.read();
    if x == 0 {
        ans = 2;
    }
    let x: usize = sc.read();
    if x == 0 {
        ans = 3;
    }
    let x: usize = sc.read();
    if x == 0 {
        ans = 4;
    }
    let x: usize = sc.read();
    if x == 0 {
        ans = 5;
    }

    println!("{}", ans);
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


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

int32_t main() {
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    int ans=0;
    for(int i=1;i<n;i++){
        if(a[i]<a[i-1]){
            ans+=a[i-1]-a[i];
            a[i]=a[i-1];
        }
    }
    cout<<ans<<"\n";
    return 0;
}

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

int main(void){
    int n;
    cin>>n;
    int x,y;
    deque<int> v;
    while(n--){
        cin>>x;
        if(x==0){
            //pb
            cin>>x>>y;
            if(x) v.push_back(y);
            else v.push_front(y);
        }else if(x==1){
            cin>>y;
            cout<<v[y]<<endl;
        }else{
            cin>>x;
            if(x)v.pop_back();
            else v.pop_front();
        }
    }
    return 0;
}


Measured memory_bytes: 4504
#include <stdio.h>
#include <string.h>
#include <math.h>
int main(void){
    long int a;
    char b[10];
    long int ans;
    int b_100;
    scanf("%ld%s", &a, b);
    b_100 = (b[0] - '0')*100 + (b[2] - '0')*10 + (b[3] - '0');
    //printf("%d\n", b_100);
    ans = a * b_100 / 100;
    printf("%ld\n", ans);

    return 0;
}


Measured memory_bytes: 1732
n = input()
m = n.split()
P = [int(i) for i in m]
if P[1] == 0:
    for i in range(P[1]): #因数注意！
        n = input()    
    print("0 0")
else:
    
    AC = [0] * P[0]
    WA = [0] * P[0]

    for i in range(P[1]): #因数注意！
        n = input()    
        m = n.split()
        p = [i for i in m] #1列の数列をリスト化
        if p[1] == "AC":
            AC[int(p[0])-1] = 1
        else:
            if AC[int(p[0])-1] == 0:
                WA[int(p[0])-1] = WA[int(p[0])-1] +1
            else:
                pass
    A1 = 0
    A2 = 0
    for i in range(P[0]):
        if AC[i] == 1:
            A1 = A1+1
            A2 = A2 + WA[i]
    print(str(A1)+" "+str(A2))

Measured memory_bytes: 4596
#include<stdio.h>
#include<math.h>
int main()
{
   char str[1000000],str1[1000000];
   int i,j=0,len;
   gets(str);
   gets(str1);
   len=strlen(str);
   for(i=0;i<len;i++)
   {
       if(str[i]!=str1[i])
        j++;
   }
   printf("%d\n",j);
    return 0;
}


Measured memory_bytes: 1972
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int) n; i++)
#define repb(i, n) for (int i = (int) n; i >= 0; i--)
#define reps(i, m, n) for (int i = (int) m; i < (int) n; i++)
#define repsb(i, m, n) for (int i = (int) m; i >= (int) n; i--)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<int>());
#define pb(a) push_back(a)
#define ll long long int
const ll LLINF = 1e18 + 10;
int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return 1; } return 0; }
template < class T > bool chmin(T & a,const T & b) { if (b < a) { a = b; return 1; } return 0; }
//vector<vector<int>> vec(n_rows, vector<int>(n_cols, value));
using namespace std;
int s(int a,int b,int c){
    if (a % 2 == 1 || b % 2 == 1||c % 2 == 1)
        return 0;
    if (a==b && b==c)
        return -1;

        return s((b + c) / 2, (a + c) / 2, (a + b) / 2) + 1;
}
int main(int argc, char const * argv[]){
    ll a, b, c;
    cin >> a >> b >> c;
    ll ans = s(a,b,c);
    cout<<ans<<endl;

    return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;

//MOD
//--------------------------------------------
#define MUL(a,b) (((a) % MOD) * ((b) % MOD)) % MOD

// grid
//--------------------------------------------
VL dx = {0, 1, 0, -1};
VL dy = {1, 0, -1, 0};
VL dx2 = {-1, 0, 1, -1, 1, -1, 0, 1};
VL dy2 = {-1, -1, -1, 0, 0, 1, 1, 1};

//debug
//--------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main code

int main(int argc, char const* argv[])
{
	LL n;
	cin >> n;
	VL a(5);
	for (int i = 0; i < 5; i++) {
		cin >> a[i];
	}
	PLL mina = make_pair(0, a[0]);
	for (int i = 1; i < 5; i++) {
		if (mina.second > a[i]) {
			mina = make_pair(i, a[i]);
		}
	}
	LL ans = 5 + (n / mina.second) - (n % mina.second == 0 ? 1 : 0);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n, q = map(int, input().split())
s = input()
lr = [list(map(int, input().split())) for i in range(q)]
s_count = [0 for i in range(n + 1)]
for i in range(n):
    s_count[i + 1] = s_count[i] + (1 if s[i:i + 2] == 'AC' else 0)

for i in range(q):
    print(s_count[lr[i][1] - 1] - s_count[lr[i][0] - 1])


Measured memory_bytes: 32272
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> pll;
const ll inf = 1LL << 60;

int main(){
    //cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    int n; cin >>n;
    vector<int> A(n);
    REP(i,n){
        cin >> A[i];
    }
    vector<int> B(n,INF);

    REP(i,n){
        *lower_bound(ALL(B),A[i]) = A[i];
    }

    REP(i,n){
        if(B[i] == INF){
            cout << i << endl;
            return 0;
        }
    }
    
    cout << n << endl;
}


Measured memory_bytes: 3636
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>

#define MAX_N 100
#define INF 100000
#define rep(i, n) for(int i=0; i<n; ++i)
#define REP(i, s, t) for(int i=s; i<=s; ++i)

using namespace std;

const int nmax=8;
bool graph[nmax][nmax];


int dfs(int v, int N, bool visited[nmax])
{
    bool all_visited=true;

    // if all points are visited, add 1 to answer
    rep(i, N)
    {
        if(visited[i]==false) all_visited=false;
    }
    if(all_visited) return 1;

    int ret=0;

    rep(i, N)
    {
        // adjacent && not visited
        if(graph[v][i]==false) continue;
        if(visited[i]) continue;

        visited[i]=true;
        ret+=dfs(i, N, visited);
        visited[i]=false;
    }

    return ret;
}

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

    int N, M;
    cin >> N >> M;

    rep(i, M)
    {
        int A, B;
        cin >> A >> B;
        graph[A-1][B-1]=graph[B-1][A-1]=true;
    }

    bool visited[nmax];
    rep(i, N) visited[i]=false;

    visited[0]=true;
    cout << dfs(0, N, visited) << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<ll> V;
typedef pair<ll,ll> P;
typedef map<ll,ll> M;

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


signed main(){
    int n;
    cin >> n;
    V line(n);
    M line_map;
    vector<string> type(n);
    vector<vector<string>> args(n);

    set<int> variables;
    M value_map;
    vector<int> val_ind;

    REP(i,n){
        cin >> line[i] >> type[i];
        line_map[line[i]] = i;
        string s = type[i];

        if(s == "ADD" || s == "SUB")
            args[i].resize(3);
        if(s == "SET" || s == "IF")
            args[i].resize(2);
        if(s == "HALT")
            args[i].resize(0);
        for(auto& x : args[i])
            cin >> x;

        if(s == "ADD" || s == "SUB"){
            variables.insert(args[i][0][0]);
            variables.insert(args[i][1][0]);
            if(args[i][2].size() == 1 && args[i][2][0] >= 'a' && args[i][2][0] <= 'z')
                variables.insert(args[i][2][0]);
        }
        if(s == "SET" || s == "IF"){
            variables.insert(args[i][0][0]);
            if(s == "SET" && args[i][1].size() == 1 && args[i][1][0] >= 'a' && args[i][1][0] <= 'z')
                variables.insert(args[i][1][0]);
        }
    }
    for(auto x : variables){
        value_map[x] = val_ind.size();
        val_ind.push_back(x);
    }

    V values(val_ind.size(), 0);

    int now_line = 0;
    auto print = [&](){
        REP(i, val_ind.size()){
            cout << char(val_ind[i]) << "=" << values[i] << endl;
        }

        std::exit(0);
    };

    time_t st = clock();
    while(1.0 * (clock() - st) / CLOCKS_PER_SEC < 4.8){
        if(now_line == n)
            print();
        string s = type[now_line];

        /*
        for(auto x : values)cout << x << " ";cout << endl;

        cout << s << endl;
        */

        if(s == "ADD" || s == "SUB"){
            int val1 = values[value_map[args[now_line][1][0]]];
            int val2 = (args[now_line][2].size() == 1 && args[now_line][2][0] >= 'a' && args[now_line][2][0] <= 'z')
                    ? values[value_map[args[now_line][2][0]]]
                    : std::stoi(args[now_line][2]);
            val1 += (s == "ADD" ? 1 : -1) * val2;
            if(val1 < 0 || val1 >= 16)
                print();
            values[value_map[args[now_line][0][0]]] = val1;
        }
        if(s == "SET"){
            int val = (args[now_line][1].size() == 1 && args[now_line][1][0] >= 'a' && args[now_line][1][0] <= 'z')
                    ? values[value_map[args[now_line][1][0]]]
                    : std::stoi(args[now_line][1]);
            if(val < 0 || val >= 16)
                print();
            values[value_map[args[now_line][0][0]]] = val;
        }
        if(s == "IF"){
            int val = values[value_map[args[now_line][0][0]]];
            if(val){
                if(!line_map.count(stoi(args[now_line][1])))
                    print();
                now_line = line_map[stoi(args[now_line][1])];
                continue;
            }
        }
        if(s == "HALT")print();

        ++now_line;
    }
    cout << "inf" << endl;

}



Measured memory_bytes: 3176
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

s = ns()
n = len(s)

ans = inf
for i in range(n - 2):
    m = int(s[i] + s[i + 1] + s[i + 2])
    ans = min(ans, abs(753 - m))

print(ans)

Measured memory_bytes: 3064
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_C&lang=jp
#   Doubly Linked List : python3
#  2018.11.27 yonezawa


from collections import deque

import sys
input = sys.stdin.readline
import cProfile


def main():
    q = deque()
    n =  int(input())
    skipFlag = False

    while n > 0:
        if skipFlag == False:
            l = list(map(str,input().split()))
            if len(l) == 0:
                break
        skipFlag = False
        cmd = l[0]
        if ( cmd == 'insert'):
            d = int(l[1])
            if n <= 1:
                q.appendleft(d)
                n -= 1
                continue
            l = list(map(str,input().split()))
            if len(l) == 0:
                q.appendleft(d)
                break
            if (l[0] == 'deleteFirst' ):
                n -= 1
                continue
            elif (len(q) == 0 and l[0] == 'deleteLast'):
                n -= 1
                continue
            else:
                skipFlag = True
                q.appendleft(d)
        elif ( cmd == 'delete'):
            try:
                q.remove(int(l[1]))
            except:
                None
        elif ( cmd == 'deleteFirst'):
            q.popleft()
        else:
            q.pop()
        n -= 1

    print (*q)

if __name__ == '__main__':
   main()
#    pr = cProfile.Profile()
#    pr.runcall(main)
#    pr.print_stats()


Measured memory_bytes: 47376
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define mod 1000000007
#define vi vector<int>
#define si set<int>
#define pi pair<int,int>
#define li list<int>
#define fi first
#define in insert
#define se second
#define fr(i,n) for(i = 0 ; i < n ; i++)

int main()
{
    fio
    string s,t;
    cin>>s>>t;
    vector<char> v;
    int sl=s.size();
    int tl = t.size();
    int i,j,k;
    int dp[sl+1][tl+1];
    for(i = 0;i<=tl;i++)
        dp[0][i] = 0;
    for(i=0;i<=sl;i++)
        dp[i][0]=0;
    for(i=1;i<=sl;i++)
    {for(j = 1;j<=tl;j++)
        {
            if(s[i-1]==t[j-1])
            dp[i][j] = 1+dp[i-1][j-1];
            else
                dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
        }
    }
    i = sl;
    j = tl;
    while(i>0&&i<=sl &&j>0&&j<=tl)
    {
        if(dp[i][j]>dp[i-1][j] && dp[i][j]>dp[i][j-1])
            {v.pb(s[i-1]);
            i--;j--;}
        else
        {
            if(dp[i][j]<=dp[i-1][j])
                i--;
            else if(dp[i][j]<=dp[i][j-1])
                j--;
        }
    }
    for(i = v.size()-1;i>=0;i--)
        cout<<v[i];

        return 0;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define y1 zzz
#define fi first
#define se second
#define PII pair<int,int>
#define PII2 pair<int,PII >
#define PII3 pair<PII,int >
#define PII4 pair<PII,PII >
#define all(x) (x).begin(),(x).end()
#define pb push_back
int dp[3010][3010][2],a[3010],n;
int f(int l,int r,int state)
{
    if(l==r)
    {
        if(state)return -a[l];
        return a[l];
    }
    if(dp[l][r][state]!=-1e18)return dp[l][r][state];
    if(state)return dp[l][r][state]=min(-a[l]+f(l+1,r,1-state),-a[r]+f(l,r-1,1-state));
    return dp[l][r][state]=max(a[l]+f(l+1,r,1-state),a[r]+f(l,r-1,1-state));
}
void solve()
{
    cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            dp[i][j][0]=dp[i][j][1]=-1e18;
    cout<<f(1,n,0);
}
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("XORQUERY.inp","r",stdin);
    //freopen("XORQUERY.out","w",stdout);
    //int t;cin>>t;while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 141696
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lowb lower_bound
#define upb upper_bound
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

	string s;
	cin >> s;
	int q;
	cin >> q;
	rep(i, q) {
		string t; cin >> t;
		if (t == "print") {
			int a, b; cin >> a >> b;
			cout << s.substr(a, b - a + 1) << endl;
		}
		if (t == "reverse") {
			int a, b; cin >> a >> b;
			reverse(s.begin() + a, s.begin() + b + 1);
		}
		if (t == "replace") {
			int a, b; string p; cin >> a >> b >> p;
			s.replace(a, b - a + 1, p);
		}
	}
	return 0;
}


Measured memory_bytes: 3228
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end();++it)
#define pb push_back
#define fs first
#define sc second
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

const int INF = ~(1<<31);
const double pi = acos(-1);
const double EPS = 1e-9;
typedef unsigned long long ull;

template <class T> T smod(T a, T b) {
  return (a % b + b) % b; }

int n;
int mn = INF;

int solve(vii &A, int a, int b) {
    if(a == 0 && b == 0) return n;
    set<ii> have;
    rep(i,0,n) have.insert(A[i]);
    int cost = n;
    rep(i,0,n) {
        if(have.find(ii(A[i].fs-a, A[i].sc-b)) != have.end()) cost--; 
    }
    return cost;
}

int main() {
    cin.sync_with_stdio(false);
    cin >> n;
    vii A(n);
    rep(i,0,n) cin >> A[i].fs >> A[i].sc;
    vii D;
    rep(i,0,n) rep(j,0,n) {
        D.pb(ii(A[i].fs-A[j].fs, A[i].sc-A[j].sc));
    }
    rep(i,0,D.size()) {
            mn = min(mn, solve(A, D[i].fs, D[i].sc));
    }
    cout << mn << endl;
    return 0;
}


Measured memory_bytes: 384
n,k = [int(x) for x in input().split()]
d = {}
for _ in range(n):
    a = [int(x) for x in input().split()]
    if a[0] in d.keys():
        d[a[0]] += a[1]
    else:
        d[a[0]] = a[1]


for i in sorted(d.keys()):
    k -= d[i]
    if k <= 0:
        print(i)
        break

Measured memory_bytes: 10560
#include<iostream>
using namespace std;
int main() {
	int b, f, r, v, n;
	int a[4][3][10];
	cin >> n;
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				a[i][j][k] = 0;
			}
		}
	}
	for (int h = 0; h < n; h++) {
		cin >> b >> f >> r >> v;
		a[b - 1][f - 1][r - 1] += v;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				cout << " " << a[i][j][k];
			}
			cout << endl;
		}
		if (i < 3) {
			cout << "####################" << endl;
		}
	}
}



Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

  vector<int> vec( n );
  for( int i = 0; i < n; i++ ) {
    cin >> vec[ i ];
  }

  reverse( vec.begin(), vec.end() );
  for( int i = 0; i < n; i++ ) {
    cout << vec[ i ];
    if( i != n - 1 ) {
      cout << " ";
    }
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 3096
def character_count(str)
  v = [0] * 26
  str.split('').each { |c| v[c.ord - 'a'.ord] += 1 }
  return v
end

def intersection_count(v1, v2)
  count = 0
  26.times do |i|
    if v1[i] > 0 and v2[i] > 0 then
      count += 1
    end
  end
  return count
end

def count(x, y)
  intersection_count(
    character_count(x),
    character_count(y)
  )
end

def main(argv)
  n = gets.chomp.to_i
  s = gets.chomp
  
  m = 0
  (n-1).times do |i|
    x = s[0..i]
    y = s[i+1..n]
    m = [m, count(x, y)].max
  end
  puts m.to_s
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 1000000007
#define PI 3.14159265358979323846
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;

   // cin>>t;
    while(t--)
    {
       int n,m,i;
       cin>>n>>m;
       if(n>m)
        swap(n,m);
       for(i=0;i<m;i++)
        cout<<n;
    }
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
int a[100005][3],n,f[100005][3],ans;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);
    for(int i=1;i<=n;i++)
    for(int j=0;j<3;j++) 
    for(int k=0;k<3;k++) if(j!=k) f[i][j]=max(f[i][j],f[i-1][k]+a[i][j]);
    for(int i=0;i<3;i++) ans=max(ans,f[n][i]);
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)
int main(){
    int H,W,N,sr,sc;
    cin>>H>>W>>N>>sr>>sc;
    string S,T;
    cin>>S>>T;
    int l=0,r=0,u=0,d=0;
    int ml=0,mr=0,mu=0,md=0;
    rep(i,N){
        if(S[i]=='R') r++;
        else if(S[i]=='L') l++; 
        else if(S[i]=='U') u++;
        else d++;
        ml=max(ml,l);
        mr=max(mr,r);
        mu=max(mu,u);
        md=max(md,d);
        if(T[i]=='R') {
            if(sc-l<W) l--;
        }else if(T[i]=='L'){
            if(sc+r>1) r--;
        }else if(T[i]=='U'){
            if(sr+d>1) d--;
        }else{
            if(sr-u<H) u--;
        }
    }
    if(sc-ml<1 || sc+mr>W || sr-mu<1 || sr+md>H) cout<<"NO"<<endl;
    else  cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 776
#include <iostream>

int main() {
	int N, M, X, Y;
	char* result = "No War\n";
	std::cin >> N >> M >> X >> Y;
	int* NX = new int[N];
	int* NY = new int[M];
	for (int i = 0; i < N; i++)
	{
		std::cin >> NX[i];
	}

	for (int i = 0; i < M; i++)
	{
		std::cin >> NY[i];
	}
	
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < M; j++)
		{
			if (NX[i] >= NY[j] || NX[i] >= Y || NY[j] <= X)
			{
				result = "War\n";
			}
		}
	}
	std::cout << result;
	return 0;
}

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

using namespace std;

char str[101];

bool is_palindrome(int s, int e) {
    s--, e--;
    while (s < e) {
        if (str[s++] != str[e--]) return false;
    }
    return true;
}

int main() {
    // freopen("B.in", "r", stdin);
    scanf("%s", str);
    int n = strlen(str);
    auto v = is_palindrome(1, n) && is_palindrome(1, (n-1)/2) && is_palindrome((n+3)/2, n) ?
    "Yes" : "No";
    puts(v);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

ll s,c;
int main(){
	scanf("%lld%lld",&s,&c);
	ll ans;
	if(c<=2*s)ans=c/2;
	else{
		ans=s;
		c-=2*s;
		ans+=c/4;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 128
import sys

N, K = map(int, input().split())
if K == 0:
    print(N*N)
    sys.exit()

ans = 0
for b in range(K, N+1):
    s, r = N//b, N % b
    ans += s * (b-K)
    ans += max(0, r - K + 1)
print(ans)


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

int main(){
  int a,b;
  cin >> a >> b;

  int j=0;
  int k=b;
  while(k){
    k/=10;
    j++;
  }
//  cout << j << endl;

  int x;
  x=a*pow(10,j)+b;
//  cout << x << endl;


  bool T=false;
  int i=1;
  while(i*i<=100100){
    if(i*i==x){
      T=true;
      break;
    }
    i++;
  }

  if(T) cout << "Yes" << endl;
  else cout <<"No" <<endl;
}

Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def TUPLE(): return tuple(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7 
#mod = 998244353
from decimal import *
#import numpy as np
#decimal.getcontext().prec = 10

S = input()

ans = 0
cnt = 0
for x in S:
	if x == "R":
		cnt += 1
	else:
		ans = max(ans, cnt)
		cnt = 0
ans = max(ans, cnt)

print(ans)

Measured memory_bytes: 10344
s = input()
t = input()

slength = len(s)
tlength = len(t)

minimum = tlength

for i in range(slength - tlength + 1):
    count = 0
    for j in range(tlength):
        if t[j] != s[i + j]:
            count += 1
    if minimum > count:
        minimum = count

print(minimum)

Measured memory_bytes: 9064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int M = N % 10;
  
  if( M == 2 || M  == 4 || M == 5 || M ==  7  || M == 9){
    cout << "hon" << endl;
  }
  
  else if ( M == 0 || M == 1 || M == 6 || M == 8 ){
    cout << "pon" << endl;
  }
  
  else if ( M == 3 ) {
    cout << "bon" << endl;
  }
  
  
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    rep(i, n) {
        if (i%2==0) ans += a[i];
        else ans -= a[i];
    }

    rep(i, n) {
        if (i == 0) cout << ans << endl;
        else {
            ans = 2*a[i-1] - ans;
            cout << ans << endl;
        }
    }

}

Measured memory_bytes: 1664
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  for(ll i = 0; i < n; i++) cin >> a.at(i); 
  vector<ll> b(a);
  sort(b.begin(), b.end(), greater<int>());
  for(ll i = 0; i < n; i++){
    if(a.at(i) != b.at(0)) cout << b.at(0) << endl;
    else{
      cout << b.at(1) << endl;
    }
  }
}

Measured memory_bytes: 4736
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		City[] cities = new City[m];
		for (int i = 0; i < m; i++) {
			cities[i] = new City(i, sc.nextInt(), sc.nextInt());
		}
		sc.close();

		// yの昇順
		Arrays.sort(cities, new Comparator<City>() {
			public int compare(City c1, City c2) {
				return c1.y - c2.y;
			}
		});

		int[] cityCnt = new int[n + 1];
		String[] numArray = new String[m];
		for (City city : cities) {
			String num = padZero(city.p) + padZero(++cityCnt[city.p]);
			numArray[city.i] = num;
		}

		for (String num : numArray) {
			System.out.println(num);
		}
	}

	static class City {
		int i;
		int p;
		int y;
		public City(int i, int p, int y) {
			this.i = i;
			this.p = p;
			this.y = y;
		}
	}

	static String padZero(int id) {
		StringBuilder sb = new StringBuilder(String.valueOf(id));
		while (sb.length() < 6) {
			sb.insert(0, "0");
		}
		return sb.toString();
	}
}


Measured memory_bytes: 103132
str_s = input()
int_k = int(input())

result = list()
for f in range(len(str_s)):
    pattern = set()
    for t in range(f + 1, f + 1 + int_k):
        pattern.add(str_s[f:t])
        result = sorted(set(result + list(pattern)))[:int_k]

print(result[-1])


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

int N;
double T,A,h;
int main(){
	cin >> N >> T >> A;
	int ans = 0;
	double d = 1e9;
	for(int i=1;i<=N;i++){
		cin >> h;
		if(abs(T-h*0.006-A)<d){
			ans = i;
			d = abs(T-h*0.006-A);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const ll mod = 1e9;

ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}
ll inv(ll x){return expo(x,mod-2);}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};
/*---------------------------------------------------------------------------------------------------------------------*/

const int M = 2e5 + 5;

vector<pair<int , ll> > vec[M];
int vis[M];
ll pos[M];

// min max
pair<ll , ll> dfs(int u , ll here){
    //if(vis[u]) return;
    pos[u] = here;
    vis[u] = 1;
    ll maxx = here;
    ll minn = here;
    for(int i = 0 ; i < vec[u].size() ; i++){
        int v = vec[u][i].first;
        ll dis = vec[u][i].second;
        if(vis[v]) continue;
        pair<ll , ll> rr = dfs(v , here + dis);
        minn = min(minn , rr.first);
        maxx = max(maxx , rr.second);
    }
    return make_pair(minn , maxx);
}
ll q[5][M];

int main(){
    
	int n , m;
	cin >> n >> m;
	
	for(int i = 1 ; i <= m ; i++){
	    int a , b;
	    ll dis;
	    si(a);  si(b);  sll(dis);
	    q[1][i] = a;
	    q[2][i] = b;
	    q[3][i] = dis;
	    vec[a].push_back(make_pair(b , dis));
	    vec[b].push_back(make_pair(a , -dis));
	}
	
	for(int i = 1 ; i <= n ; i++){
	    if(vis[i]) continue;
	    pair<ll , ll> pp = dfs(i , 0);
	    if(pp.second - pp.first > mod){
	        cout<<"No";
	        return 0;
	    }
	}
	
	for(int i = 1 ; i <= m ; i++){
	    int a = q[1][i];
	    int b = q[2][i];
	    ll dis = q[3][i];
	    if(pos[b] - pos[a] != dis){
	        cout<<"No";
	        return 0;
	    }
	}
	
	
	cout<<"Yes";
	
	
	
    
}





































Measured memory_bytes: 27648
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 
 
int32_t main()
{
    fast;
    int n; cin >> n;
    if(n % 1000 == 0) cout << 0;
    else {
        cout << 1000 * ((n / 1000) + 1) - n;
    }
    
    
    
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<ll> a(n);
    ll X = 0, x = 0, res = LINF;
    rep(i, n) {
        cin >> a.at(i);
        X += a.at(i);
    }

    rep(i, n) {
        x += a.at(i);
        if (i + 1 < n) chmin(res, abs(x - (X - x)));
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1792