akhauriyash/Code-Regression huggingface dataset:
use std::cmp::{max, min};
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, k: usize, h: [usize; n]);
    let mut dp = vec![vec![!0 / 10; n + 1]; n + 1];
    dp[0][0] = 0;
    for j in 1..(n - k + 1) {
        for i in 0..n {
            for k in 0..(i + 1) {
                let x = h[i].saturating_sub(if k > 0 { h[k - 1] } else { 0 });
                dp[i + 1][j] = min(dp[i + 1][j], dp[k][j - 1] + x);
            }
        }
    }
    let mut ret = !0;
    for i in 0..(n + 1) {
        ret = min(ret, dp[i][n - k])
    }
    assert_ne!(ret, !0);
    assert_ne!(ret, !0 / 10);
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


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

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  int x[N], y[M];
  for (int i = 0; i < N; i++) cin >> x[i];
  for (int i = 0; i < M; i++) cin >> y[i];

  for (int i = X + 1; i <= Y; i++) {
    bool flag = true;
    for (int j = 0; j < N; j++) if (x[j] >= i) flag = false;
    for (int j = 0; j < M; j++) if (y[j] < i) flag = false;
    if (flag) {
      cout << "No War" << endl;
      return 0;
    }
  }

  cout << "War" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(c) (c).begin(),(c).end()
#define EACH(i,c) for(auto i=(c).begin();i!=(c).end();++i)
using namespace std;
#define int long long

const long long MOD = 1000000007;

int dp[2010][2010];

void solve(long long N, long long M, std::vector<long long> S, std::vector<long long> T){
    for(int i = 0; i <= N; ++i) {
        dp[i][0] = 1;
    }
    for(int i = 0; i <= M; ++i) {
        dp[0][i] = 1;
    }

    for(int i = 0; i < N; ++i) {
        for(int j = 0; j < M; ++j) {
            dp[i + 1][j + 1] = (dp[i + 1][j] + dp[i][j + 1] - dp[i][j] + MOD) % MOD;
            if (S[i] == T[j]) {
                (dp[i + 1][j + 1] += dp[i][j]) %= MOD;
            }
        }
    }
    cout << dp[N][M] << endl;
}

signed main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> S(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&S[i]);
    }
    std::vector<long long> T(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&T[i]);
    }
    solve(N, M, std::move(S), std::move(T));
    return 0;
}


Measured memory_bytes: 31744
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int a = Integer.parseInt(str[0]);
    int b = Integer.parseInt(str[1]);
    System.out.println((a-1)*(b-1));
  }
}

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

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	int kais = 0;
	if (B / A < C) {
		cout << B / A;
	}
	else {
		cout << C;
	}
	system("pause");
	return 0;
}

Measured memory_bytes: 504
import sys
import math
import itertools
from heapq import heapify, heappop, heappush
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque


# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_SL())
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))


##### Library ####


##### main #####
def main():

    input_S = input()
    K = I() - 1

    # input_S = 'abcaa'
    # K = 2

    len_S = len(input_S)
    unique_S = len(set(input_S))
    
    lis = set()
    min_s = 'z'

    if len_S == 1:
        print(input_S)

    else:
        for i in range(5):
            for j in range(len_S):
                if input_S[j] > min_s:
                    continue

                s = input_S[j:j+i+1]
                lis.add(s)

        print(sorted(lis)[K])

   
if __name__ == '__main__':
    main()



Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
typedef long double ld;
#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define rep(i, a, b) for (ll i = a; i < (b); ++i)
#define reb(i, a, b) for (ll i = a; i >= (b); --i)
#define trav(a, x) for (auto &a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
int main()
{
// #ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
// #endif
   ll n, m;
   cin >> n >> m;
   char a[n][m];
   ll dp[n][m]={};
   memset(dp, 0, sizeof(dp));
   rep(i,0,n)
   {
      rep(j, 0, m)
      {
         cin >>a[i][j];
      }
   }
   ll ch = 1,ch1=1;
   rep(i,0,n)
   {
      if(a[i][0]=='#')
         ch = 0;
      if (a[0][i] == '#')
         ch1 = 0;
      dp[i][0] = ch;
      dp[0][i] = ch1;
   }
   // rep(i, 0, n)
   // {
   //    rep(j, 0, m)
   //    {
   //       cout << dp[i][j] << " ";
   //    }
   //    cout << endl;
   // }
         rep(i, 1, n)
         {
            rep(j, 1, m)
            {
               if (a[i][j] == '#')
                  continue;
               dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % 1000000007;
            }
         }
         cout << dp[n-1][m-1];
      }

