akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C_fix
# CreatedDate:  2020-09-27 01:13:48 +0900
# LastModified: 2020-09-27 01:29:07 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    N = int(input())
    S = input()
    RW_cnt = S.count("W")
    RE_cnt = S.count("E")
    LW_cnt = 0
    LE_cnt = 0
    if S[0] == "W":
        RW_cnt -= 1
        LW_cnt = 1
    else:
        RE_cnt -= 1
        LE_cnt = 1
    ans = RE_cnt
#    print("RW_cnt, RE_cnt, LW_cnt, LE_cnt")
    for i in range(1, N):
        if i == N-1:
            cnt = LW_cnt
        else:
            cnt = LW_cnt + RE_cnt
        if cnt < ans:
            ans = cnt
        if S[i] == "E":
            LE_cnt += 1
            RE_cnt -= 1
        else:
            LW_cnt += 1
            RW_cnt -= 1
#        print(RW_cnt, RE_cnt, LW_cnt, LE_cnt)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9544
/*Practice hard*/
#include <bits/stdc++.h>
using namespace std;

//_______MACROS_______//
#define   fast  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define   int   long long int
#define   pb    push_back
#define   f     first
#define   s     second
#define   PI    3.1415926535898


string S, T;
void input()
{
    cin >> S >> T;
}
void solve()
{
    T.pop_back();
    if(S == T) cout << "Yes" << endl;
    else cout << "No" << endl;
}
signed main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 3612
A = []
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))
A.append(list(map(int, input().split())))
N = int(input())
b = [int(input()) for i in range(N)]
cor = [[0 for _ in range(3)] for _ in range(3)]
ans = 'No'

for i in range(N):
    for j in range(3):
        for k in range(3):
            if b[i] == A[j][k]:
                cor[j][k] = 1

for i in range(3):
    if cor[i][0] == 1 and cor[i][1] == 1 and cor[i][2] == 1:
        ans = 'Yes'
    if cor[0][i] == 1 and cor[1][i] == 1 and cor[2][i] == 1:
        ans = 'Yes'    

if cor[0][0] == 1 and cor[1][1] == 1 and cor[2][2] == 1:
    ans = 'Yes'
if cor[0][2] == 1 and cor[1][1] == 1 and cor[2][0] == 1:
    ans = 'Yes'
    
print(ans) 

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

