akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
using namespace std;

const int NMAX = 15;

int index(char c){
	return (int)c - 'A';
}

double dp[NMAX+1][3][3];
int dx[] = {
	1, 0, -1, 0
};
int dy[] = {
	0, 1, 0 , -1
};

int main(){
	int n;
	char s, t, b;
	while(cin >> n){
		if(n == 0) break;
		cin >> s >> t >> b;
		int sx, sy;
		int tx, ty;
		int bx, by;
		sx = index(s) % 3;
		sy = index(s) / 3;
		tx = index(t) % 3;
		ty = index(t) / 3;
		bx = index(b) % 3;
		by = index(b) / 3;
		for(int i = 0; i <= NMAX; i++){
			for(int j = 0; j < 3; j++){
				for(int k = 0; k < 3; k++){
					dp[i][j][k] = 0;
				}
			}
		}
		dp[0][ty][tx] = 1.0;
		for(int i = 1; i <= n; i++){
			for(int j = 0; j < 3; j++){
				for(int k = 0; k < 3; k++){
					if(j != by || k != bx){
						for(int l = 0; l < 4; l++)
							if(j + dy[l] >= 0 && j + dy[l] < 3 && k + dx[l] >= 0
								&& k + dx[l] < 3 && (j + dy[l] != by || k + dx[l] != bx))
							{
								dp[i][j][k] += dp[i-1][j+dy[l]][k+dx[l]] / 4;
							}else{
								dp[i][j][k] += dp[i-1][j][k] / 4;
							}
					}
				}
			}
		}
		cout << fixed << setprecision(7) << dp[n][sy][sx] << endl;;
	}
	return 0;
}

Measured memory_bytes: 0
num = int(input())
nums = list(map(int, input().split()))

check = 0
for num in nums:
    if num % 2 == 0:
        if num % 3 == 0 or num % 5 == 0:
            continue
        else:
            check += 1
            
if check == 0:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 2940
#include<stdio.h>
int x,y;
long n,m;
int main()
{
	while(scanf("%d %d",&x,&y)!=EOF)
	{
		for(int i=2;i<=1000;i++)
		{
			if(x%y==0)
			{printf("-1\n");break;
			}
			n=i*x;
			if(i==1000)
			{
				printf("-1\n");
			break;
			}
			if(n%y==0)
			continue;
			else
			printf("%d\n",n);
			break;
		}
		
	}
}

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

int main(){
	int h1,m1;
	int h2,m2;
	int k;
	cin >> h1 >> m1 >> h2 >> m2 >> k;

	int minute1 = h1*60 + m1;
	int minute2 = h2*60 + m2;
	
	int diff = minute2 - minute1;

	cout << max(0, diff-k) << endl;
	
	return 0;
}

Measured memory_bytes: 3636
n,q = map(int,input().split())
S = input()
d = [0] * n
counter = 1
for i in range(n - 1):
    d[i] = counter
    if S[i]+S[i + 1] == 'AC':
            d[i+1] = counter
            counter += 1
d[len(S)-1] = counter
for i in range(q):
    r,l = map(int,input().split())
    print(d[l-1]-d[r-1])

