akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(){

  int N,i,j,k,v;

  scanf("%d", &N);
  int A[N];

  for(i=0;i<N;i++)scanf("%d",&A[i]);
  
  for( i=1 ; i <= N-1 ; i++){
    printf("%d",A[0]);
    for(k=1;k<N;k++)printf(" %d",A[k]);
    printf("\n");
    v = A[i];
    j = i - 1;
    while(j>=0 && A[j]>v){
      A[j+1]=A[j];
      j--;
    }
    A[j+1]= v;    
   }
  
  printf("%d",A[0]);
  for(k=1;k<N;k++)printf(" %d",A[k]);

  printf("\n");
  
 return 0;

}



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

using namespace std;

int main()
{
    long long n,bns=0,m;
    long long ans=0;
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> m;
        if(m)
        {
            m+=bns;
        }
        else
        {
            bns=0;
        }
        ans+=m/2;
        bns=m%2;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;

int main() {
	int n, k; double ans = 0;
	cin>>n>>k;
	
	for(int i=1; i<=n; i++){
		int tmp = i; double pro = 1.0;
		while(tmp<k){
			tmp *= 2;
			pro /= 2;
		}
		ans += pro/n;
	}
	
	printf("%.10lf",ans);
	
	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(a+b > c+d) puts("Left");
	else if(a+b == c+d) puts("Balanced");
	else puts("Right");
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


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

#pragma GCC optimization_level 3
#define _GLIBCXX_DEBUG

using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;



int main(){
	string s;
	cin>>s;

	if (s.at(0)==s.at(1) && s.at(1)!= s.at(2) && s.at(2)==s.at(3))
	{
		cout<<"Yes";
	} else if (s.at(0)==s.at(2) &&s.at(2)!=s.at(3) && s.at(1)==s.at(3))
	{
		cout<<"Yes";
	} else if (s.at(0)==s.at(3) && s.at(3)!=s.at(1) && s.at(1)==s.at(2))
	{
		cout<<"Yes";
	} else
	{
		cout<<"No";
	}
	
	
	
	
}


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

int main()
{
    int N;
    scanf("%d", &N);
    int T[N+4], X[N+4], Y[N+4];
    T[0] = X[0] = Y[0] = 0;
    for(int i = 1; i <= N; ++i) scanf("%d %d %d", &T[i], &X[i], &Y[i]);
    
    for(int i = 0; i < N; ++i) {
        int td = T[i+1] - T[i],
            xd = X[i+1] - X[i],
            yd = Y[i+1] - Y[i];
        if((td - abs(xd) - abs(yd) )%2 ||
            td < abs(xd + yd)) { cout << "No" << endl; return 0; }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1408
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int k = scanner.nextInt();
        int s = scanner.nextInt();
        int cnt = 0;
        for (int x = 0;x<=k;x++) {
        	if(x>s) {
        		break;
        	}
        	for (int y=0;y<=k;y++) {
        		if((x+y)>s) {
        			break;
        		}
        		if((s-(x+y))<=k) {
        			cnt++;
        		}
        	}
        }
        System.out.println(cnt);


    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

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

using namespace std;
typedef long long ll;
//ループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//コンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

//2値の最大公約数(順序関係なし・0はダメ)
int gcd(int a, int b){
    return b ? gcd(b, a%b) :a;
}

//n個の最大公約数
int ngcd(vector<int>& a){
    int res;
    res = a.at(0);
    for(int i = 1; i< a.size() && res != 1; i++){
        res = gcd(a.at(i), res);
    }
    return res;
}

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

//n個の最小公倍数
int nlcm(vector<int> numbers){
    int res;
    res = numbers.at(0);
    for(int i = 0; i< numbers.size();i++){
        res = lcm(res, numbers[i]);
    }
    return res;
}

//素数判定O(√N)
bool isPrime(int x){
    if(x<2) return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(int i = 3; i*i <= x; i+=2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(int n){
    int res = 0;
    while(n>0){
        res += n%10;
        n /= 10;
    }
    return res;
}

//約数全列挙
vector<int> enum_div(int n){
    vector<int> ret;
    for(int i = 1 ; i*i <= n ; ++i){
        if(n%i == 0){
            ret.push_back(i);
            if(i != 1 && i*i != n){
                ret.push_back(n/i);
            }
        }
    }
    return ret;
}

//繰り返し自乗法
long long int mod_pow(long long int x, long long int n, long long int mod){
    long long int res = 1;
    while(n > 0){
        if(n & 1) res = res*x%mod;
        x = x*x%mod;
        n >>= 1;
    }
    return res;
}

//文字列の中で何回文字が出てきたのかを数える
int stringcount(string s, char c) {
    return count(s.cbegin(), s.cend(), c); //覚える
}

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

    for(int i=1;i<N+1;i++) ans += i*(N/i)*(N/i+1)/2;

    cout << ans << endl;
}

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

int N;

int main()
{
    cin >> N;
    int nokori = N;
    if (N == 3)
    {
        cout << "2 5 63" << endl;
        return 0;
    }
    if (N == 4)
    {
        cout << "2 5 20 63" << endl;
        return 0;
    }

    if (nokori > 10000 && (nokori & 1))
    {
        cout << "15000 ";
        nokori--;
    }
    else if (nokori > 10000 && ~(nokori & 1))
    {
        cout << "15000 30000 ";
        nokori--;
        nokori--;
    }
    
    for (int i=1; i<=min(9999, nokori-2)/2; i++)
    {
        cout << i*3 << " " << 15000+i*3 << " ";
        nokori--;
        nokori--;
    }

    if (nokori & 1)
    {
        cout << "15002 15008 15014 ";
        nokori -= 3;
    }
    for (int i=0; i<nokori/2; i++)
    {
        cout << 6*i+2 << " " << 6*i+4 << " ";
    }
    return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iterator>
#include<cstdlib>
#include<vector>
#define fst first
#define snd second
using namespace std;
typedef long long ll;
typedef ostream_iterator<int> os_iter_int;

int n;
bool s[10010],t[10010];
vector<pair<int,int>> l1,l2;

template<typename inp_t>
void readx(inp_t& x)
{
	x=0; int k=1; char ch=0;
	while (ch<'0' || ch>'9') { ch=getchar(); if (ch=='-') k=-1; }
	while (ch>='0' && ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	x*=k;
}

void Make(bool* seq,vector<pair<int,int>>& vec)
{
	int fi=0;
	for (int i=1;i<n;i++) if (seq[i]!=seq[i+1])
	{
		if (!fi)
		{
			fi=1;
			for (int j=1;j<=n;j++) vec.push_back(make_pair(0,j%2));
			if (seq[i]==vec.back().snd) vec.push_back(make_pair(0,s[i]^1));
		}
		vec.push_back(make_pair(i,seq[i]));
	}
	for (int i=1;i<=n;i++) vec.push_back(make_pair(n,(vec.back().snd)^1));
}

int main()
{
	readx(n); char ch=0;
	for (int i=1;i<=n;i++)
	{
		ch=0; while (ch<'0' || ch>'1') ch=getchar();
		s[i]=ch-'0';
	}
	for (int i=1;i<=n;i++)
	{
		ch=0; while (ch<'0' || ch>'1') ch=getchar();
		t[i]=ch-'0';
	}
	
	if (n<=2)
	{
		if (n==1) printf("%d\n",(t[1]==s[1])^1);
		else printf("%d\n",((t[1]==s[1])^1)+((t[2]==s[2])^1));
		return 0;
	}
	
	// make lines
	Make(s,l1); Make(t,l2);
	
	int ans=n*n*2,l1pos=0;
	for (unsigned i=0;i<l1.size();i++) 
		if (l1[i].fst>0) { l1pos=i; break; }
	
	for (unsigned i=0;i<l2.size()-n+1;i++) if (l2[i].snd==l1[l1pos].snd)
	{
		int tmp=0;
		int s1=l1pos,s2=i;
		while (s1 && s2) { s1--; s2--; }
		while (s1<l1.size() && s2<l2.size())
		{
			tmp+=abs(l1[s1].fst-l2[s2].fst);
			s1++; s2++;
		}
		ans=min(ans,tmp);
	}
	
	printf("%d\n",ans);
}

Measured memory_bytes: 768
A, B, C = map(int, input().split())
ans1 = A*B*(C-C//2) - A*B*(C//2)
ans2 = B*C*(A-A//2) - B*C*(A//2)
ans3 = A*C*(B-B//2) - A*C*(B//2)
print(min(ans1, ans2, ans3))

Measured memory_bytes: 2940
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define bit(n, k) ((n) >> (k) & 1)

int n;
vector<vector<pair<int, int>>> xy;
int solve(int honest) {
    for (int i = 0; i < n; i++) if (bit(honest, i)) {
        for (auto &p: xy[i]) {
            if (bit(honest, p.first) != p.second) return -1;
        }
    }
    return __builtin_popcount(honest);
}

int main() {
    cin >> n;
    xy.resize(n);
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        xy[i].resize(a);
        for (auto &p: xy[i]) cin >> p.first >> p.second, p.first--;
    }
    int ma = 0;
    for (int s = 0; s < 1 << n; s++) ma = max(ma, solve(s));
    cout << ma << endl;
    return 0;
}


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

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef vector<bool> Vb;
typedef vector<int> Vi;

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 (b < a) { a = b; return 1; } return 0; }

void init();

int n;
Vi opt, dp;

int main()
{
	init();

	REP(i, n - 1)
		for (int x : opt)
		{
			if (i + x <= n)
				chmin(dp[i + x], dp[i] + 1);
			else
				break;
		}
	cout << dp[n] << endl;
}

void init()
{
	cin >> n;
	dp.resize(n + 1);
	REP(i, n + 1)
		dp[i] = i;

	int x = 6;
	while (x <= n)
	{
		opt.PB(x);
		x *= 6;
	}

	x = 9;
	while (x <= n)
	{
		opt.PB(x);
		x *= 9;
	}

	sort(ALL(opt));
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

const int N = 105;

int n;

int x[N], y[N], h[N];

int main() {

	FAST;

	cin >> n;
	for (int i = 1; i <= n; i ++) {
		cin >> x[i] >> y[i] >> h[i];
	}
	for (int cx = 0; cx <= 100; cx ++) {
		for (int cy = 0; cy <= 100; cy ++) {
			int H;
			for (int i = 1; i <= n; i ++) {
				if (h[i] > 0) {
					int k = abs(cx - x[i]) + abs(cy - y[i]);
					H = h[i] + k;
					break;	
				}
			}
			bool flag = true;
			for (int i = 1; i <= n; i ++) {
				int k = abs(cx - x[i]) + abs(cy - y[i]);
				if (h[i] != max(H - k, 0)) {
					flag = false;
					break;
				}
			}
			if (flag) {
				cout << cx << ' ' << cy << ' ' << H << '\n';
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int a;
    cin >> a;
    string s;
    cin >> s;
    if (a >= 3200)
    {
        cout << s << endl;
    } else
    {
        cout << "red" << endl;
    }
    
    
    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
h=list(map(int,input().split()))
ans = [1234567890123]*n
ans[0]=0
for i in range(1,n):
    for j in range(i-1,max(i-1-k,-1),-1):
        ans[i] = min(ans[i],ans[j]+abs(h[i]-h[j]))
    
print(ans[n-1])

Measured memory_bytes: 52728
#include <iostream>
#include <string>

using ll = long long;

int main() {
    std::string S;
    std::cin >> S;
    for (int i = 0; i < 3; i++) {
        if (S[i] == '1') {
            S[i] = '9';
        }
        else if (S[i] == '9') {
            S[i] = '1';
        }
    }


    std::cout << S << std::endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int

	fmt.Scan(&n)
	a := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}

	fmt.Println(solve(a))
}

func solve(a []int) int {
	r := 10000000
	min, max := minmax(a)

	for i := min; i <= max; i++ {
		s := 0
		for _, x := range a {
			s += (x - i) * (x - i)
		}

		if s < r {
			r = s
		}
	}

	return r
}

func minmax(a []int) (min int, max int) {
	min = a[0]
	max = a[0]

	for i := 1; i < len(a); i++ {
		if a[i] < min {
			min = a[i]
		}
		if a[i] > max {
			max = a[i]
		}
	}

	return
}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
#define INF 0x3f3f3f3f
#define MAXN 301000
int n;
char str[MAXN];
int diff[MAXN];
struct Node {
	int start, end;
	int minv, flag, add;
	void operator += (const int& val) {
		minv += val;
		flag += val;
		add += val;
	}
} tree[MAXN<<2];
void pushdown (int o) {
	if (tree[o].add) {
		tree[o<<1] += tree[o].add;
		tree[o<<1|1] += tree[o].add;
		tree[o].add = 0;
	}
}
void pushup (int o) {
	tree[o].minv = min(tree[o<<1].minv, tree[o<<1|1].minv);
	tree[o].flag = min(tree[o<<1].flag, tree[o<<1|1].flag);
}
void build (int o, int start, int end) {
	tree[o].start = start;
	tree[o].end = end;
	tree[o].add = 0;
	if (start == end) {
		tree[o].flag = diff[start] - start;
		tree[o].minv = diff[start];
		return;
	}
	int mid = (start + end) >> 1;
	build(o<<1, start, mid);
	build(o<<1|1, mid + 1, end);
	pushup(o);
}
void update (int o, int pos, int val) {
	//printf ("%d %d %d\n", tree[o<<1].start, tree[o].end, pos);
	if (pos <= tree[o].start) {
		tree[o] += val;
		return;
	}
	pushdown(o);
	if (pos <= tree[o<<1].end)
		update(o<<1, pos, val);
	update(o<<1|1, pos, val);
	pushup (o);
}
int query1 (int o) {
	//printf ("%d: %d %d %d\n", 1, tree[o].start, tree[o].end, tree[o<<1].flag);
	if (tree[o].start == tree[o].end)
		return tree[o].start;
	pushdown(o);
	int r;
	if (tree[o<<1].flag < 0)
		r = query1(o<<1);
	else
		r = query1(o<<1|1);
	pushup(o);
	return r;
}
int query2(int o) {
	//printf ("%d: %d %d %d\n", 2, tree[o].start, tree[o].end, tree[o<<1].minv);
	if (tree[o].start == tree[o].end)
		return tree[o].minv < 2 ? INF : tree[o].start;
	pushdown(o);
	int r;
	if (tree[o<<1|1].minv < 2)
		r = query2(o<<1|1);
	else
		r = min(query2(o<<1), tree[o<<1|1].start);
	pushup(o);
	return r;
}
int main () {
#ifdef TXT
	freopen ("in.txt", "r", stdin);
#endif
	int q, pos;
	while (~scanf ("%d%d", &n, &q)) {
		scanf("%s", str + 1);
		for (int i = 1; i <= n; i ++)
			diff[i] = diff[i - 1] + (str[i] == '(' ? 1 : -1);
		//for (int i = 1; i <= n; i ++)
		//	printf ("%d ", diff[i]);
		//printf ("\n");
		build(1, 1, n);
		query1(1);
		while (q --) {
			scanf ("%d", &pos);
			update(1, pos, str[pos] == '(' ? -2 : 2);
			str[pos] = str[pos] == ')' ? '(' : ')';
			pos = str[pos] == ')' ? query1(1) : query2(1);
			//printf ("%d %s\n", pos, str + 1);
			update(1, pos, str[pos] == '(' ? -2 : 2);
			str[pos] = str[pos] == ')' ? '(' : ')';
			printf ("%d\n", pos);
		}
	}
	return 0;
}

Measured memory_bytes: 26012
n = gets.to_i; s = Array.new(n)
res = 0; i = 0
n.times { |i|
s[i] = gets.to_i
  res += s[i]
}
if res % 10 != 0
  puts res
else
  s.sort.each { |val|
    if val % 10 != 0 then
      puts res -= val; exit
    end
  }
  puts res = 0
end


Measured memory_bytes: 1788
import java.io.*;

class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] strs = br.readLine().split(" ");
    int X = Integer.parseInt(strs[0]);
    int A = Integer.parseInt(strs[1]);
    
    System.out.println(X < A ? 0 : 10);
  }
}

Measured memory_bytes: 21204
#include <cstdlib>
#include <iostream>
#include <typeinfo>
//#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int a, b, k;
  cin >> a >> b >> k;
  int cnt = 0;
  int i;
  for (i = min(a,b); i >0; i--)
  {
    if (a % i == 0 && b % i == 0)
    {
      cnt++;
    }
    if(cnt==k){
      break;
    }
  }
  cout << i << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define N 250

/*int parent(int);
int left(int);
int right(int);
*/
int main()
{
  int i,A[N+1],n;
  scanf("%d",&n);
  for(i=1;i<=n;i++)
    {
      scanf("%d",&A[i]);
    }
  
   for(i=1;i<=n;i++)
    {
      printf("node %d: key = %d, ",i,A[i]);
    
  if(i != 1)
    {
      printf("parent key = %d, ",A[i/2]);
    }
  if(2*i <= n)
    {
      printf("left key = %d, ",A[2*i]);
    }
  if(2*i+1 <= n)
    {
      printf("right key = %d, ",A[2*i+1]);
    }
  printf("\n");
    }
  return 0;
}
/*
int parent(int i)
{
  return floor(i/2);
}
int left(int i)
{
  return 2*i;
}
int right(int i)
{
  return (2*i + 1);
}
*/



Measured memory_bytes: 2052
#include<iostream>
using namespace std;
int main(){
	int a[5];
	cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
	for(int i=0; i<5; i++){
		for(int l=0; l<4; l++){
			if(a[l]<a[l+1]){
				int c = a[l];
				a[l] = a[l+1];
				a[l+1] = c;
			}
		}
	}
	cout <<a[0]<<" "<<a[1]<<" "<<a[2]<<" "<<a[3]<<" "<<a[4]<<endl;
	return 0;
}

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

#define READ                freopen("in.txt", "r", stdin)
#define WRITE               freopen("out.txt", "w", stdout)

#define si(a)               scanf("%d", &a)
#define sii(a,b)            scanf("%d %d", &a, &b)
#define siii(a,b,c)         scanf("%d %d %d", &a, &b, &c)

#define CLR(a)              memset(a, 0, sizeof(a))
#define SET(a)              memset(a, -1, sizeof(a))

#define PI                  acos(-1.0)

#define pb                  push_back
#define mp                  make_pair
#define SORT(v)             sort(v.begin(), v.end())
#define REV(v)              reverse(v.begin(), v.end())
#define FOR(i, n)           for(int i=0; i<n; i++)
#define FOR1(i, n)          for(int i=1; i<=n; i++)
#define ROF(i, n)           for(int i=n-1; i>=0; i--)
#define ROF1(i, n)          for(int i=n; i>=1; i--)
#define LOOP(i, x, y)       for(int i=x; i<=y; i++)
#define fastIO()            ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);


typedef long long              LL;
typedef unsigned long long     ULL;
typedef vector<int>            VI;
typedef pair<int, int>         PII;
typedef pair<string, int>      PSI;
typedef pair<char, int>        PCI;

const int MAX = 10;
const double eps = 1e-9;
const int INF = 0x3f3f3f3f;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

//bool valid(int a, int b){ return (a>=1 and a<=n and b>=1 and b<=m); }


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

    if(a+b+c >= 22)
        cout << "bust" << endl;
    else
        cout << "win" << endl;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define brep(i,n) for(int i=n-1;i>=0;i--)
#define brep1(i,n) for(int i=n;i>=1;i--)
#define rep1(i,n) for(int i=1;i<n;i++)
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
#define ll long long

unsigned const int MOD = 1e9+7;



int main(void){
    string a;
    cin >> a;
    if(a[0] == a[1] || a[1] == a[2] || a[2] == a[3])cout << "Bad" << endl;
    else cout << "Good" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>
#include <math.h>

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef vector<vector<int>> vii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<ll> vll;

typedef pair<int, int> pii;

typedef queue<int> qi;
typedef queue<string> qs;


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

const ll MOD = pow(10, 9) + 7;

const ll MAX_N = pow(10, 10);

int main(){
    int n;
    cin >> n;
    vll D(n);
    rep(i, n) cin >> D[i];
    int m;
    cin >> m;
    vll T(m);
    rep(i, m) cin >> T[i];

    //D[i]の個数を入れるmapを作成
    map<ll, int> mapD;
    map<ll, int> mapT;

    rep(i, n){
        ll d = D[i];
        mapD[d]++;
    }
    rep(i, m){
        ll t = T[i];
        mapT[t]++;
    }

    if(m > n){
        cout << "NO" << endl;
        return 0;
    }

    rep(i, m){
        ll x = T[i];
        if(mapD[x] < mapT[x]){
            cout << "NO" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 28416
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#define INT long long int
#define MOD 1000000007
using namespace std;
string a, b, c;

string f(int x, int y, int z, int t)
{
    if( x > a.size() ) return "A";
    if( y > b.size() ) return "B";
    if( z > c.size() ) return "C";
    if( t == 0 ) return f(x+1, y, z, a[x]-'a');
    if( t == 1 ) return f(x, y+1, z, b[y]-'a');
    if( t == 2 ) return f(x, y, z+1, c[z]-'a');
    return 0;
}

int main()
{
    cin>>a>>b>>c;
    cout<<f(1, 0, 0, a[0]-'a');
}



Measured memory_bytes: 256
m, d= (int(i) for i in input().split())
ans = 0
for month in range(m):
  month = month+1
  for day in range(d):
      day += 1
      if(day > 9):
          d10 = day // 10
          d1 = day % 10
          if(d10 * d1 == month and d1 > 1 and d10 > 1):
              ans += 1
              #print(str(month)+"/"+str(day))
print(ans)

Measured memory_bytes: 38640
#include <set>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <vector>
#include <tuple>
#include <string>
#include <math.h>
#include <time.h>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <limits>
#include <climits>
#include <numeric>
#include <functional>

#define lnd '\n'
// #define reverse(i, n) for(ll i = n-1; i >= 0; --i)
#define from(i, n) for (ll i = 0; i < n; ++i)
#define loop(i, n) for(ll i = 0; i < n; i++)
#define REPN(i, n) for (ll i = 1; i <= n; ++i)
#define ALL(s) (s).begin(), (s).end()
#define rALL(s) (s).rbegin(), (s).rend()
#define sz(s) (int)(s).size()
#define mk make_pair
#define pb push_back
#define sqr(s) ((s) * (s))

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned int ui;

template <class T>
T GCD (T a, T b) {
  if(a == 0) return b;
  return GCD(b%a, a);
}

template <class T>
T LCM(T a, T b){
  return a*b/GCM(a,b);
}

template <class T>
T modpow(T x, T p){
    T res = 1;
    while(p > 0){
        if(p&1) res *= x;
        x *= x;
        p /= 2;
    }
    return res;
}

template <class T>
T modpow(T x, T p, ll mod){
    T res = 1;
    while(p > 0){
        if(p&1) res = (res*x)%mod;
        x = (x*x)%mod;
        p /= 2;
    }
    return res%mod;
}

template <class T>
void print(T a[], ll n){
    for (ll i = 0; i < n; i++) std::cout << a[i] << ' ';
    cout << endl;
}

template<class T>
void printc(T c){
    for(auto const& v: c) std::cout << v << ' ';
    cout << endl;
}

struct HASH{
  size_t operator()(const pair<long,long>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};

bool pair_sort(const pair<int, int> &p1, const pair<int,int> &p2){
    if(p1.first != p2.first) return p1.first < p2.first;
    else return p1.second < p2.second;
}

const int INF = std::numeric_limits<int>::max();
const ll M_INF = std::numeric_limits<ll>::min();
const ll LL_INF = std::numeric_limits<ll>::max();

void solution();
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solution();
    return 0;
}

void solution(){
  string s;
  cin >> s;
  if(s[2] == s[3] && s[4] == s[5]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}     

Measured memory_bytes: 256
N,M,Q=map(int,input().split())
x=[[0]*N for _ in range(N)]
c=x
for i in range(M):
  l,r=map(lambda x:int(x)-1,input().split())
  x[l][r]+=1
for i in range(N):
  for j in range(N):
    if j==0:
      c[i][j]=x[i][j]
    else:
      c[i][j]=c[i][j-1]+x[i][j]
for i in range(Q):
  p,q=map(lambda x:int(x)-1,input().split())
  count=0
  for i in range(p,q+1):
    if p!=0:
      count+=c[i][q]-c[i][p-1]
    else:
      count+=c[i][q]
  print(count)
    

Measured memory_bytes: 78688
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <stack>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

int main(){
    for(;;){
        int n,m;
        cin >> n >> m;
        if(!n and !m)break;
        vector<pair<ll, pair<int, int> > >pack(m);
        for (int i=0; i<m; i++) {
            ll a;
            int b,c;
            cin >> a >> b >> c;
            pack[i]={a,{b,c}};
        }
        sort(pack.begin(), pack.end());
        vector<int> ka(n+1,0);
        int ans = 1;
        ka[1]=1;
        for (int i=0; i<m; i++) {
            if (ka[pack[i].second.second]==1) {
                continue;
            }else{
                if (ka[pack[i].second.first]==1) {
                    ka[pack[i].second.second]=1;
                    ans++;
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1600
package main

import "fmt"

var N, K int
var x, y []int
var c []string

func main() {
	fmt.Scanf("%d %d", &N, &K)

	x := make([]int, N)
	y := make([]int, N)
	c := make([]string, N)

	K2 := K * 2

	for i := 0; i < N; i++ {
		fmt.Scanf("%d %d %s", &x[i], &y[i], &c[i])

		if c[i] == "W" {
			y[i] += K
		}

		x[i] %= K2
		y[i] %= K2
	}

	m := MakeMatrix(K2+1, K2+1)

	for i := 0; i < N; i++ {
		m[y[i]+1][x[i]+1]++
	}

	for y := 1; y < K2+1; y++ {
		for x := 1; x < K2+1; x++ {
			m[y][x] += m[y][x-1] + m[y-1][x] - m[y-1][x-1]
		}
	}

	max := 0
	for y := 0; y < K+1; y++ {
		for x := 0; x < K+1; x++ {
			tmp := m[y][x] - m[y][0] - m[0][x] + m[0][0]
			tmp += m[y][K2] - m[y][x+K] - m[0][K2] + m[0][x+K]
			tmp += m[y+K][x+K] - m[y+K][x] - m[y][x+K] + m[y][x]
			tmp += m[K2][x] - m[K2][0] - m[y+K][x] + m[y+K][0]
			tmp += m[K2][K2] - m[K2][x+K] - m[y+K][K2] + m[y+K][x+K]

			tmp = Max(tmp, N-tmp)
			max = Max(max, tmp)
		}
	}

	fmt.Println(max)
}

func MakeMatrix(w, h int) [][]int {
	m := make([][]int, w)
	for x := 0; x < w; x++ {
		m[x] = make([]int, h)
	}

	return m
}

func Max(x, y int) int {
	if x > y {
		return x
	}
	return y
}


Measured memory_bytes: 40832
#include <cstdio>
#include <cassert>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define int long long
using namespace std;

typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef unsigned long long ull; 
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const long long INF = 1e18;
const int M = 1e9 + 7;
//__int128


signed main() {
  // freopen("in.txt", "r", stdin);
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.setf(ios::fixed); cout.precision(10);
  long long a, b, k;
  cin >> a >> b >> k;
  if(a >= k) {
    cout << a - k << ' ' << b << endl;
  } else {
    cout << 0 << ' ' << max(a + b - k, 0ll) << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MAXN = 1e5 + 7;

ll hi[MAXN], dp[MAXN];

int main()
{
#ifdef LOCAL
    freopen("data.txt", "r", stdin);
#endif
    int n, k;
    cin >> n >> k;
    k = min(n, k);
    for (int i = 0; i != n; ++i)
       cin >> hi[i];
    for (int i = 1; i != k; ++i) {
        ll mini = abs(hi[0] - hi[i]), tmp;
        for (int j = 1; j != i; ++j) {
            if ((tmp = dp[j] + abs(hi[i] - hi[j])) < mini)
                mini = tmp;
        }
        dp[i] = mini;
    }
    for (int i = k; i != n; ++i) {
        ll mini = dp[i - k] + abs(hi[i - k] - hi[i]), tmp;
        for (int j = i - k + 1; j != i; ++j) {
            if ((tmp = dp[j] + abs(hi[i] - hi[j])) < mini)
                mini = tmp;
        }
        dp[i] = mini;
    }
    cout << dp[n - 1] << endl;
}

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

int main() {
	int n, d;
	cin >> n >> d;
	int ans = 0;
	rep(i, n) {
		ll x, y;
		cin >> x >> y;
		double sq = sqrt(x * x + y * y);
		if (sq <= d) ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

ll f(ll a, ll b) {
	if(b%a==0) return 2*b-a;
	return 2*a*(b/a)+f(b%a, a);
}

int main() {
	ll n, x;
	scanf("%lld%lld", &n, &x);
	printf("%lld\n", n+f(min(x, n-x), max(x, n-x)));
   	return 0;
}

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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  while (N > 0) {
    ans += N % 10;
    N /= 10;
  }
  if (ans == 1) {
    ans = 10;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
	int w, h, n;
	cin >> w >> h >> n;
	int x[n], y[n];
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}
	int nowx = x[0], nowy = y[0];
	int count = 0;
	for (int i = 1; i < n; i++) {
		int dx = x[i] - nowx, dy = y[i] - nowy;
		if (dx >= 0 && dy < 0) {
			count += dx - dy;
		} else if (dx < 0 && dy >= 0) {
			count += dy - dx;
		} else {
			if (dx < 0) {
				dx = -dx;
				dy = -dy;
			}
			count += max(dx, dy);
		}

		nowx = x[i];
		nowy = y[i];
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 3076
import java.util.Scanner;

public class Main {
    static final Scanner sc = new Scanner(System.in);
    
    public static void main(String[] args) {
        int N = nint();
        int L = nint();
        int[] a = nints(N, 1, 0);
        
        int idx = -1;
        for (int i = 1; i <= N-1; i++) {
            if (a[i] + a[i+1] >= L) {
                idx = i;
                break;
            }
        }
        
        if (idx == -1) {
            System.out.println("Impossible");
            return;
        }
        
        System.out.println("Possible");
        for (int i = 1; i < idx; i++) {
            System.out.println(i);
        }
        for (int i = N-1; i >= idx; i--) {
            System.out.println(i);
        }
    }
    
    private static long nlong() {
        return sc.nextLong();
    }

    private static int nint() {
        return sc.nextInt();
    }

    private static String nstr() {
        return sc.next();
    }

    private static char[] nchars() {
        return sc.next().toCharArray();
    }

    private static String[] nstrs(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++) {
            a[i] = nstr();
        }
        return a;
    }

    private static int[] nints(int n) {
        return nints(n, 0, 0);
    }

    private static int[] nints(int n, int padL, int padR) {
        int[] a = new int[padL + n + padR];
        for (int i = 0; i < n; i++)
            a[padL + i] = nint();
        return a;
    }

    private static char[][] nchars2(int h, int w) {
        return nchars2(h, w, 0);
    }

    private static char[][] nchars2(int h, int w, int pad) {
        char[][] a2 = new char[h + pad * 2][w + pad * 2];
        for (int i = 0; i < h; i++)
            System.arraycopy(nchars(), 0, a2[pad + i], pad, w);
        return a2;
    }
}

Measured memory_bytes: 61108
#include<iostream>
using namespace std;
 
int main(){
	int a,b;
	while(true){
		cin >> a >> b;
		if(a == 0 && b == 0) break;
		if(a > b)cout << b << " " << a << "\n";
		else cout << a << " " << b << "\n";
	}
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


int main(){
    LL n;cin >> n;
    LL ans = LINF;
    for (LL i = 1; i*i <= n; i++) {
        if(n%i==0){
            ans = min(ans,n/i+i-2);
        }
    }
    cout << ans << 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(){
    int a, b, c;
    cin >> a >> b >> c;
    if (a < b && b < c){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define INF 100000000
using namespace std;
typedef long long ll;

map<ll,ll> Dic(vector<ll>& v){
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());
	map<ll,ll> res;
	for(int i = 0;i < v.size();i++){
		res[v[i]] = i;
	}
	return res;
}

int main()
{
	ll N,K;
	cin >> N >> K;
	vector<ll> X1(N),Y1(N),D1(N),X2(N),Y2(N),D2(N),SX,SY,SD;
	SX.push_back(0), SX.push_back(INF);
	SY.push_back(0), SY.push_back(INF);
	SD.push_back(0), SD.push_back(INF);
	for(int i = 0;i < N;i++){
		cin >> X1[i] >> Y1[i] >> D1[i] >> X2[i] >> Y2[i] >> D2[i];
		SX.push_back(X1[i]), SX.push_back(X2[i]);
		SY.push_back(Y1[i]), SY.push_back(Y2[i]);
		SD.push_back(D1[i]), SD.push_back(D2[i]);
	}
	map<ll,ll> DX = Dic(SX),DY = Dic(SY),DD = Dic(SD);
	vector<vector<vector<ll>>> C(SX.size(), vector<vector<ll>>(SY.size(), vector<ll>(SD.size(), 0)));
	for(int i = 0;i < N;i++){
		for(int x = DX[X1[i]];x < DX[X2[i]];x++){
			for(int y = DY[Y1[i]];y < DY[Y2[i]];y++){
				for(int d = DD[D1[i]];d < DD[D2[i]];d++){
					C[x][y][d]++;
				}
			}
		}
	}
	ll res = 0;
	for(int x = 0;x < SX.size();x++){
		for(int y = 0;y < SY.size();y++){
			for(int d = 0;d < SD.size();d++){
				if(C[x][y][d] >= K){
					res += (SX[x + 1] - SX[x]) * (SY[y + 1] - SY[y]) * (SD[d + 1] - SD[d]);
				}
			}
		}
	}
	cout << res << endl;
	return 0;
}

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

int main() {
	string str;
	getline(cin, str);
	istringstream input(str);
	
	while (!input.eof()) {
		input >> str;
		for (int i = 0; i < str.length(); ++i) {
			if (i + 4 < str.length() && str[i] == 'a' && str[i + 1] == 'p' && str[i + 2] == 'p' && str[i + 3] == 'l' && str[i + 4] == 'e') {
				str[i] = 'p';
				str[i + 1] = 'e';
				str[i + 2] = 'a';
				str[i + 3] = 'c';
				str[i + 4] = 'h';
				i += 4;
			}
			else if (i + 4 < str.length() && str[i] == 'p' && str[i + 1] == 'e' && str[i + 2] == 'a' && str[i + 3] == 'c' && str[i + 4] == 'h') {
				str[i] = 'a';
				str[i + 1] = str[i + 2] = 'p';
				str[i + 3] = 'l';
				str[i + 4] = 'e';
				i += 4;
			}
		}
		cout << str << (input.eof() ? '\n' : ' ');
	}
	return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 2e5 + 5;

int n;
string s;

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n >> s;
	int r = count(all(s), 'R');
	int w = count(s.begin(), s.begin() + r, 'W');
	cout << w << endl;
	return 0;
}


Measured memory_bytes: 3764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Numerics;

public class Program
{
    public static void Main(string[] args)
    {
        //string[] line = Console.ReadLine().Split(' ');

        string s = Console.ReadLine();


        int d = int.MaxValue;

        for (int i = 0; i <= s.Length - 3; i++)
        {
            int r = int.Parse(s.Substring(i, 3));

            d = Math.Min(d, Math.Abs(753 - r));
        }


        Console.WriteLine(d);
        Console.ReadLine();
    }
}


Measured memory_bytes: 13140
using System;
class aoj
{
    static void Main()
    {
        char[,] a = new char[8, 8];
        for(int i = 0; i < 8; i++)
        {
            string u = Console.ReadLine();
            for (int j = 0; j < 8; j++)
                a[i, j] = u[j];
        }
        Console.WriteLine("90");
        for(int i = 0; i < 8; i++)
        {
            for(int j = 7; j >= 0; j--)
            {
                    Console.Write(a[j,i]);
            }
            Console.WriteLine();
        }
        Console.WriteLine("180");
        for(int i = 7; i >= 0; i--)
        {
            for(int j = 7; j >= 0; j--)
            {
                    Console.Write(a[i, j]);
            }
            Console.WriteLine();
        }
        Console.WriteLine("270");
        for(int i = 7; i >= 0; i--)
        {
            for(int j = 0; j < 8; j++)
            {
                    Console.Write(a[j, i]);
            }
            Console.WriteLine();
        }
    }
}

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

using namespace std;

#define CARD_SIZE 3

int main()
{
	int A[CARD_SIZE][CARD_SIZE];
	for (int i = 0; i < CARD_SIZE; i++) {
		for (int j = 0; j < CARD_SIZE; j++) {
			cin >> A[i][j];
		}
	}

	int N;
	cin >> N;
	vector < int >b(N);
	for (int i = 0; i < N; i++) {
		cin >> b[i];
	}
	sort(b.begin(), b.end());

	bool isOpen[CARD_SIZE][CARD_SIZE];
	for (int i = 0; i < CARD_SIZE; i++) {
		for (int j = 0; j < CARD_SIZE; j++) {
			isOpen[i][j] =
			    binary_search(b.begin(), b.end(), A[i][j]);
		}
	}

	// check row
	for (int i = 0; i < CARD_SIZE; i++) {
		bool isOK = true;
		for (int j = 0; j < CARD_SIZE; j++) {
			isOK = isOK && isOpen[i][j];
		}
		if (isOK) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	// check column
	for (int i = 0; i < CARD_SIZE; i++) {
		bool isOK = true;
		for (int j = 0; j < CARD_SIZE; j++) {
			isOK = isOK && isOpen[j][i];
		}
		if (isOK) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	// check Diagonal
	if ((isOpen[0][0] && isOpen[1][1] && isOpen[2][2])
	    || (isOpen[0][2] && isOpen[1][1] && isOpen[2][0])) {
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;

	return 0;
}


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

const int INF=2000000000;

int main(){
  int N, K; cin >> N >> K;
  vector<int> h(N);
  for(int &x: h) cin >> x;
  vector<int> dp(N, INF);
  dp[0]=0;
  for(int i=1;i<N;i++){
    for(int j=1;j<=K && i-j>=0;j++){
      int dh=abs(h[i]-h[i-j]);
      dp[i]=min(dp[i], dp[i-j]+dh);
    }
  }
  cout << dp[N-1] << endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include <iomanip>
#include<math.h>

#define rep0(i,N) for(int i=0;i<N;i++)
#define rep1(i,a,N) for(int i=0+a;i<N;i++)
#define lint long long int
#define SIZE 100005

using namespace std;

int main(){
	int a[10];
	cin>>a[1]>>a[2]>>a[5];
	int sum;
	sum=a[5]*3;
	a[9]=sum-a[1]-a[5];
	a[8]=sum-a[2]-a[5];
	a[7]=sum-a[8]-a[9];
	a[4]=sum-a[1]-a[7];
	a[6]=sum-a[4]-a[5];
	a[3]=sum-a[1]-a[2];
	cout<<a[1]<<" "<<a[2]<<" "<<a[3]<<endl;
	cout<<a[4]<<" "<<a[5]<<" "<<a[6]<<endl;
	cout<<a[7]<<" "<<a[8]<<" "<<a[9]<<endl;
return 0;
}

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

int main() {
  typedef long long ll;
  string S;
  cin >> S;
  
  int count = 0;
  int max = 0;
  REP(i, S.size()) {
    if (S.at(i) == 'A' || S.at(i) == 'C' || S.at(i) == 'G' || S.at(i) == 'T') {
      count++;
      if (count > max) {
        max = count;
      }
    }
    else {
      if (count > max) {
        max = count;
      }
      count = 0;
    }
  }
  cout << max << endl;
}


Measured memory_bytes: 384
def wczytaj_liste(): 
    wczytana_lista = input()
    lista_znakow = wczytana_lista.split()
    ostateczna_lista = []
    for element in lista_znakow:
        ostateczna_lista.append(int(element))
    return ostateczna_lista


def kamienie_niemilosci(): 
    N, K = wczytaj_liste()
    A = wczytaj_liste()
    win = {1:'First', 2:'Second'}
    odp = []
    for i in range(K+1):
        if i < A[0]:
            odp.append(2)
        else:
            czy_istnieje = False
            for male_a in A: 
                if i - male_a >= 0 and odp[i-male_a] == 2: 
                    czy_istnieje = True
            if czy_istnieje: 
                odp.append(1)
            else: 
                odp.append(2)
    print(win[odp[K]])
    
kamienie_niemilosci()

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

int main(){

    cin.tie(0);
    ios::sync_with_stdio(0);

    string s;
    ll k;
    
    cin >> s >> k;
    
    int n = (int)s.size();
    
    if(s == string(n,s[0])){
        cout << n * k / 2 << endl;
        return 0;
    }
    
    ll a = 1, b = 1;
    
    int i = 0;
    ll ans = 0;
    
    while(i < n){
        ll cnt = 1;
        while(s[i]==s[i+1]){
            cnt++;
            i++;
        }
        ans += cnt / 2;
        i++;
    }
    
    for(int i = 1;;i++){
        if(s[0]==s[i]) a++;
        else break;
    }

    for(int i = n - 2;; i--){
        if(s[n-1] == s[i]) b++;
        else break;
    }
    
    if(s[0]!=s[n-1]) {
        cout << ans * k << endl;
    } else {
        cout << ans * k - (a/2 + b/2 - (a+b)/2) * (k - 1) << endl;
    }
    
}


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

string s;
int i;

/*
 * expr   ::= term [ "-" term]*
 * term   ::= number | "S<" expr ">"
 * number ::= [0-9]+
 */

ll expr();
ll term();
ll number();

ll expr(){
    ll val=term();
    while(s[i]=='-'){
        i++;
        val=val>>min(term(),32ll);
    }
    return val;
}
ll term(){
    if(isdigit(s[i])) return number();
    i+=2;
    ll val=expr();
    val=val*val%1'000'000'007;
    i++;
    return val;
}
ll number(){
    string val;
    while(isdigit(s[i])){
        val.push_back(s[i++]);
    }
    return stoll(val);
}

bool input(){return getline(cin,s) and s!="#";}

ll solve(){
    for(auto c=s.begin();c!=s.end();){
        if(*c==' ') c=s.erase(c);
        else c++;
    }
    for(int i=2;i<s.size();i++){
        if(isdigit(s[i]) or s[i]=='S'){
            if(s[i-1]=='>' and s[i-2]=='>'){
                s[i-1]='-';
                s.erase(s.begin()+i-2);
            }
        }
    }
    i=0;
    return expr();
}


int main(void){
    while(input()){
        cout<<solve()<<endl;
    }
    return 0;
}



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

// tの長さが2以上であり, かつtの中の文字のうち過半数が同じ文字であるとき, tはアンバランスである
// 2 <= |s| <= 10 ^ 5
// O(n)
// 入力の中からアンバランスな連続する部分文字列のインデックスを出力 (インデックスは1始まり)
// アンバランスな部分文字列が存在しない場合は, '-1 -1'と出力
// 存在する場合は, 's[a]s[a+1]..s[b]として(1 <= a < b <= |s|)として, 'a b' と出力

void solve() {
    string s;
    cin >> s;

    // |t| = 2; 2 <= charof(t)
    // t = 'aa', ..
    // |t| = 3; 2 <= charof(t)
    // t = ('aaa', 'xaa', 'aax',) 'axa', ..
    // |t| = 4; 3 <= charof(t)
    // t = ('aaaa', 'aaax', 'xaaa', 'axaa', 'aaxa')
    // |t| = 5; 3 <= charof(t)
    // t = ('aaaaa', 'xaaax', 'axaxa', 'aaaxx', 'xxaaa', 'xaxaa', 'aaxax', 'xaaxa', 'axaax')
    // |t| = 6; 4 <= charof(t)
    // t = ('aaaaaa', 'aaaaxx', 'axaaxa', 'xaaaax',

    // 'aa'か'axa'パターンを探せば良さそう？ 最長とか言われてないし

    smatch result;
    bool b = std::regex_search(s, result, regex("(.)\\1|(.).\\2"));
    if (!b) {
        cout << "-1 -1" << endl;
    } else {
        // cout << result.str() << endl;
        auto p = result.position();
        cout << p+1 << ' ' << p + result.length() << endl;
    }
}

int main() {
    ios::sync_with_stdio(false);
    solve();
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
  ll N,mainasu=0,ans=0;
  cin>>N;
  vector<ll> A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    if(A.at(i)<0)
      mainasu++;
    A.at(i) = abs(A.at(i));
    ans += A.at(i);
  }
  if(mainasu%2==0)
    cout<<ans<<endl;
  else{
    sort(A.begin(),A.end());
    cout<<ans-2*A.at(0)<<endl;
  }
}

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

int main(){
    string s; cin >>s;
    int odd1 = 0;
    int even1 =0;
    int n = s.size();
    int ans = 0;
    for(int i=0; i<n; ++i){
        if(i%2==0){
            if(s[i]=='1') even1 ++;
        }
        else{
            if(s[i]=='1') odd1 ++;
        }
    }
    ans = odd1+((n+1)/2-even1);
    ans = min(even1 + (n/2 - odd1),ans);
    cout << ans << endl;
}

Measured memory_bytes: 512