akhauriyash/Code-Regression huggingface dataset:
n,m = map(int,input().split())
mod = 10**9 + 7
l = n+1000
fac = [1]*l
facr = [1]*l

for i in range(l-1):
    fac[i+1] = fac[i]*(i+1)%mod
facr[l-1] = pow(fac[l-1],mod - 2,mod)
for i in range(1,l)[::-1]:
    facr[i-1] = facr[i]*i%mod

def combi(N,K):
    return fac[N]*facr[N-K]%mod*facr[K]%mod

prime = {}
i = 2
x = m
while i*i <= m:
    if x%i == 0:
        prime[i] = 0
        while x%i == 0:
            x = x//i
            prime[i] += 1
    i += 1
if x > 1:
    prime[x] = 1
ans = 1
for q in prime.values():
    ans *= combi(q+n-1,n-1)
    ans %= mod
print(ans)


Measured memory_bytes: 40560
H,W,K = gets.split.map &:to_i
M = [0] * (H+W)
N = (1<<H*W) - 1
m = (1<<W) - 1
H.times {|i| M[i] ^= m; m <<= W}
n=m = 0
H.times { m |= 1 << _1*W }
W.times {|i| M[-i-1] = m; m += m}
B = H.times.inject(0) { (_1<<W) + gets.tr('.#','10').to_i(2) }
(1<<H).times {|h|
  b = B
  H.times { h[_1] > 0 and b |= M[_1] }
  next if b == N
  (1<<W).times {|w|
    t = b
    W.times { w[_1] > 0 and t |= M[-1-_1] }
    n += 1  if K == H*W - t.to_s(2).scan(?1).size
  }
}
p n

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define pii pair<int,int>
#define all(x) begin(x), end(x)
#define loop(i,n) for(int i=0; i<n; i++)
#define rep(i,a,b,c) for(int i=a; i<b; i+=c)
#define brep(i,a,b,c) for(int i=a; i>b; i-=c)
#define tc(t) int t; cin>>t; while(t--)
#define sz(v) int((v).size())
#define pb push_back


using namespace std;

void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {std::cout << x;}
void __print(unsigned x) {std::cout << x;}
void __print(unsigned long x) {std::cout << x;}
void __print(unsigned long long x) {std::cout << x;}
void __print(float x) {std::cout << x;}
void __print(double x) {std::cout << x;}
void __print(long double x) {std::cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i : x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
template <typename T> inline void inp(T &any) {cin >> any;} template <typename T, typename... U>inline void inp(T &a, U &...b) {cin >> a; inp(b...);}
#define rin(args...) ll args; inp(args);
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#define matdeb(mat,row,col) cout << #mat << "::" << endl; printmat(mat,row,col); printpartition;
#define debugv(v,n) cout << #v << ":" << endl; printv(v,0,n-1); printpartition;
#else
#define debug(x...)
#define matdeb(mat,row,col)
#define debugv(v,n)
#endif

const int maxm = 1000000000 + 7;

double startTime;
double getCurrentTime() {
	return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}


//----------->CODE BEGINS --------------->


int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	int  n;
	cin>>n;

	vector<int>a(n);

	map<int,int>mp;

	loop(i,n)
	{
		cin>>a[i];
		mp[a[i]]++;
	}
    
    ll ans = 0;

	for(auto it:mp)
	{
		if(it.first != it.second)
		{
			if(it.first>it.second)
			{
				ans += it.second;
			}

			else
			{
				ans += (it.second-it.first);
			}
		}
	}

	cout<<ans<<endl;
}


Measured memory_bytes: 8176
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

string s[]={"thu","fri","sat","sun","mon","tue","wed"};

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,m; cin >> n >> m;
	int q; cin >> q;
	bool ok=true;
	for(int i=0;i<q;i++){
		int a,b; cin >> a >> b;
		if((n<b&&b<=m)||(n<=a&&a<m))ok=0;
		if(a<n&&b>m)ok=0;
	}
	if(ok)cout << 0 << endl;
	else cout << 1 << endl;
}



Measured memory_bytes: 3208
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define reverse(s) reverse(s.begin(), s.end());
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }

template <class T>
void VecRowShow(vector<T> vec) {
	rep(i, vec.size()) {
		if (i != vec.size() - 1) cout << vec[i] << " ";
		else cout << vec[i] << endl;
	}
}

