akhauriyash/Code-Regression huggingface dataset:
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextInt64() int64 {
	i, err := strconv.ParseInt(io.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}


func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func intMin(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func (io *Io) PrintBool(b bool, trueS, falseS string) {
	if b {
		io.PrintLn(trueS)
	} else {
		io.PrintLn(falseS)
	}
}

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

func absi(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func b2i(b bool) int {
	if b {
		return 1
	}
	return 0
}

type Int64s []int64
func (f Int64s) Len() int {
	return len(f)
}
func (f Int64s) Less(i, j int) bool {
	return f[i] < f[j]
}

func (f Int64s) Swap(i, j int) {
	f[i], f[j] = f[j], f[i]
}


func abcInt(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func gcdInt(a, b int) int {
	for a%b != 0 {
		a, b = b, a%b
	}
	return b
}

type P struct {
	a,b,c,d int
}

func solve(io *Io) {
	h := io.NextInt()
	w := io.NextInt()

	a := make([][]int, h)
	for i := 0; i < h; i++ {
		a[i] = make([]int, w)
		for j := 0; j < w; j++ {
			a[i][j] = io.NextInt()
		}
	}

	anses := make([]P, 0)
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if a[i][j] % 2 == 1 {
				if j != w-1 {
					anses = append(anses, P{i,j,i,j+1})
					a[i][j+1]++
				} else if i != h-1 {
					anses = append(anses, P{i,j,i + 1,j})
					a[i+1][j]++
				}
			}
		}
	}

	io.PrintLn(len(anses))
	for _, ans := range(anses) {
		io.PrintLn(ans.a + 1, ans.b + 1, ans.c + 1, ans.d + 1)
	}
}

func main() {
	io := NewIo()
	defer io.Flush()

	solve(io)
}


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

int main() {

	//入力
	string S;
	cin >> S;

	//十分に大きな数
	int ans = S.size();
	
	//iは最初の色(0 or 1)
	for (int i = 0; i < 2; i++) {
		
		//最初の色がiの時の入れ替える回数
		int cnt = 0;

		//jは今見ているタイル
		for (int j = 0; j < S.size(); j++) {

			if (j % 2 == 0 && S[j] != char(i + '0')) {
				cnt++;
			}
			else if (j % 2 == 1 && S[j] == char(i + '0')) {
				cnt++;
			}

		}

		ans = min(cnt, ans);

	}

	cout << ans << endl;

}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
    using namespace std;
    
    
    int main(){
      string str;
      long n, k;
      cin >> n  >>  k >> str;
      
      if(str[k-1] == 'A'){
          str[k-1] = 'a';
      }else if(str[k-1] == 'B'){
          str[k-1] = 'b';
      }else if(str[k-1] == 'C'){
          str[k-1] = 'c';
      }
      
      cout << str << endl;
      
      
      return 0;
    }

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

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

int search_maze(const vector<string> &field, int sx, int sy)
{
    int height = field.size();
    int width = field[0].size();

    vector<vector<int>> dist(height, vector<int>(width, -1));
    queue<pair<int, int>> que;
    dist[sx][sy] = 0;
    que.push(make_pair(sx, sy));

    int ret = 0;
    while (!que.empty())
    {
        pair<int, int> currentPos = que.front();
        int x = currentPos.first;
        int y = currentPos.second;
        que.pop();

        rep (d, 4)
        {
            int nx = x + dx[d];
            int ny = y + dy[d];
            if (nx < 0 || nx >= height || ny < 0 || ny >= width)
                continue;
            if (field[nx][ny] == '#')
                continue;

            if (dist[nx][ny] == -1)
            {
                que.push(make_pair(nx, ny));
                dist[nx][ny] = dist[x][y] + 1;
                ret = max(dist[nx][ny], ret);
            }
        }
    }
    return ret;
}

int main()
{
    int h, w;
    cin >> h >> w;

    vector<string> f(h);
    rep (i, h)
        cin >> f[i];

    int ans = 0;
    rep (i, h)
        rep (j, w)
        {
            if (f[i][j] == '#')
                continue;
            ans = max(search_maze(f, i, j), ans);
        }

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

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
char s1[1010],s2[1010]; // two words, s1 & s2 
int dis[1010][1010]; // array for the Levenshtein distance

int main(){
  cin>> s1 >> s2;
 
  int m=strlen(s1);
  int n=strlen(s2);

  for(int j=1;j<=m;j++){
    dis[j][0]=j;
  }
  for(int j=1;j<=n;j++){
    dis[0][j]=j;
  }
  for(int j=1;j<=m;j++){
    for(int k=1;k<=n;k++){
      dis[j][k] = min(
dis[j-1][k]+1,
min(dis[j][k-1]+1, 
    (s1[j-1]==s2[k-1] ? dis[j-1][k-1] : dis[j-1][k-1] + 1 ))); // comparing letters of the two words; +1 if different at respective location
    }
  }
  cout<<dis[m][n]<<endl;
  return 0;
}

Measured memory_bytes: 5096
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
const int maxn=2e5+10;
const int mod=1e9+7;
const double pi=3.1415926535;
int n;
ll k;
ll a[maxn];
ll f[maxn];

int check(ll x)
{
    ll temp=k;
    for(int i=1;i<=n;i++)
    {
        ll t=x/f[i];
        if(a[i]>t)
        {
            temp-=a[i]-t;
        }
    }
    if(temp<0)
        return 0;
    return 1;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
        cin>>f[i];
    sort(a+1,a+1+n,greater<ll>());
    sort(f+1,f+1+n);
    ll l=0,r=1e15;
    ll ans=0;
    while(l<=r)
    {
        ll mid=(l+r)/2;
        if(check(mid))
        {
            r=mid-1;
            ans=mid;
        }
        else
            l=mid+1;
    }
    cout<<ans<<'\n';



}


Measured memory_bytes: 6756
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
C = 1000
for i in range(N):
  B = T - (0.006 * int(H[i]))
  if abs(A - B) < C:
    C = abs(A - B)
    ans = i+1
print(ans)

Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>
#include <cmath>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const ll SZ = 1009, SZ2 = 1e5;

ll grid[SZ][SZ], us[SZ][SZ];
pair<ll, ll> gr[SZ][SZ], ans[SZ][SZ];

ll mt[SZ2], used[SZ2];
ll cur = 0;

vector<vector<ll>> g;

bool khun(int v) {
	used[v] = cur;

	for (auto to : g[v]) {
		if (mt[to] == -1) {
			mt[to] = v;
			return true;
		}
		else if (used[mt[to]] != cur && khun(mt[to])) {
			mt[to] = v;
			return true;
		}
	}

	return false;
}

int main()
{
	fastInp;

	ll n, m;
	cin >> n >> m;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> grid[i][j];
			grid[i][j]--;
			gr[i][j] = { grid[i][j] / m, grid[i][j] % m };
		}
	}

	for (int it = 0; it < m; it++) {
		g.clear();
		for (int j = 0; j < m + n; j++) {
			mt[j] = -1;
		}
		for (int i = 0; i < n + m; i++) {
			used[i] = 0;
		}
		cur = 1;

		ll cnt = 0;
		vector<ll> rws;
		vector<pair<ll, ll>> crds;
		g.resize(n);
		map<pair<ll, ll>, pair<ll, ll>> c;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if (!us[i][j]) {
					g[i].push_back(gr[i][j].first);
					c[{gr[i][j].first, i}] = { i, j };
				}
			}
		}

		for (int i = 0; i < n; i++) {
			khun(i);
			cur++;
		}

		for (int j = 0; j < n; j++) {
			ll vl = mt[j];
			pair<ll, ll> crds = c[{j, vl}];
			us[crds.first][crds.second] = 1;
			ans[vl][it] = gr[crds.first][crds.second];
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cout << ans[i][j].first * m + ans[i][j].second + 1 << " ";
		}
		cout << "\n";
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			for (int k = i + 1; k < n; k++) {
				if (ans[i][j].first > ans[k][j].first) swap(ans[i][j], ans[k][j]);
			}
			cout << ans[i][j].first * m + ans[i][j].second + 1 << " ";
		}
		cout << "\n";
	}

	return 0;
}