int main(){
	int n;
	for(cin >> n; n--; ){
		string s;
		cin >> s;
		s += '0';

		const string tbl[10] = {
			"",
			".,!? ",
			"abc",
			"def",
			"ghi",
			"jkl",
			"mno",
			"pqrs",
			"tuv",
			"wxyz",
		};

		int d = 0, t = 0;
		for(size_t i = 0; i < s.size(); ++i){
			int c = s[i] - '0';
			if(c == 0 || c != d){
				if(d != 0){
					cout << tbl[d][t];
				}
				d = c;
				t = 0;
			}
			else{
				t = (t + 1) % tbl[d].size();
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 1216
#include <stdio.h>
#include <math.h>

int main(void)
{
	int n, i, g;
	int s[1001];
	double a, m;//aが偏差値,mが平均,gが合計
	
	while(1){
		a = m = 0;
		g = 0;
		
		scanf("%d", &n);
		if(n==0){
			break;
		}
		
		for(i=0;i<n;i++){
			scanf("%d", &s[i]);
			g += s[i];
		}
		
		m = (double)g/n;
		
		for(i=0;i<n;i++){
			a += ((s[i]-m)*(s[i]-m))/n;
		}
		
		printf("%f\n", sqrt(a));
	}
	
	return 0;
}


Measured memory_bytes: 2056
#ifndef _TEMPLATE_ROOT
#define _TEMPLATE_ROOT
#include "bits/stdc++.h"
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define repl(i, a, b) for(ll i = a; i < (b); ++i)
#define repd(i, a, b) for(int i = a; i >= (b); --i)
#define repdl(i, a, b) for(ll i = a; i >= (b); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
#endif
#ifndef _TEMPLATE_IO
#define _TEMPLATE_IO

template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void writef(T ...tail) { write(tail...); cout << flush; }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  if (v.size()) {
    rep(i, 0, sz(v) - 1)
      out << v[i] << " ";
    out << v.back();
  }
  return out;
}
#endif
using namespace std;

struct Dsu {
  int dsu[200005];
  Dsu() { rep(i, 0, 200005) dsu[i] = -1; }
  int size(int u) { return -dsu[find(u)]; }
  int find(int u) { if (dsu[u] < 0) return u; return dsu[u] = find(dsu[u]); }
  void merge(int u, int v) {
    u = find(u), v = find(v);
    if (u == v) return;
    if (-dsu[u] > -dsu[v]) swap(u, v);
    dsu[u] += dsu[v];
    dsu[v] = u;
  }
} dsu;

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

  int n, m; read(n, m);
  int ans = 0;
  rep(i, 0, m) {
    int a, b; read(a, b);
    dsu.merge(a, b);
  }
  rep(i, 1, n + 1) chmax(ans, dsu.size(i));
  write(ans);
}





Measured memory_bytes: 7460
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

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

fn main() {
    input!{
        n: usize,
        k: usize,
        mut s: chars
    }
    match s[k - 1] {
        'A' => s[k - 1] = 'a',
        'B' => s[k - 1] = 'b',
        'C' => s[k - 1] = 'c',
        _ => ()
    }
    for i in 0..n {
        print!("{}", s[i]);
    }
    println!("");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#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 rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
const ll LINF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
inline ll lin() { ll x; scanf("%lld",&x); return x;}
inline char chin() { char x; scanf("%c",&x); return x;}
inline string stin() { string x; cin >> x; return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
char itoa(int n) { return n + '0';}
ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  string w = stin();
  string t;
  int ans = 0;
  while (cin >> t) {
    if (t == "END_OF_TEXT") break;
    rep(i,t.size()) {
      if ('A'<=t[i] && t[i]<='Z') t[i] += 'a'-'A';
    }
    if (t == w) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
using ll =long long;
using db = double;

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

#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(v) SORT(v);(v).erase(unique((v).begin(),(v).end()),(v).end())
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
const int mod = 1e9 + 7;

ll ans;
//ここから書き始める
int main()
{
	cout << setprecision(10);
	
	string s[3];
	cin >> s[0] >> s[1] >> s[2];
	int i[] = {0,0,0};
	int now = 0;
	while (true) {
		if(s[now].size() > i[now]){
			i[now]++;
			now =s[now][i[now]-1]-'a';
		}else {
			cout << (char)(now+'A') << endl;
			break;
		}
	}
}
//写経コード

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl
const ll INF = 1000000007;

int main(){
  int a, b;
  cin >> a >> b;
  if(b < a) cout << a - 1 << endl;
  else cout << a << endl;
}


Measured memory_bytes: 256
l=list(input())
n=len(l)
if n==1:
    print(l[0])
    exit()
op=['0','1']
for i in range(n-2):
    tmp=[]
    for j in op:
        tmp.append(j+'0')
        tmp.append(j+'1')
    op=tmp
ans=0
for i in op:
    k=list(i)
    k.append('2')
    s=l[0]
    t=0
    for j in range(n):
        if k[j]=='1':
            s+=l[j+1]
        elif k[j]=='0':
            t+=int(s)
            s=l[j+1]
        else:
            t+=int(s)
    ans+=t
print(ans)

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    ll n, m;
    cin >> n >> m;

    set<ll> div;
    for (int i = 1; i * i < m; i++) {
        if (m % i == 0) {
            div.insert(i);
            div.insert(m / i);
        }
    }

    ll ans = 1;
    for (auto iter = div.begin(); iter != div.end(); iter++) {
        if (m / (*iter) >= n) {
            ans = (*iter);
        }
    }
    cout << ans << endl;

    return 0;
}



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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MOD 1000000007
#define INF (1LL<<25)     //33554432
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

signed main(void)
{
  int n;
  cin >> n;
  queue<int> que;
  REP(i, 1<<n) {
    int a;
    cin >> a;
    que.push(a);
  }

  while(que.size() != 1) {
    int s = que.front(); que.pop();
    int t = que.front(); que.pop();
    if(s > t) que.push(s-t);
    else if(s == t) que.push(s);
    else if(s < t) que.push(t-s);
    else assert(false);
  }

  cout << que.front() << endl;

  return 0;
}


Measured memory_bytes: 1280
/*  -*- coding: utf-8 -*-
 *
 * 3052.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const long long MOD = 1000000007LL;

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

/* main */

int main() {
  ll a, b, x;
  scanf("%lld%lld%lld", &a, &b, &x);

  ll sum = x % MOD;
  if (x >= a) {
    ll k = (x - a) / (a - b) + 1;
    sum = (sum + (k % MOD) * (b % MOD)) % MOD;
  }

  printf("%lld\n", sum);
  return 0;
}



Measured memory_bytes: 3228
def lscan; gets.split.map(&:to_i); end

N = gets.to_i
ABC = (1..3).map{gets.chomp}

chrs = (0...N).map{|i| ABC.map{|s| s[i]}.sort.uniq.size}
p chrs.map{|e| e-1}.reduce(:+)


Measured memory_bytes: 1788
def range_product():
	a, b = map(int, raw_input().split(" "))
	if a>0:
		print "Positive"
	elif a==0:
		print "Zero"
	else:
		if b>=0:
			print "Zero"
		else:
			l = b-a+1
			if l%2==0:
				print "Positive"
			else:
				print "Negative"


if __name__ == "__main__":
	range_product()

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

int main(){
  int n;
  cin >> n;
  long long a[n],sum = 0;
  int i,pm=1,minh=1000000001;
  for(i=0;i<n;i++){
    cin >> a[i];
    if(a[i]<0){
      pm *= -1;
      a[i] *= -1;
    }
    if(minh>a[i]) minh = a[i];
    sum += a[i];
  }
  if(pm==1) cout << sum << endl;
  else cout << (sum - minh * 2) << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
  int N;
  scanf("%d", &N);
 
  multiset< int > sets;
  sets.insert(0);
  for(int i = 0; i < N; i++) {
    int depth;
    scanf("%d", &depth);
    auto p = sets.upper_bound(depth);
    if(p == sets.begin()) {
      puts("No");
    } else {
      int q = *--p;
      sets.erase(p);
      puts("Yes");
      for(int j = q + 1; j <= depth && sets.size() <= N; j++) {
        if(sets.size() == N && *--sets.end() > j) sets.erase(--sets.end());
        sets.insert(j);
      }
    }
  }
}

Measured memory_bytes: 23304
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int h, w;
	cin >> h >> w;
	vvi d(10, vi(10));
	REP(i, 10)REP(j, 10)cin >> d[i][j];
	vi cnt(10, 0);
	REP(i, h) {
		REP(j, w) {
			int a;
			cin >> a;
			if (a != -1)cnt[a]++;
		}
	}
	REP(k, 10) {
		REP(j, 10) {
			REP(i, 10) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}
	int ans = 0;
	REP(i, 10) {
		ans += cnt[i] * d[i][1];
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define pb(t) push_back(t)
#define ft first
#define sc second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;


ll N;
vector<ll> g[MAX];
ll d[2][MAX];

void dijkstra(ll s, ll idx) {
    ll clr[MAX]={};
    ll u, v, i;
    
    for(i=0; i<N; i++) d[idx][i]=INF;
    d[idx][s]=0;
    priority_queue<P> q;
    q.push(P(0, s));
    while(q.size()) {
        P f=q.top(); q.pop();
        u=f.sc;
        clr[u]=1;
        if(d[idx][u]<-f.ft) continue;
        for(i=0; i<g[u].size(); i++) {
            v=g[u][i];
            if(clr[v]) continue;
            if(d[idx][v]>d[idx][u]+1) {
                d[idx][v]=d[idx][u]+1;
                q.push(P(-d[idx][v], v));
            }
        }
    }
    
}

int main(void) {
    cin >> N;
    ll i;
    for(i=0; i<N-1; i++) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    
    dijkstra(0, 0);
    dijkstra(N-1, 1);
    
    ll x=0, y=0;
    for(i=0; i<N; i++) {
        if(d[0][i]<=d[1][i]) x++;
        else y++;
    }
    
    if(x>y) puts("Fennec");
    else puts("Snuke");
    
}








Measured memory_bytes: 9488
### subroutines

def score(ns)
  sum = 0
  ones = 0
  for n in ns
    if n == 1
      sum += 1
      ones += 1
    elsif n < 10
      sum += n
    else
      sum += 10
    end
  end

  for i in (0...ones)
    break if sum + 10 > 21
    sum += 10
  end

  (sum <= 21) ? sum : 0
end

### main

while true
  ns = gets.strip.split(' ').map{|s| s.to_i}
  break if ns[0] == 0

  puts score(ns)
end

Measured memory_bytes: 6104
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int K,L;
  cin >> K;
  if (K%7==0)L=9*K/7;
  else L=9*K;
  int X=10%L;
  int Y=0;
  int S=0;
  int m;
  rep(i,L){
    if(X==1){
      S=1;
      m=i;
      break;
    }
    X=(X*10)%L;
  }
  if(S){cout << m+1 << endl;}
  else{cout << -1 << endl;}
  return 0;
}





Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<map>
#include<set>
#define ll long long int
using namespace std;

int n;
ll L;
ll a[100100];
int main() {
  cin>>n>>L;
  ll sum = 0;
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum+=a[i];
  }
  for(int i=0;i<n-1;i++){
    if(a[i]+a[i+1]>=L){
      cout<<"Possible"<<endl;
      for(int j=0;j<i;j++){
        cout<<j+1<<endl;
      }
      for(int j=n-2;j>=i;j--){
        cout<<j+1<<endl;
      }
      return 0;
    }
  }
  cout<<"Impossible"<<endl;
  return 0;
}


Measured memory_bytes: 1536
N,M = map(int,input().split())
H = list(map(int,input().split()))
ans = [1 for i in range(N)]
for i in range(M):
    a,b = map(int,input().split())
    if H[a-1] < H[b-1]:
        ans[a-1] = 0
    elif H[a-1] > H[b-1]:
        ans[b-1] = 0
    else:
        ans[a-1] = 0
        ans[b-1] = 0
print(sum(ans))


Measured memory_bytes: 20144
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
char a[10];
int main()
{
    int n,l,r,l1,r1;
    cin>>n;
    l=0;
    r=n;
    cout<<"0"<<endl;
    cin>>a;
    if(a[0]=='V')
        return 0;
    else if(a[0]=='M')
        l1=1;
    else
        l1=0;
    int mid,mid1;
    while(l!=r-1)
    {
        mid=(l+r)/2;
        cout<<mid<<endl;
        cin>>a;
            if(a[0]=='V')
        return 0;
        else if(a[0]=='M')
            mid1=1;
        else
            mid1=0;
        int t =mid-l;
        if(t%2==0)
        {
            if(mid1==l1)
            {
                l=mid;
                l1=mid1;
            }
            else
            {
                r=mid;
            }

        }
        else
        {
            if(mid1==l1)
                r=mid;
            else
            {
                l=mid;
                l1=mid1;
            }

        }
    }
    return 0;
}


Measured memory_bytes: 852
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include<string>
#include<math.h>
#include<stdlib.h>
#include<time.h>
#include<map>
#include<queue>
#include<set>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;
long long n,x,ans;
long long wor(long long a,long long b){
	if (a%b==0) return b*(a/b*2-1);
	return wor(b,a%b)+b*2*(a/b);//*a/b
}
int main(){
	scanf("%lld%lld",&n,&x);
	ans=n+wor(max(n-x,x),min(n-x,x));
	printf("%lld\n",ans);
	return 0;
}

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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int di2[] = {1, 1, -1, -1, 0, 1, 2, 2, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1};
const int dj2[] = {1, -1, 1, -1, 2, 2, 2, 1, 0, -1, -2, -2, -2, -2, -2, -1, 0, 1, 2, 2};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

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

  if(s == "RRR") cout << 3 << endl;
  else if(s == "RRS" || s == "SRR") cout << 2 << endl;
  else if(s == "SSS") cout << 0 << endl;
  else cout << 1 << endl;
}

Measured memory_bytes: 3576
a, b, x = map(int, input().split())
import numpy as np
if b*a*a/2>x:
  print(np.arctan(a*b*b/2/x)*180/np.pi)
else:
  y=2*x/(a*a) - b
  z = b-y
  print(np.arctan(z/a)*180/np.pi)

Measured memory_bytes: 12488
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1001001001;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}
//printf("%.10f\n", N);
/*
ll memo[100000];
ll fibo(ll n){
    if(memo[n] != 0)return memo[n];
    if(n <= 1)return n;
    else return memo[n] = fibo(n - 1)+ fibo(n - 2);
}*/
int main() {
    ll memo[3][100005];
    ll N;
    cin >> N;
    vector<vector<ll>> num(N,vector<ll>(3));
    rep(i,N)cin >> num[i][0] >> num[i][1] >> num[i][2];
    memo[0][0] = 0;memo[0][1] = 0;memo[0][2] = 0;
    rep(i,N){
        rep(j,3){
            if(j == 0){
                memo[j][i + 1] = max(memo[1][i],memo[2][i]) + num[i][j];
            }
            else if(j == 1){
                memo[j][i + 1] = max(memo[0][i],memo[2][i]) + num[i][j];
            }
            else{
                memo[j][i + 1] = max(memo[0][i],memo[1][i]) + num[i][j];
            }
        }
    }
    cout << max(max(memo[0][N],memo[1][N]),memo[2][N]) << endl;
    /*rep(i,3){
        rep(j,N + 1)cout << memo[i][j] << " ";
        cout << endl;
    }*/
    /*rep(i,N){
        rep(j,3)cout << num[i][j] << " ";
        cout << endl;
    }*/
}

Measured memory_bytes: 8064
import Data.Bits
import qualified Data.ByteString.Char8 as C
import qualified Data.Vector.Unboxed as U

main = C.interact $ put . sol . get

get = U.unfoldr (C.readInt . C.dropWhile (<'0'))

put = C.unwords . fmap (C.pack . show) . U.toList

sol v = U.map (xor p) u
  where
  u = U.tail v
  p = U.foldr1 xor u

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

int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    int a[n+1];
    for(int i=0;i<=n;i++){
        if(i==0)
            a[0] = 9999;
        else
            cin >> a[i];
    }
    int count = 0;
    for(int i=1;i<=n;i++){
        int first = a[i];
        int second = a[first];
        if(second == i) count++;
    }
    cout << count/2 << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
using Graph =vector<int>;
typedef pair<ll,ll> P;

const int MAX = 210000;
const int MOD = 1000000007;
vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int ans;
int main(){
  int N,M;cin>>N>>M;
  vector<P> primes=prime_factorize(M);
  COMinit();
  ll res=1;
  for(auto pa:primes){
    int num=pa.second;
    ll tmp=COM(num+N-1,N-1);
    res=(res*tmp)%MOD;
  }
  cout<<res<<endl;
}


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

int main() {

  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);

  int H, W, h, w;
  cin >> H >> W >> h >> w;

  int total = H * W - ((H / h) * (W / w));
  int neg = ((H / h) * (W / w));

  int pval = 1000;
  int nval = 1000 * (1 - h * w) - 1;
  if (total * pval + neg * nval > 0) {
    cout << "Yes\n";
    vector<vector<int>> mat(H, vector<int> (W, pval));
    for (int i = h-1; i < H; i += h) {
      for (int j = w-1; j < W; j += w) {
        mat[i][j] = nval;
      }
    }
    for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
        cout << mat[i][j] << " ";
      }
      cout << '\n';
    }
  } else {
    cout << "No\n";
  }
}

