akhauriyash/Code-Regression huggingface dataset:
uses
	SysUtils,
	Classes;

procedure MainProc;
	var
		text : string;
		strlist : TStringList;
		numA, numB, ans: Integer;
	begin
	ReadLn(text);
	strlist := TStringList.Create;
	
	try
		strlist.Delimiter := ' ';
		strlist.DelimitedText := text;
		numA := StrToInt(strlist.Strings[0]);
		numB := StrToInt(strlist.Strings[1]);
	finally
			FreeAndNil(strlist);
			end;
	ans := (numA * numB) mod 2;
	if ans = 1 then
		WriteLn('Yes')
	else
		WriteLn('No');
	end;

begin
MainProc;
end.

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int max = 0;
		int sum = 0;
		int num = 0;
		int tmp = 0;
		int N = scan.nextInt();
		for(int i =N; i > 0; i--) {
			tmp = i;
			while(true) {
				if(tmp % 2 == 0 && tmp > 0) {
					sum++;
					tmp /= 2;
				} else {
					if(max <= sum) {
						max = sum;
						num = i;
					}
					sum = 0;
					break;
				}
			}
		}
		System.out.println(num);
		scan.close();

	}

}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
#define N 155 
using namespace std;
typedef long long ll;
int n,k;
ll mod;

namespace s1
{	
	ll f[N][N][N],ans;
	void solve()
	{
		f[0][0][0] = f[1][0][0] = f[1][1][0] = 1;
		for(int i=2;i<=n;++i)
		{
			if(i & 1) for(int j=0;j<=k / 2;++j) 
			{
				for(int t=0;t<=k / 2;++t)
				{
					if(t + 1 <= k / 2) f[i][t + 1][j] = (f[i][t + 1][j] + f[i - 1][t][j]) % mod;
					f[i][0][j] = (f[i][0][j] + f[i - 1][t][j]) % mod;
				}
			}
			else for(int j=0;j<=k / 2;++j)
			{
				for(int t=0;t<=k / 2;++t)
				{
					if(t + 1 <= k / 2) f[i][j][t + 1] = (f[i][j][t + 1] + f[i - 1][j][t]) % mod;
					f[i][j][0] = (f[i][j][0] + f[i - 1][j][t]) % mod;
				}
			}
		}
		for(int i=0;i<=k / 2;++i)
		  for(int j=0;j<=k / 2;++j)
		    ans = (ans + f[n][i][j]) % mod;
		cout<<ans<<endl;
	}
}
namespace s2
{
	ll f[N][N][N],ans;
	void solve()
	{
		f[0][0][0] = 1;
		for(int i=2;i - k < 0;i+=2)//先处理只有右边的一段 
		{
			int now = i / 2;
			for(int j=0;j<now;++j) f[now][0][0] = (f[now][0][0] + f[now - 1][0][j]) % mod;
			for(int j=0;j<now;++j) f[now][0][j + 1] = (f[now][0][j + 1] + f[now - 1][0][j]) % mod;
		} 
		int las = 0;
		for(int i=1;i<=n;i+=2)
		{
			int now = (i + k) / 2;
			las = now;
			//都不选
			for(int j=0;j<=k + 1;++j) 
			  for(int t=0;t<now;++t)
			    f[now][0][0] = (f[now][0][0] + f[now - 1][j][t]) % mod;
			//只选左边
			for(int j=0;j<=k;++j) 
			  for(int t=0;t<now;++t)
			    f[now][j + (j!=0)][0] = (f[now][j + (j!=0)][0] + f[now - 1][j][t]) % mod;
			if(i + k > n) continue;
			//只选右边	
			for(int j=0;j<=k + 1;++j) 
			  for(int t=0;t<now;++t)
			    f[now][0][t + 1] = (f[now][0][t + 1] + f[now - 1][j][t]) % mod;
			//两边都选
			for(int j=0;j<=k;++j) 
			  for(int t=0;t<now;++t)
			    if(t + 2 <= k + 1) f[now][max(j + (j!=0),t + 2)][t + 1] = (f[now][max(j + (j!=0),t + 2)][t + 1] + f[now - 1][j][t]) % mod;
		}
		for(int i=0;i<=k + 1;++i)
		  for(int t=0;t<=las;++t)
		    ans = (ans + f[las][i][t]) % mod;
		cout<<ans<<endl;
	}
}

int main()
{
	cin>>n>>k>>mod;
	if(!(k & 1)) s1::solve();
	else s2::solve();
	return 0;
}

Measured memory_bytes: 28928
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    List = [1]

    for i in range(1, 7):
        List.append(pow(6, i))
        List.append(pow(9, i))

    List.sort()
    dp = [f_inf for _ in range(n + 1)]
    dp[0] = 0

    for i in range(1, n + 1):
        for L in List:
            if i - L >= 0:
                dp[i] = min(dp[i], dp[i - L] + 1)

    print(dp[n])


if __name__ == '__main__':
    resolve()


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

void downTo(vector<int> &vs, int s, int t) {
    while (s >= t) {
        vs.push_back(s--);
    }
}

void upTo(vector<int> &vs, int s, int t) {
    while (s <= t) {
        vs.push_back(s++);
    }
}