Measured memory_bytes: 6576
#include <bits/stdc++.h>
using namespace std;
int main(){
long long int n;
cin >>n;
long long int x[n],y[n];
long long int h[n];
for (int i=0;i<n;i++){
cin >>x[i] >>y[i] >> h[i];
}
for (long long int cx=0;cx<=100;cx++){
      for (long long int cy=0;cy<=100;cy++){
            for (long long int hh=(h[0]-200);hh<=h[0]+200;hh++){
bool xyz=true;
                     for (long long int i=0;i<n;i++){
long long int k=0;
if(h[i]!=max(hh-abs(cx-x[i])-abs(cy-y[i]),k)) xyz=false;
}
if (xyz==true) cout <<cx <<" "<< cy <<" "<<hh <<endl;
           }
      }
}
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

struct edge{
    ll to;
    ll cost;
    edge(ll _to,ll _cost):to(_to),cost(_cost){}
};

vector<vector<edge>> G;

//無向辺
void add_edge(ll from,ll to,ll cost){
    G[from].push_back(edge(to,cost));
    G[to].push_back(edge(from,cost));
}

bool used[100][100];
bool isreach[100];

void solve(int now){
    isreach[now] = 1;
    rep(i,G[now].size()){
        edge e = G[now][i];
        ll to = e.to;
        ll from = now;
        if(used[now][to])continue;
        if(isreach[to])continue;
        solve(to);
    }
}

ll n,m;

int main(){
    cin >> n >> m;
    G.resize(100);
    vector<P> vp(m);
    rep(i,m){
        ll a,b;
        cin >> a >> b;
        a--; b--;
        vp[i].first = a;
        vp[i].second = b;
        add_edge(a,b,1);
    }
    // cout << "!" << endl;
    ll ans = 0;
    rep(i,m){
        ll a = vp[i].first;
        ll b = vp[i].second;
        used[a][b] = 1;
        used[b][a] = 1;
        rep(j,n)isreach[j] = 0;
        solve(0);
        rep(j,n){
            if(!isreach[j]){
                ans++;
                break;
            }
        }
        used[a][b] = 0;
        used[b][a] = 0;
    }
    cout << ans << endl;
}

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

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

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

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

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

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

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

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

use std::cmp;
use std::collections::BTreeSet;

fn main() {
    input!(s: chars);
    let n = s.len();
    let s = s.iter().map(|&c| c == '1').collect::<Vec<_>>();
    if !s[0] || s[n - 1] {
        println!("-1");
        return;
    }

    let mut tree = vec![vec![]; n];
    let mut cur = 0;
    let mut cur_size = 1;

    for i in 0..(n - 1) {
        let one = i + 1;
        let other = n - one;
        if s[one - 1] != s[other - 1] {
            println!("-1");
            return;
        }
        if !s[i] {
            continue;
        }

        let have_to_add = one - cur_size + 1;
        for _ in 0..have_to_add {
            if cur_size == n {
                println!("-1");
                return;
            }
            let v = cur_size;
            tree[cur].push(v);
            tree[v].push(cur);
            cur_size += 1;
        }
        cur = cur_size - 1;
    }

    let mut set = BTreeSet::new();
    for from in 0..n {
        for &to in tree[from].iter() {
            let (a, b) = (cmp::min(from, to), cmp::max(from, to));
            set.insert((a, b));
        }
    }

    assert_eq!(set.len(), n - 1);
    for &(a, b) in set.iter() {
        println!("{} {}", a + 1, b + 1);
    }
}


Measured memory_bytes: 17660
#include <iostream>
#include <vector>
#include <boost/range/irange.hpp>

using  namespace std;
using namespace boost;

int main() {
    using uint = unsigned int;
    uint N;
    cin >> N;
    vector<uint> as(N, 0), bs(N, 0);
    for(auto i: irange((uint)0, N)){
        cin >> as.at(i);
    }
    for(auto i: irange((uint)0, N)){
        cin >> bs.at(i);
    }
    long long int sum{0};
    for(auto i: irange((uint)0, N)){
        if(as.at(i) > bs.at(i)){
            sum -= (as.at(i)-bs.at(i));
        } else {
            sum += (bs.at(i) - as.at(i))/2;
        }
    }
    if (sum >= 0){
        cout << "Yes";
    } else {
        cout << "No";
    }
    return 0;
}

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

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
const int oo = 1e9 + 7;
const int modulo = 1e9 + 7;
template<typename T>
inline T sum(const T& a, const T& b) { return T((a % modulo + b % modulo) % modulo); }
template<typename T>
inline T mul(const T& a, const T& b) { return T((1LL * (a % (1LL * modulo)) * (b % (1LL * modulo))) % (1LL * modulo)); }
string to_string(string a) { return "\"" + a + "\""; }
#ifdef __LOCAL_DEBUG
#define debug(args...) { string __out = #args; replace(__out.begin(), __out.end(), ',', ' '); stringstream __out_ss(__out);\
istream_iterator<string> __it(__out_ss); _debug(__it, args); }
void _debug(istream_iterator<string> it) { }
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T a, Args... args){ cerr << *it << " = " << to_string(a) << '\n'; _debug(++it, args...); }
#else
#define debug(...)
#endif

