akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl


int main() {
    int N, Q;  cin >> N >> Q;
    string S;  cin >> S;
    vector<int> l(Q);
    vector<int> r(Q);
    rep(i, Q) cin >> l[i] >> r[i];

    vector<int> v(N+1, 0);
    for (int i=1; i<N; ++i) {
        if (S[i-1] == 'A' && S[i] == 'C') v[i+1] = v[i] + 1;
        else v[i+1] = v[i];
    }

    rep(i, Q) {
        print(v[r[i]] - v[l[i]]);
    }
}

Measured memory_bytes: 2176
//Author : pakhandi
//
using namespace std;

#include <bits/stdc++.h>

#define wl(n) while(n--)
#define fl(i,a,b) for(i=a; i<b; i++)
#define rev(i,a,b) for(i=a; i>=b; i--)

#define si(n) scanf("%d", &n)
#define sll(l) scanf("%lld",&l)

#define debug(x) cout<<"\n#("<<x<<")#\n"
#define nline printf("\n")

#define mem(a,i) memset(a,i,sizeof(a))

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

#define PB push_back
#define SZ size
#define MP make_pair

#define IGNORE cin.ignore (std::numeric_limits<std::streamsize>::max(), '\n');

const string reference = "CODEFESTIVAL2016"; 

int main()
{
	int i, j;

	string str1;

	cin >> str1;
	int ans = 0;
	fl(i,0,str1.SZ())
	{
		if(str1[i] != reference[i])
			ans++;
	}

	cout << ans;


	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int a[100005],b[100005];
int v[100005];
int main()
{
    int n,ans1=0,ans11=0,ans2=0,ans22=0,t1=0,t2=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&v[i]);
    for(int i=1;i<=n;i++)
    {
        if(i&1)
        {
            a[v[i]]++;
            if(a[v[i]]>ans1) ans1=a[v[i]],t1=v[i];
        }
        else
        {
            b[v[i]]++;
            if(b[v[i]]>ans2) ans2=b[v[i]],t2=v[i];
        }
    }
    int ans;
    if(t2==t1)
    {
        memset(a,0,sizeof(a));
        memset(b,0,sizeof(b));
        for(int i=1;i<=n;i++)
        {
            if(v[i]==t2) continue;
            if(i&1)
            {
                a[v[i]]++;
                if(a[v[i]]>ans11) ans11=a[v[i]];
            }
            else
            {
                b[v[i]]++;
                if(b[v[i]]>ans22) ans22=b[v[i]];
            }
        }
        ans=max(ans1+ans22,ans2+ans11);
        ans=n-ans;
    }
    else ans=n-ans1-ans2;
    printf("%d\n",ans);
}


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

#define se second
#define fi first

typedef long long ll;
typedef pair<ll,int> pii;
typedef pair<ll,pii> data;


int X,Y,Z;
int N;
vector<pii> V;
int coins[100010][4];
ll ans = 0;
priority_queue<pii, vector<pii>, greater<pii> > Q,P;
ll max1[100010],max2[100010];

