akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ss second
#define ff first

ll dp[1001][1001];
ll mod=1000000007;
int main(){
    string x[1100];
    int w,h;
    cin>>w>>h;
    for(int i=0;i<w;i++)
    {
        cin>>x[i];
    }
    dp[0][0]=1;
    for(int i=0;i<w;i++)
    {for(int j=0;j<h;j++)
    {   if(x[i][j]=='#')
    continue;
        if(i-1>=0)
            dp[i][j]+=dp[i-1][j];
        if(j-1>=0)
            dp[i][j]+=dp[i][j-1];
        dp[i][j]%=mod;

    }
}
cout<<dp[w-1][h-1];
}


Measured memory_bytes: 9088
#include<cstdio>
typedef long long ll;
char s[200010];
int n,nxt[200010],m,cnt[100010][26],k;
ll pos[110],cnts[110][26];
ll calc(ll x,int c){
	if(n%m){
		ll sum=0;
		for(int i=k;i--;)
			if(x>=pos[i])sum+=cnts[i][c],x-=pos[i];
		return sum+cnt[x][c];
	}
	else return cnt[m][c]*(x/m)+cnt[x%m][c];
}
int main(){
	ll l,r;
	scanf("%s%lld%lld",s,&l,&r);
	for(n=0;s[n];n++){
		int&i=nxt[n+1];
		for(i=nxt[n];i&&s[i]!=s[n];i=nxt[i]);
		if(n&&s[i]==s[n])i++;
	}
	n/=2;
	for(int i=0;i<n;i++)
		for(int j=0;j<26;j++)
			cnt[i+1][j]=cnt[i][j]+(s[i]==j+'a');
	m=n-nxt[n];
	if(n%m){
		pos[0]=n,pos[k=1]=n+m;
		for(;pos[k]<=r;k++)pos[k+1]=pos[k-1]+pos[k];
		for(int i=0;i<k;i++)
			for(int j=0;j<26;j++)cnts[i][j]=!i?cnt[n][j]:i==1?cnt[n][j]+cnt[m][j]:cnts[i-2][j]+cnts[i-1][j];
	}
	for(int i=0;i<26;i++)
		printf("%lld%c",calc(r,i)-calc(l-1,i)," \n"[i==25]);
}

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

using ld = long double;

ld n, k;

ld sum = 0.0;

int main() {
    std::cin >> n >> k;
    for (ld i = 1; i <= n; i++) {
        ld u = 1.0;
        ld x = i;
        while (x < k) {
            u *= 0.5;
            x *= 2;
        }
        sum += (u*ld(1.0/n));
    }
    std::cout << std::setprecision(10) << sum << std::endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void) {
  int N;
  while (cin >> N, N) {
    int ans = 0, sum = 0, head = 0;
    for (int i = 1; i < N; i++) {
      while (sum > N) {
        sum -= head;
        head++;
      }
      if (sum == N)
        ans++;
      sum += i;
    }
    if (sum == N)
      ans++;
    cout << ans << endl;
  }
}


Measured memory_bytes: 3000
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const int MOD2 = 998244353;

ll a[100010];
bool seen[100010];

const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll PER(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n - k] % MOD) % MOD;
}


int main(){
    int n;
    cin >> n;
    ll b;
    rep(i, n+1) {
        cin >> a[i];
        if (seen[a[i]]) b = a[i];
        seen[a[i]] = 1;
    }
    ll pre = 0, suf = 0;
    rep(i, n+1){
        if(a[i] == b) break;
        pre++;
    }
    rrep(i, n+1){
        if(a[i] == b) break;
        suf++;
    }

    COMinit();

    for(ll i = 1; i <= n+1; i++){
        cout << (COM(n+1, i) - COM(pre+suf, i-1) + MOD) % MOD<< endl;
    }


    return 0;
}


Measured memory_bytes: 16476
using System;
using System.Collections.Generic;

namespace ALDS1_5_C
{
    public struct Point
    {
        public double x;
        public double y;

        public Point(double x, double y)
        {
            this.x = x;
            this.y = y;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var queue = new Queue<Point>();
            queue.Enqueue(new Point(0, 0));
            queue.Enqueue(new Point(100, 0));
            while (n-- != 0) Recursion(queue);
            foreach (var p in queue) Console.WriteLine("{0} {1}", p.x, p.y);
        }

        static void Recursion(Queue<Point> q)
        {
            var cos = Math.Cos(Math.PI / 3);
            var sin = Math.Sin(Math.PI / 3);
            var p1 = q.Dequeue();
            q.Enqueue(p1);
            while (true)
            {
                if (q.Peek().Equals(new Point(0, 0))) break;
                var p = q.Dequeue();

                var v = new Point((p.x - p1.x) / 3, (p.y - p1.y) / 3);
                var s = new Point(p1.x + v.x, p1.y + v.y);
                var t = new Point(p1.x + v.x * 2, p1.y + v.y * 2);
                var u = new Point(s.x + v.x * cos - v.y * sin, s.y + v.x * sin + v.y * cos);
                q.Enqueue(s);
                q.Enqueue(u);
                q.Enqueue(t);
                q.Enqueue(p);
                p1 = p;
            }
        }
    }
}

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

const int inf = 1e9 + 37;

int d[31][31], g[501][501];
vector < vector < int > > cnt(3, vector < int > (31, 0));

