akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n;
	cin>>n;
	vector<int> a(n), p(n), s(n);
	for(int i = 0; i < n; i++){
		cin>>a[i];
		p[i] = a[i];
		if(i)p[i] = max(p[i], p[i - 1]);
	}
	for(int i = n - 1; i >= 0; i--){
		s[i] = a[i];
		if(i + 1 < n)s[i] = max(s[i], s[i + 1]);
	}
	for(int i = 0; i < n; i++){
		int ans = 0;
		if(i)ans = max(ans, p[i - 1]);
		if(i + 1 < n)ans = max(ans, s[i + 1]);
		cout<<ans<<'\n';
	}

	return 0;
}

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

using namespace std;


#define MAXK 1001
int n, k, w[2*MAXK][2*MAXK];
int sm(int x1, int y1, int x2, int y2) {
  return w[x2][y2] - w[x1-1][y2] - w[x2][y1-1] + w[x1-1][y1-1];
}

int calc(int x, int y) {
  return sm(1, 1, x, y) + sm(x+1, y+1, x+k, y+k) + sm(x+k+1, 1, 2*k, y) + sm(1, y+k+1, x, 2*k) + sm(x+k+1, y+k+1, 2*k, 2*k);
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> k;
  for (int i = 0; i < n; ++i) {
    int x, y;
    char c;
    cin >> x >> y >> c;
    if (c=='B') y += k;
    w[x%(2*k)+1][y%(2*k)+1]++;
  }
  for (int x = 1; x <= 2*k; ++x)
    for (int y = 1; y <= 2*k; ++y)
      w[x][y] += w[x-1][y] + w[x][y-1] - w[x-1][y-1];
  int ans = 0;
  for (int x = 1; x <= k; ++x)
    for (int y = 1; y <= k; ++y)
      ans = max(ans, max(calc(x, y), n-calc(x, y)));
  cout << ans << endl;
  return 0;
}


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

bool check(string str, int &a, int &b)
{
    int L = str.size();
    auto cs = str.c_str();
    for (int i = 0; i < L; ++i)
    {
        char c = cs[i];
        if (i + 1 < L && c == cs[i + 1])
        {
            a = i + 1, b = i + 1 + 1;
            return true;
        }
        else if (i + 2 < L && c == cs[i + 2])
        {
            a = i + 1, b = i + 2 + 1;
            return true;
        }
    }
    return false;
}

int main()
{
    string str;
    getline(cin, str);
    int a = -1, b = -1;

    check(str, a, b);
    printf("%d %d", a, b);

    return 0;
}			

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return (ans.x+m)%m;
}
int fact[N];
void calfac(int n ){
fact[0] = 1;
for(int i = 1 ; i <= n+2; i++){
 fact[i] = (((fact[i-1]%mod)*(i%mod))%mod + mod)%mod;
}
 }
int calc(int n , int r){
 if(r > n)return 0;
 if(r == n)return 1;
 int ans = 1;
 ans = ((ans%mod)*(fact[n])%mod + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[n-r] , mod)%mod) + mod)%mod;
 ans = ((ans%mod)*(mmInverse(fact[r] , mod)%mod) + mod)%mod;
 return (ans+mod)%mod;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin>>n;
map<string , int> m;
for(int i = 0 ; i  < n; i++){
 string str;
 cin>>str;
 m[str]++;
}
cout<<(int)m.size()<<endl;
}


Measured memory_bytes: 19220
#include <stdio.h>

int main(void) {
  int i, j, k, n, m;
  scanf("%d%d", &n, &m);
  int a[m], b[m][n], ans[n];
  for(i = 0; i < m; ++i) scanf("%d", &a[i]);
  for(i = 0; i < m; ++i) for(j = 0; j < n; ++j) scanf("%d", &b[i][j]);
  for(i = 0; i < n; ++i) ans[i] = 0;
  for(i = 0; i < m; ++i) {
    int t = 0;
    for(j = 0; j < n; ++j) {
      if(a[i] == b[i][j]) ans[j]++;
      else t++;
    }
    ans[a[i] - 1] += t;
  }
  for(i = 0; i < n; ++i) printf("%d\n", ans[i]);
  return 0;
}


Measured memory_bytes: 2764
using System;
using System.Linq;
using System.Collections.Generic;