int main()
{
    scanf("%d%d%d",&X,&Y,&Z);
    N = X + Y + Z;
    for(int i = 0; i < N; i++)
    {
        ll a,b,c;
        scanf("%lld%lld%lld",&coins[i][1],&coins[i][2],&coins[i][3]);
        a = coins[i][1];
        b = coins[i][2];
        c = coins[i][3];
        V.push_back(make_pair(a - b,i));
    }
    sort(V.begin(),V.end());
    ll sum = 0;
    for(int i = 0; i < Y; i++)
    {
        int now = V[i].se;
        Q.push(make_pair(coins[now][2] - coins[now][3],now));
        sum += coins[now][2];
    }
    max1[Y] = sum;
    for(int i = Y; i < N - X; i++)
    {
        int now = V[i].se;
        pii top = Q.top();
        if(coins[now][2] - coins[now][3] > top.fi)
        {
            Q.pop();
            sum += coins[top.se][3] - coins[top.se][2] + coins[now][2];
            Q.push(make_pair(coins[now][2] - coins[now][3],now));
        }
        else sum += coins[now][3];
        max1[i + 1] = sum;
    }
    reverse(V.begin(),V.end());
    sum = 0;
    for(int i = 0; i < X; i++)
    {
        int now = V[i].se;
        P.push(make_pair(coins[now][1] - coins[now][3],now));
        sum += coins[now][1];
    }
    max2[X] = sum;
    for(int i = X; i < N - Y; i++)
    {
        int now = V[i].se;
        pii top = P.top();
        if(coins[now][1] - coins[now][3] > top.fi)
        {
            P.pop();
            sum += coins[top.se][3] - coins[top.se][1] + coins[now][1];
            P.push(make_pair(coins[now][1] - coins[now][3],now));
        }
        else sum += coins[now][3];
        max2[i + 1] = sum;
    }
    ll ans = 0;
    for(int i = 0; i <= N - Y - X; i++)
    {
        ans = max(ans,max1[Y + i] + max2[N - Y - i]);
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 7024
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll gf(ll n, ll v) {
  ll x = n / v - 1;
  if (x < 1)
    return 0;
  if (n % x == n / x)
    return x;
  return 0;
}

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif

  ll n;
  scanf("%lld", &n);
  ll ans = 0;
  for (int x = 1; x * (ll)x <= n; ++x)
    if (n % x == 0) {
      ans += gf(n, x);
      if (n / x != x)
        ans += gf(n, n / x);
    }
  printf("%lld\n", ans);

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <bits/stdc++.h>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>
#include <unistd.h>

using namespace std;

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

long long int INF = 1e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define line cout << "----------" << endl;


ll mod = 1000000007;
ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){

    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){

    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){

    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}

/*
ll fact[800005],rfact[800005];

void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
	rfact[800000] = rui(fact[800000],mod - 2);
	for(ll i=800000; i>=1; i--){
	   rfact[i-1] = rfact[i] * i;
	   rfact[i-1] %= mod;
	}
	return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/

ll n,m,num,sum,ans,a,b,c,d,e,g,h,w,i,j,k,q;
ll x[300005],y[300005],z[100005];
ll dp[500005][15];
char s[500005];

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

        num += x[i];
    }
    for(i=0;i<n;i++){
        cin >> y[i];
    }
    for(i=0;i<n;i++){
        if(x[i] > y[i]){
            x[i] -= y[i];
            y[i] = 0;
        }else{
            y[i] -= x[i];
            x[i] = 0;
            if(x[i+1] > y[i]){
                x[i+1] -= y[i];
                y[i] = 0;
            }else{
                y[i] -= x[i+1];
                x[i+1] = 0;
            }
        }
    }
    for(i=0;i<=n;i++){
       // pe(x[i]);

    }
   // line;
    for(i=0;i<=n;i++){
        sum += x[i];
    }
    p(num - sum);
    
	return 0;
}



Measured memory_bytes: 17280
// 2011/01/04 Tazoe

#include <iostream>
#include <iomanip>
using namespace std;

struct sensyu
{
	int bangou;
	double time200;
};

void sort_sensyu(struct sensyu sem[24], int nb, int ne)
{
	for(int i=nb; i<=ne-1; i++)
		for(int j=i+1; j<=ne; j++)
			if(sem[i].time200>sem[j].time200){
				struct sensyu tmp = sem[i];
				sem[i] = sem[j];
				sem[j] = tmp;
			}
}

int main()
{
	struct sensyu sem[24];
	for(int i=0; i<24; i++)
		cin >> sem[i].bangou >> sem[i].time200;

	struct sensyu fin[8];

	sort_sensyu(sem, 0, 7);
	fin[0] = sem[0];
	fin[1] = sem[1];

	sort_sensyu(sem, 8, 15);
	fin[2] = sem[8];
	fin[3] = sem[9];

	sort_sensyu(sem, 16, 23);
	fin[4] = sem[16];
	fin[5] = sem[17];

	sem[4] = sem[10];
	sem[5] = sem[11];
	sem[6] = sem[18];
	sem[7] = sem[19];
	sort_sensyu(sem, 2, 7);
	fin[6] = sem[2];
	fin[7] = sem[3];

	for(int i=0; i<8; i++)
		cout << fin[i].bangou << ' ' << showpoint << setprecision(4) << fin[i].time200 << endl;

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <numeric>
#include <string>
#include <map>
#include <set>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1145141919
typedef long long int ll;
using namespace std;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
    for (T &x : vec)
        is >> x;
    return is;
}

int main(){
    ll a,b,c;
    ll k;
    cin >> a >> b >> c >> k;

    if(k%2==0){
        cout << a - b << endl;
    }else{
        cout << b - a << endl;
    }

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
from collections import deque
from collections import Counter
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,k,s = readInts()
for i in range(k):
	print(s, end=" ")
for i in range(n-k):
	print(min(10**9-1,s+1),end=" ")
print()

Measured memory_bytes: 9696
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int n = scan.nextInt();
    int k = scan.nextInt();
    int c = scan.nextInt();
    String plan = scan.next();
    boolean[] can_work_days = new boolean[n];
    for(int i = 0;i < n;i++){
      if(plan.charAt(i) == 'o'){
        can_work_days[i] = true;
      }else{
        can_work_days[i] = false;
      }
    }
    
    int[] earliest_days = new int[k];
    int[] latest_days = new int[k];
    
    for(int i = 0, work_day = 0;work_day < k;i++){
      if(can_work_days[i]){
        earliest_days[work_day] = i;
        i += c;
        work_day++;
      }
    }
    for(int i = n - 1, work_day = 0;work_day < k;i--){
      if(can_work_days[i]){
        latest_days[work_day] = i;
        i -= c;
        work_day++;
      }
    }
    for(int i = 0;i < k;i++){
      if(earliest_days[i] == latest_days[k - i - 1])System.out.println(earliest_days[i] + 1);
    }
  }
}

Measured memory_bytes: 46112
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0; i < n; i++)
#define REPR(i, n) for(long long i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(long long i = m; i <= n; i++)
#define FORR(i, m, n) for(long long i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;


int main(){FIN

    string s;cin>>s;
    int a = (s[0]-'0')*10 + (s[1]-'0');
    int b = (s[2]-'0')*10 + (s[3]-'0');
    if (0<a && a<13 && 0<b && b<13) cout<<"AMBIGUOUS";
    else if(0<a && a<13) cout<<"MMYY";
    else if(0<b && b<13) cout<<"YYMM";
    else cout<<"NA"; 
    return 0;
}

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

int main()
{
    char a[1000],b[100];
    int c,iVar;
    double fVar;
    scanf("%s",a);
    scanf("%s",b);
    strcat(a,b);
    c=atoi(a);

    for(int i=0; i<=c; i++)
    {
        if(c==i*i)
        {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");

  return 0;
    
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
  ll cnt = 0;
  for (int i = n-1; i >= 0; i--) {
    a[i] += cnt;
    if (a[i]%b[i] != 0) {
      cnt += b[i]-a[i]%b[i];
    }
    // if (a[i] >= b[i]) {
    //   if (a[i]%b[i] == 0) continue;
    //   else a[i] %= b[i];
    // }
    // cnt += b[i]-a[i];
  }
  dump(cnt);
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;

typedef long long ll;

ll dp[15][10][2];
int f(ll n) {
  ll ans = 0;
  string s = to_string(n);
  // cout << s << endl;
  for(int i = 0; i < 15; i++) {
    for(int j = 0; j < 10; j++) {
      for(int k = 0; k < 2; k++) {
	dp[i][j][k] = 0;
      }
    }
  }

  // cout << s << endl;
  dp[0][s[0]-'0'][1] = 1;
  for(int i = (s[0] - '0') - 1; i > 0; i--) {
    dp[0][i][0] = 1;
  }

  for(int i = 1; i < s.size(); i++) {
 
      for(int j = 1; j < 10; j++) dp[i][j][0]++;
    for(int j = 0; j < 10; j++) {     
	  if(j == 0) {
	    dp[i][j][0] += dp[i-1][j][0];
	    dp[i][j+1][0] += dp[i-1][j][0];
	    //  cout <<i<<"  "<<j<<"  "<<"aa"<<endl;
	  }
	  else if(j == 9) {
	    dp[i][j][0] += dp[i-1][j][0];
	    dp[i][j-1][0] += dp[i-1][j][0];
	    //  cout <<i<<"  "<<j<<"  "<<"bb"<<endl;
	  }
	  else {
	    dp[i][j+1][0] += dp[i-1][j][0];
	    dp[i][j][0] += dp[i-1][j][0];
	    dp[i][j-1][0] += dp[i-1][j][0];
	    // cout <<i<<"  "<<j<<"  "<<"cc"<<endl;
	  }
	  // for(int i = 0; i < 10; i++) cout << dp[1][i][0] <<"   "<<dp[1][i][1] << endl;   
  
	  if(j + 1 <= (s[i] - '0')) {
	    //   cout <<i<<"  "<<j<<"  "<<"ee"<<endl;
	    if(j + 1 == (s[i] - '0')) {
	    dp[i][j+1][1] += dp[i-1][j][1];
	    }
	    else dp[i][j+1][0] += dp[i-1][j][1];
	    
	    dp[i][j][0] += dp[i-1][j][1];
	    if(j > 0) dp[i][j-1][0] += dp[i-1][j][1];
	 
	  }
	  
	  else if(j <= (s[i] - '0')) {
	    //  cout <<i<<"  "<<j<<"  "<<"dd"<<endl;
	    if(j == (s[i] - '0')) {
	      dp[i][j][1] += dp[i-1][j][1];
	    }
	    else dp[i][j][0] += dp[i-1][j][1];
	    if(j > 0) dp[i][j-1][0] += dp[i-1][j][1];
	  }
	  
	  else if(j - 1 <= (s[i] - '0')) {
	    //  cout <<i<<"  "<<j<<"  "<<"ff"<<endl;
	    if(j - 1 == (s[i] - '0')) {
	      dp[i][j-1][1] += dp[i-1][j][1];
	    }
	    else {
	      dp[i][j-1][0] += dp[i-1][j][1];
     
	    }
	      
	  }
    }
  }

 	    
 
   for(int i = 0; i < 10; i++) {
    ans += dp[s.size()-1][i][0] + dp[s.size()-1][i][1];
    //  cout << dp[s.size()-1][i][0] << "   "<< dp[s.size()-1][i][1]<<endl;
    }
  return ans;
   
	

	  
	 
	
}
  

int main() {
  ll k;
  //cout << f(100) << endl;
  cin >> k;
  
  ll l = 0, r = 1e12;

  while(r - l > 1) {
    ll mid = (l + r) / 2;
      if(k <= f(mid)) r = mid;
     else l = mid;
  }
  cout << r << endl;
  
}
    


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
int n, k, p[55], m, t, u;
bool b[55];
signed main() {
	cin >> n >> k;
	for (int i = 0; i < k; i++) {
		cin >> m;
		cin >> t; p[t] = t;
		for (int j = 1; j < m; j++) {
			cin >> u; p[u] = t;
		}
	}
	cin >> k;
	for (int i = 0; i < k; i++) {
		cin >> t >> u;
		if (p[t] == p[u]) { b[t] = 1; b[u] = 1; }
	}
	k = 0; for (int i = 1; i <= n; i++)k += b[i];
	cout << k << endl;
}


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

int main()
{
	std::string s;
	std::cin >> s;

	int tmp = 0;
	int max = 0;

	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'A' || s[i] == 'G' || s[i] == 'C' || s[i] == 'T') {
			tmp++;
			if (tmp > max)
				max = tmp;
		}
		else {
			if (tmp > max)
				max = tmp;
			tmp = 0;
		}
	}

	std::cout << max << std::endl;

	return 0;
}

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

#define INF INT64_C(10101010101010101)

int64_t mul(int64_t a, int64_t b) {
	int64_t r = 0;
	while (b > 0) {
		if (b & 1) {
			r += a;
			if (r > INF) r = INF;
		}
		a += a;
		if (a > INF) a = INF;
		b >>= 1;
	}
	return r;
}

int main(void) {
	int64_t X, K, D;
	if (scanf("%" SCNd64 "%" SCNd64 "%" SCNd64, &X, &K, &D) != 3) return 1;
	if (X < 0) X = -X;
	if (mul(K, D) <= X) {
		printf("%" PRId64 "\n", X - K * D);
	} else {
		int64_t a = X % D;
		int64_t b = D - a;
		int64_t ac = X / D;
		printf("%" PRId64 "\n", (K - ac) % 2 == 0 ? a : b);
	}
	return 0;
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
#define clear(a) memset(a, 0, sizeof(a))
#define full(a) memset(a, 0x3f, sizeof(a))
#define fornext(x, i) for(int i = head[x], y = ver[i]; i; i = nxt[i], y = ver[i])
#define mset(a, b) memset(a, b, sizeof(a))
#define Rep(i, a, b) for(int i = (a); i <= (b); ++i)
#define dRep(i, a, b) for(int i = (a); i >= (b); --i)
#define IOset(a) freopen(a".in", "r", stdin), freopen(a".out", "w", stdout);
#define un unsigned
#define ll long long
#define db double
#define dbg cout<<"c "

template<typename _T>
inline void read(_T &dig) {
	int flg; char c;
	flg = dig = 0;
	while (c = getchar(), !isdigit(c)) if (c == '-') flg = 1;
	while (isdigit(c)) dig = dig * 10 + c - '0', c = getchar();
	if (flg) dig = -dig;
}

template <typename _T, typename ...Args>
inline void read(_T &x, Args &...args) {
	read(x);
	read(args...);
}

const int N = 105;
int a[N], n;

int main() {
	read(n);
	Rep(i, 1, n) read(a[i]);
	int cnt = 0;
	Rep(i, 1, n) Rep(j, i + 1, n) Rep(k, j + 1, n) {
		if (a[i] == a[j] || a[i] == a[k] || a[j] == a[k]) continue;
		if (a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[j] + a[k] > a[i]) ++cnt;
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 3672
#include <iostream>

using namespace std;

int main(void)
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while (1) {
    c -= b;
    if (c <= 0) {
      cout << "Yes";
      break;
    }
    a -= d;
    if (a <= 0) {
      cout << "No";
      break;
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>

int main(void){
    int a,b,c,x;
    scanf("%d%d%d",&a,&b,&c);

    x = a-b;
    c = c-x;

    if(c<0){
        printf("0");
    }else{
    printf("%d\n",c);
    }
}

Measured memory_bytes: 128
use std::io::{self, Read};

fn main() {
    let mut buffer = String::new();
    io::stdin().read_to_string(&mut buffer).unwrap();
    let buffer = buffer.trim();

    let mut v = Vec::new();
    for word in buffer.split_whitespace() {
        let n: u16 = word.parse().unwrap();
        v.push(n);
    }
    let a = v.get(0);
    let b = v.get(1);
    let c = v.get(2);
    if a < b && b < c {
        println!("Yes");
    } else {
        println!("No");
    }
}



Measured memory_bytes: 5020
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    o = 1900 * M + (N - M) * 100
    print(o * (2 ** M))


if __name__ == '__main__':
    main()


Measured memory_bytes: 10220
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  l=LI()
  l.sort()

  a=2*l[2]-l[1]-l[0]

  if a%2==0:
    return a//2
  return a//2+2

print(main())


Measured memory_bytes: 5420
#/usr/bin/env ruby

while (n, m = gets.chomp!.split.map(&:to_i)) != [0, 0]
  participants = (1..n).to_a

  out = 0
  while participants.length != 1
    out = (out + m - 1) % participants.length
    participants.delete_at(out)
  end
  puts participants.pop
end

Measured memory_bytes: 6864
n = int(input())
s = [input() for i in range(n)]

m = int(input())
t = [input() for i in range(m)]

for i in range(n):
    for j in range(m):
        if s[i]==t[j]:
            s[i] = ""
            t[j] = ""
#print(s)
#print(t)
max_score = 0
for i in range(n):
    if s[i]!="" and s.count(s[i])>=max_score:
        max_score = s.count(s[i])
print(max_score)


Measured memory_bytes: 3064
a, b = map(int, input().split())
ans = 0
import itertools
for i,j,k in itertools.product(range(0,10), repeat=3):
  if i == 0:
    continue
  x = 10000*i + 1000*j + 100*k + 10*j + i
  if a <= x <= b:
    ans += 1
print(ans)

Measured memory_bytes: 3060
n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(1, n-1):
    
    if p[i-1] > p[i] and p[i] > p[i+1]:
        cnt += 1
    elif p[i-1] < p[i] and p[i] < p[i+1]:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
//abc169_b.cpp
//Sun May 31 20:45:51 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	ll a[n];

	ll ans = 1;
	ll limit = 1000000000000000000/ans;

	for (int i=0;i<n;i++){
		cin >> a[i];
		if (a[i]==0){
			cout << 0 << endl;
			return 0;
		}
	}

	for (int i=0;i<n;i++){
		if (a[i]>limit){
			cout << -1 << endl;
			return 0;
		}
		ans *= a[i];
		limit = 1000000000000000000/ans;
	}


	cout << ans << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 4416
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

#define ll long long
#define ull unsigned long long

int main()
{
    int n, a;
    std::cin >> n;
    for (int i = 0; i < n; ++i)
    {
        std::cin >> a;
        if (a % 2 == 0 && (a % 3 != 0 && a % 5 != 0))
        {
            std::cout << "DENIED" << std::endl;
            return 0;
        }
    }
    std::cout << "APPROVED" << std::endl;


    return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>

/*
#include<boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/rational.hpp>
namespace mp = boost::multiprecision;
using Real = mp::number<mp::cpp_dec_float<1024>>;
using Bint = mp::cpp_int;
*/

using namespace std;

#define int long long
#define REP(i,s,e) for((i)=(s);(i)<(e);(i)++)
#define RREP(i,s,e) for((i)=((s)-1);(i)>=(e);(i)--)
#define FOR(i,n) for((i)=(0);(i)<(n);(i)++)
#define RFOR(i,n) for((i)=((n)-1);(i)>=(0);(i)--)
#define MOD 1000000007

signed main(){
    int N,K;
    int A[200000];
    cin>>N>>K;

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

    for(int i=K;i<N;i++){
        if(A[i]<=A[i-K]){
            cout<<"No"<<endl;
        }
        else{
            cout<<"Yes"<<endl;
        }
    }
}


Measured memory_bytes: 4684
import sys
import collections


def main():
    [n, q] = [int(s) for s in sys.stdin.readline().strip().split()]
    a = [-1] * (n-1)
    b = [-1] * (n-1)
    tree = collections.defaultdict(set)
    for i in range(n-1):
        a[i], b[i] = [int(s) for s in sys.stdin.readline().strip().split()]
        tree[a[i]-1].add(b[i]-1)
        tree[b[i]-1].add(a[i]-1)

    p = [-1] * q
    x = [-1] * q
    adds = [0] * n
    for i in range(q):
        p[i], x[i] = [int(s) for s in sys.stdin.readline().strip().split()]
        adds[p[i]-1] += x[i]

    results = [0] * n
    seen = set()

    # def rec_add(node, cur, c):
    #     if c > 1000:
    #         return
    #     cur += adds[node]
    #     results[node] = cur
    #     seen.add(node)
    #     for child in tree[node]:
    #         if child in seen:
    #             continue
    #         rec_add(child, cur, c+1)
    #
    # rec_add(0, 0, 0)

    for i in range(n):
        results[i] = adds[i]
        for child in tree[i]:
            adds[child] += results[i]
    print(' '.join([str(n) for n in results]))


main()


Measured memory_bytes: 131068
n,p=map(int,input().split())
S=input()[::-1]
if p==2 or p==5:
    ans=0
    for i in range(n):
        if int(S[i])%p==0:
            ans+=n-i
    print(ans)
    exit()
mod=[0]*(n+1)
mod_l=[0]*p
mod_10=[1]*n
for i in range(n-1):
    mod_10[i+1]=mod_10[i]*10%p
for i in range(n):
    mod[i+1]=(mod[i]+int(S[i])*mod_10[i])%p
for i in range(n+1):
    mod_l[mod[i]]+=1
ans=0
for i in range(p):
    ans+=mod_l[i]*(mod_l[i]-1)//2
print(ans)

Measured memory_bytes: 44988
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = ReadInt();
            var list = new List<int>();
            for (int i = 0; i < n; i++)
            {
                var d = ReadInt();
                list.Add(d);
            }
            var ans = 1;
            list.Sort();
            for (int i = 0; i < n-1; i++)
            {
                if (list[i] == list[i + 1])
                {
                    ans--;
                }
                ans++;
                
            }
            WriteLine(ans);
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11092
import java.util.*;

public class Main {
    
    static int n;
    static int[] a = new int[21];
    
    static int dfs(int A, int B, int i) {
        int x;
        int y;
        if(i == n) return Math.abs(A-B);
        x = dfs(A+a[i], B, i+1);
        y = dfs(A, B+a[i], i+1);
        return Math.min(x, y);
    }
    
    public static void main(String[] args) {
        try(Scanner sc = new Scanner(System.in)) {
            while(sc.hasNext()) {
                n = sc.nextInt();
                if(n == 0) break;
                for(int i=0; i<n; i++) {
                    a[i] = sc.nextInt();
                }
                System.out.println(dfs(0, 0, 0));
            }
        }
    }
}



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

int n, m, o, r, c, sz, ang;
int mp[20][20] = {0}, tmp[400] = {0};

void rotate();
void reversal();
void lshift();
void rshift();
void island();

int main() {
  int i, j;
  cin >> n >> m;
  for(i = 1; i <= n; ++i)
    for(j = 1; j <= n; ++j) cin >> mp[i][j];
  for(i = 0; i < m; ++i) {
    cin >> o;
    if(o == 0) rotate();
    if(o == 1) reversal();
    if(o == 2) lshift();
    if(o == 3) rshift();
    if(o == 4) island();
  }
  for(i = 1; i <= n; ++i) {
    for(j = 1; j <= n; ++j) {
      cout << mp[i][j];
      if(j != n) cout << " ";
    }
    cout << endl;
  }
  return 0;
}
void rotate() {
  int i, j, k, cnt;
  cin >> r >> c >> sz >> ang;
  if(ang == 0 || ang == 360 || sz == 1) return;
  for(k = 0; k < ang; k += 90) {
    cnt = 0;
    for(i = r; i < r + sz; ++i)
      for(j = c; j < c + sz; ++j) tmp[cnt++] = mp[i][j];
    cnt = 0;
    for(i = c + sz - 1; i >= c; --i)
      for(j = r; j < r + sz; ++j) mp[j][i] = tmp[cnt++];
  }
}
void reversal() {
  int i, j;
  cin >> r >> c >> sz;
  for(i = r; i < r + sz; ++i)
    for(j = c; j < c + sz; ++j) mp[i][j] = 1 - mp[i][j];
}
void lshift() {
  cin >> r;
  mp[r][n + 1] = mp[r][1];
  for(int i = 1; i <= n; ++i) mp[r][i] = mp[r][i + 1];
}
void rshift() {
  cin >> r;
  mp[r][0] = mp[r][n];
  for(int i = n; i > 0; --i) mp[r][i] = mp[r][i - 1];
}
void island() {
  int data;
  int d[4] = {1, 0, -1, 0};
  pair<int, int> now, nextn;
  stack<pair<int, int>> st;
  cin >> r >> c;
  data = mp[r][c];
  mp[r][c] = 1 - mp[r][c];
  st.push(make_pair(r, c));
  while(!st.empty()) {
    now = st.top();
    st.pop();
    for(int i = 0; i < 4; ++i) {
      nextn = now;
      nextn.first += d[i];
      nextn.second += d[1 ^ i];
      if(nextn.first > 0 && nextn.first <= n &&
         nextn.second > 0 && nextn.second <= n &&
         mp[nextn.first][nextn.second] == data) {
        st.push(nextn);
        mp[nextn.first][nextn.second] =
            1 - mp[nextn.first][nextn.second];
      }
    }
  }
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

string s;

vector<pair<char, ll>> prs;

int main(void) {
  // Here your code !
  cin >> s;

  int n = s.size() + 1;

  vector<ll> base(n, -1L);

  if (s[0] == '<') base[0] = 0;

  if (s.back() == '>') base[n - 1] = 0;

  for (int i = 1; i < s.size(); ++i) {
    if (s[i - 1] == '>' && s[i] == '<') {
      base[i] = 0;
    }
  }

  s.insert(0, s[0] == '<' ? "_" : ">");

  // for (auto &e : s) {
  //   printf("%2c ", e);
  // }
  // printf("\n");

  // for (auto &e : base) {
  //   printf("%2d ", e);
  // }
  // printf("\n");

  for (int i = 0; i < n; ++i) {
    if (base[i] != 0) continue;

    for (int j = i + 1; j < n; ++j) {
      if (base[j] == 0) break;
      if (s[j] == '>') break;
      base[j] = max(base[j], (ll)(j - i));
    }

    for (int j = i - 1; j >= 0; --j) {
      if (base[j] == 0) break;
      if (s[j] == '<') break;
      base[j] = max(base[j], (ll)(i - j));
    }
  }

  // for (auto &e : s) {
  //   printf("%2c ", e);
  // }
  // printf("\n");

  // for (auto &e : base) {
  //   printf("%2d ", e);
  // }
  // printf("\n");

  for (int i = 0; i < n; ++i) {
    if (s[i] == '<' && s[i + 1] == '>') {
      if (base[i] <= base[i + 1]) base[i] = base[i + 1] + 1;
    }
  }

  // for (auto &e : s) {
  //   printf("%2c ", e);
  // }
  // printf("\n");

  // for (auto &e : base) {
  //   printf("%2d ", e);
  // }
  // printf("\n");

  ll ans = 0;

  for (auto &e : base) {
    ans += e;
  }

  printf("%lld\n", ans);

  return 0;
}


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

#define fast ios_base::sync_with_stdio(false); cin.tie(nullptr); cin.tie(nullptr);
#define range(v) v.begin(),v.end()
#define int long long
#define pb push_back
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(2e5 + 10)

using namespace std;


char solve() {
	char c;
	cin >> c;
	if (tolower(c) == c) return 'a';
	else return 'A';
}

int32_t main() {
	fast
	int t_c = 1;
	// cin >> t_c;
	while (t_c--) {
		auto ans = solve();
		cout << ans << endl;
	}
}

Measured memory_bytes: 3648
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <numeric>

using namespace std;
#define modd 1000000007


typedef pair<long long, long long> pl;


#define ll long long




/*
class UnionFind {
public:
	vector <ll> par; 
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i; 
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, k, a, b, c, d, e,H, W;
long long A[12][20] = {};
long long B[200005] = {};
long long C[20][200] = {};
bool f;
bool ff;
string S;
set <long long>sll;
pl buf;
vector <long long>vl;
vector <pl>vpl;

struct ST
{
	long long group;
	long long rank;
	long long tugi=-1;
	int siro;
};

void sai(int kaime) {
	for (int ii = 0; ii < 2; ii++) {
		
		
		for (int j = 0; j <= M; j++) {
			C[kaime][j] = 0;
		}
		

		for (int jj = 0; jj < M; jj++) {
			f = false;
			if (kaime > 0) {
				C[kaime][jj] = C[kaime - 1][jj];
			}

			for (int j = 0; j < A[jj][0]; j++) {
				if (kaime + 1 == A[jj][j+1]) {
					f = true;
				}
			}

			if (ii == 1 && f==true) {
				C[kaime][jj]++;
			}
		}

		if (kaime == N - 1) {
			a = 1;
			for (int j = 0; j < M; j++) {
				if (C[kaime][j] % 2 != B[j]) {
					a = 0;
				}
			}
			if (a == 1) {
				b++;
			}

		}
		else {
			sai(kaime + 1);
		}
	}
}

vector <ST> vst;
double fl, fll;


int main() {

	cin >>N>>M;
	
	a = 0;

	a = 3 * N + M;

	cout<<a/2 << endl;

	return 0;

}


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

int main(void) {
  long long n, k;
  cin >> n >> k;

  long long result;
  if (n <= k) {
    result = min(n, k - n);
  } else {
    // result = n % min(k, n - k);
    result = n % min(k, n - k);
    if (result < k) result = min(result, k - result);
  }

  cout << result << endl;
  return 0;
}

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

using namespace std;

#define Fast  ios::sync_with_stdio(false); cin.tie(0)
#define pb push_back
#define pf push_front
#define pp pop
#define ppb pop_back
#define ppf pop_front
#define mp make_pair
#define S second
#define F first
typedef long long ll;
const ll mod = 1e9 + 7;
const ll N = 1e6 + 5;
ll inf = 1e18;

ll dp[N];

int main(){

    Fast;

    ll n;
    cin >> n;
    ll ans = 0;

    for(int i = 1; i < n; i ++){
        dp[i] ++;
        for(int j = i+i; j < n; j += i){
            dp[j] ++;
        }

        ans += dp[i];
    }

    cout << ans ;

    return 0;
}


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

ll solve(ll k, vector<ll>& a) {
    ll t = a[1];
    ll h = a[a[1]];

    while (t != h) {
        t = a[t];
        h = a[a[h]];
    }

    ll mu = 0;
    t = 1;
    while (t != h) {
        t = a[t];
        h = a[h];
        mu++;
    }
    ll lam = 1;
    h = a[t];
    while (t != h) {
        h = a[h];
        lam++;
    }

    ll s;
    if (k <= mu) {
        s = k;
    } else {
        s = (k - mu) % lam;
        s += mu;
    }
    ll ans = 1;
    for (ll i = 0; i < s; i++) {
        ans = a[ans];
    }
    return ans;
}

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

    ll n, k;
    cin >> n >> k;

    vector<ll> a(n + 1, 0);
    for (ll i = 1; i < n + 1; i++)
        cin >> a[i];
    cout << solve(k, a) << "\n";
}


Measured memory_bytes: 4740
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
using namespace std;
#define ll long long
ll n,tmp1,tmp2;
int main()
{
    scanf("%lld",&n);
    for(int a=1;a<=3500;a++)
        for(int b=1;b<=3500;b++)
        {
            tmp1=-n*a*b,tmp2=n*a+n*b-4*a*b;
            if(tmp1&&tmp2&&tmp1%tmp2==0&&tmp1/tmp2>0)
            {
                printf("%lld %lld %lld\n",a,b,tmp1/tmp2);
                return 0;
            }
        }
    return 0;
}


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

int main (){
  int N,K;
  cin >>N >> K;
  vector <int> vec(N,0);
  for (int i=0;i<N;i++){
    cin >> vec.at(i);
  }
  vector <int> kitai(N-(K-1),0);
  int kmax=0;
  int count =0;
  for (int i=0;i<(N-(K-1));i++){
    if (i==0){
      for (int j=0;j<K;j++){
        kitai.at(i)+=vec.at(i+j);
      }
    }
    else {
      kitai.at(i)=kitai.at(i-1);
      kitai.at(i)+=vec.at(i+K-1);
      kitai.at(i)-=vec.at(i-1);
    }
      
    if (kmax<kitai.at(i)){
      kmax =kitai.at(i);
      count =i;
    }
  }
  double kitaimax =0;
  for (int i=0;i<K;i++){
    int a=vec.at(count+i)*(vec.at(count+i)+1)/2;
    kitaimax+=(double)a/(double)vec.at(count+i);
  }
  cout << fixed << setprecision(10);
  cout << kitaimax << endl;
}
  

Measured memory_bytes: 1792
#include <iostream>
#include <limits.h>
#include <cstdio>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
/* ここからが本編 */
/*  */
int main(void)
{
  int test = 1;
  int i,j,k,l;
  int n;
  int min = INT_MAX;
  int rep = INT_MIN;
  int a;
  scanf("%d",&n);
  rep(i,n) {
    scanf("%d",&a);
    if(a - min > rep) rep = a - min;
    if(min > a) min = a;
  }
  printf("%d\n",rep);
  return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

void dfs(vector<vector<int>> &tree, int now, int bf, int bfuse, int mx, map<pair<int, int>, int> &ans){
  int use = 0;
  if(use == bfuse) use++;
  for(int i : tree.at(now)){
    if(i == bf) continue;
    int ii = i, nn = now;
    if(nn > ii) swap(nn, ii);
    pair<int, int> p = make_pair(nn, ii);
    if(ans.count(p) == 0){
      ans[p] = use;
      dfs(tree, i, now, use, mx, ans);
      use++;
      if(use == bfuse) use++;
    }
  }
}

int main(){
  int n;
  cin >> n;
  vector<vector<int>> tree(n, vector<int>());
  vector<pair<int, int>> in(n-1);
  map<pair<int, int>, int> ans;
  rep(i, n-1){
    int a, b;
    cin >> a >> b;
    a--; b--;
    in.at(i) = make_pair(a, b);
    tree.at(a).push_back(b);
    tree.at(b).push_back(a);
  }
  int mx = 0;
  rep(i, n){
    mx = max(mx, (int)tree.at(i).size());
  }
  cout << mx << endl;
  dfs(tree, 0, -1, -1, mx, ans);
  rep(i, n-1){
    auto p = in.at(i);
    if(ans.count(p) == 1)cout << ans[p]+1 << endl;
    else return 1;
  }
  return 0;
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
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;}
const int inf = 1001001001;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    rep(key,1000) {
        int d[3] = {key/100,(key%100)/10,key%10};
        int ex = -1;
        bool ok = false;
        rep(i,n) {
            int now = s[i]-'0';
            if(now == d[ex+1]) ex++;
            if(ex == 2) {
                ok = true;
                break;
            }
        }
        if(ok) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
signed main(){
  int n,id=0;
  cin>>n;
  int a[50];
  r(i,50)a[i]=i+n/50;
  n%=50;
  r(i,n){
    a[id]+=50;
    r(j,50)if(j!=id)a[j]--;
    id=(id+1)%50;
  }
  cout<<50<<endl;
  r(i,50)cout<<(i?" ":"")<<a[i];
  cout<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import numpy as np
N = int(input())
A_1 = np.array([int(x) for x in input().split()])
A_2 = np.array([int(x) for x in input().split()])
A_1_sum = list(np.cumsum(A_1))
A_2_sum = [0] + list(np.cumsum(A_2))
ans = -(np.inf)
for i in range(N):
    ans = max(ans, A_1_sum[i] + A_2_sum[-1] - A_2_sum[i])
print(ans)


Measured memory_bytes: 12432
n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
b = set()
now = float("inf")
now3 = [float("inf")]*3
for k in a:
        if k == now3[0] == now3[1] == now3[2]:
            print(k**2)
            break
        if k == now:
                b.add(k)
        if len(b) == 2:
            b = list(b)
            print(b[0]*b[1])
            break
        now = k
        now3.append(k)
        now3.pop(0)
else:
    print(0)


Measured memory_bytes: 14252
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
   public static void main(String[] args)  {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            br.readLine();
            String[] split = br.readLine().split(" ");
            int n = split.length;
            double[] prob = new double[n];
            for (int i = 0; i < n; i++) {
               prob[i] = Double.parseDouble(split[i]); 
            }
            double[][] dp = new double[n + 1][n + 1];
            dp[0][0] = 1.0;
            for (int i = 1; i <= n; i++) {
                for (int j = 0; j <= n; j++) {
                    double p = 0.0;
                    if (j == 0) {
                        p += dp[i - 1][j]*(1 - prob[i - 1]);
                    } else {
                        p += dp[i - 1][j - 1]*prob[i - 1] + dp[i - 1][j]*(1 - prob[i - 1]);
                    }
                    dp[i][j] = p;
                }
            }
            double result = 0.0;
            for (int i = (n + 1) / 2 ; i <= n; i++) {
                result += dp[n][i];
            }
            /*for(double[] row: dp) {
                for (Double d: row) {
                    System.out.print(String.format("%.2f ", d == null ? 0.0 : d));
                }
                System.out.println();
            }*/
            System.out.println(result);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 130508
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a)%MOD)+((b)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF 214748364700000
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using MCI = std::map<char, int>;
using namespace std;


int N;


bool solve(int n = N){
	if(n == 0) return true;
	if(n < 4) return false;
	return solve(n-4) || solve(n-7);
}


signed main(){
	cin >> N;

	if(solve()) Yes;
	else No;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

#define rep(i, n)      for (int i=0; i<int(n); i++)
#define rep3(i, s, n)  for (int i=int(s); i<int(n); i++)
#define rev_rep(i, n)  for (int i=int(n)-1; i>=0; i-=1)

int N;
int epsilon = numeric_limits<double>::epsilon();
bool a_lt_b(double a, double b) {
  return (b - a) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon * epsilon);
}

int main() {
  cin >> N;
  rep(i, N) {
    double xa, ya, ra, xb, yb, rb;
    cin >> xa >> ya >> ra >> xb >> yb >> rb;
    double dist_p = (xa-xb)*(xa-xb) + (ya-yb)*(ya-yb);
    int ans = 1;
    if (a_lt_b((ra+rb)*(ra+rb), dist_p)) ans = 0;
    if (ra > rb && a_lt_b(dist_p, (ra-rb)*(ra-rb))) ans =  2;
    if (ra < rb && a_lt_b(dist_p, (rb-ra)*(rb-ra))) ans = -2;
    cout << ans << "\n";
  }
  return 0;
}

Measured memory_bytes: 3212
# -*- coding: utf-8 -*-
"""
Created on Sun Feb  3 21:07:35 2019

@author: Yamazaki Kenichi
"""

N,M = map(int,input().split())
X = list(map(int,input().split()))

if N >= M:
    ans = 0

else:
    X.sort()
    A = []
    for i in range(M-1):
        A.append(X[i+1]-X[i])
    A.sort()
    ans = X[M-1]-X[0]

    for i in range(M-2,M-2-(N-1),-1):
        ans = ans - A[i] 
print(ans)

Measured memory_bytes: 13960
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll ans,n,r,g,b;
string s; 
int main()
{
	cin>>n>>s;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='R') r++;
		if(s[i]=='G') g++;
		if(s[i]=='B') b++;
	}
	ans=r*g*b;
	for(int i=0;i<n;i++)
	for(int j=i+1;j<n,2*j-i<n;j++)
	{
		if(s[i]!=s[j]&&s[j]!=s[2*j-i]&&s[i]!=s[2*j-i])
		ans--;
	}
	cout<<ans;
    return 0;
}


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

int main(void)
{
	int K;
	cin >> K;

	queue<long int> q;

	for (int i = 1; i < 10; i++) {
		q.push(i);
	}

	long int x = 0;
	for (int i = 0; i < K; i++) {
		x = q.front();
		q.pop();
		if (x % 10 != 0) {
			q.push(10 * x + x % 10 - 1);
		}
		q.push(10 * x + x % 10);
		if (x % 10 != 9) {
			q.push(10 * x + x % 10 + 1);
		}
	}

	cout << x << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include<iostream>
#include<vector>
using namespace std;
int main()
{
    int n;
    while(cin>>n)
    {
        int a[200];
        int sum1=0,sum2=0;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            sum1+=a[i]*a[i];
            sum2+=2*a[i];
        }
//        cout<<sum1<<" "<<sum2<<endl;
        int sum=100000000;
        for(int i=-100;i<=100;i++)
        {
            sum=min(sum1+n*i*i-sum2*i,sum);
        }
        cout<<sum<<endl;
    }
}


Measured memory_bytes: 256