akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

int main(){
  int a,b,c;

  scanf("%d %d %d", &a, &b, &c);

  if(c - (a - b) > 0) printf("%d\n", c - (a - b));

  else printf("0\n");
  
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#define AC ios_base::sync_with_stdio(0),cin.tie(0)
using namespace std;
const int x[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
int main(){
	AC;
	int n;
	cin>>n;
	cout<<x[n-1]<<"\n";
	//cout<<"The "<<n<<"-th element is "<<x[n-1]<<".\n";
}

Measured memory_bytes: 3600
#include<stdio.h>
 
int main(void) {
  int i,j,N,M,Q;
  
  scanf("%d %d %d",&N,&M,&Q);
  
  int x[501][501] = {{0}};
  
  for(i=0; i<M;i++) {
    int l,r;
    scanf("%d %d",&l,&r);
    x[l][r]++;
  }
 
  for(i=1; i<=N; i++) {
    for(j=1; j<=N; j++) {
      x[i][j] = x[i][j] + x[i-1][j] + x[i][j-1] - x[i-1][j-1];
    }
  }
	
  for(i=0; i<Q; i++) {
    int p,q;
    scanf("%d %d",&p,&q);
    printf("%d\n",x[q][q] - x[p-1][q] - x[q][p-1] + x[p-1][p-1]);
  }
    
  return(0);
}
 

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

namespace ABC094
{
    class A
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            List<int> a = Console.ReadLine().Split().Select(int.Parse).ToList();
            a = a.OrderBy(x => x).ToList();

            int max = a[a.Count - 1];
            int index = a.BinarySearch(max / 2);
            int minIndex2 = 0;

            if (index < 0)
            {
                index = ~index;
                minIndex2 = index - 1;
                index = Math.Abs(a[index] - max / 2d) < Math.Abs(a[minIndex2] - max / 2d) ? index : minIndex2;
            }

            int min = a[index];
            //Console.WriteLine(string.Join(" ", a));
            Console.WriteLine("{0} {1}", max, min);

        }
    }
}


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

int main()
{
	int num;
	cin >> num;
	string str = to_string(num);
	str = str.substr(str.size() - 1);
	string result;
	switch (stoi(str))
	{
	case 0:
	case 1:
	case 6:
	case 8:
		result = "pon";
		break;
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		result = "hon";
		break;
	case 3:
		result = "bon";
		break;
	}
	cout << result << "\n";
	return 0;
}


Measured memory_bytes: 3108
#include <iostream>
#include <string.h>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;
int main(){
	long long a, b, c, d;
	cin >> a >> b >> c >> d;
	long long  a_ = a,  b_ = b, c_=c, d_=d;
	while (c_ != d_) {
		if (c_ > d_ ) {
			c_ -= d_;
		}
		else {
			d_ -= c_;
		}
	}
	a_ -= (a / c);
	a_ -= (a / d);
	a_ += (a / (c*d/d_));
	b_ -= (b / c);
	b_ -= (b / d);
	b_ += (b / (c*d/d_));
	if (a%c == 0 || a % d == 0) {
		cout << b_ - a_;
	}
	else {
		cout << b_ - a_+1;
	}
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, m := scanInt(), scanInt()
	uf := make(unionFind, n)
	uf.init()
	for i := 0; i < m; i++ {
		a, b := scanInt()-1, scanInt()-1
		uf.unite(a, b)
	}
	ans := 0
	for i := 0; i < n; i++ {
		ans = max(ans, uf.size(i))
	}
	fmt.Fprintln(wr, ans)
}

type unionFind []int

func (uf *unionFind) init() {
	for i := 0; i < len(*uf); i++ {
		(*uf)[i] = -1
	}
}

func (uf *unionFind) find(x int) int {
	if (*uf)[x] < 0 {
		return x
	}
	(*uf)[x] = uf.find((*uf)[x])
	return (*uf)[x]
}

func (uf *unionFind) unite(x, y int) {
	x, y = uf.find(x), uf.find(y)
	if x != y {
		if (*uf)[x] > (*uf)[y] {
			x, y = y, x
		}
		(*uf)[x] += (*uf)[y]
		(*uf)[y] = x
	}
}

func (uf *unionFind) size(x int) int {
	return -(*uf)[uf.find(x)]
}


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