Measured memory_bytes: 9088
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {

	private final static int MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int A = sc.nextInt();

		if (X < A) {
			System.out.println(0);
		} else {
			System.out.println(10);
		}
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	private static int add(int a, int b) {
		return (a + b) % MOD;
	}

	private static int sub(int a, int b) {
		return (a - b % MOD) % MOD;
	}

	private static int mul(int a, int b) {
		return ((a % MOD) * (b % MOD)) % MOD;
	}

	public static class Scanner {
		private BufferedInputStream inputStream;
		private StringBuilder buffer = new StringBuilder();

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
				b[i] = nextInt();
			}
		}

		public long nextLong() throws IOException {
			long num = 0;
			int sign = 1;

			int read = skip();
			if (read == '-') {
				sign = -1;
				read = inputStream.read();
			}

			do {
				num = num * 10 + sign * (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			int read = skip();
			do {
				buffer.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			String text = buffer.toString();
			buffer.delete(0, buffer.length());

			return text;
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
ll fact[100005],dp[100005];
ll mod_inv(ll n)
{
	return mod_Expo(n,mod-2,mod);
}
ll ncr(ll n,ll r)
{
	if(r==0)
	return 1;
	if(dp[n]!=-1)
	return dp[n];
	return dp[n]=((((fact[n]%mod)*(mod_inv(fact[r])%mod))%mod)*(mod_inv(fact[n-r])%mod))%mod;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll n,i,j,l,m,k;
    	cin>>n>>k;
    	ll a[n];
    	rep(i,0,n)
    	{
    		cin>>a[i];
    		dp[i]=-1;
		}
		dp[n]=-1;
		fact[0]=1;
		repi(i,1,n)
		fact[i]=(i*fact[i-1])%mod;
		sort(a,a+n);
		m=0;
		rep(i,k-1,n)
		{
			m = (a[i]*ncr(i,k-1)%mod + m%mod)%mod;
		}
		repi(i,0,n-k)
		{
			m = ((m%mod - (a[i]*ncr(n-i-1,k-1)%mod))%mod + mod )%mod;
			
		}
		cout<<m;
    }
	return 0;
}

Measured memory_bytes: 2560
package main

import "fmt"

func diff(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func main() {
	var n, l int
	fmt.Scan(&n, &l)

	sum := 0
	for i := 0; i < n; i++ {
		sum += l + i
	}

	min := diff(sum-l, sum)
	ans := sum - l
	for i := 0; i < n; i++ {
		if v := diff(sum-(l+i), sum); v < min {
			min = v
			ans = sum - (l + i)
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define N 21
using namespace std;
typedef pair<int,int> P;
int w,h,G[N][N];
string mp[N];
map<P,int>M;

void bfs(P s){
  int D[N][N];
  memset(D,-1,sizeof(D));
  queue<P> Q;
  Q.push(s);
  int x=s.first,y=s.second;
  D[y][x]=0;
  while(!Q.empty()){
    P t=Q.front();Q.pop();
    x=t.first,y=t.second;
    if(mp[y][x]=='*'||mp[y][x]=='o') G[M[s]][M[t]]=D[y][x];

    int dx[]={0,0,-1,1},dy[]={1,-1,0,0};
    for(int i=0;i<4;i++){
      int nx=x+dx[i],ny=y+dy[i],cost=D[y][x]+1;
      if(nx<0||ny<0||nx>=w||ny>=h||mp[ny][nx]=='x'||D[ny][nx]!=-1)continue;
      Q.push(P(nx,ny));
      D[ny][nx]=cost;
    }
  }
}

int n,num[11];
P start;
int calc(){
  int res=0;
  for(int i=1;i<n;i++)res+=G[num[i-1]][num[i]];
  return res;  
}

int dfs(int idx){
  if(idx==M[start]) return dfs(idx+1);
  if(idx==n) return calc();
  int res=1e9;
  for(int i=0;i<n;i++){
    if(num[i]!=-1)continue;
    num[i]=idx;
    res=min(res,dfs(idx+1));
    num[i]=-1;
  }
  return res;
}


int main(){
  while(1){
    cin>>w>>h;
    if(!w&&!h)break;
    for(int i=0;i<h;i++) cin>>mp[i];
    M.clear();
    memset(G,-1,sizeof(G));
    memset(num,-1,sizeof(num));
    n=0;
    vector<P> p;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++){
	P t=P(j,i);
	if(mp[i][j]=='*'||mp[i][j]=='o') p.push_back(t),M[t]=n++;
	if(mp[i][j]=='o') start=t;
      }
    for(int i=0;i<n;i++)bfs(p[i]);

    bool flg=1;
    for(int i=0;i<n;i++)if(G[0][i]==-1)flg=0;
    num[0]=M[start];
    cout <<(flg?dfs(0):-1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define veci(x,n) vector<int> x((int) (n))
#define vecs(x,n) vector<string> x((int) (n))
#define vecbf(x,n) vector<bool> x((int) (n), false)

int main(){
  string s;
  cin >> s;
  int len = s.size();
  int ans1 = 0;
  int ans2 = 0;
  rep(i,len){
    if(i%2 == 0 && s.at(i) != '0'){
      ans1++;
    }
    if(i%2 == 1 && s.at(i) != '1'){
      ans1++;
    }
  }
  rep(i,len){
    if(i%2 == 0 && s.at(i) != '1'){
      ans2++;
    }
    if(i%2 == 1 && s.at(i) != '0'){
      ans2++;
    }
  }
  //cout << ans1 << endl << ans2 << endl;
  cout << min(ans1,ans2) << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> PDL;
typedef pair<LD, LD> PDD;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

template<class T>
void in(T& x) {
	cin >> x;
}

template<class T1,class T2>
void in(pair<T1, T2>& p) {
	in(p.first);
	in(p.second);
}

template<class T>
void in(vector<T>& v,LL st=-1,LL en=-1) {
	if (st == -1) {
		st = 0;
		en = v.size() - 1;
	}
	for (LL n = st; n <= en; n++) {
		in(v[n]);
	}
}

void modinvs(long long N, vector<long long>& inv, vector<long long>& sinv, long long mod = 1e9 + 7) {
	inv.resize(N + 1);
	sinv.resize(N + 1);
	inv[1] = 1;
	sinv[0] = 1;
	sinv[1] = 1;
	for (int n = 2; n <= N; n++) {
		inv[n] = mod - (inv[mod % n] * (mod / n)) % mod;
		sinv[n] = (sinv[n - 1] * inv[n]) % mod;
	}
}

LL modpow(LL base, LL p) {
	if (p == 0)return 1;
	if (p == 1)return base;
	LL temp = modpow(base, p / 2);
	temp = (temp * temp) % MOD;
	if (p & 1)temp = (temp * base) % MOD;
	return temp;
}

LL st(LL en,LL st = 1) {
	LL ans = st;
	for (LL n = st+1; n <= en; n++) {
		ans = (ans * n) % MOD;
	}
	return ans;
}

LL Comb(LL n, LL k, VLL& st, VLL& sinv) {
	LL ans = (st[n] * sinv[n - k]) % MOD;
	ans = (ans * sinv[k]) % MOD;
	return ans;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL N, K;
	cin >> N >> K;
	if (K >= N)K = N-1;
	VLL st(N + 1,1);
	for (LL n = 2; n <= N; n++) {
		st[n] = (st[n - 1] * n) % MOD;
	}
	VLL inv, sinv;
	modinvs(N, inv, sinv);
	LL ans = 0;
	for (LL k = 0; k <= K; k++) {
		LL temp = Comb(N - 1, N - k - 1, st, sinv);
		temp = (temp * Comb(N, k, st, sinv)) % MOD;
		ans += temp;
	}
	ans %= MOD;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 4992
a = [input().split() for l in range(2)]

N = int(a[0][0]) 
M = int(a[0][1]) 
X = int(a[0][2]) # current place 

goal_len01 = N - X # end place
goal_len02 = X # start place

cost1 = 0
for i in range(goal_len01):
  if str(X+i+1) in a[1]:
    cost1 += 1

cost2 = 0
for i in range(goal_len02):
  if str(i+1) in a[1]:
    cost2 += 1

min_cost = 0
if cost1 >= cost2:
  min_cost = cost2
else:
  min_cost = cost1
  
print(min_cost)

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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef std::pair<ll, ll> PLL;


ll INF = 1LL << 60;
// dp[i][x][y]: i番目の薬品を使った時、物質aがx g、物質bが y gの時の最小コスト
ll dp[50][500][500];

signed main() {
    ll N,MA,MB;
    rep(i,0,50) rep(x,0,500) rep(y,0,500) dp[i][x][y]=INF;
    dp[0][0][0] = 0;
    cin>>N>>MA>>MB;
    rep(i,1,N+1){
        ll a,b,c;
        cin>>a>>b>>c;
        rep(x,0,500) rep(y,0,500) {
            if (dp[i-1][x][y]==-1)
                continue;
            dp[i][x][y] = min(dp[i][x][y], dp[i-1][x][y]);
            dp[i][x+a][y+b] = min(dp[i][x+a][y+b], dp[i-1][x][y] + c);
        }
    }
    ll ans = INF;
    rep(x,1,500) rep(y,1,500) {
        ll c = dp[N][x][y];
        if (c == INF)
            continue;
        if (x * MB == y * MA)
            ans = min(ans, c);
    }
    if (ans==INF){
        cout<<-1<<endl;
    }else{
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 97920
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
int  a;
double b;
using namespace std;
int main () {
	cin>>a;
	if(a % 2==0) printf("0.500000000\n");
	
	else {
	b=a;
	printf("%.8lf",((b+1)/2)/b);	
	}
	return 0;
}

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

int main(){
    int n;
    std::cin >> n;
    std::vector<int> p(n);
    for(int i = 0; i < n; i++) std::cin >> p[i];
    int cnt = 0;
    for(int i = 0; i + 2 < n; i++){
        int maxp = std::max({p[i], p[i + 1], p[i + 2]});
        int minp = std::min({p[i], p[i + 1], p[i + 2]});
        if(minp < p[i + 1] && p[i + 1] < maxp) cnt++;
    }
    std::cout << cnt << std::endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7,MAX = 1e5;

int main()
{
	string s;
	cin >> s;
	int n;
	cin >> n;
	for(int j = 0;j<n;j++)
	{
		string op;
		int a,b;
		cin >> op;
		cin >> a >> b;
		if(op=="print")
		{
			for(int i = a;i<=b;i++)
			{
				cout<<s[i];
			}
			cout<<endl;
		}
		else if(op=="reverse")
		{
			for(int i = 0;i<=(b-a)/2;i++)
			{
				swap(s[a+i],s[b-i]);
			}
		}
		else
		{
			string t;
			cin >> t;
			for(int i=a;i<=b;i++)
			{
				//cout<<b<<endl;
				s[i]=t[i-a];
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3212
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
//using ll=long long;
//#define int long long
#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279; //円周率
/*---------------------便利な関数--------------------------------------*/
int fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}

int gcd(int a, int b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}

int lcm(int a, int b) {      //最小公倍数
    return a * b / gcd(a, b);
}

int keta(int n) {        //桁数を求める
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}

int ketasum(int n) {    //各桁の和
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
//最小化問題(DP)
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
//最大化問題(DP)
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//dp注意点
//問題の種類	 初期化する値	 備考
//最小化問題 	INF	
//最大化問題	    -INF	 テーブル全体で 00 以上の値しかとらないことがわかっていれば −1−1 でもいいですし、00 でもいい場合もあります
//数え上げ問題	00	
//確率問題	      00	
//Yes/No 判定問題	False
/*-------------ここまで---------------------------------------------*/

/*signed*/int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << a + b + c - max({ a,b,c }) << endl;
    return 0;
}

Measured memory_bytes: 3624
s = list(input())
t = list(input())
n = len(s)

s_par = [i for i in range(n + 1)]
t_par = [i for i in range(n + 1)]

for i in range(n):
    for j in range(i):
        if s[i] == s[j]:
            s_par[i] = s_par[j]
            break
            
for i in range(n):
    for j in range(i):
        if t[i] == t[j]:
            t_par[i] = t_par[j]
            break
            
if s_par == t_par:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 28112
import sys

change = False
debug = False


def print_err(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)


def main():
    """
    0 と 1 からなる文字列 S が与えられます。
    以下の操作を好きな回数繰り返すことで S の要素をすべて 0 にできるような、|S| 以下の最大の整数 K を求めてください。
    S の長さ K 以上の連続する区間 [l,r] を選ぶ(すなわち、r−l+1≥K が満たされる必要がある)。
    l≤i≤r なるすべての整数 i に対し、Si が 0 なら Si を 1 に、Si が 1 なら Si を 0 に置き換える。
    制約
    1≤|S|≤105
    Si(1≤i≤N) は 0 または 1 である
    """
    S = input()

    f(S)


def f(S):
    """
    最大となるKより、1つずつ変えるのは最後の手段
    ※K以上の反転可能であるため

    000: OK
    001, 110:  -> 100, 011
    010, 101:
      11を最終的に反転するように修正していく
        101: 1-3 all
        011: 1-2
        000: 2-3
    011, 100: 11を反転でOK

    0001 となっているとき
    K=3とすれば
    000 をまず反転、その後K+1まで反転すれば、初期状態からK+1番目のみ反転できる
    """
    n = len(S)
    ans = n

    # 反転確認
    table = str.maketrans('01', '10')
    for k in range(1, n):
        if S[k] == S[k - 1]:
            continue

        t = max(k, n - k)
        ans = min(ans, t)

        # 反転を利用して異なる部分を変更
        # 要素数の多い方を対称の異なる文字含めて反転

        # CPython3, PyPy: TLE
        if change:
            if t == k:
                S = S[:t].translate(table) + S[t:]
            else:
                S = S[:k] + S[k:].translate(table)

            if debug:
                print_err("t:", t, "k:", k, "S:", S, sep="\t")

    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3364
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
#define rep(i,n) for(i = 0; i < (n); ++i)
#define rrep(i,n) for(i = 1; i <= (n); ++i)
#define drep(i,n) for(i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define Sort(a) sort(a.begin(),a.end())
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z main.cpp
//./a.exe

bool isPrime(int x){
    int i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
  int i=0,ans=0,A=0;
  string s;
  cin >> s;
  rep(i,s.size()){
      if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T'){
        ans ++; 
        if(ans>A){
        A=ans;
        }
      }
          else{ans=0;
              
          }
           
          
        }

        ans=max({A,0});  
        cout << A << endl;
        
  



//////////////////////////////////////////////////////
return 0;}

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


int main() {
    int64_t x, k, d;
    cin >> x >> k >> d;

    if (x < 0) x = -x;
    int64_t res = 0;
    if (x / d > k) {
        res =  x - k * d;
        cout << res << endl;
        return 0;
    }

    //　原点はさんでちょこまかするパタン
    int64_t restK = k - abs(x) / d;
    if (restK % 2 == 0) {
        res = abs(x - d * (k - restK));
    } else {
        res = abs(x - d * (k - restK + 1));
    }
    cout << res << endl;
    return 0;

}


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

int main(){
  int N,D,X;
  cin >> N >> D >> X;
  vector<int> a(N);
  for (int i = 0; i < N; i++) cin >> a.at(i);
  for (int i = 0; i < N; i++){
    if (D % a.at(i) != 0) X++;
    X += D / a.at(i);
  }
  cout << X << endl;
}

Measured memory_bytes: 256
n, y = map(int, input().split())

for i in range(n+1):
  for j in range(n-i+1):
    if 10000*i + 5000*j + 1000*(n-i-j) == y:
      print(i, j, (n-i-j))
      exit()
      
print(-1, -1, -1)

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF             2e9
#define INF_LL          1LL<<60
#define ll              long long
#define Ceil(x, n)      (((((x))+((n)-1))/n))
#define CeilN(x, n)     (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)    ((x)-(x)%(n))
#define ALL(x)          (x).begin(),(x).end()
typedef pair<ll, ll>    P;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    REP(i, n) {
        if(a[i] % 2 == 1) {
            cout << "first" << endl;
            return 0;
        }
    }

    cout << "second" << endl;
    return 0;
    return 0;
}

Measured memory_bytes: 640
let main () =
  let (a, b,c ,d) = Scanf.scanf "%d %d %d %d" (fun a b c d -> (a, b, c, d)) in
  if (abs @@ (-) a b <= d && abs @@ (-) b c <= d) || abs @@ (-) a c <= d then
    print_string "Yes\n"
  else
    print_string "No\n"

let () = main ()


Measured memory_bytes: 384
n,m = map(int,input().split())
d = {str(x):[] for x in range(1,n+1)}
n = str(n)
ans = "IMPOSSIBLE"
for i in range(m):
    t = input().split()
    d[t[0]].append(t)

for l1 in d["1"]:
    if l1[1]==n:
        ans="POSSIBLE"
    else:
        for l2 in d[l1[1]]:
            if l2[1]==n:
                ans="POSSIBLE"
print(ans)

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

using namespace std;

int main()
{
	int h, w;
	
	while(true)
	{
		scanf("%d %d", &h, &w);
		
		if(h == 0 && w == 0)
			break;
		
		cout << string(w, '#') << "\n" << '#';
		for(int i = 0; i < h-2; i++)
			cout << string(w-2, '.') << '#' << "\n" << '#';
		cout << string(w-1, '#') << "\n\n";
	}
	return 0;
}


Measured memory_bytes: 3140
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;

vector<ll> fact(2e6 + 1, 1);

ll fastpow(ll base, ll idx)
{
	ll ret = 1;
	while(idx)
	{
		if(idx & 1) ret = (ret * base) % MOD;
		base = (base * base) % MOD;
		idx /= 2;
	}
	return ret;
}

ll ncr(ll n, ll r)
{
	ll ret = (fact[n] * fastpow(fact[n - r], MOD - 2)) % MOD;
	return (ret * fastpow(fact[r], MOD - 2)) % MOD;
}

int main()
{
	#ifndef ONLINE_JUDGE
	freopen(".in.txt", "r", stdin);
	freopen(".out.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	for(ll i = 1; i < 2e6 + 1; i++) fact[i] = (fact[i - 1] * i) % MOD;
	ll k, c = 0; cin >> k;
	string s; cin >> s;
	for(int i = 0; i < s.size(); i++)
		c += (ncr(s.size() + k, i) * fastpow(25, s.size() + k - i)) % MOD;
	cout << (((fastpow(26, s.size() + k) - c) % MOD) + MOD) % MOD;

	return 0;
}

Measured memory_bytes: 19880
import bisect
N = int(input())
A = sorted(list(map(int,input().split())))
B = sorted(list(map(int,input().split())))
C = sorted(list(map(int,input().split())))
count = 0
for i in range(N):
    b = B[i]
    cind = bisect.bisect_right(C,b)
    aind = bisect.bisect_left(A,b)
    count+=(N-cind)*aind
print(count)

Measured memory_bytes: 23092
import java.util.Scanner;

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

        int house[][][];
        house = new int[4][3][10];
        for(int h=0;h<4;h++){
          for(int i=0;i<3;i++){
            for(int j=0;j<10;j++){
              house[h][i][j] = 0;
            }
          }
        }

        for(int m=1;m<=n;m++){
          int b = sc.nextInt();
          int f = sc.nextInt();
          int r = sc.nextInt();
          int v = sc.nextInt();
          house[b-1][f-1][r-1] = house[b-1][f-1][r-1] + v;
        }
      for(int h2=0;h2<4;h2++){
        for(int i2=0;i2<3;i2++){
          for(int j2=0;j2<10;j2++){
            System.out.print(" " + house[h2][i2][j2]);
          }
          System.out.println("");
        }
        if(h2 != 3){
          for(int x=1;x<=20;x++){
          System.out.print("#");
          }
        }
        if(h2 != 3){
        System.out.println("");
      }
      }
    }
}


Measured memory_bytes: 29796
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    
    if(a == b && b != c || a == c && b != a || b == c && b != a) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

void call(int n, int c){
  static int i, x;
  bool end = false;

  if(c != 2){
    if(!c) i = 1;
    x = i;
    if(x % 3 == 0){
      cout << " " << i;
      end = true;
    }
  }
  if(x % 10 == 3 && !end){
    cout << " " << i;
    end = true;
  }
  if(!end){
    x /= 10;
    if(x){ 
      call(n, 2); 
    }
  }

  if(++i <= n){ 
    call(n, 1); 
  }
}

int main(){
  int n;
  cin >> n; call(n, 0);
  cout << endl;

  return 0;
}

Measured memory_bytes: 1648
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
#define LP(i, a, b) for (int i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (int i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-13

#define INF 1e16
const int MaxSize = 3000 + 10;
const LL MOD = 1e9 + 7;

int N, T, A[MaxSize], B[MaxSize], pref[MaxSize][MaxSize],
		suff[MaxSize][MaxSize];

void precalc() {
	LPE(i, 0, N)
	{
		memset(pref[i], 0, sizeof(suff[i]));
		memset(suff[i], 0, sizeof(suff[i]));
	}

	LPE(i, 1, N)
	{
		LP(t, 1, T)
		{
			pref[i][t] = max(pref[i][t], pref[i - 1][t]);

			if (t >= A[i]) {
				pref[i][t] = max(pref[i][t], pref[i - 1][t - A[i]] + B[i]);
			}
		}
	}

	for (int i = N; i >= 1; i--) {
		LP(t, 1, T)
		{
			suff[i][t] = max(suff[i][t], suff[i + 1][t]);

			if (t >= A[i]) {
				suff[i][t] = max(suff[i][t], suff[i + 1][t - A[i]] + B[i]);
			}
		}
	}
}

int main() {

	ios_base::sync_with_stdio(false);
	//freopen("/Users/georgeli/pycp/A_1.in", "r", stdin);
	cin >> N >> T;
	LPE(i, 1, N)
	{
		cin >> A[i] >> B[i];
	}

	precalc();

	int ans = 0;
	LPE(li, 1, N)
	{
		LP(pt, 0, T)
		{
			ans = max(ans, pref[li - 1][pt] + suff[li + 1][T - 1 - pt] + B[li]);
		}
	}

	cout << ans;

	return 0;
}



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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define MAXN 11111

const int INF = 1 << 29 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int main() {
    ios::sync_with_stdio(0) ;
    int n , y ,z ;
    cin >> n >> y ;

    for(int i =0 ;i<=n ;i++) {
        for(int j = 0 ;j<=n ;j++) {
            z = n -i - j ;
            if(z<0) continue ;
            if(z*1000 + i*10000 + j*5000 == y) {
                cout << i << ' ' << j << ' ' << z << endl ;
                return 0 ;
            }
        }
    }
    cout <<"-1 -1 -1" <<endl ;
    return 0 ;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int MAX_N = 102345;
int n, stone[MAX_N], f[MAX_N];

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> stone[i];
    f[1] = 0;
    f[2] = abs(stone[2] - stone[1]);
    for (int i = 3; i <= n; i++) {
        f[i] = min(f[i - 1] + abs(stone[i] - stone[i - 1]), f[i - 2] + abs(stone[i] - stone[i - 2]));
    }
    cout << f[n] << endl;
    return 0;
}

Measured memory_bytes: 4400
import java.util.InputMismatchException;
import java.util.Scanner;

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

        try{
            int a = scan.nextInt();
            int b = scan.nextInt();
            System.out.println((a*b)+ " " +2*(a+b));
        }catch(InputMismatchException e){
            System.out.println(e);
        }
    }
}


Measured memory_bytes: 26428
// Numeric

// 整数論

#include<vector>
#include<set>

// 素因数分解：力任せ
std::vector<int> prime_factor(const int n) {
    int tmp = n;
    std::vector<int> result;
    for(int i = 2; i * i <= n; ++i) {
        while(!(tmp % i)) {
            tmp /= i;
            result.push_back(i);
        }
    }
    if(tmp != 1) result.push_back(tmp);
    return result;
}

// 素数判定：Sieve of Eratosthenes
std::vector<bool> Eratosthenes(const int n) {
    std::vector<bool> is_prime(n + 1, true);
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; is_prime[i] && i * i <= n; ++i)
        for(int j = i * i; j <= n; j += i)
            is_prime[j] = false;
    return is_prime;
}

// べき乗：繰り返し二乗法
int power(const int m, const int n) {
    if(!n) return 1;
    if(n & 1) return power(m, n - 1) * m;
    return power(m * m, n >> 1);
}

int mod_power(const long long int m, const long long int n, const int mod) {
    if(!n) return 1;
    if(n & 1) return mod_power(m, n - 1, mod) * m % mod;
    return mod_power(m * m % mod, n >> 1, mod) % mod;
}

// 最大公約数：Euclidean algorithm
int gcd(const int m, const int n) {
    return n ? gcd(n, m % n) : m;
}

// 最小公倍数
int lcm(const long long int m, const long long int n) {
    return m * n / gcd(m, n);
}

// m x + n y = gcd(m, n) であるような x, y, gcd を求める：Extended Euclidean algorithm
struct ExtendedGCD {int x, y, gcd;};
ExtendedGCD extended_gcd(const int m, const int n, const int x = 1, const int xx = 0, const int y = 0, const int yy = 1) {
    if(!n) return {x, y, m};
    return extended_gcd(n, m % n, xx, x - m / n * xx, yy, y - m / n * yy);
}

// 自然数 n と互いに素な n 以下の自然数の個数：Euler's totient function
int phi(const int n) {
    int answer = n;
    auto list = prime_factor(n);
    for(auto i: std::set<int>(list.begin(), list.end())) answer -= answer / i;
    return answer;
}

////////////////////////////////////////////////////////////////////////////////

#include<iostream>
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    auto res = extended_gcd(a, b);
    cout << res.x << " " << res.y << endl;
}

Measured memory_bytes: 1172
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int n; cin >> n;
    int b[n];
    int lt=(n%2 ? n/2 : n/2 -1), rt = (n%2 ? n/2 +1 : n/2);
    REP(i, n){
        int a; cin >> a;
        if((n-i)%2) b[lt--] = a;
        else b[rt++] = a;
    }
    REP(i, n){
        if(i) cout << " ";
        cout << b[i];
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N, K; cin >> N >> K;
	vector<ll> D(K);
	for (int i = 0; i < K;i++)cin >> D[i];
	while (true) {
		bool f = false;
		ll t = N;
		while (t) {
			ll q = t % 10;
			if (find(D.begin(), D.end(), q) != D.end()) {
				f = true;
				break;
			}
			t /= 10;
		}
		if (!f) {
			cout << N << endl;
			return 0;
		}
		N++;
	}
}

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

using namespace std;

int main()
{
    char str[4], str2[4];
    scanf("%s%s", str, str2);
    reverse(str, str + 3);
    if(strcmp(str, str2) == 0)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string.h>

int main(void)
{
    char buffer[1000000], *p;
    size_t i = 0;
    int ac_count = 0;
    int wa_count = 0;
    int tle_count = 0;
    int re_count = 0;

    // input
    if (scanf("%1000000[\x01-\xff]", buffer) != 1) {
        return 1;
    }

    // output
    for (i = 0, p = strtok(buffer, "\n"); p; ++i, p = strtok(NULL, "\n")) {
        // if(i == 0){ printf("%s\n", p); }
        // printf("%s\n", p);
        if(strcmp(p, "AC") == 0){ ac_count++; }
        if(strcmp(p, "WA") == 0){ wa_count++; }
        if(strcmp(p, "TLE") == 0){ tle_count++; }
        if(strcmp(p, "RE") == 0){ re_count++; }
    }

    printf("AC x %d\n", ac_count);
    printf("WA x %d\n", wa_count);
    printf("TLE x %d\n", tle_count);
    printf("RE x %d\n", re_count);

    return 0;
}


Measured memory_bytes: 2064
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int m = scanner.nextInt();
		int brd = Math.abs(n - m);
		long ans = 0;
		int mod = (int) (Math.pow(10, 9) + 7);

		if (brd >= 2) {
			ans = 0;
		} else if (brd == 0) {
			ans = kaijoEx(n, mod) * kaijoEx(m, mod) * 2 % mod;
		} else {
			ans = kaijoEx(n, mod) * kaijoEx(m, mod) % mod;
		}

		System.out.println(ans);
	}

	static long kaijoEx(int m, int mod) {
		long s = 1;
		for (int i1 = 1; i1 <= m; i1++)
			s = (long) ((s * i1) % mod);
		return s;
	}
}


Measured memory_bytes: 23380
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	vector<int> A(N);
	vector<int> B(M);
	int res = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < M; i++) {
		cin >> B[i];
	}
	vector<vector<int> > dp(N + 1, vector<int>(M + 1, 0));


	for (int i = 0; i <= N; i++) {
		dp[i][0] = 1;
	}
	for (int i = 0; i <= M; i++) {
		dp[0][i] = 1;
	}

	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= M; j++) {
			dp[i][j] = dp[i - 1][j] + dp[i][j - 1];
			if (A[i - 1] != B[j - 1]) {
				dp[i][j] -= dp[i - 1][j - 1];
			}
			dp[i][j] = (dp[i][j] + 10 * MOD) % MOD;
		}
	}
	cout << dp[N][M] << endl;
}

Measured memory_bytes: 31616
#include<cstdio>
using namespace std;
int n,m;
int main()
{
	scanf("%d%d",&n,&m);
	for(register int x=0;x<=n;x++)
		for(register int y=0;y<=n;y++)
				if(x*10000+y*5000+(n-x-y)*1000==m && x>=0 && y>=0 && n-x-y>=0)
				{
					printf("%d %d %d",x,y,n-x-y);
					return 0;
				}
	printf("-1 -1 -1");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include <stdio.h>
using namespace std;
typedef long long LL;
const int MAX = 1000020;
LL N;
LL a[MAX],b[MAX],c[MAX];

void Cin(LL a[])
{
    for(int i = 1;i<=N;i++) scanf("%lld",&a[i]);
}

int main()
{
    cin>>N;
    Cin(a),Cin(b),Cin(c);
    sort(a+1,a+1+N),sort(b+1,b+1+N),sort(c+1,c+1+N);
    LL sum = 0;
    LL ai = 0,ci = 0;
    for(int i = 1;i<=N;i++){
        while(a[ai+1]<b[i]&&ai+1<=N) ai++;
        while(c[ci+1]<=b[i]&&ci+1<=N) ci++;
        sum += ai*(N-ci);
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 9216
def solve(s)
  return false unless s[0] == 'A'

  t = s[2..-2]
  return false unless t.count('C') == 1

  x = t.index('C') + 2
  (0...s.size).each do |i|
    next if i == 0 || i == x
    return false unless s[i] == s[i].downcase
  end

  true
end

s = gets.chomp
puts solve(s) ? 'AC' : 'WA'


Measured memory_bytes: 1788
N = int(input())
Vs = list(map(int, input().split()))
Cs = list(map(int, input().split()))

diff = []
for i in range(N):
    diff.append(Vs[i]-Cs[i])
ans = 0
for i in range(N):
    if diff[i] > 0:
        ans += diff[i]
    else:
        pass
print(ans)


Measured memory_bytes: 3060
import bisect
import cmath
import heapq
import itertools
import math
import operator
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter, mul, add, xor

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N, M, C = list(map(int, sys.stdin.buffer.readline().split()))
B = list(map(int, sys.stdin.buffer.readline().split()))
A = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(N)]

B = np.array(B, dtype=int)
A = np.array(A, dtype=int)

ok = (A * B).sum(axis=1) + C > 0
print(ok.sum())


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

int main() {
  ll n;cin>>n;
  int ans=1e9;
  for(int i=1;i<=sqrt(n);i++){
    ll j;
    if(n%i==0)j=n/i;
    string I=to_string(i),J=to_string(j);
    int a=I.size(),b=J.size();
    int f=max(a,b);
    ans=min(ans,f);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define sort(v) sort(all(v))
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main() {
    IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
	    string s;
	    cin>>s;
	    if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes\n";
	    else cout<<"No\n";
	}
	return 0;
}

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

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

    vector<int> a(n);
    int max1 = 0, max2 = 0;
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
        if (a.at(i) > max1) {
            max2 = max1;
            max1 = a.at(i);
        } else if (a.at(i) == max1 || a.at(i) > max2) {
            max2 = a.at(i);
        }
    }

    for (int i = 0; i < n; i++) {
        if (a.at(i) == max1) {
            cout << max2 << endl;
        } else {
            cout << max1 << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 4056
<?php
$n=trim(fgets(STDIN));
$a=1;
$ans=0;
while($a<=ceil($n/2)){
  $b=$a;
  while($a*$b<$n){
    $ans+=2;
    if($a==$b){
      --$ans;
    }
    ++$b;
  }
  ++$a;
}
echo $ans;

Measured memory_bytes: 16216
import sys
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False

def ddprint(x):
  if DBG:
    print(x)

n,m = inm()
a = inl()
h = {}
h[0] = 1
acc = [0]*(n+1)
for i in range(n):
    acc[i+1] = x = (acc[i]+a[i])%m
    if x in h:
        h[x] += 1
    else:
        h[x] = 1
sm = 0
for x in h:
    sm += h[x]*(h[x]-1)//2
print(sm)


Measured memory_bytes: 62576
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
//#include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    int N, K; cin >> N >> K;
    string S; cin >> S;
    string compress;
    for (int i = 0; i < N; i++) {
        if (i != 0 && S[i] == S[i-1]) continue;
        compress.push_back(S[i]);
    }
    int unhappy = 0;
    for (int i = 0; i < compress.size() - 1; i++) {
        if (compress[i] == 'R' && compress[i+1] == 'L') {
            K--;
            if (K < 0) unhappy += 2;
        }
    }
    if (compress[0] == 'L' && compress[compress.size() - 1] == 'R') {
        unhappy += 2;
        if (K > 0) unhappy--;
    } else if (compress[0] == 'L' || compress[compress.size() - 1] == 'R') {
        unhappy++;
    } else {
        if (K > 0) unhappy++;
    }
    cout << N - unhappy << endl;
}


Measured memory_bytes: 704