struct elm {
  ll a, b;
  elm() { }
};
bool operator<(const elm& l, const elm& r) {
  return l.a < r.a;
}
const int N = 1e5 + 5;
elm a[N];
int n, m;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 1; i <= n; ++i)
    cin >> a[i].a >> a[i].b;
  sort(a + 1, a + 1 + n);
  ll ans = 0;
  int i = 1;
  while (m) {
    ll add = min(1LL * m, a[i].b);
    m -= add;
    ans += add * a[i].a;
    ++i;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
  string S;
  int check=0;
  cin >> S;
  
  for(int i=0;i<S.length();i++){
    if(i%2 == 0){
      if(S[i] == 'L'){
        check = 1;
        goto STOP;
      }  
    }  
    else{
      if(S[i] == 'R'){
        check = 1;
        goto STOP;
      }  
    }  
  }  
  STOP:
  if(check == 0)
    cout << "Yes" << endl;
  if(check == 1)
    cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
# define ll int64_t
#define rep(i,n) for(ll i=0;i<n;i++)
#define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}


int main(){
    ll n,mini=1000000;
    cin>>n;
    rrep(i,(int)pow(n, 0.5)){
        if(n%i!=0) continue;
        else{
        if(max(to_string(i).length(),to_string(n/i).length())<=mini) mini=max(to_string(i).length(),to_string(n/i).length());
        }
    }
    cout<<mini<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<cmath>
#include<functional>
#include<queue>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void sort(int &a,int &b)
{
	if(a>b)
		swap(a,b);
}
void open(const char *s)
{
#ifndef ONLINE_JUDGE
	char str[100];
	sprintf(str,"%s.in",s);
	freopen(str,"r",stdin);
	sprintf(str,"%s.out",s);
	freopen(str,"w",stdout);
#endif
}
int rd()
{
	int s=0,c;
	while((c=getchar())<'0'||c>'9');
	do
	{
		s=s*10+c-'0';
	}
	while((c=getchar())>='0'&&c<='9');
	return s;
}
int upmin(int &a,int b)
{
	if(b<a)
	{
		a=b;
		return 1;
	}
	return 0;
}
int upmax(int &a,int b)
{
	if(b>a)
	{
		a=b;
		return 1;
	}
	return 0;
}
int gcd(int a,int b)
{
	return b?gcd(b,a%b):a;
}
priority_queue<pii> q;
int d[2010];
vector<int> g[2010],g2[2010];
int a[2010];
int b[2010];
pii c[2010];
void dfs(int x)
{
	b[x]=1;
	for(auto v:g[x])
		if(!b[v])
		{
			dfs(v);
			g2[x].push_back(v);
			d[v]++;
		}
}
int main()
{
	int n;
	scanf("%d",&n);
	int i,j;
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		c[i].first=a[i];
		c[i].second=i;
	}
	sort(c+1,c+n+1);	
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			if(gcd(a[c[i].second],a[c[j].second])!=1)
				g[c[i].second].push_back(c[j].second);
	for(i=1;i<=n;i++)
		if(!b[c[i].second])
			dfs(c[i].second);
	for(i=1;i<=n;i++)
		if(!d[i])
			q.push(pii(a[i],i));
	for(i=1;i<=n;i++)
	{
		int x=q.top().second;
		q.pop();
		printf("%d ",a[x]);
		for(auto v:g2[x])
		{
			d[v]--;
			if(!d[v])
				q.push(pii(a[v],v));
		}
	}
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];

    int ggg = a[0];
    rep(i,n-1) ggg = __gcd(ggg, a[i+1]);
    if(ggg != 1){
        puts("not coprime");
        return 0;
    }

    //エラトステネスの篩
    int P_MAX = 1000005;
    vi pmn(P_MAX);     //smallest prime number that can divide i(pmn[i] == i -> i is prime number)
    for(int i = 1; i < P_MAX; i++)
        if(i%2 == 0) pmn[i] = 2;
        else pmn[i] = i;
    for(int i = 3; i*i < P_MAX; i += 2){
        if(pmn[i] == i){
            for(int j = 3*i; j < P_MAX; j += 2*i)
                if(pmn[j] == j) pmn[j] = i; 
        }
    }

    vi cnt(P_MAX,0);
    rep(i,n){
        while(a[i] != 1){
            int apmn = pmn[a[i]];
            if(cnt[apmn]){
                puts("setwise coprime");
                return 0;
            }
            cnt[apmn]++;
            while(a[i]%apmn == 0) a[i] /= apmn;
        }
    }
    puts("pairwise coprime");
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 100010;
int N;
int p[MC];

int main(){
	scanf("%d" , &N);
	repp(i,0,N){
		scanf("%d" , p + i);
	}
	int ans = 0;
	repp(i,0,N){
		if(p[i] == i+1){
			++ans;
			if(p[i+1] == i+2)++i;
		}
	}
	printf("%d\n" , ans);
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
  int N;
  
  cin >> N;
  
  bool ans = false;
  
  while (N != 0) {
    ans = (N % 10 == 7);
    
    if (ans) {
      break;
    }
    
    N /= 10;
  }
  
  cout << (ans ? "Yes" : "No") << endl;
  
  return 0;
}

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

int main(){
 char c;
 cin >> c;
 string s = "abcdefghijklmnopqrstuvwxyz";
  for(int i = 0; i<26; ++i){
     if(s[i]==c) cout << s[i+1] << endl;
  }
}

Measured memory_bytes: 384
#include <bits/stdint-intn.h>
#include<cstdint>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<iterator>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>
#include<utility>
#include<initializer_list>


#define repi(i,start,end)for(int64_t (i)=(start);(i)<(end);++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x, v) for(auto& (x) : (v))
#define iterate(itr, v) for(auto (itr)=(v).begin();(itr)!=(v).end();++(itr))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vin(v) rep(i,(v).size()) cin >> (v)[i];
#define vpin(v) rep(i,(v).size()) cin >> (v)[i].first >> (v)[i].second

using namespace std;
using Int = int64_t;
using pint = pair<Int, Int>;
using vint = vector<Int>;
using vvint = vector<vint>;
using vpint = vector<pint>;
using vstr = vector<string>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<"\n";}
template<class T>void println(T a){cout << a << "\n";}
template<class T>void put_line(T &v){iterate(itr,v){cout<<*itr<<((itr==--v.end())?"\n":" ");}}
// auto [x, y] = make_tuple(3, 4); => let (x, y) = (3, 4);