Measured memory_bytes: 2560
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通りに作成したソースコード
 */
public class Main {

	private static final long MOD = 1_000_000_007L;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] a = IntStream.range(0, n + 1).map(i -> scanner.nextInt()).toArray();
			// 各数字が配列aでのindexを格納する配列
			int[] indexes = new int[n + 1];
			Arrays.fill(indexes, -1);
			int tempL = 0, tempR = 0;
			for (int i = 0; i < n + 1; i++) {
				if (indexes[a[i]] >= 0) {
					tempL = indexes[a[i]] + 1;
					tempR = i + 1;
					break;
				}
				indexes[a[i]] = i;
			}
			final int l = tempL, r = tempR;
			// 階乗の配列
			long[] frac = new long[n + 2];
			frac[0] = 1;
			IntStream.range(1, frac.length).forEach(i -> frac[i] = frac[i - 1] * i % MOD);
			// 階乗^-1の配列
			long[] reverseFrac = new long[n + 2];
			reverseFrac[n + 1] = powMod(frac[n + 1], MOD - 2);
			for (int i = reverseFrac.length - 2; i >= 0; i--) {
				reverseFrac[i] = reverseFrac[i + 1] * (i + 1) % MOD;
			}
			// n+1_C_k − l+n−r_C_k−1 を計算
			IntStream.rangeClosed(1, n + 1)
					.mapToLong(k -> calcMod(frac[n + 1] * reverseFrac[k] % MOD * reverseFrac[n + 1 - k] % MOD
							- ((l + n - r - k + 1 >= 0)
									? frac[l + n - r] * reverseFrac[k - 1] % MOD * reverseFrac[l + n - r - k + 1] % MOD
									: 0L)))
					.forEach(System.out::println);
		}
	}

	/**
	 * @param n
	 * @param m
	 * @return n^m mod MOD
	 */
	private static long powMod(long n, long m) {
		long result = 1L;
		while (m > 0) {
			if (1 == (m & 1)) {
				result = result * n % MOD;
			}
			n = n * n % MOD;
			m >>= 1;
		}
		return result;
	}

	/**
	 * @param l 入力数字
	 * @return l mod MOD
	 */
	private static long calcMod(long l) {
		l %= MOD;
		if (l < 0) {
			l += MOD;
		}
		return l;
	}
}