public static class Program {
    public static void Main() {
        int[]nk=Console.ReadLine().Split().Select(int.Parse).ToArray();
        int n=nk[0];
        int k=nk[1];
        int[]a=Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[]dp=new int[n];
        for(int i=1;i<n;i++) {
            dp[i]=int.MaxValue;
            for(int j=Math.Max(0,i-k);j<i;j++){
                int x=a[i]-a[j];
                if(x<0)x=-x;
                dp[i]=Math.Min(dp[i],dp[j]+x);
            }
        }
        Console.WriteLine(dp[n-1]);
    }
}



Measured memory_bytes: 20064
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    string s,t; cin >> s >> t;
    int ans = 0;
    rep(i,3) {
        if (s[i] == t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   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;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

    int main(){
        lint n,q;
        string s;
        cin>>n;
        if(n==0)cout<<1<<endl;
        else cout<<0<<endl;
    
    
    }
      

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
    int r;
    cin >> r;
    cout << 3*r*r << "\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ; 
const int INF = 1001001001 ; 


int main () {
  int N ,M ,X  ;
  cin >> N >> M >> X ; 
  
  vector<int> C(N) ; 
  vector<vector<int>> A(N , vector<int>(M)) ;  
  vector<int> sum(M) ; 

  for(int i = 0 ; i< N ; i++){
    cin >> C.at(i) ;
    for(int j = 0 ; j < M ; j++){
      cin >> A.at(i).at(j) ; 
    }
  }
  
  //bit全探索
  int ans = INF ; 
  for(int s = 0 ; s < (1 << N) ; s++){
    int cost = 0 ;
    vector<int> d(M) ;  
    for(int i = 0 ; i < N ; i++){
      if (s >> i&1){ //sのi bitsが立っている時だけ
        cost += C.at(i)  ;
        for(int j = 0 ; j < M ; j++){
          d.at(j) += A.at(i).at(j) ; 
        }
      }
    }
    bool ok = true ; 
    for(int j = 0 ; j < M ; j++) {
      if(d.at(j) < X ) ok = false ;
    }
    if(ok) ans = min(ans,cost) ; 
    
  }
  if(ans == INF) cout << -1 << endl ; 
  else cout << ans << endl;
  
  return 0 ; 
}

Measured memory_bytes: 3608
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String a = sc.next();
    String b = sc.next();
    String c = sc.next();
    a=a.toUpperCase();
    b=b.toUpperCase();
    c=c.toUpperCase();
    System.out.println(a.substring(0,1)+b.substring(0,1)+c.substring(0,1));

  }
  

  
}


Measured memory_bytes: 21844
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[n];
		for(int i = 0;i < n;i++){
			a[i] = saori.saori_hayami();
			b[i] = saori.saori_hayami();
			c[i] = saori.saori_hayami();
		}
		int[][] dp = new int[n][3];
		dp[0][0] = a[0];
		dp[0][1] = b[0];
		dp[0][2] = c[0];

		for(int i = 1;i < n;i++){
			dp[i][0] = Math.max(dp[i-1][1] + a[i], dp[i-1][2] + a[i]);
			dp[i][1] = Math.max(dp[i-1][0] + b[i], dp[i-1][2] + b[i]);
			dp[i][2] = Math.max(dp[i-1][0] + c[i], dp[i-1][1] + c[i]);	
		}
		int ans = 0;
		for(int i = 0;i < 3;i++){
			ans = Math.max(ans, dp[n-1][i]);
		}
		System.out.println(ans);
		
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

using namespace std;

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

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

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

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

const int MAXN = (int) 5e4, MAXV = (int) 1e6;

struct edge
{
	int u, v, w;

	edge() { }
	edge(int _u, int _v, int _w): u(_u), v(_v), w(_w) { }
};

int n, m, Q, MOD;

edge e[MAXN + 5];

inline void input()
{
	n = read<int>(), m = read<int>(), Q = read<int>(), MOD = read<int>();
	for(int i = 1; i <= m; ++i) e[i].u = read<int>(), e[i].v = read<int>(), e[i].w = read<int>();
}

namespace SET
{
	const int MAX_NODE = MAXN * 6;

	int fa[MAX_NODE + 5];

	inline void init(int N) { for(int i = 1; i <= N; ++i) fa[i] = i; }
	inline int get_fa(int u) { return u == fa[u] ? u : fa[u] = get_fa(fa[u]); }
	inline void link(int u, int v) { fa[get_fa(u)] = get_fa(v); }
	inline bool p(int u, int v) { return get_fa(u) == get_fa(v); }
}

