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

int tp(char s) {
  if (s == 'o') {
    return 100;
  } else {
    return 0;
  }
}

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

  int ans = 700;
  ans += tp(s[0]);
  ans += tp(s[1]);
  ans += tp(s[2]);

  cout << ans << endl;

}

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

int main() {
    // init data
    int days = 0;
    std::cin >> days;
    std::vector<std::vector<int>> data;  // days , 3
    data.resize(days);
    for (int i=0;i<days;i++) {
        data[i].resize(3);
    }
    for (int i=0;i<days;i++) {
        for (int j=0;j<3;j++) {
            std::cin >> data[i][j];
        }
    }

    std::vector<std::vector<int>> memory;
    memory.resize(days);
    for (int i=0;i<days;i++) {
        memory[i].resize(3);
    }
    memory[0][0] = data[0][0];
    memory[0][1] = data[0][1];
    memory[0][2] = data[0][2];

    for (int i=1;i<days;i++) {
        for (int j=0;j<3;j++) {
            memory[i][j] = memory[i-1][(j+1)%3] + data[i][j];
            memory[i][j] = std::max(memory[i][j], memory[i-1][(j+2)%3] + data[i][j]);
        }
    }

    std::cout << std::max(std::max(memory[days-1][0], memory[days-1][1]), memory[days-1][2]);

    return 0;
}

Measured memory_bytes: 11136
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <valarray>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <limits>
#include <numeric>
#include <utility>
#include <deque>
#include <unordered_set>
#include <unordered_map>
#include <regex>
#include <array>
#include <bitset>
#include <complex>
#include <tuple>
#include <random>

using namespace std;
using ll = long long;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  int ans = ceil(1.0 * n / 1.08);
  if (floor(ans * 1.08) == n)
    cout << ans << endl;
  else
    cout << ":(" << endl;

  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;

    set<int> s;
    REP(i, N) {
        int a;
        cin >> a;
        s.insert(a);
    }

    cout << s.size() << endl;


}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextStr() string {
	sc.Scan()
	s := sc.Text()
	return s
}

func getRuneAt(s string, i int) rune {
	rs := []rune(s)
	return rs[i]
}

func main() {
	sc.Split(bufio.ScanWords)

	var val []int
	val = make([]int, 5)
	for index := 0; index < 5; index++ {
		val[index] = nextInt()
	}
	k := nextInt()

	for i := 0; i < 4; i++ {
		for j := i + 1; j < 5; j++ {
			if !canCommunicate(val[i], val[j], k) {
				fmt.Print(":(")
				return
			}
		}
	}
	fmt.Print("Yay!")
}

func canCommunicate(a int, b int, waveRange int) bool {
	return (b - a) <= waveRange
}


Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)
#define all(c) begin(c),end(c)
 
template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const long long INF = 0x3f3f3f3f3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9; 

// 多次元配列を作る
// vector<vector<int>> vn(n, vector<int>(3, 0));

// 多次元配列の dump
// for (vector<int> v : vn) {
//     cout << v;
// }

// printf("%d\n", n);
// printf("%lld\n", n);