Measured memory_bytes: 62348
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

#define loop(i,a,b) for(int i=(a);i<int(b);i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()

int n,k;
string v[20];
vector<bool> used;
set<string> S;

void dfs(int cnt, string s) {
    if(cnt==k) {
        S.insert(s);
        return;
    } else {
        rep(i,n) {
            if(!used[i]){
                used[i] = 1;
                dfs(cnt+1, s+v[i]);
                used[i] = 0;
            }
        }
    }
}

int main() {
    while(cin>>n>>k && n) {
        S.clear();
        used.assign(n,false);
        rep(i,n)cin>>v[i];
        dfs(0,"");
        cout << S.size() << endl;
    }
}

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

int main() {
  int n,k;
  cin >> n >> k;

  vector<int> p(n);
  //vectorに全入力値を代入する
  rep(i,n) cin >> p[i];

  //金額を昇順に並べる
  sort(p.begin(), p.end());

  //k個の商品を購入する
  int ans = 0;
  rep(i,k) {
    ans += p[i]; //最小の商品ｋ個購入
  }

  cout << ans << endl;
}

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

int main(){
  ll n,k;cin >> n >> k;
  vector<ll> psn(n);
  rep(i,k){
    ll d;cin >> d;
    rep(j,d){
      ll a;cin >> a;
      --a;
      psn.at(a)++;
    }
  }
  ll ans = 0;
  rep(i,n){
    if( psn.at(i) == 0 ) ++ans;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3580
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static boolean search(int[] num, int key){
        int len = num.length;
        num[len-1] = key;

        int i = 0;
        while (num[i] != key){
            i++;
        }

        return i != len-1;
    }

    public static void main(String[] args) throws IOException {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());

        int[] num = new int[n+1];
        String[] strings = br.readLine().split("\\s");
        for (int i=0; i<strings.length; i++){
            num[i] = Integer.parseInt(strings[i]);
        }

        int q = Integer.parseInt(br.readLine());
        String[] strs = br.readLine().split("\\s");
        int sum = 0;
        for (int i=0; i<q; i++){
            if (search(num, Integer.parseInt(strs[i]))){
                sum++;
            }
        }

        System.out.println(sum);

    }
}

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

