akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}cout<<endl;}
vector<ll> divv(ll n);

int main() {
    ll n,k;
    string s;
    cin>>n>>k>>s;
    rep(i, s.size()) if(i+1 == k ) s[i] = s[i] - ('A'-'a');
    pr(s);
    return 0;
}

// return sorted 約数s 1 <= x <= n
vector<ll> divv(ll n) {
  vector<ll> v;
  for(ll i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.push_back(i);
      if(i*i != n) v.push_back(n/i);
    }
  }
  sort(alll(v));
  return v;
}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(a, b);
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

Measured memory_bytes: 888
l=[0,1e2]
gets.to_i.times{l=[0]+l.each_cons(2).flat_map{|i,j|d=(j-i)/3;[i+d,i+d+d*Complex(1,3**0.5)/2,i+d*2,j]}}
puts l.map{|i|i.rect*" "}

Measured memory_bytes: 6608
/**
*    author:  souzai32
*    created: 02.08.2020 15:25:02
**/

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

int main() {

    int n;
    cin >> n;
    vector<long long int> a(n),b(n);
    rep(i,n) cin >> a.at(i) >> b.at(i);

    long long int ans=0;
    int num;
    for(int i=n-1; i>=0; i--){
        a.at(i)+=ans;
        num=a.at(i)%b.at(i);
        if(num) num=b.at(i)-num;
        ans+=num;
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int x, y;
  bool c=false, d=false, e=false;
  cin >> x >> y;
  c = x%3, d = y%3, e = (x+y)%3;
  cout << (c*d*e == 0 ? "Possible" : "Impossible") << endl;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
ll a[300010];
ll mx[300010],mn[300010];
multiset<ll> st;
ll res=-1e18;
int main()
{
	scanf("%d",&n);
	for (int i=0;i<n*3;i++) scanf("%lld",&a[i]);
	for (int i=0;i<n;i++) mx[n-1]+=a[i],st.insert(a[i]);
	for (int i=n;i<n*3;i++)
	{
		if (*st.begin()>=a[i]) mx[i]=mx[i-1];
		else
		{
			mx[i]=mx[i-1]-(*st.begin())+a[i];
			st.erase(st.begin());
			st.insert(a[i]);
		}
		//cout <<i+1<<" "<<mx[i]<<" ##\n";
	}
	//cout <<"\n";
	st.clear();
	for (int i=n*3-1;i>=n*2;i--) mn[n*2]+=a[i],st.insert(-a[i]);
	for (int i=n*2-1;i>=0;i--)
	{
		if (*st.begin()>=-a[i]) mn[i]=mn[i+1];
		else
		{
			mn[i]=mn[i+1]+(*st.begin())+a[i];
			st.erase(st.begin());
			st.insert(-a[i]);
		}
		//cout <<i+1<<" "<<mn[i]<<" ##\n";
	}
	for (int i=n-1;i<n*2;i++) res=max(res,mx[i]-mn[i+1]);
	printf("%lld",res);
	return 0;
} 

Measured memory_bytes: 11520
def main():
  N, M = list(map(lambda n: int(n), input().split(" ")))
  if M == 0:
    print("0 0")
    return 0

  AC = [0] * N
  WA = [0] * N

  for i in range(M):
    tmp = input().split(" ")
    No = int(tmp[0]) - 1
    if tmp[1] == "AC":
      AC[No - 1] = 1
    if tmp[1] == "WA" and AC[No - 1] == 0:
      WA[No - 1] += 1
  
  totAC = sum(AC)
  totWA = sum([AC[i] * WA[i] for i in range(len(AC))])
  print(totAC, end=" ")
  print(totWA)
    
main()


Measured memory_bytes: 11388
#include <iostream>
#include <string>

#define N 3

int main(void)
{
    std::string forcast;
    std::string result;
    int  Hit = 0;

    std::cin >> forcast;
    std::cin >> result;
    
    for(int i = 0; i < N; i++)
    {
        if(forcast[i] == result[i]){
            Hit++;
        }
    }
    std::cout << Hit <<std::endl;
    return 0;
}

Measured memory_bytes: 256
#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 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 int INF = (1<<30)-1;
//const ll INF = (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;}
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; }

int main () {
  int a, b, c;
  cin >> a >> b >> c;
  bool poor = false;
  if (a == b && b != c) poor = true;
  if (b == c && c != a) poor = true;
  if (c == a && a != b) poor = true;
  if (poor) yn;
  return 0;
}

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

const int max_n=2020;
vector<int> L;
int main(){
    int n;
    cin >>n;
    rep(i,n){
        int tmp;cin>>tmp;L.emplace_back(tmp);
    }
    sort(L.begin(),L.end());
    int ans =0;
    for(int i=n-1;i>1;i--){
        for(int j=i-1;j>0;j--){
            int v=j-(lower_bound(L.begin(),L.end(),L[i]-L[j]+0.1)-L.begin());
            ans+=max(v,0);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
const double PI=4*atan(1);
using namespace std;
#define MOD 1000000007

int findmin(int a,int b) {
    return a<b?a:b;
}
int findmax(int a,int b) {
    return a>b?a:b;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char ch;
    cin>>ch;
    if(isupper(ch)) {
		cout<<"A\n";
	}
	else {
		cout<<"a\n";
	}
    cout.flush();
    return 0;
}


Measured memory_bytes: 3576
N = int(input())
A = tuple(map(int,input().split()))
mod = 10**9+7
B = [0]*N
for i in range(N):
    B[i] = A[i]**2
s1, s2 = 0, 0 
for i in range(N):
    s1 += A[i]
    s2 += B[i]
s1 = s1**2
ans = (s1 -s2)//2%mod
print(ans)

Measured memory_bytes: 31760
#include<stdio.h>
#define nyan(a,b) ((a)>(b)?(a):(b))
#define nyaa(a,b) ((a)+(b)-1)/(b)

int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  printf("%d\n",nyaa(c,nyan(a,b)));
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(){

	int nn,mm;
	int ss[51][2];
	int ans;
	int i,j;

	scanf("%d %d",&nn,&mm);

	for(i=0;i<mm;i++){
		scanf("%d %d",&ss[i][0],&ss[i][1]);
	}

	for(j=1;j<=nn;j++){
		ans = 0;
		for(i=0;i<mm;i++){
			if(ss[i][0] == j) ans++;
			if(ss[i][1] == j) ans++;
		}
		printf("%d\n",ans);
	}
}


Measured memory_bytes: 128
#include <stdio.h>
  
 #define N 8
 #define FREE 0
 #define NOT_FREE 1
  
 void putQueen(int);
 void PrintBoard(void);
  
 int Queen[N][N];
 int dpos[2*N-1];
 int dneg[2*N-1];
 int row[N];
 int col[N];
  
 int main(){
  
 int i;
 int n;
 int q_row;
 int q_col;
  
 scanf("%d",&n);
  
 for(i=0;i<n;i++){
 scanf("%d%d",&q_row,&q_col);
 Queen[q_row][q_col] = NOT_FREE;
 }
  
 putQueen(0);
  
   return 0;
}
void putQueen(int i){
  
 int j;
  
 if(i==N){
 PrintBoard();
 return;
 }
  
 for(j=0;j<N;j++){
 if(col[j]==NOT_FREE || dpos[i+j]==NOT_FREE || dneg[i-j+N-1]==NOT_FREE) continue;
  
 row[i] = j;
 col[j] = dpos[i+j] = dneg[i-j+N-1] = NOT_FREE;
 putQueen(i+1);
  
 col[j] = dpos[i+j] = dneg[i-j+N-1] = FREE;
 }
  
}
void PrintBoard(void){
  
 int i;
 int j;
  
 for(i=0;i<N;i++){
  for(j=0;j<N;j++){
  
 if(Queen[i][j]==NOT_FREE){
    if(row[i]!=j) return;
    }
  
   }
  }
  
 for(i=0;i<N;i++){
  for(j=0;j<N;j++){
  
 if(row[i]==j){
  printf("Q");
   }
  
 else{
  printf(".");
   }
  
   }
  printf("\n");
   }
 }

Measured memory_bytes: 572
N,M = map(int,input().split())
A = list(map(int,input().split()))
S = sum(A) #総得票数
A.sort(reverse = True) #票数の大きい順に並べる
if A[M-1] >= S / (4*M) : print("Yes") #この条件より大きい要素が(M-1)個あれば題意を満たす
else :print("No")

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
using namespace std;
#define sci(n) scanf("%lld", &(n))
#define scd(n) scanf("%Ld", &(n))
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> pll;
int main(void)
{	
	LL n, k; sci(n); sci(k);
	vector<LL> tr; tr.resize(n);
	LL mn = 10e9;
	for (int i = 0; i < n; i++) { sci(tr[i]); }
	sort(tr.begin(), tr.end());
	for (int i = 0; i <= n - k; i++) { mn = min(mn, abs(tr[i] - tr[i + k-1])); }
	cout << mn;
	return 0;
}

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

int main() {
  
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;

  cout << (char)(s1.at(0)-32) << (char)(s2.at(0)-32) << (char)(s3.at(0)-32) << endl; 
  
return 0;
}

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

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

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

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 adder (i: usize, j: usize) -> isize{
    let mut pow: usize = 1;
    for k in 1..i {
        pow *= 10;
    }
    (pow * j) as isize
}

fn main(){
    input!{
        a: i64,
        b: i64
    }
    for i in 1..1009{
        if (i as f64 * 0.08) as i64 == a && b == (i as f64 * 0.1) as i64 {
            print!("{}", i);
            return
        }
    }
    print!("{}", -1)
}


Measured memory_bytes: 4352
#include<stdio.h>
#define N 20
#define TRUE 1
#define FALSE 0
void rec(int);
int solve(int,int);
int s[N];
int n,q;
int m[200];
int a[N];
int flag[200];
int main(){
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m[i]);
    flag[i]=0;
  }
  for(i=0;i<n;i++){
  s[i]=0;
  }
  rec(0);
  
  for(i=0;i<q;i++){
    if(flag[i]==1)printf("yes\n");
    else printf("no\n");
  }

  return 0;
}
void rec(int i){
  int j,sum=0;
  if(i==n){
    for(j=0;j<q;j++){
      if(solve(0,m[j]))flag[j]=1;
    }
    return;
  }
  rec(i+1);
  s[i]=1;
  rec(i+1);
  s[i]=0;
}
int solve(int i,int m){
  int res;
  if(m==0)
    return TRUE;
  if(i>=n) return FALSE;
  if(s[i]==1)res=solve(i+1,m-a[i]);
    else res=solve(i+1,m);
    return res;
}
  
 



Measured memory_bytes: 2104
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const long long INFL = 2e18;
const int MOD = 1000000007;
const long long MAX = 1000100;
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 main(){
	COMinit();
	int H,W,A,B;
	cin >> H >> W >> A >> B;

	vector<ll> c(H-A+1,0);

	for(int i = 1;i <= H-A;i++){
		c[i] = COM(i-1+B-1,B-1);
	}

	vector<ll> d(H-A+1,0);
	for(int i = 1;i <= H-A;i++){
		d[i] = COM(H-i+W-B-1,H-i);
	}


	ll ans = 0;
	for(int i = 1;i <= H-A;i++){
		ans += c[i] * d[i] % MOD;
		ans %= MOD;
	}

	cout << ans << endl;
}


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

int arr[33] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
  int x; cin >> x;
  cout << arr[x-1];
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define TRACE(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr << endl;}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "[" << *it << " = " << a << "]";
	err(++it, args...);
}

#define MAXN ((ll)2e5+5)
#define MOD ((ll)1e9 + 7)
#define INF ((ll)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define LOG(x) if(DEBUG) cerr << x << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<ll,ll>
#define mid ((l+r)/2)

ll n,t;
ll br[30], p[30];

void precalc()
{
	br[0] = 1;
	p[0] = 1;
	for (int i = 1; i < 30; ++i)
	{
		br[i] = br[i-1]*26 + 1;
		p[i] = p[i-1]*26;
		// TRACE(i, br[i]);
	}
}

void solve()
{
	cin >> n;
	t = 10;

	while(t > 0)
	{
		ll ex = p[t];

		if(ex > n || ex > n - br[t-1])
		{
			// cout<<endl;
			t--; 
			continue;
		}

		ll k = 27;

		while(--k > 0)
		{
			if(k*ex > 0 && k*ex+br[t-1] > 0 && k*ex+br[t-1] <= n)
				break;
		}

		if(k > 0)
		{
			ll val = k * p[t];
			n -= val;
			cout << char('a' + (k-1));
		}

		t--;
	}

	if(n > 0)
		cout << char('a' + (n-1)) << endl;
}

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	precalc();
	solve();
}