int main() {
	int n;
	cin >> n;
	vector<ll> a(n), b(n), c(n);
	rep(i, n) {
		cin >> a[i];
		if (i == 0) {
			b[i] = a[i];
		}
		else {
			b[i] = b[i - 1] + a[i];
		}
	}

	ll len = b[n - 1];
	ll m = (ll)2020202020 * (ll)200000;

	rep(i, n) {
		int a;
		if (len == 2 *b[i]) {
			cout << 0 << endl;
			return 0;
		}
		else if (len > 2 * b[i]) {
			m = min(m, len - 2 * b[i]);
		}
		else {
			m = min(m, 2 * b[i] - len);
		}
	}
	cout << m << endl;
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "0" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
ll GCD(ll a, ll b) {
    return ( b==0 ? a : GCD(b, a%b) ); 
}
ll LCM(ll a, ll b){
    return a/GCD(a, b) *b;
}
//--MAIN-----------------------------------
void Main() {
    ll N,M; cin>>N>>M;
    vector<ll> A(N);
    rep(i,N) cin>>A[i];
    rep(i,N) A[i]/=2;
    ll ct=0;
    ll da=1;
    while(A[0]%2==0){ A[0]/=2; ct++; da*=2;}
    reps(i,1,N){
        if(A[i]%da!=0) dame;
        A[i]/=da;
        if(A[i]%2==0) dame;
    }
    rep(i,N) A[i]*=da;
    ll ans=1;
    rep(i,N){
        ans=LCM(ans,A[i]);
        if(ans>M) dame;
    }
    cout<< (M+ans)/(ans*2) <<"\n";
}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

int main(){
    int n;
    string s, ans;
    cin >> n >> s;
    vector<char> v(s.length());
    rep(i, s.length()){
        v.at(i) = s[i] + n;
        if(v.at(i) > 90){
            v.at(i) -= 26;
        }
    }
    rep(i, s.length()){
        cout << v.at(i);
    }
    cout <<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        String C[] = new String[2 * H];
        for (int i = 0; i < 2 * H; i += 2) {
            C[i] = sc.next();
            C[i + 1] = C[i];
        }
        for (int i = 0; i < 2 * H; i++) {
            System.out.println(C[i]);
        }
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <string>
using namespace std;
int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	int n[] = { a, b, c };

	for (int j = 0; j < 3; j++)
	{
		for (int i = 0; i < 2 - j; i++)
		{
			int n0 = n[i];
			int n1 = n[i + 1];
			if (n1 < n0)
			{
				n[i] = n1;
				n[i + 1] = n0;
			}
		}
	}
cout << n[0] << " " << n[1] << " " << n[2] << endl;
}



Measured memory_bytes: 3064
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lson l,(l+r)/2,rt<<1
#define rson (l+r)/2+1,r,rt<<1|1
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define pb push_back
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define pll pair<long long,long long>
#define pii pair<int,int>
#define pq priority_queue
const int N=3e5+5,MD=1e9+7,INF=0x3f3f3f3f;
const ll LL_INF=0x3f3f3f3f3f3f3f3f;
const double eps=1e-9,e=exp(1),PI=acos(-1.);
int dp1[N],dp2[N];
char s[N];
int main()
{
    //ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int n;
    scanf("%d%s",&n,s+1);
    for(int i=1;i<=n;i++)
        dp1[i]=dp1[i-1]+(s[i]=='W');
    for(int i=n;i>0;i--)
        dp2[i]=dp2[i+1]+(s[i]=='E');
    int ans=n;
    for(int i=0;i<=n;i++)
        ans=min(dp1[i]+dp2[i+1],ans);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 2944
#include "bits/stdc++.h"
using namespace std;
int main(){
    set<int> a;
    set<int> b;
    set<int> c;
    a.insert(1);
    c.insert(2);
    a.insert(3);
    b.insert(4);
    a.insert(5);
    b.insert(6);
    a.insert(7);
    a.insert(8);
    b.insert(9);
    a.insert(10);
    b.insert(11);
    a.insert(12);
    int x, y;
    cin >> x >> y;
    if(a.count(x) == a.count(y) && b.count(x) == b.count(y) && c.count(x) == c.count(y))
    cout << "Yes" << endl;
    else 
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#include<utility>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fori(i,k,n) for(int i=k;i<(int)n;i++)
using namespace std;
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
const int dX[8] = { 0, 1, 1, 1, 0, -1, -1, -1 }, dY[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
/*
(char)'1' - (int)48 = (int)1; 


*/


int main()
{
	string a;
	stack<int> all;
	stack< pair<int, int> > ss;
	int ans = 0;
	cin >> a;
	for (int i = 0; i < (int)a.size(); i++)
	{
		if (a[i] == '\\')
			all.push(i);
		else if (a[i] == '/'&&!all.empty())
		{
			int b = all.top(); all.pop();
			int a = i - b;
			ans += a;
			while (!ss.empty() && ss.top().first >b)
			{
				a += ss.top().second;
				ss.pop();
			}
			pair<int, int> pp;
			pp.first = b; pp.second = a;
			ss.push(pp);
		}
	}
	vector<int> aa;
	while (!ss.empty())
	{
		aa.push_back(ss.top().second);
		ss.pop();
	}
	reverse(aa.begin(), aa.end());
	cout << ans << endl;
	cout << aa.size();
	for (int i = 0; i < (int)aa.size();i++)
	{
		cout << " ";
		cout << aa[i];
	}
	cout << endl;
}

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

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args&&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#define pi 3.141592653589
#define MOD 1000000007
#define to() int t; cin>>t; while(t--)
#define pb push_back
#define in insert
#define mp make_pair
#define ff first
#define ss second
#define si(s) s.size()
#define fori(it,v) for(it=v.begin();it!=v.end(); it++) 
#define for1(low,high,k) for(int i=low;i<high;i+=k)
#define for11(low,high,k) for(int j=low;j<high;j+=k)
#define for2(low,high,k) for(int i=low;i<=high;i+=k)
#define rev(high,low,k)  for(int i=high;i>=low ;i-=k)
#define all(x) x.begin(), x.end()
#define fil(x,i) memset(x,i,sizeof(x));
#define setbits(x) __builtin_popcount(x)
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define read freopen("input.txt","r",stdin)
#define write freopen("output.txt","w",stdout) 
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
inline ll power(ll a, ll n)
{
if(n==0) return 1LL;
ll p=power(a,n/2)%MOD;
p=(p*p)%MOD;
 if(n%2) return (p*a)%MOD;
else return p;
}


int main()
{
	boost;
	ll n; cin>>n;
	ll ans=(power(10LL,n)%MOD-(2LL*power(9LL,n))%MOD+power(8LL,n)%MOD)%MOD;
	ans=(ans+MOD*1LL)%MOD;
	cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <queue> 
using namespace std;
typedef long long ll;
int inf=-1;
typedef pair<int,int> P;
int main(void){
    ll n,m,i,x;
    cin>>n>>m;
    ll dan[n+10]={1,1,2},f[n+10];
    for(i=0;i<n+1;i++)f[i]=1;
    for(i=0;i<m;i++){
        cin>>x;
        f[x]=0;
    }
    for(i=2;i<=n;i++){
   
        dan[i]=(dan[i-1]*f[i-1]+dan[i-2]*f[i-2])%1000000007;
      }
    cout<<dan[n]%1000000007<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
#include<unordered_map>
#include<math.h>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#include<iomanip>
#include<string>
#include<map>
#define PI 3.14159265
#define mod 998244353    
using namespace std;

 

void func(){
    long long n , w ;
    cin >> n >> w ;
    int val[n] , wt[n];
    long long dp[n + 1][w + 1];

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

    for(int i = 0 ; i <= n ; ++i){
        for(int j = 0; j <= w ; ++j){
            if(i == 0 || j == 0){
                dp[i][j] = 0;
            }
            else if(wt[i - 1] > j){
              dp[i][j] = dp[i - 1][j];
            }
            else{
              dp[i][j] = max(dp[i - 1][j] , val[i - 1] + dp[i - 1][j - wt[i - 1]]);
            }
        }
    }
     cout << dp[n][w] << "\n";
}
int main(){
    int t = 1 , cnt = 0 ;
  // cin >> t;
    
    while(t--){
        
        func();
    }
}

Measured memory_bytes: 79104
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int l, r, d;
  cin >> l >> r >> d;
  r++;
  int ans = 0;
  FOR(i, l, r) {
    if (i % d == 0) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
struct c{
  int a;
  int b;
  
  bool operator<( const c& right ) const {
        return b == right.b ? a < right.a : b < right.b;
    }
  
};


int main(){
  int n,m,i,j,hon=0;
  long int kotae=0;
  cin>>n>>m;
  vector<c> d(n);
  for(i=0;i<n;i++){
    cin>>d[i].b>>d[i].a;
  }
  sort(d.begin(), d.end());
  for(i=0;i<=n;i++){
    for(j=0;j<d[i].a;j++){
      kotae+=d[i].b;
      hon++;
      if(hon==m){
        break;
      }
    }
    if(hon==m){
      break;
    }
  }
  cout<<kotae;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N, M;
  cin >> N >> M;
  long foo = abs(N-M);
  if (foo > 1) {
    cout << 0 << endl;
    return;
  }
  long ans = 1;
  for (long i = 1; i <= N; i++) { ans *= i; ans %= MOD; }
  for (long i = 1; i <= M; i++) { ans *= i; ans %= MOD; }
  if (foo == 0) { ans *= 2; ans %= MOD; }
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int k = Integer.parseInt(sa[1]);
		sa = br.readLine().split(" ");
		int[] p = new int[n];
		for (int i = 0; i < n; i++) {
			p[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		double ans = 0;
		for (int i = 0; i < k; i++) {
			ans += (p[i] + 1) / 2.0;
		}

		double val = ans;
		for (int i = k; i < n; i++) {
			val -= (p[i - k] + 1) / 2.0;
			val += (p[i] + 1) / 2.0;
			ans = Math.max(ans, val);
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 53116
def digit_sum(n):
    # 各桁の和を求める
    # 計算量: O(logN)
    ans = 0
    while n > 0:
        ans += 1
        n //= 10
    return ans

n = int(input())
cnt = 0

for i in range(1, n+1):
    cnt += digit_sum(i) % 2

print(cnt)


Measured memory_bytes: 2940
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
//typedef pair<int,int> P;
//priority_queue<int> pque;
//priority_queue<int, vector<int>, greater<int>> pque;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 2000000000;//10^9
ll MOD  = 1000000007;
ll dp[110][10];
ll F[100];
int fib(int n){
    if(F[n] != -INF){
        return F[n];
    }
    if(n < 0){
        return 0;
    }
    if(n == 0){
        return 1;
    }
    if(n == 1){
        return 1;
    }
    if(n == 2){
        return 2;
    }
    else{
        return F[n] = fib(n-1) + fib(n-2);
    }
}
int main(void){
    for(int i = 0; i < 100; i++){
        F[i] = -INF;
    }
    int H,W,K;
    cin >> H >> W >> K;
    dp[0][1] = 1;//高さi,横からj番目にいる場合の数
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            dp[i][j] += dp[i-1][j] * fib(j-1) * fib(W - j);
            dp[i][j] %= MOD;
            if(j != 1){
                dp[i][j] += dp[i-1][j-1] * fib(j-2) * fib(W-j);
                dp[i][j] %= MOD;
            }
            if(j != W){
                dp[i][j] += dp[i-1][j+1] * fib(j-1) * fib(W - j - 1);
                dp[i][j] %= MOD;
            }
        }
    }
    
    
    
    cout << dp[H][K] << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#include<set>
#include<complex>
#include<complex>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define INF 200000000

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;

enum
{
	BOTTOM,
	LEFT,
	RIGHT,
	TOP
};

struct P
{
	double x, y;
	P(double x,double y) :x(x), y(y) {}
	P() :P(0, 0) {}
	P operator+(const P& v)const
	{
		return P(x + v.x, y + v.y);
	}
	P operator-(const P& v)const
	{
		return P(x - v.x, y - v.y);
	}
	P operator*(const double v)const
	{
		return P(x*v, y*v);
	}
	bool operator==(const P& v)const
	{
		return abs(x - v.x) <= 0.0000000000001&&abs(y - v.y) <= 0.00000000000001;
	}
	bool operator!=(const P& v)const
	{
		return abs(x - v.x) > 0.0000000000001 || abs(y - v.y) > 0.00000000000001;
	}

	double dot(const P& v)const
	{
		return x*v.x + y*v.y;
	}
	double cross(const P& v)const
	{
		return x*v.y - y*v.x;
	}
	double length()const
	{
		return sqrt(x*x + y*y);
	}
	double length2()const
	{
		return (x*x + y*y);
	}
	
	bool operator<(const P& v)const
	{
		return x<v.x || (x == v.x) && y < v.y;
	}
	bool operator>(const P& v)const
	{
		return x>v.x || (x == v.x) && y > v.y;
	}
};

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

	double x1, y1, r1, x2, y2, r2;
	cin >> x1 >> y1 >> r1 >> x2 >> y2 >> r2;
	P p1(x1, y1), p2(x2, y2);

	if ((p1 - p2).length() > (r1 + r2))
	{
		cout << "4" << endl;
	}
	else if ((p1 - p2).length() == (r1 + r2))
	{
		cout << "3" << endl;
	}
	else
	{
		if (((p1 - p2).length() + min(r1, r2)) < max(r1, r2))
		{
			cout << "0" << endl;
		}
		else if (((p1 - p2).length() + min(r1, r2)) == max(r1, r2))
		{
			cout << "1" << endl;
		}
		else
		{
			cout << "2" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3276
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define ll long long
#define SIZE 2010
#define rep(i, a, b) for (int i = a; i <= b; ++i)
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
int h, w, k, a[15][SIZE], pre[15][SIZE], ans = 1e9;

int query(int xa, int ya, int xb, int yb) {
	return pre[xb][yb] - pre[xa][yb] - pre[xb][ya] + pre[xa][ya];
}

void gao(int top) {
	vector<int> vec(1, 0);
	int cnt = 1, tmp = 0, pre = 0;
	while (top) {
		if (top & 1) ++tmp, vec.emplace_back(cnt);
		top >>= 1;
		++cnt;
	}
	vec.emplace_back(h);
	
	rep(i, 1, w) {
		bool f = false;
		rep(j, 1, (vec.size() - 1)) {
			if (query(vec[j - 1], pre, vec[j], i) > k) {
				if (query(vec[j - 1], i - 1, vec[j], i) > k) return;
				f = true;
			}
		}
		if (f) { ++tmp; pre = i - 1; }
	}
	ans = min(ans, tmp);
}

int main() {
	cin >> h >> w >> k;
	int top = (1 << (h - 1)) - 1;
	rep(i, 1, h) {
		string s; cin >> s;
		rep(j, 1, w) a[i][j] = s[j - 1] - '0';
	}
	rep(i, 1, h) {
		rep(j, 1, w) {
			pre[i][j] = a[i][j] + pre[i - 1][j] + pre[i][j - 1] - pre[i - 1][j - 1];
		}
	}
	for (int i = top; i >= 0; --i) gao(i);
	cout << ans;
}

Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    string blood[] = {"A", "B", "AB", "O"};
    vector<int> num(4, 0);

    for(;;){
        int tmp;
        char c;
        string s;
        if(!(cin >> tmp >> c >> s))
            break;

        int i = find(blood, blood+4, s) - blood;
        ++ num[i];
    }

    for(int i=0; i<4; ++i)
        cout << num[i] << endl;
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using lint = long long;

const lint mod = 998244353;
lint dp[3005][3005];

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

  lint N, S;
  cin >> N >> S;
  vector<lint> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  dp[0][0] = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= 3001; j++) {
      dp[i + 1][j] += 2ll * dp[i][j] % mod;
      dp[i + 1][j] %= mod;
      dp[i + 1][min(3001ll, j + A[i])] += dp[i][j];
      dp[i + 1][min(3001ll, j + A[i])] %= mod;
    }
  }

  cout << dp[N][S] << "\n";
  return 0;
}


Measured memory_bytes: 74068
#include<iostream>
using namespace std;
int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if ((A < C&&C < B) || (B < C&&C < A)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}


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

int main(void) {
    int x, n;
    cin >> x >> n;
    set<int> s;
    for (int i = 0; i < n; i++) {
        int x; cin >>x;
        s.insert(x);
    }
    int k = 0;
    while(true) {
        int min = x - k;
        int max = x + k;
        if (s.find(min) == s.end()) {
            cout << min;
            break;
        }
        if (s.find(max) == s.end()) {
            cout << max;
            break;
        }
        ++k;
    }
}



Measured memory_bytes: 3636
n, k = map(int, input().split())
a = [0] * n
for i in range(k):
    d = int(input())
    for j in list(map(int, input().split())):
        a[j-1] += 1

ans = n
for i in range(n):
    if a[i] != 0:
        ans -= 1

print(ans)

Measured memory_bytes: 9204
// Problem : A - Plural Form
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize("O3")  
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
typedef long long ll;
#define F first
#define pii pair<int,int>
#define S second
#define endl "\n"
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define mem(z,i) memset(z,i,sizeof(z))
#define eps 1e-7
#define I (int)
#define mod 1000000007
#define pb push_back
const long long INF = 1000000000000000000LL;
//const int WASTE=∞
const int N=1e5+5;
signed main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
  	// cout<<fixed;
  	// cout.precision(10);
   	// ofstream cout (".out");
    // ifstream cin  (".in");
	string s;
	cin>>s;
	int n=s.length();
	if(s[n-1]=='s') cout<<s+"es";
	else cout<<s+'s';
   	
   	
   	
   	
   	
   	
   	
   	
   	
   	
   	
  	return 0;
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define maxn 300300
using namespace std;

char v[maxn];

int main() {
    int n;
    scanf("%d %s",&n,v);
    int nw = 0, ne = 0;
    for(int i=1;i<n;i++)
        if(v[i] == 'E')
            nw++;
    int ans = nw;
    for(int i=1;i<n;i++){
        if(v[i] == 'E')
            nw--;
        if(v[i-1] == 'W')
            ne++;
        ans = min(ans,ne+nw);
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	#ifdef LOCAL
//		freopen("in1.txt", "r", stdin);
//		freopen("in1.txt", "w", stdout);
	#endif
	bool x;
	cin >> x;
	cout << !x << '\n';
}

Measured memory_bytes: 3636
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=200000000;
//setprecision(2) <<

const int MOD = 1000000007;




long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}
class Edge{
public:
	long long from;
	long long to;
	long long w;
};


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long A,B,C;
	cin>>A>>B>>C;
	if((A*B*C)%2==1){
		cout<<min(min(A*B,B*C),C*A)<<endl;
	}else cout<<0<<endl;
	
}


Measured memory_bytes: 256
from random import randint
import sys
input = sys.stdin.readline


def calc_score(D, C, S, T):
    """
    開催日程Tを受け取ってそこまでのスコアを返す
    """
    contest_last_opened = [0]*26  # コンテストiを前回開催した日
    score = 0
    for d, t in enumerate(T, start=1):
        get_score = S[d-1][t-1]
        score += get_score
        contest_last_opened[t-1] = d
        loss_score = 0
        for i in range(26):
            ld = contest_last_opened[i]
            loss_score += C[i]*(d-ld)
        score -= loss_score
    return score


def local_search():
    pass


def main(D, C, S):
    T = []
    for d in range(1, D+1):
        # d日目に一番満足度が高いコンテストを開催する 1-indexed
        # S[d-1]で最大のコンテストiを選ぶ　→ 0点！w
        # c[i]*(d-ld)最小のコンテストiを選ぶ
        today_score = calc_score(D, C, S, [1])
        today_contest = 1
        for i in range(2, 26 + 1):
            tmp_score = calc_score(D, C, S, [i])
            if today_score < tmp_score:
                today_score = tmp_score
                today_contest = i
        T.append(today_contest)
    return T


if __name__ == '__main__':
    D = int(input())
    C = [int(i) for i in input().split()]
    S = [[int(i) for i in input().split()] for j in range(D)]
    T = main(D, C, S)
    print(*T, sep="\n")


Measured memory_bytes: 78304
#include<stdio.h>
 
int A[11]={0,1,2,3,4,5,6,7,8,9,0};
int cnt=0;
 
void dfs(int i,int r,int d,int n){
 
 if(i<11){
    if(d==n){
      if(r==0){cnt++;return;}
      else return;
    }
 
    if(r<0)return;
 
    dfs(i+1,r-A[i],d+1,n);
    dfs(i+1,r,d,n);
 }
return;
}
 
int main(){
 int n,s;
 
 while(1){
 
      scanf("%d %d",&n,&s);
      if(n==0 && s==0)break;
      if(s > 55)printf("0\n");
      else {
            cnt=0;
            dfs(0,s,0,n);
            printf("%d\n",cnt);
      }
 }
 
 return 0;
}


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

int main() {
    int H, W;
    cin >> H >> W;
    int M = max(H, W);
    vector<vector<char>> data(M, vector<char>(M));
    for(int h=0;h<H;h++){
        for(int w=0;w<W;w++){
            cin >> data[h][w];
        }
    }
    vector<vector<int>> dp(M, vector<int>(M));
    // h == 0, w == 0
    if (data[0][0] == '#'){
        dp[0][0] = 1;
    }
    // h==0
    for(int w=1;w<W;w++){
        if(data[0][w-1]=='.' && data[0][w]=='#'){
            dp[0][w] = dp[0][w-1] + 1;
        }else{
            dp[0][w] = dp[0][w-1];
        }
    }
    // w==0
    for(int h=1;h<H;h++){
        if(data[h-1][0]=='.' && data[h][0]=='#'){
            dp[h][0] = dp[h-1][0] + 1;
        }else{
            dp[h][0] = dp[h-1][0];
        }
    }
    // h>=1, w>=1
    for(int h=1;h<H;h++){
        for(int w=1;w<W;w++){
            int d, r;
            if(data[h][w]=='#' && data[h][w-1]=='.'){
                r = dp[h][w-1] + 1;
            }else{
                r = dp[h][w-1];
            }
            if((data[h][w]=='#') && data[h-1][w]=='.'){
                d = dp[h-1][w] + 1;
            }else{
                d = dp[h-1][w];
            }
            dp[h][w] = min(r, d);
        }
    }
    cout << dp[H-1][W-1] << endl;
    // for(int h=0;h<H;h++){
    //     for(int w=0;w<W;w++){
    //         cout << dp[h][w];
    //     }
    //     cout << endl;
    // }
    // for(int h=0;h<H;h++){
    //     for(int w=0;w<W;w++){
    //         cout << data[h][w];
    //     }
    //     cout << endl;
    // }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int D;
  cin>>D;
  
  if(D==25){
    cout<<"Christmas"<<endl;
  }
  
  else if(D==24){
    cout<<"Christmas Eve"<<endl;
  }
  
  else if(D==23){
    cout<<"Christmas Eve Eve"<<endl;
  }
  
  else {
    cout<<"Christmas Eve Eve Eve"<<endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
#define PI 3.14159265359
#define MOD 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

int main(){

    int h,w;

    while(true){
        
        cin >> h >> w;
        if(h == 0 && w == 0) return 0;
        rep(i,h){
            rep(i,w){
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
/*
  mail: mleautomaton@foxmail.com
  author: MLEAutoMaton
  This Code is made by MLEAutoMaton
*/
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=60,Mod=1e9+7;
int f[N][N][N*N],n,k;
void Add(int &x,int y){x+=y;if(x>=Mod)x-=Mod;}
int main(){
	n=gi();k=gi();
	if(k%2)return puts("0"),0;
	f[1][0][0]=f[1][1][0]=1;
	for(int i=1;i<n;i++)
		for(int j=0;j<=i;j++)
			for(int s=0;s<=i*i/2;s++){
				if(j)Add(f[i+1][j-1][j+s],1ll*f[i][j][s]*j%Mod*j%Mod);
				Add(f[i+1][j][j+s],1ll*f[i][j][s]*(2*j+1)%Mod);
				Add(f[i+1][j+1][j+s],f[i][j][s]);
			}
	printf("%d\n",f[n][0][k/2]);
	return 0;
}


Measured memory_bytes: 41216
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

N,M=map(int,input().split())
uf=UnionFind(N)

for _ in range(M):
    a,b=[int(e)-1 for e in input().split()]
    uf.union(a,b)
ans=max([uf.size(i) for i in range(N)])
print(ans)

Measured memory_bytes: 22432
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define vec vector
#define fi first
#define se second
#define eb emplace_back
#define ef emplace_front
#define pof pop_front()
#define pob pop_back()
#define Rep(i,n) for(li i=0,nn=(li)(n);i!=nn;++i)
#define Rep1(i,n) for(li i=1,nn=(li)(n)+1;i!=nn;++i)
#define Size(v) (li)(v.size())
#define SortA(v) sort(v.begin(),v.end())
#define SortD(v) sort(v.rbegin(),v.rend())
#define All(a) (a).begin(),(a).end()
#define Input(a) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii);}
#define Input2(a,b) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii)>>(b).at(ii);}
#define mp make_pair
using li = int64_t;
using intl = int64_t;
using vi = vec<li>;
using vb = vec<bool>;
using vvi = vec<vi>;
using qi = deque<li>;
using pi = pair<li, li>;
using vpi = vec<pi>;
using si = set<li>;
using vsi = vec<si>;
using mii = map<li, li>;
using vmii = vec<mii>;
vec<li> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<li> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr li INF = 9223372036854775807;

void Yes(li b) {
	if (b)cout << "Yes";
	else cout << "No";
}
void yes(li b) {
	if (b)cout << "yes";
	else cout << "no";
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cout.precision(16);

	li N;
	cin >>N;

	char c;

	vi C(N);//,D(N);

	Rep(i,N){
		cin>>c;
		C[i]=(c=='R');
		//D[i]=(c!='R');
	}

	li count = accumulate(All(C),0);

	cout<<accumulate(C.begin()+count, C.end(),0);

}

Measured memory_bytes: 4784
import math
x,y = map(int,input().split())
mod = 10**9+7

if (2*x-y)%3 != 0 or (-x+2*y)%3 != 0 or y>2*x or x>2*y:
  print(0)
  exit()
  
a = ((2*x-y)//3)%mod
b = ((-x+2*y)//3)%mod


def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

print(cmb(a+b,a)%mod)


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

const int maxn = 3e3 + 10;
char s[maxn], t[maxn];

int main() {
	scanf("%s%s", s+1, t+1);
	int m = strlen(s+1), n = strlen(t+1);
	
	vector<vector<int>> dp(m+1, vector<int>(n+1));
	
	vector<vector<pair<int, int>>> pre(m+1, vector<pair<int, int>>(n+1, {-1, -1}));
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= n; j++) {
			if (s[i] == t[j]) {
				dp[i][j] = dp[i-1][j-1] + 1;
				pre[i][j] = {i-1, j-1};
			} else {
				if (dp[i-1][j] > dp[i][j-1]) {
					pre[i][j] = {i-1, j};
				} else {
					pre[i][j] = {i, j-1};
				}
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			}
		}
	}
	
	pair<int, int> pos = {m, n};
	string res = "";
	while (pos.first > 0) {
		int x = pos.first; 
		int y = pos.second;
		if (s[x] == t[y]) {
			res = s[x] + res;
		} 
		pos = pre[x][y];
	}
	cout << res << endl;
}

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

using namespace std;
using ll = long long;

int main() {
	int X, Y, Z;
	int K;
	cin >> X >> Y >> Z >> K;
	vector<ll> xs(X), ys(Y), zs(Z); 
	vector<long long> valueXY(X * Y);
	int xy_k = min(K, X * Y);
	vector<long long> valueXYZ(xy_k * Z);

	for (int i = 0; i < X; i++) {
		cin >> xs[i];
	}

	for (int i = 0; i < Y; i++) {
		cin >> ys[i];
	}
	for (int i = 0; i < Z; i++) {
		cin >> zs[i];
	}

	for (int x = 0; x < X; x++) {
		for (int y = 0; y < Y; y++) {
			valueXY[x + y * X] = xs[x] + ys[y]; 
			//cout << "x:" << x << " y:" << y << " " <<  valueXY[x + y * X] << endl;

		}
	}
	
	sort(valueXY.begin(), valueXY.end());


	for (int xy = 0; xy < xy_k; xy++) {
		for (int z = 0; z < Z; z++) {
			valueXYZ[xy * Z + z] = valueXY[X * Y - 1 - xy] + zs[z];
		}
	}

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

	for (int i = 0; i < K; i++) {
		cout << valueXYZ[xy_k * Z - i - 1] << endl;
	}




	return 0;
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int ans = 0;
    for(int i=0;i<b;i++){
        ans += a;
        if(ans%b==c){
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}


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

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

using namespace std;

int N;
char a[110][110];
int win[110];

int main(){
  srand((unsigned int)time(NULL));
  cin >> N;
  rep(i,N) {
    string s;
    cin >> s;
    rep(j,N) { 
      a[i][j] = s[j];
      if( j < i && a[i][j] == 'o' ) ++win[i];
    }
  }
  int maxi_p = 0;
  rep(i,N) if( win[maxi_p] < win[i] ) maxi_p = i;
  bool definitely = false;
  if( win[maxi_p] == N-1 ) definitely = true;

  int judge_ai_hand = 1;
  int use = 0;
  rep(_,1000){
    if( definitely ) {
      printf("%d\n",maxi_p+1); fflush(stdout);
    } else {
      if( rand() % 1000 >= 10 ) {
        printf("%d\n",rand()%N+1); fflush(stdout);
      } else {
        printf("%d\n",maxi_p+1); fflush(stdout);

      }
    }
    scanf("%d", &judge_ai_hand);
  }
  return 0;
}

Measured memory_bytes: 1332
import sys
from functools import lru_cache

sys.setrecursionlimit(20000000)
N = int(input())
heights = [int(h) for h in input().split()]


# heights = [10, 30, 40, 20]

# heights = [10, 10]
# heights = [30, 10, 60, 10, 60, 50]
# 记忆化
@lru_cache(None)
def dfs(i):
    if i == len(heights) - 1:
        return 0
    return min(abs(heights[i] - heights[i + 1]) + dfs(i + 1) if i + 1 < len(heights) else float("inf"),

               abs(heights[i] - heights[i + 2]) + dfs(i + 2) if i + 2 < len(heights) else float("inf"))


def helper():
    dp = [float("inf")] * len(heights)
    dp[0] = 0
    for i in range(1, len(heights)):
        dp[i] = min(dp[i], dp[i - 1] + abs(heights[i] - heights[i - 1]))
        if i > 1:
            dp[i] = min(dp[i], dp[i - 2] + abs(heights[i] - heights[i - 2]))
    return dp[-1]


# print(dfs(0))
print(helper())

Measured memory_bytes: 14976
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(){
	int m, d;
	int count=0;
	int d1, d10;
	scanf("%d%d", &m,&d);
	for(int i=1; i<=m; i++){
		for(int j=1; j<=d; j++){
			d1=j%10;
			d10=(j-d1)/10;
			if((d1>=2) && (d10>=2) && (d1*d10==i)) count++;
		}
	}
	printf("%d", count);
	
	return 0;
}

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

bool prime(int n){
	if(n<2) return false;

	for(int i=2;i*i<=n;i++)
		if(n%i==0) return false;
	return true;
}

int main()
{
	int a,d,n;
	while(cin>>a>>d>>n){
		if(a==0 && d==0 && n==0) return 0;

		int count=0,now=a;
		while(true){
			if(prime(now)) count++;
			if(count==n){cout<<now<<endl;break;}
			now+=d;
		}

	}
}

Measured memory_bytes: 0
import java.io.*;
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        //START

        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int K=sc.nextInt();
        int Q=sc.nextInt();

        int i=0;
        int num=0;
        //int A[]=new int[N+10];
        int P[]=new int[N+10];

        for(i=0;i<N+10;i++){
            P[num]=0;
        }

        for(i=1;i<=Q;i++){
            num=sc.nextInt();
            P[num]++;
        }

        for(num=1;num<=N;num++){
            if(P[num]>=Q-K+1){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }


        //END
    }
}



Measured memory_bytes: 72048
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <deque> 

using namespace std;


int base[30];

void init()
{
	base[0] = 1;
	for (int i = 1 ; i < 30 ; i++)
		base[i] = base[i - 1] * 2;
}

int m, k;

int main()
{
	init();
	
	scanf("%d%d", &m, &k);
	
	if (m == 0 && k == 0)
	{
		printf("0 0\n");
		return 0;
	}
	
	if (m == 1 && k == 0)	//特例 
	{
		printf("0 0 1 1\n");
		return 0;
	}
	
	if (m == 1 && k == 1)	//特例 
	{
		printf("-1\n");
		return 0;
	}
	
	int max = base[m];
	if (max <= k)
	{
		printf("-1\n");
		return 0;
	}
	
	if (k == 0)
	{
		printf("0 0");
		for (int i = 1 ; i < base[m] ; i++)
		{
			printf(" %d %d", i, i);
		}
		printf("\n");
		return 0;
	}
	
	printf("0 %d 0", k);
	for (int i = 1 ; i < base[m] ; i++)
	{
		if (i != k)
			printf(" %d", i);
	}
	printf(" %d", k);
	for (int i = base[m] - 1 ; i >= 1 ; i--)
	{
		if (i != k)
			printf(" %d", i);
	}
	printf("\n");
	
	return 0;
}

//0 3 0 2 1 3 1 2 


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
#define sz(x) (int)(x.size())
#define fi(a, b) for(int i=a;i<b;++i)
#define pb push_back
typedef long long ll;
//////////////////////////

int const N = 2e5 + 41;
int was[N], col[N];
ll ans = 0;
vector<int> e[N];
int n, m;

int dfs(int u){
	was[u] = 1;
	int ret = 2;
	fi(0, sz(e[u])){
		int to = e[u][i];
		if(!was[to]){
			col[to] = col[u] ^ 1;
			ret = min(ret, dfs(to));
		}else{
			if(col[to] != (col[u] ^ 1)){
				ret = 1;
			}
		}
	}
	return ret;
}

void solve(){
	scanf("%d %d",&n,&m);
	fi(0, m){
		int a, b;
		scanf("%d %d",&a,&b);
		--a;--b;
		e[a].pb(b);
		e[b].pb(a);
	}
	ll cnt0 = 0, cnt1 = 0, cnt2 = 0;
	fi(0, n){
		if(was[i]) continue;
		if(sz(e[i]) == 0) ++cnt0;
		else{
			int cur = dfs(i);

			if(cur == 1) ans += (cnt1 + cnt2) * 2;
			else ans += (cnt1 * 2 + cnt2 * 4); 
			

			ans += cur;
			if(cur == 1) ++cnt1;
			else ++cnt2;
		}
	}

	ans += (n + n - cnt0 + 1) * cnt0;
	ans -= cnt0;
	printf("%lld\n",ans);
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();


	return 0;
}

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

int main(){
  string S, T;
  cin >> S;
  cin >> T;

  if(S.size() != T.size() - 1){
    cout << "No" << endl;
  }else{
    for(int i = 0; i < S.size(); i++){
      if(S.at(i) != T.at(i)){
        cout << "No" << endl;
        break;
      }else if(i == S.size()-1){
        cout << "Yes" << endl;
      }
    }
  }
}

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

int main(){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    
    if((x - r >= 0 && W >= x + r) && (y - r >= 0 && H >= y + r)){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>

int main(){
	while(1){
		int t, n, sum=0;
		
		scanf(" %d", &t);
		if(t==0) break;
		
		scanf(" %d", &n);
		for(int i=0; i<n; ++i){
			int a, b;
			scanf(" %d %d", &a, &b);
			sum += b-a;
		}
	
		if(sum>=t) printf("OK\n");
		else printf("%d\n", t-sum);
	
	}	
	
	return 0;
}

Measured memory_bytes: 1196
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int n = sc.nextInt();
        int ans=Integer.MAX_VALUE;
        int s1=n/6,s2=n/9;
        int[] TS=new int[n+10];
        int[] TN=new int[n+10];
        for (int i = 0; i <= n; i+=6) {
            int temp=i;
            while (temp/6>0){
                temp/=6;
                TS[i]+=temp%6;
            }
            for (int j = 0; j < 6; j++) {
                if(i+j<=n)TS[i+j]=TS[i]+j;
            }
        }
        for (int i = 0; i <= n; i+=9) {
            int temp=i;
            while (temp/9>0){
                temp/=9;
                TN[i]+=temp%9;
            }
            for (int j = 0; j < 9; j++) {
                if(i+j<=n)TN[i+j]=TN[i]+j;
            }
        }
        for (int i = 0; i <= s1; i++) {
            for (int j = 0; j <= s2; j++) {
                int six=6*i;
                int nine=9*j;
                if(i*6+j*9<=n){
                    ans=min(ans,TS[i*6]+TN[j*9]+n-6*i-9*j);
                }
            }
        }
        out.println(ans);
    }
}

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

int main(){
    int n;
    cin >> n;
    double ans=0;
    for(int i = 0;i < n;i ++){
        double x;
        string u;
        cin >> x >> u;
        if(u=="JPY") ans += x;
        else if(u=="BTC") ans += x*380000.0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N int
	fmt.Scanf("%d", &N)
	H := make([]int, N)
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &H[i])
	}
	count := 1
	max := H[0]
	for i := 1; i < N; i++ {
		if max <= H[i] {
			count++
		}
		if max < H[i] {
			max = H[i]
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 512
import scala.io.StdIn

object Main extends App {
  val n  = StdIn.readLine().toInt
  val a :Array[Int] = StdIn.readLine().split(" ").map(_.toInt)
  val b :Array[Int] = StdIn.readLine().split(" ").map(_.toInt)
  val c :Array[Int] = StdIn.readLine().split(" ").map(_.toInt)  
  var ans = 0
  var prev = a(0)

  (0 to a.length - 1).foreach {i =>
    val position = a(i) - 1
    ans = ans + b(position)

    if (prev == position - 1) ans = ans + c(prev)

    prev = position
  }

  println(ans)
}


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

int main() {
    int n; long long a[200000] = {}, b[200000] = {};
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        b[a[i] - 1]++;
    }
    long long ans = 0;
    for (int i = 0; i < n; i++) {
        if (b[i] >= 2) ans += b[i] * (b[i] - 1) / 2;
    }
    for (int i = 0; i < n; i++) {
        cout << ans - b[a[i]-1]+1 << endl;
    }
}


Measured memory_bytes: 5760