akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define ll long long

using namespace std;

struct Node
{
    int data;
    struct Node* left;
    struct Node* right;
    Node(int x)
    {
        data=x;
        left=NULL;
        right=NULL;
    }
};
#define Node struct Node

int main()
{
    int t=1;
    //cin>>t;
    while(t--)
    {
        int n;
        cin>>n;
        if(n==0)
            cout<<1<<endl;
        else
            cout<<0<<endl;
    }
    return 0;
}







Measured memory_bytes: 3612
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstring>
#include <string>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <ctime> 
using namespace std;

#define pb push_back
#define All(a) a.begin(), a.end()
#define met(a, b) memset(a, b, sizeof(a))
#define rep1(i, l, r) for(int i = l; i <= r; ++i)
#define rep2(i, l, r) for(int i = l; i < r; ++i) 
#define per(i, r, l) for(int i = r; i >= l; --i)
typedef long long ll;
typedef double db;
typedef long double ldb;
const int NIL = -1;
const int oo = 0x3f3f3f3f;
const ll INF = 2e18;
const db eps = 1e-8;
const db PI = acos(-1.0);
const int maxn = 1e5 + 7;

map<int, int> odd, even;
struct node
{
	int val, num;
	node(int a = 0, int b = 0):val(a), num(b){}
};

bool operator < (node a, node b)
{
	return a.num < b.num || a.num == b.num && a.val < b.val;
}

inline int read(void)
{
	int x = 0, f = 1; char ch = getchar();
	while(ch < '0' || ch > '9')	{ if(ch == '-') f = -1; ch = getchar(); } 
	while(ch >= '0' && ch <= '9') {	x = (x << 1) + (x << 3) + ch - '0';	ch = getchar();	}
	return x * f;
}

inline void write(int x)
{
	if(x < 0) { putchar('-'); x = -x; }
    if(x >= 10) write(x/10); 
	putchar(x%10+'0'); 
}

int main(void)
{
	int n = read();
	odd[0] = 0;
	even[0] = 0;
	rep1(i, 1, n)
	{
		int v = read();
		if(i&1)
		{
			odd[v]++;
		}
		else
		{
			even[v]++;
		}
	}
	priority_queue<node> pq1, pq2;
	for(map<int, int>::iterator it = odd.begin(); it != odd.end(); ++it)
	{
		pq1.push(node(it->first, it->second));
	}
	for(map<int, int>::iterator it = even.begin(); it != even.end(); ++it)
	{
		pq2.push(node(it->first, it->second));
	}
	node t1, t2, t3, t4;
	t1 = pq1.top(); t2 = pq2.top();
	pq1.pop(); pq2.pop();
	t3 = pq1.top(); t4 = pq2.top();
	if(t1.val != t2.val)
	{
		printf("%d", n - t1.num - t2.num);
	}
	else
	{
		int m = max(t1.num+t4.num, t2.num+t3.num);
		printf("%d", n - m);
	}
	
	return 0;
} 

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

using namespace std;
using ii = pair<int, int>;

class UFDS
{
private:
    std::vector<int> size, ps;
    int count;

public:
    UFDS(int N) : size(N + 1, 1), ps(N + 1), count(N)
    {
        std::iota(ps.begin(), ps.end(), 0);
    }

    int find_set(int x) 
    {
        return x == ps[x] ? x : (ps[x] = find_set(ps[x]));
    }

    bool same_set(int x, int y)
    {
        return find_set(x) == find_set(y);        
    }

    void union_set(int x, int y)
    {
        if (same_set(x, y))
            return;

        int p = find_set(x);
        int q = find_set(y);

        if (size[p] < size[q])
            std::swap(p, q);

        ps[q] = p;
        size[p] += size[q];
        --count;
    }

    int get_count() const { return count; }
};

int solve(int N, const vector<ii>& es)
{
    UFDS ufds(N);

    for (auto p : es)
    {
        auto x = p.first, y = p.second;

        ufds.union_set(x, y);
    }

    return ufds.get_count();
}

int main()
{
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;

    vector<ii> es(M);

    for (int i = 0; i < M; ++i)
    {
        int x, y, z;
        cin >> x >> y >> z;

        es.push_back(ii(x, y));
    }

    cout << solve(N, es) << endl;

    return 0;
}


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

const int mx=177;

// set up left and right sets
int r[mx][mx],m[mx],m1[mx],v[mx],N,M;

int dfs(int a) {
	if (a<0)
		return 1;
	if(v[a])
		return 0;
	v[a]=1;
	for (int i=0; i<M; i++) {
		if (r[a][i] && dfs(m1[i])) {
			m[a]=i, m1[i]=a;
			return 1;
		}
	}
	return 0;
}

int dfsExp(int a) {
	for (int i=0; i<N; i++)
		v[i]=0;
	return dfs(a);
}

