akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  int c=0,i=3,T;

  while(i){
    T=0;
    cin >> T;
    c += T;
    --i;
  }
  cout << (c==17?"YES":"NO") << endl;

  return 0;
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

from  collections import defaultdict
from collections import Counter
import bisect
def main():
    N, K = MI()
    A = LI()
    A.sort()
    def is_ok(arg):
        # 条件を満たすかどうか？問題ごとに定義、argを求めたい値にして条件をreturnで返す
        cnt = 0
        for a in A:
            if a == 0:
                if arg >= 0:
                    cnt += N - 1
                else:
                    cnt += 0
            elif a < 0:
                aa = -((-arg) // a)
                cnt += N - bisect.bisect_left(A, aa)
                if aa <= a:
                    cnt -= 1
            else:
                aa = arg // a
                cnt += bisect.bisect_right(A, aa)
                if aa >= a:
                    cnt -= 1
        cnt //= 2
        return cnt >= K

    def meguru_bisect(ng, ok):
        '''
        初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
        まずis_okを定義すべし
        ng ok は  とり得る最小の値-1 とり得る最大の値+1
        最大最小が逆の場合はよしなにひっくり返す
        '''
        while (abs(ok - ng) > 1):
            mid = (ok + ng) // 2
            if is_ok(mid):
                ok = mid
            else:
                ng = mid
        return ok
    cnt_neg = bisect.bisect_left(A, 0)
    cnt_pos = N - bisect.bisect_right(A, 0)
    cnt_zer = N - cnt_pos - cnt_neg

    if K <= cnt_neg * cnt_pos:
        ng = - 10 ** 18 - 10
        ok = 1
        ans = meguru_bisect(ng, ok)
        print(ans)
    elif K <= cnt_neg * cnt_pos + cnt_zer * (N - 1) - cnt_zer * (cnt_zer - 1) // 2:
        print(0)
    else:
        ng = -1
        ok = 10 ** 18 + 10
        ans = meguru_bisect(ng, ok)
        print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 101560
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a,b = Is()
if b >= a:
    print(a)
else:
    print(a-1)

Measured memory_bytes: 3444
from collections import deque

H, W = map(int, input().split())

# input black cells
black_cells = []

for h in range(H):
    line = list(input())
    for w in range(W):
        if line[w] == "#":
            black_cells.append(h * W + w)


# Graph
def r(p):
    q_list = []
    h = p // W
    w = p % W
    if h != 0:
        q_list.append(p - W)
    if h != H-1:
        q_list.append(p + W)
    if w != 0:
        q_list.append(p - 1)
    if w != W-1:
        q_list.append(p + 1)
    return q_list


queue = deque(black_cells)
d = [10000] * (H * W)
for i in black_cells:
    d[i] = 0

# dijkstra
while len(queue) > 0:
    p = queue.popleft()
    for q in r(p):
        if d[q] > d[p] + 1:
            d[q] = d[p] + 1
            queue.append(q)

print(max(d))



Measured memory_bytes: 118828
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans=0
for  i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i*500+j*100+k*50==x:
                ans+=1
print(ans)

Measured memory_bytes: 9084
#include<bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
using namespace std;
inline int read(){
	int v=0,f=1;
	char c=getchar();
	while (c<'0' || c>'9'){
		if (c=='-') f=-1;
		c=getchar();
	}
	while (c>='0' && c<='9'){
		v=v*10+c-'0';
		c=getchar();
	}
	return v*f;
}
const int Maxn=1000005;
int n,a[Maxn],b[Maxn];
char s[Maxn];
int main(){
	n=read();
	scanf("%s",s);
	for (int i=1;i<=n;i++) a[i]=s[i-1]-'0';
	for (int i=0;i<n-1;i++) b[i]=abs(a[i+1]-a[i+2]);
	int ans=0,X=n-2;
	for (int i=0;i<n-1;i++){
		int f=1;
		for (int j=0;j<20;j++){
			if (i>>j&1){
				if (!(X>>j&1)){
					f=0;
				}
			}
		}
		if (f) ans^=(b[i]&1);
	}
	if (ans==1){
		printf("1\n");return 0;
	} 
	for (int i=0;i<n-1;i++){
		if (b[i]==1){
			printf("0\n");
			return 0;
		}
	}
	ans=0;
	for (int i=0;i<n-1;i++){
		int f=1;
		for (int j=0;j<20;j++){
			if (i>>j&1){
				if (!(X>>j&1)){
					f=0;
				}
			}
		}
		if (f)ans^=b[i];
	}
	printf("%d\n",ans);
	return 0;
}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
bool check = 0;
int N = 0;
vector<int> v(N);
int a, b;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  cin >> a >> b;
 pr((a-1)*(b-1));
  return 0;
}

