akhauriyash/Code-Regression huggingface dataset:
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)


LL n;
LL a[101010];
LL b[101010];

struct BIT {
	LL bit[202020];
	void init() {
		REP(i, 202020)bit[i] = 0;
	}
	LL sum(int i) {
		LL s = 0;
		while (i > 0) {
			s += bit[i];
			i -= i& -i;
		}
		return s;
	}
	void add(int i, LL x) {
		while (i <= 202020) {
			bit[i] += x;
			i += i& -i;
		}
	}
};

LL calc(LL mid) {
	BIT bit;
	bit.init();
	REP(i, n)b[i] = (a[i] <= mid ? 1 : -1);

	LL ret = 0;
	LL tmp = n + 1;
	bit.add(tmp, 1);
	REP(j, n) {
		tmp += b[j];
		ret += bit.sum(tmp - 1);
		bit.add(tmp, 1);
	}
	return ret;
}

int main() {
	cin >> n;
	REP(i, n)cin >> a[i];
	LL l = 0, r = 1e9;
	LL num = (n*(n + 1) / 2) / 2;
	while (r - l > 1) {
		LL mid = (l + r) / 2;
		if (calc(mid) <= num)l = mid;
		else r = mid;
	}
	cout << r << endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) for(int i = 0; i < (n); i++)

/* exchange */
#define chmin(a, b) (a) = min((ll)(a), (ll)(b))
#define chmax(a, b) (a) = max((ll)(a), (ll)(b))

/* output */
#define I(x) cin >> x;
#define D(x) cerr << (x) << " ";
#define BR cerr << "\n";
#define P(x) cout << (x) << endl;
#define FIX cout << fixed << setprecision(10);

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll ret = 0;

int main(void){
  string S, T;
  I(S);
  I(T);
  bool ok = true;
  REP(i, S.size()) {
    if (S[i] != T[i]) ok = false;
  }

  P(ok?"Yes":"No");

}


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int mochi [] = new int [N];
		for(int m = 0; m<N; m++){
	        mochi[m]=scan.nextInt();
	    }

		//bubble sort
		int count = 0;
		for(int i =0; i<mochi.length-1; i++){
			for(int j = mochi.length-1; j>i; j--){
				if(mochi[j-1]>mochi[j]){
					int temp = mochi[j-1];
					mochi[j-1] = mochi[j];
					mochi[j] = temp;
					count++;
				}
			}

		}
		//System.out.println(Arrays.toString(mochi));

		int check = 0;
		for(int i = 0; i <mochi.length-1; i++){
			if(mochi[i]<mochi[i+1]){
				check++;
			}
		}
		System.out.println(check + 1);



	}

}


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