int main() {
    int n;
    while (cin >> n) {
        while (n--) {
            int s, t;
            cin >> s >> t;
            vector<int> ans;
            if (s <= 5) {
                if (s < t) {
                    upTo(ans, s, t);
                } else {
                    downTo(ans, s, t);
                }
            } else {
                if (s < t) {
                    upTo(ans, s, t);
                } else {
                    upTo(ans, s, 9);
                    if (t < 6) {
                        downTo(ans, 5, t);
                    } else {
                        downTo(ans, 5, 0);
                        upTo(ans, 1, t);
                    }
                }
            }
            cout << ans[0];
            for (int i = 1, size = ans.size(); i < size; i++) {
                cout << " " << ans[i];
            }
            cout << endl;
        }
    }
}

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

int main(){
    long long h,w;
    cin >> h>>w;
    if(h>1&&w>1){
    cout << (h*w+1)/2 <<endl;
}else{
    cout << 1 <<endl;
}    return 0;


}

Measured memory_bytes: 256
from collections import deque

n, q = map(int, input().split())
listA = []
t=1
while t <=n:
    try:
        listA.append(input().split())
        t +=1
    except:
        break

result=[]
qu = deque()
for i in range(n):
    qu.append(listA[i])

time = 0
while True:
    try:
        task = qu.popleft()
        if int(task[1]) <= q:
            time += int(task[1])
            result.append([task[0], time])
        else:
            time += q
            task[1] = int(task[1]) - q
            qu.append(task)
    except:
        break


for i in range(n):
    print(*result[i])
    



Measured memory_bytes: 23488
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int H,W,K;
    cin >> H >> W >> K;
    vector<string>c(H);
    for(int i = 0; i < H; i++) {
        cin >> c[i];
    }
    int ans = 0;
    for(int bit = 0; bit < (1 << (H+W)); bit++) {
        int cnt = 0;
        for(int i = 0; i < H; i++) {
            if(bit & (1 << i)) {
                continue;
            }
            else {
                for(int j = H; j < H+W; j++) {
                    if(bit & (1 << j)) {
                        continue;
                    }
                    else {
                        if(c[i][j-H] == '#') {
                            cnt++;
                        }
                    }
                }
            }
        }
        if(cnt == K) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <cmath>

using namespace std;

void helper(string s, int index, long sum, long& ret) {
    if (index == s.size()) {
        ret += sum;
    } else {
        for (int i = 1; i + index <= s.size(); ++i) {
            long cur = stoll(s.substr(index, i));
            helper(s, index + i, sum + cur, ret);
        }
    }
}

int main() {
    string s;
    cin >> s;
    long ret = 0;
    long sum = 0;
    helper(s, 0, sum, ret);
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let x: i64 = sc.read();
    let n: usize = sc.read();
    let p: Vec<i64> = sc.vec(n);

    let mut ans = -10000;
    for i in -1000..=1000 {
        if p.contains(&i) {
            continue;
        }
        let di = (i - x).abs();
        let da = (ans - x).abs();
        if di < da {
            ans = i;
        }
    }
    println!("{}", ans);
}

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

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


Measured memory_bytes: 2184
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <bitset>
#include <tuple>
#include <stack>
#include <utility>

using namespace std;

int main(){
    int ab, bc, ca;
    cin >> ab >> bc >> ca;

    int ans = ab*bc/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
#include <stdio.h>
#define MAX 200001

int main(){
  int n,a[MAX],s[MAX],list[MAX],round[MAX],next[MAX],last[MAX],p,
      i,j;
  
  long k,count,mod;
  
  scanf("%d%ld",&n,&k);
  for(i=0;i<MAX;i++){last[i]=-1;}
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(last[a[i]] == -1){
      next[i] = i;
      last[a[i]] = i;
    }else{
      next[i] = next[last[a[i]]];
      next[last[a[i]]] = i;
      last[a[i]] = i;
    }
  }
  
  p=0;
  count=1;
  round[1] = 0;
  while(1){
    if(next[p] <= p){
      count++;
    }
    p = next[p] + 1;
    if(p == n){
      break;
    }
    round[count] = p;
  }

  mod = k % count;
  if(mod == 0){
    return 0;
  }
  
  p = 0;
  for(i=0;i<MAX;i++){s[i]=-1; list[i]=-1;}
  for(i=round[mod];i<n;i++){
    if(list[a[i]] == -1){
      s[p] = a[i];
      list[a[i]] = p;
      p++;
    }else{
      for(j=list[a[i]]+1;j<p;j++){
        list[s[j]] = -1;
      }
      p = list[a[i]];
      list[a[i]] = -1;
    }
  }
    
  for(i=0;i<p;i++) printf("%d ",s[i]);
  return 0;
}   

Measured memory_bytes: 6144
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)
 
int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    rep(i,n){
        int a;
        cin>>a;
        v[i] = a%3;
    }
     
    int zero=0,one=0,two=0;
    rep(i,n){
        if(v[i]==0)zero++;
        if(v[i]==1)one++;
        if(v[i]==2)two++;
    }
     
    if(one==0&&two==0){
        cout<<1<<endl;
        return 0;
    }
     
    int ans = 0;
     
    if(one>=1){
        if(one-1< two)ans = max( ans , 1 + zero + (one-1)*2 );
        if(one-1> two)ans = max( ans , 1 + zero + two*2 + 1 );
        if(one-1==two)ans = max( ans , 1 + zero + two*2 );
    }
     
    if(two>=1){
        if(one< two-1)ans = max( ans , 1 + zero + one*2+1 );
        if(one> two-1)ans = max( ans , 1 + zero + (two-1)*2 );
        if(one==two-1)ans = max( ans , 1 + zero + (two-1)*2 );
    }
 
    if(ans<n)ans++;
    cout<<ans<<endl;
}

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