int main() {
    int n, m, ta, tb;
    cin >> n >> m;
    bool a[n], b[n];
    fill(a, a+n, false);
    fill(b, b+n, false);
    for (int i = 0; i < m; i++) {
        cin >> ta >> tb;
        if (ta == 1) a[tb-1] = true;
        if (ta == n) b[tb-1] = true;
        if (tb == 1) a[ta-1] = true;
        if (tb == n) b[ta-1] = true;
    }

    for (int i = 1; i < n-1; i++) {
        if (a[i] && b[i]) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }

    cout << "IMPOSSIBLE" << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define plll pair<ll,pll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;

ll num[510];
ll maxchange;
ll n;


bool solve(ll div)
{
    ll add[n];
    ll subtract[n];
    for(ll i=0;i<n;i++)
    {
        add[i]=num[i]%div;
    }
    sort(add,add+n);
    for(ll i=0;i<n;i++)
    {
        subtract[i]=div-add[i];
        if(subtract[i]==div)
        {
            subtract[i]=0;
        }
    }
    for(ll i=1;i<n;i++)
    {
        add[i]+=add[i-1];
    }
    for(ll i=n-2;i>=0;i--)
    {
        subtract[i]+=subtract[i+1];
    }
    ll minval=INF;
    for(ll i=0;i<n-1;i++)
    {
        minval=min(minval,max(add[i],subtract[i+1]));
    }
    if(minval<=maxchange)
    {
        return true;
    }
    return false;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll sum=0;
    cin>>n>>maxchange;
    for(ll i=0;i<n;i++)
    {
        cin>>num[i];
        sum+=num[i];
    }
    set<ll> s1;
    ll temp;
    ll root=sqrt(sum);
    for(ll i=1;i<=root;i++)
    {
        if(sum%i==0)
        {
            temp=sum/i;
            s1.insert(i);
            s1.insert(temp);
        }
    }
    vector<ll> divisor(s1.begin(),s1.end());
    ll size=divisor.size();
    ll ans=1;
    for(ll i=1;i<size;i++)
    {
        if(solve(divisor[i]))
        {
            ans=divisor[i];
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define Imposter ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
#define f(n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(i=a;i<b;i++)
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define vll vector<ll>
#define vlll vector<vll>
#define all(x) x.begin(),x.end()
ll MOD=1e9 +7;
ll power(ll x, ll y, ll p) {
    ll res = 1;    x = x % p;
    while(y > 0) {
        if(y & 1) res = (res*x) % p;
        y = y>>1;    x = (x*x) % p;
    } return res;
}
ll mpower(ll x, ll y, ll m){
  if(y < 0){
    return 0;
  }else if(y == 0){
    return 1LL;
  }else if(y%2 == 0){
    return mpower(x,y/2,m)*mpower(x,y/2,m)%m;
  }else{
    return mpower(x,y-1,m)*x%m;
  }
}


int main()
{
    Imposter

    ll n; cin >> n; 
  vector<ll> a(n); f(n){ cin >> a[i]; }
  
  //main
  vector<ll> zero(61), one(61);
  f(n){
    for(int j=0;j<61;j++){
      if((a[i]>>j)%2==1){
        one[j]++;
      }else{
        zero[j]++;
      }
    }
  }
  ll ans = 0;
  f(61){
    if(zero[i] != 0 && one[i] != 0){
      ll tmp = ((mpower(2,i,MOD)*zero[i]%MOD)*one[i])%MOD;
      ans = (ans+tmp)%MOD;
      if(ans < 0){
        ans += MOD; 
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5584
#include <stdio.h>

int main(void){

  int i,n,A[100];

  scanf("%d\n",&n);
  for(i=0;i<n;i++){
      scanf(" %d",&A[i]);
    }
  
  for(i=n-1;i>=0;i--){
    if(i != n-1)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 1860
#include <bits/stdc++.h>
const int MAX = 1e6 + 10;
typedef long long i64;
using namespace std;
const double EPS = 1e-6;
const int MOD = 1e9 + 7;
#define mul(a, b) ((i64)(a) * b % MOD)
int dp[2][55];
int main() {

    #ifdef LOCAL_DEBUG
    freopen ("data.in", "r", stdin );
    //freopen ("data.out", "w", stdout );
    #endif
    ios_base::sync_with_stdio(0); cin.tie(0);
    #define endl '\n'

   int n; cin >> n;
   char ar[2][53];
   cin >> ar[0] + 1 >> ar[1] + 1;
   int ans = 1;

   for(int i = 1; i <= n; i++){
	   if(ar[0][i] == ar[1][i]){
		   if(i == 1){
			   ans = 3;
		   }
		   else if(ar[0][i - 1] == ar[1][i - 1]){
			   ans = mul(ans, 2);
		   }
		   else{
			   ;
		   }
	   }
	   else{
		   if(i == 1){
			   ans = 6;
		   }
		   else if(i > 1 and ar[0][i - 1] == ar[0][i]){
			   ;
		   }
		   else{
			   if(ar[0][i - 1] == ar[1][i - 1]){
				   ans = mul(ans, 2);
			   }
			   else{
				   ans = mul(ans, 3);
			   }
		   }
	   }
   }
   cout << ans;


}



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

#define inf 1000000007

using namespace std;

typedef long long ll;

int main()
{
    string c;
    cin >> c;
    if(c[0]>'Z')
    {
        printf("a\n");
    }
    else
    {
        printf("A\n");
    }
    return 0;
}


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

using namespace std;

typedef long long ll;

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 solve(const int n, const vector<int> &p) {
    int count = 0;
    for (int i = 1; i < n - 1; i++) {
        if ((p[i - 1] < p[i] && p[i] < p[i + 1]) ||
                (p[i + 1] < p[i] && p[i] < p[i - 1])) {
            count++;
        }
    }

    return count;
}

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

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

    cout << solve(n, p) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

ll n,q;
string s;
struct SegmentTree {
private:
    int n;
    vector<int> node;
public:
    SegmentTree(vector<int> v) {
        int sz = (int)v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, 0);

        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
    }

    void add(int k, int val) {
        k += (n - 1);
        node[k] += val;

        while(k > 0) {
            k = (k - 1) / 2;
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }

    int getsum(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(b <= l || r <= a) return 0;
        if(a <= l && r <= b) return node[k];

        int vl = getsum(a, b, 2*k+1, l, (l+r)/2);
        int vr = getsum(a, b, 2*k+2, (l+r)/2, r);
        return vl + vr;
    }
};

vector<SegmentTree> v;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>n>>s>>q;
    rep(i,26){
        vi vv(n,0);
        rep(j,n){
            if(s[j]-'a'==i)vv[j]=1;
        }
        v.pb(SegmentTree(vv));
    }
    int a,b;
    rep(i,q){
        cin>>a>>b;
        if(a==1){
            char c;
            cin>>c;
            int cc = c-'a';
            int bb = s[b-1]-'a';
            s[b-1]=c;
            v[bb].add(b-1,-1);
            v[cc].add(b-1,1);
        }else{
            int c;
            cin>>c;
            ll ans = 0;
            rep(i,26){
                if(v[i].getsum(b-1,c)>0){
                    ans++;
                }
            }
            print(ans);
        }
    }
    return 0;
}

Measured memory_bytes: 111444
#include<iostream>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main(){
	long long int a[200000],mini=100000000000,n,sum1=0,sum2=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		sum1+=a[i];
	}
	for(int i=n-1;0<i;i--){
		sum1-=a[i];
		sum2+=a[i];
		if(abs(sum1-sum2)<mini){
			mini=abs(sum1-sum2);
		}
	}
	cout<<mini<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,x,cnt=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&x);
		cnt+=x&1;
	}
	if(cnt&1) puts("NO");
	else puts("YES");
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
using namespace std;
const int N=100010;
int e[N*2],nex[N*2],head[N],ed=0;
void adde(int x,int y){e[++ed]=y;nex[ed]=head[x];head[x]=ed;}
int dfs(int x,int fa){
    int i,t=0;
    for(i=head[x];i;i=nex[i])
        if(e[i]!=fa) t^=dfs(e[i],x)+1;
    return t;
}
int main(){
    int n,i,x,y;
    scanf("%d",&n);
    for(i=1;i<n;i++){
        scanf("%d %d",&x,&y);
        adde(x,y);adde(y,x);
    }
    if(dfs(1,0)) printf("Alice\n");
    else printf("Bob\n");
    return 0;
}


Measured memory_bytes: 6912
#include <iostream>
#include <algorithm>

void a();
void b();
void c();
void d();
void e();
void f();

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

void a() {
	int A, B;
	std::cin >> A >> B;
	std::cout << std::max({A + B, A - B, A * B}) << std::endl;
}

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

namespace ConsoleApp1
{
    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            B();
        }

        static void B()
        {
            var N = ReadInt();
            var an = ReadSplitInt();
            Console.WriteLine(an.Max() - an.Min());
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int DigitsSum(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static IList<string> ReadSplit() => Read().Split().ToList();
        static IList<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
    }
}

Measured memory_bytes: 13396
N, M = list(map(int, input().split()))
res = [-1,-1,-1]

for i in range(0,N+1):
    for j in range(0,N+1):
        if i + j > N:
            continue
        if 10000*i+5000*j+1000*(N-i-j) == M:
            res = [i,j,N-i-j]
            break
            
print(" ".join(list(map(str, res))))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

bool solve()
{
    int n,m;
    cin >>n >>m;

    vector<set<int>> G(n);
    rep(i,m)
    {
        int a,b;
        cin >>a >>b;
        --a; --b;
        G[a].insert(b);
        G[b].insert(a);
    }

    for(int i=1; i<n-1; ++i)
    {
        if(G[0].count(i) && G[n-1].count(i)) return true;
    }
    return false;
}

int main()
{
    cout << (solve()?"POSSIBLE":"IMPOSSIBLE") << endl;
    return 0;
}


Measured memory_bytes: 28416
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int s;cin >> s;
	vector<int> a(10000);
	vector<bool> memo(10000);
	a[0]=s;
	rep(i,9999){
		if(memo[a.at(i)]){
			cout << i+1 << endl;
			return 0;
		}
		memo[a.at(i)]=true;
		if(a.at(i)%2==0) a[i+1]=a[i]/2;
		else a[i+1]=a[i]*3+1;
	}
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N, K = map(int, input().split())
As = list(map(int, input().split()))
Ms = dict()

cnt = 0
pos = 0
Ms[pos] = cnt

found = False

while cnt < K:
    pos = As[pos]-1
    cnt += 1
    if (not found) and (pos in Ms.keys()):
        found = True
        K = (K - Ms[pos]) % (cnt - Ms[pos]) + cnt
    Ms[pos] = cnt

print(pos+1)


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

int main() {
  int s;
  cin >> s;
  vector<int> series(1000000, 0);
  series.at(0) = s;
  for (int i = 0; i < 1000000; i++) {
    int ai = series.at(i);
    if ( ai % 2 == 1) {
      series.at(i + 1) = 3 * ai + 1;
    }
    else {
      series.at(i + 1) = ai / 2;
    }
    auto itr = find(series.begin(), series.begin() + i, series.at(i + 1));
    if (itr != series.begin() + i) {
      cout << i + 2 << endl;
      break;
    }
  }
}


Measured memory_bytes: 4096
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
def LILI(n): return [LI() for _ in range(n)]
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main_old(): 
    N, M, queries = LI()
    L = []
    R = []
    for _ in range(M):
        l, r = LI()
        L.append(l)
        R.append(r)
    P = []
    Q = []
    for _ in range(queries):
        p, q = LI()
        P.append(p)
        Q.append(q)

    regions = [[] for _ in range(N+1)]
    for l, r in zip(L, R):
        regions[l].append(r-l)
    regions_cumsum = [[0]*(N+1) for _ in range(N+1)]
    for i in range(len(regions)):  # [0,1,1,1,2,2] みたいなのを [1, 4, 6] と変換したい。
        # まずはカウントする
        cnt = [0]*(N+1)
        for j in range(N+1):
            cnt[regions[i][j]] += 1
        # 続いて累積和を取る。
        regions_cumsum[0] = cnt[0]
        for j in range(1, N+1):
            regions_cumsum[j] = regions_cumsum[j-1] + cnt[j]

    from bisect import bisect_right
    
    for p, q in zip(P, Q):
        counter = 0
        length = q-p
        print(regions_cumsum[q] - regions_cumsum[p])




    # 駅番号: [そこから出る区間の長さのリスト] を持つ。
    # クエリを駅番号・長さに持ち替えてソート。
    # クエリごとに、駅番号において長さよりも短い電車が何本あるか見ていく。となりの駅に写ったら1引く。
    # これでQ*N？



def main(): 
    N, M, queries = LI()
    L = []
    R = []
    for _ in range(M):
        l, r = LI()
        L.append(l)
        R.append(r)
    P = []
    Q = []
    for _ in range(queries):
        p, q = LI()
        P.append(p)
        Q.append(q)

    trains = [[0]*(N+1) for _ in range(N+1)]
    for l, r in zip(L,R):
        trains[l][r] += 1

    cumsum = [[0]*(N+1) for _ in range(N+1)]
    for i in range(1, N+1):
        for j in range(1, N+1):
            cumsum[i][j] = cumsum[i][j-1] + trains[i][j]

    for p, q in zip(P, Q):
        range_sum = 0
        for i in range(p, q+1):
            range_sum += cumsum[i][q] - cumsum[i][p-1]
        print(range_sum)

main()

Measured memory_bytes: 90332
import java.util.*;
import java.io.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int A = Integer.parseInt(sc.next());
        int B = Integer.parseInt(sc.next());
        int C = Integer.parseInt(sc.next());
        sc.close();

        int maxbuy = B / A;
        out.printf("%d\n", Math.min(C, maxbuy));
        out.flush();
    }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
signed main(){
	 map<int ,int>mp;
	 int ans=0;
	 int n,cnt=0;
	 cin>>n;
	 ++mp[0];
	 rep(i,n){
		 int wa;
		 cin>>wa;
		 cnt+=wa;
		 ++mp[cnt];
       }
       for(auto i=mp.begin();i!=mp.end();++i){
		   ans+=i->second*(i->second-1)/2;
	   }
	   cout<<ans<<endl;
   }

Measured memory_bytes: 12800
N = int(input())
alpha = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
ans = ''

while N > 0:
    N-=1
    index = N%26
    ans = alpha[index] + ans
    N = N // 26
print(ans)

Measured memory_bytes: 9084
n , m = map(int,input().split())
p = []
for i in range(n):
    a,b = map(int,input().split())
    p.append([a,b])
p.sort()
ans = 0
cou = 0
for a,b in p:
    if cou + b < m:
        cou += b
        ans += a*b
    elif cou + b >= m:
        ans += a*(m-cou)
        break
print(ans)

Measured memory_bytes: 20048
import heapq

# お約束
INF = float("inf")
MOD = int(1e9 + 7)
def int1(n):
    return int(n) - 1
def parse(*args):
    # (tuple(map(int, input().split())) for _ in range(N))
    return tuple(p(v) for p, v in zip(args, input().split()))

N = int(input())
V = list(map(int, input().split()))

que = []

for v in V:
	heapq.heappush(que, v)

res = 0
while que:
	v1, v2 = heapq.heappop(que), heapq.heappop(que)
	if not que:
		res = (v1 + v2) / 2
		break
	heapq.heappush(que, (v1 + v2) / 2)

print(res)


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

int main() {
  int X, Y;
  int A = 0;
  cin >> X >> Y;
  
  if(X==1) A+=300000;
  if(Y==1) A+=300000;
  if(X==2) A+=200000;
  if(Y==2) A+=200000;
  if(X==3) A+=100000;
  if(Y==3) A+=100000;
  if(X==1 && Y==1) A+=400000;
  
  cout << A << endl;
 

  return 0; 
  
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
#define bit(n,k) ((n>>k)&1)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H& b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H& b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H& b) const { return x == b.x && y == b.y; }
	bool operator!=(const H& b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P& b) const { return cost < b.cost; }
	bool operator>(const P& b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E& b) const { return cost < b.cost; }
	bool operator>(const E& b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T& a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T& a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int a[200000];
signed main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	int res = 0;
	for (int i = 1; i < n; i++) {
		if (a[i - 1] >= a[i]) chmax(ans, ++res);
		else res = 0;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
#include<string>
#define ll long long

#define fr(i,a,b) for(ll i=a;i<b;i++)
#define ffr(i,a,b) for(ll i=a;i>=b;i--)
#include<bits/stdc++.h>
#include<vector>
#define vl vector<ll>
//const ll N=1e5+5;




int main(){
    ll x,y,mi,ma;
    cin>>x>>y;
    ma=x*4;mi=x*2;
    if(y>=mi&&y<=ma){
        if(y%2==0)
        cout<<"Yes";
        else
        cout<<"No";
    }
    else
    cout<<"No";
	return 0;
}

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

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;
  
  if(s.at(k - 1) == 'A'){
    s.at(k - 1) = 'a';
  }
  
  else if(s.at(k - 1) == 'B'){
    s.at(k - 1) = 'b';
  }
  
  else{
    s.at(k - 1) = 'c';
  }
  
  cout << s << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int, int>
using namespace std;
const int MAXN = 2e5 + 7;
int k[MAXN], L[MAXN], R[MAXN];
ll solve(vector<pii>&vec) {
    int n = vec.size();
    set<int>s;
    for (int i = 1; i <= n; i++) s.insert(i);
    sort(vec.begin(), vec.end(), greater<pii>());
    ll res = 0;
    for (pii x : vec) {
        auto it = s.upper_bound(x.second);
        if (it == s.begin()) continue;
        it--;
        s.erase(it);
        res += x.first;
    }
    return res;
}
int main() {
    int T; scanf("%d", &T);
    while (T--) {
        int n; scanf("%d", &n);
        long long ans = 0;
        vector<pii>vec1, vec2;
        for (int i = 1; i <= n; i++) {
            scanf("%d%d%d", &k[i], &L[i], &R[i]);
            if (L[i] >= R[i]) vec1.push_back({L[i] - R[i], k[i]}), ans += R[i];
            else vec2.push_back({R[i] - L[i], n - k[i]}), ans += L[i];
        }
        ans += solve(vec1);
        ans += solve(vec2);
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 12012
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

ll cnt[51];

int main(){
	int n,m;
	cin >> n >> m;
	int tmp;
	rep(i,m){
		cin >> tmp;
		cnt[tmp-1]++;
		cin >> tmp;
		cnt[tmp-1]++;
	}
	rep(i,n){
		cout << cnt[i] << endl;
	}
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
int H, W;
	cin >> H >> W;

	map<char, int> K;
	fx(H) {
		fy(W) {
			char c;
			cin >> c;
			K[c]++;
		}
	}
	int div[3] = { 4,2,1 };
	int counts[3] = { 0,0,0 };
	fw(3) {
		fz(26) {
			counts[w] += K['a' + z] / div[w];
			K['a' + z] -= K['a' + z] / div[w] * div[w];
		}
	}

	if (H % 2 == 0 && W % 2 == 0) {
		if (counts[0] == H*W/4 ) {
			ce("Yes")
		}
		else {
			ce("No")
		}
	}
	else if (H % 2 == 1 && W % 2 == 1) {
		if (counts[2] == 1) {
			fx(counts[0]+1) {
				if (counts[1] + 2 * x == (H - 1) / 2 + (W - 1) / 2 && counts[0] - x == (H-1)*(W-1)/4) {
					ce("Yes")
						return 0;
				}
			}
			ce("No")
		}
		else {
			ce("No")
		}
	}
	else {
		if (H%2==0) {
			fx(counts[0]+1) {
				if (counts[0] - x == H / 2 * (W - 1) / 2 && counts[1] + 2 * x == H / 2) {
					ce("Yes")
						return 0;
				}
			}
			ce("No")
		}
		else {
			fx(counts[0]+1) {
				if (counts[0]-x==W/2*(H-1)/2&&counts[1]+2*x==W/2) {
					ce("Yes")
						return 0;
				}
			}
			ce("No")
		}
	}
    return 0;
}



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

//型定義
typedef long long ll;

//定数
const int INF=1e+9;
const int MOD=1e+9+7;

//REPマクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define REP2(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define REPD2(i,a,b) for(ll i=a;i>(ll)(b);i--)

// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

//vectorの扱い
#define ALL(x) (x).begin(),(x).end() //sortなどの引数省略
#define SIZE(x) ((ll)(x).size()) //size
#define MAX(x) *max_element(ALL(x)) //最大値
#define MIN(x) *min_element(ALL(x)) //最小値

int main(){
    ll N;
    cin>>N;
    vector<ll> a(N),b(N);
    REP(i,N){
        cin>>a[i];
    }
    REP(i,N) cin>>b[i];

    vector<ll> a_mod(N),b_mod(N);
    vector<ll> bit(30,0);
    REP(k,29){
        REP(i,N){
            a_mod[i]=a[i]%((ll)pow(2,k+1));
            b_mod[i]=b[i]%((ll)pow(2,k+1));
        }
        sort(ALL(a_mod));
        sort(ALL(b_mod));

        REP(i,N){
            if(a_mod[i]<=pow(2,k)){
                bit[k]+=lower_bound(ALL(b_mod),pow(2,k+1)-a_mod[i])-lower_bound(ALL(b_mod),pow(2,k)-a_mod[i]);
            }else{
                bit[k]+=lower_bound(ALL(b_mod),pow(2,k+1)-a_mod[i])-lower_bound(ALL(b_mod),0);
                bit[k]+=lower_bound(ALL(b_mod),pow(2,k+1))-lower_bound(ALL(b_mod),pow(2,k+1)+pow(2,k)-a_mod[i]);
            }
        }
    }

    ll ans=0;
    REP(k,30){
        if(bit[k]%2==1){
            ans+=pow(2,k);
        }
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 9452
from collections import deque
N, M = map(int, input().split())
edges = [list(map(int, input().split())) for _ in range(M)]
S, T = map(int, input().split())

graph = [[] for _ in range(N + 1)]
for u, v in edges:
    graph[u].append(v)

INF = 10 ** 9 + 7
dp = [[INF] * (N + 1) for _ in range(3)]
dp[0][S] = 0
q = deque()
q.append((S, 0))

while q:
    v, t = q.popleft()
    u = (t + 1) % 3
    d = dp[t][v]
    if t == 2:
        d += 1
    for w in graph[v]:
        if dp[u][w] != INF:
            continue
        dp[u][w] = d
        q.append((w, u))
        
print(dp[0][T] if dp[0][T] < INF else -1)



Measured memory_bytes: 77528
using System;
using System.IO;
using System.Linq;

namespace ABC118A
{
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length > 0)
            {
                Console.SetIn(new StreamReader(args[0]));
            }

            new Program().calc();
        }

        void calc()
        {
            var temp = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int a = temp[0]; // 正整数A
            int b = temp[1]; // 正整数B

            if (b % a == 0)
            {
                Console.WriteLine(a + b);
            }
            else
            {
                Console.WriteLine(b - a);
            }
        }
    }
}


Measured memory_bytes: 13268
/*
 * ID: 0582
 * Problem: type of triangles
 */

#include <stdio.h>

void swap(int *a, int *b)
{
    int t;
    t = *a;
    *a = *b;
    *b = t;
}

int main(void)
{
    int a, b, c;
    int n1, n2, n3;
    
    n1 = n2 = n3 = 0;
    while (1) {
        scanf("%d %d %d", &a, &b, &c);
        // force a <= b <= c
        if (a > b)
            swap(&a, &b);
        if (b > c)
            swap(&b, &c);
        if (a > b)
            swap(&a, &b);

        if (a + b <= c)
            break;

        int a2b2 = a * a + b * b;
        int c2 = c * c;
        if (a2b2 == c2)
            n1++;
        else if (a2b2 > c2)
            n2++;
        else
            n3++;
    }

    printf("%d %d %d %d\n", n1 + n2 + n3, n1, n2, n3);

    return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,counter=0;
  cin>>A>>B;
  for(int i=A;i<B+1;i++){
    if(i/10000==i%10&&(i/1000)%10==(i/10)%10)
      counter++;
  }
cout<<counter<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 string S;
  cin>>S;
  int N=S.size();
  bool ans=true;
  for(char i='a';i<='z';i++){
  int sum=0;
    for(int j=0;j<N;j++){
    if(S.at(j)==i){
      sum++;
    }
      if(sum==2)
        break;
    } if(sum==2){
      ans=false; break;
    }
      
  }if(ans)
    cout<<"yes"<<endl;
  else
    cout<<"no"<<endl;
  
  return 0;
}


Measured memory_bytes: 256
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10**9)
n=int(input())
Edges=[[] for _ in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    Edges[a].append(b)
    Edges[b].append(a)
while sum([len(Edges[i]) for i in range(n)]):
    for i in range(n):
        if len(Edges[i])==1:
            j=Edges[i][0]
            Edges[i].remove(j)
            Edges[j].remove(i)
            for k in Edges[j]:
                Edges[k].remove(j)
                if not Edges[k]:
                    print('First')
                    exit()
            Edges[j]=[]
print('Second')

Measured memory_bytes: 88368
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int main(){
  int a=0,b=0,c=0,d=0;
  int p[3];
  while(~scanf("%d%d%d",p,p+1,p+2)){
    SORT(p,3)
    if(p[0] + p[1] <= p[2]){
      printf("%d %d %d %d\n",a,b,c,d);
      return 0;
     }
     
       a++;
       if(p[0]*p[0] + p[1]*p[1] == p[2] * p[2]) b++;
       if(p[0]*p[0] + p[1]*p[1] > p[2] * p[2]) c++;
       if(p[0]*p[0] + p[1]*p[1] < p[2] * p[2]) d++;
      
  }
}


Measured memory_bytes: 3284
import java.lang.*;
import java.util.*;

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

        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int answer = 0;

        for(int i = 0;i <= 25; i ++){
            for(int j = 0; j <= 14; j++){
                if(4 * i + 7 * j == N){
                    System.out.println("Yes");
                    return;
                }
            }
        }

        System.out.println("No");
    }
}

Measured memory_bytes: 22740
// --------------
// Tejas Pandey  |
// 18 - 08 - 19  |
// ABC #138      |
// --------------

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

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
	{
		//cout << "Case #" << c-t << ": ";
		int a;
		cin >> a;
		cin.ignore();
		string s;
		cin >> s;
		if(a < 3200){
			cout << "red";
		}
		else
		cout << s;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <algorithm> 
 
int main() {
  int A;
  int B;
 
  cin >> A>>B;
  
  if(A>=13) cout << B <<endl;
  else if( A >= 6) cout << B/2 <<endl;
  else cout << 0 <<endl;

}

Measured memory_bytes: 256
A,B = list(map(int,input().split()))


x = 10*B

if A%2 == 0:
	x_low = 25*(A//2)
	x_high = int(12.5*(A+1))
else:
	x_low = int(12.5*A)+1
	x_high = int(12.5*(A+1))-1


while x < (10*B+10):
	if x_low <= x and x <= x_high:
		print(x)
		exit()
	x += 1
print(-1)



Measured memory_bytes: 38384
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

#N, K, C = map(int, readline().split())  int
#S = read().rstrip().decode()  string
# N =int(read())
#print(C,A,B)

x=read().rstrip().decode()

if '7' in x:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 9084
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
long long int a = 0, b = 0, c = 0, ans = 0, x = 0, y = 0, z = 0, n = 0, m = 0, maxy = 0, mini = 9999, counter = 0, endp = 0, checker = 0;

std::vector <char> vec{}, vecsec{}, vecth{};
long long int iremono[100001], sec[100001];
long long int iremono2[100001], check[100001];
std::vector<long long int>kinds{}, kaku{};
char maze[1000][1000];
int sx, sy;
int gx, gy;

bool relation[1000][1000];
int twod[1001][1001];
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
bool okada = false, okada2 = false;
std::string output, output2, input, input2;
char rev[100001];


int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {

		c = i % j;
		i = j;
		if (c != 0) {

			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int kaizyo(int k) {
	int sum = 1;
	for (int i = 1; i <= k; ++i)
	{
		sum *= i;
	}
	return sum;
}

int N, M;//はんい
int bfs() {
	queue<pair<int, int>> que;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= M; j++) {
			twod[i][j] = INF;
		}
	}
	que.push(pair<int, int>(sx, sy));
	twod[sx][sy] = 1;
	while (que.size()) {
		pair<int, int> p = que.front();
		que.pop();
		if (p.first == gy && p.second == gx) {
			break;
		}
		for (int i = 0; i < 4; i++) {
			int nx = p.first + dx[i], ny = p.second + dy[i];
			if (1 <= nx && nx <= N && 1 <= ny && ny <= M && maze[nx][ny] != '#'&&twod[nx][ny] == INF) {
				que.push(pair<int, int>(nx, ny));
				twod[nx][ny] = twod[p.first][p.second] + 1;
			}
		}
	}
	return twod[gy][gx];
}
vector <int> g[100100];
int main()
{
	cin >> a;
	rep(i, a) {
		cin >> iremono[i];
	}
		maxy = iremono[0];
	rep(i, a) {
		if (iremono[i] >= maxy) {
			counter++;
			maxy = iremono[i];
		}
	}
	cout << counter << endl;



}

Measured memory_bytes: 6400
import collections
n, k = map(int,input().split())
a = list(map(int,input().split()))

num = collections.defaultdict(int)

for elem in a:
    num[elem] += 1

count = 0
if len(num) <= k:
    print(count)
else:
    # sort使う発想なかった(出現頻度の昇順にソート)
    sorted_num = sorted(num.items(), key=lambda x:x[1])
    # 減らさなければいけない種類数だけ繰り返す
    for i in range(len(num) - k):
        # 出現頻度の少ない数から順に，その頻度を加えていく
	    count += sorted_num[i][1]

    print(count)



Measured memory_bytes: 39320
#include<bits/stdc++.h>
using namespace std;
int n;
char a[10001];
bool c=false,f=false;
int main(){
	scanf("%s",a);
	for(int i=0;i<strlen(a);i++){
		if(c==false&&a[i]=='C')
			c=true;
		if(c==true&&a[i]=='F'){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <cassert>

template <class Monoid, template <class> class Container> class segment_tree {
public:
	using value_structure = Monoid;
	using value_type = typename value_structure::value_type;
	using container_type = Container<value_type>;
	using const_reference = typename container_type::const_reference;
	using size_type = typename container_type::size_type;

private:
	size_type sequence_size, base_size;
	container_type c;
	static size_type getsize(const size_type size) {
		size_type ret = 1;
		while (ret < size)
			ret <<= 1;
		return ret;
	}
	void recalc(const size_type index) {
		c[index] = value_structure::operation(c[index << 1], c[index << 1 | 1]);
	}

public:
	segment_tree() : base_size(0), c() {}
	explicit segment_tree(const size_type size)
		: sequence_size(size), base_size(getsize(size)),
		c(base_size + size + (size & 1), value_structure::identity()) {}

	bool empty() const { return !sequence_size; }
	size_type size() const { return sequence_size; }

	const_reference operator[](const size_type index) const {
		assert(index < size());
		return c[index + base_size];
	}
	value_type fold(size_type first, size_type last) const {
		assert(first <= last);
		assert(first <= size());
		assert(last <= size());
		value_type ret_l = value_structure::identity(),
			ret_r = value_structure::identity();
		for (first += base_size, last += base_size; first < last;
			first >>= 1, last >>= 1) {
			if (first & 1)
				ret_l = value_structure::operation(ret_l, c[first++]);
			if (last & 1)
				ret_r = value_structure::operation(c[last - 1], ret_r);
		}
		return value_structure::operation(ret_l, ret_r);
	}
	template <class F> size_type search(const F &f) const {
		if (f(value_structure::identity()))
			return 0;
		if (!f(c[1]))
			return size() + 1;
		value_type acc = value_structure::identity();
		size_type i = 1;
		while (i < base_size)
			if (!f(value_structure::operation(acc, c[i <<= 1])))
				acc = value_structure::operation(acc, c[i++]);
		return i - base_size + 1;
	}

	template <class F> void update(size_type index, const F &f) {
		assert(index < size());
		index += base_size;
		c[index] = f(c[index]);
		while (index >>= 1)
			recalc(index);
	}
};

template <class T> class plus_monoid {
public:
	using value_type = T;
	static value_type operation(const value_type &x, const value_type &y) {
		return x + y;
	}
	static value_type identity() { return value_type(0); }
	static value_type reverse(const value_type &x) { return x; }
};

#include <iostream>
#include <vector>

template<class T> using vec_alias = ::std::vector<T>;

int main() {
	int n, q;
	::std::cin >> n >> q;

	segment_tree<plus_monoid<int>, vec_alias> seg(n);

	while (q--) {
		int c, x, y;
		::std::cin >> c >> x >> y;

		if (c)
			::std::cout << seg.fold(x - 1, y) << ::std::endl;
		else
			seg.update(x - 1, [y](int a) {return a + y;});
	}

	return 0;
}



Measured memory_bytes: 3588
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <set>
using namespace std;

#define LET(name, value) __typeof(value) name = value
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define FOREQ(i, a, b) for (int i = (a); i <= (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOREACH(i, c) for (LET(i, (c).begin()); i != (c).end(); ++i)

char field[30][30];

int main() {
  int h, w;
  while (scanf("%d%d", &h, &w), h|w) {
    REP(y, h) REP(x, w) { scanf(" %c", &field[y][x]); }

    static const int dy[] = {-1, -1, -1, 0, 0, 1, 1, 1};
    static const int dx[] = {-1, 0, 1, -1, 1, -1, 0, 1};
    set<string> dict;
    string ans, str;
    REP(sy, h) REP(sx, w) REP(dir, 8) {
      int y = sy, x = sx;
      str.clear();
      do {
        str += field[y][x];
        LET(it, dict.lower_bound(str));
        if (it != dict.end() && *it == str) {
          if (str.size() > ans.size() || (str.size() == ans.size() && str < ans)) {
            ans = str;
          }
        } else {
          dict.insert(it, str);
        }
        y = (y + dy[dir] + h) % h;
        x = (x + dx[dir] + w) % w;
      } while (y != sy || x != sx);
    }
    printf("%s\n", ans.size() > 1 ? ans.c_str() : "0");
  }
}

Measured memory_bytes: 26000
import sys
input = sys.stdin.readline

def unite(node_a, node_b):
    root_a, depth_a = node_a.root()
    root_b, depth_b = node_b.root()
    if root_a == root_b:# すでに連結成分
        return
    elif depth_a >= depth_b:# aの方が深い
        root_b.is_root = False
        root_b.parent = root_a
        root_a.white += root_b.white
        root_a.black += root_b.black
    else:# bの方が深い
        root_a.is_root = False
        root_a.parent = root_b
        root_b.white += root_a.white
        root_b.black += root_a.black

class Node:
    def __init__(self, color):# color: 0:white, 1:black
        self.parent = None
        self.is_root = True
        self.white = 1 if color == 0 else 0
        self.black = 1 if color == 1 else 0
    
    def root(self):
        node = self
        depth = 0
        while not node.is_root:
            node = node.parent
            depth += 1
        return node, depth

def main():
    H, W = map(int, input().split())
    s = [input().strip() for i in range(H)]
    
    nodes = [[Node(0 if s[j][i] == "." else 1) for i in range(W)] for j in range(H)]

    for y in range(H):
        for x in range(W):
            now = s[y][x]
            for nx, ny in [(x, y-1), (x+1, y), (x, y+1), (x-1, y)]:
                if 0 <= nx and nx < W and 0 <= ny and ny < H:
                    if s[ny][nx] != now:
                        unite(nodes[y][x], nodes[ny][nx])
    
    ans = 0
    # count_roots = 0
    for y in range(H):
        for x in range(W):
            if nodes[y][x].is_root:
                # count_roots += 1
                node = nodes[y][x]
                ans += node.white * node.black
    print(ans)
    # print(count_roots)


if __name__ == "__main__":
    main()

Measured memory_bytes: 46196