inline void solve()
{
	int g = 0;
	for(int i = 2; i <= m; ++i) g = __gcd(g, abs(e[i].w - e[1].w));
	if(g == 0) g = MOD;
	MOD = __gcd(MOD, 3 * g);

	static int id[MAXN + 5][3][2], cnt = 0;

	for(int i = 1; i <= n; ++i)
		for(int j = 0; j < 3; ++j)
			for(int k = 0; k < 2; ++k)
				id[i][j][k] = ++cnt;

	SET::init(cnt);
	int z = e[1].w % g;
	for(int i = 1; i <= m; ++i)
	{
		int u = e[i].u, v = e[i].v, w = (e[i].w - z) / g % 3;
		for(int j = 0; j < 3; ++j)
		{
			SET::link(id[u][j][0], id[v][(j * 2 + w) % 3][1]);
			SET::link(id[u][j][1], id[v][(j * 2 + w) % 3][0]);
			SET::link(id[v][j][0], id[u][(j * 2 + w) % 3][1]);
			SET::link(id[v][j][1], id[u][(j * 2 + w) % 3][0]);
		}
	}

	static int vis[2][MAXV + 5];

	for(int i = 0, res = z; i < MOD * 2; ++i, (res *= 2) %= MOD) vis[i & 1][res] = 1;

	while(Q--)
	{
		int u = read<int>(), v = read<int>(), r = read<int>();

		bool fg = 0;
		for(int x = 0; x < 3; ++x)
		{
			for(int y = 0; y < 2; ++y)
				if(SET::p(id[v][0][0], id[u][x][y]) && vis[y][((r + z - (LL) x * g % MOD) % MOD + MOD) % MOD]) { fg = 1; break; }
			if(fg) break;
		}

		puts(fg ? "YES" : "NO");
	}
}

int main()
{
#ifndef ONLINE_JUDGE
//	freopen("F.in", "r", stdin);
//	freopen("F.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}



Measured memory_bytes: 11136
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;
     
    int main() {
      string a, b, c;
      cin >> a >> b >> c;
     
      if (a[a.length() - 1] == b[0] && b[b.length() - 1] == c[0]) {
        cout << "YES" << endl;
      } else {
        cout << "NO" << endl;
      }
     
      return 0;
    }

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

					using namespace std;
					typedef long long ll;
					int n, m, s;
					int main()
					{
						cin >> n >> m;
						for(int i = 1; i < n; i++)
							s += i;
						for(int i = 1; i < m; i++)
							s += i;
						cout << s;		
					}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>

using namespace std;
typedef long long int ll;typedef pair<int, int> P;
const long long mod = 1e9 + 7;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define ALL(a) (a).begin(),(a).end()

int main(void) {
	int n; cin >> n;
	set<string> s;
	string str; cin >> str;
	s.insert(str);
	char x = *(str.end() - 1);
	bool f = 1;
	rep(i, n - 1) {
		cin >> str;
		if(x!=*(str.begin()))f=0;
		if (s.count(str) != 0)f = 0;
		s.insert(str);
		x = *(str.end() - 1);
	}
	cout << (f ? "Yes" : "No") << endl;
	return 0;
}

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

long long lcm(long long x, long long y) {
  long long r;
  long long t = x * y; 
  if (x < y) {
    long long temp = x;
    x = y;
    y = temp;
  }
  
  r = x % y;
  while(r!=0){
    x = y;
    y = r;
    r = x % y;
  }
  
  return t / y;
}
 
int main() {
  long long A,B;
  cin >> A >> B;
  long long C,D;
  cin >> C >> D;
  
  long long c = B / C;
  long long d = B / D;
  long long e = B / lcm(C,D);
  long long b = B - c - d + e;
  long long f = (A - 1) / C;
  long long g = (A - 1) / D;
  long long h = (A - 1) / lcm(C,D);
  long long a = A - 1 - f - g + h;
  cout << b - a << endl;
}

Measured memory_bytes: 256
/* ****revpro**** */
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define endl	   '\n'
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)    
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define mii	    map<ll,ll>
using namespace std;