int bipMatch() {
	int ret=0;
	for (int i=0; i<N; i++)
		m[i]=-1;
	for (int i=0; i<M; i++)
		m1[i]=-1;
	for (int i=0; i<N; i++)
		if(m[i]<0)
			ret+=dfsExp(i);
	return ret;
}

int main() {
	cin>>N; M=N;
	vector<int> a(N),b(N),c(N),d(N);
	for (int i=0; i<N; i++)
		cin>>a[i]>>b[i];
	for (int i=0; i<N; i++)
		cin>>c[i]>>d[i];
	for (int i=0; i<N; i++)
		for (int j=0; j<N; j++)
			if(a[i]<c[j] && b[i]<d[j])
				r[i][j]=true;
	cout<<bipMatch()<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
int fi[505][505];
signed main(){
	int h,w;
	cin>>h>>w;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			cin>>fi[i][j];
		}
	}
	int cnt = 0;
	vector< pair<int,int> > mae, ato;
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w-1;j++){
			if( fi[i][j] % 2 == 1 ){
				cnt ++ ;
				mae.pb( mp( i,j ) );
				ato.pb( mp(i,j+1) );
				fi[i][j]--;
				fi[i][j+1]++;
			}
		}
	}
	for(int i=1;i<=h-1;i++){
		if( fi[i][w] % 2 == 1 ){
			cnt ++ ;
			mae.pb( mp( i, w ) );
			ato.pb( mp(i+1, w ) );
			fi[i][w]--;
			fi[i+1][w]++;
		}
	}
	cout<<cnt<<endl;
	for(int i=0;i<cnt;i++){
		cout<<mae[i].first<<" "<<mae[i].second<<" "<<ato[i].first<<" "<<ato[i].second<<endl;
	}
	return 0;
}

Measured memory_bytes: 8804
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

int main(){

    int n, m;
    cin >> n >> m;

    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;

    return 0;
}

Measured memory_bytes: 256
S = input()

flg = False
for i in range(len(S)):
  if i % 2 == 0:
    if S[i] not in ['R', 'U', 'D']:
      flg = True
      break
  else:
    if S[i] not in ['L', 'U', 'D']:
      flg = True
      break

if flg:
  print('No')
else:
  print('Yes')


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

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define MOD 1000000007

#define trace1(x)                    cout <<#x<<": "<<x<< endl;
#define trace2(x, y)                 cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)              cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)           cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;

typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    ll i,j,n,m,a,b,t;
    cin>>a>>b>>t;
    cout<<(t/a)*b;
    return 0;
}

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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
//void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);

    int d,t,s;

    cin >> d >> t >> s;

    if(t*s >= d){
    	cout << "Yes";
    } else {
    	cout << "No";
    }

    return 0;
}












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

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define fori(n) for(int i = 0; i < n; ++i)
#define forj(n) for(int j = 0; j < n; ++j)
#define endl "\n";
typedef long long ll;
typedef pair<int, int> pii;

int32_t main(){
    IOS;
    string s;
    cin >> s;
    if (s == "AAA" || s == "BBB")
        cout << "No";
    else
        cout << "Yes";

}



Measured memory_bytes: 3608
#include <cstdio>
using namespace std;
 
#define sf scanf
 
int main() {
	int a, b; sf("%d %d", &a, &b);
	if (a % 3 == 0) printf("Possible\n");
	else if (b % 3 == 0) printf("Possible\n");
	else if ((a+b) % 3 == 0) printf("Possible\n");
	else printf("Impossible\n");
	return 0;
}

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

typedef long long lli;

const int N = 10;
const int INF = 1 << 29;

struct state{
  lli num;
  int cnt;
  state(lli num=0, int cnt=0):num(num),cnt(cnt){}
};

int n;
lli pow_10[11];
vector<int> v;

lli hash(const vector<int> &vec){
  lli res = 0, di = 1;
  
  for(int i=vec.size()-1;i>=0;i--){
    res += vec[i] * di;
    di *= 10;
  }

  return res;
}

lli reverse(lli num, int begin, int end){
  lli res = num;
  lli powbe = pow_10[begin], powen = pow_10[end];

  for(int i=0;i<(end-begin+1)/2;i++){
    res += powbe * (num / powen % 10 - num / powbe % 10);
    res += powen * (num / powbe % 10 - num / powen % 10);
    powbe *= 10;
    powen /= 10;
  }
  
  return res;
}

int bfs(lli num, map<lli, int> mp[2], int mp_pos){
  int res = INF;
  queue<state> q;
  state u, u2;

  mp[mp_pos][num] = 0;

  for(q.push(state(num, 0)); !q.empty();){
    u = q.front();
    q.pop();

    if(mp_pos == 1 && mp[0].count(u.num)) res = min(res, mp[0][u.num] + u.cnt);
    if(mp_pos == 0 && u.cnt >= 4 || u.cnt >= 5) continue;

    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
        u2 = state(reverse(u.num, i, j), u.cnt + 1);
        if(!mp[mp_pos].count(u2.num)){
          mp[mp_pos][u2.num] = u2.cnt;
          q.push(u2);
        }
      }
    }
  }

  return res;
}