int main() {
  int N;
  cin >> N;
  int fx = 0;
  int amari;
  int syou = N;
  while (1) {
    if (syou < 10) {
      fx += syou;
      break;
    }
    amari = syou % 10;
    syou = syou / 10;
    fx += amari;
  }
  // cout << fx << endl;
  if (N % fx == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import sys
def main():
    input = sys.stdin.readline
    N,M=map(int, input().split())
    S=[tuple(map(int, input().split())) for _ in range(N)]
    C=[tuple(map(int, input().split())) for _ in range(M)]
    ans=[0]*N
    for i in range(N):
        a,b=S[i]
        tmp=10**10
        for j in range(M):
            c,d=C[j]
            if tmp > abs(a-c)+abs(b-d):
                tmp = abs(a-c)+abs(b-d)
                ans[i]=j+1
    for i in range(N):
        print(ans[i])

if __name__ == '__main__':
    main()

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

/*

*/

const ll MX = 1e18;

int main() {
  int n;
  cin >> n;
  ll as[100005];
  rep(i,n) {
    ll a;
    cin >> a;
    if (a == 0) {
      cout << 0 << endl;
      return 0;
    }
    as[i] = a;
  }
  ll ans = 1;
  rep(i,n) {
    if (as[i] > MX/ans) {
      cout << -1 << endl;
      return 0;
    }
    ans *= as[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4348
import java.util.*;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n1 = sc.nextInt();
    int n2 = sc.nextInt();
    int n3 = sc.nextInt();
    
    int[] array = {n1,n2,n3};
    int matchCount1 = 0;
    int matchCount2 = 0;
    for(int val : array){
      if(val == 5){
        matchCount1++;
      }else if(val == 7){
        matchCount2++;
      }
    }
    
    if(matchCount1 == 2 && matchCount2 == 1){
      System.out.println("YES");
    } else{
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 21712
import itertools
h, w, k = map(int, input().split())
p = [list(str(input())) for _ in range(h)]
bl = p.count('#')
bl = bl - k
ee = list(range(h))
q = list(range(w))
kotae = 0
pp = []
qq = []
for i in range(h + 1):
    pp += list(itertools.combinations(ee, i))
for i in range(w + 1):
    qq += list(itertools.combinations(q, i))
for i in pp:
    for j in qq:
        ans = 0
        for zz in range(h):
            for ww in range(w):
                if zz not in i:
                    if ww not in j:
                        if p[zz][ww] == '#':
                            ans += 1
        if ans == k:
            kotae += 1
print(kotae)

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

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

int main()
{
    int r,D,x2000;
    cin>>r>>D>>x2000;
    REP(i,10)
    {
        x2000=r*x2000-D;
        cout<<x2000<<endl;
    }
}

Measured memory_bytes: 256
import java.util.*;


public class Main {
    public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true) {
		    int H = sc.nextInt();
		    int W = sc.nextInt();
		    if (H == 0 && W == 0) break;
		    
		    for (int i = 0; i<H; i++) {
		        for (int t= 0; t<W; t++) {
		            System.out.print("#");
		        }
		    System.out.println("");
		    }
		    System.out.println("");
		}

		
    }
}


Measured memory_bytes: 32800
using System;
class c
{
    static void Main()
    {
        var inp = int.Parse(Console.ReadLine());
        if (inp == 1) Console.WriteLine("Hello World");
        else
        {
            var a = int.Parse(Console.ReadLine());
            var b = int.Parse(Console.ReadLine());
            Console.WriteLine(a + b);
        }
    }
}

Measured memory_bytes: 13140
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>


using namespace std;
using vi=vector<int>;
using vvi=vector<vi>;
using vc=vector<char>;
using vvc=vector<vc>;


struct f_t
{
	int n;
	int x, y, f;
	bool operator<(const f_t&rhs) const
	{
		if(n!=rhs.n) return n>rhs.n;
		if(x!=rhs.x) return x>rhs.x;
		return y>rhs.y;
	}
};


bool cmp(f_t*a, f_t*b)
{
	if(a->n!=b->n) return a->n>b->n;
	if(a->x!=b->x) return a->x<b->x;
	return a->y<b->y;
}


void fill(vvc&ans, int ox, int oy, int ax, int ay, int s, int c)
{
	int w=ans[0].size();
	int h=ans.size();

	for(int i=0;i<s;i++)
	{
		int y=oy+ay*i;
		if(y<0 || h<=y) continue;

		for(int j=0;j<s-i;j++)
		{
			int x=ox+ax*j;
			if(x<0 || w<=x) continue;

			ans[y][x]=c;
			x+=ax;
		}
	}
}


void fill_big(vvc&ans, int ox, int oy, int d, int c)
{
	fill(ans, ox-1, oy-1, -1, -1, d/2-1, c);
	fill(ans, ox  , oy-1,  1, -1, d/2-1, c);
	fill(ans, ox-1, oy  , -1,  1, d/2  , c);
	fill(ans, ox  , oy  ,  1,  1, d/2  , c);
}


void solve(vvc&ans, int d)
{
	int h=ans.size();
	int w=ans[0].size();
	char s[]="RYGBxyz";

	if(d%2)
	{
		for(int y=0;y<h;y++)
		{
			for(int x=0;x<w;x++)
			{
				ans[y][x]=s[(x+y)%2];
			}
		}
		return;
	}

	for(int iy=0;iy<h;iy++)
	{
		int y=iy*d;
		for(int ix=0;ix<w;ix++)
		{
			int x=ix*d;
			fill_big(ans, x, y, d, "RG"[(ix+iy)%2]);
			if(x-d/2-1>w) break;
		}
		if(y-d/2-1>h) break;
	}

	for(int iy=0;iy<=h;iy++)
	{
		int y=iy*d+d/2;
		for(int ix=0;ix<w;ix++)
		{
			int x=ix*d+d/2;
			fill_big(ans, x, y, d, "BY"[(ix+iy)%2]);
			if(x-d/2-1>w) break;
		}
		if(y-d/2-1>h) break;
	}
}


int main(void)
{
	int h, w, d;

	while(scanf("%d%d%d", &h, &w, &d)==3)
	{
		vvi f(h);
		vvc ans(h);

		for(int y=0;y<h;y++)
		{
			f[y].assign(w, 0x0F);
			ans[y].assign(w, '#');
		}

		solve(ans, d);

		for(int y=0;y<h;y++)
		{
			printf("%.*s\n", w, &ans[y][0]);
		}
	}

	return 0;
}


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

int a[100010], b[100010];

int main() {
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(0);
	int n, k; cin >> n >> k;
	for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
	vector<int> v;
	v.push_back(k);
	for (int i = 0; i <= 30; i++) {
		int mask = 1 << i;
		if (k & mask) {
			int tmp = k ^ mask;
			tmp |= mask - 1;
			v.push_back(tmp);
		}
	}
	int64_t ans = 0;
	for (int kk: v) {
		int64_t res = 0;
		for (int i = 0; i < n; i++) {
			if ((a[i] | kk) == kk) {
				res += b[i];
			}
		}
		ans = max(ans, res);
	}
	cout << ans;
}


Measured memory_bytes: 1024
import sys
from bisect import bisect_left

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n = ni()

upper = [-1]*(2*n)
nxs = [0]*(2*n)
for i in range(n):
    nxs[i] += 1

def root(x):
    if upper[x] < 0:
        return x
    else:
        upper[x] = root(upper[x])
        return upper[x]

def equiv(x, y):
    return root(x) == root(y)

def unite(x, y):
    x, y = root(x), root(y)
    if x != y:
        if upper[y] < upper[x]:
            x, y = y, x
        upper[x] += upper[y]
        nxs[x] += nxs[y]
        upper[y] = x
    return x == y



co = []

for i in range(n):
    co.append(na())

xs = list(set(_[0] for _ in co))
xs.sort()

ys = list(set(_[1] for _ in co))
ys.sort()

for c in co:
    unite(bisect_left(xs, c[0]), bisect_left(ys, c[1])+n)

ans = 0
for i in range(2*n):
    if upper[i] < 0:
        ans += nxs[i] * (-upper[i] - nxs[i])
ans -= n
print(ans)


Measured memory_bytes: 116700
n = int(input())
happy = [list(map(int, input().split())) for i in range(n)]

ans = []
ans.append(happy[0])

for i in range(1, n):
    ans.append( [max(ans[i-1][(j+1)%3] + happy[i][j], ans[i-1][(j+2)%3] + happy[i][j]) for j in range(3)] )

print(max(ans[n-1]))

Measured memory_bytes: 47324
/*deco loves Chino*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
int fib[1100];
vector<pair<int,int> > ans[1100];
const int mod=1e9+7;
signed main()
{
	fib[0]=fib[1]=1;
	for(int i=2;i<=90;i++)
	{
		fib[i]=fib[i-1]+fib[i-2];
	}
	ans[1].push_back(make_pair(1,2)),ans[1].push_back(make_pair(1,3));
	for(int i=1;i<=87;i++)
	{
		for(int j=0;j<ans[i].size();j++)
		{
			pair<int,int> qwq=ans[i][j];
			int dx=qwq.second,dy=qwq.first+dx;
			while(dy<=fib[i]+fib[i+3])
			{
				ans[i+1].push_back(make_pair(dx,dy));
				dy+=dx;	
			} 
		}
	}
	int t;
	cin>>t;
	while(t--)
	{
		int n,m;
		scanf("%lld%lld",&n,&m);
		if(n>m)
		{
			swap(n,m);
		}
		int now=1;
		while(fib[now+1]<=n&&fib[now+2]<=m)
		{
			++now;
		}
		cout<<now<<" ";
		if(now==1)
		{
			cout<<n*m%mod<<"\n";
			continue;
		}
		int anss=0;
		for(int i=0;i<ans[now-1].size();i++)
		{
			pair<int,int> qwq=ans[now-1][i];
			if(qwq.second<=m)
			{
				anss+=((n-qwq.first)/qwq.second)%mod;
			}
			if(qwq.second<=n)
			{
				anss+=((m-qwq.first)/qwq.second)%mod;
			}
			anss%=mod;
		}
		cout<<anss<<"\n";
	} 
}


Measured memory_bytes: 4096
package main

import (
	"fmt"
)

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

	for _, c := range s {
		x := c + int32(n)
		if x > 90 {
			x -= 26
		}
		fmt.Printf("%c", x)
	}
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define double long double
#define rep(i, n) for (ll i = 0; i < n; i++)
#include <math.h> /* M_PI */
#define INF 2147483647
vector<long long> ret;
void divisor(long long n)
{
    vector<long long> ret1;
    ret = ret1;

    for (long long i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end()); // 昇順に並べる
}
int main()
{
    ll n;
    cin >> n;
    set<ll> data;

    vector<ll> A(n);
    map<ll, ll> most;
    rep(i, n)
    {
        ll a = 0;
        cin >> a;
        A[i] = a;
        most[a] += 1;
        data.insert(a);
    }
    int flag = 1;
    ll ans = 0;
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    rep(i, n)
    {
        if (most[A[i]] >= 2)
        {
            continue;
        }
        flag = 1;
        data.erase(A[i]);
        if (i != n - 1)
        {
            if (A[i] > A[i + 1])
            {
                //data.erase(A[i]);
            }
        }
        if (i == n - 1)
        {
            if (A[i - 1] > A[i])
            {
                ans += 1;
                break;
            }
        }
        flag = 1;
        divisor(A[i]);
        for (int x : ret)
        {
            if (data.count(x) == 1) //入っていたら1
            {
                flag = 0;
                break;
            }
        }
        //cout << A[i] << endl;
        if (flag == 1)
        {

            ans += 1;
        }
        data.insert(A[i]);
    }
    cout << ans;
}

Measured memory_bytes: 26528
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>

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

using namespace std;

int main() {
  while(1){
    int h,w;
    cin>>h>>w;
    if(!h)break;
    tuple<int,int> res(190,190);
    for(int i = 1;i <= 190;++i){
      for(int j = i+1;j <= 190;++j){
        if(i*i+j*j>h*h+w*w||(i*i+j*j==h*h+w*w&&i>h)){
          int k,l;
          tie(k,l)=res;
          if(i*i+j*j<k*k+l*l||(i*i+j*j==k*k+l*l&&i<k)){
            res=make_tuple(i,j);
          }
        }
      }
    }
    cout<<get<0>(res)<<' '<<get<1>(res) <<endl;
  }
  return 0;
}

Measured memory_bytes: 1160
// And in the end, the love you take is equal to the love you make.
//                      Paul McCartney (the Beatles). The End. Abbey Road.

#include <bits/stdc++.h>
using namespace std;

using LL = long long;

namespace _buff {

const size_t BUFF = 1 << 19;
char ibuf[BUFF], *ib = ibuf, *ie = ibuf;
char getc() {
  if (ib == ie) {
    ib = ibuf;
    ie = ibuf + fread(ibuf, 1, BUFF, stdin);
  }
  return ib == ie ? -1 : *ib++;
}

}

LL read() {
  using namespace _buff;
  LL ret = 0;
  bool pos = true;
  char c = getc();
  for (; (c < '0' || c > '9') && c != '-'; c = getc()) {
    assert(~c);
  }
  if (c == '-') {
    pos = false;
    c = getc();
  }
  for (; c >= '0' && c <= '9'; c = getc()) {
    ret = (ret << 3) + (ret << 1) + (c ^ 48);
  }
  return pos ? ret : -ret;
}

const size_t N = 1e6 + 5;
const int MOD = 1e9 + 7;

int qpow(int base, int e) {
  int ret = 1;
  for (; e; e >>= 1) {
    if (e & 1) {
      ret = (LL) ret * base % MOD;
    }
    base = (LL) base * base % MOD;
  }
  return ret;
}

int f[N], pre[N];

int main() {
  int n = read(), h = read(), d = read();

  int fac = 1, sum = 0;
  for (int i = 1; i <= n; ++i) {
    fac = (LL) fac * i % MOD;
    sum = (sum + fac) % MOD;
  }

  f[0] = pre[0] = 1;
  for (int i = 1; i <= h; ++i) {
    f[i] = (LL) (pre[i - 1] - (i >= d + 1 ? pre[i - d - 1] : 0)) * sum % MOD;
    pre[i] = (pre[i - 1] + f[i]) % MOD;
  }

  if (f[h] < 0) f[h] += MOD;
  cout << (LL) f[h] * fac % MOD * qpow(sum, MOD - 2) % MOD << endl;
  return 0;
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 1000000000000000000
#define int long long int

signed main(void)
{
    int X, Y;
    cin >> X >> Y;
    if(abs(X-Y) <= 1){
        cout << "Brown";
    } else {
        cout << "Alice";
    }

    return 0;
}

Measured memory_bytes: 256