int main (){
	lint n,sum,high;
	sum = 0;
	cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	rep(i,n-1){
		high = a[i+1]-a[i];
		if (high<=0){
			a[i+1] += abs(high);
			sum += abs(high);
		}
	}
	
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 4024
n=int(input())
s=[list(input()) for _ in range(n)]
import numpy as np
ss=[si+si for si in s]
ss=np.array(ss+ss)
ans=0
for i in range(n):
    a=ss[i:i+n,:n]
    if np.array_equal(a,a.T):
      ans+=1
print(ans*n)

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

const int WIDTH = 21;
const int HEIGHT = 21;
const int INIT_X = 10;
const int INIT_Y = 10;

int main()
{
	int n;
	while (std::cin >> n, n != 0) {
		// ツフツィツーツδ仰ドツづーツ渉可甘コツ可サ (ツ可スツづ?づ按つ「ツ湘ウツ妥?
		std::vector< std::vector<bool> > f(HEIGHT, std::vector<bool>(WIDTH, false));

		// ツフツィツーツδ仰ドツづ可陛ウツ静篠づーツ配ツ置
		for (int i = 0; i < n; ++i) {
			int x, y;
			std::cin >> x >> y;
			f[y][x] = true;
		}

		// ツδ債ボツッツトツづーツ暗堋督ョツつウツつケツづゥ
		int robotX = INIT_X;
		int robotY = INIT_Y;
		int m;
		std::cin >> m;
		for (int i = 0; i < m; ++i) {
			char d;
			int l;
			std::cin >> d >> l;
			const int addX = (d == 'E') ? 1
				: (d == 'W') ? -1
				: 0;
			const int addY = (d == 'N') ? 1
				: (d == 'S') ? -1
				: 0;
			for (int i = 0; i < l; ++i) {
				f[robotY][robotX] = false;
				robotX += addX;
				robotY += addY;
			}
			f[robotY][robotX] = false;
		}

		// ツ陛ウツ静篠つェツ残ツづ?づ?つ「ツづ按つ「ツつゥツ陳イツづ猟づゥ
		bool exist = false;
		for (int y = 0; y < HEIGHT; ++y) {
			for (int x = 0; x < WIDTH; ++x) {
				if (f[y][x]) {
					exist = true;
				}
			}
		}

		// ツ出ツ療?
		std::cout << ((!exist) ? "Yes" : "No") << std::endl;
	}
	return 0;
}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline

def main():

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

    for i in range(10**N):
        num = str(i)
        if len(num) == N and all(num[s-1]==str(c) for s,c in Set):
            print(i)
            break
    else:
        print(-1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    int ret = 0;
    int high = 0;
    int len = 0;
    for (int i = 0; i < n; i++) {
        int h;
        cin >> h;
        if (high >= h) {
            high = h;
            len++;
        } else {
            ret = max(ret, len);
            high = h;
            len = 0;
        }
    }
    cout << max(ret, len) << endl;
    return 0;
}

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

struct Node {
  int key;
  Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int key) {
  Node *y = NIL;
  Node *x = root;
  Node *z = new Node();
  z->key = key;

  while (x != NIL) {
    y = x;
    if (z->key < x->key) {
      x = x->left;
    } else {
      x = x->right;
    }
  }
  z->parent = y;

  if (y == NIL) {
    root = z;
  } else if (z->key < y->key) {
    y->left = z;
  } else {
    y->right = z;
  }
}

void printPreorder(Node *node) {
  cout << " " << node->key;
  if (node->left != NIL) printPreorder(node->left);
  if (node->right != NIL) printPreorder(node->right);
}

void printInorder(Node *node) {
  if (node->left != NIL) printInorder(node->left);
  cout << " " << node->key;
  if (node->right != NIL) printInorder(node->right);
}

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

  int n;
  cin >> n;

  string command;
  int v;
  for (int i = 0; i < n; i++) {
    cin >> command;
    if (command == "insert") {
      cin >> v;
      insert(v);
    } else if (command  == "print") {
      printInorder(root);
      cout << endl;
      printPreorder(root);
      cout << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 26640
l=[0]*120
s="#"*20
for i in range(input()):b,f,r,v=map(int,raw_input().split());l[b*30+f*10+r-41]+=v
print"",
for i in range(1,121):
 print l[i-1],
 if i==120:break
 if i%30==0:print;print s,
 if i%10==0:print;print"",

Measured memory_bytes: 4216
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
const int mod=1000000007;
const int N=3000;
int n;
char a[N+5];
int dp[N+1][N+1];
int Sum[N+1];
int main(){
	cin>>n>>a+1;
	dp[1][1]=1;
	for(int i=2;i<=n;i++){
		for(int j=1;j<i;j++)Sum[j]=(Sum[j-1]+dp[i-1][j])%mod;
		for(int j=1;j<=i;j++)dp[i][j]=a[i-1]=='>'?Sum[j-1]:((Sum[i-1]-Sum[j-1])%mod+mod)%mod;
//		for(int j=1;j<=i;j++)cout<<dp[i][j]<<" ";puts("");
	}
	int ans=0;
	for(int i=1;i<=n;i++)(ans+=dp[n][i])%=mod;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 34176
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

char str[105];

int main(int argc, char* argv[])
{
    scanf("%s", str);
    int k;
    scanf("%d", &k);

    vector<int> a;
    int n=strlen(str);
    int i;
    int cnt=0;
    for(i=0; i<n; i++) {
        if(i>0 && str[i-1]==str[i]) {
            cnt++;
        }
        else {
            if(cnt>0) {
                a.push_back(cnt);
            }
            cnt=1;
        }
    }
    if(cnt>0) {
        a.push_back(cnt);
    }

    ll ans=0;
    int siz=(int)a.size();
    if(siz==1) {
        ans = n*(ll)k/2;
        printf("%lld\n", ans);
        return 0;
    }
    
    for(i=0; i<siz; i++) {
        if(str[0]==str[n-1]) {
            if(i==0 || i==siz-1) {
                ans += (a[i]/2);
                continue;
            }
        }
        ans += (a[i]/2)*(ll)k;
    }

    if(str[0]==str[n-1]) {
        int num=a[0]+a[siz-1];
        ans += (num/2)*(ll)(k-1);
    }
    printf("%lld\n", ans);

    return 0;
}






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

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
*/

using namespace std;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<vector<int> > vvi;
typedef vector<vector<ii> > vvii;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define ff first
#define ss second
#define trav(a, x) for(auto& a : x) 
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define PI 3.1415926535897932384626433832795
const ll INF = 1e18;
const int mod = 1e9 + 7;
const int N = 1e5;
ll gcd(ll a,ll b){if (a==0) return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return a*(b/gcd(a,b));}
ll Abs(ll a){if(a>0)return a;return -a;}
ll Ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
double Abs(double a){if(a>0)return a;return -a;}

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

/*
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;
*/

inline int pow_(ll x, ll y,ll p){
  int r = 1; while(y){if(y & 1) r = r * x % p; y >>= 1; x = x * x % p;} return r;
}
inline int inv_(int x){return pow_(x, mod - 2, mod);}
inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int mul(int a, int b){return a * 1LL * b % mod;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}

int Arr[100005] = {0};
int size[100005] = {0};

int root(int i)
{
    while(Arr[i]!=i)
    {
        Arr[i] = Arr[Arr[i]];
        i = Arr[i];
    }

    return i;
}

int find(int i,int j)
{
    if(root(i)==root(j))return 1;
    else return 0;
}

void union_(int i,int j)
{
    int root_i = root(i);
    int root_j = root(j);

    if(size[root_i] > size[root_j])
    {
        Arr[root_j] = Arr[root_i];
        size[root_i] += size[root_j];
    }
    else
    {
        Arr[root_i] = Arr[root_j];
        size[root_j] += size[root_i]; 
    }
}


int main()
{
    #ifdef LOCAL_TEST
    freopen("in.txt","r",stdin);
    //freopen("out.txt", "w", stdout);
    #else
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    #endif

    ll n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        Arr[i] = i;
        size[i] = 1;
    }
    vector<ii> edges;
    for(int i=1;i<=m;i++)
    {
        ll x,y;
        cin>>x>>y;
        edges.pb(mp(x,y));
    }

    ll ans[100005] = {0};
    for(int i=1;i<=m;i++)ans[i]=n*(n-1)/2;
    for(int i=m-1;i>=0;i--)
    {
        ll x = edges[i].first;
        ll y = edges[i].second;
        if(root(x)!=root(y))
        {
            ll s1 = size[root(x)];
            ll s2 = size[root(y)];

            ans[i] = ans[i+1] - s1*s2;

            union_(x,y);
        }
        else
        {
            ans[i] = ans[i+1];
        }
    }

    for(int i=1;i<=m;i++)
    {
        cout<<ans[i]<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3828
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        n: usize,
        m: usize,
        ps: [(usize1, String);m]
    }
    let mut a = vec![false;n];
    let mut w = vec![0;n];
    for (p,s) in ps {
        if s == "AC" {
            a[p] = true;
        } else if !a[p] {
            w[p] += 1;
        }
    }
    let ac = a.iter().filter(|o| **o).count();
    let wa = w.iter().zip(a.iter()).filter(|t| *t.1)
              .map(|t| { t.0 }).sum::<u64>();
    println!("{} {}", ac, wa);
}
/* vim:set foldmethod=marker: */


Measured memory_bytes: 10492
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, C;
    cin >> A >> B >> C;
    ll ans = 1;
    C--;
    if (C <= A + B) {
        ans += B + C;
    } else {
        ans += 2 * B + A;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <queue>
#include <cstdio>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string.h>
#include <limits.h>
#include <map>
#include <string>
#include <bitset>
#include <vector>
using namespace std;
int main() {
    int a,b;
    cin>>a>>b;
    if(a<=b) printf("unsafe\n");
    else printf("safe\n");
    return 0;
}


Measured memory_bytes: 3648
day = input()

if day == "SUN":
    print("7")
elif day == "MON":
    print("6")
elif day == "TUE":
    print("5")
elif day == "WED":
    print("4")
elif day == "THU":
    print("3")
elif day == "FRI":
    print("2")
else:
    print("1")

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if ((b * 10 + c) % 4 == 0) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,a[3],MAX=0;
  cin >> n;
  for(int i=0;i<n;i++){
    cin >> a[i];
    MAX = max(MAX,a[i]);
  }
  for(int i=1;i<=MAX;i++){
    bool dotti=true;
    for(int j=0;j<n;j++){
      if(a[j] % i != 0) dotti = false;
    }
    if(dotti == true) cout << i << endl;
  }
}



Measured memory_bytes: 3088
n = int(input())
s = input()


def check(t):
    t = t[-1] + t + t[0]
    for i in range(1, n + 1):
        if s[i - 1] != ('o' if (t[i] == 'S') ^ (t[i - 1] != t[i + 1]) else 'x'):
            return
    print(t[1:n+1])
    import sys
    sys.exit()


def getans(ans):
    ans = list(ans)
    for i in range(1, n):
        ans[i + 1] = 'S' if (ans[i] == 'S') ^ (s[i] == 'o') ^ (ans[i - 1] == 'S') else 'W'
    check("".join(ans)[:-1])


getans('WW' + '.' * (n - 1))
getans('WS' + '.' * (n - 1))
getans('SW' + '.' * (n - 1))
getans('SS' + '.' * (n - 1))

print(-1)


Measured memory_bytes: 4468
package main

import (
	"fmt"
)

func main() {
	var N int
	fmt.Scan(&N)
	answer := 0
	V := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scan(&V[i])
	}
	for i := 0; i < N; i++ {
		var Ci int
		fmt.Scan(&Ci)
		if Ci < V[i] {
			answer += V[i] - Ci
		}
	}
	fmt.Println(answer)
}


Measured memory_bytes: 512
import java.util.*;
import java.math.*;
     
class Main{
    public static void main(String[] args) {
        
        try(Scanner sc = new Scanner(System.in)){
 
            int n = Integer.parseInt(sc.next());
            ArrayList<Integer> list = new ArrayList<>();
            ArrayList<Integer> copyList = new ArrayList<>();
            for(int i = 0; i < n; i++){
                int add = Integer.parseInt(sc.next());
                list.add(add);
                copyList.add(add);
            }
            
            Collections.sort(copyList);
            int centerL = copyList.get(n/2 - 1);
            int centerR = copyList.get(n/2);

            for(int j = 0; j < list.size(); j++){
                if(centerL >= list.get(j)) System.out.println(centerR);
                else System.out.println(centerL);
            }

 
        }catch(Exception e){
            e.printStackTrace();
        }        
    }
}

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

int main()
{
  long long Total = 0;
  int N, A[100000];
  
  cin >> N;
    
  for(int i = 0; i < N; i++)
  {
    cin >> A[i];
  }
  
  for(int i = 0; i < N; i++)
  {
    Total += A[i] -1;
  }
  
  cout << Total;
}

Measured memory_bytes: 3644
def main():
    H, W, K = map(int, input().split())
    A = [list(input()) for _ in range(H)]
    combs = []
    total_blacks = 0
    ans = 0
    for a in A:
        for a_ in a:
            if a_ == "#":
                total_blacks += 1

    for i in range(2**(H+W)):
        tmp_combs = []
        for j in range(H+W):
            if (i >> j) & 1:
                tmp_combs.append(1)
            else:
                tmp_combs.append(0)
        combs.append(tmp_combs)
    
    for c in combs:
        num_black = total_blacks
        for i in range(H):
            for j in range(W):
                h, w = c[i], c[H+j]
                if (h == 1 or w == 1) and A[i][j] == "#":
                    num_black -= 1

        if num_black == K:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 75156
let solve () = 
    let x = Scanf.sscanf (read_line ()) "%d" (fun a -> a) in
    let a = Scanf.sscanf (read_line ()) "%d" (fun a -> a) in
    let b = Scanf.sscanf (read_line ()) "%d" (fun a -> a) 
    in print_int ((x - a) mod b); print_string "\n"

let _ = solve ()

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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int H, W; cin >> H >> W;
    int ans = 0;
    string S[H];
    int grid[H][W];
    queue<pair<pair<int, int>, int>> que;
    rep(i, H){
        cin >> S[i];
        rep(j, W){
            if(S[i][j] == '.') grid[i][j] = 0;
            else{
                grid[i][j] = 1;
                que.push(make_pair(make_pair(i, j), 0));
            }
        }
    }

    while(!que.empty()){
        pair<pair<int, int>, int> op = que.front();
        int x = op.first.first, y = op.first.second, d = op.second;
        que.pop();
        bool painted = false;
        if(x-1 >= 0 && grid[x-1][y] == 0){
            painted = true;
            grid[x-1][y] = 1;
            que.push(make_pair(make_pair(x-1, y), d+1));
        }
        if(x+1 < H && grid[x+1][y] == 0){
            painted = true;
            grid[x+1][y] = 1;
            que.push(make_pair(make_pair(x+1, y), d+1));
        }
        if(y-1 >= 0 && grid[x][y-1] == 0){
            painted = true;
            grid[x][y-1] = 1;
            que.push(make_pair(make_pair(x, y-1), d+1));
        }
        if(y+1 < W && grid[x][y+1] == 0){
            painted = true;
            grid[x][y+1] = 1;
            que.push(make_pair(make_pair(x, y+1), d+1));
        }

        if(painted) ans = max(ans, d+1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 17296
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
signed main() {
    int X,Y;
    cin >> X >> Y;
    for(int i = 0; i <= X; i++) {
        int j = X-i;
        if(i*2+j*4 == Y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


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

int main(){
  int n; cin >> n; n = n%10;
  string ans;
  if(n == 3) ans = "bon";
  else if (n == 0 || n==1 || n==6 || n==8) ans = "pon";
  else ans = "hon";

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

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main() {
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    int i;
    for (i = 0; i < 4; i++)
        reverse(divide[i].begin(), divide[i].end());
    
    bool can = true;
    for (i = 0; i < s.length();) {
        bool can2 = false;
        int k;
        for (k = 0; k < 4; k++) {
            if (s.substr(i, divide[k].length()) == divide[k]) {
                can2 = true;
                break;
            }
        }
        if (can2) {
            i += (divide[k].length());
        }
        else {
            can = false;
            break;
        }
    }
    cout << ((can) ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
using ll = long long;
using uint = unsigned;
using ull = unsigned long long;
using P = pair<int,int>;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int main() {
    int A, B, M; cin >> A >> B >> M;
    vector<int> a(A);
    vector<int> b(B);

    int amin = INF;
    int bmin = INF;
    rep(i,A) {
        cin >> a[i];
        amin = min(amin,a[i]);
    }
    rep(i,B) {
        cin >> b[i];
        bmin = min(bmin,b[i]);
    }

    int ans = amin + bmin;
    vector<int> x(M), y(M), c(M);
    rep(i,M) {
        cin >> x[i] >> y[i] >> c[i];
        --x[i];
        --y[i];
    }
    rep(i,M) {
       ans = min(ans, a[x[i]]+b[y[i]]-c[i]);
    }
    cout << ans << endl;

    return 0;
}


























Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define IN inline
#define RE register
#define F first
#define S second
#define N 400005
#define mod 998244353
#define INF 0x3f3f3f3f
int n,v,x[N],vl[22],k=0,pf[22][N],pb[22][N],dpf[N],dpb[N],lf[N];
int main(){
	scanf("%d%d",&n,&v);
	for(int i=v;i;i>>=1) vl[k++]=i;
	vl[k]=0;
	reverse(vl,vl+k+1);
	for(int i=1;i<=n;++i) scanf("%d",x+i);
	for(int i=0;i<=k;++i){
		pf[i][1]=1;
		for(int j=2;j<=n;++j){
			if(x[j]-x[j-1]<=vl[i]) pf[i][j]=pf[i][j-1];
			else pf[i][j]=j;
		}
		pf[i][n+1]=n;
		pb[i][n]=n;
		for(int j=n-1;j;--j){
			if(x[j+1]-x[j]<=vl[i]) pb[i][j]=pb[i][j+1];
			else pb[i][j]=j;
		}
		pb[i][0]=1;
	}
	dpf[0]=0;
	memset(dpb,63,sizeof(dpb));
	dpb[0]=n+1;
	for(int msk=0;msk<(1<<k);++msk){
		for(int i=0;i<k;++i) if(!(msk&1<<i)){
			dpf[msk|1<<i]=max(dpf[msk|1<<i],pb[i][dpf[msk]+1]);
			dpb[msk|1<<i]=min(dpb[msk|1<<i],pf[i][dpb[msk]-1]);
		}
	}
	for(int msk=0,dmsk=(1<<k)-1;dmsk>=0;++msk,--dmsk)
		lf[dpb[dmsk]-1]=max(lf[dpb[dmsk]-1],dpf[msk]+1);
	for(int i=1;i<=n;++i) lf[i]=max(lf[i],lf[i-1]);
	for(int i=1;i<=n;++i){
		if(lf[pb[k][i]]>=pf[k][i]) puts("Possible");
		else puts("Impossible");
	}
	return 0;
}

Measured memory_bytes: 69632
n = int(input());
s = input();

r = [];
g = [];
b = [];
for i in range(n) :
    if s[i] == 'R' :
        r.append(i+1);
    if s[i] == 'G' :
        g.append(i+1);
    if s[i] == 'B' :
        b.append(i+1);

hiku = 0;
for j in range(2,n) :
    if j-1 < n-j :
        for i in range(1,j) :
            if (not(s[j-i-1]==s[j-1])) and (not(s[j-i-1]==s[j+i-1])) and (not(s[j-1]==s[j+i-1])) :
                hiku += 1;
    else :
        for i in range(1,n-j+1) :
            if (not(s[j-i-1]==s[j-1])) and (not(s[j-i-1]==s[j+i-1])) and (not(s[j-1]==s[j+i-1])) :
                hiku += 1;

print(len(r)*len(g)*len(b)-hiku);

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

int main(){

  int n;

  while(cin >> n && n){
    int sum = 0;
    int cnt = 0, shokika = 0;
    for(int i = 1; i < n; i++){
      sum += i;
      //  cout << sum << endl;
      shokika++;
      if(sum == n){
	cnt++;
      }
      //  if(shokika)
      if(i + 1 == n){
	i = n - shokika; 
	shokika = 0;
	sum = 0;
	//	cout << i << endl;
      }
    }
     cout << cnt << endl;
     cnt = 0;
  }


  return 0;
}

Measured memory_bytes: 1160
package main

import (
	"fmt"
)

func main() {
	var n, k, r, s, p int
	var t string
	fmt.Scanf("%d %d", &n, &k)
	fmt.Scanf("%d %d %d", &r, &s, &p)
	fmt.Scanf("%s", &t)

	hs := t[:k]
	for i := k; i < n; i++ {
		if t[i] == hs[i-k] {
			hs += "x"
		} else {
			hs += string(t[i])
		}
	}

	score := 0
	for _, h := range hs {
		switch h {
		case 'r':
			score += p
		case 's':
			score += r
		case 'p':
			score += s
		}

	}

	fmt.Printf("%d\n", score)
}


Measured memory_bytes: 9984
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;cin>>s>>t;
    int ans = 0;
    for(int i=0; i<s.size(); i++){
        if(s[i] != t[i]){
            ans++;
        }
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 3796
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
  string s;
  cin >> s;
  string s1 = s;
  string s2 = s;
  int ans = 0;
  int count1 = 0;
  int count2 = 1;
  for (int i = 1; i < s1.size(); i++){
    if (i%2==1 && s1[0]==s1[0+i]){
      s1[i] = (s1[i] == '0') ? '1' : '0';
      count1++;
    }
    else if (i%2==0 && s1[0]!=s1[0+i]){
      s1[i] = (s1[i] == '0') ? '1' : '0';
      count1++;
    }
  }  

  s2[0] = (s1[0] == '0') ? '1' : '0';
  for (int i = 1; i < s2.size(); i++){
    if (i%2==1 && s2[0]==s2[0+i]){
      s2[i] = (s2[i] == '0') ? '1' : '0';
      count2++;
    }
    else if (i%2==0 && s2[0]!=s2[0+i]){
      s2[i] = (s2[i] == '0') ? '1' : '0';
      count2++;
    }
  }  
  ans = min(count1, count2);
  cout << ans;
}

Measured memory_bytes: 512
# coding: utf-8
n=int(input())
a=list(map(int, input().split()))
max=-1000000
min=1000000
sum=0
for i in range(n):
    if a[i]>max:
        max=a[i]
    if a[i]<min:
        min=a[i]
    sum+=a[i]
print("{} {} {}".format(min,max,sum))


Measured memory_bytes: 6596
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/agc022/tasks/agc022_b

//参考：
//https://competitive12.blogspot.com/2019/09/agc-022-b-gcd-sequence.html

//ポイント1：
//最初に条件を満たす、ベースとなる小さい数列を作り、そこから特別性を壊さないよう値を加えていく

//ポイント2：
//mod2と3を見る
//例えば{2,4,3,9}は
//mod2では{0,0,1,1}
//mod3では{2,1,0,0}

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;

LL ans[20000];

void solve(){
	if(N==3){
		ans[0] = 2;ans[1] = 5;ans[2] = 63;
		return;
	}
	ans[0] = 2;
	ans[1] = 4;
	ans[2] = 3;
	ans[3] = 9;
	int counter = 0;
	LL two = 6;
	LL three = 12;
	LL six = 6;

	auto add_six= [&](int length){
		ans[length] = six;
		six+=6;
	};
	auto add_two= [&](int length){
		if(two<=30000){
			if(two%3==0) two+=2;
			ans[length] = two;
			two+=2;
			if(two%3==0) two+=2;
			if(two<=30000){
				ans[length+1] = two;
				two+=2;
			}
			else{
				add_six(length);
				add_six(length+1);
			}
		}else{
			add_six(length);
			add_six(length+1);
		}
	};
	auto add_three= [&](int length){
		if(three<=30000){
			if(three%2==0) three+=3;
			ans[length] = three;
			three+=3;
			if(three%2==0) three+=3;
			if(three<=30000){
				ans[length+1] = three;
				three+=3;
			}
			else{
				add_six(length);
				add_six(length+1);
			}
		}else{
			add_six(length);
			add_six(length+1);
		}
	};
	if(N%2==0){
		for(int length = 4;length<N;length+=2){
			if(counter%2==0){
				add_two(length);
			}else{
				add_three(length);
			}
			counter++;
		}
	}else{
		N--;
		for(int length = 4;length<N;length+=2){
			if(counter%2==0){
				add_two(length);
			}else{
				add_three(length);
			}
			counter++;
		}
		N++;
		add_six(N-1);
	}
}

int main(){
    cin >> N;

    solve();

    for(int i=0;i<N;i++) cout << ans[i] << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int r, g, b;
  cin >> r >> g >> b;
  if( (10*g+b)%4 == 0 ){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	vector<int>a(n),b(n);
	for(int i=0; i<n; i++) {
		cin>>a[i];
	}
	for(int i=0; i<n; i++) {
		cin>>b[i];
	}
	long long sum_a=0,sum_b=0;
	for(int i=0; i<n; i++) {
		sum_a+=a[i];
	}
	for(int i=0; i<n; i++) {
		sum_b+=b[i];
	}
	long long cnt=sum_b-sum_a,cnt_a=0,cnt_b=0;
	for(int i=0; i<n; i++) {
		int x=b[i]-a[i];
		if(x<0) {
			cnt_a+=abs(x);
		} else {
			cnt_b+=(x+1)/2;
		}
	}
	if(cnt>=cnt_a&&cnt>=cnt_b) {
		cout<<"Yes"<<endl;
	} else {
		cout<<"No"<<endl;
	}
	return 0;
}



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

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

using namespace std;

ll gcd(ll a, ll b){
//    if(a==1 | b==1)return 1;
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
//cout<<a<<' '<<b<<endl;
    
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b){
//cout<<a*b<<' '<<gcd(a, b)<<endl;
    return a * b / gcd(a, b);
}

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

  cout<<lcm(a,b);
  return 0;
}

Measured memory_bytes: 256
n=int(input())

def primes_factraizar(n):
    rn = int(n**0.5)
    is_prime = [True] * (rn+1) #まずは[1]*n^0.5を用意
    is_prime[0] = False 
    is_prime[1] = False
    for i in range(2, rn + 1): #素数の判定√nまでで十分
        if not is_prime[i]: #非素数は無視
            continue            #continue分はループ中の後続の命令をスキップする
        for j in range(i * 2, rn + 1, i): #i*2~nまでのiの倍数を順番に消す
            is_prime[j] = False
    return [i for i in range(rn + 1) if is_prime[i]]
primes = primes_factraizar(n)

if n==0 or n==1:
    print(0)
    exit()



div = []
for i in primes:
    for j in range(1000):
        if n%i==0:
            n=n//i
        else:
            if j == 0:
                break
            div.append(j)
            break
if n != 1:
    div.append(1) 

if div == []:
    print(1)
    exit()
ans = 0
for i in div:
    c = 0
    for j in range(1,10**9):
        if i >= c+j:
            c+=j
        else:
            ans += j-1
            break
print(ans)


Measured memory_bytes: 20364
// I need some holiday
// But I don't wish that everyday is holiday
// Because I didn't bear the pain
// Because it wasn't a true freedom
//         ——『イヤホンと蝉時雨』·Orangestar

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define MP make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }
template<typename T> inline T sqr(const T &val) { return val * val; }

namespace fastIO
{
	const int MAX_BUFFER_SIZE = 1 << 16;

	char buffer[MAX_BUFFER_SIZE], *cur = buffer, *ed = buffer;

	inline char getc() { return cur == ed && (ed = (cur = buffer) + fread(buffer, 1, MAX_BUFFER_SIZE, stdin), cur == ed) ? EOF : *cur++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

inline char *read_str(char *s)
{
	register char ch(getc());
	while(!isgraph(ch)) ch = getc();
	for(; isgraph(ch); ch = getc()) *s++ = ch;
	*s = '\0';
	return s;
}

// END tpl.

const int MOD = (int) 1e9 + 7;

const int MAXN = 15;

inline int fpm(int x, int y)
{
	int res = 1;
	for(; y; y >>= 1, x = (LL) x * x % MOD) if(y & 1) res = (LL) res * x % MOD;
	return res;
}

int n, m;

int adj[MAXN + 5];

inline void input()
{
	n = read<int>(), m = read<int>();
	for(int i = 0; i < m; ++i)
	{
		int u = read<int>() - 1, v = read<int>() - 1;
		adj[u] |= 1 << v;
	}
}

inline void solve()
{
	auto chk = [] (int S) { return (S >> 0 & 1) == (S >> 1 & 1); };

	static int f[1 << MAXN];

	f[0] = 1;
	for(int U = 1; U < 1 << n; ++U) if(chk(U))
		for(int S = U; S; S = (S - 1) & U) if(chk(S))
		{
			int T = U ^ S;
			int res = f[T];
			for(int i = 0; i < n; ++i) if(T >> i & 1) res = (LL) res * ((1 << __builtin_popcount(adj[i] & S)) - 1) % MOD;
			for(int i = 0; i < n; ++i) if(S >> i & 1) res = (LL) res * (1 << __builtin_popcount(adj[i] & T)) % MOD;
			(f[U] += res) %= MOD;
		}
	int ans = (fpm(2, m) - f[(1 << n) - 1]) % MOD;
	printf("%d\n", (ans + MOD) % MOD);
}

int main()
{
#ifdef K_ON
	freopen("F.in", "r", stdin);
	freopen("F.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}




Measured memory_bytes: 384
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <vector>
#define maxn 305
#define M 1000000007
inline int read() {
	int d=0;char ch=getchar();while(!isdigit(ch))ch=getchar();
	while(isdigit(ch)){d=d*10+ch-48,ch=getchar();}return d;
}

int n, m;
int f[maxn][maxn][maxn];
std::vector< std::pair<int, int> > pr[maxn];

int main() {
	n = read(), m = read();
	for(int i = 1; i <= m; ++i) {
		int l = read(), r = read(), x = read();
		pr[r].push_back(std::make_pair(l, x));
	}
	f[1][0][0] = 1;
	for(int i = 1; i <= n; ++i) {
		for(int p = pr[i].size()-1; p >= 0; --p)
			for(int j = 0; j < i; ++j)
				for(int k = 0; k <= j; ++k) {
					int l = pr[i][p].first, x = pr[i][p].second;
					if(x == 1) {
						if(j >= l || k >= l) f[i][j][k] = 0;
					}
					else if(x == 2) {
						if((j >= l && k >= l) || (j < l && k < l)) f[i][j][k] = 0;
					}
					else {
						if(j < l || k < l) f[i][j][k] = 0;
					}
				}
		if(i == n) break;
		for(int j = 0; j < i; ++j)
			for(int k = 0; k <= j; ++k)
				if(f[i][j][k]) {
					f[i+1][j][k] = (f[i+1][j][k] + f[i][j][k]) % M;
					f[i+1][i][k] = (f[i+1][i][k] + f[i][j][k]) % M;
					f[i+1][i][j] = (f[i+1][i][j] + f[i][j][k]) % M;
				}
	}
	int ans = 0;
	for(int j = 0; j < n; ++j)
		for(int k = 0; k <= j; ++k)
			ans = (ans + f[n][j][k]) % M;
	printf("%d\n", ((ans+ans)%M+ans)%M);
	return 0;
}

Measured memory_bytes: 108800
#include <algorithm>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

int main() {
  int n;
  std::cin >> n;
  std::vector<long long> a(n), b(n), sup;
  for (auto& x : a) std::cin >> x;
  for (auto& x : b) std::cin >> x;
  long long dem = 0;
  long long cnt = 0;
  for (int ni = 0; ni < n; ++ni) {
    long long d = b[ni] - a[ni];
    if (d > 0) {
      dem += d;
      ++cnt;
    }
    if (d < 0) sup.push_back(-d);
  }
  std::sort(sup.begin(), sup.end());
  std::reverse(sup.begin(), sup.end());
  std::vector<long long> acc(sup.size() + 1, 0);
  for (int si = 0; si < (int)sup.size(); ++si) acc[si + 1] = acc[si] + sup[si];
  for (int ai = 0; ai < (int)acc.size(); ++ai) {
    if (acc[ai] >= dem) {
      std::cout << cnt + ai << std::endl;
      return 0;
    }
  }
  std::cout << -1 << std::endl;
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double, P> event;

#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 each(itr,v) for(auto itr:v)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<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_popcount

#define INF INT_MAX/3
#define EPS 1e-8

int n;
double px[222],py[222],pz[222],vx[222],vy[222],vz[222],r[222],vr[222];
bool used[222];
double res[222];

int main(){
	cin.sync_with_stdio(false);
  while(1){
    cin>>n;
    if(n==0)break;
    memset(used,0,sizeof(used));
    rep(i,n)cin>>px[i]>>py[i]>>pz[i]>>vx[i]>>vy[i]>>vz[i]>>r[i]>>vr[i];
    set<event> es;
    rep(i,n){
      es.insert(event(r[i]/vr[i],P(i,-1)));
    }
    rep(i,n)rep(j,i){
      double ax=px[i]-px[j],bx=vx[i]-vx[j];
      double ay=py[i]-py[j],by=vy[i]-vy[j];
      double az=pz[i]-pz[j],bz=vz[i]-vz[j];
      double rr=r[i]+r[j],v=vr[i]+vr[j];
      double A=bx*bx+by*by+bz*bz-v*v;
      double B=ax*bx+ay*by+az*bz+rr*v;
      double C=ax*ax+ay*ay+az*az-rr*rr;
      if(abs(A)<EPS||B*B-A*C<EPS)continue;
      double t1=(-B+sqrt(B*B-A*C))/A;
      double t2=(-B-sqrt(B*B-A*C))/A;
      if(max(t1,t2)<EPS)continue;
      es.insert(event(min(t1,t2)<EPS?max(t1,t2):min(t1,t2),P(i,j)));
    }
    each(i,es){
      if(i.se.se==-1&&!used[i.se.fi]){
        used[i.se.fi]=true;
        res[i.se.fi]=i.fi;
      }else if(!used[i.se.fi]&&!used[i.se.se]){
        used[i.se.fi]=used[i.se.se]=true;
        res[i.se.fi]=i.fi;
        res[i.se.se]=i.fi;
      }
    }
    rep(i,n){
      printf("%.10f\n", res[i]);
    }
  }
	return 0;
}

Measured memory_bytes: 4316
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
using namespace std;
typedef long long ll;


int main(int argc, char *args[]) {
	int N;
	cin >> N;
	char color[101];
	bool flag;
	flag = false;
	for (int i = 0; i < N; i++) {
		cin >> color[i];
		if (color[i] == 'Y') {
			flag = true;
			break;
		}
	}
	if (flag == true) {
		cout << "Four" << endl;
	}
	else {
		cout << "Three" << endl;
	}
}


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

typedef long long ll;

const int maxn = 3010;
int N, a[maxn];
ll dp[maxn][maxn][2];
bool vis[maxn][maxn][2];

ll rec(int l, int r, int t) {
    if (l > r) {
        return 0;
    }
    ll& ret = dp[l][r][t];
    if (vis[l][r][t]) {
        return ret;
    }
    vis[l][r][t] = true;
    if (t == 0) {
        ret = max(a[l] + rec(l + 1, r, 1), a[r] + rec(l, r - 1, 1));
    } else {
        ret = min(-a[l] + rec(l + 1, r, 0), -a[r] + rec(l, r - 1, 0));
    }
    return ret;
}

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

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    ll answer = rec(0, N - 1, 0);
    cout << answer;

    return 0;
}

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

int main(void){
  int D;
  cin >> D;
  string ret = "Christmas";
  if(D==22){
    ret = "Christmas Eve Eve Eve";
  }else if(D==23){
    ret = "Christmas Eve Eve";
  }else if(D==24){
    ret = "Christmas Eve";
  }
  cout << ret << endl;  
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef map<int,int> dct;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define pi 3.14159265

bool compare(pll a, pll b){
    return a.first*b.second<a.second*b.first;
}

const ll mod = 1e9+7;
const ll inf = ll(1e18);

ll modexp(ll x,ll n){
    if(n==0)return 1;
    if(n%2==0)return modexp((x*x)%mod,n/2);
    return (x*modexp((x*x)%mod,n/2))%mod;
}
ll gcd(ll a, ll b){
    if (a == 0)
        return b;
    return gcd(b % a, a);
}
int main(){
    //clock_t tm = clock();
    fastio;
    ll n,x;
    cin>>n;
    vl a(n);
    map<ll,ll>b;
    f(i,0,n){
        cin>>a[i];
        x=a[i];
        f(j,2,int(sqrt(x))+1){
            if(x%j==0){
                ll c=0;
                while(x%j==0){
                    x/=j;
                    c++;
                }
                if(in(b,j))
                    b[j]=max(b[j],c);
                else
                    b[j]=c;
            }
        }
        if(x>1 and !(in(b,x))){
            b[x]=1;
        }
    }
    ll lcm=1;
    fr(i,b){
        lcm=(lcm*modexp(i.first,i.second))%mod;
    }
    ll ans=0;
    f(i,0,n){
        ans=(ans+(lcm*modexp(a[i],mod-2))%mod)%mod;
    }
    cout<<ans<<endl;
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 1024
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys
def sinput(): return sys.stdin.readline()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()
def gcd(numbers): return func.reduce(frac.gcd, numbers)
def lcm(numbers): return func.reduce(LCM, numbers)
sys.setrecursionlimit(10**7)
mod = 10 ** 9 + 7
inf = np.inf

n,m,r = imap()
cities = map(lambda x: int(x)-1, sinput().split())
abc = np.array([iarr() for i in range(m)])
a,b,c = abc.T[0]-1, abc.T[1]-1, abc.T[2]
graph = sps.csr_matrix((c,(a,b)),(n,n))
wf = sps.csgraph.floyd_warshall(graph,directed=0).astype(int)

anss = []
for city in ite.permutations(cities):
    ans = 0
    for i in range(r-1): ans += wf[city[i]][city[i+1]]
    anss.append(ans)
print(min(anss))


Measured memory_bytes: 20000
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i,n) cin >> h[i];

  int pre = 0;
  rep(i,n){
    if(h[i]>pre)h[i]--;
    if(h[i]<pre){
      cout << "No" << endl;
      return 0;
    }
    pre = h[i];
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 888
# coding: utf-8
# Here your code !
h,w=[int(x) for x in input().split()]
s=[""]*h
for i in range(h):
    s[i]=list(input())
from itertools import product
for i,j in product(range(h),range(w)):
    if s[i][j]=="#":
        continue
    ans=0
    for p,k in product([i-1,i,i+1],[j-1,j,j+1]):
        try:
            if p<0 or k<0:
                continue
            if s[p][k]=="#":
                ans+=1
        except:
            pass
    s[i][j]=str(ans)
for i in s:
    print("".join(i))

Measured memory_bytes: 40816
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import defaultdict 
def main():
    N = int(input())
    ans = defaultdict(int)
    for i in range(1, 110):
        for j in range(1, 110):
            for k in range(1, 110):
                v = i*i+j*j+k*k+i*j+j*k+k*i
                ans[v] += 1
    for i in range(1, N+1):
        print(ans[i])
if __name__ == '__main__':
    main()


Measured memory_bytes: 14432
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

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


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

int main() {
  int R;
  cin >> R;
  cout << 2 * R * 3.14159265357323;
}


Measured memory_bytes: 3764