#define N  100005
ll add(ll x,ll y,ll mod) { x += y; if(x >= mod) x -= mod; return x;}
ll sub(ll x,ll y,ll mod) { x -= y; if(x < 0) x += mod; return x;}
ll mul(ll x,ll y,ll mod) { return (x * 1ll * y) % mod;}
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		map <ll,ll> m;
		m[0]++;
		ll n,k;
		cin>>n>>k;
		if(k==1){ cout<<0;return 0;}
		ll pre[n+1]={0};
		pre[0]=0;
		ll ans=0;
		rep(i,0,n){
			ll cur;
			cin>>cur;
			pre[i+1]=(pre[i]+cur)%k;
			pre[i+1]=(pre[i+1]-1+k)%k;
			ans+=m[pre[i+1]];
			m[pre[i+1]]++;
			if((i-k+2)>=0) m[pre[i-k+2]]--; 
		}
		cout<<ans;
	}
	return 0;
}

Measured memory_bytes: 14336
import numpy as np
 
h, w, k = list(map(int, input().split(' ')))
c = []
for i in range(h):
    c.append(np.array(list(list(input()))))
 
c = np.array(c)
ans = 0
 
h_comb = [[]]
for i in range(h):
    h_comb.append([i])
    for j in range(i+1, h):
        h_comb.append([i, j])
        for l in range(j+1, h):
            h_comb.append([i, j, l])
            for m in range(l+1, h):
                h_comb.append([i, j, l, m])
                for n in range(m+1, h):
                    h_comb.append([i, j, l, m, n])
                    for o in range(n+1, h):
                        h_comb.append([i, j, l, m, n, o])
 
w_comb = [[]]
for i in range(w):
    w_comb.append([i])
    for j in range(i+1, w):
        w_comb.append([i, j])
        for l in range(j+1, w):
            w_comb.append([i, j, l])
            for m in range(l+1, w):
                w_comb.append([i, j, l, m])
                for n in range(m+1, w):
                    w_comb.append([i, j, l, m, n])
                    for o in range(n+1, w):
                        w_comb.append([i, j, l, m, n, o])
 
 
for h_indice in h_comb:
    for w_indice in w_comb:
        a = c.copy()
        if len(h_indice) != 0:
            for i in h_indice:
                a[i, :] = 'x'
        if len(w_indice) != 0:
            for i in w_indice:
                a[:, i] = 'x'
        cnt = np.count_nonzero(a=='#')
        if cnt == k:
            ans += 1
 
print(ans)

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int A, B, T;
    cin >> A >> B >> T;
    int ans = 0;
    for (int i = A; i <= T; i+=A) {
        ans += B;
    }
    cout << ans << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

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

using namespace std;

typedef long long int li;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}
    