int main(void){
    int n;
    scanf("%d", &n);
    // printf("%d\n", n);

    vector<int> vn(n, 0);
    REP(i,n) {
        int m;
        scanf("%d", &m);
        vn[i] = m;
    }
    std::sort(vn.begin(),vn.end());
    int min_m;
    while(vn.size() > 1) {
        int nm = vn[1] % vn[0];
        vn.erase(vn.begin() + 1);
        if(nm == 1){
            min_m = 1;
            break;
        } else if (nm > 1) {
            vn.insert(vn.begin(), nm);
        } else if (vn.size() == 1) {
            // printf("last\n");
            min_m = vn[0];
        }
        // cout << nm;
        // cout << vn;
        // printf("\n");
    }
    printf("%d", min_m);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int N=210;

int gi() {
	int x=0,o=1;char ch=getchar();
	while(!isdigit(ch)&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,dep[N];
char s[N];
bool G[N][N];

int bfs(int s) {
	memset(dep,-1,sizeof(dep));
	dep[s]=0;queue<int> q;q.push(s);
	int ans=0;
	while(!q.empty()) {
		int u=q.front();q.pop();
		ans=max(ans,dep[u]+1);
		for(int v=1;v<=n;v++)
			if(G[u][v]) {
				if(!~dep[v]) dep[v]=dep[u]+1,q.push(v);
				else if(abs(dep[u]-dep[v])&1^1) cout<<-1,exit(0);
			}
	}
	return ans;
}

int main() {
	cin>>n;
	for(int i=1;i<=n;i++) {
		scanf("%s",s+1);
		for(int j=1;j<=n;j++) G[i][j]=s[j]-'0';
	}
	int ans=0;
	for(int i=1;i<=n;i++) ans=max(ans,bfs(i));
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
t1, t2 = map(int,input().split())
a1, a2 = map(int,input().split())
b1, b2 = map(int,input().split())

a1 = t1*a1
a2 = t2*a2
b1 = t1*b1
b2 = t2*b2

if (a1 + a2) == (b1 + b2):
    print('infinity')
    exit(0)

elif (a1 + a2) > (b1 + b2):
    a1, b1 = b1, a1
    a2, b2 = b2, a2
if b1 > a1:
    print(0)
    exit(0)

tmp00 = a1 - b1
tmp01 = b1 + b2 - a1 - a2

ans = tmp00 // tmp01 * 2 + 1
if tmp00 % tmp01 == 0:
    ans -= 1

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
int main() {
	char n[6];
	int ans = 0;
	scanf("%s", n);
	for (int i = 0; i < 6; i++)
	{
		ans += (n[i] == '1') ? 1 : 0;
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
*/

ll n,a[100010],d[100010]={},ans=0;
int b=0,c=0;

void init(){
	cin>>n;
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	rep(i,n){
		if(a[i]<0)b++;
		if(a[i]>0)c++;
		ans+=abs(a[i]);
	}
}

int main(void){
	init();
	if(a[0]<=0 && a[n-1]>=0){//異符号がある
		//全部いける
		cout<<ans<<endl;
		ll tmp=a[n-1];
		d[n-2]=1;
		irep(i,n-2){
			if(a[i+1]>0){
				d[i]=0;
			}else{
				d[i]=1;
			}
		}
		rep(i,n-1){
			if(a[i]==0){
				if(d[i]==1){
					if(tmp>0){
						cout<<tmp<<" "<<a[i]<<endl;
						tmp=tmp-a[i];
					}else{
						cout<<a[i]<<" "<<tmp<<endl;
						tmp=a[i]-tmp;
					}
				}else{
					if(tmp<0){
						cout<<tmp<<" "<<a[i]<<endl;
						tmp=tmp-a[i];
					}else{
						cout<<a[i]<<" "<<tmp<<endl;
						tmp=a[i]-tmp;
					}
				}
			}else if(a[i]<0){
				if(d[i]==0){
					cout<<a[i]<<" "<<tmp<<endl;
					tmp=a[i]-tmp;
				}else{
					cout<<tmp<<" "<<a[i]<<endl;
					tmp=tmp-a[i];
				}
			}else{
				if(d[i]==1){
					cout<<a[i]<<" "<<tmp<<endl;
					tmp=a[i]-tmp;
				}else{
					cout<<tmp<<" "<<a[i]<<endl;
					tmp=tmp-a[i];
				}
			}
		}
		// rep(i,n)cerr<<d[i]<<" ";
		// cerr<<endl;
		cerr<<"debug:"<<tmp<<endl;
	}else if(a[0]>0){//全て正
		//絶対値最小の要素以外は行ける
		cout<<ans-2*abs(a[0])<<endl;
		ll tmp=a[0];
		d[n-1]=1;
		irep(i,n-2){
			if(a[i+1]>0){
				d[i]=0;
			}else{
				d[i]=1;
			}
		}
		reg(i,1,n-1){
			if(a[i]==0){
				if(d[i]==1){
					if(tmp>0){
						cout<<tmp<<" "<<a[i]<<endl;
						tmp=tmp-a[i];
					}else{
						cout<<a[i]<<" "<<tmp<<endl;
						tmp=a[i]-tmp;
					}
				}else{
					if(tmp<0){
						cout<<tmp<<" "<<a[i]<<endl;
						tmp=tmp-a[i];
					}else{
						cout<<a[i]<<" "<<tmp<<endl;
						tmp=a[i]-tmp;
					}
				}
			}else if(a[i]<0){
				if(d[i]==0){
					cout<<a[i]<<" "<<tmp<<endl;
					tmp=a[i]-tmp;
				}else{
					cout<<tmp<<" "<<a[i]<<endl;
					tmp=tmp-a[i];
				}
			}else{
				if(d[i]==1){
					cout<<a[i]<<" "<<tmp<<endl;
					tmp=a[i]-tmp;
				}else{
					cout<<tmp<<" "<<a[i]<<endl;
					tmp=tmp-a[i];
				}
			}
		}
		cerr<<"debug:"<<tmp<<endl;
	}else{//全て負
		cout<<ans-2*abs(a[n-1])<<endl;
		ll tmp=a[n-1];
		d[n-2]=1;
		irep(i,n-1){
			if(a[i+1]>0){
				d[i]=0;
			}else{
				d[i]=1;
			}
		}
		rep(i,n-1){
			if(a[i]==0){
				if(d[i]==1){
					if(tmp>0){
						cout<<tmp<<" "<<a[i]<<endl;
						tmp=tmp-a[i];
					}else{
						cout<<a[i]<<" "<<tmp<<endl;
						tmp=a[i]-tmp;
					}
				}else{
					if(tmp<0){
						cout<<tmp<<" "<<a[i]<<endl;
						tmp=tmp-a[i];
					}else{
						cout<<a[i]<<" "<<tmp<<endl;
						tmp=a[i]-tmp;
					}
				}
			}else if(a[i]<0){
				if(d[i]==0){
					cout<<a[i]<<" "<<tmp<<endl;
					tmp=a[i]-tmp;
				}else{
					cout<<tmp<<" "<<a[i]<<endl;
					tmp=tmp-a[i];
				}
			}else{
				if(d[i]==1){
					cout<<a[i]<<" "<<tmp<<endl;
					tmp=a[i]-tmp;
				}else{
					cout<<tmp<<" "<<a[i]<<endl;
					tmp=tmp-a[i];
				}
			}
		}
		cerr<<"debug:"<<tmp<<endl;
	}
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  set<int> colors;
  colors.insert(a);
  colors.insert(b);
  colors.insert(c);
  
  cout << colors.size() << endl;
  return 0;
}


Measured memory_bytes: 256
N = int(input())
# A = input().split()
# B = list(map(int, A))

# A.sort()
# print(B)

A = list(map(int, input().split()))
A.sort()
A.reverse()
# print(A)

tapu = 0
tapi = 0

i = 0
while i + 1 < N:
    if A[i] == A[i + 1]:
        if tapu == 0:
            tapu = A[i]
            i += 1
        elif tapi == 0:
            tapi = A[i]
            i += 1
            break
    i += 1

ans = tapu * tapi
print(ans)


Measured memory_bytes: 14252
#include <stdio.h>

int main(void){

  char S[100];
  scanf("%s",&S);
  int i, j, count1=0, count2=0;
  for(i=0;S[i]!='\0';i++){
    count1+=1;
  }
  for(j=0;j<count1/2;j++){
    if(S[j]!=S[count1-j-1]){
      count2+=1;
    }
  }
  printf("%d\n",count2);
  return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		var s = Str;
		var r = s.Count(c => c == 'R');
		var w = N - r;
		WriteLine(r > w ? "Yes" : "No");
	}
}


Measured memory_bytes: 13268
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut trains = vec![];
    for i in 0..n - 1 {
        let v = read_vec::<usize>();
        trains.push((v[0], v[1], v[2]));
    }
    for start in 0..n - 1 {
        let mut cur_time = 0;
        for j in start..n - 1 {
            let (c, s, f) = (trains[j]);
            if cur_time < s {
                cur_time = s;
            } else if cur_time % f == 0 {
                ;
            } else {
                cur_time += f - (cur_time % f);
            }
            cur_time += c;
        }
        println!("{}", cur_time);
    }
    println!("{}", 0);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
static const int N=100;

int main(){
  int n,p[N+1],m[N+1][N+1],i,j,k,z,tmp;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    scanf("%d%d",&p[i-1],&p[i]);
  }

  for(i=1;i<=n;i++)
    m[i][i]=0;

  for(j=2;j<=n;j++){
    for(i=1;i<=n-j+1;i++){
      k=i+j-1;
      m[i][k]=(1<<21);
      for(z=i;z<=k-1;z++){
       	m[i][k]=fmin(m[i][k],m[i][z]+m[z+1][k]+p[i-1]*p[z]*p[k]);
	
      }
    }
  }

  printf("%d\n",m[1][n]);

  return 0;
}



Measured memory_bytes: 2040
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int mod=1e9+7;
int fac(int n) { int res=1;
	for (int i=1;i<=n;++i) res=1ll*res*i%mod;
	return res;
}

int main() {
	int n=read(),m=read(); if (n<m) swap(n,m);
	if (n==m) printf("%d\n",2ll*fac(n)*fac(m)%mod);
	else if (n==m+1) printf("%d\n",1ll*fac(n)*fac(m)%mod);
	else puts("0");
	return 0;
}

Measured memory_bytes: 3664
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
string S;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    cin >> S;
    int r = 0;
    for (auto &val : S)
    {
        if (val == 'R')
        {
            r++;
        }
    }
    int b = N - r;
    if (r > b)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
from fractions import gcd
n, m = map(int, input().split())
a = [int(i)//2 for i in input().split()]


def lcm(x, y):
    return x*y//gcd(x, y)


l = 1
for i in a:
    l = lcm(l, i)
for i in a:
    if l//i % 2 == 0:
        print(0)
        exit()
print((m//l+1)//2)

Measured memory_bytes: 16316
from collections import deque

K = int(input())

q = deque()
for i in range(1,10):
    q.append(i)
ans=0
cnt=0
while cnt<K:
    cnt+=1
    current = q.popleft()

    dn = [-1,0,1]
    for i in dn:
        if current%10+i<0 or current%10+i>9:
            continue
        q.append(current*10+current%10+i)
else:
    ans=current
    
print(ans)

Measured memory_bytes: 18760
# encoding: utf-8
import math
N, K = map(int, input().split())
x = list(map(int, input().split()))

# find position of Mr.Sunuke
for i_snk, xi in enumerate(x):
    if xi >= 0: break

# (left, right) * K patterns, left + right = K
min_dist = (x[-1] - x[0]) * K
for left in range(K + 1):
    right = K - left
    # skip
    # print("#", i_snk, left, right)
    if i_snk - left < 0: continue
    elif right + i_snk > N: continue
    # calc dist
    left_x = x[i_snk - left]
    right_x = x[i_snk + right - 1]
    tocorner = int(min(math.fabs(left_x), math.fabs(right_x)))
    side2side = right_x - left_x
    # print("##", i_snk, left_x, right_x, tocorner + side2side)
    if tocorner + side2side < min_dist: min_dist = tocorner + side2side

print(min_dist)


Measured memory_bytes: 15020
#include <bits/stdc++.h>
#define ll long long
#define pb emplace_back
#define mp make_pair

using namespace std;

int main()
{
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10);
	#ifdef PIYUSH_HOME
		I_O;
	#else
	#define print(...) 0
	#endif
	string s; cin >> s;
	bool res = false;
	if(s[0] != 'A')
		res = true;
	int t = 0;
	for (int i = 0; i < s.size(); ++i)
	{
		if(s[i] > 'z' || s[i] < 'a')
			t++;
	}
	if(t != 2)
		res = true;
	bool r = false;
	for (int i = 2; i < s.size() - 1; ++i)
	{
		if(s[i] == 'C')
			r = true;
	}
	if(!r)
		res = true;
	if(res)
		cout << "WA";
	else
		cout << "AC";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#define _USE_MATH_DEFINES

int main()
{
    char str[4];
    int count=0,value=700,length=0;

    scanf("%s",str);


    for(int i=0;i<3;i++){
	if (str[i]=='o')
	    count++;
    }


    value=value+count*100;

    printf("%d",value);

    return 0;
}




Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    LL N,M;cin >> N >> M;
    if(abs(N-M)>1)cout << 0 << endl;
    else if(abs(N-M)==0){
        LL ans = 1;
        for(int i = N;i>1;i--)ans = (ans*i)%MOD;
        for(int j = M;j>1;j--)ans = (ans*j)%MOD;
        cout << ans*2%MOD << endl;
    }
    else{
        LL ans = 1;
        for(int i = N;i>1;i--)ans = (ans*i)%MOD;
        for(int j = M;j>1;j--)ans = (ans*j)%MOD;
        cout << ans%MOD << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,flag=0;
  cin>>n;
  while(n>0)
  {
    int r=n%10;
    if(r==7)
    {
      flag=1;
      break;
    }
    n=n/10;
  }
  if(flag)
    cout<<"Yes\n";
  else
    cout<<"No\n";
  return 0;
}


Measured memory_bytes: 3624
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int X = sc.nextInt();
    int Y = sc.nextInt();

    if (N < K) {
      System.out.println(N * X);
    } else {
      System.out.println((K * X) + ((N - K) * Y));
    }

  }
}

Measured memory_bytes: 23124
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Map;
import java.util.HashMap;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author lucasr
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		MyScanner in = new MyScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		DFriends solver = new DFriends();
		solver.solve(1, in, out);
		out.close();
	}

	static class DFriends {
		public void solve(int testNumber, MyScanner sc, PrintWriter out) {
			int N = sc.nextInt();
			int M = sc.nextInt();
			UnionFind uf = new UnionFind(N);
			for (int i = 0; i < M; i++) {
				int a = sc.nextInt() - 1;
				int b = sc.nextInt() - 1;
				uf.union(a, b);
			}
			Map<Integer, Integer> counter = new HashMap<>();
			int max = 0;
			for (int i = 0; i < N; i++) {
				int val = uf.find(i);
				int tmp = counter.getOrDefault(val, 0) + 1;
				max = Math.max(max, tmp);
				counter.put(val, tmp);
			}
			out.println(max);
		}

	}

	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;

		public MyScanner(InputStream is) {
			br = new BufferedReader(new InputStreamReader(is));
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}

	static class UnionFind {
		int[] rep;

		public UnionFind(int size) {
			rep = new int[size];
			for (int i = 0; i < size; i++) {
				rep[i] = i;
			}
		}

		public int find(int val) {
			if (rep[val] != val) {
				return rep[val] = find(rep[val]);
			}
			return val;
		}

		public boolean union(int a, int b) {
			int aRep = find(a);
			int bRep = find(b);
			if (aRep == bRep) return false;
			rep[aRep] = bRep;
			return true;
		}

	}
}



Measured memory_bytes: 69340
#include<bits/stdc++.h>
using namespace std;
#pragma region Macros
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
using P = pair<ll, ll>;
#define VEC(type, name, size)\
    V<type> name(size);\
    IN(name)
#define VVEC(type, name, h, w)\
    VV<type> name(h, V<type>(w));\
    IN(name)
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LL(...)\
    ll __VA_ARGS__;\
    IN(__VA_ARGS__)
#define STR(...)\
    string __VA_ARGS__;\
    IN(__VA_ARGS__)
#define CHAR(...)\
    char __VA_ARGS__;\
    IN(__VA_ARGS__)
#define DOUBLE(...)\
    DOUBLE __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LD(...)\
    LD __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T a) { cin >> a; }
void scan(int &a) { cin >> a; }
void scan(long long &a) { cin >> a; }
void scan(char &a) { cin >> a; }
void scan(double &a) { cin >> a; }
void scan(long double &a) { cin >> a; }
void scan(char a[]) { scanf("%s", a); }
void scan(string &a) { cin >> a; }
template <class T> void scan(V<T> &);
template <class T, class L> void scan(pair<T, L> &);
template <class T> void scan(V<T> &a) { for(auto &i : a) scan(i); }
template <class T, class L> void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template <class T> void scan(T &a) { cin >> a; }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
template <class T> inline void print(T x){ cout << x << '\n';}
struct inputoutputfaster{
    inputoutputfaster(){
        ios::sync_with_stdio(false);\
        cin.tie(nullptr);
        cout << fixed << setprecision(15);
    }
}inputoutputfaster_;
template <class T> V<T> press(V<T> &x){ 
    V<T> res = x;
    sort(all(res));
    res.erase(unique(all(res)), res.end());
    REP(i, SZ(x)){
        x[i] = lower_bound(all(res), x[i]) - res.begin();
    }
    return res;
}
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; }
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
inline void err(bool b = true) {if(b) {cout << -1 << '\n'; exit(0);}}
template<class T> inline void fin(bool b = true, T e = 0) {if(b) {cout << e << '\n'; exit(0);}}
template<class T> T divup(T x, T y) {return (x+(y-1))/y;}
template <typename T> T pow(T a, long long n, T e = 1) {T ret = e; while (n) {if (n & 1) ret *= a; a *= a; n >>= 1; } return ret; }
const ll INF = 1e18;
#pragma endregion

int main(){
    INT(x, t);
    print(max(x - t, 0));
}

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

int N, M, Q;
vector<int> a, b, c, d;

int score(vector<int> A) {
    int res = 0;
    rep(i, Q) if (A[b[i]] - A[a[i]] == c[i]) res += d[i];
    return res;
}

int main() {
    cin >> N >> M >> Q;
    a.resize(Q); b.resize(Q); c.resize(Q); d.resize(Q);
    rep(i, Q){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--, b[i]--;
    }
    queue<vector<int>> que;
    rep(i, M){
        vector<int> q = {i+1};
        que.push(q);
    }
    int ans = 0;
    while (!que.empty()){
        vector<int> elem = que.front();
        que.pop();
        if (elem.size()==N) ans = max(ans, score(elem));
        else {
            repi(i, elem[elem.size()-1], M+1){
                vector<int> elem_new = elem;
                elem_new.push_back(i);
                que.push(elem_new);
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 9800
n = int(input())
num_list = [97] * n
target = n - 1
tmp_target = n - 1
max_num = 97
if n==1:
    print('a')
while tmp_target > 0:
    print("".join(list(map(chr, num_list))))
    if max(num_list[0:target:]) >= num_list[target]:
        num_list[target] += 1
    else:
        num_list[target] = 97
        tmp_target = target - 1
        while tmp_target > 0:
            if max(num_list[0:tmp_target:]) >= num_list[tmp_target]:
                num_list[tmp_target] += 1
                break
            else:
                num_list[tmp_target] = 97
                tmp_target -= 1

Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

ll dp[101][101];

void COMinit() {
    rep(i, 101) {
        dp[i][0] = 1;
        repd(j, 1, i + 1) {
            dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
        }
    }
}

int main()
{
    ll N, P;
    cin >> N >> P;
    ll K = 0, G = 0;
    rep(i, N) {
        ll A;
        cin >> A;
        if (A % 2) K++;
        else G++;
    }

    COMinit();
    ll sum = 0;
    if (P == 0) {
        for (ll i = 0; i <= K; i += 2) {
            sum += dp[K][i];
        }
        ll two = 1LL << G;
        sum *= two;
    }
    else {
        for (ll i = 1; i <= K; i += 2) {
            sum += dp[K][i];
        }
        ll two = 1LL << G;
        sum *= two;
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

#define MAX 10000
#define NIL -1

typedef struct { int parent, left, right;} Node;

Node T[MAX];
int n, D[MAX], H[MAX];

void setDepth(int u,int d) {
  if(u == NIL) return;
  D[u] = d;
  setDepth(T[u].left, d+1);
  setDepth(T[u].right,d+1);
}

int setHeight(int u) {
  int h1 = 0, h2 = 0;
  if(T[u].left != NIL)
    h1 = setHeight(T[u].left) + 1;
  if(T[u].right != NIL)
    h2 = setHeight(T[u].right) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}

// 接点 u の兄弟を返す
int getSibling(int u) {
  if( T[u].parent == NIL ) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL )
    return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL )
    return T[T[u].parent].right;
  return NIL;
}

void print(int u) {
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("sibling = %d, ",getSibling(u));
  int deg = 0;
  if(T[u].left  != NIL) deg++;
  if(T[u].right != NIL) deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);
  
  if(T[u].parent == NIL) {
    printf("root\n");
  } else if(T[u].left == NIL && T[u].right == NIL) {
    printf("leaf\n");
  } else {
    printf("internal node\n");
  }
}

int main(void) {
  int v, l, r, root = 0;
  scanf("%d",&n);
  for(int i=0;i<n;i++) T[i].parent = NIL;
  for(int i=0;i<n;i++) {
    scanf("%d %d %d",&v,&l,&r);
    T[v].left  = l;
    T[v].right = r;
    if(l != NIL) T[l].parent = v;
    if(r != NIL) T[r].parent = v;
  }
  
  for(int i=0; i<n; i++)
  if(T[i].parent == NIL) root = i;
  
  setDepth(root,0);
  setHeight(root);
  
  for(int i=0;i<n;i++) print(i);
  
  return 0;
}


Measured memory_bytes: 2052
import java.util.*;

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

		int D = sc.nextInt();
		int[] c = new int[N];
		for(int i=0; i<N; i++)
			c[i] = sc.nextInt();
		
		int[][] s = new int[D][N];
		for(int i=0; i<D; i++)
			for(int j=0; j<N; j++)
				s[i][j] = sc.nextInt();
		
		int[] last = new int[N];
		for(int i=0; i<D; i++) {
			int bestIndex = -1;
			int bestScore = 0;
			for(int j=0; j<N; j++) {
				int score = s[i][j] + c[j]*(i+1-last[j]);
				if(bestIndex < 0 || score > bestScore) {
					bestIndex = j;
					bestScore = score;
				}
			}
			System.out.println(bestIndex+1);
			last[bestIndex]=i+1;
		}

		sc.close();
	}
}


Measured memory_bytes: 37984
en=[chr(i) for i in range(65,91)]+list(' .,-\'?')
de={
' ':'101','\'':'000000',',':'000011','-':'10010001','.':'010001','?':'000001',
'A':'100101','B':'10011010','C':'0101','D':'0001','E':'110','F':'01001',
'G':'10011011','H':'010000','I':'0111','J':'10011000','K':'0110','L':'00100',
'M':'10011001','N':'10011110','O':'00101','P':'111','Q':'10011111','R':'1000',
'S':'00110','T':'00111','U':'10011100','V':'10011101','W':'000010','X':'10010010',
'Y':'10010011','Z':'10010000'
}
while 1:
    try:s=input()
    except:break
    a=b=''
    for x in s:a+=de[x]
    a+='0'*(-len(a)%5)
    for i in range(len(a)//5):b+=en[int(a[i*5:i*5+5],2)]
    print(b)

Measured memory_bytes: 7480
N,M = map(int, input().split())
S = []
for _ in range(M):
  s_list = ['0' for _ in range(N)]
  for s in list(map(int, input().split()))[1:]:s_list[s-1] = '1'
  S.append(int(''.join(s_list),2))

P = list(map(int, input().split()))
ans = 0
for i in range(2**N):
  flag = True
  for idx, s in enumerate(S):
    if bin(i&s)[2:].count('1')%2 != P[idx]:
      flag = False
      break
  if flag is True: ans += 1
print(ans)

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

using namespace std;
using ll = long long;
constexpr int mod = 1e9+7;
constexpr int md = mod;
ll gcd(ll a, ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
int main(){
    ll n,m;
    cin>>n>>m;
    vector<ll> a(m);
    vector<int> num = {-1,2,5,5,4,5,6,3,7,6};
    for(auto & b : a) cin>>b;
    sort(a.begin(),a.end(),[=](int a,int b){
        return num[a] < num[b];
    });
    vector<string> dp(n+5,"");
    dp[0] = "";
    for(int i=0;i<n;++i){
        for(auto b : a){
            if(i+num[b] <= n){
                if(i != 0 && dp[i] == "") continue;
                if(dp[i+num[b]].size() < dp[i].size() +1) dp[i+num[b]] = to_string(b) + dp[i];
                else if(dp[i+num[b]].size() == dp[i].size() + 1 && dp[i+num[b]] < to_string(b) + dp[i]){
                    dp[i+num[b]] = to_string(b) + dp[i];
                }
            }
        }
    }
    cout << dp[n] << endl;
    return 0;
}



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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int main() {
  int n, k;
  string s;
  cin >> n >> s >> k;

  char c = s[k - 1];

  for (int i = 0; i < n; ++i) {
    if (s[i] == c) {
      cout << s[i];
    } else {
      cout << '*';
    }
  }
  cout << endl;
}

Measured memory_bytes: 256
s = input()
n = input()
ans = 20000000
for i in range(len(s)):
  x = s[i:i+len(n)]
  con = 0
  if len(x) < len(n):
    break
  else:
    for y in range(len(n)):
      if x[y] != n[y]:
        con += 1
    ans = min(ans, con)
    
print(ans)

Measured memory_bytes: 8940
/*
 * a.c
 *
 *  Created on: 2017/06/13
 *      Author: AWV060608
 */

#include	<stdio.h>
#include	<string.h>

#define		TOU			4+1
#define		KAI			3+1
#define		HEYA		10+1

int		main(void)
{
	int		n;
	int		i,j,k;
	int		b, f, r, v;
	int		zaiseki[TOU][KAI][HEYA]={0};

	scanf("%d",&n);

	for(i=0; i<n; i++)
	{
		scanf("%d",&b);	//?£?
		scanf("%d",&f);	//???
		scanf("%d",&r);	//??¨?±?
		scanf("%d",&v);	//???

		zaiseki[b][f][r] += v;
	}
	for(i=1; i<TOU; i++)
	{
		for(j=1; j<KAI; j++)
		{
			for(k=1; k<HEYA; k++)
			{
				printf(" %d",zaiseki[i][j][k]);
			}
			printf("\n");
		}
		if(i != TOU-1 )
		{
			printf("####################\n");
		}
	}
	return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    for(int i = 0; i < n; ++i){
        cin >> p[i];
    }
    for(int i = 0; i < n; ++i){
        cin >> q[i];
    }
    vector<int> per(n);
    for(int i = 0; i < n; ++i){
        per[i] = i+1;
    }
    int a = 0, b = 0;
    int cnt = 0;
    do{
        ++cnt;
        bool flag = true;
        for(int i = 0; i < n; ++i){
            if(p[i] != per[i]){
                flag = false;
                break;
            }
        }
        if(flag)    a = cnt;
        flag = true;
        for(int i = 0; i < n; ++i){
            if(q[i] != per[i]){
                flag = false;
                break;
            }
        }
        if(flag)    b = cnt;
    }while(next_permutation(per.begin(), per.end()));
    cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

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

  int N, X;
  cin >> N >> X;

  int ans = 0;

  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    ans = __gcd(ans, X - x);
    X = x;
  }

  cout << abs(ans) << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

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

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}


int d[3] = {-1,0,1};
int main(){
   int x,a,b;cin>>x>>a>>b;
   cout<<(abs(x-b)>abs(x-a)?'A':'B');
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

int main() {
  int N;
  cin >> N;
  cout << N * N * N << endl;
}

Measured memory_bytes: 256
void main() {
	auto ip = readAs!(int[]), N = ip[0], K = ip[1];
	auto A = readAs!(int[]);
	
	auto M = A.reduce!max;
	auto G = A.reduce!gcd;
	if(K % G == 0 && M >= K) {
		writeln("POSSIBLE");
	} else writeln("IMPOSSIBLE");
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 4280
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <functional>
#include <tuple>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using ll = long long;
using namespace std;
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }

template <typename UnaryPredicate>
ll binsearch(ll l, ll r, UnaryPredicate p) { // [l, r), p is monotone
    assert (l < r);
    -- l;
    while (r - l > 1) {
        ll m = (l + r) / 2;
        (p(m) ? r : l) = m;
    }
    return r; // = min { x in [l, r) | p(x) }, or r
}

void flip(vector<pair<ll, ll> > & it) {
    repeat (i, it.size()) swap(it[i].first, it[i].second);
    whole(reverse, it);
}
bool pred(vector<vector<pair<int, int> > > const & g, ll limit) {
    function<vector<pair<ll, ll> > (int, int)> dfs = [&](int v, int parent) {
        if (g[v].size() == 1) {
            vector<pair<ll, ll> > result;
            result.emplace_back(0, 0);
            return result;
        }
        vector<pair<ll, ll> > left, right;
        for (auto edge : g[v]) {
            int w, value; tie(w, value) = edge;
            if (w == parent) continue;
            auto & it = (left.empty() ? left : right);
            it = dfs(w, v);
            repeat (i, it.size()) {
                it[i].first  += value;
                it[i].second += value;
            }
        }
        vector<pair<ll, ll> > result;
        auto func = [&]() {
            int i = 0;
            int j = right.size() - 1;
            for (; i < left.size(); ++ i) {
                while (j >= 0 and left[i].first + right[j].first > limit) -- j;
                if (j < 0) break;
                ll a = left[i].second;
                ll b = right[j].second;
                if (a > b) swap(a, b);
                result.emplace_back(a, b);
            }
        };
        func();
        flip(left);
        func();
        flip(right);
        func();
        flip(left);
        func();
        whole(sort, result);
        result.erase(whole(unique, result, [&](auto x, auto y) { return x.second <= y.second; }), result.end());
        return result;
    };
    return not dfs(0, -1).empty();
}

constexpr ll inf = ll(1e18)+9;
int main() {
    int n; scanf("%d", &n);
    vector<vector<pair<int, int> > > g(n);
    repeat (i, n - 1) {
        int a, v; scanf("%d%d", &a, &v);
        g[a - 1].emplace_back(i + 1, v);
        g[i + 1].emplace_back(a - 1, v);
    }
    ll result = binsearch(0, inf, [&](ll limit) {
        return pred(g, limit);
    });
    printf("%lld\n", result);
    return 0;
}


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

int main()
{
  int n, m;
  cin >> n >> m;
  
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  
  rep(k,m)
  {
    vector<int> b(n+1, 0);
    rep(i,n)
    {
      b[max(0, i - a[i])]++;
      b[min(n, i + a[i] + 1)]--;
    }
    rep(i,n)
    {
      b[i+1] += b[i];
    }
    rep(i,n) if(b[i] == 0) b[i]++;
    
    bool flag = true;
    rep(i,n)
    {
      if(a[i] != n)
      {
        flag = false;
        break;
      }
    }
    if(flag) break;
    
    swap(a, b);
  }
  
  rep(i,n) cout << a[i] << " "; cout << endl;
  
  return 0;
}

Measured memory_bytes: 5168
# include "iostream"
# include "cstdio"

using namespace std;

const int maxm=1e2+10;

int N,Red,Blue;
char S[maxm];

int main(){
	register int i;
	scanf("%d",&N);
	scanf("%s",S+1);
	for(i=1;i<=N;i++) Red+=(S[i]=='R');
	Blue=N-Red;
	puts(Red>Blue?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int nums[200009];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    cin>>N;
    
    rep(i,N) cin>>nums[i];
    sort(nums,nums+N);
    reverse(nums,nums+N);
    
    map<int,int> dic;
    int cnt=0;
    rep(j,N){
        bool f=true;;
        for(int i=0;(1ll<<i)<=2e9;i++){
            ll a=(1ll<<i)-nums[j];
            if(dic.count(a)){
                cnt++;
                if(--dic[a]<=0) dic.erase(a);
                f=false;
                break;
            }
        }
        if(f) dic[nums[j]]++;
    }
    cout1(cnt)
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#define pr printf
#define sc scanf

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef long double ld;
int n = 0;
int accumL[100010];
int accumR[100010];
char ch;
char s[100010];
int resp[100010];
int main () {
    ch = getchar();
    while(ch != '\n') {
        s[n++] = ch;
        ch = getchar();
    }
    for(int i = 0; i < n; i++) {
        if(i) {
            accumL[i] = accumL[i-1];
            accumR[i] = accumR[i-1];
        }
        if(s[i] == 'L') accumL[i]++;
        else accumR[i]++;
    }
    for(int i = 0; i < n; i++) {
        if (s[i] == 'L') {
            int l = 0, r = i-1;
            int pt;
            while(l < r) {
                int m = (l+r)>>1;
                if(accumR[m] != accumR[i]) l = m+1;
                else r = m-1;
            }
            if(accumR[l] == accumR[i]) pt = l; 
            else pt = l+1;
            if ((i-pt) & 1) resp[pt+1]++;
            else resp[pt]++;
        } else {
            int l = i+1, r = n-1;
            int pt;
            while(l < r) {
                int m = (l+r)>>1;
                if(accumL[m] != accumL[i]) r = m-1;
                else l = m+1;
            }
            if(accumL[l] == accumL[i]) pt = l+1; 
            else pt = l;
            if ((i-pt) & 1) resp[pt-1]++;
            else resp[pt]++;
        }
    }
    for(int i = 0; i < n; i++) {
        if(i) pr(" ");
        pr("%d", resp[i]);
    }
    pr("\n");
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define met(s) memset(s, 0, sizeof(s))
const int mod = 100000007;
const int maxn = 1000000;
const int inf = 0x3f3f3f3f;
int book[15][15];
bool used[50000];
int cal(int a[], int b[], int d)
{
    int sum = 0;
    for (int i = 0; i < d; i++)
        sum += (a[i] - b[i]) * (a[i] - b[i]);
    return sum;
}
int main()
{
    int n, d;
    scanf("%d%d", &n, &d);
    for (int i = 0; i * i < 50000; i++)
        used[i * i] = true;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < d; j++)
            scanf("%d", &book[i][j]);
    }
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            if (used[cal(book[i], book[j], d)])
                ans++;
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

int main()
{
    auto a = 0;
    auto b = 0;
    while(cin>>a>>b)
    {
        auto const area = a * b;
        auto const sideLength = (a + b) * 2;
        cout << area << " " << sideLength << endl;
    }
    return 0;
}


Measured memory_bytes: 3112