int n, m, q; 
vint a, b, c, d;

int calc(vint &A) {
    int res = 0;
    rep(i, q) {
        if(A[b[i]] - A[a[i]] == c[i]) res += d[i];
    }
    return res;
}

void dfs(vint &A, int &res) {
    if(A.size() >= n + 1) {
        int p = calc(A);
        chmax(res, p);
        return;
    }
    int e = A.back();
    repi(i, e, m + 1) {
        A.push_back(i);
        dfs(A, res);
        A.pop_back();
    }
}

int main(void) {
    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];

    vint A(1, 1);
    int ans = 0;
    dfs(A, ans);
    println(ans);

    return 0;
}


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

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



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**8)
from collections import defaultdict,Counter
def saiki(cnts):
  hitomozi = []
  d = defaultdict(lambda: [])
  heads = defaultdict(lambda: 0)
  for s,c in cnts:
    if len(s)==1:
      hitomozi.append(s[0])
    else:
      for k,v in c.items():
        if v>0:
          heads[k] += 1
      t = s[-1]
      c[t] -= 1
      s.pop(-1)
      d[t].append([s,c])
  for h in hitomozi:
    ans[0] += heads[h]
  for v in d.values():
    if len(v)<=1:
      continue
    saiki(v)
  return 

N = int(input())
S = [list(input()) for _ in range(N)]
ans = [0]
cnts = []
for s in S:
  cnts.append([s,Counter(s)])
