akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= int(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(c) begin(c), end(c)
#define MSG(a) cout << a << endl;

template <typename T>
using vec = std::vector<T>;
using vi = vec<int>;
using vvi = vec<vi>;
using pii = std::pair<int, int>;
using ll = long long;
using ld = long double;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  int A, B;
  cin >> A >> B;
  MSG((A - 1) * (B - 1));
  return 0;
}


Measured memory_bytes: 256
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0: a, b = b, a % b
    return b
  
def solve():
    M, K = map(int, line_input())
    if K >= pow(2, M): print(-1)
    elif M == 0:
        if K == 0: print("0 0")
        else: print(-1)
    elif M == 1:
        if K == 0: print("0 0 1 1")
        else: print(-1)
    else:
        ans = []
        if K == 0: ans = [int(i)//2 for i in range(2 ** (M + 1))]
        else:
            ans.append(K)
            for i in range(2 ** M):
                if i != K: ans.append(i)
            ans.append(K)
            for i in reversed(range(2 ** M)):
                if i != K: ans.append(i)
        print(" ".join(map(str, ans)))
    return 0
  
if __name__ == "__main__":
    solve()

Measured memory_bytes: 31992
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <time.h>
#include <bits/stdc++.h>

#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long int ll;
const int INF=1e9+5;
int main() {
#ifdef _DEBUG
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    IO;
    int n ,w;
    cin>>n>>w ;
    vector<ll>temp_row(w+2);
    vector<vector<ll>>dp(n+1,temp_row);
    int weight , value;
    for(int i = 0 ;i < n ; i ++){
        cin>>weight>>value;
        for(int j =w-weight ; j >=0; j --){
            dp[i+1][j+weight]=max(dp[i+1][j+weight],dp[i][j]+value);
        }
        for(int j = 0 ;j<=w;j++)  dp[i+1][j]=max(dp[i+1][j],dp[i][j]);

    }
    ll ans= 0;
    for(int i =0 ; i <=w; i++)ans=max(ans,dp[n][i]);
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 80256
#include <stdio.h>

int main( void ) {
	int n, debt = 100000;

	for ( scanf( "%d", &n ); n--; debt *= 1.05, debt = debt % 1000 ? ( debt / 1000 + 1 ) * 1000 : debt ) ;

	printf( "%d\n", debt );

	return 0;
}

Measured memory_bytes: 588
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long
#define ull unsigned long long
#define ld long double
#define endl "\n"
#define ff first
#define ss second
#define pi pair<ll, ll>
#define PI 3.141592653589793238462643383279502884L
#define mp make_pair
#define pb push_back
#define fall(i, a, b) for (int i = a; i < b; i++)
#define sz(x) (ll) x.size()
#define all(x) x.begin(), x.end()
#define ed cout << "ed";
#define time_passed 1.0 * clock() / CLOCKS_PER_SEC
ll MOD = 1e9 + 7;
ll MOD1 = 1e9 + 123;
ll MOD2 = 1e9 + 321;

vector<int> G[1000000];
vector<int> L(1000000, 0);
vector<int> vis(1000000, 0);

void dfs(ll y, ll c)
{
    vis[y] = c;

    for (auto h : G[y])
    {
        if (vis[h] == 0)
            dfs(h, c);
    }
}
int main()
{
    fio;
    ll t, a, n, q, k, i, l, m, c, u, f, j, p, x, y, b, d;
 
 cin>>n>>m;
 for(i=0;i<m;i++)
 cin>>a>>b, G[a].pb(b),G[b].pb(a);
c=0;
for(i=1;i<=n;i++)
if(vis[i]==0)
dfs(i,++c);
unordered_map<int,int>mp;
for (i = 1; i <= n; i++)
    mp[vis[i]]++;
p=INT_MIN;
for (auto h : mp)
p=max(p,(ll)h.ss);

    cout << p << endl;

return 0;
}


Measured memory_bytes: 46896
#include<bits/stdc++.h>
#define for_int(i,a,b) for(int i=(a);i<=(b);++i)
#define rep_int(i,a,b) for(int i=(a);i>=(b);--i)
#define for_ll(i,a,b) for(ll i=(a);i<=(b);++i)
#define rep_ll(i,a,b) for(ll i=(a);i>=(b);--i)
#define ull unsigned long long
#define ll long long
#define db double
#define HPMAX 1005
#define KMP_MAX 1005
#define prime_MAX 1e6+5
#define quick_pow_mod 1e9+7
#define PII pair<int,int>
using namespace std;
//快读
int read() {
	char c = getchar();
	int x = 0, f = 1;
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (; isdigit(c); c = getchar())
		x = x * 10 + c - 48;
	return x * f;
}
int a;
int main() {
	a = read();
	cout << a + a * a + a * a * a << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
using namespace std;
const int N=2e5+5;
typedef long long ll;
ll tr[N];
int h[N],a[N];
void add(int,ll);
ll ask(int);
int main(){
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",h+i);
    for(int i=1;i<=n;i++) scanf("%d",a+i);
    ll ans=0;
    for(int i=1;i<=n;i++){
        ll t=a[i]+ask(h[i]);
        ans=max(ans,t);
        add(h[i],t);
    }
    printf("%lld",ans);
}
ll ask(int i){
    ll re=0;
    while(i){
        re=max(re,tr[i]);
        i-=i&-i;
    }
    return re;
}
void add(int i,ll k){
    while(i<N){
        tr[i]=max(tr[i],k);
        i+=i&-i;
    }
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
class person{
	private: int sum;
	public: person(int sum):sum(sum){}
		void setKoishi(){
			sum++;
		}
		int clear(){
			int res=sum;
			sum=0;
			return res;
		}
		bool haveAllKoishi(int allKoishi){
			return sum == allKoishi;
		}
};

class vessel{
	private:int sum;
	public:vessel(int sum):sum(sum){}
	       void setKoishi(int koishi){
			sum=koishi;
	       }
	       void getKoishi(){
			sum--;
	       }
	       bool isNothing(){
			return sum==0;
	       }
};
int main(){
	int sum;
	int n,p;
	while((cin>>n>>p)&&(n!=0)&&(p!=0)){
		vector<person> candidate;
		vessel aVessel(p);
		for(int i=0;i<n;i++){
			candidate.emplace_back(0);
		}
		for(int cnt=0;cnt<1000000;cnt++){
			if(!aVessel.isNothing()){
				aVessel.getKoishi();
				candidate[cnt%n].setKoishi();
			}else{
				if(candidate[cnt%n].haveAllKoishi(p)){
					cout << cnt%n << endl;
					break;
				}else{
					aVessel.setKoishi(candidate[cnt%n].clear());
				}
			}
		}
	}
  return 0;
}

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

int main(){
    while(1){
        string x;
        int sum = 0;
        cin >> x;
        
        if(x=="0") break;
        
        for (int i=0; i <x.length();i++){
            sum += x[i]-'0';
        }cout<<sum<<endl;
        }return 0;
}



Measured memory_bytes: 3184
import java.math.BigDecimal;
import java.util.Scanner;
import java.math.RoundingMode;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int totalNum = sc.nextInt();
		double[] list = new double[totalNum];
		for(int i = 0; i < totalNum; i++) {
			list[i] = (double)sc.nextInt();
		}
		double reciprocalSum = 0;
		for(int i = 0; i < totalNum; i++) {
			reciprocalSum += 1 / list[i];
		}
		double ans = 1 / reciprocalSum;
		System.out.println(ans);
	}
}

Measured memory_bytes: 22740
#include <iostream>
#include <cstdlib>

int main()
{
    int n, x;
    std::cin >> n >> x;
    int l[110];
    for (int i = 0; i < n; ++i) std::cin >> l[i];
    int d[110];
    d[0] = 0;
    int count = 1;
    
    for (int i = 1; i <= n; ++i){
        d[i] = d[i-1] + l[i-1];
        if (d[i] <= x) ++count;
    }
    
    std::cout << count;
    
    return 0;
}

Measured memory_bytes: 256
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int A = input[0];
            int B = input[1];
            Console.WriteLine(A <= 8 && B <= 8 ? "Yay!" : ":(");
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = INF+7;
const ll LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define VI vector<int>
#define VII vector<vector<int>>
#define all(v) (v.begin(),v.end())
#define MP make_pair
#define pb(n) push_back(n)


int main(){
    int p,m,c;
    cin>>p>>m>>c;cout<<p+c+m<<endl;
}


Measured memory_bytes: 3088
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll a[Max];
ll k,A,B;
void solve(){
	cin>>A>>B>>k;
	if(k<=A){
		cout<<A-k<<" "<<B<<endl; 
	}else{
		cout<<0<<" "<<max(B-(k-A),0LL);
	}
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll n; cin >> n;
  vector<ll> run;
  ll cnt = 0;
  ll prev = -1;
  ll cur;
  REP(i, n){
    cin >> cur;
    if(cur == prev){
      cnt++;
    }else{
      run.push_back(cnt);
      cnt = 1;
    }
    prev = cur;
  }
  run.push_back(cnt);
  ll ans = 0;
  REP(i, run.size()){
    ans += run[i]/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define PI 2*acos(0)
#define INF 1e15
//#define mx 1000005
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s,t;
    int i,j,cnt;
    cnt=0;
    cin>>s;
    cin>>t;
    for(i=0;i<s.size();i++){
        if(s[i]!=t[i]) cnt++;
    }
    cout<<cnt;
    return 0;
}


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

int main() {
  int n; cin >> n;
  vector<int> a(n);
  int ans = 0;
  for (int& e: a) cin >> e;
  sort(a.rbegin(), a.rend());
  for (int i = 0; i < n; i++) ans += a.at(i) * (i % 2 == 0 ? 1 : -1);
  cout << ans << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import itertools

n, m = map(int, input().split())

n_cnt = 0
m_cnt = 0

if n >= 2:
    n_cnt = len(list(itertools.combinations(range(n), 2)))

if m >= 2:
    m_cnt = len(list(itertools.combinations(range(m), 2)))

print(n_cnt + m_cnt)


Measured memory_bytes: 3444
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdlib>
using namespace std;
#define REP(i,n) for(int i = 0;i < (int)(n);i++);

int main() {
	int r;
	cin >> r;
	if (r < 1200)cout << "ABC";
	else if (r < 2800)cout << "ARC";
	else cout << "AGC";
	return(0);
}


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

int main(){
    int A_start,A_finish,B_start,B_finish;
    cin>>A_start>>A_finish>>B_start>>B_finish;
    if(max(A_start,B_start)<=min(A_finish,B_finish)){
        cout<<min(A_finish,B_finish)-max(A_start,B_start);
    }else{
        cout<<0;
    }
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
def is_kaibun(s):
    n = len(s)
    flag = True
    for i in range(n//2):
        flag = (flag and s[i] == s[n-i-1])
    return flag
        
s = input()
n = len(s)

if n%2==1 and is_kaibun(s) and is_kaibun(s[:(n-1)//2]) and is_kaibun(s[(n+1)//2:]):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  int a,b;
  char c;
  int ans=0;
  for(int i=0;i<3;i++){
    cin >> c;
    if(c=='1')
      ans++;
  }

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

Measured memory_bytes: 768
import sys
#input = sys.stdin.readline
from collections import deque
N, u, v = map(int, input().split())
G = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
v-=1
u-=1
que = deque([v])
par = [-1]*N
depth = [-1]*N
depth[v] = 0
while que:
    i = que.popleft()
    d = depth[i]
    for nv in G[i]:
        if depth[nv]>=0:
            continue
        depth[nv] = d+1
        par[nv] = i
        que.append(nv)
d = depth[u]
now = u
m = 0
que = deque([now])
while que:
    i = que.pop()
    m = max(m, depth[i])
    for nv in G[i]:
        if depth[nv]<depth[i]:
            continue
        que.append(nv)
for i in range(d//2):
    pp = par[now]
    que = deque([pp])
    while que:
        i = que.pop()
        m = max(m, depth[i])
        for nv in G[i]:
            if depth[nv]<depth[i] or nv == now:
                continue
            que.append(nv)
    now = pp
print(m-1)
    






Measured memory_bytes: 64876
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  immutable mod = 1_000_000_000 + 7;
  auto n = readln.chomp.to!int;
  long res = 1;
  foreach (i; 1..n+1) {
    res *= i;
    res %= mod;
  }

  res.writeln;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+5,mod=1e9+7;
vector<int>v[N];
ll res=1,f[N],inv[N],invf[N];
int n,si[N],ans[N];
void dfs(int x,int pre)
{
    si[x]=1;
    for(int i=0;i<v[x].size();i++)
    {
        if(v[x][i]==pre) continue;
        dfs(v[x][i],x);
        si[x]+=si[v[x][i]];
        res=res*invf[si[v[x][i]]]%mod;
    }
    res=res*f[si[x]-1]%mod;
}
void solve(int x,int pre,ll res)
{
    ans[x]=res;
    for(int i=0;i<v[x].size();i++)
    {
        if(v[x][i]==pre) continue;
        solve(v[x][i],x,res*inv[n-si[v[x][i]]]%mod*si[v[x][i]]%mod);
    }
}
int main()
{
    scanf("%d",&n);
    f[0]=f[1]=invf[0]=invf[1]=1,inv[1]=1;
    for(int i=2;i<N;i++)
    {
        f[i]=f[i-1]*i%mod;
        inv[i]=(mod-mod/i)*inv[mod%i]%mod;
        invf[i]=invf[i-1]*inv[i]%mod;
    }
    for(int i=1;i<n;i++)
    {
        int x,y;
        scanf("%d%d",&x,&y);
        v[x].push_back(y);
        v[y].push_back(x);
    }
    dfs(1,0);
    solve(1,0,res);
    for(int i=1;i<=n;i++) printf("%d\n",ans[i]);
}


Measured memory_bytes: 20212
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int h, a; cin >> h >> a;
	int ans = 0;
	if (h % a != 0) ans++;
	ans += h / a;
	cout << ans << endl;
}

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

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

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

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

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

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

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

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

fn main() {
    input! {
        n: usize,
        k: usize,
        r: usize,
        s: usize,
        p: usize,
        t: chars,
    }

    let mut used = vec![true; n];
    let mut ans = 0;
    for (i, &ti) in t.iter().enumerate() {
        if i >= k && t[i] == t[i - k] && used[i - k] {
            used[i] = false;
            continue;
        }
        ans += match ti {
            'r' => p,
            's' => r,
            'p' => s,
            _ => 0,
        };
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}



int main()
{
	IOS;
	ll h,w;
	cin>>h>>w;
	if(h==1||w==1)
	return cout<<1,0;
	ll n1=(w/2)+w%2;
	ll n2=(h/2)+h%2;
	ll ans=n1*n2+(w-n1)*(h-n2);
	cout<<ans;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long int A,B,C;
  cin>>A>>B>>C;
  long count=0;
  if(C>=A+B+1){
    count+=A+B+1+B;
  }
  else{
    count+=B+C;
  }
  cout<<count;
  return 0;
}

Measured memory_bytes: 3608
# ABC084C - Special Trains
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    A = tuple(tuple(map(int, input().split())) for _ in range(N - 1))
    for i in range(N):
        cur = 0
        for c, s, f in A[i:]:
            if cur <= s:
                cur = s + c
            else:
                cur = (cur + f - 1) // f * f + c  # ? (@maspy)
        print(cur)


if __name__ == "__main__":
    main()

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

int main() {
  int64_t n;
  cin>>n;
  vector<string> s(n);
  for(int i=0;i<n;i++){
    cin>>s.at(i);
  }
  int64_t M=0;
  int64_t A=0;
  int64_t R=0;
  int64_t C=0;
  int64_t H=0;
  for(int i=0;i<n;i++){
    if(s.at(i).at(0)=='M'){
      M++;
      }
    if(s.at(i).at(0)=='A'){
      A++;
      }
    if(s.at(i).at(0)=='R'){
      R++;
      }
    if(s.at(i).at(0)=='C'){
      C++;
      }
    if(s.at(i).at(0)=='H'){
      H++;
      }
    }
  int64_t count=0;
  count+=(M*A*R+M*A*C+M*A*H+M*R*C+M*R*H+M*C*H+A*R*C+A*R*H+A*C*H+R*C*H);
  cout<<count;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int l = s.size(), pA, pZ;
  bool fA = false, fZ = false;
  for(int i=0,j=l-1; i<l; ++i,--j){
    if(!fA && s[i] == 'A'){
      pA = i;
      fA = true;
    }
    if(!fZ && s[j] == 'Z'){
      pZ = j;
      fZ = true;
    }
    if(fA && fZ){
      cout << pZ-pA+1 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3696
#include <stdio.h>
int main(){
    int input;
    int i,j, cnt, sum;
    while(1){
        cnt = 0;
        scanf("%d\n",&input);
        if(input == 0) break;
        for(i=1;i<input;++i){
            sum = i;
            for(j=i+1;;++j){
                sum += j;
                if(sum > input) break;
                else if(sum == input) {
                    ++cnt;
                    break;
                }
            }
        }
        printf("%d\n", cnt);
    }
}

Measured memory_bytes: 1032
#include <iostream>
#include <cmath>
#include <string>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <queue>
using namespace std;
typedef long long ll;

int main(void) {
    set<double> swtr, ssgr;
    int i, j;
    double ans_wtr=0, ans_sgr=0;
    double a, b, c, d, e, f, ans=0;
    cin >> a >> b >> c >> d >> e >> f;
    
    for(i=0; i<=f/(100*a); i++) {
        for(j=0; 100*a*i+100*b*j<=f; j++)
            swtr.insert(100*a*i+100*b*j);
    }
    
    for(i=0; i<=f/c; i++) {
        for(j=0; c*i+d*j<=f; j++) {
            ssgr.insert(c*i+d*j);
        }
    }
    
    vector<double>wtr = vector<double>(swtr.begin(), swtr.end());
    vector<double>sgr = vector<double>(ssgr.begin(), ssgr.end());
    
    
    
    for(i=0; i<wtr.size(); i++) {
        for(j=0; j<sgr.size(); j++) {
            if(i==0 && j==0)
                continue;
            if(wtr[i]+sgr[j]<=f && e*wtr[i]>=100*sgr[j]) {
                if(sgr[j]/(wtr[i]+sgr[j])>=ans) {
                    ans=sgr[j]/(wtr[i]+sgr[j]);
                    ans_wtr=wtr[i];
                    ans_sgr=sgr[j];
                }
            }
        }
    }
    cout << ans_wtr+ans_sgr << " " << ans_sgr << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main()
{
	string s[7]={"MON","TUE","WED","THU","FRI","SAT","SUN"};
	string a;
	cin>>a;
	for(int i=0;i<7;i++)
	{
		if(s[i]==a)
		{
			if(i+1-7==0)
			{
				cout<<7;
			}
			else
			{
				cout<<abs(i+1-7);
			}
			return 0;
		}
	}
	return 0;
}


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

int main(){
	string w;
	cin >> w;
	int alp[26] = {};
	for (int i = 0; i < w.size(); i++) {
		alp[w[i] - 'a']++;
	}
	bool isOdd = false;
	for (int i = 0; i < 26; i++) {
		if (alp[i] % 2 == 1) isOdd = true;
	}
	if (isOdd) cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		long n = in.nextInt();
		int max=0,maxInd=0,nextMax = 0;

		for(int i = 1; i <= n; i++) {
			int tmp = in.nextInt();
			if(tmp > max) {
				nextMax = max;
				max = tmp;
				maxInd = i;
			}else if(tmp > nextMax) {
				nextMax = tmp;
			}
		}

		for(int i = 1; i <= n; i++) {
			int ans = (i != maxInd) ? max : nextMax;
			System.out.println(ans);
		}

	}
}


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

bool isVowel(char c) {
  string S = "aeiou";
  bool b = false;
  rep(i,S.size()) if(c==S[i]) b = true; 
  return b;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  char c; cin >> c;
  if(isVowel(c)) puts("vowel");
  else puts("consonant");

  return 0;
}


Measured memory_bytes: 256
//#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
typedef long long ll;

using namespace std;


int main() {
	string s0, s1, s2; cin >> s0 >> s1 >> s2;
	cout << s0[0] << s1[1] << s2[2] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		String[] w = new String[n];
		for (int i = 0; i < n; i++)
			w[i] = in.next();
		int flag = 0;
		
		for (int i = 0; i < n - 1; i++){
			if (w[i].charAt(w[i].length() - 1) != w[i + 1].charAt(0))
				flag++;
			for (int j = i + 1; j < n; j++){
				if (w[i].equals(w[j]))
					flag++;
			}
		}
		
		if (flag > 0)
			System.out.println("No");
		else
			System.out.println("Yes");
		

	}

}

Measured memory_bytes: 24148
#include <iostream>
#include <vector>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n, x, y;
    cin >> n >> x >> y;
    vector<int> ans(n);
    for (int i = 1; i <= n; ++i) {
        for (int j = i + 1; j <= n; ++j) ++ans.at(min(j - i, abs(i - x) + 1 + abs(j - y)));
    }
    for (int i = 1; i < n; ++i) cout << ans.at(i) << endl;
    return 0;
}


Measured memory_bytes: 256
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n =INT()

a = LIST()

occ = defaultdict(int)

for el in a:
    occ[el]+=1
flag =0
for o in occ:
    if(occ[o]>1):
        flag = 1
        break
if(flag==1):
    print("NO")
else:
    print("YES")

Measured memory_bytes: 116404
from itertools import product

n = int(input())
A = tuple(map(int, input().split(' ')))
q = int(input())
M = tuple(map(int, input().split(' ')))

numbers = set()
for bits in product((0, 1), repeat=n):
    numbers.add(sum([a * b for a, b in zip(A, bits)]))

for m in M:
    if m in numbers:
        print('yes')
    else:
        print('no')



Measured memory_bytes: 5720
#include <bits/stdc++.h>
using namespace std;
bool check(int x)
{
	int p=x, t=x%10;
	x/=10;
	while (x!=0)
	{
		if (x%10!=t) return false;
		x/=10;
	}
	return true;
}
int main()
{
	int n;
	cin >> n;
	while (!check(n)) n++;
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        System.out.println((a/b) + " " + (a % b) + " " + String.format("%.5f", ((double)a/(double)b)));
    }
}


Measured memory_bytes: 26412
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

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




/* nCr */
const long long table_size = 100005;
long long fact[table_size], finv[table_size], inv[table_size];

// 前処理
void make_table(long long mod) {
    fact[0] = fact[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (long long i = 2; i < table_size; i++){
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// nCr
long long nCr(long long n, long long r, long long mod){
    if(n < r)return 0;
    return fact[n] * (finv[r] * finv[n - r] % mod) % mod;
}

int main() {
    ll n;
    cin >> n;
    
    ll l = 0, r = 0;
    vector<ll> b(n);
    REP(i, n + 1){
        ll a;
        cin >> a;
        a--;
        if(b[a]){
            r = i;
            l = b[a] - 1;
        }
        else{
            b[a] = i + 1;
        }
    }
    
    make_table(MOD);
    
    REP(i, n + 1){
        cout << (nCr(n + 1, i + 1, MOD) - nCr(n - r + l, i, MOD) + MOD) % MOD << endl;
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define SPEED ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);

int main()
{
    SPEED;

    int d,t,s;

    cin>>d>>t>>s;

    float ans = (float)d/t;

    //cout<<ans<<"\n";

    if(ans<=s) cout<<"Yes"<<"\n";

    else cout<<"No"<<"\n";
}

Measured memory_bytes: 3644
N = int(input())
# L = []

# L = map(int, input().split())
# = list(map(int, input().split()))
L = [int(i) for i in input().split()]
#L.append(int(input()))
#s = 0
#for x in L:
    #s = s + x
#print(s)

# print(a/b)
#print(L)
s = sum(L)
m = max(L)
#print(s)
#print(m)
#f = 0
#for x in L:
#    if(x > s - x):
#        f = 1

if (m < s - m):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{     
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        var result = new List<int>();

        for(int i = 1; i <= n; i++)
        {
            if(i % 3 == 0)
            {
                result.Add(i);
                continue;
            }

            string str = i.ToString();

            if (str.Contains("3"))
            {
                result.Add(i);
            }
        }

        Console.Write(" ");
        Console.WriteLine(String.Join(" ", result));

    }
}


Measured memory_bytes: 16024
#include <bits/stdc++.h> 
using namespace std ; 
#define ll long long int 
#define pb push_back
#define ff first 
#define dobara(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define ss second 
#define S(x) scanf("%d",&x) 
#define SL(x) scanf("%lld",&x)
#define M 1000000007
#define sz(x) (int)x.size()
#define all(a) (a).begin(),(a).end()

int main(){
	ll n , ans = 0 ; 
	cin>>n ; 

	for(ll i=1;i<=sqrt(n);i++){
		if(n%i == 0){
			ll m = n/i - 1 ; 
			if(m != 0 && n/m == n%m){
				ans += m ; 
			}

			if(n/i != i){
				ll div = n/i ; 
				m = n/div - 1  ;
				if(m != 0 && n/m == n%m){
					ans += m ; 
				}
			}
		}
	}

	cout<<ans<<"\n" ; 
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.StringJoiner;

public class Main {

    private static final String BOMB = "#";

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        String[][] s = new String[h][w];
        for (int i = 0; i < h; i++) {
            s[i] = sc.next().split("");
        }

        for (int i = 0; i < h; i++) {
            StringJoiner sj = new StringJoiner("");
            for (int j = 0; j < w; j++) {
                if (s[i][j].equals(BOMB)) {
                    sj.add(BOMB);
                    continue;
                }
                int count = 0;
                if (j > 0 && s[i][j - 1].equals(BOMB)) {
                    count++;
                }
                if (j < w - 1 && s[i][j + 1].equals(BOMB)) {
                    count++;
                }
                if (i > 0 && j > 0 && s[i - 1][j - 1].equals(BOMB)) {
                    count++;
                }
                if (i > 0 && s[i - 1][j].equals(BOMB)) {
                    count++;
                }
                if (i > 0 && j < w - 1 && s[i - 1][j + 1].equals(BOMB)) {
                    count++;
                }
                if (i < h - 1 && j > 0 && s[i + 1][j - 1].equals(BOMB)) {
                    count++;
                }
                if (i < h - 1 && s[i + 1][j].equals(BOMB)) {
                    count++;
                }
                if (i < h - 1 && j < w - 1 && s[i + 1][j + 1].equals(BOMB)) {
                    count++;
                }
                sj.add(String.valueOf(count));
            }
            System.out.println(sj.toString());
        }
    }

}


Measured memory_bytes: 25428
using System;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = long.Parse(Console.ReadLine());
            var A = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
            var result = 0L;
            long MOD = 1000000007;
            for (int d = 0; d < 60; d++)
            {
                var count = 0L;
                for (int i = 0; i < N; i++)
                {
                    if ((A[i] & (1L << d)) > 0) count++;
                }
                long sub = count * (N - count);
                sub %= MOD;
                long sub2 = (1L << d) % MOD;
                result += sub2 * sub;
                result %= MOD;
            }
            Console.WriteLine(result);
        }
    }
}


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

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int ans[n+1][3];
    ans[0][0]=0;
    ans[0][1]=0;
    ans[0][2]=0;
    int t1,t2,t3;
    for(int i=1;i<=n;i++){
        cin>>t1>>t2>>t3;

        ans[i][0]=t1+max(ans[i-1][1],ans[i-1][2]);
        
        ans[i][1]=t2+max(ans[i-1][0],ans[i-1][2]);

        ans[i][2]=t3+max(ans[i-1][1],ans[i-1][0]);
        
        }
        cout<<max(ans[n][0],max(ans[n][1],ans[n][2]));
    return 0;
}

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

typedef long long int ll;

using namespace std;

char lowCaseAlpha[] = {' ', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
void fast() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int main()
{
    fast();

    //freopen("out.txt", "w", stdout);

    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll left = a + b;
    ll right = c + d;
    if (left > right)
        cout << "Left";
    else if (right > left)
        cout << "Right";
    else 
        cout << "Balanced";
    return 0;
}

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

t=[[0]*w for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j]=='.':
            for k in [(i-1,j-1),(i-1,j),(i-1,j+1),(i,j-1),(i,j+1),(i+1,j-1),(i+1,j),(i+1,j+1)]:
                if k[1]>=0 and k[1]<w and k[0]>=0 and k[0]<h:
                    if s[k[0]][k[1]]=='#':
                        t[i][j]+=1
        else:
            t[i][j]='#'

for i in range(h):
    print(*t[i],sep='')

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

int main() {
	int x, y, s;
	while(cin >> x >> y >> s, x) {
		int ans = 0;
		for(int a = 1; a <= 1000; ++a) {
			for(int b = 1; b <= 1000; ++b) {
				double f = (double)a * (100 + x) / 100.0, g = (double)b * (100 + x) / 100.0;
				if((int)floor(f) + (int)floor(g) == s) {
					ans = max(ans, (int)floor(a * (100 + y) / 100.0) + (int)floor(b * (100 + y) / 100.0));
				}
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';
int mod = 1e9 + 7;
ll inf = 1e18;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int ans = 0, tmp = 0;
    for (int i = 0; i < s.size();i++){
        if(s[i]=='A')
            tmp++;
        else if(s[i]=='G')
            tmp++;
        else if(s[i]=='C')
            tmp++;
        else if(s[i]=='T')
            tmp++;
        else
            tmp = 0;
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main(){
	int n;
	int inputa,inputb;
	int atotal,btotal;
	vector<int> a;
	vector<int> b;
	while(cin >> n, n !=0){
		a.clear();
		b.clear();
		atotal=btotal=0;
		for(int i=0;i<n;i++){
			cin>>inputa>>inputb;
			if(inputa > inputb){
				atotal += inputa + inputb; 
			}else if(inputa < inputb){
				btotal += inputa + inputb;
			}else{
				atotal +=inputa;
				btotal +=inputb;
			}
		}
		cout<<atotal<<" "<<btotal<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, b, n) for (ll i = b; i < n; ++i)

using namespace std;
using ll = long long;
using P = pair<int, int>;

void solve(ll N, ll A, ll B, ll C, ll D, ll E) {
  ll bn = min(min(min(A, B), min(C, D)), E); // bottle neck
  cout << (N / bn + (N % bn ? 1 : 0) + 4) << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll N;
  cin >> N;
  ll A;
  cin >> A;
  ll B;
  cin >> B;
  ll C;
  cin >> C;
  ll D;
  cin >> D;
  ll E;
  cin >> E;

  solve(N, A, B, C, D, E);

  return 0;
}


Measured memory_bytes: 3616
H, W, K = map(int, input().split())
field = []
t = 0
for i in range(H):
    line = list(input())
    field.append(line)
    t += line.count('#')

ans = 0
for bit in range(2 ** (H + W)):
    row = []
    col = []
    acc = 0
    for i in range(H):
        if bit & (1<<i):
            row.append(i)
    for j in range(H, H + W):
        if bit & (1<<j):
            col.append(j - H)
    for i in row:
        acc += field[i].count('#')
    for j in col:
        for i in range(H):
            acc += field[i][j] == '#'
    for i in row:
        for j in col:
            if field[i][j] == '#':
                acc -= 1
    if t - acc == K:
        ans += 1
print(ans)


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

int main(){
  ll x,y; cin>>x>>y;
  if((max(x,y)-min(x,y))<2) cout<<"Brown"<<endl;
  else cout<<"Alice"<<endl;
}


Measured memory_bytes: 256
from itertools import combinations
N = int(input())
XY = [tuple(map(int, input().split())) for _ in range(N)]
l = 0
r = 2000
for _ in range(50):
    m = (l + r) / 2
    C = []
    for (x1, y1), (x2, y2) in combinations(XY, 2):
        d = ((x1-x2)**2+(y1-y2)**2)**0.5
        if d >= 2 * m:
            l = m
            break
        h = (m ** 2 - (d / 2) ** 2)**0.5
        hx = (y2-y1)/d*h
        hy = (x2-x1)/d*h
        x = (x1 + x2)/2
        y = (y1 + y2)/2
        C.append((x+hx,y-hy))
        C.append((x-hx,y+hy))
    else:
        if any(all(((x-x0)**2+(y-y0)**2)**0.5<=m+10**-8 for x0, y0 in XY) for x, y in C):
            r = m
        else:
            l = m
print(r)

Measured memory_bytes: 3316
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int x = min(A - B, C);
  C -= x;
  cout << C << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
using namespace std;

int main(void) {
	string s;
	int x;

	cin >> s;

	x = s.length() - 2;

	cout<<s[0]<<x<<s[x+1];

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

#define rep(i,a,b) for(int i=a;i<b;i++)

const int inf = 1001001000;
const int mod = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


int main(){
    int a,b;
    cin >> a >> b;
    int count = 0;
    rep(i,a,b+1){
        vector<int> arr;
        int t = i;
        while(t){
            arr.push_back(t%10);
            t /= 10;
        }
        bool istrue = true;
        rep(j,0,2){
            if(arr[j] != arr[4-j]){
                istrue = false;
            }
        }

        if(istrue) count++;
    }
    cout << count << endl;
}




Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
 int n,m,x,y,a[100],b[100];
  cin >> n >> m >> x >> y;
  for(int i=0; i<n; i++) {
    cin >> a[i];
  }
  for(int i=0; i<m; i++) {
    cin >> b[i];
  }
  sort(a,a+n);
  sort(b,b+m);
  if(y-x>0) {
    if(min(b[0],y)-max(a[n-1],x)>0) {
      cout << "No War" << endl;
      return 0;
    }
  }
  cout << "War" << endl;
}


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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en 


constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007;

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


void Main(){
    int n;
    cin >> n;
    int ans = 0;
    int count = 0;
    REP(i, n) {
        int a,b;
        cin >> a >> b;
        if (a == b) {
            count += 1;
        } else {
            count = 0;
        }
        ans = max(ans, count);
    }
    if (ans >= 3) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}   

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}



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

int main()
{
    string s, t;
    cin >> s >> t;
    vector<int> count(1000);
    for (int i = 0; i < s.length() - t.length() + 1; i++)
    {
        string str;
        for (int j = 0; j < t.length(); j++)
        {
            str += s.at(j + i);
        }
        //cout<<str<<endl;
        if (str == t)
            break;
        else
        {
            for (int k = 0; k < t.length(); k++)
            {
                if (str.at(k) != t.at(k))
                    count.at(i) += 1;
                else
                    continue;
            }
        }
    }
    /***
    for (int i = 0; i < count.size(); i++)
    {
        cout<<count.at(i)<<" ";
    }
    cout<<endl;
    ***/
    // countの最小値
    int minc = t.length();
    for (int n = 0; n < s.length() - t.length() + 1; n++)
    {
        if (minc > count.at(n))
            minc = count.at(n);
        else
            continue;
    }
    cout << minc << endl;
    return 0;
}

Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
    int a, b;
    cin >> a >> b;
    if (a <= 5) {
        cout << 0 << endl;
    }
    else if (a >= 13) cout << b << endl;
    else cout << b / 2 << endl; 
    
    return 0;
}

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

#define F first
#define S second

#define debug(x) cerr << #x << " : " << x << endl;

#define _all(x) x.begin(), x.end()
#define _sz(x) ((int)x.size())

typedef long long ll;


// code //


void solve() {
	
	
}

int main() {
	int n;
	cin >> n;
	int a[n];
	for(int i=0; i<n; ++i) cin >> a[i];
	int m=0;
	ll sum=0;
	for(int i=0; i<n; ++i) {
		m=max(m, a[i]);
		sum += m-a[i];
	}
	cout << sum;
}


Measured memory_bytes: 4416
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <tuple>
#include <cstdio>
#include <cassert>
#include <functional>
#define _LIBCPP_DEBUG 0
using namespace std;

int main(void){
    int n;
    cin >> n;
    map<string, int> memo;
    for (int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        memo[s]++;
    }

    int max=0;
    for (auto it = memo.begin(); it!=memo.end() ; it++)
    {
        if (it->second > max)
        {
            max=it->second;
        }
    }

    for (auto it = memo.begin(); it!=memo.end(); it++)
    {
        if (it->second==max)
        {
            cout << it->first << endl;
        }
        
    }
    
}


Measured memory_bytes: 19244
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.Map;
import java.util.Map.Entry;
import java.util.TreeMap;

public class Main {
  public static void main(String[] args) throws Exception {
    
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
    
    int n = Integer.parseInt(br.readLine());
    String s;
    Map<String, Integer> map = new TreeMap<>();
    int max = 0;
    for(int i=0; i<n; i++) {
      s = br.readLine();
      int val = map.containsKey(s) ? map.get(s) + 1:1;
      map.put(s, val);
      max = Math.max(max,val);
    }
    
    br.close();
    
    for(Entry<String, Integer> entry : map.entrySet()) {
      if(entry.getValue() == max)
        bw.write(entry.getKey() + "\n");
    }
    
    bw.flush();
    
  }
}

Measured memory_bytes: 70372
#include <stdio.h>

int is_prime(int n)
{
    int i;

    if (n == 2) return 1;

    if (n % 2 == 0) return 0;

    for (i = 3; i * i <= n; i += 2) {
        if (n % i == 0)
            return 0;
    }

    return 1;
}

int main(void)
{
    int N;
    scanf("%d", &N);

    int i, n;
    int cnt = 0;

    for (i = 0; i < N; i++) {
        scanf("%d", &n);
        cnt += is_prime(n);
    }

    printf("%d\n", cnt);

    return 0;
}

Measured memory_bytes: 596
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

N,M,K=MI()
A=[0]+LI()
B=[0]+LI()
from itertools import accumulate
A=list(accumulate(A))
B=list(accumulate(B))
ans=0
b_cnt=M
for a_cnt in range(N+1):
  if A[a_cnt]>K:
    break
  while A[a_cnt]+B[b_cnt]>K:
    b_cnt-=1
  ans=max(ans,a_cnt+b_cnt)
print(ans)

Measured memory_bytes: 41156