signed main () {
	int n, c;
    cin >> n >> c;
    for (int i = 1; i <= c; ++i) {
        for (int j = 1; j <= c; ++j)
            cin >> d[i][j];
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            cin >> g[i][j];
            ++cnt[(i + j) % 3][g[i][j]];
        }
    }
    int ans = inf;
    for (int i = 1; i <= c; ++i) {
        for (int j = 1; j <= c; ++j) {
            for (int w = 1; w <= c; ++w) {
                if (i != j && j != w && i != w) {
                    int cur = 0;
                    for (int y = 1; y <= c; ++y) 
                        cur += d[y][i] * cnt[0][y];
                    for (int y = 1; y <= c; ++y) 
                        cur += d[y][j] * cnt[1][y];
                    for (int y = 1; y <= c; ++y) 
                        cur += d[y][w] * cnt[2][y];
                    ans = min(ans, cur);
                }
            }
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 1280
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val n: Int = sc.nextLine.toInt
    val range = List.fill(n)(sc.nextLine.split(" ").map(_.toInt))
    println(range.foldLeft(0)((acc, ran) => acc + (ran(1) - ran(0)) + 1))
  }
}


Measured memory_bytes: 30804
#include<stdio.h>
int main()
{
	char s0[10];
	char s1[10];
	char s2[10];
	char r[3];
	int k;
	
	scanf("%s %s %s", s0, s1, s2);
	
	r[0] = s0[0];
	r[1] = s1[0];
	r[2] = s2[0];
	
	for(k=0; k<3; k++)	r[k] = r[k]-32;
	
	printf("%c%c%c", r[0], r[1], r[2]);
	return 0;
}


Measured memory_bytes: 128
package main

import (
	"fmt"
)

const mod = int(1e9 + 7)

var ifac, fac []int

func main() {
	var x, y int
	fmt.Scan(&x, &y)

	const cmax = int(1e6 + 1)
	fac = make([]int, cmax)
	ifac = make([]int, cmax)
	inv := make([]int, cmax)
	fac[0], fac[1] = 1, 1
	ifac[0], ifac[1] = 1, 1
	inv[0], inv[1] = 1, 1
	for i := 2; i < cmax; i++ {
		fac[i] = (fac[i-1] * i) % mod
		inv[i] = (mod - inv[mod%i]*(mod/i)) % mod
		if inv[i] < 0 {
			inv[i] += mod
		}
		ifac[i] = (ifac[i-1] * inv[i]) % mod
	}

	if (x+y)%3 != 0 || x > y*2 || y > x*2 {
		fmt.Println(0)
		return
	}
	n := (x + y) / 3
	r := x - n
	fmt.Println(comb(n, r))
}

func comb(n, r int) int {
	if r > n {
		return 0
	} else if r == 0 || r == n {
		return 1
	}
	t := (ifac[n-r] * ifac[r]) % mod
	return (t * fac[n]) % mod
}

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

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

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


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

using namespace std;

typedef pair<int, int> P;

int N, K;
vector<int> G[2001];
int depth[2001];
P edge[2000];

void clear_depth(){
    for(int i = 1; i<= N; i++){
        depth[i] = -1;
    }
}

void dfs1(int n, int d){
    depth[n] = d;
    for(int i = 0; i < G[n].size(); i++){
        if(depth[G[n][i]]==-1) dfs1(G[n][i], d+1);
    }
}