saiki(cnts)
print(ans[0])

Measured memory_bytes: 310260
#include<bits/stdc++.h>
using ll=long long;
const int MOD=1e9+7;
using namespace std;
int main(){
  int n;
  cin >> n;
  ll ans=1;
  for(int i=1;i<=n;i++){
    ans*=i;
    ans%=MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;
    int A[N];
    map<int,int> m;
    int ans=0;
    rep(i,N){
        cin>>A[i];
        m[A[i]]++;
        ans+=A[i];
    }
    int Q;
    cin>>Q;
    int B[Q],C[Q];
    rep(i,Q){
        cin>>B[i]>>C[i];
        ans+=(C[i]-B[i])*m[B[i]];
        m[C[i]]=m[C[i]]+m[B[i]];
        m[B[i]]=0;
        cout << ans << endl;
    }


    



}


Measured memory_bytes: 11860
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  char a;
  cin >> a;
  if(a=='A')cout << 'T' << endl;
  else if(a=='T')cout << 'A' << endl;
  else if(a=='C')cout << 'G' << endl;
  else cout << 'C' << endl;
}


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

int main()
{
    int n; cin >> n;
    vector<int> l(n);
    rep(i,n) cin >> l[i];
    int ans = 0;
    sort(l.begin(), l.end());
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            for(int k=j+1; k<n; k++){
                if((l[i] < l[j]+l[k]) && (l[j] < l[i]+l[k]) && (l[k] < l[i]+l[j])) ans++;
                else break;
            }
        }
    }

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

Measured memory_bytes: 3632
import numpy as np

N, M, C = map(int, input().split())

B = np.array(list(map(int, input().split())))

A = [None] * N

for i in range(N):
    A[i] = list(map(int, input().split()))

A = np.array(A)

ans = A.dot(B.reshape((-1, 1))) > -C
print(sum(ans)[0])

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

int main() {
   int y, m, d;
   char c1, c2;
   cin >> y >> c1 >> m >> c2 >> d;
   if(y < 2019){
     cout << " Heisei " << endl;}
   else if (y == 2019 && m < 5){
      cout << "Heisei" << endl;}
   else{
     cout << "TBD" << endl;}
}


Measured memory_bytes: 256
from itertools import product
S = input()
for x in "()+*-":
    S = S.replace(x, " {} ".format(x))
S = S.split()

def parse(pri, cur):

    def number():
        nonlocal cur
        if S[cur].isdigit():
            val = int(S[cur])
            cur += 1
            return val
        cur += 1
        val = expr(0)
        cur += 1
        return val
    
    def expr(level):
        nonlocal cur
        if level == 3:
            this = number()
        else:
            this = expr(level+1)
        while cur < len(S) and S[cur] in "+-*" and pri[S[cur]] == level:
            op = S[cur]
            cur += 1
            that = expr(level+1)
            if op == "+":
                this += that
            elif op == "-":
                this -= that
            else:
                this *= that
        return this
    return expr(0)