/* stuff you should look for
	* ll overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(i=0;i<n;i++)
#define test(a) cout << "*" << a << endl
#define ll long long
int main(){
  int money[2];
  int moneyAB;
  int num[2];
  int numKyoutuu;
  int sum=0;
  int i;
  
  cin >> money[0] >> money[1];
  cin >> moneyAB;
  moneyAB *= 2;
  cin >> num[0] >> num[1];  
  //test(moneyAB);
  
  sum = min(money[0]+money[1],moneyAB) * min(num[0],num[1]);
  
  numKyoutuu = min(num[0],num[1]);
  num[0] -= numKyoutuu;
  num[1] -= numKyoutuu;
  
  if(num[0]>num[1])
    i = 0;  
  else
    i = 1;
  
  sum += num[i] * min(money[i],moneyAB);
    
  cout << sum << endl;
  
  //test(numA);
  //test(numB);

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long 
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
const int N=200005,mo=998244353;
char s[N];
int n,f[N][3][3][2],val;//i th, cur j, mod k, same l
inline void add(int &x,int y)
{x+=y; if(x>mo) x-=mo;}
bool chks()
{
	bool ret=1;
	for(int i=1;i<=n;i++)
	{
		val=(val+s[i]-'a')%3;
		if(s[i]!=s[1]) ret=0;
	}
	return ret;
}
int main()
{
	scanf("%s",s+1); n=strlen(s+1);
	if(chks()){printf("1\n");return 0;}
	if(n==2){printf("2\n");return 0;}
	if(n==3){
//		aab - acc - bbc - baa - cca - cbb | aab
//		abc - ccc
//		    - aaa
//		aba - cca ~ bba (+6)
//		    - acc (+0)
		if(s[1]!=s[2]&&s[2]!=s[3]&&s[3]!=s[1]) printf("3\n");
		else if(s[1]==s[3]) printf("7\n");
		else printf("6\n");
		return 0;
	}
	f[1][0][0][0]=f[1][1][1][0]=f[1][2][2][0]=1;
	for(int i=1;i<n;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<3;k++){
				for(int x=0;x<3;x++){
					int nxtmod=(k+x)%3;
					if(x!=j) add(f[i+1][x][nxtmod][0],f[i][j][k][0]);
					add(f[i+1][x][nxtmod][1],f[i][j][k][1]);
					if(x==j) add(f[i+1][x][nxtmod][1],f[i][j][k][0]);
				}
			}
		}
	}
	int ans=0;
	for(int i=0;i<3;i++)
	  add(ans,f[n][i][val][1]);
	int kd=1;
	for(int i=2;i<=n;i++)
	  if(s[i]==s[i-1]) kd=0;
	add(ans,kd);
	printf("%d\n",ans);
	return 0;
}


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

int main(){
    int N; cin >> N;
    string S,T; cin >> S >> T;
    rep(i,N) cout << S[i] << T[i];
    cout << endl;
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ a=max(a,b);}

int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, k, s;
	cin >>n >>k >>s;
	
	int LM = 1e9;
	if(s==LM) {
		rep(i, k) cout<< LM <<" ";
		rep(i, n-k) cout <<1 <<" ";
		cout <<"\n";
		return 0;
	}
	
	VI ans;
	rep(i, k) ans.push_back(s);
	rep(i, n-k) ans.push_back(LM);
	rep(i, n) cout <<ans[i] <<"\n";
	return 0;
}


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


int gcd(int a, int b){
    int r, tmp;
    /* 自然数 a > b を確認・入替 */
    if(a<b){
        tmp = a;
        a = b;
        b = tmp;
    }
  /* ユークリッドの互除法 */
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main(void)
{
    int K;
    cin >> K;
    int sum = 0;
    for(int i = 1; i <= K; i++){
        for(int j = 1; j <= i; j++){
            for(int k = 1; k <= j; k++){
                int d = gcd(i,j);
                int e = gcd(d,k);
                if(i == j && j == k){
                    sum += e;
                }else if(i == j || j == k || k== i){
                    sum += 3*e;
                }else{
                    sum += 6*e;
                }
            }
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3620
#include<cstdio>
#include<vector>
#include<deque>
#include<utility>

using namespace std;


typedef unsigned int ui;
typedef vector<int> edge_t;


class vertex_t
{
	public:
	int m_is_passed;
	vector<int> m_edge;
};


int main(void)
{
	vector<vertex_t> vertex;
	deque<int> result;
	ui n, m, a, b, c=1;
	ui i, j;

	while(scanf("%u%u", &n, &m)==2)
	{
		result.clear();
		vertex.clear();
		vertex.resize(n+1);
		for(i=0;i<m;i++)
		{
			scanf("%u%u", &a, &b);
			vertex[a].m_edge.push_back(b);
			vertex[b].m_edge.push_back(a);
		}
		for(i=1;i<=n;i++)
		{
			if(vertex[i].m_edge.size())
			{
				c=i;
				break;
			}
		}

		for(i=c;;)
		{
			edge_t& edge=vertex[i].m_edge;
			vertex[i].m_is_passed=1;
			result.push_front(i);
			for(j=0;j<edge.size();j++)
			{
				if(!vertex[edge[j]].m_is_passed)
				{
					i=edge[j];
					break;
				}
			}
			if(j>=edge.size()) break;
		}

		result.pop_back();
		for(i=c;;)
		{
			edge_t& edge=vertex[i].m_edge;
			vertex[i].m_is_passed=1;
			result.push_back(i);
			for(j=0;j<edge.size();j++)
			{
				if(!vertex[edge[j]].m_is_passed)
				{
					i=edge[j];
					break;
				}
			}
			if(j>=edge.size()) break;
		}

		printf("%u\n%d", result.size(), result[0]);
		for(i=1;i<result.size();i++)
		{
			printf(" %d", result[i]);
		}
		printf("\n");
	}

	return 0;
}


Measured memory_bytes: 7424
n,m=map(int,input().split())
p=list(map(int,input().split()))
class UnionFind():
    def __init__(self,n):
        self.n=n
        self.root=[-1]*(n+1)
        self.rnk=[0]*(n+1)

    def Find_Root(self,x):
        if self.root[x]<0:
            return x
        else:
            self.root[x]=self.Find_Root(self.root[x])
            return self.root[x]

    def Unite(self,x,y):
        x=self.Find_Root(x)
        y=self.Find_Root(y)
        if x==y:
            return
        elif self.rnk[x]>self.rnk[y]:
            self.root[x]+=self.root[y]
            self.root[y]=x
        else:
            self.root[y]+=self.root[x]
            self.root[x]=y
            if self.rnk[x]==self.rnk[y]:
                self.rnk[y]+=1

    def isSameGroup(self,x,y):
        return self.Find_Root(x)==self.Find_Root(y)

    def Count(self,x):
        return -self.root[self.Find_Root(x)]

UF=UnionFind(n)
for i in range(m):
    x,y=map(int,input().split())
    UF.Unite(x,y)
ans=0
for i in range(n):
    if UF.isSameGroup(i+1,p[i]):
        ans+=1
print(ans)


Measured memory_bytes: 93420
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<stack>
#include<cmath>
#include<algorithm>
#include<map>
typedef long long ll;
using namespace std;
#define INF 0x3f3f3f3f
/**
*超时有可能是输入的问题
*注意边界
*仔细读题
*没思路试试逆向思维
**加油，奥利给！！！ 
**/
queue<int>q;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
map<int,int>p;
/*struct knd{
	int x,y,z;
}s[200000];*/ 
int a[200000];
int main()
{
	int m,n,i,j,t,k,s=0;
	cin>>n;
	for(i=1;i*i<n;i++)
	{
		for(j=i;i*j<n;j++)
		{
			if(i*j<n)
			{
				if(i==j) s++;
				else s+=2;
			}
		}
	}
	cout<<s;
 } 

Measured memory_bytes: 3636
def f(exponent):
	#reurns how many times a prime raised to exponent can be used
	step = 1
	cumul = 0
	count = 0
	while( cumul <= exponent):
		cumul += step
		count +=1
		step +=1
	return count - (1 if cumul > exponent else 0)

def answer(n):
	if n == 1: return 0
	res = 0
	for d in range(2, int(n ** 0.5) + 2):
		if n % d == 0:
			e = 0
			while(n%d == 0): 
				e +=1
				n/=d
			res+= f(e)
	if n > 1: res += 1
	return res

print answer(int(raw_input()))

Measured memory_bytes: 66116
import std.stdio, std.string, std.conv, std.bigint, std.typecons, std.algorithm, std.array, std.math, std.range;
 
void main() {
    auto tmp = readln.split.to!(int[]);
    auto N = tmp[0], M = tmp[1];
    int[][] edges;
    int[][] connection;
    connection.length = N;
    foreach (i; 0..M) {
        tmp = readln.split.to!(int[]);
        edges ~= [tmp[0]-1, tmp[1]-1];
        connection[tmp[0]-1] ~= tmp[1]-1;
        connection[tmp[1]-1] ~= tmp[0]-1;
    }
    edges.filter!((excludedEdge) {
        auto vertex = [0];
        while (vertex.length < N) {
            auto bcnt = vertex.length;
            foreach (v; vertex) {
                foreach (next; connection[v]) {
                    if (v == excludedEdge[0] && next == excludedEdge[1]) continue;
                    if (v == excludedEdge[1] && next == excludedEdge[0]) continue;
                    if (vertex.canFind(next)) continue;
                    vertex ~= next;
                }
            }
            if (bcnt == vertex.length) {
                return true;
            }
        }
        return false;
    }).array.length.writeln;
}

Measured memory_bytes: 256
#include<iostream>;

using namespace std;

int main()
{
	int X;
	cin >> X;
	if (X % 7 == 1)
		cout << "fri" <<endl;
	else if (X % 7 == 2)
		cout << "sat" <<endl;
	else if (X % 7 == 3)
		cout << "sun" <<endl;
	else if (X % 7 == 4)
		cout << "mon" <<endl;
	else if (X % 7 == 5)
		cout << "tue" <<endl;
	else if (X % 7 == 6)
		cout << "wed" <<endl;
	else if (X % 7 == 0)
		cout << "thu" <<endl;
	return 0;
}


Measured memory_bytes: 3112
#include<bits/stdc++.h>
using namespace std;
#define Max 100005
#define stable 2000000000
int n;
struct node{
	char huase;
	int num;
};
node L[Max/2+2],R[Max/2+2],B[Max],C[Max];

void merge(node A[],int left,int mid,int right)
{
	int n1,n2;
	n1 = mid - left;
	n2 = right- mid;
	for(int i = 0;i<n1;i++) L[i] = A[left+i];
	for(int i=0;i<n2;i++) R[i] = A[mid+i];
	L[n1].num = stable;
	R[n2].num = stable;
	int i=0,j=0;
	for(int k=left;k<right;k++)
	{
		if(L[i].num<=R[j].num)
			A[k] = L[i++];
		else 
			A[k] = R[j++];
	}
 } 
 
void mergeSort(node A[],int left,int right)
{
	if(left+1<right)
	{
		int mid = (left+right)/2;
		mergeSort(A,left,mid);
		mergeSort(A,mid,right);
		merge(A,left,mid,right);
	}
	
}

int partition(node A[],int p,int r)
{
	int X = A[r].num;
	int i = p-1;
	for(int j=p;j<r;j++)
	{
		if(A[j].num<=X)
		{
			swap(A[++i],A[j]);
		}
	}
	swap(A[++i],A[r]);
	return i;	
}

void quickSort(node A[],int p,int r)
{
	if(p<r)
	{
		int q =partition(A,p,r);
		quickSort(A,p,q-1);
		quickSort(A,q+1,r);
	}
}

int main()
{
	cin>>n;
	int nm;
	char c;
	int flag = 1;
	for(int i=0;i<n;i++)
	{
		cin>>c>>nm;
		B[i].num = nm;
		B[i].huase = c;
		C[i].num = nm;
		C[i].huase = c;
	}
	mergeSort(B,0,n);  //right不包括 
	quickSort(C,0,n-1);  //right包括 
	for(int i=0;i<n;i++)
	{
		if(B[i].huase!=C[i].huase)
		{
			flag =0;
			break;
		}
	}
	if(flag)
		cout<<"Stable"<<endl;
	else 
		cout<<"Not stable"<<endl;
	for(int i =0;i<n;i++)
		cout<<C[i].huase<<' '<<C[i].num<<endl;
	return 0;
	 
	
	
}








 
 
 


Measured memory_bytes: 5360
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	int n, m;
	cin >> n >> m;
	int load[n+1][n+1] = {0};
	for(int i = 0; i < m; i++){
		int a, b;
		cin >> a >> b;
		load[a][b] += 1;
		load[b][a] += 1;
	}
	int ans[n + 1] = {0};
	for(int i = 0; i < n+1; i++){
		for(int j = 0; j < n+1; j++){
			ans[i] += load[i][j];
		}
	}
	for(int i = 1; i < n + 1; i++)cout << ans[i] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<array>
#include<functional>
#include<iomanip>
#include<ios>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)

typedef int value_type; /* ソートするキーの型 */

value_type med3(value_type x, value_type y, value_type z)
/* x, y, z の中間値を返す */
{
    if (x < y)
        if (y < z) return y; else if (z < x) return x; else return z; else
        if (z < y) return y; else if (x < z) return x; else return z;
}

void quicksort(value_type a[], int left, int right,value_type index[])
/* クイックソート
 * a     : ソートする配列 
 * left  : ソートするデータの開始位置
 * right : ソートするデータの終了位置
 * index: index配列
 */
{
    if (left < right) {
        int i = left, j = right;
        value_type tmp, pivot = med3(a[i], a[i + (j - i) / 2], a[j]); /* (i+j)/2ではオーバーフローしてしまう */
        while (1) { /* a[] を pivot 以上と以下の集まりに分割する */
            while (a[i] < pivot) i++; /* a[i] >= pivot となる位置を検索 */
            while (pivot < a[j]) j--; /* a[j] <= pivot となる位置を検索 */
            if (i >= j) break;
            tmp = a[i]; a[i] = a[j]; a[j] = tmp; /* a[i],a[j] を交換 */
            tmp = index[i]; index[i] = index[j]; index[j] = tmp;
            i++; j--;
        }
        quicksort(a, left, i - 1,index);  /* 分割した左を再帰的にソート */
        quicksort(a, j + 1, right,index); /* 分割した右を再帰的にソート */
    }
}


int dfs(int n,int N){
    if (n>N){
        return 0;
    }
    

    int ret;
    
    return ret;
}
int main(){
    int A,B;
    cin >>A>>B;
    int ans;
    if(A>B){
        ans=A+(A-1);
    }else if(B>A){
        ans=B+(B-1);
    }else{
        ans=A+B;
    }
    std::cout << ans<< endl;
    return 0;
}

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

vector<vector<int>> G;

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

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

  priority_queue<int> que;
  for (int i = 0; i < n; i++) {
    int c; cin >> c;
    que.push(c);
  }

  queue<int> q;
  vector<int> visited(n, false);
  q.push(0);
  visited[0] = true;

  vector<int> answer(n);
  answer[0] = que.top();
  que.pop();

  int sum = 0;
  while(!q.empty()) {
    int from = q.front();
    q.pop();

    for (int i = 0; i < (int)G[from].size(); i++) {
      int to = G[from][i];
      if(visited[to]) continue;
      answer[to] = que.top();
      sum += que.top();
      que.pop();
      visited[to] = true;
      q.push(to);
    }
  }

  cout << sum << '\n';
  for (auto it : answer) {
    cout << it << " ";
  }
  cout << '\n';
}


Measured memory_bytes: 4104
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

int main()
{
//	cut here before submit 
//	freopen("testcase.bottom", "r", stdin);
	string str = "";
	while (getline (cin, str ) ){
		if (str.empty() ){
			break;
		} // end if
		vector <vector <int> > n (10, vector <int> (10, 0 ) );
		int i,j;

		for (i = 0; i < 10; ++i){
			n[0][i] = str[i] - '0';
		} // end for
		
		for (i = 0; i < 9; ++i){
			for (j = 0; j < 9 - i; ++j){
				n[i+1][j] = (n[i][j] + n[i][j+1]) % 10;
			} // end for
		} // end for
/*
		for (i = 0; i < 10; ++i){
			for (j = 0; j < 10; ++j){
				cout << n[i][j] << ' ';
			} // end for
			cout << endl;
		} // end for
		cout << endl;
*/
		cout << n[9][0] << endl;

	} // end loop
		
	return 0;
}

Measured memory_bytes: 0
// author: Saman Mahdanian
#include <bits/stdc++.h>

using namespace std;
const int N = 5e5 + 10;
const int MOD = 1e9 + 7;

void _psum (int &, int);
int _sum (int, int);
int _mul (int, int);
int _pow (int, int);
int gcd (int, int);

int n, m, k, inv[N], f[N], res[N];
vector <int> X;

int x[] = {0, 0, -1, +1};
int y[] = {-1, +1, 0, 0};
string s[N];

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

	cin >> n >> m;
	for (int i = 0; i < n; i++)
		cin >> s[i];

	auto is_val = [&] (int x, int y) {
		return x < n && y < m && min(x, y) >= 0;
	};

	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++)
			if (s[i][j] == '#') {
				bool res = false;
				for (int d = 0; d < 4; d++)
					if (is_val(i + x[d], j + y[d]))
						res |= (s[i + x[d]][j + y[d]] == '#');
				if (!res) 
					return cout << "No" << endl, 0;
			}
	cout << "Yes" << endl;
}

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