int main()
{    
    ios_base::sync_with_stdio(false);
        cin.tie(NULL);

        li n;

        cin>>n;

        string s;

        cin>>s;

        f(i,0,s.length())
        {
            s[i]=char(s[i]+n);

            if(s[i]>'Z')
                s[i]=char(s[i]-26);
        }

        cout<<s;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int fc(int x)
{
	if (x % 100 != 0)return 0;
	return fc(x / 100) + 1;
}

int main()
{
	int D = 0, N = 1;
	cin >> D >> N;
	 
	int count =0;

	for (int i = 1;; i++)
	{
		if (fc(i) == D)
		{
			count++;
			if (count == N)
			{
				cout << i << endl;
				return 0;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    B = [a[i]-i-1 for i in range(len(a))]
    B.sort()
    ans = 0
    for i,aa in enumerate(a):
        ans+=abs(aa-(i+1)-B[len(B)//2])
    print(ans)


if __name__ == '__main__':
    main()

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

int main(void) {
	
	int N, a, b, c, d;
	scanf("%d", &N);
	a = N / 1000;
	b = N / 100 % 10;
	c = N / 10 % 10;
	d = N % 10;

	if (a == b && b == c) printf("Yes\n");
	else if (b == c && c == d) printf("Yes\n");
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 128
/**************************************
 * Au: Hany01
 * Prob: agc002e
 * Date: Oct 20th, 2018
 * Email: hany01@foxmail.com
**************************************/

#include<bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define File(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout)
#define Rep(i, j) for (register int i = 0, i##_end_ = j; i < i##_end_; ++ i)
#define For(i, j ,k) for (register int i = (j), i##_end_ = (k); i <= i##_end_; ++ i)
#define Fordown(i, j, k) for (register int i = (j), i##_end_ = (k); i >= i##_end_; -- i)
#define Set(a, b) memset(a, b, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define SZ(a) ((int)(a.size()))
#define ALL(a) a.begin(), a.end()
#define PB(a) push_back(a)
#define MP(a, b) make_pair(a, b)
#define X first
#define Y second
#define INF (0x3f3f3f3f)
#define INF1 (2139062143)
#define y1 wozenmezhemecaia 
#ifdef hany01
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline T read() {
    register char c_; register T _, __;
    for (_ = 0, __ = 1, c_ = getchar(); !isdigit(c_); c_ = getchar()) if (c_ == '-')  __ = -1;
    for ( ; isdigit(c_); c_ = getchar()) _ = (_ << 1) + (_ << 3) + (c_ ^ 48);
    return _ * __;
}
//EOT


const int maxn = 1e5 + 5;

int n, a[maxn];

int main()
{
#ifdef hany01
    File("agc002e");
#endif

	For(i, 1, n = read<int>()) a[i] = read<int>();
	sort(a + 1, a + 1 + n), reverse(a + 1, a + 1 + n);

	Fordown(i, n, 1) if (a[i] >= i) {
		int t = i;
		while (a[t + 1] == i) ++ t;
		puts((((t - i) & 1) || ((a[i] - i) & 1)) ? "First" : "Second");
		return 0;
	}

    return 0;
}

//Analysis:
//1. 将数列从大到小排序，是一个阶梯型，操作看作是删掉左边一列或下面一行。也可以看作是从(1,1)出发，每次走(1,0)或(0,1)
//2. 结论：(x,y)的胜败态和(x+1,y+1)相同
//所以只要求出(x,x)的胜败态即可


Measured memory_bytes: 640
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N,M = map(int,input().split())
AA = []
for _ in range(N):
    KA = list(map(int,input().split()))
    AA.append(KA[1::])

from collections import defaultdict
dic = defaultdict(int)
for A in AA:
    for a in A:
        dic[a] += 1

ans = 0
for v in dic.values():
    if v==N:
        ans += 1

print(ans)

Measured memory_bytes: 3316
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        int k = sc.nextInt();

        List<Long> aValues = new ArrayList<>(x);
        List<Long> bValues = new ArrayList<>(y);
        List<Long> cValues = new ArrayList<>(z);

        for (int i = 0; i < x; i ++){
            aValues.add(sc.nextLong());
        }
        for (int i = 0; i < y; i ++){
            bValues.add(sc.nextLong());
        }
        for (int i = 0; i < z; i ++) {
            cValues.add(sc.nextLong());
        }

        aValues.sort(Collections.reverseOrder());
        bValues.sort(Collections.reverseOrder());
        cValues.sort(Collections.reverseOrder());

        List<Long> tasteSumValues = new ArrayList<>();

        for (int i = 0; i < x; i++){
            if (i > k){
                break;
            }

            for (int j = 0; j < y; j++){
                if (i * j > k){
                    break;
                }

                for (int m = 0; m < z; m++){
                    if (i * j * m > k){
                        break;
                    }
                    long tasteSum = aValues.get(i) + bValues.get(j) + cValues.get(m);
                    tasteSumValues.add(tasteSum);
                }
            }
        }

        tasteSumValues.sort(Collections.reverseOrder());

        for (int i = 0; i < k; i++){
            System.out.println(tasteSumValues.get(i));
        }
    }

}

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

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

struct UF {
  int n;
  vector< int > par;
  UF(int n) : n(n), par(n, -1) {}
  int find(int x) { return par[x] < 0 ? x : par[x] = find(par[x]); }
  int size(int x) { return -par[find(x)]; }
  bool same(int a, int b) { return find(a) == find(b); }
  void unite(int a, int b) {
    a = find(a);
    b = find(b);
    if(a == b) return;
    if(par[a] < par[b]) swap(a, b);
    par[b] += par[a];
    par[a] = b;
  }
  void clear() { par.assign(n, -1); }
};

using P = pair<int, int>;

inline void Main() {
  // code
  int N, M, x, y, res = 0;
  map<int, int> MII;
  cin >> N >> M;
  rep(i, N) {
    cin >> x;
    MII.insert(P(x-1, i));
  }
  UF uf(N);
  rep(i, M) {
    cin >> x >> y;
    uf.unite(x-1, y-1);
  }

  rep(i, N) {
    int t = N - 1 - i;
    if (uf.same(t, MII.at(t))) {
      res++;
    }
  }

  cout << res << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<ll, ll>p;
struct edge { int to, cost; };
std::vector<int>G[100000];
std::vector<int>I[100000];

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = false;
bool f = false;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

int main() {
	std::string s;
	std::cin >> s;
	ll ans = 0, t = s.size() - 1;
	for (int i = 0;i <= t;i++) {
		for (int j = 0;j <= t - i;j++) {
			ll a = s[i] - '0';
			if (i + j == t) {
				ans += std::pow(10, j)*a*std::pow(2, t - j);
			}
			else {
				ans += std::pow(10, j)*a*std::pow(2, t - j - 1);
			}
		}
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i, n)     for (int i = 0; i < (int)(n); ++i)
#define rep1(i, n)    for (int i = 1; i <= (int)(n); ++i)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define rrep(i, n)    for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n)   for (int i = (int)(n); i >= 1; --i)
#define allrep(V, v)  for (auto &&V : v)
#define all(x)        (x).begin(), (x).end()
using lint = long long;
constexpr int    INF  = 1 << 30;
constexpr lint   INFL = 1LL << 62;
constexpr int    MOD  = 1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;

long long gcd(long long a, long long b) {
  while (a && b) {
    if (a >= b) a %= b;
    else b %= a;
  }
  return a + b;
}

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

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  lint a, b, c, d;
  cin >> a >> b >> c >> d;
  lint cdg = lcm(c, d);
  lint l   = (a - 1) - ((a - 1) / c + (a - 1) / d - (a - 1) / cdg);
  lint r   = b - (b / c + b / d - b / cdg);
  cout << r - l << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

void swap (int *x, int *y);
int partition (int array[], int left, int right,int num[]);
void quick_sort (int array[], int left, int right,int num[]);

int main(void){
    int N,*num,*a,i;
    scanf("%d",&N);
    num = malloc(sizeof(int)*N);
    a = malloc(sizeof(int)*N);
    for(i=0;i<N;i++){
        scanf("%d",&a[i]);
        num[i] = i+1; 
    }
    quick_sort(a,0,N-1,num);
    for(i=0;i<N;i++) printf("%d ",num[i]);
    return 0;
}

void swap (int *x, int *y) {
  int temp;    // 値を一時保存する変数

  temp = *x;
  *x = *y;
  *y = temp;
}

/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right,int num[]) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { 
        swap(&array[i], &array[j]); 
        swap(&num[i], &num[j]);
        }
  } while (i < j);

  swap(&array[pivot], &array[j]); 
  swap(&num[pivot], &num[j]);  //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right,int num[]) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right,num);
    quick_sort(array, left, pivot-1,num);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right,num);
  }
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
    {
        int n;
        cin >> n;
        int a = n * n;
        int b = a * n;
        cout << a + b + n << "\n";
    }
}

Measured memory_bytes: 3640
n,q = map(int,input().split())
peer = [[] for _ in range(n)]
for _ in range(n-1):
  a,b = map(int,input().split())
  a -= 1
  b -= 1
  peer[a].append(b)
  peer[b].append(a)
ans = [0 for _ in range(n)]
for _ in range(q):
  p,x = map(int,input().split())
  p -= 1
  ans[p] += x
ect = [0 for _ in range(n)]
ect[0] = 1
now = [0]
while now != []:
  last = now
  now = []
  for x in last:
    for y in peer[x]:
      if ect[y] == 0:
        ect[y] = 1
        now.append(y)
        ans[y] += ans[x]
print(' '.join(list(map(str,ans))))


Measured memory_bytes: 66836
#include <iostream>

using namespace std;

int main(){

	ios::sync_with_stdio(false);

	int cats, cat_dog, num_cat;

	cin >> cats >> cat_dog >> num_cat;

	if(num_cat < cats || num_cat > (cats + cat_dog)) {
		cout << "NO" << endl;
	}
	else{
		cout << "YES" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int main(){
  rd(N);
  wt_L((N-1)/2);
  wt_L('\n');
  return 0;
}
// cLay varsion 20191108-1

// --- original code ---
// int N;
// {
//  rd(N);
//  wt((N-1)/2);
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
template<class T> bool chmax(T &a,  T b) {if(a<b){a=b; return 1;} return 0;}
template<class T> bool chmin(T &a,  T b) {if(a>b){a=b; return 1;} return 0;}
bool Add(int &a,int b){a = (a + b) % MOD;}
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    double cnt = 0.0;
    FOR(i,1,n+1) if(i %2 == 1) cnt += 1;

    cout << fixed << setprecision(10) << double(cnt / n) << endl;

}

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

#define ll long long

int main(){
    ll a,b,n;
    cin>>a>>b>>n;
    ll x=(n/b)*b-1;
    if(x==-1) cout<<(a*n)/b;
    else cout<<(a*x)/b-a*(x/b);
}

Measured memory_bytes: 3632
// Problem : A - Good Integer
// Contest : AtCoder - AtCoder Beginner Contest 079
// URL : https://atcoder.jp/contests/abc079/tasks/abc079_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

template<class T>
T max2(T a,T b){return a>b?a:b;}
template<class T>
T min2(T a,T b){return a<b?a:b;}

void solve()
{
	string s;cin>>s;
	if((s[0]==s[1] and s[1]==s[2])or(s[1]==s[2] and s[2]==s[3]))
	cout<<"Yes";
	else
	cout<<"No";
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1.0e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,l,i;
    cin>>n>>l;
    ll arr[n+1],brr[n+1];
    ll pos=0,minn=mod;
    for(i=0;i<n;i++)
    {
        arr[i]=l+i;
        brr[i]=abs(arr[i]);
        if(brr[i]<minn)
        {
            minn=brr[i];
            pos=i;
        }
    }
    ll sum=0;
    for(i=0;i<n;i++)
    {
        if(i!=pos)
        sum+=arr[i];
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define all(s) s.begin(),s.end()
using namespace std;
typedef pair<int,int> pii;

vector<pii> vp;

int min(int a,int b){
	return (a<b)?a:b;
}

int find(int x,int p){
	if(p)return (x==vp[x].first)?x:vp[x].first=find(vp[x].first,p);
	else return (x==vp[x].second)?x:vp[x].second=find(vp[x].second,p);
}

void unite(int x,int y,int check){
	int nx=find(x,check),ny=find(y,check);
	if(check)vp[ny].first=nx;
	else vp[ny].second=nx;
}

int main(){
	int n,k,l,to,from;
	cin>>n>>k>>l;
	vp=vector<pii>(n);
	rep(i,n)vp[i].first=vp[i].second=i;
	rep(i,(k+l)){
		cin>>from>>to;
		from--;to--;
		unite(from,to,((i<k)?1:0));
	}
	rep(j,n){find(j,0);find(j,1);}
	vector<pii> vec=vp;
	sort(all(vec));
	rep(i,n){
		vector<pii>::iterator low=lower_bound(all(vec),vp[i]);
		vector<pii>::iterator up=upper_bound(all(vec),vp[i]);
		if(i!=0)cout<<" ";
		cout<<(up-low);
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3840
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;

int h,w;
int a[500][500];

int main() {
	cin >> h >> w;

	rep(i, 0, h) {
		rep(j, 0, w) {
			cin >> a[i][j];
		}
	}

	vector<vector<int>>st;
	rep(i, 0, h) {
		rep(j, 0, w-1) {
			if (a[i][j] % 2) {
				a[i][j]--;
				a[i][j + 1]++;
				st.push_back({ i + 1,j + 1,i + 1,j + 2 });
			}
		}
	}

	rep(i, 0, h - 1) {
		if (a[i][w - 1] % 2) {
			a[i][w - 1]--;
			a[i + 1][w - 1]++;
			st.push_back({ i + 1,w,i + 2,w });
		}
	}

	cout << st.size() << endl;

	rep(i,0,st.size()) {
		printf("%d %d %d %d\n",st[i][0],st[i][1],st[i][2],st[i][3]);
	}


	return 0;
}


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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using P = pair<int,int>;
//Write From this Line

int main()
{
	string t;
	cin >> t;
	// ? は Dにすればいい。
	int ans = 0;
	rep(i,t.size()){
		if(t[i] == 'D' || t[i] == '?'){
			t[i] = 'D';
			ans ++;
		}else {
			if(i+1 >= t.size()) continue;
			if(t[i+1] == '?' || t[i+1] == 'D'){
				ans ++;
				t[i+1] = 'D';
			}
		}
	}
	cout << t << endl;
}


Measured memory_bytes: 3720
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

vector<long long> numOfAll;
vector<long long> numOfP;

// nは層の数
long long getP(long long n, long long pos) {
	if (!n) return 1;
	if (pos < n) return 0;

	long long num = numOfAll[n];

	// all
	if (pos == num - 1) {
		return numOfP[n];
	}

	if (pos == num / 2) { // 中央
		return pow(2, n);
	}
	else if (pos < num / 2) { // 左半分
		return getP(n - 1, pos - 1);
	}
	else { // 右半分
		return numOfP[n - 1] + 1 + getP(n - 1, pos - num / 2 - 1);
	}
}


int main() {
	int n;
	long long x;
	cin >> n >> x; x--;

	numOfAll.push_back(1);
	for (int i = 1; i <= n; i++) {
		numOfAll.push_back(numOfAll[i-1] + pow(2, i + 1));
	}

	numOfP.push_back(1);
	for (int i = 1; i <= n; i++) {
		numOfP.push_back(numOfP[i - 1] + pow(2, i));
	}

	cout << getP(n, x) << endl;

	return 0;
}

Measured memory_bytes: 256
/// --- In the name of ALLAH --- ///


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


typedef long long              ll;
typedef vector<int>            vi;
typedef vector<ll>             vl;
typedef vector<vi>             vvi;
typedef vector<vl>             vvl;
typedef pair<int,int>          pii;
typedef pair<double, double>   pdd;
typedef pair<ll, ll>           pll;
typedef vector<pii>            vii;
typedef vector<pll>            vll;
typedef double                 dl;

#define endl                   '\n'
#define PB                     push_back
#define F                      first
#define S                      second
#define all(a)                 (a).begin(),(a).end()
#define rall(a)                (a).rbegin(),(a).rend()
#define sz(x)                  (ll)x.size()
#define wt                     ll t; cin>>t; while(t--)
#define input(a,n)             for(int i=0;i<n;i++) cin>>a[i];

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;


#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))
#define mod 10000007
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

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


const ll mx=1e9;









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

if((a==1&&b==2)||(a==2&&b==1))
    cout<<3<<endl;
else if((a==1&&b==3)||(a==3&&b==1))
    cout<<2<<endl;
else if((a==3&&b==2)||(a==2&&b==3))
    cout<<1<<endl;




    return 0;
}









































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

int main() {
  int h,w,k;
  cin >> h >> w >> k;
  field field(h);
  int all = 0;
  rep(i,0,h) {
    vector<string> a(w);
    string s;
    cin >> s;
    rep(j,0,w) {
      a[j] = s.substr(j,1);
      if (s.substr(j,1) == "#") {
        all += 1;
      }
    }
    field[i] = a;
  }
  vector<int> hl(h);
  rep(i,0,h) {
    int hp = 0;
    rep(j,0,w) {
      if (field[i][j] == "#") {
        hp += 1;
      }
    }
    hl[i] = hp;
  }
  int ans = 0;
  rep(bith, 0, (1 << h)) {
    rep(bitw, 0, (1 << w)) {
      int p = all;
      rep(i,0,h) {
        if (bith & (1<<i)) {
          p -= hl[i];
        } else {
          rep(j,0,w) {
            if (bitw & (1<<j)) {
              if (field[i][j] == "#") {
                p -= 1;
              }
            }
          }
        }
      }
      if (p == k) {
        ans += 1;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3608
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#pragma warning(disable:4996) 

typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define LINF3 1000000000000
#define INF 2140000000
//const long long MOD = 1000000007;
const long long MOD = 998244353;

using namespace std;


char str[5];

void solve()
{
    scanf("%s", str);
    if (str[0] >= 'a' && str[0] <= 'z') {
        printf("a\n");
    }
    else {
        printf("A\n");
    }

    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 1660
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    data=[parseMap(split(readline())) for i in 1:n]
    sort!(data, by=x->x[1])
    ans=data[end][1]+data[end][2]
    println(ans)
end
main()

Measured memory_bytes: 159112
use std::collections::HashMap;

fn main() {
    let n = read::<u64>();
    if n == 1 {
        println!("0");
        return;
    }

    let map = prime_factorize(n);

    // println!("{:?}", map);

    let mut ret = 0;
    for (_, v) in map.iter() {
        let mut i = 1;
        let mut cnt = *v;
        while i <= cnt {
            cnt -= i;
            i += 1;
            ret += 1;
        }
    }
    println!("{}", ret);
}

fn prime_factorize(mut n: u64) -> HashMap<u64, u64> {
    let mut map: HashMap<u64, u64> = HashMap::new();
    let mut i = 2;
    while i * i <= n {
        if n % i != 0 {
            i += 1;
            continue;
        }

        while n % i == 0 {
            let entry = map.entry(i).or_insert(0);
            *entry += 1;
            n /= i;
        }
        i += 1;
    }
    if n > 1 {
        let entry = map.entry(n).or_insert(0);
        *entry += 1;
    }
    map
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}


Measured memory_bytes: 2140