pri = {}
ans = -float("inf")
for P in product(range(3), repeat=3):
    pri["+"], pri["-"], pri["*"] = P
    ans = max(ans, parse(pri, 0))
print(ans)


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

int main(){

  double a,b,c,e,d,f,x,y;

  while(cin >> a >> b >> c >> d >> e >> f){

    y=((c*d)-(f*a))/(b*d-a*e);
    x=(c-b*y)/a;

    printf("%.3lf %.3lf\n",x,y);
  }
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,xsum=0;cin>>n;
  lvector a(n,0);
  map<ll,ll> m,x,y;
  rep(i,n) {
    cin>>a[i];
    m[a[i]]+=1;
  }
  for(auto i:m) {
    ll k=i.first,v=i.second;
    xsum+=v*(v-1)/2;
    x[k]=v*(v-1)/2,y[k]=(v-1)*(v-2)/2;
  }
  rep(i,n) {
    ll ans=xsum-x[a[i]]+y[a[i]];    
    print(ans);
  }
  return 0;
}

Measured memory_bytes: 26880
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
num=0
for i in range(n):
    sum=0
    a=list(map(int,input().split()))
    for j in range(m):
        sum+=a[j]*b[j]
    if sum>-c:
        num+=1
print(num)

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

int main() {
  int n = 0;
  string s;
  cin >> s;
  for(auto x : s) {
    if(x == '+') ++n;
    else --n;
  }
  
  cout << n << endl;
  
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;

class Main {

	static ArrayDeque<String> queue = new ArrayDeque<String>();

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuffer sb = new StringBuffer();
		
		int n = Integer.parseInt(br.readLine());
		for (int i = 0; i < n; i++) {
			String order = br.readLine();
			if (order.contains("F")) {
				queue.poll();
			} else if (order.contains("L")) {
				queue.pollLast();
			} else if (order.contains("insert")) {
				queue.addFirst(order.replace("insert ", ""));
			} else {
				queue.removeFirstOccurrence(order.replace("delete ", ""));
			}
		}

		sb.append(queue.poll());
		while (queue.isEmpty() != true) {
			sb.append(" " + queue.poll());
		}
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 589264
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
const long double eps = 1e-10;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; }return 0; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    ll n, a, b; cin >> n >> a >> b;
    cout << max(b * (n - 1) + a - a * (n - 1) - b + 1, 0LL) << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2147483647
#define SYOU(x) setprecision(x)
using namespace std;
long long i[300000];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a=0,b=0,c=0,d=0,e=1,f=0;
  string s;
  cin >>s;
  for(int n=0;n<s.size();n++){
    if(n%2==0){
      if(s[n]=='R'||s[n]=='U'||s[n]=='D');
      else{
	d++;
	break;
      }
    }
    else{
      if(s[n]=='L'||s[n]=='U'||s[n]=='D');
      else{
	d++;
	break;
      }
    }
  }
  if(d==0) cout <<"Yes\n";
  else cout <<"No\n";
  return (0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<char> vc;
typedef pair<int, int> pi;
const int mod = 1e9 + 7;
const double EPS = 1e-9;
const int INF = 1 << 29;
#define mp make_pair
#define el putchar('\n')
#define sp putchar(' ')
#define Fill(a,val) memset(a,val,sizeof a)
#define all(a) a.begin(),a.end()
#ifndef ONLINE_JUDGE
#define tr(a, it) for (decltype(a.begin()) it = a.begin(); it != a.end(); ++it)
#else
#define tr(a, it) for (typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#endif
#define in(n) scanf("%d",&n)
#define inl(n) scanf("%I64d",&n)
#define out(n) printf("%d",n);
#define outl(n) printf("%I64d",n);

int main(){
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	string ans; ans += (s1[0] - 'a' + 'A');
	ans += (s2[0] - 'a' + 'A');
	ans += (s3[0] - 'a' + 'A');
	cout << ans; el;
	return 0;
}

Measured memory_bytes: 256
<?php
$s=trim(fgets(STDIN));
$n=strlen($s);
if($n%2==1){
  echo "No";
  exit;
}
$i=0;
while($i<$n){
  if($i%2==0){
    if($s[$i]!="h"){
      echo "No";
      exit;
    }
  }else{
    if($s[$i]!="i"){
      echo "No";
      exit;
    }
  }
  ++$i;
}
echo "Yes";

Measured memory_bytes: 4856
dic = {}
while True:

    try:
        word,PageNum = raw_input().split()
        if word not in dic:
            dic[word] = []
            dic[word].append(int(PageNum))
        else:
            dic[word].append(int(PageNum))
    except:
        break

for k,v in sorted(dic.items()):
    print  k
    print " ".join(map(str,sorted(v)))

Measured memory_bytes: 4204
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<list>
#include<set>
using namespace std;

int cnt=0;
int len=0;
int now=0;
int main(){
  char s[100001];
  int re[100001];
  cin >> s;

  len = strlen(s);

  for(int i=0;i<len;i++){
    if(s[i] == 'W'){
      re[i] = 1;
    }else{
      re[i] = 0;
    }
  }

  now = re[0];

  for(int i=0;i<len;i++){

    if(now!=re[i]){
      now = (now+1)%2;
      cnt++;
      }
  }

  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 768
import math

def get_distance(l1, l2):
    dis = 0
    for i in range(len(l1)):
        dis += (l1[i]-l2[i]) ** 2
    return math.sqrt(dis)

N, D = map(int, input().split())
X = []
ans = 0
for _ in range(N):
    X.append(list(map(int, input().split())))

for n in range(N-1):
    for d in range(n+1, N):
        dis = get_distance(X[n], X[d])
        if dis.is_integer():
            ans += 1

print(ans)


Measured memory_bytes: 62384
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstdint>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <cstdlib>
#include <sstream>
#include <functional>

#include <boost/range/irange.hpp>
using boost::irange;

#include <boost/utility/string_ref.hpp>
using string_view = boost::string_ref;

using namespace std;

template<class T, size_t N, class F>
struct compare_n
{
    F f;
    bool operator() (const T& t1, const T& t2)
    {
        return f(get<N>(t1), get<N>(t2));
    }
};
 
template<size_t N, class T>
auto make_less_n(const T&)
{
    using t = typename T::value_type;
    using less = std::less<typename tuple_element<N, t>::type>;
    return compare_n<t, N, less>();
}



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

    int x;
    cin >> x;
    
    switch(x){
        case 7: case 5: case 3:
            cout << "YES\n"; break;
        default:
            cout << "NO\n"; break;
    }

    return 0;
}



Measured memory_bytes: 256
def main():
    n = int(input())
    a = list(map(int,input().split()))
    c = 0
    for i in range(n-1):
        for j in range(n-1,i,-1):
            if a[j] < a[j-1]:
                a[j],a[j-1] = a[j-1],a[j]
                c+=1
    print(' '.join(map(str,a)))
    print(c)


if __name__ == '__main__':
    main()



Measured memory_bytes: 5600
def main():
    mod = 10**9 + 7
    N, M = map(int, input().split())
    S = list(map(int, input().split()))
    T = list(map(int, input().split()))
    u = [1] * (N + 1)
    v = [1] * (N + 1)
    for t in T:
        for i, s in enumerate(S, 1):
            if s == t:
                v[i] = v[i - 1] + u[i]
            else:
                v[i] = v[i - 1] + u[i] - u[i - 1]
        u, v = v, u
    return u[-1] % mod

print(main())


Measured memory_bytes: 4980
#include <stdio.h>

int main()
{
    char b;
    b = getchar();

    switch (b)
    {
    case 'A':
        printf("%c", 'T');
        break;
    case 'C':
        printf("%c", 'G');
        break;
    case 'G':
        printf("%c", 'C');
        break;
    case 'T':
        printf("%c", 'A');
        break;
    default:
        break;
    }


    return 0;
}

Measured memory_bytes: 128
#include"bits/stdc++.h"
    using namespace std;
    using ll = long long ;
    ///PBDS Starting.......

    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    using namespace __gnu_pbds;
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

    ///PBDS_SET
    ///Index of Value - .order_of_key()
    ///Value at Index - .find_by_order()
    ///typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds_set;
    ///typedef tree<int, null_type, lessorequal<int>, rb_tree_tag,tree_order_statistics_node_update> pbds_multiset;

    /// PBDS closing......
    #define int long long
    #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20)
    #define endl '\n'
    ///............Author..................................................................
    ///........... :: .....................................................................
    ///...........(  NOBODY  )................................................................
    ///........... Bangabandhu Sheikh Mujibur Rahman Science and Technlogy University,Gopalganj
    ///........... ( N~76 ) ...................................................................
    ///........... No Copyright .....You can copy and paste my code without any permission.....
    /// !!!!!!!!!!!!!!!........................................................................
    #define pb push_back
    #define esp 0.000000001
    #define pi acos(-1)
    #define N 1000009
    #define ff first
    #define ss second
    #define all(x) x.begin(),x.end()
    /// Code Loading Please wait.............
    /// returning to N~76.
    /// Loading Finished.....................

    int32_t main()
    {
       // FAST_IO;
        int n;
        cin>>n;
        double ans=(double)2*pi*n;
        cout<<ans<<endl;
        return 0;
    }



Measured memory_bytes: 3788
package main

import (
	"fmt"
)

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

	a := make([]int, n)
	var d int
	for i := 0; i < k; i++ {
		fmt.Scan(&d)
		for j := 0; j < d; j++ {
			var aa int
			fmt.Scan(&aa)
			a[aa-1]++
		}
	}
	var ans int
	for _, e := range a {
		if e == 0 {
			ans++
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 2456
import sys
f=lambda:sys.stdin.readline()
while 1:
 n=int(f())
 if n==0:break
 d={}
 for _ in[0]*n:
  k,v=f().strip().split()
  d[k]=v
 a=''
 for _ in[0]*int(f()):
  e=f().strip()
  a+=d[e]if e in d else e
 print(a)


Measured memory_bytes: 6508
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    char a, b;
    cin >> a >> b;

    if ( a == b ) {
        cout << "H" << endl;
    } else {
        cout << "D" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
/*
* Welcome to my code!
*---------------------------------------------*
* author : lynmisakura(twitter : @andoreiji11)
*/
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <cassert>

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define repn for(int i = 0;i < n;i++)
#define ain(a) for(auto& i : a)cin >> i;
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x.size()) 
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define cont continue

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using pi = pair<int,int>;
using vpi = vector<pi>;
using pl = pair<ll,ll>;
using vpl = vector<pl>;

template<class T> bool chmin(T& a,T b){if(a > b){a = b;return true;}else return false;}
template<class T> bool chmax(T& a,T b){if(a < b){a = b;return true;}else return false;}
template<class T> void print(std::vector<T> a)
{ int sz = a.size(); for(int i=0;i<a.size();i++)cout << a[i] << (i < sz-1 ? ' ' : '\n'); }
void ioboost(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}
///////////////////////////////////////////////////////////

int main(int argc, char const *argv[])
{
  ioboost();
  
  ll a,b,c;cin >> a >> b >> c;
  ll k;cin >> k;

  if(k <= a)cout << k << '\n';
  else if(k <= a + b)cout << a << '\n';
  else cout << a - (k - (a + b)) << '\n';

  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;

int main() {
    while (true) {
        int n;
        cin >> n;
        
        if (n==0) {
            break;
        }
        
        vector<P> l;
        
        for (int i=0; i<n; i++) {
            int pi, d1i, d2i;
            cin >> pi >> d1i >> d2i;
            l.push_back(P(d1i+d2i, pi));
        }
        
        sort(l.begin(), l.end());
        
        cout << l[n-1].second << " " << l[n-1].first << endl;
    }
}


Measured memory_bytes: 3232
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){

  while(1){
    ll ans = 0;
    ll N,X; cin>>N>>X;
    if( (N==0) and (X == 0)) break;

    repn(i,N-2){
      for(ll j = i + 1; j < N; j++){
        for(ll k = j + 1; k <= N; k++){
          ll tmp = i + j + k;
          if(tmp == X){
            ans++;
            // cout<<i<<" "<<j<<" "<<k<<endl;
          }
        }
      }
    }
    cout<<ans<<endl;
  }
}



Measured memory_bytes: 3120
#include<cstdio>
#include<cstring>

using namespace std;

int n;
char s[512];

int dp[512][512];
int rec(int l,int r){
	if(dp[l][r]!=-1) return dp[l][r];

	if(l==r) return dp[l][r]=1;

	if(s[l]!='m' || s[r-1]!='w') return dp[l][r]=0;

	for(int i=l+1;i<r-1;i++) if(s[i]=='e' && rec(l+1,i) && rec(i+1,r-1)) return dp[l][r]=1;
	return dp[l][r]=0;
}

int main(){
	scanf("%s",s);
	n=strlen(s);
	memset(dp,-1,sizeof dp);
	puts(rec(0,n)?"Cat":"Rabbit");
	return 0;
}

Measured memory_bytes: 1984
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            int yen = cin.ReadInt;

            int left = yen % 1000;
            int ans;

            if (left == 0)
            {
                ans = 0;
            }
            else {
                ans = 1000 - left;
            }
            WriteLine(ans);

        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 27924
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define N 1225
using namespace std;
int read()
{
	int s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
int d[N],m,x[N],y[N],n;
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
	{
		x[i]=read(),y[i]=read();
		if(((x[i]+y[i])&1)!=((x[1]+y[1])&1))	return puts("-1"),0;
	}
	if(!((x[1]+y[1])&1))	d[++m]=1;
	for(int i=30;~i;i--)	d[++m]=(1<<i);
	printf("%d\n",m);
	for(int i=1;i<=m;i++)	printf("%d ",d[i]); puts("");
	for(int i=1;i<=n;i++,puts(""))
	{
		for(int j=1;j<=m;j++)
		{
			if(abs(x[i])>abs(y[i]))
			{
				if(x[i]>0)	x[i]-=d[j],putchar('R');
				else	x[i]+=d[j],putchar('L');
			}
			else
			{
				if(y[i]>0)	y[i]-=d[j],putchar('U');
				else	y[i]+=d[j],putchar('D');
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256