// int choose (int r, int k) {
// 	return _mul (f[k], _mul(inv[r], inv[k - r]));
// }

void _psum (int &a, int b) {
	a += b;
	if (a >= MOD)
		a -= MOD;
}

int _sum (int a, int b) {
	return a + b - (a + b >= MOD? MOD : 0);
}

int _mul (int a, int b) {
	return 1LL * a * b % MOD;
}

int _pow (int a, int b) {
	if (!b) 
		return 1;
	int res = _pow (a, b >> 1);
	res = _mul (res, res);
	if (b & 1)
		res = _mul (res, a);
	return res;
}

// SamMHD :: Jun27-2019 :: Another Day with Shayan...

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;

signed main(){
  int x;
  cin>>x;
  int ans=0;
  loop(i,1,40){
    loop(j,2,10){
      int tmp=pow(i,j);
      if(tmp<=x)ans=max(ans,tmp);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ull = uint64_t;
const ll INF = 9e18;

void print() { cout << endl; }
template <typename Head, typename... Tail>
void print(Head head, Tail... tail) {
    int size = sizeof...(Tail);
    cout << head;
    if (size > 0) {
        cout << " ";
    }
    print(tail...);
}

void print0() {}
template <typename Head, typename... Tail>
void print0(Head head, Tail... tail) {
    cout << head;
    print0(tail...);
}

vector<ll> mkprimes(ll N) {
    vector<bool> isprime(N + 1);
    vector<ll> primes;
    for (ll i = 0; i <= N; i++) {
        isprime[i] = true;
    }
    isprime[0] = false;
    isprime[1] = false;

    for (ll i = 2; i <= N; i++) {
        if (isprime[i]) {
            primes.push_back(i);
            for (ll j = 2 * i; j <= N; j += i) {  // 素数iの倍数は素数ではない
                isprime[j] = false;
            }
        }
    }
    return primes;
}

vector<vector<ll>> prime_factors(ll m) {
    vector<vector<ll>> result(m + 1);

    vector<ll> primes = mkprimes(m);
    vector<bool> isprime(m + 1, false);
    for (auto p : primes) {
        isprime[p] = true;
    }

    for (ll nn = 2; nn <= m; nn++) {
        if (isprime[nn]) {
            result[nn].push_back(nn);
            continue;
        }
        ll n = nn;
        for (auto p : primes) {
            if (n % p == 0) {
                bool exist = false;
                for (ll pp : result[n / p]) {
                    if (pp == p) {
                        exist = true;
                    }
                    result[n].push_back(pp);
                }
                if (!exist) {
                    result[n].push_back(p);
                }
                break;
            }
        }
    }
    return result;
}

int main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    ll maxval = 1000000;
    vector<vector<ll>> pfs = prime_factors(maxval);

    {
        bool pc = true;
        vector<bool> used(maxval + 1, false);
        for (ll i = 0; i < N; i++) {
            ll n = A[i];
            for (auto pf : pfs[n]) {
                if (used[pf]) {
                    pc = false;
                    break;
                }
                used[pf] = true;
            }
            if (!pc) {
                break;
            }
        }
        if (pc) {
            print("pairwise coprime");
            return 0;
        }
    }
    {
        vector<ll> usecount(maxval + 1, 0);
        for (ll i = 0; i < N; i++) {
            ll n = A[i];
            for (auto pf : pfs[n]) {
                usecount[pf]++;
            }
        }
        ll maxusecount = 0;
        for (auto u : usecount) {
            maxusecount = max(maxusecount, u);
        }
        if (maxusecount == N) {
            print("not coprime");
            return 0;
        } else {
            print("setwise coprime");
            return 0;
        }
    }
}


Measured memory_bytes: 84912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define all(obj) (obj).begin(), (obj).end()
static const int dx[4] = { 0, 1, 0, -1 };
static const int dy[4] = { 1, 0, -1, 0 };
static const char dir[4] = { 'u', 'r', 'd', 'l' };
static const ll INF = 1 << 21;
static const ll MOD = 1e9 + 7;
int N;

signed main()
{
    cin >> N;
    vector<ll> A(N);
    ll ans = 0ll;
    rep(i, N)
    {
        cin >> A[i];
    }
    ll tmp = 0ll;
    rep(i, N)
    {
        if (A[i] != 0) {
            tmp += A[i];
        } else {
            ans += tmp / 2;
            tmp = 0;
        }
    }
    ans += tmp / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <set>
#include <queue>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

const int dx[6] = { 1, 0, -1, -1, 0, 1 };
const int dy[6] = { 0, -1, -1, 0, 1, 1 };
struct Point {
  int x, y, cost;
  Point(int x, int y, int cost) : x(x), y(y), cost(cost) {;}
  bool operator<(const Point &rhs) const {
    if (x != rhs.x) { return x < rhs.x; }
    return y < rhs.y;
  }
};

int main() {
  int t, n;
  while (scanf("%d %d", &t, &n), t|n) {
    set<Point> visit;
    REP(i, n) {
      int x, y;
      scanf("%d %d", &x, &y);
      visit.insert(Point(x, y, 0));
    }
    int sx, sy;
    scanf("%d %d", &sx, &sy);
    queue<Point> que;
    que.push(Point(sx, sy, 0));
    while (!que.empty()) {
      Point p = que.front();
      que.pop();
      if (visit.count(p)) { continue; }
      visit.insert(p);
      REP(dir, 6) {
        int nx = p.x + dx[dir];
        int ny = p.y + dy[dir];
        int ncost = p.cost + 1;
        if (ncost > t) { continue; }
        que.push(Point(nx, ny, ncost));
      }
    }
    printf("%d\n", (int)visit.size() - n);
  }
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int N;ll M;cin>>N>>M;
    ll x=M/N;
    ll ans=1;
    for(ll i=1;i*i<=M;i++){
        if(M%i==0){
            if(i<=x&&i>ans)ans=i;
            if(M/i<=x&&M/i>ans)ans=M/i;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import sys
readline=sys.stdin.readline

N=int(readline())
A=list(map(int,readline().split()))

ans = 0
cur = A[0]

for i in range(1, len(A)):
  if cur > A[i]:
    diff = cur - A[i]
    ans += diff
    A[i] += diff
  cur = A[i]

print(ans)

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

void solve(vector<string>& strings, int size)
{
	for (int i = 1; i < size; i++) {
		for (int j = 0; j < strings[i].size(); j++) {
			if (strings[i][j] == '+') {
				for (int k = i - 1; k >= 0; k--) {
					if (strings[k][j] != ' ') {
						break;
					}
					else {
						strings[k][j] = '|';
					}
				}
			}
		}
	}
}

int main()
{
	while (true) {
		int n;

		cin >> n;

		if (n == 0) {
			break;
		}

		vector<string> strings(n);

		for (int i = 0; i < n; i++) {
			cin >> strings[i];

			for (unsigned int j = 0; j < strings[i].size(); j++) {
				if (strings[i][j] == '.') {
					if (strings[i][j + 1] != '.') {
						strings[i][j] = '+';
					}
					else {
						strings[i][j] = ' ';
					}
				}
			}
		}

		solve(strings, n);

		for (int i = 0; i < n; i++) {
			cout << strings[i] << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
#include <vector>
#include <functional>
#include <queue>

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> P2;


int main(){
  P2 team[51];
  int wrongCount[51][11];
  
  string message;
  int T, P, R;
  int Tid, Pid, time;
  
  while(cin >> T >> P >> R){
    if(T == 0 && P == 0 && R == 0) break;
    
    memset(wrongCount, 0, sizeof(wrongCount));
    
    for(int i = 0 ; i < T ; i++){
      team[i].first = 0; // Correct count
      team[i].second.first = 0; // time count
      team[i].second.second = i+1; // team number
    }

    for(int i = 0 ; i < R ; i++){
      cin >> Tid >> Pid >> time >> message;
      
      Tid--;
      
      if(message == "CORRECT"){
	team[Tid].first++;
	team[Tid].second.first += wrongCount[Tid][Pid]*1200 + time;
      }
      else if(message == "WRONG") wrongCount[Tid][Pid]++;
    }
    
    for(int i = 0 ; i < T ; i++){
      team[i].second.first *= -1;
      team[i].second.second *= -1;
    }
    
    stable_sort(team, team+T);
    reverse(team, team+T);
  
    for(int i = 0 ; i < T ; i++){
      printf("%d %d %d\n", team[i].second.second*=-1, team[i].first, team[i].second.first*=-1);
    }
  }
  return 0;
}

Measured memory_bytes: 940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a,b;
	cin >> a >> b;
	if(a==b) cout <<"Draw" << endl;
	else if(a==1) cout << "Alice" << endl;
	else if(b==1) cout << "Bob" << endl;
	else{
	    if(a<b) cout << "Bob" << endl;
	    else cout << "Alice" << endl;
	}
}

Measured memory_bytes: 256
gcd = lambda a,b: a if b==0 else gcd(b,a%b)
n,m = map(int,input().split())
s = input()
t = input()
d = gcd(n,m)
if s[::n//d]==t[::m//d]:
    print(n*m//d)
else:
    print(-1)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           v.size()
#define		ss              ' '
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef		long long       ll;
typedef		vector<ll>      vll;


int main()
{
 //O_O ;
   ll t;
   string a;

   cin>>t;
   cin>>a;
   ll count=0;
   for(ll i=0;i<t;i++)
   {
       if(a[i]=='A'&&a[i+1]=='B'&&a[i+2]=='C')
        count++;
   }
   cout<<count<<nn;



    return 0;
}


Measured memory_bytes: 256
from sys import stdin

data = []
for i in range(5):
    data.append(int(stdin.readline().rstrip()))

cnt = 0
index = 0

max_i = 0
max_d = 0

for i in range(5):
    if (10 - (data[i] % 10)) % 10 > max_d:
        max_i = i
        max_d = (10 - (data[i] % 10)) % 10

data[max_i], data[4] = data[4], data[max_i]

while True:
    if cnt % 10 == 0:
        cnt += data[index]
        if index == 4:
            break
        index += 1
    else:
        cnt += 1

print(cnt)

Measured memory_bytes: 38384
package main

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

func nextInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	num, _ := strconv.Atoi(scanner.Text())
	return num
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	N := nextInt(scanner)
	A := make([]int, N)
	for i := 0; i < N; i++ {
		A[i] = nextInt(scanner)
	}
	fmt.Println(strings.Trim(fmt.Sprint(countingSort(A, N)), "[]"))

}

func countingSort(A []int, k int) []int {
	B := make([]int, k)
	C := make([]int, 10000)

	for _, v := range A {
		C[v]++
	}

	for i := 1; i < len(C); i++ {
		C[i] = C[i] + C[i-1]
	}

	for _, v := range A {
		B[C[v]-1] = v
		C[v]--
	}

	return B
}



Measured memory_bytes: 66900
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define llinf 4e17
#define nllinf -4e18
 
#define vll vector<ll>
#define sll set<ll>
#define pll pair<ll,ll> 
#define vpll vector<pair<ll,ll > >
 
#define repup(a,b,i) for(i=a;i<=b;i++)
#define repdown(a,b,i) for(i=b; i>=a; i--)
#define repupx(a,b,i,x) for(i=a;i<=b;i+=x)
	
#define repit(v,it) for(it=v.begin(); it!=v.end(); it++)
#define itall(v) v.begin(),v.end()
#define pb push_back
#define pf push_front
#define mp make_pair
#define fr first
#define sc second
 
#define err(n) cout<<n<<" ";
#define t1 cout<<",";
 
ll MOD= 998244353;
 
int main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll i,j,k,q; 

ll n, W;cin>>n>>W;

ll ans[W+10]={0};
ll wa=0;
repup(0,n-1,q){
	ll v, w; cin>>w>>v;
	wa+=w;
	repdown(0,W-w,i){
		ans[i+w]= max(ans[i+w], ans[i]+v);
	}
}
ll as=0;
repup(0,W,i)as=max(as,ans[i]);

cout<<as<<'\n';
}

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

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

int main() {
  ll N;
  ll Q;
  cin >> N >> Q;
  auto ft = atcoder::fenwick_tree<ll>(N);
  REP(i, N) {
    ll a;
    cin >> a;
    ft.add(i, a);
  }
  REP(i, Q) {
    ll t;
    cin >> t;
    if (t == 0) {
      ll p;
      ll x;
      cin >> p >> x;
      ft.add(p, x);
    } else {
      ll l;
      ll r;
      cin >> l >> r;
      cout << ft.sum(l, r) << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 8208
#include<iostream>
#include<queue>

using namespace std;
static const int N = 100;
static const int INFTY = (1<<21);

int n, M[N][N];
int d[N];

void bfs(int s) {
  queue<int> q;
  q.push(s);
  for (int i = 0; i < n; i++) {
    d[i] = INFTY;
  }
  d[s] = 0;
  int u;
  while (!q.empty()) {
    u = q.front(); q.pop();
    for (int v = 0; v < n; v++) {
      if (M[u][v] == 0) {
        continue;
      }
      if (d[v] != INFTY) {
        continue;
      }
      d[v] = d[u] + 1;
      q.push(v);
    }
  }
  for (int i = 0; i < n; i++) {
    cout << i + 1 << " " << ((d[i] == INFTY) ? (-1) : d[i]) << endl;
  }
}

int main()
{
  int u, k, v;

  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      M[i][j] = 0;
    }
  }

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

  bfs(0);

  return 0;
}

Measured memory_bytes: 3128
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if(abs(a-x) > abs(b-x)) cout << "B" << endl;
    else cout << "A" << endl;
}


Measured memory_bytes: 256
fn main(){
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).unwrap();
	let vec: Vec<&str> = s.trim().split(' ').collect();
	let a = vec[0].parse::<i32>().unwrap();
	let b = vec[1].parse::<i32>().unwrap();
	if (a * b) % 2 == 1 {
		println!("Odd");
	} else {
		println!("Even");
	}
}


Measured memory_bytes: 4352