Measured memory_bytes: 3592
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long N = scan.nextLong();
        long[] capacity = new long[5];
        for (int i = 0; i < 5; i++) {
            capacity[i] = scan.nextLong();
        }
        Arrays.sort(capacity);
        long answer = N % capacity[0] == 0 ? N / capacity[0] + 4 : N / capacity[0] + 5;
        System.out.println(answer);
    }
}


Measured memory_bytes: 22612
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



int n, a, b, t, r;

signed main() {
	cin >> n >> a >> b;
	rep(i,n) {
		cin >> t;
		if (t<a || b<=t) r++;
	}
	cout << r << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
bool aaa[11111111];
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}


int main() {
  int a;
  ll ans=0,n,k,x,y,m,memo=1,sx=1,sy=1,gx,gy;
  string ka,ss;
  map<string,int>mp;
  cin>>ka;
  n=ka.size();
  k=ll((n-1)/2);
  bool foo=true;
  rep(i,k){
    if(!((ka[i]==ka[n-i-1])&&(ka[k-i-1]==ka[i])))foo=false;
  }
  if(foo)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  
  //cout<<dp[x-1][y-1]<<endl;

  //vector<vector<bool>> sinsetsu(15,vector<bool>(14)),usotsuki(15,vector<bool>(14));
  //vector<vector<int>> sss(15,vector<int>(14))
  //vector<vector<int>> sss(h,vector<int>(w));
  //vector<int> a(k),b(k);
  //char x;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
#include<algorithm>
#include<cmath>
#include<set>
#include<vector>
#define mod 1000000007
#define int long long int
void subset(int arr[],vector<int> &v,int initial,int final,int mat[15][15],int n,int m,int x)
{
	if(initial>final)
	{
		int count[m+1]={0};
		int here=0;
		int j;
		if(v.size()!=0)
		{
			for(int p:v)
			{
				here+=arr[p];
				for(j=1;j<=m;j++)
				{
					count[j]+=mat[p][j];
				}
				
			}
		}
		bool result=true;
		for(j=1;j<=m;j++)
		{
			if(count[j]<x)
			{
				result=false;
				break;
			}
		}
		if(result)
		{
			//answer=min(answer,here);
		}
	}
	else
	{
		v.push_back(initial);
		subset(arr,v,initial+1,final,mat,n,m,x);
		v.pop_back();
		subset(arr,v,initial+1,final,mat,n,m,x);
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string str1,str2;
	cin>>str1>>str2;
	int n=str1.size();
	int j;
	for(j=0;j<n;j++)
	{
		if(str1[j]!=str2[j])
		{
			cout<<"No"<<endl;
			exit(0);
		}
	}
	cout<<"Yes"<<endl;
}


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

int main() {
  int a,i,j=0,k=0,l=0,m=0,n=0;
  string arare;
  cin >> a;
  for(i=0;i<a;i++){
    cin >> arare;
    if(arare == "P"){
      j =1;
    }
    if(arare == "W"){
      k =1;
    }
    if(arare == "G"){
      l=1;
    }
    if(arare == "Y"){
      m=1;
    }
    n =j+k+l+m;
  }
  if(n==3){
    cout << "Three" << endl;
  }else{
    cout << "Four" << endl;
  }
}
      

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>

// MARK: - header
namespace {
using namespace std;
using ll = long long;
using ull = unsigned long long;
template<ull MOD>
struct Mod {
    ull v = 0;
    Mod() {};
    Mod(ull val) : v(val) {}
    operator ull() const {return v;}
    ull operator=(ll x) {return v = x % MOD;}
    ull operator+=(ll x) {return operator=(v + x);}
    ull operator*=(ll x) {return operator=(v * x);}
};
}

// MARK: - answer

ll X,Y,Z,K;
vector<ll> A,B,C;

void input() {
    cin >> X >> Y >> Z >> K;
    A.resize(X);
    for (auto &a : A)
        cin >> a;
    B.resize(Y);
    for (auto &a : B)
        cin >> a;
    C.resize(Z);
    for (auto &a : C)
        cin >> a;
}

void solve() {
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    vector<ll> da(X), db(Y), dc(Z);
    for (ll i = 0; i < X-1; i++)
        da[i] = A[i+1]-A[i];
    for (ll i = 0; i < Y-1; i++)
        db[i] = B[i+1]-B[i];
    for (ll i = 0; i < Z-1; i++)
        dc[i] = C[i+1]-C[i];
    
    vector<vector<vector<bool>>> mat(X, vector<vector<bool>>(Y, vector<bool>(Z, false)));
    ll max = A.back() + B.back() + C.back();
    struct Elem {
        ll x, y, z, s;
        operator ll() const {return s;}
    };
    priority_queue<Elem> queue;
    queue.push({X-1,Y-1,Z-1,max});
    mat[X-1][Y-1][Z-1] = true;
    while (K-- > 0) {
        auto q = queue.top(); queue.pop();
        cerr << q.x << q.y << q.z << endl;
        cout << q.s << endl;
        
        if (q.x > 0 and !mat[q.x-1][q.y][q.z]) {
            mat[q.x-1][q.y][q.z] = true;
            queue.push({q.x-1, q.y, q.z, q.s - da[q.x-1]});
        }
        if (q.y > 0 and !mat[q.x][q.y-1][q.z]) {
            mat[q.x][q.y-1][q.z] = true;
            queue.push({q.x, q.y-1, q.z, q.s - db[q.y-1]});
        }
        if (q.z > 0 and !mat[q.x][q.y][q.z-1]) {
            mat[q.x][q.y][q.z-1] = true;
            queue.push({q.x, q.y, q.z-1, q.s - dc[q.z-1]});
        }
    }
}

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



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

#import
#import math
#import numpy as np
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

dp = [10 ** 10] * (10 ** 5 + 1)
dp[0] = 0

for w, v in wv:
    for i in range(10 ** 5, 0, -1):
        if i - v < 0:
            break

        dp[i] = min(dp[i], dp[i - v] + w)

for i in range(10 ** 5, 0, -1):
    if dp[i] <= W:
        print(i)
        exit()



Measured memory_bytes: 68644
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
typedef long long ll;
using namespace std;
int main()
{
  vector<long int> A(3);
  cin >> A[0] >> A[1] >> A[2];
  long ans = 0;
  while (1)
  {
    if ((A[0] == 1) && (A[1] == 1) && (A[2] == 1))
    {
      cout << ans << endl;
      return 0;
    }
    if ((A[0] == A[1]) && (A[0] == A[2]))
    {
      cout << -1 << endl;
      return 0;
    }
    if ((A[0] % 2 != 0) || (A[1] % 2 != 0) || (A[2] % 2 != 0))
    {
      cout << ans << endl;
      return 0;
    }
    long int tmpA = A[0];
    long int tmpB = A[1];
    A[0] = (A[1] + A[2]) / 2;
    A[1] = (tmpA + A[2]) / 2;
    A[2] = (tmpA + tmpB) / 2;
    ans++;
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for (int i=(b-1);i>=a;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb(x) (x&-(x))
const int N = 101010;
int n;
int a,b,v,w,t;
long long sum=0;
int main (){
	cin>>a>>v>>b>>w>>t;
	int dis=abs(a-b);
	int subv=abs(v-w);
//	de(dis);
//	de(subv);
	//dis%subv==0 &&
	if( (v-w) > 0 && (dis*1./subv <=t) )
	{
		cout<<"YES"<<endl;
		return 0;
	} 
	cout<<"NO"<<endl;
	return 0;
} 

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef stack<int> SI;
typedef queue<int> QI;
typedef pair<int,int> PII;
typedef long long LL;

#define d(x)  cout<<#x<<" = "<<(x)<<endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).rbegin()) i=(c).rbegin(); i!=(c).rend(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
#define INF 2000000000

const double EPS = 1e-10;
const double PI  = acos(-1.0);
////////////////////////////////////////////////
int a[100][100],n,s,judge,cost;
int t[100];
int main()
{
	cin>>n;
	REP(i,n)
	{
		REP(j,n)
		{
			cin>>a[i][j];
			if(a[i][j]==-1)a[i][j]=INF;
		}
	}
	t[0]=1;
	for(;;)
	{
		int mincost=INF;
		REP(u,n)
		{
			REP(v,n)
			{
				if(t[u]==1&&t[v]==0)
				{
					if(mincost>a[u][v])
					{
						mincost=a[u][v];
						s=v;
					}
				}
			}
		}
		cost+=mincost;
		t[s]=1;
		judge=1;
		REP(i,n)judge&=t[i];
		if(judge==1)break;
	}
	cout<<cost<<endl;
	return 0;
}

Measured memory_bytes: 3104
class Dice:
    def __init__(self):
        self.dice=[i for i in range(6)]
        self.workspace=[i for i in range(6)]
        self.top=self.dice=[0]
    
    def set(self,numbers):
        self.dice=[i for i in numbers]
        self.workspace=[i for i in numbers]
        
    def rotate(self,command):
        if command == "W":
            self.workspace=[self.dice[2], self.dice[1], self.dice[5], self.dice[0], self.dice[4], self.dice[3]]
            self.dice=self.workspace
        elif command == "E":
            self.workspace=[self.dice[3], self.dice[1], self.dice[0], self.dice[5], self.dice[4], self.dice[2]]
            self.dice = self.workspace
        
        if command == "S":
            self.workspace=[self.dice[4], self.dice[0], self.dice[2], self.dice[3], self.dice[5], self.dice[1]]
            self.dice=self.workspace
        elif command == "N":
            self.workspace=[self.dice[1], self.dice[5], self.dice[2], self.dice[3], self.dice[0], self.dice[4]]
            self.dice=self.workspace
            
    def get_top(self):
        self.top=self.dice[0]
        print(self.top)
        
    def debug(self,numbers):
        print(numbers)
    
        
numbers=list(map(int,input().split()))
dice=Dice()
dice.set(numbers)
commands=input()
for i in range(len(commands)):
      dice.rotate(commands[i])
dice.get_top()


Measured memory_bytes: 5616
#include <stdio.h>

int main() {

  int w,b,p;
  int me[3][3],kara;
  int i,j,k;
  int flag = 10;
  int sum =0;

  while(1) {
    flag = 10;
    for(j=0;j<3;j++) {
      for(i=0;i<3;i++) {
	scanf("%c",&kara);
	if(kara == '0') {
	  flag = -1;
	  break;
	}
	if(kara == '+') me[i][j] = 10;
	else if(kara == 'b') me[i][j] = 1;
	else me[i][j] = 0;
	//printf("me[%d][%d] == %d\n",i,j,me[i][j]);
      }

      if(flag == -1) break;
      scanf("%c",&kara);
    }


    if(flag == -1) break;


  
    for(j=0;j<3;j++) {
      sum = 0;
      for(i=0;i<3;i++) {
	sum += me[j][i];
      }
      //  printf("sum = %d\n",sum);
      if(sum == 3) {
	flag = 3;
	break;
      } else if(sum == 0) {
	flag = 0;
	break;
      }
    }


    for(j=0;j<3;j++) {

      if(flag != 10) break;
      sum = 0;
      for(i=0;i<3;i++) {
	sum += me[i][j];
      }
      if(sum == 3) {
	flag = 3;
	break;
      } else if(sum == 0) {
	flag = 0;
	break;
      }
    }


    if(flag == 10) {
      sum = 0;
      sum = me[0][0] + me[1][1] + me[2][2];
      //printf("%d %d %d = %d\n",me[0][0],me[1][1],me[2][2],sum); 
      if(sum == 0) flag = 0;
      else if(sum == 3) flag = 3;
    }

   


    if(flag ==10) {
      sum = 0;
      sum = me[2][0] + me[1][1] + me[0][2];
      if(sum == 0) flag = 0;
      else if(sum == 3) flag = 3;
    }

    //  printf("flag = %d\n",flag);
  
    if(flag == 3) printf("b\n");
    else if(flag == 0) printf("w\n");
    else printf("NA\n");

  }
  return 0;

     
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
#define mod 1000000007
#define mod1 998244353
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int li;
typedef unsigned long long int ull;
using namespace std;
bool sortbysec(const pair<li,li>&a,const pair<li,li>&b)
{
    return (a.second<b.second);
}
void bfs(vector<li>v[],li visit[],li s,li dist[])
{
  int i;
  deque<li>q;
  visit[s]=1;
q.push_back(s);
  while(!q.empty())
  {
    int x=q.front();
    q.pop_front();
    for(auto i=v[x].begin();i!=v[x].end();i++)
    {
      if(!visit[*i])
      {q.push_back(*i);
        visit[*i]=1;
        dist[*i]=dist[x]+1;
      }
    }
  }
}
int main()
{
fast_io
li n,x,y,i,j;
cin>>n>>x>>y;
map<li,li>m;
vector<li>v[n];
for(i=0;i<n-1;i++)
{
  v[i].push_back(i+1);
  v[i+1].push_back(i);
}
v[x-1].push_back(y-1);
v[y-1].push_back(x-1);
for(i=0;i<n;i++)
{
  li visit[n];
  memset(visit,0,sizeof(visit));
  li dist[n];
  dist[i]=0;
  bfs(v,visit,i,dist);
  for(j=0;j<n&&j!=i;j++)
  m[dist[j]]++;
}
for(i=1;i<n;i++)
{
  cout<<m[i]<<endl;
}
return 0;
}


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

int main() {
  int n, x;
  while(true) {
    scanf("%d %d", &n, &x);
    if(n == 0 && x == 0) break;
    int ans = 0;
    for(int i = 1; i <= n - 2; i++) {
      for(int j = i + 1; j <= n - 1; j++) {
        int maxnum = x - (i + j);
        if(j < maxnum && maxnum <= n) ans++;
      }
    }
    printf("%d\n", ans);
  }
}


Measured memory_bytes: 3220
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>

using namespace std;

const int INF=0x3f3f3f3f;
const int N=2333;

int n,k,q;

int a[N],id[N];

bool cmp(int x,int y)
{
	return a[x]<a[y];
}

int lst[N],ed;

bool bd[N];

void solve(int l,int r)
{
	static int tmp[N];
	for(int i=l;i<=r;++i)
		tmp[i]=a[i];
	nth_element(tmp+l,tmp+r-k+1,tmp+r+1);
	for(int i=l;i<=r-k+1;++i)
		lst[++ed]=tmp[i];
}

int calc()
{
	ed=0;
	for(int i=1,l=1;i<=n+1;++i)if(bd[i])
	{
		if(l<=i-1)
			solve(l,i-1);
		l=i+1;
	}
	if(ed<q)
		return INF;
	nth_element(lst+1,lst+q,lst+ed+1);
	int mn=lst[1],mx=lst[1];
	for(int i=2;i<=q;++i)
	{
		mn=min(mn,lst[i]);
		mx=max(mx,lst[i]);
	}
	return mx-mn;
}

int main()
{
	scanf("%d%d%d",&n,&k,&q);
	for(int i=1;i<=n;++i)
		scanf("%d",a+i);
	for(int i=1;i<=n;++i)
		id[i]=i;
	sort(id+1,id+n+1,cmp);
	bd[n+1]=true;
	int ans=INF;
	for(int i=1;i<=n;++i)
	{
		ans=min(ans,calc());
		bd[id[i]]=true;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,n;
  cin>>h>>w>>n;
  vector<int64_t> c(10);
  c.at(0)=(int64_t)(h-2)*(w-2);
  set<vector<int>> f;
  vector<vector<int>> s={{-1,-1},{-1,0},{-1,1},{0,-1},{0,0},{0,1},{1,-1},{1,0},{1,1}};
  for(int i=0;i<n;i++){
    int a,b;
    cin>>a>>b;
    f.insert({a,b});
    for(auto p:s){
      int pa=a+p.at(0);
      int pb=b+p.at(1);
      if(pa-1>=1&&pa+1<=h&&pb-1>=1&&pb+1<=w){
        int x=0;
        for(auto g:s){
          int ga=pa+g.at(0);
          int gb=pb+g.at(1);
          if(f.count({ga,gb}))
            x++;
        }
        c.at(x-1)--;
        c.at(x)++;
      }
    }
  }
  for(int i=0;i<10;i++)
    cout<<c.at(i)<<endl;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/


signed main() {
	int n, a, b; cin >> n >> a >> b;
	cout << min(n * a, b) << endl;
}

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

int main(){
  int N, M;cin >> N >> M;
  int X[100000];
  int sum = 0;
  for(int i = 0;i < M;i++)
    cin >> X[i];
  sort(X, X + M);
  for(int i = 0;i < M - 1;i++)
    X[i] = X[i + 1] - X[i];
  sort(X, X + M - 1);
  for(int i = 0;i < M - N;i++)
    sum += X[i];
  cout << sum;
}


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

using namespace std;
typedef long long ll;

#define INF (long long)(10e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

int main(void)
{
    int n, a, b;
    cin >> n >> a >> b;
    cout << (((b - a)%2==0)?"Alice":"Borys") << endl; 
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

template<class Type>
Type solve(Type res = Type()){
    ll N,M; cin >> N >> M;
    vector<pii> AB(M);
    for(auto &in:AB){
        cin >> in.first >> in.second;
        in.first--;
        in.second--;
    }
    vector<ll> ans(M);
    UnionFind UF((int)N);
    vector<ll> cost(N);
    reverse(AB.begin(),AB.end());
    ans[0] = N*(N-1)/2;
    for(int i = 0; i < M-1;i++){
        int u,v; tie(u,v) = AB[i];
        if(UF.findSet(u,v)){
            ans[i+1] = ans[i];
        }else{
            ll ru = UF.root(u),rv = UF.root(v);
            ans[i+1] = ans[i] + cost[ru] + cost[rv];
            UF.unionSet(u,v);
            
            ll r = UF.root(u);
            ll sz = UF.size(r);
            cost[r] = sz*(sz-1)/2;
            ans[i+1] -= cost[r];
        }
    }
    reverse(ans.begin(),ans.end());
    for(auto a:ans){
        cout << a << endl;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    //cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


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

int main() {
  set<int> s;
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    s.insert(a);
  }
  cout << (s.size() == n ? "YES" : "NO") << endl;
}

Measured memory_bytes: 9600
from collections import defaultdict

M = 998244353
B = pow(10, 18, M)
N = int(input())

def ext_euc(a, b):
  x1, y1, z1 = 1, 0, a
  x2, y2, z2 = 0, 1, b
  while z1 != 1:
    d, m = divmod(z2,z1)
    x1, x2 = x2-d*x1, x1
    y1, y2 = y2-d*y1, y1
    z1, z2 = m, z1
  return x1, y1

def inv_mod(a, b, m):
  x, y = ext_euc(a, m)
  return (x * b % m)

def mex(s):
  for i in range(N+1):
    if i not in s:
      return i

def calc_grundy(e):
  g = {}
  for i in range(N, 0, -1):
    if i not in e:
      continue
    m = mex({g.get(j, 0) for j in e[i]})
    if m:
      g[i] = m
  sum_g = defaultdict(int)
  sum_g[0] = inv_mod(B-1, pow(B, N+1, M)-B, M)
  x = 1
  for i in range(1, N+1):
    x = (x * B) % M
    if i in g:
      j = g.pop(i)
      sum_g[j] = (sum_g[j] + x) % M
      sum_g[0]  = (sum_g[0] - x) % M
      if not g:
        break
  return sum_g

def read_edge():
  M = int(input())
  e = defaultdict(set)
  for i in range(M):
    a, b = sorted(map(int, input().split()))
    e[a].add(b)
  return e

def solve(N, edge):
  sum_g = list(map(calc_grundy, edge))
  ret = 0
  for gx, sx in sum_g[0].items():
    for gy, sy in sum_g[1].items():
      gz = gx^gy
      sz = sum_g[2][gz]
      if sz:
        ret += (sx*sy*sz) % M
  return ret%M


edge = [read_edge() for i in range(3)]

print(solve(N, edge))

Measured memory_bytes: 73456
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))
ans = [[0]*W for _ in range(H)]
h = 0
w = 0
for i, a in enumerate(A):
    for _ in range(a):
        if w == W:
            h += 1
            w = 0
        
        if h % 2 != 0:
            ind = W-w-1
        else:
            ind = w
        ans[h][ind] = i+1
        w += 1
for _ in range(H):
    print(*ans[_])


Measured memory_bytes: 9400
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <tgmath.h>
#define MOD 1000000007
using namespace std;

#define INT_MAX 2147000000
#define LONG_MAX 9223372036854775806

typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
ll N,x;
#define MAXN 100001
ll a[MAXN];
int main(){
    cin >> N >> x;
    //N = 100000,x = 0;
    rep(i,N){
        //a[i] = 1000000000;
        cin >> a[i];
    }
    ll ans = 0;
    if(a[0]>x){
        ans += (a[0]-x);
        a[0] -= ans;
    }
    rep(i,N-1){
        if(a[i]+a[i+1]>x){
            ll tmp;
            tmp = (a[i]+a[i+1])-x;
            ans += tmp;
            if(a[i+1]>=tmp)a[i+1] -= tmp;
            else{
                a[i+1] = 0;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#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 <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int W, H;
char board[510][510];
long double dp[510][510];

void calc(long double bin_v) {
    fill(dp[0], dp[H+1], INF);
    queue< tuple<int, int, long double> > que;
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            if(board[i][j] == 'g') {
                dp[i][j] = 0.0;
                que.emplace(i, j, dp[i][j]);
            }
            if(board[i][j] == '*') {
                dp[i][j] = bin_v;
                que.emplace(i, j, dp[i][j]);
            }
        }
    }

    while(que.size()) {
        int x, y; long double val;
        tie(x, y, val) = que.front(); que.pop();

        for(int k=0; k<4; k++) {
            int nx = x + dx[k], ny = y + dy[k];
            if(board[nx][ny] == '#') continue;
            if(board[nx][ny] == '*') continue;
            if(dp[nx][ny] > val + 1) {
                dp[nx][ny] = val + 1;
                que.emplace(nx, ny, val + 1);
            }
        }
    }
}


signed main() {
    cin >> W >> H;
    int sx, sy, gx, gy, cnt = 0;
    for(int i=0; i<H; i++) {
        for(int j=0; j<W; j++) {
            cin >> board[i][j];
            if(board[i][j] == 's') sx = i, sy = j;
            if(board[i][j] == 'g') gx = i, gy = j;

            if(board[i][j] == 's' or board[i][j] == '.') {
                cnt++;
            }
        }
    }

    // fprintf(stderr, "cnt = %lld\n", cnt);
    long double ub = INF, lb = 0;
    for(int r=0; r<200; r++) {
        long double x = (ub + lb) / 2.0;
        calc(x);
        
        long double E = 0.0;
        for(int i=0; i<H; i++) {
            for(int j=0; j<W; j++) {
                if(board[i][j] == '.' or board[i][j] == 's') {
                    E += dp[i][j];
                }
            }
        }
        E /= cnt;
        if(E < x) ub = x;
        else lb = x;
    }

    long double x = ub;
    calc(x);
    // fprintf(stderr, "x = %.12f\n", x);
    printf("%.12Lf\n", dp[sx][sy]);
    return 0;
}



Measured memory_bytes: 8328
y,m,d = map(int, input().split("/"))

if y < 2019:
    print ("Heisei")
    exit ()

if y == 2019:
    if m < 4:
        print ("Heisei")
        exit ()
    elif m == 4:
        if d <= 30:
            print ("Heisei")
            exit ()
    else:
        pass

print ("TBD")


Measured memory_bytes: 2940
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.*;

class Main {
	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		in.nextLine();
		for(int i=0;i<n;i++) {
			String s = in.nextLine();
			System.out.println(solve(s));
		}
	}
	public static String solve(String s) {
		List<String> keywords = new ArrayList<>();
		for(int a=0;;a++) {
			if(a % 2 == 0 || a % 13 == 0) continue;
			for (int b = 0; b <= 300; b++) {
				String str = "";
				for(int k=0;k<s.length();k++) {
					if(s.charAt(k) == ' ') {
						str += " "; continue;
					}
					str += F(s.charAt(k), a, b);
				}
				if(str.contains("that") || str.contains("this")) {
					return str;
				}
			}
		}
	}

	public static String F(char ch, int alpha, int beta) {
		int gamma = ch - 'a';
		return ""+((char)('a' + (alpha*gamma + beta) % 26));
	}
}

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

typedef long long LL;  
using namespace std;

#define fillchar(a, x) memset(a, x, sizeof(a))
#define MP make_pair
#define PB push_back
#define endl '\n'

const LL M = 1e18;
const int N = 2001;

LL kmin[N][N];

LL n;

int prev(int s) {if(s!=0) return s-1; return (n-1);}

int main()
{
ios_base::sync_with_stdio(0); 
cout.precision(15);
cout.setf(ios::fixed);

LL x;

cin>>n>>x;
int i,j;

for(i=0;i<n;i++) 
	cin>>kmin[i][0];

for(j=1;j<n;j++)
		for(i=0;i<n;i++)
		{
		
		kmin[i][j] = min(kmin[i][j-1],kmin[prev(i)][j-1]);	
		//if(j==2) cout<<kmin[i][j]<<endl;
		}

LL ans = M;

for(i=0;i<n;i++)
	{
	LL cur = x*i;	
	for(j=0;j<n;j++)
		cur = cur + kmin[j][i];
	ans = min(ans,cur);
	}

cout<<ans<<endl;

}


Measured memory_bytes: 31488
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	int n, m;
	cin >> n >> m;
	char a[51][51], b[51][51];
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cin >> a[i][j];
		}
	}
	for(int i = 0; i < m; i++){
		for(int j = 0; j < m; j++){
			cin >> b[i][j];
		}
	}
	for(int i = 0; i + m <= n; i++){
		for(int j = 0; j + m <= n; j++){
			bool include = true;
			for(int k = 0; k < m; k++){
				for(int l = 0; l < m; l++){
					if(a[i + k][j + l] != b[k][l]){
						include = false;
						k = m;
						break;
					}
				}
			}
			if(include){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
using namespace std;
int main(){
    priority_queue<int> Q;
    string op;
    while(true){
        cin >> op;
        if(op=="insert"){
            int val;
            cin >> val;
            Q.push(val);
        }else if(op=="extract"){
            int val;
            val=Q.top();Q.pop();
            cout << val << endl;
        }else if(op=="end"){
            break;
        }
    }
}


Measured memory_bytes: 7112
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>
#include <omp.h>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;
typedef pair<long long int, pll> lpll;

const long long int mod = 998244353;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 
const long long int pl=1000000;

long double N,M,D;

int main(){

    cout << fixed << setprecision(18);
    cin>>N>>M>>D;
    if(D==0){
        cout<<(long double)(M-1)/N<<endl;
    }else{
        cout<<(long double)(M-1)*(N+max(0.0L,(N-2*D)))/N/N<<endl;;
    }
}



Measured memory_bytes: 3640
#include<stdio.h>
int n,q;
int A[20];
int B[2001];

void solve(int i,int j){
	if(j>2000) return;
	B[j]=1;
	if(i==n) return;

	solve(i+1,j);
	solve(i+1,j+A[i]);
}	

int main(void){
	int i,key;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&A[i]);
	}
	solve(0,0);	

	scanf("%d",&q);
	for(i=0;i<q;i++){
		scanf("%d",&key);
		if(B[key]) printf("yes\n");
		else printf("no\n");
	}

	return 0;
}

Measured memory_bytes: 588
INF = float('inf')
n = int(input())
h = [int(i) for i in input().split()]
dp = [0, abs(h[1] - h[0])] + [INF] * (n - 2)
for i in range(2, n):
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
print(dp[n - 1])

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

int main(){
	long long N;
	cin >> N;
	string t = "";
	while(N != 0){
		t = (char)((N - 1) % 26 + 'a') + t;
		N--;
		N /= 26;
	}
	cout << t << endl;
}

Measured memory_bytes: 3628
import sys, cmath, math
t = complex(0)
a = math.pi/2
for line in sys.stdin:
    l = list(map(int, line.split(",")))
    if l == [0, 0]:
        break
    t += cmath.rect(l[0], a)
    a -= l[1]*math.pi/180
print(int(t.real))
print(int(t.imag))

Measured memory_bytes: 7968
N = int(input())
S = list(input())
dp = [[0]*(N) for _ in range(N)]
for i in range(N-1):
    if S[i] == S[N-1]:
        dp[i][N-1] = 1

for i in range(N-2, -1, -1):
    for j in range(N-1, -1, -1):
        if j < i:
            if S[j] == S[i]:
                dp[j][i] = min(dp[j+1][i+1] + 1, i-j)
            else:
                dp[j][i] = 0

ans = 0
for i in range(N):
    for j in range(N):
        ans = max(ans, dp[i][j])
print(ans)

Measured memory_bytes: 230664
a = int(input())
count = 0
ans = "No"
for i in range(a) :
  b = list(map(int,input().split()))
  if b[0] == b[1] :
    count = count + 1
  else :
    count = 0
  if count == 3 :
    ans = "Yes"

print(ans)

Measured memory_bytes: 9176
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

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

   if(a == b){cout << c << endl;}
   else if(b == c){cout << a << endl;}
   else if(c == a){cout << b << endl;}

   return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main(N):
    x = 0
    for a in range(1, N+1):
        for b in range(1, N//a+1):
            x += a*b
    return x

if sys.argv[-1] == 'ONLINE_JUDGE':
    import numba
    from numba.pycc import CC
    i8 = numba.int64
    cc = CC('my_module')

    def cc_export(f, signature):
        cc.export(f.__name__, signature)(f)
        return numba.njit(f)

    main = cc_export(main, (i8, ))
    cc.compile()

from my_module import main

N = int(read())
print(main(N))


Measured memory_bytes: 27468
import java.util.Scanner;
 
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String[] array = new String[999];
        int i = 0;
         
        while(sc.hasNext()){
            String num = sc.next();
                if(num.equals("0")){
                    i--;
                    System.out.println(array[i]);
                    array[i] = "";
                } else {
                    array[i] = num;
                    i++;
                }
        }
    }
}

Measured memory_bytes: 17156
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0382
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] nc = RArInt();
            int n = nc[0] + 1;
            int sum = RArInt().Sum();
            Console.WriteLine(sum % n == 0 ? sum / n : sum / n + 1);
        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



Measured memory_bytes: 18260
//author: Hayato Kawakita
// 2020/04/27 18:54
//vertict: 

#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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 (a>b) { a=b; return 1; } return 0; }

int n, m;
int h[1505], w[1505];

void solve() {
  map<int, int> mh, mw;
  rep(i, n) {
    int res = 0;
    FOR(j, i, n) {
      res += h[j];
      mh[res]++;
    }
  }
  rep(i, m) {
    int res = 0;
    FOR(j, i, m) {
      res += w[j];
      mw[res]++;
    }
  }
  ll ans = 0;
  for (auto it = mh.begin(); it != mh.end(); it++) {
    ans += it->second * mw[it->first];
  }
  cout << ans << '\n';
}

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

  while (1) {
    cin >> n >> m;
    if (n == 0 && m == 0) return 0;
    rep(i, n) cin >> h[i];
    rep(i, m) cin >> w[i];

    solve();
  }




  
  return 0;
}


Measured memory_bytes: 34452