int solve(){  
  vector<int> w = v;
  map<lli, int> mp[2];

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

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(v[i] == w[j]) {
        v[i] = j;
        break;
      }
    }
  }

  w = v;
  sort(w.begin(), w.end());

  bfs(hash(w), mp, 0);
  return bfs(hash(v), mp, 1);
}

int main(){
  pow_10[0] = 1;
  for(int i=1;i<11;i++) pow_10[i] = pow_10[i-1] * 10;

  while(cin >> n){
    v.clear();
    for(int i=0;i<n;i++){
      int x;
      cin >> x;
      v.push_back(x);
    }
    cout << solve() << endl;
  }
}

Measured memory_bytes: 113332
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    deque<int> b;
    rep(i,n){
        if(i % 2 == 0) b.push_back(a[i]);
        else b.push_front(a[i]);
    }
    if(n % 2 == 1)reverse(ALL(b));
    rep(i,n){
        int tmp = b.front();
        b.pop_front();
        printf("%d%c", tmp, i==n-1 ? '\n' : ' ');
    }
}

Measured memory_bytes: 3840
/*input 
100000 100000 44444 55555
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a, x) for (auto& a : x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)
#define resz resize

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 200001;
const ld PI = 4*atan((ld)1);

ll fac[MX], ifac[MX];

ll modpow(ll x, ll p) {
	return !p ? 1 : modpow((x * x) % MOD, p / 2) * (p & 1 ? x : 1) % MOD;
}

ll inv(ll x) { return modpow(x, MOD - 2); }

ll binom(ll a, ll b) {
        if (a < b || b < 0 || a < 0) return 0;
        ll tmp = fac[a]*ifac[b] % MOD;
        tmp = tmp*ifac[a-b] % MOD;
        return tmp;
} 

void comp() {
	fac[0] = ifac[0] = 1;
	FOR(i, 1, MX) {
		fac[i] = i * fac[i - 1] % MOD;
		ifac[i] = inv(fac[i]);
	}
}

ll H, W, A, B;

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

	cin >> H >> W >> A >> B;
	comp();

	ll ans = 0;
	ll mx = -1;
	FOR(i, B + 1, W + 1) {
		ll tmp = (binom(H - A + i - 2, H - A - 1) * binom(W + A - i - 1, A - 1));
		ans += tmp;
		ans %= MOD;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3328
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  int N;
  int v[22], c[22];

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

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

  int ans = -INF;

  for (int i = 0; i < (1 << N); ++i) {
    int x = 0;
    int y = 0;

    for (int j = 0; j < N; ++j) {
      if ((i >> j) & 1) {
        x += v[j];
        y += c[j];
      }
    }
    chmax(ans, x - y);
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
#define MOD (ll)(1e9+7)
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;


signed main(){
    ll n;
    cin >> n;
    ll a[n] = {};

    rep(i,0,n) cin >> a[i];

    sort(a,a+n);

    ll temp = LINF,memo = 0;
    rep(i,0,n-1){
        if(temp >= abs(a[n-1]/2 - a[i])){
            temp = abs(a[n-1]/2 - a[i]);
            memo = i;
        }
    }

    cout << a[n-1] << " " << a[memo] << endl;

    return 0;
}

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

int const N = 2e5 + 7;

set<int> st;
map<int, int> mp;
int main()
{
	int n; cin >> n;

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

	int res = 0;
	for (auto x : mp)
	{	
		if (x.second >= 2)
		{
			st.insert(x.first);
			continue;
		}

		bool check = true;
		for (int j = 1; j*j <= x.first; ++j)
			if (x.first % j == 0)
		{
			if (st.count(j) || st.count(x.first / j))
				check = false;
		}
		res += check;
		st.insert(x.first);
	}
	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 22344
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric> 
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
string ABC = "ABC";
bool solve(string s)
{
    while(1)
    {
        if(s == ABC) return true;
        if(s.size() <= 3) return false;
        char ch = 'B';
        if(s.substr(0, 3) == "ABC") ch = 'A';
        else if(s.substr(s.size() - 3) == "ABC") ch = 'C';
        int cnt = 0;
        string t = ""; t += ch;
        for(int i = 0; i < s.size()- 2; i++)
        {
            if(s.substr(i, 3) == "ABC")
            {
                s.replace(i, 3, t);
                cnt++;
            }
        }
        if(cnt == 0 || cnt != count(s.begin(), s.end(), ch)) break;
    }
    return false;
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
    string s;
    cin >> s;
    cout << (solve(s) ? "Yes" : "No") << endl;
	return 0;
}


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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
ll LCM(int a, int b){
    return a*b/gcd(a,b);
}

int main(void){
    int n;
    cin>>n;
    vector<ll> a(n),cnt(1e6+1);
    vector<bool> dp(1e6+1,true);
    set<int> st;
    rep(i,0,n){
        cin>>a[i];
        if(cnt[a[i]]!=0){
            cnt[a[i]]=2;
            continue;
        }
        for(int x=a[i];x<=1e6;x+=a[i])cnt[x]++;
    }

    int ans=0;
    for(auto i:a){
        if(cnt[i]==1){
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;

}

Measured memory_bytes: 12764
import java.util.Scanner;

public class Main {
	static String getFigure(Scanner sc) {
		StringBuilder str = new StringBuilder();
		int m = sc.nextInt();
		int startx = sc.nextInt();
		int starty = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int way = startx == x ? 0 : 1;
		String dir = "";
		if (y - starty < 0 || x - startx < 0) {
			way += 2;
		}
		int length = Math.abs(x - startx) + Math.abs(y - starty);
		str.append(length);
		for (int j = 2; j < m; j++) {
			int nextx = sc.nextInt();
			int nexty = sc.nextInt();
			int newway = nextx == x ? 0 : 1;
//			dir = nextx == x ? "L" : "R";
			if (nexty - y < 0 || nextx - x < 0) {
				newway += 2;
			}
			if (nexty - y < 0 || nextx - x < 0) {
				dir = way == 3 || way == 0 ? "L" : "R";
			} else {
				dir = way == 3 || way == 0 ? "R" : "L";
			}
/*			if (nextx == x) {
				if (nexty - y < 0) {
					dir = way == 3 ? "L" : "R";
				} else {
					dir = way == 3 ? "R" : "L";
				}
			} else {
				if (nextx - x < 0) {
					dir = way == 0 ? "L" : "R";
				} else {
					dir = way == 0 ? "R" : "L";
				}
			}*/
			str.append(dir);
			length = Math.abs(x - nextx) + Math.abs(y - nexty);
			str.append(length);
			x = nextx;
			y = nexty;
			way = newway;
		}
		return str.toString();
	}

	private static String Reverse(String str) {
		StringBuilder origin_rev = new StringBuilder();
		StringBuilder num = new StringBuilder();
		for (char c : str.toCharArray()) {
			if (Character.isDigit(c)) {
				num.append(c);
			} else if (c == 'L') {
				origin_rev.insert(0, num);
				origin_rev.insert(0, 'R');
				num = new StringBuilder();
			} else {
				origin_rev.insert(0, num);
				origin_rev.insert(0, 'L');
				num = new StringBuilder();
			}
		}
		origin_rev.insert(0, num);
		return origin_rev.toString();

	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			String origin = getFigure(sc);
			String origin_rev = Reverse(origin);
			for (int i = 0; i < n; i++) {
				String figure = getFigure(sc);
				if (origin.equals(figure) || origin_rev.equals(figure)) {
					System.out.println(i + 1);
				}
			}
			System.out.println("+++++");
		}
	}
}