int main(){
    cin >> N >> K;
    int ans = INT32_MAX;
    for(int i = 0; i < N-1; i++){
        int A, B;
        cin >> A >> B;
        G[A].push_back(B);
        G[B].push_back(A);
        edge[i] = P(A, B);
    }
    if(K%2 == 0){
        for(int i = 1; i <= N; i++){
            int tmp = 0;
            clear_depth();
            dfs1(i, 0);
            for(int j = 1; j <= N; j++){
                if(depth[j] > K/2) tmp++;
            }
            ans = min(ans, tmp);
        }
        cout << ans << endl;
    }else{
        for(int i = 0; i < N-1; i++){
            int tmp = 0;
            clear_depth();
            depth[edge[i].first] = 0;
            depth[edge[i].second] = 0;
            dfs1(edge[i].first, 0);
            dfs1(edge[i].second, 0);
            for(int j = 1; j <= N; j++){
                if(depth[j] > K/2) tmp++;
            }
            ans = min(ans, tmp);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 512
#include <iostream> 
#include <string> 
#include <vector> 
#include <cmath> 
#include <algorithm> 
#include <cstdlib> 
#include <ctime> 
#include <cstdio> 
#include <functional> 
#include <set> 
#include <sstream> 
#include <cctype>

using namespace std; 

#define MP make_pair
typedef unsigned long long ULL;

//dp[i+][j]
//i番目まで使って重さj以下になるように選んだ時の最大価値
long dp[101][10001];

int main(){

	int N,W;
	cin>>N>>W;

	vector<int> v(N),w(N);
	for(int i=0;i<N;i++) cin>>v[i]>>w[i];

	for(int i=0;i<N;i++){
		for(int j=0;j<=W;j++){
			if(j<w[i]) dp[i+1][j]=dp[i][j];
			else       dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
		}
	}

	cout<<dp[N][W]<<endl;

	return 0;
}

Measured memory_bytes: 9016
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int n;
    cin>>n;
    vi a(n);
    forn(i,n)   cin>>a[i];
    sort(all(a));

    int cnt=1, max_cnt=1, i=0, j=1;
    while(i<n && j<n)
    {
        if(a[j]-a[i]<=2)
        {
            j++;
            cnt++;
        }
        else
        {
            max_cnt = max(max_cnt, cnt);
            i++;
            cnt--;
        }
    }
    max_cnt = max(max_cnt, cnt);
    cout<<max_cnt<<endl;
    return 0;
}



Measured memory_bytes: 3608
/**********************************************************************************************
******************************AUTHOR:**********************************************************
****************************ASHISH RANJAN******************************************************
***********************************************************************************************/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<chrono>
#include<vector>
#include<string>
#include<cstring>
#include<climits>
using namespace std;
using namespace std::chrono;
/*
auto start = high_resolution_clock::now();
auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    cout << "Time taken by function: "
         << duration.count() << " microseconds" << endl;
*/
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long
const int M = 1e9 + 7;
#define fr(i,n) for(int i=0;i<n;i++)
#define frs(i,a,b) for(int i = a;i<b;i++)
#define meme(a,b) memset(a,b,sizeof(a)); //works only for 0 and -1
ll mod(long long x){
 return (x%M+M)%M;
}
ll add(long long a,long long  b){
return mod(mod(a)+mod(b));
}
ll mul(long long a,long long b){
return mod(mod(a)*mod(b));
}
ll minu(long long a,long long b){
return mod(mod(a)-mod(b));
}
ll modPow(ll a,ll b){
if(b==0)return 1LL;
if(b==1)return a%M;
ll res= 1;
while(b){
if(b%2==1)
res = mul(res,a);
a = mul(a,a);
b/=2;
}
return res;
}
void solve(){
int n;
cin>>n;
int count = 0;
// bool flag = false;
int mx = INT_MIN;
while(n--){
int a,b;
cin>>a>>b;
if(a==b){
count++;
mx = max(mx,count);
}
else{
count = 0;
}
}
if(mx>=3)cout<<"Yes";
else cout<<"No";
return;
}
int main(){
  fast();
//  int t;cin>>t;
//  while(t--){
    solve();
    cout<<endl;
//  }
 return 0;
}


Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef pair<int,int> PII;
const int maxn=1000100,mod=998244353;
#define MP make_pair
#define lson o<<1,l,mid
#define rson o<<1|1,mid+1,r
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline int read(){
    int x=0,f=0;char ch=getchar();
    while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
    while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
    return f?-x:x;
}
int n,a[maxn],f[maxn][2];
char s[maxn];
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	FOR(i,1,n) a[i]=s[i]-'0';
	f[1][0]=min(a[1],11-a[1]);
	f[1][1]=min(a[1]+1,10-a[1]);
	FOR(i,2,n){
		f[i][0]=min(f[i-1][0]+a[i],f[i-1][1]+10-a[i]);
		f[i][1]=min(f[i-1][0]+a[i]+1,f[i-1][1]+9-a[i]);
	}
	printf("%d\n",f[n][0]);
}

Measured memory_bytes: 12928
n_rect = 0
n_dia = 0
while True:
    try:
        a,b,c = map(int, input().split(','))
        if a**2 + b**2 == c**2:
            n_rect += 1
        if a == b:
            n_dia += 1
    except EOFError:
        break

print(n_rect) 
print(n_dia) 

Measured memory_bytes: 7564
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
 
namespace ConsoleApplication13
{
    class Program
    {
        static void Main(string[] args)
        {
			int[] a = new int[3];
			a[0]=1;
			a[1]=a[2]=0;
			string line;
			while((line=Console.ReadLine())!=null)
			{
				string b = line;
				int c=0;
				if(b[0]=='A'&&b[2]=='B')
				{
				c=a[0];
				a[0]=a[1];
				a[1]=c;
			}
			if(b[0]=='A'&&b[2]=='C')
				{
				c=a[0];
				a[0]=a[2];
				a[2]=c;
			}
			if(b[0]=='B'&&b[2]=='C')
				{
				c=a[1];
				a[1]=a[2];
				a[2]=c;
			}
			if(b[0]=='B'&&b[2]=='A')
				{
				c=a[0];
				a[0]=a[1];
				a[1]=c;
			}
			if(b[0]=='C'&&b[2]=='A')
				{
				c=a[0];
				a[0]=a[2];
				a[2]=c;
			}
			if(b[0]=='C'&&b[2]=='B')
				{
				c=a[1];
				a[1]=a[2];
				a[2]=c;
			}
				}
				if(a[0]==1)
				Console.WriteLine("A");
				if(a[1]==1)
				Console.WriteLine("B");
				if(a[2]==1)
				Console.WriteLine("C");
}}
}

Measured memory_bytes: 8548
#include <stdio.h>
#define ll unsigned long long

void main(){
    unsigned long long K;
    unsigned long long ans = 7;
    int i = 1;
    scanf("%lld",&K);
    if(K%2 == 0){printf("-1\n");return;}
    unsigned long long npcp = 0;
    while(1){
        int f = (npcp*10+7)/K;
        npcp = (npcp*10+7)%(K);
        if(npcp == 0 && f > 0){printf("%d\n",i);return;}
        //npcp = npcp + 7;
        i++;
        if(i >= 10000000){break;}
    }
    printf("-1\n");
}

Measured memory_bytes: 1696
module ABC102

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public  :: task_B
  private :: linear_search

  ! constants for this <module>
  integer(INT32), parameter, private :: len_sequence_max = 100

  ! variables for this <module>
  integer(INT32), private :: len_sequence
  integer(INT32), private :: val_sequence_max
  integer(INT32), private :: val_sequence_min

  ! array for this <module>
  integer(INT32), private :: val_sequence(1:len_sequence_max)

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_B

    ! variables for this <subroutine>
    integer :: iter

    ! STEP.01
    ! read out the length of the given sequence
    read(unit=INPUT_UNIT, fmt=*) len_sequence

    ! STEP.02
    ! read out the values of the given sequence
    read(unit=INPUT_UNIT, fmt=*) val_sequence(1:len_sequence)

    ! STEP.03
    ! find the maximum & minimum value of the given sequence
    call linear_search

    ! STEP.04
    ! calculate & output the maximum difference of the given sequence
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') val_sequence_max - val_sequence_min

    ! STEP.END
    return

  end subroutine task_B

  subroutine linear_search

    ! support variables for this <subroutine>
    integer(INT32) :: iter

    val_sequence_max = val_sequence(1)
    val_sequence_min = val_sequence(1)

    do iter = 1, len_sequence, 1
      if (val_sequence(iter) .gt. val_sequence_max) val_sequence_max = val_sequence(iter)
      if (val_sequence(iter) .lt. val_sequence_min) val_sequence_min = val_sequence(iter)
    end do

    return

  end subroutine linear_search

end module ABC102


program main

  ! <module>s to import
  use, non_intrinsic :: ABC102

  ! require all variables to be explicitly declared
  implicit none

  call task_B

end program main

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define int long long
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;


ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
bool root(string s){
    int n=s.length();
    if(n==2){
        if(s[0]==s[1]){
            return true;
        }
        else return false;
    }
    if(n==3){
        if(s[0]==s[2]){
            return true;
        }
        else return false;
    }
 
    return false;
}
 
 
//深さ優先
vector<int> seen;
vector<ll> h;
 
//普通の深さ優先探索seenを返す感じ
void dfs(const Graph &G,int v){
    seen[v] = 0; //v探索済み
 
    P good=make_pair(v,h[v]);
    for(auto next_v :G[v]){
        if(seen[next_v]!=-1) continue;//もう探索していた
        if(h[next_v]>good.second){
            good=make_pair(next_v,h[next_v]);
        }
        dfs(G,next_v);
    }
 
    if(!(h[v]==good.second && v==good.first)){
        seen[good.first]=1;
    }
}
 
signed main(){
    int n; cin>>n;
    for(int i=1;i<=9;i++){
        int abc=100*i+10*i+1*i;
        if(n<=abc){
            cout<<abc<<endl;
            return 0;
        }
    }
}   

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

long long gcd(long long a, long long b) {
    long long v0 = a, v1 = b, v2 = a % b;
    while (v2 != 0) {
        v0 = v1;
        v1 = v2;
        v2 = v0 % v1;
    };
    return v1;
}

long long lcm(long long a, long long b){
    return (a * b) / gcd(a, b);
}

int main() {
    long long A,B,C,D;
    cin >> A >> B >> C >> D;
    long long ans=0;
    
    ans += (B/C) - (A/C);
    if (A%C == 0) {
        ans++;
    }
    //cout << ans <<endl;
    
    ans += (B/D) - (A/D);
    if (A%D == 0) {
        ans++;
    }
    //cout << ans << endl;
    
    long long CD = lcm(C, D);
    
    ans -= (B/CD) - (A/CD);
    if (A%CD==0) {
        ans--;
    }
    
    ans = (B-A+1)-ans;
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 8
#define Q 'Q'
#define F 99

void putQueen(int);
int dpos[14],dneg[14],row[N],col[N],fas[N];
int main(){
  int n,i,j,k;
  for(i=0;i<15;i++){
    row[i]=F;
    dpos[i]=F;
    dneg[i]=F;
    col[i]=F;
    fas[i]=F;
  }
  scanf("%d",&n);
  
  for(k=0;k<n;k++){
    scanf("%d%d",&i,&j);
    fas[i]=j;
    row[i]=j;
    col[j]=Q;
    dpos[i+j]=Q;
    dneg[i-j+N-1]=Q;
  }
  putQueen(0);
  
  return 0;
}
void putQueen(int i){
  int j;
  if(i==N){
    for(i=0;i<N;i++){
      for(j=0;j<N;j++)if(j==row[i])printf("Q");else printf(".");
      printf("\n");
    }
      
    return;
  }
  if(fas[i]!=F){
    putQueen(i+1);
    return;
  }
  for(j=0;j<N;j++){
    if(col[j]!=F||dpos[i+j]!=F||dneg[i-j+N-1]!=F)continue;
    row[i]=j;
    col[j]=dpos[j+i]=dneg[i-j+N-1]=Q;
    putQueen(i+1);
    col[j]=dpos[j+i]=dneg[i-j+N-1]=F;
  }
}



Measured memory_bytes: 2112
#include<stdio.h>

int main()
{
    char s[16];
    int y,m,d;

    scanf("%04d/%02d/%02d",&y,&m,&d);

    if((10000*y+100*m+d-20190430)>0) printf("TBD");
    else printf("Heisei");
    return 0;
}


Measured memory_bytes: 128
fun main(args: Array<String>) {
    val s = readLine()!!
    val t = readLine()!!

    var ans : CharArray
    var tOk : Boolean
    for (i in s.length-t.length downTo 0) {
        ans = s.toCharArray()
        tOk = true
        for (j in t.indices) {
            if (s[i+j] == '?' || s[i+j] == t[j]) {
                ans[i+j] = t[j]
            } else {
                tOk = false
                break
            }
        }
        if (tOk) {
            println(ans.joinToString("").replace("?", "a"))
            return
        }
    }
    println("UNRESTORABLE")
}


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

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

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

  if(str[0]=='7' || str[1]=='7' || str[2]=='7'){
    cout << "Yes" << endl; 
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3628
import sys
read = sys.stdin.buffer.read
INF = 10**12

class Rmin():
	def __init__(self, size):
		#the number of nodes is 2n-1
		self.n = 1 << (size.bit_length())
		self.node = [INF] * (2*self.n-1)

	def Access(self, x):
		return self.node[x+self.n-1]

	def Update(self, x, val):
		x += self.n-1
		self.node[x] = val
		while x > 0:
			x = (x-1)>>1
			self.node[x] = min(self.node[(x<<1)+1], self.node[(x<<1)+2])
		return

	#[l, r)
	def Get(self, l, r):
		L, R = l+self.n, r+self.n
		s = INF
		while L<R:
			if R & 1:
				R -= 1
				s = min(s, self.node[R-1])
			if L & 1:
				s = min(s, self.node[L-1])
				L += 1
			L >>= 1
			R >>= 1
		return s

n, q, a, b, *qs = map(int, read().split())
dp_l, dp_r = Rmin(n+1), Rmin(n+1)
dp_l.Update(b, -b)
dp_r.Update(b, b)

total_diff = 0
x = a
for y in qs:
	diff = abs(y - x)
	l_min = dp_l.Get(1, y)
	r_min = dp_r.Get(y, n+1)
	res = min(l_min + y, r_min - y)
	dp_l.Update(x, res - diff - x)
	dp_r.Update(x, res - diff + x)
	total_diff += diff
	x = y

N = dp_l.n
print(total_diff + min((l+r)>>1 for l, r in zip(dp_l.node[N:], dp_r.node[N:])))

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

const int N = 100 * 1000 + 5;
int n, k, ans;

int a[N];
vector <int> adj[N];
int g[N];
bool mark[N];
bool b[N];

void dfs(int v) {
	mark[v] = true;
	g[v] = 1;
	for (auto u : adj[v]) {
		if (!mark[u]) {
		//	h[u] = h[v] + 1;
			dfs(u);
			g[v] = max(g[v], g[u] + 1);
		}
	}
	if (g[v] == k && !b[v]) {
		ans++;
		g[v] = 0;
	}
//	if (h[v] % (k + 1) == 0) {
//		ans++;
//	}
}
int main() {
	cin >> n >> k;
	b[1] = true;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		adj[a[i]].push_back(i);
		if (a[i] == 1) {
			b[i] = true;
		}
	}
	dfs(1);
	if (a[1] != 1) {
		ans++;
	}
	cout << ans << endl;
	return 0;
}


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

ll gcd(ll a, ll b){ return b ? gcd(b, a%b) : a;}

ll lcm(ll a, ll b){
  return a/gcd(a,b)*b;
}

ll f(ll x, int c, int d) {
  ll res = x;
  res -= x/c;
  res -= x/d;
  res += x/lcm(c, d);
  return res;
}

int main(){
  ll a, b;
  int c, d;
  cin >> a >> b >> c >> d;
  ll ans = f(b, c, d) - f(a-1, c, d);
  cout << ans << endl;
}

/*
int main(){
  long long int a, b, c, d;
  cin >> a >> b >> c >> d;
  long long int range = b - a + 1;
  long long int c_in_range = range/c;
  long long int d_in_range = range/d;
  long long int cd_in_range = range/(c * d);
  cout << range - (c_in_range + d_in_range - cd_in_range) << endl;

}
*/

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

class Dice {
	int *d;
public:
	Dice(int *pd);
	void roll(char dir);
	int me(int n);
	void top(int topn);
	void front(int frn);
};
Dice::Dice(int *pd) {
	d = pd;
}

void Dice::roll(char dir) {
	int tmp;
	if(dir=='E') {
		tmp = d[0];
		d[0] = d[3];
		d[3] = d[5];
		d[5] = d[2];
		d[2] = tmp;
		}
	else if(dir=='W') {
		tmp = d[0];
		d[0] = d[2];
		d[2] = d[5];
		d[5] = d[3];
		d[3] = tmp;
	}
	else if(dir=='S') {
		tmp = d[0];
		d[0] = d[4];
		d[4] = d[5];
		d[5] = d[1];
		d[1] = tmp;
	}
	else {
		tmp = d[0];
		d[0] = d[1];
		d[1] = d[5];
		d[5] = d[4];
		d[4] = tmp;
	}
}
int Dice::me(int n) {
	return d[n-1];
}
void Dice::top (int topn) {
	if(topn == d[1])
		roll('N');
	else if(topn == d[2])
		roll('W');
	else if(topn == d[3])
		roll('E');
	else if(topn == d[4])
		roll('S');
	else if(topn == d[5]) {
		roll('S');
		roll('S');
	}	 
}
void Dice::front (int frn) {
	if(frn == d[2]) {
		roll('W');
		roll('S');
		roll('E');		
	}
	if(frn == d[3]) {
		roll('E');
		roll('S');
		roll('W');		
	}
	if(frn == d[4]) {
		roll('W');
		roll('S');
		roll('S');
		roll('E');		
	}
}

int main()
{
	int d1[6],d2[6];
	int fn,tn;
	for (int i=0; i < 6; i++)
		cin >> d1[i];
	for (int i=0; i < 6; i++)
		cin >> d2[i];
	Dice dice1(d1), dice2(d2);
	for (int i = 0; i < 3; i++) {
		dice2.top(dice1.me(1));
		dice2.front(dice1.me(2));
		if (
			(dice1.me(3) == dice2.me(3)) &&
			(dice1.me(4) == dice2.me(4)) &&
			(dice1.me(5) == dice2.me(5)) &&
			(dice1.me(6) == dice2.me(6))
		) {
			cout << "Yes" << endl;
			break;
		}	
		else {
			dice1.roll('N');
			dice1.roll('W');
			if (i == 2)
				cout << "No" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
int n,tot,vis[1005],ans;
char s[1005];
int main()
{
	scanf("%d",&n);
	while(n)
	{
		s[++tot]=n%10+'0';
		n/=10;
	}
	for(int i=1;i<=tot;++i)
	{
		if(s[i]=='1'&&!vis[i]) s[i]='9',vis[i]=1;
		if(s[i]=='9'&&!vis[i]) s[i]='1',vis[i]=1;
	}
	for(int i=1;i<=tot;++i)
		ans+=pow(10,i-1)*(s[i]-'0');
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f 
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long int
#define pi 3.14159265358979
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define PI 3.1415926535897932384626
#define minn INT_MAX
#define maxx INT_MIN
#define fori(i, n) for (i = 0; i < n; i++)
typedef pair<int, int>  pii;
typedef vector<int>   vi;
typedef vector<pii>   vpii;
typedef vector<vi>    vvi;
int main() {
  #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
  #endif
  int x;
  cin>>x;
  if(x==0)
    cout<<1;
  else
    cout<<0;
  return 0;
}

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


signed main(){

 int n; cin>>n;
 int m = sqrt(n);
 int p = 0;

 for(int i=1;i<m+1;i++){

    if(n%i == 0)
        p = i;
 }

  m = n/p;
  cout<<m+p-2<<endl;

  return 0;
  }


Measured memory_bytes: 256
''' بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ '''
#codeforces
gi = lambda : list(map(int,input().split()))
n, m = gi()
l = m // 2 + m % 2
ans = l * (n // 2 + n % 2) + (m // 2) * (n // 2)
if n == 1 or m == 1:
	ans = 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int n;string s,t; cin >> n >> s >> t;
  rep(i,n){
    cout << s[i] << t[i];
  }
  cout << endl;
  return 0;
}


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

struct die {
	int val[6];
	void N() {
		int tmp[6];
		for (int i = 0; i < 6; i++) {
			tmp[i] = val[i];
		}
		val[0] = tmp[1];
		val[4] = tmp[0];
		val[5] = tmp[4];
		val[1] = tmp[5];
	}
	void E() {
		int tmp[6];
		for (int i = 0; i < 6; i++) {
			tmp[i] = val[i];
		}
		val[2] = tmp[0];
		val[5] = tmp[2];
		val[3] = tmp[5];
		val[0] = tmp[3];
	}
	void W() {
		int tmp[6];
		for (int i = 0; i < 6; i++) {
			tmp[i] = val[i];
		}
		val[3] = tmp[0];
		val[5] = tmp[3];
		val[2] = tmp[5];
		val[0] = tmp[2];
	}
	void S() {
		int tmp[6];
		for (int i = 0; i < 6; i++) {
			tmp[i] = val[i];
		}
		val[0] = tmp[4];
		val[1] = tmp[0];
		val[5] = tmp[1];
		val[4] = tmp[5];
	}
};

int main()
{
	string com;
	die d;
	for (int i = 0; i < 6; i++) {
		cin >> d.val[i];
	}
	cin >> com;
	for (char c : com) {
		switch (c)
		{
		case 'N':
			d.N();
			break;
		case 'E':
			d.E();
			break;
		case 'W':
			d.W();
			break;
		case 'S':
			d.S();
			break;
		}
	}
	cout << d.val[0] << endl;
	return 0;
}

Measured memory_bytes: 3196
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int calc(int x) {
	int maxi = -1;
	for (int y = 10; y <= x; y *= 10)
		maxi = max(maxi, (x / y) * (x % y));
	if (maxi == -1) maxi = x;
	return maxi;
}

int main() {
	int Q; cin >> Q;
	while (Q--) {
		int N; cin >> N;
		int cnt = 0;
		while (calc(N) != N) {
			cnt++;
			N = calc(N);
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 1160
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! p {
    ($($x:expr),*) => {
        $(println!("{:?}", $x);)*
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        #[allow(unused_mut)]
        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)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $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")
    };
}
fn main(){
    input!{
        k:i32,
        x:i32
    }
    let v = (x-k+1..x+k).into_iter().collect::<Vec<i32>>();
    for i in v{
        print!("{} ",i);

    }
}

Measured memory_bytes: 4476
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class ABC101_C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int ans = 0;

            while ((k - 1) * ans + 1 < n) {
                ans++;
            }
            out.print(ans);
        }

    }
}



Measured memory_bytes: 22996
## YYMM or MMYY or AMBIGUOUS or NA
## YY: なんでもok
## MM: 01~12
## MMの個数によって条件分岐すればok

s = input()
pre = int(s[:2])
last = int(s[2:])

if 1 <= pre <= 12 and 1 <= last <= 12:
  print("AMBIGUOUS")
elif 1 <= pre <= 12:
  print("MMYY")
elif 1 <= last <= 12:
  print("YYMM")
else:
  print("NA")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 1e4 + 10;
int a, b;
int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    while(cin >> a >> b) {
        int ans = a;
        if(!(a % b)) ans = -1;
        cout << ans << endl;
    }
}

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

char i2c(int i) {
    if(0 <= i && i < 26) return 'a' + i;
    if(26 <= i && i < 52) return 'A' + i - 26;
    assert(false);
}

int c2i(char c) {
    if('a' <= c && c <= 'z') return c - 'a';
    if('A' <= c && c <= 'Z') return c - 'A' + 26;
    assert(false);
}

char rev_c(char c, int r) {
    int num = c2i(c);
    num -= r;
    (num += 52) %= 52;
    return i2c(num);
}

bool solve() {
    int N;
    cin >> N;
    if(!N) return false;

    vector<int> K(N);
    for(int &e : K) cin >> e;

    string S;
    cin >> S;

    for(int i = 0; i < S.size(); i++) {
        int k = K[i % K.size()];
        cout << rev_c(S[i], k);
    }
    cout << endl;
    return true;
}

int main() {
    while(solve());
    return 0;
}



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

int main() {
  string s; cin >> s;
  string ans = "Yes";
  if (s[0] == s[1] && s[1] == s[2]) ans = "No";
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
// Hey! 僕の提出を見てくれてありがとう.
// ロボ子さん可愛いぞ！！！！！君もV沼にはまろう↓
// https://www.youtube.com/channel/UCDqI2jOz0weumE8s7paEk6g
using namespace std;
namespace mp = boost::multiprecision;
// 任意長整数型
using bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using real1024 = mp::number<mp::cpp_dec_float<1024>>;
// ついでに有理数型
using rat = boost::rational<bint>;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
//sortを降順にする時は greater<型>()

void solve(long long N, long long H, long long W, std::vector<long long> A, std::vector<long long> B){
	int ans = 0;
	for (int i = 0; i < N; i++) {
		if (H <= A[i] && W <= B[i])ans++;
	}
	cout << ans << endl;
}

int main(){
    long long N;
  scanf("%lld",&N);
  long long H;
  scanf("%lld",&H);
  long long W;
  scanf("%lld",&W);
  std::vector<long long> A(N);
  std::vector<long long> B(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
    scanf("%lld",&B[i]);
  }
    solve(N, H, W, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 3704
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.map f

[<EntryPoint>]
let main argv =
    let [|a;b|] = reads int
    let (x, y) = (min a b, max a b)
    let z = (y - x) / 2 + x
    if (y - x) % 2 = 0
    then printfn "%i" z
    else printfn "IMPOSSIBLE"
    0

Measured memory_bytes: 13532
#include <bits/stdc++.h>
using namespace std;
#define int long long
using P = pair<int, int>;
using V = vector<int>;
constexpr array<int, 4> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
constexpr int INF = 1234567890, MOD = 1000000000 + 7;
// constexpr int MOD = 998244353;
// constexpr int INF2 = 1000000000000000000LL+7;
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;
}
constexpr int ceil(int a, int b) { return (a + b - 1) / b; }
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int fact(int n) { return n > 1 ? n * fact(n - 1) % MOD : 1; }
constexpr int modpow(int a, int n)
{
    int rtn = 1;
    while (n > 0)
    {
        if (n & 1)
            rtn = rtn * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return rtn;
}
int modinv(int a)
{
    int b = MOD, u = 1, v = 0;
    while (b)
    {
        int t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= MOD;
    if (u < 0)
        u += MOD;
    return u;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << setprecision(10);

    int n, W;
    cin >> n >> W;

    vector<P> vw(n);
    for (int i = 0; i < n; i++)
    {
        int v, w;
        cin >> v >> w;
        vw[i] = {v, w};
    }

    // dp[w]: 容量wのナップサックの最大の価値
    // dp[W]が答え

    // 同じ商品はいくつもナップサックに入れられる
    // 更新するとき 今の商品を見たときのDP表から遷移すればよい

    vector<int> dp(W + 1, 0);
    for (auto &&vwi : vw)
    {
        const int v = vwi.first, w = vwi.second;

        // dp値更新
        for (int i = 1; i < W + 1; i++)
        {
            // もらうDP
            if (i - w >= 0)
                dp[i] = max(dp[i - w] + v, dp[i]);
        }
    }
    cout << dp[W] << endl;
}



Measured memory_bytes: 3268
"use strict";

main(require("fs").readFileSync("/dev/stdin", "utf-8"));

function main(input) {
  input = input
    .split("\n")[0]
    .split(" ")
    .map(i => parseInt(i));
  const fee = [400000, 300000, 200000, 100000];
  let result = 0;
  input.forEach(e => {
    if (e <= 3) {
      result += fee[e];
    }
  });
  if (input[0] === input[1] && input[0] === 1) {
    result += fee[0];
  }
  console.log(result);
}


Measured memory_bytes: 21064
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
int main(){
  long long int INF=10000000000000;
  long long int i,j,k,dp[110][110],v,e,s,t,d;
  scanf("%lld %lld\n",&v,&e);
  for(i=0;i<v;i++){
    for(j=0;j<v;j++){
      dp[i][j]=INF;
    }
  }
  for(i=0;i<e;i++){
    scanf("%lld %lld %lld\n",&s,&t,&d);
    dp[s][t]=min(dp[s][t],d);
  }
  for(i=0;i<v;i++){
    dp[i][i]=0;
  }
  for(k=0;k<v;k++){
    for(i=0;i<v;i++){
      for(j=0;j<v;j++){
        dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]);
      }
    }
  }
  for(i=0;i<v;i++){
    if(dp[i][i]<0){
      printf("NEGATIVE CYCLE\n");
      return 0;
    }
  }
  for(i=0;i<v;i++){
    for(j=0;j<v;j++){
      if(j==0){
        if(dp[i][j]>INF-20000000000){
          printf("INF");
        }
        else{
          printf("%lld",dp[i][j]);
        }
      }
      else{
        if(dp[i][j]>INF-20000000000){
          printf(" INF");
        }
        else{
          printf(" %lld",dp[i][j]);
        }
      }
    }
    printf("\n");
  }
  return 0;
}


Measured memory_bytes: 3308
// 0 -> C (< 2^N) をつくる
fn calc(n: usize, c: usize) -> Vec<usize> {
    assert!(c.count_ones() % 2 == 1);
    if n == 1 {
        return vec![0, 1];
    }
    if (c >> (n - 1)) & 1 == 0 {
        let mut i = n - 1;
        while (c >> i) & 1 == 0 {
            i -= 1;
        }
        let mut ans = calc(n, (c ^ (1 << i)) | (1 << (n - 1)));
        for a in ans.iter_mut() {
            let x = *a >> (n - 1) & 1;
            let y = *a >> i & 1;
            *a &= !(1 << (n - 1)) & !(1 << i);
            *a |= (x << i) | (y << (n - 1));
        }
        return ans;
    }
    let mut f = calc(n - 1, 1 << (n - 2));
    let t = calc(n - 1, c ^ (1 << (n - 1)) ^ (1 << (n - 2)));
    for t in t {
        f.push(t ^ (1 << (n - 2)) ^ (1 << (n - 1)));
    }
    f
}

fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let a: usize = it.next().unwrap().parse().unwrap();
    let b: usize = it.next().unwrap().parse().unwrap();
    let c = a ^ b;
    if c.count_ones() % 2 == 0 {
        println!("NO");
        return;
    }
    let ans = calc(n, c);
    assert!(ans.windows(2).all(|a| (a[0] ^ a[1]).count_ones() == 1));
    let mut out = String::from("YES\n");
    for x in ans {
        out.push_str(&format!("{} ", x ^ a));
    }
    out.pop();
    println!("{}", out);
}

fn main() {
    run();
}


Measured memory_bytes: 6644
package main

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

const (
	maxBufferSize = 1048576
)

type Scanner struct {
	lineScanner *bufio.Scanner
	wordScanner *bufio.Scanner
}

var Stdin *Scanner

func init() {
	Stdin = NewScanner()
	Stdin.lineScanner.Buffer(make([]byte, 0), maxBufferSize)
	Stdin.wordScanner.Buffer(make([]byte, 0), maxBufferSize)
}

func NewScanner() *Scanner {
	scanner := &Scanner{
		lineScanner: bufio.NewScanner(os.Stdin),
		wordScanner: bufio.NewScanner(os.Stdin),
	}
	scanner.lineScanner.Split(bufio.ScanLines)
	scanner.wordScanner.Split(bufio.ScanWords)
	return scanner
}

func (sc *Scanner) NextLine() string {
	Stdin.lineScanner.Scan()
	return Stdin.lineScanner.Text()
}

func (sc *Scanner) Next() string {
	Stdin.wordScanner.Scan()
	return Stdin.wordScanner.Text()
}

func (sc *Scanner) NextInt() int {
	Stdin.wordScanner.Scan()
	ret, err := strconv.Atoi(Stdin.wordScanner.Text())
	if err != nil {
		panic(err)
	}
	return ret
}

func (sc *Scanner) NextNInts(N int) []int {
	ints := make([]int, N)
	for i := 0; i < N; i++ {
		ints[i] = sc.NextInt()
	}
	return ints
}

func (sc *Scanner) NextInt64() int64 {
	Stdin.wordScanner.Scan()
	ret, err := strconv.ParseInt(Stdin.wordScanner.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return ret
}

func (sc *Scanner) NextFloat() float64 {
	Stdin.wordScanner.Scan()
	ret, err := strconv.ParseFloat(Stdin.wordScanner.Text(), 64)
	if err != nil {
		panic(err)
	}
	return ret
}

func Min(is ...int) int {
	min := math.MaxInt32
	for _, i := range is {
		if min > i {
			min = i
		}
	}
	return min
}

func searchMin(N, K int) int {
	min := 1
	for i := 0; i < N; i++ {
		min = Min(2 * min, min + K)
	}
	return min
}

func main() {
	N := Stdin.NextInt()
	K := Stdin.NextInt()

	min := searchMin(N, K)
	fmt.Println(min)
}


Measured memory_bytes: 640
n, k = io.read("*n", "*n")
k = k / 1000
z = k % 5
x, y = -1, -1
while(z <= n) do
    nt, kt = n - z, k - z
    a = kt - nt * 5
    if(a % 5 == 0) then
        x = a / 5
        if(x <= nt and 0 <= x) then
            y = nt - x
            break
        end
    end
    z = z + 5
end
if(0 <= y) then io.write(string.format("%d %d %d\n", x, y, z)) else print("-1 -1 -1") end


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

struct Edge{
    int to;
    int id;
};

int main(void){
    int n, a, b;
    std::vector<std::vector<Edge>> tree;
    std::vector<int> used;
    std::vector<int> ans;

    std::cin >> n;
    tree.resize(n);
    used.resize(n);
    ans.resize(n-1);

    for(int i = 0; i < n-1; i++){
	std::cin >> a >> b;
	a--; b--;
	tree[a].push_back((Edge){b, i});
	tree[b].push_back((Edge){a, i});
    }

    std::queue<int> q;
    q.push(0);
    used[0] = 1;

    while(!q.empty()){
	int c = -1;
	int u = q.front(); q.pop();
	for(int i = 0; i < tree[u].size(); i++){
	    int to = tree[u][i].to;
	    int id = tree[u][i].id;
	    if(used[to]) c = ans[id];
	}
	int k = 1;
	for(int i = 0; i < tree[u].size(); i++){
	    int to = tree[u][i].to;
	    int id = tree[u][i].id;
	    if(used[to]) continue;
	    q.push(to);
	    if(k == c) k++;
	    ans[id] = k;
	    used[to] = 1;
	    k++;
	}
    }

    int max = 0;
    for(int i = 0; i < n; i++){
	int size = tree[i].size();
	max = std::max(max, size);
    }
    std::cout << max << std::endl;

    for(int i = 0; i < n-1; i++){
	std::cout << ans[i] << std::endl;
    }

    return 0;
}



Measured memory_bytes: 10012