Measured memory_bytes: 52184
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
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;
}
// a^n mod を計算する
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 gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    string S; cin >> S;
    int a=0,b=0,c=0;
    for(int i=0;i<3;i++){
        if(S[i]=='a') a++;
        if(S[i]=='b') b++;
        if(S[i]=='c') c++;
    }
    if(a==1 && b==1 && c==1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3632
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>
// #include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
// using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

typedef vector<int> vec;
typedef vector<vec> mat;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

long long my_mod_pow(long long x, long long n) {
	long long ret = 1;
	for (; n > 0; n >>= 1, x = x * x % MOD) {
		if (n & 1) {
			ret = ret * x % MOD;
		}
	}
	return ret;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    Int T1, T2, A1, A2, B1, B2;
    cin >> T1 >> T2 >> A1 >> A2 >> B1 >> B2;
    Int C1 = (A1 - B1) * T1;
    Int C2 = (A2 - B2) * T2;

    if (C1 + C2 == 0) {
        cout << "infinity" << endl;
    } else if (C1 < 0 && C1 + C2 < 0) {
        cout << 0 << endl;
    } else if (C1 > 0 && C1 + C2 > 0) {
        cout << 0 << endl;
    } else {
        Int D1 = abs(C1);
        Int D2 = abs(C1 + C2);
        Int ans = 1;
        ans += D1 / D2 * 2;
        if (D1 % D2 == 0) ans--;
        cout << ans << endl;
    }
    return 0;
}

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

string s;

int m=1e9+7,dp[10009][2][100],p,d;


int dfs(int idx,int z,bool tight){
  if(idx==s.size())return !z;
  int &res=dp[idx][tight][z];
  if(~res)return res;
  res=0;
  int r=(tight?9:s[idx]-'0');
  for(int i=0;i<=r;i++){
    res+=dfs(idx+1,(z+i)%d,tight||i<r);
    res%=m;
  }
  return res;
}

int main(){
  memset(dp,-1,sizeof dp);
  cin>>s>>d;
  cout<<(dfs(0,0,0)-1+m)%m<<endl;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


Measured memory_bytes: 8832
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;

int n, k, m;
set<int> t;

void ck(int* b) {
		int s = 0;

		for (int i = 0; i < k; i++) {
			if (b[i] > 9)
				s = s * 100 + b[i];
			else
				s = s * 10 + b[i];
		}

		if (t.find(s) == t.end()) {
			t.insert(s);
			m++;
		}
}

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

	while (n > 0 || k > 0) {
		vector<int> a(n);

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

		m = 0;
		int i = (1 << k) - 1;
		t.clear();

		while (i < (1 << n)) {
			vector<int> b;
			for (int j = 0; j < n; j++) {
				if((1 << j) & i)
					b.push_back(j);
			}

			do {
				vector<int> c;
				for (int i = 0; i < k; i++)
					c.push_back(a[b[i]]);

				ck(&c[0]);
			} while (next_permutation(b.begin(), b.end()));

			int x = i & -i, y = i + x;
			i = ((i & ~y) / x >> 1) | y;
		}

		cout << m << endl;
		
		cin >> n >> k;
	}

	return 0;
}



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

int power(int x, int y){
  int n = 1;
  for(int i = 0; i < y; i++)
    n *= x;
  return n;
}
int digit(int x, int y){
  return x%power(10,y+1)/power(10,y);
}

int mod = 1e9+7;

int main() {
  int n;
  cin >> n;
  vector <double> a(n);
  for(int i = 0; i < n; i++)
    cin >> a.at(i);
  double d = 0;
  for(int i = 0; i < n; i++)
    d += 1/a.at(i);
  cout << 1/d << endl;
 
}


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

int main() {
  int n; string s; int q; cin >> n >> s >> q;
  vector<set<int>> S(26);
  rep(i, n) S[s[i] - 'a'].insert(i);
  rep(i, q) {
    int a; cin >> a;
    if (a == 1) {
      int b; char c; cin >> b >> c; b--;
      S[s[b] - 'a'].erase(b);
      s[b] = c;
      S[s[b] - 'a'].insert(b);
    }
    else if (a == 2) {
      int l, r; cin >> l >> r; l--;
      int cnt = 0;
      rep(j, 26) {
        auto it = S[j].lower_bound(l);
        if (it != S[j].end() && *it < r) cnt++;
      }
      cout << cnt << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 26244
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<map>
#define ll long long
#define mod 998244353
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static int buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
int n,x;
int main()
{
	n=read(); x=read();
	int pos=0;
	for(int i=1;i<=n;i++){
		pos+=read();
		if(pos>x){
			writeln(i); return 0;
		}
	}
	writeln(n+1);
	return 0;
}

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

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<lli, lli> pi;

int n, m, q;
int mat[60][4];
int a[15];
lli mx;

void call(int i, int j)
{
    //cout <<i << " " << j << endl;
    if(i > n){
//        for(int in=1; in<=n; in++){
//            cout << a[in] << " ";
//        }
//        cout << endl;
        lli cnt = 0;
        for(int in=0; in<q; in++){
            if(a[mat[in][1]]-a[mat[in][0]] == mat[in][2]) cnt += mat[in][3];
        }
        mx = max(mx, cnt);
        return;
    }
    a[i] = j;
    call(i+1, j);
    if(j<m)
        call(i, j+1);
}

int main()
{
    cin >> n >> m >> q;
    for(int i=0; i<q; i++){
        cin >> mat[i][0] >> mat[i][1] >> mat[i][2] >> mat[i][3];
    }
    call(1, 1);
    cout << mx << '\n';

    return 0;
}


Measured memory_bytes: 3576
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    string N; 
    cin >> N;
    if((N[0] == N[1] && N[1] == N[2]) || (N[1] == N[2] && N[2] == N[3])){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

ll gcd(long long a,long long b) {
    if (a < b) swap(a,b);
    if (b == 0) return a;
    
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;
const ll INF = 1e9 + 7;

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


/////////////////////////////////////////////////////////////////////////////////////////
ll ans = 0;
void dfs(ll N,ll next,int mask){
    if (next > N) return;
    //3,5,7が全部あれば
    if (mask == 0b111) ans++;

    dfs(N,next*10+7,mask|0b100);
    dfs(N,next*10+5,mask|0b010);
    dfs(N,next*10+3,mask|0b001);
}

int main(){
    ll n;
    cin >> n;
    dfs(n,0,0);
    cout << ans << endl;
}

Measured memory_bytes: 256
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
 
//#define mp make_pair
#define bug(v) cerr<<#v<<" = "<<(v)<<endl;
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define pb emplace_back
#define vii vector<int>
#define vll vector<ll>
#define vpll vector< pair <ll,ll> >
#define pll pair <ll,ll>
#define pii pair <int,int>
#define pq priority_queue< int >
#define khtm "\n"
#define F first
#define S second
#define fr(i,a,n) for(i=a;i<n;i++)
#define mem(arr,l) memset(arr,l,sizeof arr)
#define ALL(x) x.begin(), x.end()
#define frr(i,a,n) for(i=n-1;i>=a;i--)
//#define mod 1000000007
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase ll T; cin>>T; while(T--)
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;

const int mod=1e9+7;
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}


/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 

ll i,j,k,m,l,r,n;
ll a[MAX];


int main()
{
 
  #ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
//cout << setprecision(15) << fixed;
fast

fr(i,0,4)
	cin >> a[i];
//cin >> n >> k;
	n = (ll)ceil(a[2]/(ld)a[1]);

	k = (ll)ceil(a[0]/(ld)a[3]);
	bug(k)
cout << (n-k > 0 ? "No" : "Yes");

  #ifndef ONLINE_JUDGE
  cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  #endif
 
  return 0;
 
}

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

int main(){
    int i,N;
    cin >> N;
    vector<int> A(N - 1);
    for (i=0;i < N - 1;i++){
        cin >> A.at(i);
    }
    vector<int> C(N);

    for (i = 0;i <N-1;i++){
        C.at(A.at(i)-1) = C.at(A.at(i)-1) + 1;
    }

    for (i = 0;i < N;i++){
        cout << C.at(i) << endl;
    }
}




Measured memory_bytes: 4840
#include"bits/stdc++.h"
#include<cassert>
#define fr first
#define sc second
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 998244353;
const long long inf = 1ll << 62;
typedef pair<int, int> P;
typedef pair<int, P> PP;
int h[100006];
signed main() {
	int n; cin >> n;
	rep(i, n)cin >> h[i];
	h[n] = inf;
	int ans = 0, cnt = 0;
	rep(i, n) {
		if (h[i] < h[i + 1]) {
			ans = max(ans, cnt);
			cnt = 0;
		}
		else cnt++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int w = sc.nextInt();
    int n = sc.nextInt();
    int[] values = new int[w];
    for(int i = 0; i < values.length; i++){
      values[i] = i+1;
    }
    for(int i = 0; i < n; i++){
      String str = sc.next();
      String[] ab = str.split(",");
      int a = Integer.parseInt(ab[0])-1;
      int b = Integer.parseInt(ab[1])-1;

      int dummy = values[a];
      values[a] = values[b];
      values[b] = dummy; 

    }
    for(int i = 0; i < values.length; i++){
      System.out.println(values[i]);
    }

  }
}

Measured memory_bytes: 17392
//#############################################################################
#include "bits/stdc++.h"
//#############################################################################
//Macros 
#define MOD 1000000007
#define eb emplace_back
#define mp make_pair
#define fr first
#define sc second
#define vec vector
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a, n) a, a + n
//Type Defs
typedef long long ll;
typedef unsigned long long ull;
//#############################################################################
using namespace std;
//#############################################################################
//Helpers
void io_handler()
{
#ifdef LOCAL_TESTING
    freopen("inputf.in", "r", stdin);
    freopen("outputf.in", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
void print_matrix(vector<vector<ll>> mat){
    for(auto row: mat){
        for(auto e : row){cout << e << " ";}
        cout << endl;
    }
}
void print_vector(vector<ll> v){
    for(auto e : v){cout<< e <<" ";}
    cout<<endl;
}
map<int,int> get_count(vector<ll> v){
    map<int,int> count;
    for(auto e: v){
        if(count.find(e)!=count.end()){count[e]++;}
        else{count[e] = 1;}}
    return count;
}
//#############################################################################
//Solution
void solve(){
    string s,t;
    cin>>s>>t;
    ll m = s.size(), n = t.size();
    vec<vec<ll>> dp(m+1,vec<ll>(n+1,0));
    for(ll i = 1; i<=m; i++){
        for(ll j = 1; j<=n; j++){
            if(s[i-1]==t[j-1]){
                dp[i][j] = dp[i-1][j-1]+1;
            } else {
                dp[i][j] = max(dp[i][j-1],dp[i-1][j]);
            }
        }
    }
    string lcs = "";
    ll i = m, j = n;
    while(i>0 and j>0){
        if(dp[i][j] == dp[i-1][j-1]+1
            and dp[i-1][j-1]>=dp[i-1][j]
            and dp[i-1][j-1]>=dp[i][j-1]){
            lcs = t[j-1]+lcs;
            --i;--j;
        } else {
            if(dp[i][j] == dp[i-1][j]){
                --i;
            } else {
                --j;
            }
        }
    }
    cout<<lcs<<endl;
}
//#############################################################################
//Driver
int main()
{
    io_handler();
    int t = 1;
    //cin>>t;
    for (int i = 0; i < t; i++){
        solve();
    }
#ifdef LOCAL_TESTING
    cout << "⏰ Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}
//#############################################################################

Measured memory_bytes: 70784
#include<bits/stdc++.h>
using namespace std;
#define int 		  	long long
#define f(i,n)        	for(int i=0;i<(n);++i)
#define fa(i,a,n)     	for(int i=a;i<=(n);++i)
#define fd(i,a,n)     	for(int i=a;i>=(n);--i)
#define tc 			  	int t;cin>>t;f(testcase,t)
#define pii             pair<int,int>
#define allx 			x.begin(),x.end()
#define tr(c,i) 		for(auto i = c.begin(); i != c.end(); i++)
#define present(c,x) 	(c.find(x) != c.end())
#define cpresent(c,x) 	(find(allc,x) != c.end())
#define	PI 3.1415926535897932
void c_p_c() {

	ios_base::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);

}

void findDivisors(int n)
{
	int ans = 0;

	for (int i = 1; i <= n - 1; i++) {

		for (int j = 1; j * i <= n - 1; j++)
			ans++;
	}
	cout << ans;
}
void solve() {
	int n;
	cin >> n;
	findDivisors(n);

}

int32_t main() {

	c_p_c();
	//tc
	solve();
	return 0;
}



Measured memory_bytes: 3644
n,k=map(int,input().split())
A=list(map(int,input().split()))

for i in range(n-1):
    A[i+1]+=A[i]

ans=0.0
A.reverse()
A.append(0)
A.reverse()

for i in range(n-k+1):
    now=A[i+k]-A[i]
    if now>ans:
        ans=now

print((ans+k)/2)

Measured memory_bytes: 25060
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;


int main(void){
  int n,i,j,rn[10][30003]={},d1,d2,d3,p,ans=0;
  string s;
  
  cin >> n >> s;
  
  for (i=0;i<n;i++) rn[s[i]-'0'][i+1]++;
  
  for (i=1;i<=n;i++) for (j=0;j<10;j++){
    rn[j][i]+=rn[j][i-1];
  }
  
  for (d1=0;d1<10;d1++) for (d2=0;d2<10;d2++) for (d3=0;d3<10;d3++){
    p=0;
    i=1;
    while (i<=n && rn[d1][i]==rn[d1][p]) i++;
    if (i==n+1) continue;
    p=i;
    while (i<=n && rn[d2][i]==rn[d2][p]) i++;
    if (i==n+1) continue;
    p=i;
    while (i<=n && rn[d3][i]==rn[d3][p]) i++;
    
    if (i<=n) ans++;
  }
  
  cout << ans << endl;
  
  return 0;
}

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

int main(){

    int a[5], j, i;
    for(i=0; i<5; i++) cin >> a[i];

    for(i=0; i<5; i++){
        for(j=0; j<4; j++){
            if(a[j] % 10 > a[j+1] % 10){
                int temp = a[j];
                a[j] = a[j+1];
                a[j+1] = temp;
            }
        }
    }

    // for(i=0; i<5; i++) cout << a[i] << " ";

    int sum=0, cont=0;
    for(i=0; i<5; i++) sum += a[i];
    for(i=0; i<5; i++) if(a[i] % 10 == 0) cont++;

    i = 4;
    while(a[i] % 10 != 0 && i > 0){
        sum += (10 - (a[i] % 10));
        i--;
    }
    // cout << i << "   ";
    if(cont != 0 && i+1 < 5) sum -= (10 - a[i+1] % 10);

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n;
		while ((n = in.nextInt()) > 0) {
			boolean[][] map = new boolean[n][n];
			int m = in.nextInt();
			for (int i = 0; i < m; i++) {
				int a = in.nextInt() - 1;
				int b = in.nextInt() - 1;
				map[a][b] = true;
				map[b][a] = true;

			}
			for (int i = 1; i < n; i++) {
				if (map[i][0]) {
					for (int j = 1; j < n; j++) {
						if (map[i][j]) {
							map[0][j] = true;
						}
					}
				}
			}
			int count = 0;
			for (int i = 1; i < n; i++) {
				if (map[0][i]) {
					count++;
				}
			}
			System.out.println(count);
		}
	}
}

Measured memory_bytes: 46656
num = int(input())
table = list(map(int, input().split()))
count = 0
list.sort(table)
if num == 2:
        if table[0] == table[1]:
            count += 1
else:
    for i in range(1, num-1):
        if num == 2:
            if table[0] == table[1]:
                count += 1
        elif table[i] == table[i+1] or table[i-1] == table[i]:
            count += 1
        else:
            continue
if count == 0:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 30868
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define run(x) for(int k=head[x];k;k=e[k].ne)
#define v e[k].t
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef double db;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
typedef pair<int,int> pa;
const int N=4e6+5,M=1e7+5,INF=1e9,mod=1e9+7;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);
}
ll fac[N],ifac[N],f[N];
int siz[N],vis[N],cnt=1,n;
struct edge{int s,t,ne,w;}e[N];
int head[N];
ll C(ll n,ll m){
	if(n<0||m<0||n-m<0)return 0;
	return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
int cv,ce,pre[N],S,mx;
void dfs(int x,int f){
	vis[x]=1;cv++;
	run(x){
		ce++;
		if(!vis[v]){pre[v]=k,dfs(v,x);}else
			if(v!=f&&!S)S=k;
	}
}
ll qaq=1;
void calc(int x,int lase){
	siz[x]=0;f[x]=1;
	run(x)if(k!=lase&&(k/2!=mx/2)){
		calc(v,k^1);
		if(e[k].w>e[lase].w){
			qaq=qaq*ifac[siz[v]]%mod*f[v]%mod;
		}else{
			siz[x]+=siz[v];
			f[x]=f[x]*f[v]%mod*C(siz[x],siz[v])%mod;
		}
	}
	siz[x]++;
}
void adde(int a,int b,int c){e[++cnt]=(edge){a,b,head[a],c};head[a]=cnt;}
int main(){
	read(n);fac[0]=1;rep(i,1,n+n)fac[i]=fac[i-1]*i%mod;
	ifac[n+n]=qpow(fac[n+n],mod-2,mod);
	repd(i,n+n-1,0)ifac[i]=ifac[i+1]*(i+1)%mod;
	rep(i,1,n+n){
		int x,y;read(x,y);y+=n;
		adde(x,y,x+y);adde(y,x,x+y);
	}ll res=fac[n+n];
	rep(i,1,n+n)if(!vis[i]){
		S=0;cv=ce=0;dfs(i,0);
		if(cv*2!=ce)return puts("0"),0;mx=S;
		for(int o=S;e[o].s!=e[S].t;o=pre[e[o].s],mx=(e[mx].w<e[o].w?o:mx));
		ll all=0;
		int x=e[mx].s;
		qaq=1;calc(x,mx);
		all+=ifac[siz[x]]*f[x]%mod*qaq%mod;
		x=e[mx].t;
		qaq=1;calc(x,mx);
		all+=ifac[siz[x]]*f[x]%mod*qaq%mod;
		res=res*all%mod;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 33024
# include <bits/stdc++.h>
# define rep(i, n) for(ll i = 0; i < (n); ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define ll long long
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define P pair<int, int>
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; }
ll lmax(ll a, ll b){if(a>= b) return a;return b;}
ll lmin(ll a, ll b){if(a>= b) return b;return a;}
static const ll INF = 1e18;

ll dp[52][102];

int main() {
  int n, k; cin >> n >> k;
  vector<int> v(n);
  rep(i, n) {
    cin >> v[i];
  }

  int ans = 0;
  for(int i = 0; i <= k; i++){
    for(int j = 0; j <= k - i; j++){
      if(i + j > n) continue;
      vector<int> a;
      int sum = 0, d = k - i - j;
      rep(x, i){
        sum += v[x];
        a.pb(v[x]);
      }
      rep(x, j){
        sum += v[n - 1 - x];
        a.pb(v[n - 1 - x]);
      }
      sort(ALL(a));
      for(int x = 0; x < d; x++){
        if(x >= a.size()) break;
        if(a[x] > 0) break;
        sum -= a[x];
      }
      chmax(ans, sum);
    }
  }

  cout << ans << endl;
}


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

#define endl '\n'
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;

bool is_month(int num) {
	return num >= 1 && num <= 12;
}

void solve() {
	const string month_first = "MMYY", month_second = "YYMM", 
	ambig = "AMBIGUOUS", wrong = "NA";
	string str;
	cin >> str;
	int first = stoi(str.substr(0, 2));
	int second = stoi(str.substr(2, 2));
	if (is_month(first) && is_month(second)) {
		cout << ambig;
	} else if (is_month(first)) {
		cout << month_first;
	} else if (is_month(second)) {
		cout << month_second;
	} else {
		cout << wrong;
	}

}

int main() {
	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif
	solve();
}

Measured memory_bytes: 256
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
typedef double lf;
typedef long double Lf;
typedef pair <int,int> pii;
typedef pair <ll, ll> pll;

#define TRACE(x) cerr << #x << "  " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define _ << " " <<

#define fi first
#define sec second
#define mp make_pair

const int MAXN = 20;

int n, m, dp[MAXN][MAXN];

char p[MAXN][MAXN];

int main() {
	scanf("%d %d",&n,&m);
	FOR(i, 1, n + 1) scanf("%s",p[i] + 1);

	FOR(i, 1, n + 1) 
		FOR(j, 1, m + 1) 
			dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + (p[i][j] == '#');

	int sve = 0;
	FOR(i, 1, n + 1) FOR(j, 1, m + 1) sve += (p[i][j] == '#');
	if (dp[n][m] == sve) puts("Possible");
	else puts("Impossible");
	return 0;
}

Measured memory_bytes: 256
//Radhe Radhe
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

int main()
{
    fast_io
    ll i,j,a,b,k;
    bool found=0;
    string s;
    cin>>a>>b;
    for(i=1; i<=3; i++)
    {
        ll x=a*b*i;
        if(x%2)
            return cout<<"Yes"<<endl,0;

    }

    return cout<<"No"<<endl,0;
    return 0;
}





Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <algorithm>
#include <sstream>
#include <cmath>
using namespace std;

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

    long long A[N];
    long long B[N];
    for(int i=0;i<N;i++){
        cin >> A[i];
        B[i] = A[i] - (i+1);
    }

    sort(B, B + N);

    int b;
    if(N%2 == 1){
        b = B[N/2];
    }else{
        b = (B[N/2 -1] + B[N/2])/2;
    }

    long long res = 0;
    for(int i=0;i<N;i++){
        res += abs(B[i] - b);
    }
    cout << res << endl;
}

Measured memory_bytes: 3456
#include <iostream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <set>

using namespace std;

int main()
{


    int q;
    cin >> q;

    set<int> S;
    int cmd, x;
    while (q--)
    {
        cin >> cmd >> x;
        if (!cmd)
        {
            S.insert(x);
            cout << S.size() << endl;
        }
        else
        {
            // cout << (S.find(x) != S.end()) << endl;
            cout << S.count(x) << endl;
        }
        
    }
}


Measured memory_bytes: 12472
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
typedef pair<ll,ll> P;
#define pb push_back
#define mp make_pair
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  ll n,c,s,t,ch,ans=0;
  vector<P> tm[33],nt;
  cin>>n>>c;
  fr(i,n){
    cin>>s>>t>>ch;
    tm[ch].pb(mp(s,t));
  }
  Fr(i,c){
    sort(tm[i].begin(),tm[i].end());
    fr(j,tm[i].size()){
      if(j+1==tm[i].size()){nt.pb(tm[i][j]);continue;}
      if(tm[i][j].second==tm[i][j+1].first) tm[i][j+1].first=tm[i][j].first;
      else nt.pb(tm[i][j]);
    }
  }
  ll cnt[100010]={};
  fr(i,nt.size()){
    for(ll j=nt[i].first;j<=nt[i].second;j++) cnt[j]++;
  }
  fr(i,100010) ans=max(ans,cnt[i]);
  cout<<ans<<endl;
}

Measured memory_bytes: 5108
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    char a;
    cin >> a;
    if(a >= 'a') cout << "a" << endl;
    else cout << "A" << endl;
}


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

int N, M;
int WA[105000];
bool AC[105000];

void solve() {
    cin >> N >> M;
    int WAnum = 0;
    int ACnum = 0;
    for(int i = 1; i <= N; i++) {
        WA[i] = 0;
        AC[i] = false;
    }
    while(M--) {
        int p;
        string S;
        cin >> p >> S;
        if(AC[p]) continue;
        if(S == "AC") {
            AC[p] = true;
            ACnum++;
            WAnum += WA[p];
        } else if(S == "WA") {
            WA[p]++;
        }
    }
    cout << ACnum << " " << WAnum << endl;
    return;
}

int main() {
    solve();
    return 0;
}


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

int main(){
    int R, G, B, K;
    cin >> R >> G >> B;
    cin >> K;

    int count_g = 0, count_b = 0;
    while(R >= G){
        G = 2*G;
        count_g++;
    }
    while(G >= B){
        B = 2*B;
        count_b++;
    }
    string ans = "No";
    if(count_b + count_g <= K){
        ans = "Yes";
    }
    cout << ans << endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
  char a,b;
  cin >> a >> b;
  char c = 'H' + 'D';
  if (a == 'H')
  {
    cout << b << endl;
  }
  else
  {
    cout << char(c - b) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;

int main() {
  while(1) {
    int n,m;
    cin>>n>>m;
    if(!n) break;
    vector<string> vs(n);
    REP(i,n) cin>>vs[i];
    int sum = 0;
    string tx;
    REP(cnt,m) {
      string line;
      cin>>line;
      tx += line;
    }
    int l = tx.size();
    vector<vector<bool>> dp(1<<n, vector<bool>(l+1, false));
    vector<vector<bool>> match(l+1, vector<bool>(n, false));
    REP(i,l+1) dp[0][i] = true;
    REP(i,l+1)REP(j,n) {
      if (j+vs[j].size() > tx.size()) continue;
      if (tx.substr(i, vs[j].size()) == vs[j]) match[i][j] = true;
    }
    REP(i,1<<n) REP(j,n) {
      if ((i>>j)&1) continue;
      int ls = vs[j].size();
      REP(k,l+1-ls) {
        if (dp[i][k] && match[k][j]) {
          dp[i|(1<<j)][k+ls] = true;
        }
      }
    }
    REP(i,l+1) {
      if (dp[(1<<n)-1][i]) ++sum;
    }
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 6104
#include                        <bits/stdc++.h>
#include                        <ext/pb_ds/assoc_container.hpp>
#define lb                      lower_bound
#define ub                      upper_bound
#define fe(x)                   *(x.begin())
#define le(x)                   *(x.rbegin())
#define pb                      push_back
#define load(node,n)            bool operator < (const node &n) const
#define fbo(x)                  find_by_order(x)
#define ook(x)                  order_of_key(x)
#define all(x)                  (x).begin(),(x).end()
#define FOR(i,n)                for(int i = 1; i<=n; i++)
#define REP(i,n)                for(int i = 0; i<n;  i++)
#define TT                      int TC;  scanf("%d",&TC);  while(TC--)
#define read                    freopen("input.txt","r",stdin)
#define write                   freopen("output.txt","w",stdout)
#define dbg(...)                debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#define set(x)                  tree<x,null_type,less<x>,rb_tree_tag,tree_order_statistics_node_update>
using                           namespace __gnu_pbds;
using                           namespace std;
typedef                         long long ll;
typedef                         pair<ll,ll> pll;
typedef                         pair<int,int> pii;

vector<string> vec_splitter(string s){
    s += ','; vector<string> res;
    while(!s.empty()) res.push_back(s.substr(0,s.find(','))), s = s.substr(s.find(',') + 1);
    return res;
}
void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused))int idx,
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T){
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") "; stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str(); debug_out(args, idx + 1, LINE_NUM, T...);
}






main(){
//read;

int a,b;
cin>>a>>b;
int c = a+b;
if(c&1) puts("IMPOSSIBLE");
else cout<<c/2;




return 0;
}



Measured memory_bytes: 256
fn get_input() -> String {
    let mut word = String::new();
    std::io::stdin().read_line(&mut word).unwrap();
    word.trim().to_owned()
}

fn main() {
    let (n, l) = {
        let line = get_input();
        let mut split = line.split_whitespace();
        let n:i32 = split.next().unwrap().parse().unwrap();
        let l:i32 = split.next().unwrap().parse().unwrap();
        (n, l)
    };

    let mut sum = 0;
    for i in 1..n+1 {
        sum += l + i - 1;
        // println!("{} {}", i, l + i - 1);
    }
    // println!("{}", sum);
    // println!("----");

    let mut ans = 0;
    let mut diff = 1000000;
    for i in 1..n+1 {
        let s = i32::abs(sum) - i32::abs(l + i - 1);

        if diff > sum - s {
            // println!("{} -> {}", ans, s);
            ans = if sum < 0 { -s } else { s };
            diff = sum - s;
        }
    }

    // mn = i32::abs(ans) - i32::abs(mn);
    // mx = i32::abs(ans) - i32::abs(mx);

    // ans = if ans - mn < ans - mx {
    //     mn
    // } else {
    //     mx
    // };

    println!("{}", ans);
}

Measured memory_bytes: 4352
N = input()
Ai = input().split()
Ai = [int(Ai[k]) for k in range(int(N))]
K = Ai[0]
T = True
for j in range(int(N)):
  if Ai[j] == 0:
    K = 0
    T = False
    print(0)
for i in range(1,int(N)):
  K = K * Ai[i]
  if K > 1000000000000000000:
    K = -1
    break
if T:
  print(K)


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

int main() {
  ll a,b;
  int k;
  cin>>a>>b>>k;
  rep(i,k) {
    if (i%2==0) {
      if (a%2==1)  a--;
      b += a/2;
      a/=2;
    } else {
      if (b%2==1) b--;
      a += b/2;
      b/= 2;
    }
  }
  cout<<a<<" "<<b;
}


Measured memory_bytes: 3636
import java.util.*;

class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] r = new int[n];
    for(int i = 0; i < n; i++){
      r[i] = sc.nextInt();
    }

    int max = -2000000000;
    int min = r[0];
    for(int i = 1; i < n; i++){
      max = Math.max(max,r[i]-min);
      min = Math.min(min,r[i]);
    }
    System.out.println(max);
  }
}



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

