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

int N;
int a[2002];

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

  cin >> N;
  for (int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  sort(a, a + N);

  int res = 0;
  for (int i = 0; i + 2 < N; ++i) {
    int ptr = i + 2;
    for (int j = i + 1; j < N; ++j) {
      while (ptr < N && a[ptr] < a[i] + a[j]) {
        ++ptr;
      }
      if (ptr > j) {
        res += ptr - j - 1;
      }
    }
  }

  cout << res << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */

int main() {
  
  lint x, k, d; cin >> x >> k >> d;
  if (x < 0) x = -x;

  lint q = x / d;

  if (q >= k) {
    x -= k * d;
    cout << x << endl;
    return 0;
  }

  x -= q * d;
  k -= q;

  if (k % 2 == 0) {
    cout << x << endl;
  } else {
    lint ans = x - d;
    if (ans < 0) ans = -ans;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

void trace(int A[],int N){
    REP(i,N){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}


int main(){
    int N;
    cin >> N;
    int a = N%10;
    N/=10;
    int b = N%=10;
    if(a == 9 || b == 9)cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

a = I()
b = I()

if (a == 1 and b == 2) or (a == 2 and b == 1):
    print(3)
elif (a == 3 and b == 1) or (a == 1 and b == 3):
    print(2)
else:
    print(1)
    

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#include <math.h>
 
#define rep(i, n) for(int i = 0; (int)(i) < n; i++)
 
using namespace std;
 
int main() {
  char n;
  string ans = "No";
  rep(i, 3){
    cin >> n;
    if(n == '7') ans = "Yes";
  }
  cout << ans << endl;
}

Measured memory_bytes: 3516
#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 N = 100;
int A,B;
char ans[N][N];

int main(){
	cin >> A >> B;
	repp(i,0,N/2) repp(j,0,N) ans[i][j] = '#';
	repp(i,N/2,N) repp(j,0,N) ans[i][j] = '.';
	[]{
		for(int i = 0 ; i < N/2 ; i += 2) for(int j = 0 ; j < N ; j += 2){
			if(A == 1) return;
			ans[i][j] = '.';
			--A;
		}
	}();
	[]{
		for(int i = N-1 ; i > N/2 ; i -= 2) for(int j = 0 ; j < N ; j += 2){
			if(B == 1) return;
			ans[i][j] = '#';
			--B;
		}
	}();
	cout << N << ' ' << N << endl;
	repp(i,0,N){
		repp(j,0,N) cout << ans[i][j];
		cout << endl;
	}
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve();
			Console.Out.Flush();
		}

		const int mod = 1000000007;  // 10^9+7
		static int Mod(long x, int m) { return (int)((x % m + m) % m); }
		static long Mod(long x, long m) { return (x % m + m) % m; }

		static public void Solve()
		{
			//string s = Console.ReadLine();
			//int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();

			int[] a = Console.ReadLine().Split().Select(int.Parse).OrderBy(p=>p).ToArray();
			int ans = 0;
			if (a[0] < a[2]) {
				int i = (a[2] - a[0]) / 2;
				a[0] += i * 2;
				ans += i;
			}
			//System.Diagnostics.Debug.WriteLine($"{ans}:{string.Join(" ", a)}");
			if (a[1] < a[2]) {
				int i = (a[2] - a[1]) / 2;
				a[1] += i * 2;
				ans += i;
			}
			//System.Diagnostics.Debug.WriteLine($"{ans}:{string.Join(" ", a)}");
			if (a[0] == a[1] && a[0] != a[2]) {
				ans++;
			} else if (a[0] == a[2] && a[0] != a[1]) {
				ans += 2;
			} else if (a[1] == a[2] && a[1] != a[0]) {
				ans += 2;
			}
			Console.WriteLine(ans);

		}
	}
}


Measured memory_bytes: 28448
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>

using namespace std;

#define MAX_N 8

long double n;
int path[MAX_N];
long double ds[MAX_N][MAX_N];
int walked;

long double calc(vector<int> path) {
    long double sum = 0;
    if (path.size() == n) {
        for(int i=0; i<n-1; i++) {
            sum += ds[path[i]][path[i+1]];
        }
        walked++;
        return sum;
    }

    for(int i=0; i<n; i++) {
        if (find(path.begin(), path.end(), i) != path.end()) {
            continue;
        }

        path.push_back(i);
        sum += calc(path);
        path.pop_back();
    }
    return sum;
}

int main() {
    walked = 0;
    
    cin >> n;

    long double xs[MAX_N];
    long double ys[MAX_N];
    long double x, y;
    for(int i=0; i<n; i++) {
        cin >> x >> y;
        xs[i] = x;
        ys[i] = y;
    }

    for (int i=0; i<n; i++) {
        for (int j=0; j<n; j++) {
            ds[i][j] = sqrt(pow(xs[i] - xs[j], 2) + pow(ys[i] - ys[j], 2));
        }
    }

    vector<int> path;
    cout << setprecision(20) << calc(path)/(long double)walked << endl;

    return 0;
}

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

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c, n, sum, A[500010], B[500000], rui[500000], dp[5000];
str S; bool check = true;	vector<ll> v;



int main() {
	//Code Line
	cin >> a >> b;
	c = 1;
	while (a >= c) {
		c *= b;
		n++;


	}
	cout << n << endl;

	return 0;
}


Measured memory_bytes: 256
n = int(input())
s = map(int, input().split())
lis = [6, 10, 12, 18, 20, 24, 30, 36, 40, 42, 48, 50, 54, 60, 66, 70, 72, 78, 80, 84, 90, 96, 100, 102, 108, 110, 114, 120, 126, 130, 132, 138, 140, 144, 150, 156, 160, 162, 168, 170, 174, 180, 186, 190, 192, 198, 200, 204, 210, 216, 220, 222, 228, 230, 234, 240, 246, 250, 252, 258, 260, 264, 270, 276, 280, 282, 288, 290, 294, 300, 306, 310, 312, 318, 320, 324, 330, 336, 340, 342, 348, 350, 354, 360, 366, 370, 372, 378, 380, 384, 390, 396, 400, 402, 408, 410, 414, 420, 426, 430, 432, 438, 440, 444, 450, 456, 460, 462, 468, 470, 474, 480, 486, 490, 492, 498, 500, 504, 510, 516, 520, 522, 528, 530, 534, 540, 546, 550, 552, 558, 560, 564, 570, 576, 580, 582, 588, 590, 594, 600, 606, 610, 612, 618, 620, 624, 630, 636, 640, 642, 648, 650, 654, 660,666, 670, 672, 678, 680, 684, 690, 696, 700, 702, 708, 710, 714, 720, 726, 730, 732, 738, 740, 744, 750, 756, 760, 762, 768, 770, 774, 780, 786, 790, 792, 798, 800, 804, 810, 816, 820, 822, 828, 830, 834, 840, 846, 850, 852, 858, 860, 864, 870, 876, 880, 882, 888, 890, 894, 900, 906, 910, 912, 918, 920, 924, 930, 936, 940, 942, 948, 950, 954, 960, 966, 970, 972, 978, 980, 984, 990, 996]
tmp = []
for i in s:
    if i % 2 == 0:
        if i not in lis:
            print('DENIED')
            exit()
print('APPROVED')

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, q;
  cin >> n >> k >> q;
  int a[100100];
  for(int i=0; i<q; i++){
    cin >> a[i];
  }
  vector<int> b(n, k);
  for(int i=0; i<q; i++){
    b[a[i]-1]++;
  }
  for(int i=0; i<n; i++){
    b[i] -= q;
  }
  for(int i=0; i<n; i++){
    if(b[i]<=0){
      cout << "No" << endl;
    }
    else cout << "Yes" << endl;
  }
}

Measured memory_bytes: 1408
#define E 0.0001
#define zero(n)(fabs(n)<E)
main(n,a,b,c,d,p,q,r,D,f){
	for(scanf("%d",&n);n;n--){
		scanf("%d%d%d%d",&a,&b,&c,&d);//fx=ax3+bx2+cx+d
		if(a<0)a=-a,b=-b,c=-c,d=-d;   //won't lose generality
		p=3*a,q=2*b,r=c,D=q*q-4*p*r;  //f'x=3ax2+2bx+c D: f'x=0?
		if(D>0){
			double x1=(-q-sqrt(D))/p/2,x2=(-q+sqrt(D))/p/2;
			double y1=a*x1*x1*x1+b*x1*x1+c*x1+d;
			double y2=a*x2*x2*x2+b*x2*x2+c*x2+d;
			if(!zero(y1)&&!zero(y2)>E&&y1*y2>0)goto one;
			puts(
				zero(x1)?(
					d==0?"1 0":
					"2 1"
				):zero(x2)?(
					d==0?"0 1":
					"1 2"
				):x1>0?(
					d>0?"2 1":
					d<0?"3 0":
					"2 0"
				):x2<0?(
					d>0?"0 3":
					d<0?"1 2":
					"0 2"
				):(
					d>0?"2 1":
					d<0?"1 2":
					"1 1"
				)
			);
		}else if(D==0)puts(
			d>0?"0 1":
			d<0?"1 0":
			"0 0"
		);else{one:
			puts(d>0?"0 1":d<0?"1 0":"0 0");
		}
	}
	exit(0);
}

Measured memory_bytes: 584
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

using namespace std;

int main(void){
    vector<int> h;
    vector<vector<int>> path;
    int n,m,temp1,temp2;
    cin>>n>>m;
    h.push_back(0);
    for(int i=0;i<n;i++){
        cin>>temp1;
        h.push_back(temp1);
    }
    for(int i=0;i<=n;i++){
        path.push_back(vector<int>(0));
    }
    for(int i=0;i<m;i++){
        cin>>temp1>>temp2;
        path[temp1].push_back(temp2);
        path[temp2].push_back(temp1);
    }
    int ans=0,fg;
    for(int i=1;i<=n;i++){
        fg=0;
        for(int hg:path[i]){
            if(hg==0)break;
            if(h[hg]>=h[i]){
                fg++;
                break;
            }
        }
        if(fg==0){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 8828
#include <bits/stdc++.h>
#define int LL
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
const long double PI=3.14159265358979323846264338327950;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}
int lcm(int a,int b)
{
	return a/__gcd(a,b)*b;
}
struct point
{
	int num;
	int x;
	int y;
	point(){}
	point(int _x,int _y,int _num)
	{
		x=_x;
		y=_y;
		num=_num;
	}
};
bool compx(point A,point B)
{
	return A.x<B.x || A.x==B.x && A.y<B.y;
}
bool compy(point A,point B)
{
	return A.y<B.y || A.y==B.y && A.x<B.x;
}
const int MAX_N=100005;
vector <point> a;
int n;
vector <pair<int,pii> > g;
void build(int i,int j)
{
	int cost=min(abs(a[i].x-a[j].x),abs(a[i].y-a[j].y));
	g.pb(mp(cost,mp(a[i].num,a[j].num)));
}
int fa[MAX_N];
int find(int x)
{
	return fa[x]==x?x:fa[x]=find(fa[x]);
}
void unite(int x,int y)
{
	fa[find(x)]=find(y);
}
bool same(int x,int y)
{
	return find(x)==find(y);
}
signed main()
{
	cin>>n;
	a.resize(n);
	rep(i,0,n)
	{
		int x=read(),y=read();
		a[i]=point(x,y,i);
	}
	sort(all(a),compx);
	rep(i,1,a.size())
	{
		build(i,i-1);
	}
	sort(all(a),compy);
	rep(i,1,a.size())
	{
		build(i,i-1);
	}
	sort(all(g));
	rep(i,0,n)fa[i]=i;
	int ans=0;
	rep(i,0,g.size())
	{
		int u=g[i].se.fi,v=g[i].se.se;
		if(!same(u,v))
		{
			unite(u,v);
			ans+=g[i].fi;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10864
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

int N;
int p[100010];

int main(void) {
	cin >> N;
	rep(i, N) cin >> p[i];

	int cnt = 0;
	for (int i = N - 1; i >= 1; --i) {
		if(p[i] == i + 1) swap(p[i], p[i - 1]), cnt++;
	}
	if(p[0] == 1) cnt++;
	printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 640
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_CHAR_CNT		26										// 文字種類数

// 内部変数
static FILE *szpFpI;											// 入力
static char sc1Str[D_CHAR_CNT + 5];								// 文字列
static int si1Char[D_CHAR_CNT];									// 使用文字

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 最小文字 - セット
int
fSetChar(
	int piPos					// <I> 追加位置
	, int piSNo					// <I> 開始文字
)
{
	int i;

	for (i = piSNo; i < D_CHAR_CNT; i++) {
		if (si1Char[i] == 0) {
			sc1Str[piPos] = 'a' + i;
			sc1Str[piPos + 1] = '\0';
			return 0;
		}
	}

	return -1;
}

// 実行メイン
int
fMain(
)
{
	int i, liRet;

	// 文字列 - 取得
	fgets(sc1Str, sizeof(sc1Str), szpFpI);

	// 使用文字 - 取得
	int liNo;
	for (i = 0; ; i++) {
		liNo = sc1Str[i] - 'a';
		if (liNo < 0 || D_CHAR_CNT <= liNo) {
			break;
		}
		else {
			si1Char[liNo] = 1;
		}
	}

	// 文字数
	int liLen = i;
	if (liLen == D_CHAR_CNT) {

		// 文字 - カット
		for (i = D_CHAR_CNT - 1; i >= 0; i--) {
			liNo = sc1Str[i] - 'a';
			si1Char[liNo] = 0;

			// 最小文字 - セット
			liRet = fSetChar(i, liNo + 1);
			if (liRet == 0) {
				return 0;
			}
		}

		return -1;
	}

	// 最小文字 - セット
	fSetChar(liLen, 0);

	return 0;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// データ - 初期化
	memset(si1Char, 0, sizeof(si1Char));						// 使用文字

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// １行出力
	if (liRet == 0) {
		sprintf(lc1Buf, "%s\n", sc1Str);
	}
	else {
		sprintf(lc1Buf, "-1\n");
	}
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define MX              200005
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define ull unsigned long long
#define ll long long

void add(int &a,int b){
    a+=b;
    if(a>=mod)
        a-=mod;
}
vector<double> p(3002);
double ans=0.0;
double dp[3002][3002];
double coins(int &N,int n,int c) {
    if(n==0){
        if(c>N/2)
            return 1;
        return 0;
    }
    if(dp[n][c]!=-1){
        return dp[n][c];
    }
    double t=1;
    t-=p[n];
    double a=1.0;
    a=p[n]*coins(N,n-1,c+1);
    a+=t*coins(N,n-1,c);
    return dp[n][c]=a;
}

int32_t main()
{
    //sbs();
    // int t;cin>>t;
    // while(t--) {
        
    //     cout<<'\n';
    // }
    int n;cin>>n;
    for(int i=1;i<=n;i++)cin>>p[i];
    for(int i=0;i<3002;i++){
        for(int j=0;j<3002;j++){
            dp[i][j]=-1;
        }
    }
    double x = coins(n,n,0);
    cout<<ps(x,10)<<endl;
    return 0;
}

Measured memory_bytes: 70912
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

signed main()
{
  double n, m, d;
  cin >> n >> m >> d;

  double ans = (m - 1) / (n * n);
  if (d == 0) ans *= n;
  else ans *= 2 * (n - d);

  cout << setprecision(10) << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ull unsigned long long 

int main(){
  int A,B,m;cin>>A>>B>>m;
  int cnt1=1000000;
  int cnt2=1000000;
  int ans=0;
  vector<int>a(A),b(B);
  for(int i=0;i<A;i++){
    cin>>a.at(i);
    cnt1=min(cnt1,a.at(i));
  }
    
  for(int i=0;i<B;i++){
    cin>>b.at(i);
    cnt2=min(cnt2,b.at(i));
  }
  ans=cnt1+cnt2;
  vector<int>x(m),y(m),c(m);
  for(int i=0;i<m;i++){
    int p;
    cin>>x.at(i)>>y.at(i)>>c.at(i);
    p=a.at(x.at(i)-1)+b.at(y.at(i)-1)-c.at(i);
    ans=min(ans,p);
  }
  cout<<ans;
}
  
  
  
    
               
  

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

int bubbleSort(int *a, int n);
void swapInt(int *a, int *b);

int main() {
	int n;
	int *a;
	int i,cnt;
	scanf("%d", &n);
	a = (int *)malloc(sizeof(int)*n);
	for (i = 0; i < n; i++) scanf("%d", &a[i]);

	cnt = bubbleSort(a, n);

	for (i = 0; i < n; i++) {
		printf("%d", *(a + i));
		if (i != n - 1)printf(" ");
	}
	printf("\n");
	printf("%d\n",cnt);
	return 0;
}

int bubbleSort(int *a, int n) {
	int i,flag=1;
	int swapCount = 0;
	while (flag) {
		flag = 0;
		for (i = n - 1; i >= 1; i--) {
			if (a[i] < a[i - 1]) {
				swapInt(&a[i], &a[i-1]);
				flag = 1;
				swapCount++;
			}
		}
	}
	return swapCount;
}

void swapInt(int *a, int *b) {
	int temp;
	temp = *a;
	*a = *b;
	*b = temp;
	return;
}

Measured memory_bytes: 604
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map
#include<cstring>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

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

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}
/*
ll Integer_factorization(ll n){
    ll num = 0;
    ll ndash = n;
    if(n == 1) return 1;
    ll a = 2;
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    return num;
}
*/

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

ll factrial(ll n){
    if(n == 0) return 1;
    ll p = factrial(n-1)*n%MOD;
    return p;
}

//MOD逆元
ll farmat(ll n,ll p){    
    if(p == 0) return 1;
    else if(p == 1) return n%MOD;
    ll d = farmat(n,p/2);
    if(p%2 == 0){
        return (d*d)%MOD;
    }else{
        return ((n*d)%MOD*d)%MOD;
    }
}

ll conbination(ll n,ll k){
    ll a = factrial(n);
    ll b = factrial(k);
    ll c = factrial(n-k);
    return (a*farmat(b,MOD-2)%MOD*farmat(c,MOD-2))%MOD;
}

int memo[10000000];

int fib(int i){
    if(i <= 1) return i;
    if(memo[i] != 0) return memo[i];
    return memo[i] = fib(i-1)+fib(i-2);
}

ll dig(ll n){
    ll d = 0;
    while(n != 0){
        n/=10;
        d++;
    }
    return d;
}

void solve() {
    int n;
    cin >> n;
    int a[n];
    int m = 0;
    int sum = 0;
    for(int i = 0;i < n;i++){
        cin >> a[i];
        m = max(m,a[i]);
        sum += a[i];
    }
    cout << sum-m/2 << endl;
    
}




int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}



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

int main() {
    long long A, B, K;
    cin >> A >> B >> K;
    if(A>=K){
	cout << A-K << " " << B << endl;
    }
    else{
	cout << 0 << " " ;
	if(B -(K-A) >=0)
	    cout << B -(K-A)<< endl;
	else
	    cout << 0 << endl;
    }
} 



Measured memory_bytes: 256
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double INF=1e+10;
const long double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		// if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ

int main(){
	int a,b;scanf("%d%d",&a,&b);
	int ret=0;
	while(a){
		ret++;
		a/=b;
	}
	printf("%d\n",ret);
}

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


int main() {
    vector<int> S(3);
    cin >> S.at(0) >> S.at(1) >> S.at(2);

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

    if(S.at(0) == 5 && S.at(1) == 5 && S.at(2) == 7){
        cout << "YES" << endl;
    }

    else{
        cout << "NO" << endl;
    }

    return 0;
}

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

int main(){

    // omajinai
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // omajinai

    ll l,r;
    cin >> l >> r;
    if(r-l > 2019){
        cout << 0 << endl;
        return 0;
    }

    ll m = 3000;
    for(ll i = l;i < r;i ++){
        for(ll j = i+1;j < r+1;j ++){
            m = min(m,(i * j) % 2019);
        }
    }

    cout << m << endl;
}

Measured memory_bytes: 256
N = int(input());

currentT = 0;
currentX = 0;
currentY = 0;
flag = True;

for i in range(N):
    t, x, y = map(int, input().split());

    timeDiff = t - currentT;
    xDiff = abs(x - currentX);
    yDiff = abs(y - currentY);

    currentT = t;
    currentX = x;
    currentY = y;

    leftMoveCount = timeDiff - (xDiff + yDiff);

    if leftMoveCount < 0:
        flag = False;
        break;
    elif leftMoveCount % 2 == 0:
        continue;
    else:
        flag = False;
        break;

if flag:
    print('Yes');
else:
    print('No');


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w
using namespace std;

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,a[100000],mi = INF;
	cin >> n;
	for(int i = 0;i < n;i++) cin >> a[i];
	int sum = max(1ll,a[0]),ans = sum - a[0];
	for(int i = 1;i < n;i++){
		if(sum > 0){
			sum += a[i];
			if(sum > -1) ans += sum + 1;
			sum = min(-1ll,sum);
		}else{
			sum += a[i];
			if(sum < 1) ans += 1 - sum;
			sum = max(1ll,sum);
		}
	}
	mi = min(mi,ans);
	sum = min(-1ll,a[0]),ans = a[0] - sum;
	for(int i = 1;i < n;i++){
		if(sum > 0){
			sum += a[i];
			if(sum > -1) ans += sum + 1;
			sum = min(-1ll,sum);
		}else{
			sum += a[i];
			if(sum < 1) ans += 1 - sum;
			sum = max(1ll,sum);
		}
	}
	mi = min(mi,ans);
	cout << mi << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#define N 30

int main(){

	int H[N],W[N];
	int i,j,k,l;
	
	for(i=0;i<N;i++){
	
		scanf("%d %d",&H[i],&W[i]);
	
		if((H[i]==0)&&(W[i]==0)){break;}
	
	}
	
	for(j=0;j<i;j++){
	
		if(H[j]==1){
			printf("#\n\n");
		}else if(i>1){
			for(k=0;k<W[j];k++){printf("#");};
			printf("\n");
			
			for(l=0;l<H[j]-2;l++){
				printf("#");
					for(k=0;k<W[j]-2;k++){printf(".");}
				printf("#\n");
				}
			
			for(k=0;k<W[j];k++){printf("#");}
			printf("\n\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 588
n, m = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
mod = 10 ** 9 + 7
xsum, ysum = 0, 0
for i in range(n):
    xsum += i * x[i] - (n - 1 - i) * x[i]
for i in range(m):
    ysum += i * y[i] - (m - 1 - i) * y[i]
ans = (xsum * ysum) % mod
print(ans)


Measured memory_bytes: 18576
#include <cstdio>
#include <vector>

int main() {
  int q;
  scanf("%d", &q);

  std::vector<int> a;
  for (int i=0; i<q; ++i) {
    int t;
    scanf("%d", &t);
    if (t == 0) {
      int x;
      scanf("%d", &x);
      a.push_back(x);
    } else if (t == 1) {
      int p;
      scanf("%d", &p);
      printf("%d\n", a[p]);
    } else {
      a.pop_back();
    }
  }
}



Measured memory_bytes: 3412
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		int n=ir.nextInt();
		out.println(n*800-(n/15)*200);
	}

	public static void main(String[] args) throws Exception {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}

Measured memory_bytes: 22996
#include "bits/stdc++.h"
using namespace std;
int main()
{
    int b = 0;
    for (int a; cin >> a; )
    {
        b++;
        if(a == 1)
        {
            b--;
            continue;
        }
        for (int i = 2; i <= sqrt(a); i++)
        {
            if(a % i == 0)
            {
                b--;
                break;
            }
        }
        
    }
    cout << b << endl;
}


Measured memory_bytes: 3112
#include<iostream>
#include<string>
#include<queue>
#include<map>
#include<string>
using namespace std;
const int dx[] = { 1, -1, 4, -4};
#define fr first
#define sc second
typedef pair < string , int > sPi;
string s;
int now;
map< string , int > used;
int bfs(){
  queue< sPi > que;
  que.push(sPi("01234567",0));
  used["01234567"] = 1;
  while(!que.empty()){
    sPi p = que.front();
    que.pop();
    for(int i = 0 ; i < 4 ; i++ ){
      string next = p.fr;
      if(0 <= p.sc+dx[i] && p.sc+dx[i] < 8 && !(p.sc==3&&!i) && !(p.sc==4&&i==1)){
        swap(next[p.sc],next[p.sc + dx[i]]);
        if(!used[next]){
          used[next] = used[p.fr] + 1;
          que.push(sPi(next,p.sc+dx[i]));
        }
      }
    }
  }
  return -1;
}
int main(){
  s.resize(8);
  bfs();
  while(cin >> s[0] >> s[1] >> s[2] >> s[3] >> s[4] >> s[5] >> s[6] >> s[7]){
    cout << used[s] - 1 << endl;
  }
}

Measured memory_bytes: 3452
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll
#define INF 1e16
#define mod 1000000007
int main(){
    ll n;
    cin>>n;
    ll ans = 0;
    ll dp[10][10] = {0};
    
    repl(i,1,n+1){
        string a = to_string(i);
        if(a[0]=='0' or a[a.size()-1]=='0') continue;
        dp[a[0]-'0'][a[a.size()-1]-'0'] += 1;
    }
    repl(i,1,10)repl(j,1,10) ans += dp[i][j] * dp[j][i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	string s;
	int ans = 0;
	cin >> s;
	for (auto ch : s) {
		if (ch == '1') ans++;
	}
	cout << ans << "\n";

	return 0;
}


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

int main(void){
  int n,x;
  cin >> n >> x;
  vector<int> m(n);
  int sum = 0,ans;
  for(int i = 0; i != n; i++){
    cin >> m[i];
    sum += m[i];
  }
  int minimum = *min_element(m.begin(),m.end());
  ans += n;
  x -= sum;
  while(x >= minimum){
    ans++;
    x -= minimum;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let mut s = read::<String>();
  let mut ans = String::from("");

  for i in s.chars() {
    if i == ',' {
      ans.push_str(" ")
    } else {
      ans.push_str(&i.to_string())
    }
  }

  println!("{}", ans);
}



Measured memory_bytes: 4352
N,M,C = map(int,input().split())
B_list = list(map(int,input().split()))
counter = 0

for i in range(N):
    SUM = C
    A_list = list(map(int,input().split()))
    for j in range(M):
        SUM += A_list[j] * B_list[j]
    if SUM > 0:
      counter += 1

print(counter)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout<<" "<<kbrni;cout<<endl
#define smap(m) cout<<#m<<":";each(kbrni,m)cout<<" {"<<kbrni.first<<":"<<kbrni.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef vector<P> vp;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    vector<vector<char> > red(h,vector<char>(w,'.')),blue(h,vector<char>(w,'.'));
    rep(i,h){
        if(i % 2 == 0){
            rep(j,w-1){
                red[i][j] = '#';
            }
            blue[i][w-1] = '#';
        }else{
            rep(j,w-1){
                blue[i][j+1] = '#';
            }
            red[i][0] = '#';
        }
    }
    rep(i,h){
        string s;
        cin >> s;
        if(i % 2 == 0){
            rep(j,w){
                if(s[j] == '#'){
                    blue[i][j] = '#';
                }
            }
        }else{
            rep(j,w){
                if(s[j] == '#'){
                    red[i][j] = '#';
                }
            }
        }
    }
    rep(i,h){
        rep(j,w){
            cout << red[i][j];
        }
        cout << endl;
    }
    cout << endl;
    rep(i,h){
        rep(j,w){
            cout << blue[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int i =0;
int[][] a = new int[300][2];
while (true) {
int H = sc.nextInt();
int W = sc.nextInt();
if (H == 0 && W == 0) {
break; }
a[i][0]=H;
a[i++][1]=W;
}
for (int k=0;k<i;k++){
	for (int l=0;l<a[k][0];l++){
	for (int j=0;j<a[k][1];j++){
		System.out.print("#");
} System.out.print("\n");}
System.out.print("\n");
	}

}
 }



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

void printrec(int h, int w){
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      putchar('#');
    }
    putchar('\n');
  }
}

int main(){
  int h, w;
  vector<int> hv;
  vector<int> wv;
  while(true){
    cin >> h >> w;
    if(h==0 && w==0){
      break;
    }

    hv.push_back(h);
    wv.push_back(w);
  }

  for(int i=0; i<(int)hv.size(); i++){
    printrec(hv[i], wv[i]);
    putchar('\n');
  }

  return 0;
}



Measured memory_bytes: 3080
#include <iostream>
#include <climits>
#include <memory.h>
#include <random>
#include <ctime>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <deque>
#include <bitset>
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef long double LD;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
#ifdef LOCAL
    #define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
    #define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*++++++++++++++++++++++++++++++++++++coding area start+++++++++++++++++++++++++++++++++++++++++*/





/*-------------------------------------coding area end------------------------------------------*/
int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.precision(10); cout << fixed;
    #ifdef LOCAL
//        freopen("../test.txt", "r", stdin);
//        freopen("../output.txt", "w", stdout);
    #endif
/*++++++++++++++++++++++++++++++++++++coding area start+++++++++++++++++++++++++++++++++++++++++*/
    int n; cin >> n;
    int ret = INT_MAX;
    for (int i = 1; i < n; i++) {
        string a = to_string(i);
        string b = to_string(n-i);
        int cnt = 0;
        for (char c : a) {
            cnt += c - '0';
        }
        for (char c : b) {
            cnt += c - '0';
        }
        ret = min(ret, cnt);

    }
    cout << ret << endl;




/*-------------------------------------coding area end------------------------------------------*/

    #ifdef LOCAL
        cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
    #endif
    return 0;
}
/* author:  txingml */


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

void fnInput(int &riElmCnt, vector<int> &rviElm, int &riTrgCnt , vector<int> &rviTrg )
{
  cin >> riElmCnt;

  rviElm.resize(riElmCnt);
  for (int i = 0; i < riElmCnt; i++)
    cin >> rviElm[i];

  cin >> riTrgCnt;

  rviTrg.resize(riTrgCnt);
  for (int i = 0; i < riTrgCnt; i++)
    cin >> rviTrg[i];
}

int fnRcsSch(int iPos, int iTrg, const vector<int> &cnrviElm, vector<vector<int>> &rvviOK)
{
  if (!iTrg)                    return 1;
  if (iTrg < 0)                 return 0;
  if (iPos == cnrviElm.size())  return 0;
  if (rvviOK[iPos][iTrg] != -1) return rvviOK[iPos][iTrg];

  int iRtn;
  iRtn = fnRcsSch(iPos + 1, iTrg, cnrviElm, rvviOK);
  rvviOK[iPos + 1][iTrg] = iRtn;
  if (iRtn)  return iRtn;

  iRtn = fnRcsSch(iPos + 1, iTrg - cnrviElm[iPos], cnrviElm, rvviOK);
  if (iTrg - cnrviElm[iPos] >= 0)
    rvviOK[iPos + 1][iTrg - cnrviElm[iPos]] = iRtn;
  return iRtn;
}

void fnExhSch(const vector<int> &cnrviElm, const vector<int> &cnrviTrg)
{
  vector<vector<int>> vviOK(21, vector<int>(2001, -1));
  
  for (int i = 0; i < cnrviTrg.size(); i++)
  {
    int iTrg = cnrviTrg[i];
    int iRtn;

    if (iRtn = fnRcsSch(0, iTrg, cnrviElm, vviOK))
      cout << "yes" << endl;
    else
      cout << "no" << endl;

    vviOK[0][iTrg] = iRtn;
  }
}

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

  int iElmCnt, iTrgCnt;
  vector<int> viElm, viTrg;

  fnInput(iElmCnt, viElm, iTrgCnt, viTrg);
  fnExhSch(viElm, viTrg);

  return 0;
}

Measured memory_bytes: 1340
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x, i, j) cerr << #x << "------------" << "\n";cerr << "from " << i << " to " << j << "\n";for(ll k=i; k<=j; k++) cerr << x[k] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;
 
const ll mod = 1e9 + 7;
const ll inf = 1e11 + 5;
const int MaxN = 2e5 + 5;

int noOfDigits(int n){
	int ans = 0;
	while(n){
		ans++;
		n /= 10;
	}
	return ans;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;
	int cnt = 0;
	for(int i = 1; i <= n; i++){
		if(noOfDigits(i) % 2 == 1){
			cnt++;
		}
	}
	cout << cnt << endl;
}		


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n){
        cin>>a[i];
    }    
    sort(a,a+n);
    cout<<a[n-1]-a[0]<<endl;
    return 0;
}


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

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<vector<bool>> v(h, vector<bool>(w, false));
  rep (i, h) {
    rep (j, w) {
      char c;
      cin >> c;
      v[i][j] = c == '#';
    }
  }
  int ans = 0;
  rep (i, 1<<h) {
    rep (j, 1<<w) {
      int cnt = 0;
      rep(l, h) {
        if ((i>>l)&1) continue;
        rep (m, w) {
          if ((j>>m)&1) continue;
          if (v[l][m]) cnt++;
        }
      }
      if (cnt == k) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  ll n, a, b;
  cin >> n; cin >> a; cin >> b;
  ll ans = n/(a+b) * a;
  ll rem = n%(a+b);
  ans += min(a, rem);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
//Breadth First Search
#include <iostream>
#include <queue>

using namespace std;

static const int N = 100;

int n, M[N][N];
int d[N];
queue<int> Q;

void bfs() {
    int u;
    for(int i = 0; i < N; i++) d[i] = -1;
    Q.push(0);
    d[0] = 0;
    while(!Q.empty()) {
        u = Q.front();
        for(int i = 0; i < n; i++) {
            if(M[u][i] == 1 && d[i] == -1) {
                Q.push(i);
                d[i] = d[u] + 1;
            }
        }
        Q.pop();
    }
    for(int i = 0; i < n; i++) {
        cout << i + 1 << " " << d[i] << endl;
    }
}

int main() {
    int u, k, v;
    cin >> n;
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) M[i][j] = 0;
    }

    for(int i = 0; i < n; i++) {
        cin >> u >> k;
        for(int j = 0; j < k; j++) {
            cin >> v;
            M[u - 1][v - 1] = 1;
        }
    }

    bfs();
}


Measured memory_bytes: 3128