Measured memory_bytes: 36448
#include <bits/stdc++.h>
using namespace std;
string s;
int main()
{
    cin>>s;
    int res=s.length()/2;
    for (int i=0;i<(int)s.length();++i)
        res-=s[i]=='p';
    printf("%d\n",res);
    return 0;
}


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

int main()
{
	int n;
	int a;//4
	int b;//2
	int c;//else
	while (cin >> n)
	{
		a = 0;
		b = 0;
		c = 0;
		int *p = new int[n];
		for (int i = 0; i < n; i++)
		{
			cin >> p[i];
			if (p[i] % 4 == 0)
			{
				a++;
			}
			else if (p[i] % 2 == 0)
			{
				b++;
			}
			else
			{
				c++;
			}
		}
		if ((b != 0 && a >= c) || (b == 0 && a >= c - 1))
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
		/*for (int i = 0; i < n; i++)
		{
			cout << p[i];
		}*/
		free(p);
	}

	return 0;
}

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

const ll mod = 1e9 + 7;
int n;
vector<vector<int>> adj;
vector<vector<ll>> dp;

ll solve(int cur, int prev, int col) {
	if (dp[cur][col] != -1)
		return dp[cur][col];
	ll tot = 0, w = 1;
	if (col == 0) {
		for (auto it : adj[cur]) {
			if (it != prev) {
				w = (w * solve(it, cur, 1)) % mod;
			}
		}
		tot += w;
	}
	w = 1;
	for (auto it : adj[cur]) {
		if (it != prev) {
			w = (w * solve(it, cur, 0)) % mod;
		}
	}
	tot = (tot + w) % mod;
	return dp[cur][col] = tot;
}

int main() {
	ios_base::sync_with_stdio(false);

	cin >> n;
	adj.resize(n);
	dp.resize(n);
	for (int i = 0; i < n; i++) {
		dp[i].resize(2, -1);
	}
	for (int i = 0; i < n - 1; i++) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	ll answer = solve(0, -1, 0);
	cout << answer;

	return 0;
}

Measured memory_bytes: 18176
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