template<typename T, typename U> void cmax(T &a, U b) { if (a < b) a = b; }
template<typename T, typename U> void cmin(T &a, U b) { if (a > b) a = b; }

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int N, C, K;
  cin >> N >> C >> K;
  vector<int> T(N);
  for (int i = 0; i < N; i++) cin >> T.at(i);

  sort(T.begin(), T.end());

  int lim = -1, c = 0, ans = 1;
  for (int i = 0; i < N; i++) {
    if (lim == -1) lim = T.at(i) + K;
    if (T.at(i) <= lim && c < C) {
      c++;
      continue;
    } else {
      ans++;
      lim = T.at(i) + K, c = 1;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3668
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

int main(){

    int a, b;
    cin >> a ;
    cin >> b;

    cout << (6 - a - b) << endl;

}

Measured memory_bytes: 256
A, B, C, D = map(int, input().split())
def gcd(a, b):
  if a % b is 0:
    return b
  return gcd(b, a % b)

def solve(n):
  return n - (n // C) - (n // D) + (n // (C * D // gcd(C, D)))

print(solve(B) - solve(A - 1))

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>

int main() {
    char c[3][100];

    for(int i = 0; i < 3; i++) {
        scanf("%s", c[i]);
    }

    long a, b;
    a = atol(c[0]);
    b = atol(c[2]);

    if(c[1][0] == '+') {
        printf("%i", a + b);
    } else {
        printf("%i", a - b);
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
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;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define LLINF (1e18)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> v[100];
    for (int query = 0; query < n; query++)
    {
        for (int i = 0; i < 100; i++)
        {
            v[i].clear();
        }
        string s;
        cin >> s;
        int depth = 0;
        ll num = 0;
        for (int i = 0; i < (int)s.size(); i++)
        {
            if (s[i] == '[')
            {
                depth++;
            }
            else if (s[i] == ']')
            {
                if (num)
                {
                    v[depth].push_back((num + 1) / 2);
                }
                num = 0;
                sort(ALL(v[depth]));
                ll total = 0;
                int m = ((int)v[depth].size() + 1) / 2;
                for (int j = 0; j < m; j++)
                {
                    total += v[depth][j];
                }
                v[depth - 1].push_back(total);
                v[depth].clear();
                depth--;
            }
            else
            {
                num *= 10;
                ll tmp = s[i] - '0';
                num += tmp;
            }
        }
        cout << v[0][0] << endl;
    }
    return 0;
}


Measured memory_bytes: 3260
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	while (1) {
		int M, N; cin >> M >> N;
		if (!M)break;
		list<int>al(M);
		iota(al.begin(), al.end(), 1);
		auto it = al.begin();
		for (int i = 1; i <= N; ++i) {
			string input; cin >> input;
			string st;
			if (al.size() == 1)continue;
			if (!(i % 3)) {
				st+=("Fizz");
			}
			if (!(i % 5)) {
				st+=("Buzz");
			}
			if (st.empty()) {
				st = to_string(i);
			}

			it++;
			if (input == st) {

			}
			else {
				al.erase(prev(it));
			}
			if (it == al.end())it = al.begin();
		}
		for (auto it = al.begin(); it != al.end(); ++it) {
			cout << *it;
			if (next(it) != al.end())cout << " ";
			else cout << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3224
/*
ЗАПУСКАЕМ 
░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
▄███▀░◐░░░▌░░░░░░░
░░░░▌░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▐░░░░░▐░░░░░░░
░░░░▌░░░░░▐▄▄░░░░░
░░░░▌░░░░▄▀▒▒▀▀▀▀▄
░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░░░▌▌░▌▌░░░░░
░░░░░░░░░▄▄▌▌▄▌▌░░░░░ 
 */
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>


using namespace std;
template<typename T1, typename T2> inline void chkmin(T1 &a, T2 b) {if (a > b) a = b;}
template<typename T1, typename T2> inline void chkmax(T1 &a, T2 b) {if (a < b) a = b;}
#define files(FILENAME) read(FILENAME); write(FILENAME)
#define read(FILENAME) freopen((FILENAME + ".in").c_str(), "r", stdin)
#define write(FILENAME) freopen((FILENAME + ".out").c_str(), "w", stdout)
#define all(c) (c).begin(), (c).end()
#define sz(c) (int)(c).size()
#define left left228
#define right right228
#define y1 y1228
#define mp make_pair
#define pb push_back
#define y2 y2228
#define rank rank228
using ll = long long;
using ld = long double;
const string FILENAME = "input";



unordered_map<ll, ll> mem;
ll a, b, c, d;


ll solve(ll x) {
	if (x == 0) {
		return 0;
	}
	if (mem.find(x) != mem.end()) {
		return mem[x];
	}
	ll ans = 3e18;
	if (ans / x >= d) {
		chkmin(ans, x * d);
	}
	for (int it = -5; it < 5; it++) {
		if (x >= it) {
			ll val = x - it;
			ll add = d * abs(it);
			if (val % 2 == 0 && val / 2 < x) {
				chkmin(ans, add + solve(val / 2) + a);
			}
			if (val % 3 == 0 && val / 3 < x) {
				chkmin(ans, add + solve(val / 3) + b);
			}
			if (val % 5 == 0 && val / 5 < x) {
				chkmin(ans, add + solve(val / 5) + c);
			}
		}
	}
	mem[x] = ans;
	return ans;
}


void solve() {
	ll n;
	cin >> n >> a >> b >> c >> d;
	mem.clear();
	cout << solve(n) << '\n';
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
 	//read(FILENAME);
	int t;
	cin >> t;
	while (t--) {
		solve();
	}
	return 0; 	
}

Measured memory_bytes: 5332
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

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

using namespace std;

const ll BIG = 1000000007LL;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

const int MAX = 120;
int N;
string S[MAX];
int P[MAX];
tuple<string, int, int> sp[MAX];

int main(int argc, const char * argv[]) {
    N = inputValue();
    rep(i, N){
        cin >> S[i] >> P[i];
        sp[i] = make_tuple(S[i], P[i], i + 1);
    }

    sort(sp, sp+N, [](auto& a, auto& b) {
        if (get<0>(a) < get<0>(b)) return true;
        if (get<0>(a) == get<0>(b)) return get<1>(a) > get<1>(b);
        return false;
    });
    
    rep(i, N) {
        output(get<2>(sp[i]));
    }


    return 0;
}

Measured memory_bytes: 256
a = []
l = []
for i in range(3):
	x,y = map(int,input().split( ))
	a.append(x)
	a.append(y)
a.sort()
for i in range(4):
	l.append(a.count(i+1))
ans ="YES"
if l.count(3) > 0:
	ans = "NO"
print(ans)
 

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>

using namespace std;

int main(void)
{
    long long S, x2, y2, x3, y3;

    cin >> S;

    x2 = 1e9;

    y2 = 1;

    x3 = (x2-S%x2)%x2;

    y3 = (S+x3) / x2;

    cout << 0 << " " << 0 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;

    return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
bool isPrime(int n){
  for(int i=2;i*i<=n;i++) if(n%i==0) return false;
  return true;
}
int main(){
  bool d[50000]={};
  int i,j,k;
  for(i=2;i<50000;i++) d[i]=isPrime(i);
  int n;
  while(cin>>n,n){
    int o=0;
    for(i=1;i<=n/2;i++) if(d[i]&&d[n-i]) o++;
    cout << o << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
import sys
readline=sys.stdin.readline

N=int(readline())
A=list(map(int,readline().split()))
B=[0]*N
sumB=0
for i in range(N):
  B[i]=A[i]-(i+1)
  
B=sorted(B)
mid=0
if len(B)&1:
  mid=B[N//2]
else:
  mid=(B[N//2-1]+B[N//2])//2
  
ans=0
for i in range(N):
  ans+=abs(B[i]-mid)

print(ans)


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

using ll = long long;

#define INF 100000000000
int main()
{
  int N, K;
  cin >> N >> K;

  vector<int> h(N);
  vector<ll> cost(N+1, INF);
  for(int i = 0; i<N; i++){
    cin >> h.at(i);
  }
  cost.at(0) = 0;
  for(int i=1; i<N; i++){
    for(int j=i-1; j>=i-K; j--){
      if(j>=0){
        cost.at(i) = min(cost.at(i), cost.at(j) + abs(h.at(i) - h.at(j)));
      }
    }
  }
  cout << cost.at(N-1) << endl;

  return 0;

}

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

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

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> g(N);
    vector<int> indegree(N);
    REP(i, N - 1 + M) {
        int A, B;
        cin >> A >> B;
        --A;
        --B;
        g[A].push_back(B);
        ++indegree[B];
    }

    vector<int> parent(N);
    queue<int> q;
    REP(i, N) {
        if (indegree[i] == 0) {
            parent[i] = -1;
            q.push(i);
            break;
        }
    }

    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (int v: g[u]) {
            --indegree[v];
            if (indegree[v] == 0) {
                parent[v] = u;
                q.push(v);
            }
        }
    }

    REP(i, N) {
        cout << (parent[i] + 1) << '\n'; // 1-based indexing
    }
    cout << flush;

    return 0;
}

Measured memory_bytes: 7040
#include<cctype>
#include<cstdio>
#include<cstring>

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

using namespace std;

#define NIL (-2)

int mem_max,mem_used;
int mem[10000],mem_id;
int var[128];

bool error;
int idx,len;
char s[301];

int number(){
	int num=0;
	for(;idx<len && isdigit(s[idx]);idx++) num=10*num+(s[idx]-'0');
	return num;
}

int expr(){
	if(s[idx]=='('){ // "(" <expr> ")" Ìp^[
		idx++;
		int a=expr();
		idx++;
		return a;
	}
	else if(isupper(s[idx]) && idx+1<len && s[idx+1]=='='){ // <assign> Ìp^[
		char c=s[idx];
		idx+=2;
		return var[c]=expr();
	}
	else if(s[idx]=='N' && idx+1<len && s[idx+1]=='U'){ // "NULL" Ìp^[
		idx+=4;
		return NIL;
	}
	else if(isupper(s[idx])){ // <variable> Ìp^[
		return var[s[idx++]];
	}
	else if(s[idx]=='m'){ // <malloc> Ìp^[
		idx+=7;
		int num=number();
		idx++;
		if(mem_used+num>mem_max) return NIL;
		else{
			mem_used+=num;
			mem[mem_id]=num;
			return mem_id++;
		}
	}
	else{ // <clone> Ìp^[
		idx+=6;
		int a=expr();
		idx++;
		if(a==NIL) return NIL;
		else if(a==-1 || mem[a]==-1){
			error=true;
			return NIL;
		}
		else if(mem_used+mem[a]>mem_max){
			return NIL;
		}
		else{
			mem_used+=mem[a];
			mem[mem_id]=mem[a];
			return mem_id++;
		}
	}
}

void line(){
	if(s[idx]=='f'){ // free
		idx+=5;
		int a=expr();
		idx++;
		if(a==NIL);
		else if(a==-1 || mem[a]==-1){
			error=true;
		}
		else{
			mem_used-=mem[a];
			mem[a]=-1;
		}
	}
	else{ // other
		expr();
	}
}

void parse(const char *s){
	idx=0;
	len=strlen(s);
	strcpy(::s,s);
	line();
}

int main(){
	scanf("%d",&mem_max);
	rep(c,128) var[c]=-1;
	rep(i,10000) mem[i]=-1;
	while(1){
		char s[301];
		if(scanf("%s",s)==-1) break;
		parse(s);
		if(error){ puts("Error"); return 0; }
	}

	int mem_leak=mem_used;
	rep(c,128) if(var[c]!=-1 && mem[var[c]]!=-1){
		mem_leak-=mem[var[c]];
		mem[var[c]]=-1;
	}
	printf("%d\n",mem_leak);

	return 0;
}

Measured memory_bytes: 0
class Integer
  def prime?
    return true if self == 2
    return false if self < 2 or self.even?

    sqrt = Math.sqrt(self)

    3.step(sqrt.ceil, 2) do |i|
      return false if (self % i).zero?
    end

    true
  end
end

puts readlines.map(&:to_i)[1..-1].select(&:prime?).size

Measured memory_bytes: 9064
#pragma GCC optimize("O2,unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2")
#include<bits/stdc++.h>
#define int ll
#define pb push_back
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
const int maxn = 1<<20, mod = 1e9 + 7;
ll S, ans = 0;
inline int LOG(int x) {
	return x < 10000 ?
	(x < 100 ? 1+(x>9) : 3+(x>999)) :
	(x < 1000000 ? 5+(x>99999) : 7+(x>9999999)+(x>99999999));
}
int bp(int a, int p) {
	int r = 1;
	while(p) {
		if(p&1) r = r*1ll*a%mod;
		a = a*1ll*a%mod, p>>=1;
	}
	return r;
}
signed main() {
	cin.tie(0)->sync_with_stdio(0);
	cin >> S;
	int l = 1;
	for(int cur = 0, i = 1;; i++) {
		cur += LOG(i);
		while(cur > S) cur -= LOG(l++);
		if(l >= 100000000) {break;}
		ans += cur==S;
	}
	//cout << ans << '\n';
	for(int ml = 9; ml <= S; ml++) {
		ll u = (S-1)/(ml+1);
		u -= S%ml;
		if(u >= 0) ans = (ans + (u/ml) + 1);
		if(S%ml == 0) {
			int no = bp(10, ml) - bp(10, ml-1);
			if(no < 0) no += mod;
			ans = (mod + ans + no - (S/ml))%mod;
		}
		//cout << ml << " " << ans << '\n';
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3624
// 何故か通らないケースがある -> 模範解答より修正

#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
#include <math.h>
using namespace std;

/*
int main()
{
    int a, b, c;
    cin >> a >> b;
    int digit = log10(b) + 1;
    double p = pow(10, digit);
    c = a * (int)p + b;

    if (sqrt(c) * sqrt(c) == c)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}
*/
int main()
{
    string a, b;
    cin >> a >> b;
    int c = stoi(a + b);
    for (int i = 1; i <= 1000; i++)
    {
        if (i * i == c)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
n = int(input())
t,a=map(int,input().split())
h = list(map(int,input().split()))
ans_num = 1<<30
ans = -1

for i in range(n):
    temp = abs(a-(t - h[i]*0.006))
    if ans_num >= temp:
        ans_num = temp
        ans = i
print(ans+1)

Measured memory_bytes: 3064
import java.util.LinkedList;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        long c = in.nextLong();
        LinkedList<Stone> queue = new LinkedList<>();
        long h1 = in.nextLong();
        queue.add(new Stone(h1, h1 * h1));
        for (int i = 1; i < n; i++) {
            long h = in.nextLong();
            while (queue.size() > 1 && queue.get(1).dp - (2L * h * queue.get(1).h) <= queue.get(0).dp - (2L * h * queue.get(0).h)) {
                queue.removeFirst();
            }
            long dp = queue.get(0).dp - (2L * h * queue.get(0).h) + (2L * h * h) + c;
            Stone stone = new Stone(h, dp);
            //while (!queue.isEmpty() && dp - (2L * h * h) <= queue.getLast().dp - (2L * h * queue.getLast().h)) {
            while (queue.size() > 1 && fromLine(queue.get(queue.size() - 2), queue.getLast(), stone) <= 0L) {
                queue.removeLast();
            }
            queue.addLast(stone);
        }
        System.out.println(queue.getLast().dp - (queue.getLast().h * queue.getLast().h));
    }

    static class Stone {
        final long h;
        final long dp;

        Stone(long h, long dp) {
            this.h = h;
            this.dp = dp;
        }
    }

    static long fromLine(Stone a, Stone b, Stone point) {
        return ((point.dp - a.dp) * (b.h - a.h)) - ((point.h - a.h) * (b.dp - a.dp));
    }
}


Measured memory_bytes: 68052
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;constexpr ll INF=1LL<<60,MOD=1e9+7;//998244353;
void solve();int main(){cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();return 0;}
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(int i=0;i<(int)n;++i)
#define _rep1(i,k,n) for(int i=k;i<(int)n;++i)
#define _rep2(i,k,n,d) for(int i=k;d>0?i<(int)n:i>(int)n;i+=d)
#ifdef __LOCAL
#include "ostreams.h"
#endif
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
template<class T> vector<T> make_vector(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_vector(size_t a,Ts... ts){return vector<decltype(make_vector(ts...))>(a,make_vector(ts...));}
void print(){cerr<<endl;} template<class T,class... Ts> void print(const T& a,const Ts&... ts){cerr<<a<<' ';print(ts...);}

void solve(){
    ll n; cin >> n;
    vector<ll> A(3 * n);
    rep(i, 3 * n) cin >> A[i], A[i]--;

    // n : wild card
    auto dp = make_vector(n + 1, n + 1, -INF);
    auto update = [&](ll i, ll j, ll v){
        chmax(dp[i][j], v);
        chmax(dp[j][i], v);
        chmax(dp[i][n], v);
        chmax(dp[n][i], v);
        chmax(dp[n][j], v);
        chmax(dp[j][n], v);
        chmax(dp[n][n], v);
    };

    // initialize
    update(A[0], A[1], 0);

    // iterate
    ll base = 0;
    rep(i, n - 1){
        ll x = A[3 * i + 2], y = A[3 * i + 3], z = A[3 * i + 4];
        if(x == y and y == z){
            base++;
            continue;
        }
        vector<tuple<ll, ll, ll>> update_queue;
        rep(_, 3){
            // 手持ちから1枚使う
            rep(a, n){
                update_queue.emplace_back(a, x, dp[a][n]);
                if(y == z){
                    update_queue.emplace_back(a, x, dp[a][y] + 1);
                }
            }
            // 手持ちから0枚使う
            update_queue.emplace_back(x, y, dp[n][n]);
            update_queue.emplace_back(x, y, dp[z][z] + 1);
            swap(x, y); swap(y, z);
        }
        // update
        for(auto& [i, j, v] : update_queue){
            update(i, j, v);
        }
    }

    ll ans = max(dp[n][n], dp[A[3 * n - 1]][A[3 * n - 1]] + 1) + base;
    cout << ans << endl;
}

Measured memory_bytes: 34976
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mod 1000000007
int main() {
	fio;
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int a[10];
	for (ll i = 0; i < 5; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < 5; i++) {
		if (a[i] == 0) {
			cout << i + 1 << endl;
		}
	}

}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
double eps=1e-8;
ll mod=1e9+7;
ll inf=1e9;
priority_queue<P,vector<P>,greater<P> > pq;

template <typename T>
int Count(const vector<T> &v, T l,T r){
  //counting [l,r]
  auto L = lower_bound(v.begin(), v.end() , l );
  auto R = upper_bound(v.begin(), v.end(), r );
  // [l,r) change upper -> lower

  return R-L;
}

int main(){
  int n,a[101];
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  int ans=0,c=a[0];
  a[n]=0;
  for(int i=1;i<=n;i++){
    if(a[i])c++;
    else ans=max(c,ans),c=0;
  }
  cout<<ans+1<<endl;
  return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int r, n;
    while(cin >> r >> n, r) {
        vector<int> v(25), u(25);
        for (int i = 0; i < n; ++i) {
            int p, q, h;
            cin >> p >> q >> h;
            for (int j = p; j < q; ++j) {
                if(j < 0){
                    u[-j-1] = max(u[-j-1], h);
                }else {
                    v[j] = max(v[j], h);
                }
            }
        }
        double ans = INF<int>;
        for (int i = 0; i < r; ++i) {
            v[i] = min(v[i], u[i]);
            ans = min(ans, r+v[i]-sqrt(r*r-i*i));
        }
        cout << ans << "\n";
    }

    return 0;
}


Measured memory_bytes: 3184
import java.util.Arrays;
import java.util.Scanner;

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

		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
		}

		Arrays.sort(A);

		System.out.println(A[N - 1] - A[0]);
	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;

int main() {
    char S[200009], T[200009];
    cin >> S >> T;

    char sToT[26] = {};
    for (int i = 0; S[i] != '\0'; i++) {
        char s = S[i] - 'a', t = T[i];
        if (sToT[s] != 0 && sToT[s] != t) {
            cout << "No" << endl;
            return 0;
        }
        sToT[s] = t;
    }
    char tToS[26] = {};
    for (int i = 0; S[i] != '\0'; i++) {
        char s = S[i], t = T[i] - 'a';
        if (tToS[t] != 0 && tToS[t] != s) {
            cout << "No" << endl;
            return 0;
        }
        tToS[t] = s;
    }

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


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

#define rep(i, m, n) for(int(i) = (int)(m); i < (int)(n); ++i)
#define rep2(i, m, n) for(int(i) = (int)(n)-1; i >= (int)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T>
using vec = vector<T>;
template <class T>
using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll)1e9 + 7;
constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;
typedef vector<ll> Array;
typedef vector<Array> Matrix;

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

struct Edge {
    ll to, rev;
    long double cap;
    Edge(ll _to, long double _cap, ll _rev) {
        to = _to;
        cap = _cap;
        rev = _rev;
    }
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph &G, ll from, ll to, long double cap, bool revFlag,
              long double revCap) {
    G[from].push_back(Edge(to, cap, (ll)G[to].size()));
    if(revFlag)
        G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve() {
    ll n, k;
    cin >> n >> k;
    Array a(n);
    REP(i, n)
        cin >> a[i];

    sort(all(a));
    ll ans = 0;
    REP(i, k)
    ans += a[i];
    cout << ans << en;
}

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

    solve();
    // ll t;cin>>t;REP(i,t) solve();

    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

#ifdef DEBUG
    #define IFD if(true)
#else
    #define IFD if(false)
#endif

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

    vector<int> A(N);
    rep(i, N) {
        cin >> A[i];
    }

    vector<int> B = A;
    sort(B.rbegin(), B.rend());

    rep(i, N) {
        cout << (A[i] == B[0] ? B[1] : B[0]) << endl;
    }

    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i, x, N) for (int i = x; i < (N); i++)
using namespace std;
int main()
{
    struct day
    {
        string s;
        int ans;
    };
    day q[7];
    q[0].s = "SUN";
    q[1].s = "MON";
    q[2].s = "TUE";
    q[3].s = "WED";
    q[4].s = "THU";
    q[5].s = "FRI";
    q[6].s = "SAT";
    int j = 7;
    rep(i, 0, 7)
    {
        q[i].ans = j;
        j--;
    }
    string t;
    cin >> t;
    rep(i, 0, 7)
    {
        if (q[i].s == t)
        {
            cout << q[i].ans << endl;
            return 0;
        }
    }
}


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

int main(){
 string s;
 int ans=0;
 cin>>s;
 int l=s.size();
 for(int i=0;i<l/2;i++){
   char s1=s[i];
   char s2=s[l-1-i];
  // cout<<s1<<" "<<s2<<" ";
   if(s1!=s2) ans++;
 }
  cout<<ans<<endl;
 return 0; 
}

Measured memory_bytes: 256
#!/usr/bin/python3
import sys

sys.setrecursionlimit(10 ** 5)

def search(n, total, dic):
    if dic[n] >= 0:
        return
    else:
        dic[n] = total
    for i in br[n]:
        search(i, total + 1, dic)

n, u, v = map(int, input().split())
br = {}
disu = {}
disv = {}
for i in range(n):
    br[i + 1] = []
    disu[i + 1] = -1
    disv[i + 1] = -1
for i in range(n - 1):
    a, b = map(int, input().split())
    br[a].append(b)
    br[b].append(a)

search(u, 0, disu)
search(v, 0, disv)
far = 0
for i in range(1, n + 1):
    if disv[i] < disu[i]:
        continue
    else:
        far = max(far, disv[i])

print(far - 1)


Measured memory_bytes: 127220
#include <cstdio>
#include <algorithm>
#pragma warning(disable : 4996)
using namespace std;
int D, N, a[111], e[111], r[111], dp[111][111];
int main() {
	while (scanf("%d%d", &D, &N), D | N) {
		for (int i = 0; i < N; i++) scanf("%d%d%d", a + i, e + i, r + i);
		int maxr = *max_element(r, r + N);
		for (int i = 0; i <= D; i++) fill(dp[i], dp[i] + maxr + 1, 999999999);
		dp[0][0] = 0;
		for (int i = 0; i < D; i++) {
			for (int j = 0; j <= maxr; j++) {
				for (int k = 0; k < N; k++) {
					if (j < r[k]) continue;
					int p = min(j + e[k], maxr), q = min(i + a[k], D);
					dp[q][p] = min(dp[q][p], dp[i][j] + 1);
				}
			}
		}
		int ret = *min_element(dp[D], dp[D] + maxr + 1);
		if (ret == 999999999) puts("NA");
		else printf("%d\n", ret);
	}
}

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

int main() {
  int n,k;
  cin >> n >> k;
  
  int x = 1;
  for(int i = 0; i < n; i++) {
    if(x > k) {
      x = x + k;
    }
    else {
      x = 2 * x;
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9+7;
Int INF = 1e18;
//Int mod = 1e6+3;

int main() {
    double ax, ay, bx, by;
    cin >> ax >> ay >> bx >> by;
    complex<double> a(ax, ay), b(bx, by);
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        double px, py;
        cin >> px >> py;
        complex<double> p(px, py);
        complex<double> ap = p - a;
        complex<double> ab = b - a;
        complex<double> ev = ab / abs(ab);
        ap = ap / ev;
        complex<double> res(real(ap), 0.0);
        res = res * ev + a;
        printf("%.12lf %.12lf\n", real(res), imag(res));
    }
    return 0;
}


Measured memory_bytes: 3352
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  string S;
  cin >> S;
  string ans="AC";

  if(S.at(0)!='A') ans="WA";
  if('A'<=S.at(1) && S.at(1)<='Z') ans="WA";
  int count_C=0;
  for(int i=2;i<S.size()-1;++i){
    if('A'<=S.at(i) && S.at(i)<='Z'){
      if(S.at(i)!='C'){
	ans="WA";
	break;
      }
      else{
	if(count_C==0) ++count_C;
	else{
	  ans="WA";
	  break;
	}
      }
    }
  }
  if('A'<=S.at(S.size()-1) && S.at(S.size()-1)<='Z') ans="WA";
  if(count_C!=1) ans="WA";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3604
from collections import deque
n,x,y=map(int,input().split())

L=[[1]]
for i in range(1,n-1):
	L.append([i-1,i+1])
L.append([n-2])
L[x-1].append(y-1)
L[y-1].append(x-1)

R=[0]*n

def bfs(j):
	V=[-1]*n
	que=deque([])
	que.append(j)
	V[j]=0
	while que:
		p=que.popleft()
		for np in L[p]:
			if V[np]==-1:
				que.append(np)
				V[np]=V[p]+1
	for i in range(n):
		R[V[i]]+=1
	
for j in range(n):
	bfs(j)
for i in range(1,n):
	print(R[i]//2)

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

int main(){
  string s; cin >> s;
  regex re = regex("((dream)|(dreamer)|(erase)|(eraser))*");
  bool result = regex_match(s, re);
  if(result) cout << "YES" << "\n";
  else cout << "NO" << "\n";
}

Measured memory_bytes: 46848
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    string s; cin >> s;
    int a = 0, z = s.length() - 1;
    while (s[a] != 'A') a++;
    while (s[z] != 'Z') z--;
    cout << z - a + 1 << endl;
    return 0;
}


Measured memory_bytes: 720
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		double[] A = new double[N];

		double ans = 0;

		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			A[i] = 1 / A[i];
			ans += A[i];
		}
		ans = 1/ans;

		/*		for(int i = 0; i < N; i++){
					ans = 1 / ans;
				}
		*/
		System.out.println(ans);

	}

}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_multiset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
//find_by_order(k) - k is the kth element of the multiset
//order_of_key(k) - Number of elements striclty samller than k
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    for(int i=1;i<4;i++)
    {
        if(s[i]==s[i-1])
        {
            cout<<"Bad"<<endl;
            return 0;
        }
    }
    cout<<"Good"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

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

    int a = -1;
    int b = -1;
    bool flag = false;
    for(int i=0; i<n-1; i++)
        if(p[i] > p[i+1]) {
            if(!flag) {
                a = i;
                flag = true;
            }
            else {
                b = i+1;
                break;
            }
        }

    if(a==-1) {
        cout << "YES" << endl;
        return 0;
    } else if (b==-1) {
        cout << "NO" << endl;
        return 0;
    }

    int tmp = p[b];
    p[b] = p[a];
    p[a] = tmp;

    for(int i=0; i<n-1; i++)
        if(p[i] > p[i+1]) {
            cout << "NO" << endl;
            return 0;
        }

    cout << "YES" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long i,d,n,ans,sum,j;
    string s,t;
    cin>>s;
    cin>>t;
    ans=t.size();
    for(i=0;i<=(s.size()-t.size());i++)
    {
        sum=0;
        for(j=0;j<t.size();j++)
        {
            if(t[j]!=s[i+j])
                sum++;
        }
        if(ans>sum)
            ans=sum;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3632
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
using namespace std;

int main() {
  long long X, ans = 0, Q = 100;
  cin >> X;
  while(Q < X)
  {
    
 
     Q += Q / 100;
    ans++;
  }
  cout << ans << endl;
}
    
  





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

int main(){
  int n;cin>>n;
  vector<string> s(n);
  for(int i=0;i<n;i++){
    cin>>s[i];
    for(int j=0;j<i;j++){
      if(s[i]==s[j]){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }for(int i=0;i<n-1;i++){
    char back=s[i].at(s[i].size()-1),head=s[i+1].at(0);
    if(back!=head){
      cout<<"No"<<endl;
      return 0;
    }
  }cout<<"Yes"<<endl;
}

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

main(){
  int t, n, st, ft;
  while(1){
    cin >> t;
    if ( t == 0 ) break;
    cin >> n;
    int sum = 0;
    for ( int i = 0; i < n;  i++ ){
      cin >> st >> ft;
      sum += ft - st;
    }
    if ( sum >= t ) cout << "OK" << endl;
    else cout << t - sum << endl;
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int S, W;
  cin >> S >> W;
  
  if (S <= W){
    cout << "unsafe" << endl;
  }  
  
  
  else {
    cout << "safe" << endl;
  }
  
  
  
  
  
  
}


Measured memory_bytes: 3552
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(s.equals("RSS")||s.equals("SRS")||s.equals("SSR")||s.equals("RSR")) System.out.println(1);
		else if(s.equals("RRS")||s.equals("SRR")) System.out.println(2);
		else if(s.equals("RRR")) System.out.println(3);
		else System.out.println(0);
    }
}

Measured memory_bytes: 35620