#define ll long long
ll dp[200][200005];

int main()
{
    int n,w;
    cin>>n>>w;
    int weight[n+5],value[n+5];
    int total_value=0;
    for(int i=1;i<=n;i++){
        cin>>weight[i];
        cin>>value[i];
        total_value+=value[i];
    }
    for(int i=0;i<=n;i++){
        for(int j=0;j<=total_value;j++)
            dp[i][j]=10000000000;
    }
    for(int i=0; i<=n; i++)
        dp[i][0]=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=total_value;j++){
            if(value[i]>j)
                dp[i][j]=dp[i-1][j];
            else
                dp[i][j]=min(dp[i-1][j],weight[i]+dp[i-1][j-value[i]]);
        }
    }
    int ans=0;
    for(int i=1;i<=total_value;i++){
        if(dp[n][i]<=w)ans=i;
    }
    cout<<ans<<endl;
}


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

int main() {
  int N, M, CITY;
  cin >> N >> M;
  vector<int> vec(N);

  for (int i = 0; i < M*2; i++) {
    cin >> CITY;
    for(int j = 0; j < N; j++){
      if(CITY == j+1){
        vec.at(j)++;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    cout << vec.at(i) << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	static Scanner scan=new Scanner(System.in);
	static int gcd (int a, int b) {return b>0?gcd(b,a%b):a;}
	static long lcm (int a, int b) {return a*b/gcd(a,b);}
	static int max(int a,int b) {return a>b?a:b;}
	static int min(int a,int b) {return a<b?a:b;}
	static long factorial(int i) {return i==1?1:i*factorial(i-1);}
	static int lower_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<=key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static int upper_bound(int a[],int key) {
		int low=0,high=a.length;
		while(low<high) {
			int mid=((high-low)/2)+low;
			if(a[mid]<key)low=mid+1;
			else high=mid;
		}
		return high;
		}
	static boolean isPrime (int n) {
		if (n==2) return true;
		if (n<2 || n%2==0) return false;
		double d = Math.sqrt(n);
		for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
		return true;
	}
	static int upper_division(int a,int b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lupper_division(long a,long b) {
		if(a%b==0) {
			return a/b;
		}
		else {
			return a/b+1;
		}
	}
	static long lmax(long a,long b) {return Math.max(a, b);}
	static long lmin(long a,long b) {return Math.min(a, b);}
	static int[] setArray(int a) {
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			b[i]=scan.nextInt();
		}
		return b;
	}
	//Arrays.sort(array, (a, b) -> Integer.compare(a[0], b[0]));
	
	public static void main(String[] args) {
		int a=scan.nextInt();
		int b=scan.nextInt();
		for(int i=0;;i++) {
			if(a*i-i+1>=b) {System.out.println(i);
			break;
			}
		}
	}
}

Measured memory_bytes: 23888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define ull unsigned long long
#define mp make_pair
#define ld long double
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
const int N=100005;
int c(ll a,ll b){
	return (a&b)==b?1:0;
}
ll x[N],y[N],ans;
int main(){
	int n=read();
	for(int i=1;i<=n;i++){
		x[i]=read(); y[i]=read();
	}
	const ll C=-2e17;
	for(int i=0;i<60;i++){
		ll t=(ll)1<<i;
		int sum=0;
		for(int j=1;j<=n;j++){
			if(y[j]<=t)sum^=c(x[j]-C,t-y[j]);
		}
		ans|=(ll)sum<<i;
		//if(sum)cout<<i<<endl;
	}
	cout<<ans+C<<endl;
}


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

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		solver.readA(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
	}

	public void readA(String str) {
		String[] strArr = str.split("\\s+");
		int[] A = new int[N];
		for (int i = 0; i < N; i++)
			A[i] = Integer.parseInt(strArr[i]);
		double a = 0;
		for (int i = 0; i < N; i++) {
			a += 1 / (double) A[i];
		}
		System.out.println(1 / a);
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 21332
H,W,M=map(int,input().split())
mine_h=[0]*H
mine_w=[0]*W
val=-1
mine=set()
for i in range(M):
    a,b=map(int,input().split())
    mine_h[a-1]+=1
    mine_w[b-1]+=1
    mine.add((a,b))
max_h=max(mine_h)
max_w=max(mine_w)
h_index=[i+1 for i, x in enumerate(mine_h)if x == max_h]
w_index=[i+1 for i, x in enumerate(mine_w)if x == max_w]
for i in h_index:
    for j in w_index:
        if (i,j) in mine:
            continue
        else:
            val=0
            break
print(max_h+max_w+val)

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()

const int MAX = 1e6+10;
const ll INF = 1e17;

int N[MAX], D;
ll dp[MAX][2];

ll solve() {
    REP (i, D+2) REP (j, 2) dp[i][j] = INF;
    dp[0][0] = 0;
    REP (d, D+1) REP (k, 2) {
        int n = N[d] + k;
        REP (a, 10) {
            int b = a - n;
            if (b >= 0) { // くり下がらない
                dp[d+1][0] = min(dp[d+1][0], dp[d][k] + a + b);
            } else {
                dp[d+1][1] = min(dp[d+1][1], dp[d][k] + a + b + 10);
            }
        }
    }
    return min(dp[D+1][0], dp[D+1][1]);
}

int main() {
    string S;
    cin >> S;
    D = S.size();
    REP (i, D) N[i] = S[D - i - 1] - '0';
    cout << solve() << endl;
}

Measured memory_bytes: 20868
n=int(input())
info=[]
for i in range(n):
    s,p=input().split()
    info.append([i+1,s,int(p)])
#print(info)
info2=sorted(info,key=lambda x:x[2],reverse=True)
info3=sorted(info2,key=lambda x:x[1])
#print(info3)
for i in range(n):
    print(info3[i][0])

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;



int main() {
	int n;
	cin >> n;
	vector<string> s(n);


	map<char, int> m;
	for(int i = 0; i < n; i++) {
		cin >> s[i];
		
		
	}

	for (char c :s[0]) {
		m[c]++;
	}


	for (int i = 1; i < n;i++) {
		map<char,int> m_tmp;
		for (char c : s[i]) {
			m_tmp[c]++;
		}

		for (int j = 'a'; j <= 'z'; j++) {
			m[j] = min(m[j], m_tmp[j]);
		}
	}
	
	string ans;
	for (auto it = m.begin(); it != m.end(); it++) {
		for (int i = 0; i < it->second;i++) {
			ans += it->first;
		}
	}
	cout << ans << endl;
	
}


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

string s;
int N;
int c;

int p[3];

ll expr();
ll term1();
ll term2();
ll factor();
ll num();

void debug(string text){
	return;
	cout << text + " ";
	for(int i = 0; i < N; i++){
		if(i == c) cout << '[' << s[i] << ']';
		else cout << s[i];
	}
	cout << endl;
}

ll expr(){
	debug("expr");
	ll x = term1();
	while(c < N){
		if(s[c] == '+' && p[0] == 0){
			c++;
			x += term1();
		}
		else if(s[c] == '-' && p[1] == 0){
			c++;
			x -= term1();
		}
		else if(s[c] == '*' && p[2] == 0){
			c++;
			x *= term1();
		}
		else break;
	}
	return x;
}

ll term1(){
	debug("term1");
	ll x = term2();
	while(c < N){
		if(s[c] == '+' && p[0] == 1){
			c++;
			x += term2();
		}
		else if(s[c] == '-' && p[1] == 1){
			c++;
			x -= term2();
		}
		else if(s[c] == '*' && p[2] == 1){
			c++;
			x *= term2();
		}
		else break;
	}
	return x;
}

ll term2(){
	debug("term2");
	ll x = factor();
	while(c < N){
		if(s[c] == '+' && p[0] == 2){
			c++;
			x += factor();
		}
		else if(s[c] == '-' && p[1] == 2){
			c++;
			x -= factor();
		}
		else if(s[c] == '*' && p[2] == 2){
			c++;
			x *= factor();
		}
		else break;
	}
	return x;
}

ll factor(){
	debug("factor");
	if(s[c] == '('){
		c++;
		ll ret = expr();
		assert(s[c] == ')');
		c++;
		return ret;
	}
	return num();
}

ll num(){
	debug("num");
	ll ret = 0;
	while(c < N && isdigit(s[c])){
		ret = ret * 10 + s[c] - '0';
		c++;
	}
	return ret;
}


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	cin >> s;
	N = s.size();

	ll ans = LLONG_MIN;
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 3; k++){
				p[0] = i, p[1] = j, p[2] = k;
				c = 0;
				ans = max(ans, expr());
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3192