void mod_inverse(int n, vector<long long>& inv, int mod)
{
    inv.assign(n+1, -1);
    inv[1] = 1;
    for(int i=2; i<=n; ++i)
        inv[i] = inv[mod % i] * (mod - mod / i) % mod;
}

class FactorialCalculation
{
private:
    const int mod;
    vector<long long> factorial;
    vector<long long> invFactorial;
public:
    FactorialCalculation(int n, int mod) : mod(mod)
    {
        factorial.resize(n+1, 1);
        invFactorial.resize(n+1, 1);
        vector<long long> inv;
        mod_inverse(n, inv, mod);
        for(int i=1; i<=n; ++i){
            factorial[i] = factorial[i-1] * i % mod;
            invFactorial[i] = invFactorial[i-1] * inv[i] % mod;
        }
    }
    long long getFactorial(int n){
        return factorial[n];
    }
    long long getInvFactorial(int n){
        return invFactorial[n];
    }
    long long getPermutation(int n, int r){
        if(n < r)
            return 0;
        return factorial[n] * invFactorial[n-r] % mod;
    }
    long long getCombination(int n, int r){
        if(n < r)
            return 0;
        return getPermutation(n, r) * invFactorial[r] % mod;
    }
    long long getHomogeneous(int n, int r){
        if(n == 0 && r == 0)
            return 1;
        return getCombination(n+r-1, r);
    }
};

const int MOD = 1000000007;

long long solve(int x, int y)
{
    int a = 2 * x - y;
    int b = 2 * y - x;
    if(a % 3 != 0 || b % 3 != 0 || a < 0 || b < 0)
        return 0;
    a /= 3;
    b /= 3;

    FactorialCalculation fc(a+b, MOD);
    return fc.getCombination(a+b, a);
}

int main()
{
    int x, y;
    cin >> x >> y;

    cout << solve(x, y) << endl;

    return 0;
}


Measured memory_bytes: 15872
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////
#define R(i,n) for(int i=0;i<(n);++i)
/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

template<typename T>
void chmin(T& a, T b) {
	a = min(a, b);
}

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////

void solve() {
	LL N, K;
	cin >> N >> K;
	vector<vector<int>>A(N, vector<int>(2));
	for (int i = 0; i < N; ++i) {
		cin >> A[i][0] >> A[i][1];
	}
	SO(A);
	
	for (int i = 0; i < N;++i) {
		if (K <= A[i][1]) {
			cout << A[i][0] << endl;
			return;
		}
		K -= A[i][1];
	}
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}

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

int main() {
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < 3; i++) {
    if (s.at(i) == 'o') {
      cnt++;
    }
  }

  int price = 700;
  price += (cnt * 100);
  cout << price << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<vector>
#include<cmath>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#define LL long long
using namespace std;

int n,m,pos[10010][2],f[10010];

struct edge{
    int u,v;
    double cost;
}es[1000010];

bool cmp(const edge& e1,const edge& e2){
    return e1.cost-e2.cost>1e-6;
}

int find(int x){
    return x==f[x]?x:f[x]=find(f[x]);
}

void join(int x,int y){
    int fx=find(x);
    int fy=find(y);
    if(fx!=fy) f[fx]=fy;
}

bool same(int x,int y){
    return find(x)==find(y);
}

int main(void){
    scanf("%d %d",&n,&m);
    int i;
    for(i=1;i<=n;i++){
        scanf("%d %d",&pos[i][0],&pos[i][1]);
    }
    double s=0;
    for(i=1;i<=m;i++){
        scanf("%d %d",&es[i].u,&es[i].v);
        int u=es[i].u,v=es[i].v;
        es[i].cost=sqrt((pos[u][0]-pos[v][0])*(pos[u][0]-pos[v][0])+(pos[u][1]-pos[v][1])*(pos[u][1]-pos[v][1]));
        s+=es[i].cost;
    }
    sort(es+1,es+1+m,cmp);
    for(i=1;i<=n;i++) f[i]=i;
    double sum=0;
    for(i=1;i<=m;i++){
        edge e=es[i];
        if(!same(e.u,e.v)){
            join(e.u,e.v);
            sum+=e.cost;
        }
    }
    printf("%.6lf\n",s-sum);
    return 0;
}




Measured memory_bytes: 3824
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

constexpr long long MOD = 1000000007;

int main() {
  int N, A, B, C, D;
  std::cin >> N >> A >> B >> C >> D;
  --A; --B; --C; --D;
  std::string str;
  std::cin >> str;
  bool AtoC = true;
  for (int i = A + 1; i < C; ++i)
  {
    if (str[i] == '#' && str[i + 1] == '#')
    {
      AtoC = false;
      break;
    }
  }
  bool BtoD = true;
  for (int i = B + 1; i < D; ++i)
  {
    if (str[i] == '#' && str[i + 1] == '#')
    {
      BtoD = false;
      break;
    }
  }
  if (C < B || C < D)
  {
    std::cout << (AtoC && BtoD ? "Yes" : "No") << std::endl;
  }
  else
  {
    bool canOver = false;
    for (int i = B - 1; i < D; ++i)
    {
      if (i + 2 < str.size() && str[i] == '.' && str[i + 1] == '.' && str[i + 2] == '.')
      {
        canOver = true;
        break;
      }
    }
    std::cout << (AtoC && BtoD && canOver ? "Yes" : "No") << std::endl;
  }
  return 0;
}



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

int main() {
  int64_t a, b, c, d, l;
  cin >> a >> b >> c >> d;
  l = c / __gcd(c, d) * d;
  cout << b - a + 1 - (b/c - (a-1)/c) - (b/d - (a-1)/d) + (b/l - (a-1)/l) << 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)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    ll ans;
    ans = n * (n - 1) / 2;
    cout << ans << endl;
    
    return 0;
}



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

typedef pair<int,int> PII;

int main(){
	int n;
	cin>>n;
	double total=0;
	for (int i = 0; i < n; ++i){
		double b;
		string s;
		cin>>b>>s;
		if(s=="JPY")
			total += b;
		else
			total += b * 380000;
	}

	cout<<total<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
using P = pair<int,int>;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    ll n,a,b;
    cin >> n >> a >> b;
    ll nca = 1,ncb = 1;
    REP(i,a){
        nca *= (n-i)*modinv(i+1,mod)%mod;
        nca%=mod;
    }
    REP(i,b){
        ncb *= (n-i)*modinv(i+1,mod)%mod;
        ncb %= mod;
    }
    ll answer = modpow(2,n,mod) - ncb - nca - 1;
    answer %= mod;
    if(answer < 0)answer += mod;
    cout <<answer<< "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
#define mpi 3.14159265359

int main()
{
    double a,b,x;
    cin >> a >> b >> x;

    double tnum = (2*a*a*b-2*x)/(a*a*a);
    double tnum2 = (b*b*a)/(2*x);
    double arct = atan(tnum);
    double arct2 = atan(tnum2);
    double ans = arct *180 / mpi;
    double ans2 = arct2 * 180 / mpi;

    if(b-x/(a*a) < x/(a*a))
    {
        cout << fixed << setprecision(10) << ans << endl;
    }
    else
    {
        cout << fixed << setprecision(10) << ans2 << endl;
    }   
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static int process(TestCase testCase) {
        int X = testCase.X;
        int Y = testCase.Y;

        return X + Y / 2;
    }

    private static boolean is753(int x) {
        return x == 7 || x == 5 || x == 3;
    }

    // Util func

    public static void main(String[] args) {
        TestCase testCase = readFromInput();

        final int result = process(testCase);

        output(result);
    }

    private static TestCase readFromInput() {
        Scanner sc = new Scanner(System.in);

        int X = sc.nextInt();
        int Y = sc.nextInt();

        sc.close();
        return new TestCase(X, Y);
    }

    private static void output(int result) {
        System.out.println(result);
    }

    public static class TestCase {
        final int X;
        final int Y;

        public TestCase(int X, int Y) {
            this.X = X;
            this.Y = Y;
        }
    }
}


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

int main() {
    int A, B;
    cin >> A >> B;
    if(A != 1 && B != 1){
        cout << 1 << endl;
    }else if(A != 2 && B != 2){
        cout << 2 << endl;
    }else{
        cout << 3 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

    int64_t x, y;
    for (int i = 0; i < n; i++) {
        int64_t t, a;
        cin >> t >> a;
        if (i == 0) {
            x = t; y = a;
        } else {
            int64_t c = (x + t - 1) / t;
            int64_t d = (y + a - 1) / a;
            c = max(c, d);
            t *= c;
            a *= c;
            x = t; y = a;
        }
    }

    cout << x + y << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int calc(int n){
    int cnt = 0;
    while(n){
        n/=10;
        ++cnt;
    }
    return cnt%2;
}
int main(){
    int n;
    cin>>n;
    int ans=0;
    rep(i,n+1)ans+=calc(i);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 1e6+10;

int main(){
    string s;
    cin>>s;
    REP(i,SZ(s))REP(j,i)
        if(s[j]=='C'&&s[i]=='F')return 0*puts("Yes");
    return 0*puts("No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 1e6+1;
int n, q;
ll _D[N],  *D=_D+1;
ll _M[N],  *M=_M+1;
ll _DM[N], *DM=_DM+1;
string s;
bool z[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> s >> q;
  FOR(i, 0, n){
    D[i] = D[i-1];
    M[i] = M[i-1];
    DM[i] = DM[i-1];
    if(s[i]=='D') D[i]++;
    if(s[i]=='M') DM[i] += D[i-1], M[i]++;
    if(s[i]=='C') z[i] = true;
  }
  FOR(_, 0, q){
    int k;
    cin >> k;
    ll ans = 0;
    FOR(i, 0, k) if(z[i]) ans += DM[i];
    FOR(i, k, n) if(z[i]) ans += DM[i]-DM[i-k]-D[i-k]*(M[i]-M[i-k]);
    cout << ans << endl;
  }
}

Measured memory_bytes: 25756
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int MOD = 1e9+7;
int n,m;
char a[1010][1010];
ll dp[1010][1010];
ll rec(int i=0,int j=0)
{
    if(i==n-1&&j==m-1)
        return 1;
    if(i==n || j==m)
        return 0;
    if(dp[i][j]+1)
        return dp[i][j];
    ll Down,Right;
    Down = Right = 0;
    if(a[i+1][j]!='#')
        Down  = rec(i+1,j)%MOD;
    if(a[i][j+1]!='#')
        Right = rec(i,j+1)%MOD;
    return dp[i][j] = (Down+Right)%MOD;
}

int main()
{
    memset(dp,-1,sizeof dp);
    cin >> n >> m;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cin >> a[i][j];
    cout << rec();
    return 0;
}


Measured memory_bytes: 9344
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int, int>
#define f first
#define s second 
using namespace std;
const LL INF = (LL) 1e9 + 5;
const LL MOD = (LL) 1e9 + 7;
//const int MAXN = 200005;

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

	LL k, qn;
	cin >> k >> qn;
	
	vector<LL> d_origin(k);
	for (int i = 0; i < k; i++) {
		cin >> d_origin[i];
	}
	
	for (int i = 0; i < qn; i++) {
		LL n, x, m, sum = 0;
		vector<LL> d(d_origin);
		cin >> n >> x >> m;
		n--;
		
		LL zcnt = 0;
		for (LL &v : d) {
			v %= m;
			sum += v;
			zcnt += (v == 0);
		}
		
		LL s = x / m, fin = x + sum * (n / d.size()), zero = zcnt * (n / d.size());
		for (int i = 0; i < n % d.size(); i++) {
			fin += d[i];
			if (d[i] == 0) {
				zero++;
			}
		}
		
		LL t = fin / m;
		cout << n - (t - s) - zero << '\n';
	}

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <math.h>
#include <string>
#include <time.h>
#include <random>
#include <memory.h>
#include <bitset>
using namespace std;

#define FILE0
#define MAGIC0
mt19937 rnd(time(0)); //rnd()

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mii map<int, int>
#define mll map<ll, ll>
#define msl map<string, ll>
#define mls map<ll, string>
#define MOD (1000000007ll)
#define MOD2 (1000000009ll)
#define BIGMOD (1000000000000000007ll)
#define RMOD int(5e8 + rnd() % (int) 5e8)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifdef FILE1
ifstream in("input.txt");
ofstream out("output.txt");
#endif
#ifdef MAGIC1
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#endif

bool isPrime(ll a)
{
	ll i;
	for (i = 2; i*i <= a; i++)
	{
		if (a%i == 0)
		{
			return 0;
		}
	}
	return (a != 1);
}

bool isPalindrom(const string &s, int l, int r)
{
	for (int i = 0; i < (r - l + 1) / 2; i++)
	{
		if (s[l + i] != s[r - i])
		{
			return 0;
		}
	}
	return 1;
}

template <class type1> type1 gcd(type1 a, type1 b)
{
	type1 t;
	while (b)
	{
		t = b;
		b = a%b;
		a = t;
	}
	return a;
}

ll positiveMod(ll v, ll md)
{
	v = v%md;
	if (v < 0)
	{
		v += md;
	}
	return v;
}

//-----------------------------------------------------end--------------------------------------//

set <pll> dat;

set <pll> res[10];

int main()
{
	fast;

	ll n, m, k, i, j, a, b, c, kk, x, y;

	cin >> n >> m >> k;

	for (i = 0; i < k; i++)
	{
		cin >> a >> b;

		dat.insert({ a, b });
	}

	for (auto it : dat)
	{
		for (i = max(1ll, it.first - 2); i <= min(n - 2, it.first); i++)
		{
			for (j = max(1ll, it.second - 2); j <= min(m - 2, it.second); j++)
			{
				kk = 0;

				for (x = 0; x < 3; x++)
				{
					for (y = 0; y < 3; y++)
					{
						if (dat.find({ i + x, j + y }) != dat.end())
						{
							kk++;
						}
					}
				}

				res[kk].insert({ i, j });
			}
		}
	}

	ll res0 = (n - 2)*(m - 2);

	for (i = 1; i < 10; i++)
	{
		res0 -= res[i].size();
	}
	
	cout << res0 << "\n";
	for (i = 1; i < 10; i++)
	{
		cout << res[i].size() << "\n";
	}

	return 0;
}

Measured memory_bytes: 62720
import java.util.*

val sc = Scanner(System.`in`)
val N = sc.nextInt()
val M = sc.nextInt()

fun main(args: Array<String>) {
    val cities = Array(N) { 0 }

    for (i in 1..M) {
        val a = sc.nextInt()
        val b = sc.nextInt()
        cities[a - 1]++
        cities[b - 1]++
    }
    for (roads in cities){
        println(roads)
    }
}


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

typedef long long ll;
typedef pair<int,int> P;

const int INF=1e9;
const int MOD=1e9+7;
bool used[110][110]={};

int main(){
    int N; cin >> N;
    vector<pair<int,int>> ans;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            if(N%2==0&&i!=j&&(i+j)!=(N+1)&&!used[i][j]){
                ans.push_back({i,j});
                used[i][j]=used[j][i]=true;
            }else if(N%2==1&&i!=j&&(i+j)!=N&&!used[i][j]){
                ans.push_back({i,j});
                used[i][j]=used[j][i]=true;
            }
        }
    }
    cout << ans.size() << endl;
    for(int i=0;i<ans.size();i++){
        cout << ans[i].first << " " << ans[i].second << endl;
    }
}

Measured memory_bytes: 3692
from bisect import bisect_left, bisect_right

a,b,c,d,e,f= map(int, input().split())
a *= 100
b *= 100

ws = set()
for i in range(31):
    for j in range(31):
        v = a*i + b*j
        if 0 < v <= f:
            ws.add(v) 
waters = list(ws)
waters.sort()

ss = set()
for i in range(3001):
    for j in range(3001):
        v = i*c +j*d
        if v <= f:
            ss.add(v)
        else:
            break 

sugars = list(ss)
sugars.sort()

max_sugar, max_water = 0, waters[0]
for w in waters:
    s_max1 = f - w
    s_max2 = (w//100)*e
    s_max = min(s_max1, s_max2)
    ind = bisect_right(sugars, s_max) - 1
    ind = ind if 0 <= ind < len(sugars) else None
    if ind is None:
        continue
    else:
        sugar = sugars[ind] if ind is not None else None
        if sugar*(max_sugar+max_water) > max_sugar*(sugar+w):
            max_sugar = sugar
            max_water = w

print(max_sugar+max_water, max_sugar)


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


int main() {
    int N, x;
    cin >> N >> x;

    int A[N];
    rep(i, N) cin >> A[i];
    sort(A, A+N);

    int ans = 0;
    rep(i, N) {
        x -= A[i];
        if (x < 0) {
            ans = i;
            break;
        } else if (x == 0) {
            ans = i + 1;
            break;
        } else {
            ans = i;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3496
/* 
 * File:   main.c
 * Author: s1252007
 *
 * Created on June 26, 2018, 11:17 AM
 */

#include <stdio.h>
#include <stdlib.h>

/*
 * 
 */

int linearSearch(int *S, int n, int *T, int q);

int main(int argc, char** argv) {
    int n, q;
    int *S, *T;
    scanf("%d", &n);
    S = (int *)malloc(sizeof(int) * n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &S[i]);
    }
    scanf("%d", &q);
    T = (int *)malloc(sizeof(int) * q);
    for (int j = 0; j < q; j++)
    {
        scanf("%d", &T[j]);
    }
    
    printf("%d\n", linearSearch(S, n, T, q));
    return (EXIT_SUCCESS);
}

int linearSearch(int *S, int n, int *T, int q)
{
    int counter = 0;
    for (int i = 0; i < q; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (S[j] == T[i]) 
            {
                counter++;
                break;
            }
        }
    }
    return counter;
}




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

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

  vector<int> ans(n+1, -1);
  queue<int> Q;
  Q.push(1);
  ans[1] = 0;

  while (!Q.empty()) {
    int x;
    x = Q.front();
    Q.pop();

    for (auto node: G[x]) {
      if (ans[node] != -1) continue;
      ans[node] = x;
      Q.push(node);
    }
  }

  cout << "Yes" << endl;
  for (int i = 2; i <= n; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}

Measured memory_bytes: 10136
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 

int main(){
	long long N,ans=1,X[26]={}; cin >> N;
	string S; cin >> S;
	for(int i=0; i<N; i++){
		for(int j=0; j<26; j++){
			if(S[i]=='a'+j) X[j]+=1;
		}
	}
	for(int i=0; i<26; i++){
		ans*=X[i]+1;
      ans%=1000000007;
	}
	cout << ans-1 << endl;
}


Measured memory_bytes: 512
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

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

	LL b = h * W + H * w - h * w;

	LL ans = H * W - b;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#define MIN -1000000
using namespace std;
typedef long long ll;
typedef pair <int, int> pll;
bool visited[100005];
const int max_N = 1e5 + 10;

string S;
int countA;
int countB;

int main(void) {
  cin >> S;
  for(int i=0; i<S.size(); i++){
    if(int(S[i]-'0')==(i%2))countA++;
    else countB++;
  }
  //cout << countA << ' ' << countB << endl;
  cout << min(countA, countB) << endl;
  return 0;
}



Measured memory_bytes: 512