akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n, a, b, i, p, h=0;
	long long t=0;
	cin >> n >> a >> b;
	for (i=1; i<=n; i++)
	{
		p=i;
		do
		{
			h+=p%10;
			p/=10;
		}while (p!=0);
		if (h>=a&&h<=b) t+=i;
		h=0;
	}
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
AB = []
for _ in range(N):
    a, b = map(int, input().split())
    AB.append((a, b))

AB.sort(key=lambda x: (x[1], x[0]))

t = 0
for a, b in AB:
    if b < t + a:
        print('No')
        break
    t += a
else:
    print('Yes')

Measured memory_bytes: 74864
import collections

N=int(input())
S=[input() for i in range(N)]

lis=collections.Counter(S)

max_lis_v=sorted(list(lis.values()))[-1]
lis_i=sorted(list(lis.items()))

for i in lis_i:
    if i[1]==max_lis_v:
        print(i[0])

Measured memory_bytes: 47744
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n;
vector <int> a;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    a.resize(n);
    for(int i = 0 ; i < n ; i++){
        cin >> a[i];
        a[i] -= i + 1;
    }
    sort(a.begin(), a.end());
    ll ans = 0;
    for(auto &i : a) ans += abs(i - a[n / 2]);
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int live[4][3][10];	//??¨?±?????????±.
	int n;				//?????±?????°.
	int b, f, r, v;
	int i, j, k, l;
	int hum;			//??\?±??????°.

	for (i = 0; i < 4; i++)
		for (j = 0; j < 3; j++)
			for (k = 0; k < 10; k++)
				live[i][j][k] = 0;

	scanf("%d", &n);	//?????±?????°???????????????.

	//??\???.
	for (l = 0; l < n; l++)
	{
		scanf("%d %d %d %d", &b, &f, &r, &v);
		live[b-1][f-1][r-1] += v;
	}

	//??????.
	for(i = 0; i < 4; i++)
		for(j = 0; j < 3; j++)
			for (k = 0; k < 10; k++)
			{
				printf(" %d", live[i][j][k]);
				if (k == 9)
					printf("\n");

				if (k == 9 && j == 2 && i < 3)
				{
					for (l = 0; l < 20; l++)
						printf("#");
					printf("\n");
				}
			}

	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <string.h>
#include <string>
using namespace std;

typedef vector<string> Dice;

void rotate_front(Dice& dice)
{
	string t = dice[0];
	dice[0] = dice[4];
	dice[4] = dice[5];
	dice[5] = dice[1];
	dice[1] = t;
}

void rotate_right(Dice& dice)
{
	string t = dice[0];
	dice[0] = dice[3];
	dice[3] = dice[5];
	dice[5] = dice[2];
	dice[2] = t;
}

void rotate_clock(Dice& dice)
{
	string t = dice[1];
	dice[1] = dice[2];
	dice[2] = dice[4];
	dice[4] = dice[3];
	dice[3] = t;
}

void rotate(Dice& dice, string top)
{
	for(int i=0; i<4; i++)
	{
		if(dice[0] == top) return;
		rotate_front(dice);
	}

	for(int i=0; i<4; i++)
	{
		if(dice[0] == top) return;
		rotate_right(dice);
	}
}

bool match(Dice d1, Dice d2)
{
	if(d1[0] != d2[0]) return false;
	if(d1[5] != d2[5]) return false;

	for(int i=0; i<4; i++)
	{
		bool is_match = true;
		for(int j=1; j<5; j++)
		{
			if(d1[j] != d2[j])
			{
				is_match = false;
				break;
			} 
		}
		if(is_match) return true;
		
		rotate_clock(d2);
	}

	return false;
}

int table[6];

int main()
{
	int T;
	string color;
	vector<Dice> dices;

	while(cin >> T, T)
	{
		dices = vector<Dice>(T);
		for(int t=0; t<T; t++)
		{
			for(int i=0; i<6; i++)
			{
				cin >> color;
				dices[t].push_back(color);
			}
			if(t != 0) rotate(dices[t], dices[0][0]);
		}

		int c = 0;
		for(int t=0; t<T; t++)
		{
			bool is_match = false;
			for(int i=0; i<t; i++)
			{
				if(match(dices[t], dices[i]))
				{
					is_match = true;
					break;
				}
			}

			if(!is_match) c++;
		}

		printf("%d\n", T-c);
	}
}

Measured memory_bytes: 0
import * as fs from "fs";

const input = (fs.readFileSync("/dev/stdin", "utf8") as string).split("\n");
const x = BigInt(input[0]);

let current = 100n;
let result = 0;
while (current < x) {
  current *= 101n;
  current /= 100n;
  result++;
}

console.log(result);

Measured memory_bytes: 29760
N,X = $stdin.readline.split.map(&:to_i)

def num_patties(l)
  l == 0 ? 1 : num_patties(l-1)*2+1
end

def num_layers(l)
  l == 0 ? 1 : num_layers(l-1)*2+3
end

def num_patties_upto(lev,x)
  if lev == 0
    x > 0 ? 1 : 0
  else
    nl = num_layers(lev)
    nh = num_layers(lev-1)
    if x <= 1
      0
    elsif x <= (1+nh)
      num_patties_upto(lev-1,x-1)
    elsif x == (2+nh)
      num_patties(lev-1)+1
    elsif x <= (2+nh+nh)
      num_patties(lev-1)+1+num_patties_upto(lev-1,x-1-nh-1)
    else
      num_patties(lev)
    end
  end
end

puts num_patties_upto(N,X)
#pp num_patties(N), num_layers(N), num_patties_upto(N,X)


Measured memory_bytes: 1788
fun main(args : Array<String>) {
    val (numberA,numberB,numberC) = readLine()!!.split(" ").map { it.toInt() }
    val value1 = numberA * numberB * numberC
    if (value1 == numberA * numberA * numberC
        && value1 == numberB * numberB * numberB
        && value1 == numberC * numberC * numberC){
        println("No")
    }else if (numberA == numberB || numberA == numberC || numberB == numberC){
        println("Yes")
    }else {
        println("No")
    }
}

Measured memory_bytes: 37928
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; 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());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
vvll dp(110, vll(10010, 0));
int main(){
    ll n, W;
    cin >> n >> W;
    vll v(n), w(n);
    REP(i, n) cin >> v[i] >> w[i];
    REP(i, n){
        REP(j, W + 1){
            if(j - w[i] >= 0) dp[i + 1][j] = max(dp[i][j - w[i]] + v[i], dp[i][j]);
            else dp[i + 1][j] = dp[i][j];
        }
    }
    cout << dp[n][W] << endl;
    return 0;
}


Measured memory_bytes: 11444
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main(){
    int N,p;
    int ansb = false;
    int a[9] = {0};
    rep(i,9){
        cin >> a[i];
    }
    cin >> N ;
    rep(i,N){
        cin >> p;
        rep(i,9){
            if(p==a[i]){
                a[i] = -1;
            }
        }
    }
    rep(i,3){
        if((a[i]==-1&&a[i+3]==-1)&&a[i+6]==-1){
            ansb =true;
        }
        if((a[i*3]==-1&&a[i*3+1]==-1)&&a[i*3+2]==-1){
            ansb =true;
        }
    }
    if((a[0]==-1&&a[4]==-1)&&a[8]==-1){
            ansb =true;
    }if((a[2]==-1&&a[4]==-1)&&a[6]==-1){
            ansb =true;
    }
    if(ansb){
        cout << "Yes"<< endl;
    }else{
        cout << "No"<<endl;
    }
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0;i<n;i++)
#define rep_bit(n) for (int bit = 0; bit < (1<<n); ++bit)
#define all(x) (x).begin(),(x).end()
#define ll long long
#define ld long double
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define SP <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
using namespace std;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vi> Graph;

//条件式 ? 真の場合の文 : 偽の場合の文
//abs(x) = (x の絶対値)
//string S  S,at(i),S += T,S += c,S.size(),S.substr(l)l文字目から最後まで,
///S.substr(l, r)l文字目からl+r-1文字目 n文字目から0個で空列を返せる
//*min_element(all(x)) *max_element(all(x))
//vi x; x.back(),x.front(),x.push_back(),x.pop_back()
//swap(a, b)
//gcd(a, b)最大公約数
//sort(all(x)),reverse(all(x)),sort(x.begin()+l,a.begin()+r)lからrまで
//stack<int> a; a.push(x),a.pop(),a.top(),a.empty()bool
//queue<int> b; b.push(x),b.pop(),b.front(),b.empty()bool,b.size() 要素が小さい順
//priority_queue<int, vector<int>, greater<int>> c,c.top()
//map<int, int> M1; 変数[key] = value; 変数.erase(key); 変数.at(key); 変数.count(key)所属判定　変数.size()
//find(all(x), key)boolソート済みのベクトル
//*lower_bound(all(x),k)以上の最小の要素,*uppper_bound(all(x),k)より大きい最小の要素
//char('0'+cnt) 数字cntからcharへの変換
//int(char-'0') charからintへの変換


int main(){

    ll n,k;
    cin >> n >> k;
    vl a(n);
    rep(i,n) {
        ll p;
        cin >> p;
        p--;
        a.at(i) = p;
    }
    vi seen(n,0);
    ll now = 0;
    ll cnt = 0;
    ll ans;
    if(k<=n){
        rep(i,k) now = a.at(now);
        ans = now;
    }
    else{
        rep(i,n){
        if(seen.at(now)) break;
        else seen.at(now) = i;
        now = a.at(now);
        cnt += 1;
    }
    ll roop = cnt - seen.at(now);
    ll new_k = k - seen.at(now) ;
    ll kaisuu = new_k/roop;
    ll rest = new_k-roop*kaisuu;
    ll new_now = now;
    rep(i,rest){
        new_now = a.at(new_now);
    }
    ans = new_now;
    }
    cout << ans + 1 << endl;
}


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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i <= int(r); ++i)
#define ford(i, n) for (int i = int(n)-1; i >= 0; --i)
#define pb push_back
#define eb emplace_back
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define endl '\n'
#define de(x) cout<<#x<<" = "<<(x)<<endl
#define de2(x,y) cout<<#x<<" = "<<(x) <<' '<< #y<<" = "<<y<<endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::high_resolution_clock::now().time_since_epoch().count());

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
	int n,k;
	cin>>n>>k;
	vector<int> a(n),dp(n,INF);
	for(auto& it:a) cin>>it;
	dp[0]=0;
	forn(i,n){
		for(int j=i-1;j>=i-k&&j>=0;j--){
			dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
		}
	}
	cout<<dp[n-1];
    return 0;
}



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

#define f first
#define s second
#define pb push_back
#define all(c) c.begin(),c.end()

#define gi(x) scanf("%d", &x)
#define pi(x) printf("%d", x)
#define gl(x) scanf("%lld", &x)
#define pl(x) printf("%lld", x)
#define sp printf(" ")
#define nl printf("\n")

typedef long long int lld;
typedef long double ldb;

int t[110], v[110];
int setmax[200020], speed[200010];

int l[200020], r[200020];


main(){
    int n, x = 0;
    cin >> n;
    for(int i = 0; i <= 200000; ++i) setmax[i] = 1e5;
    setmax[0] = 1;
    for(int i = 1; i <= n; ++i){
        cin >> t[i];
    }
    for(int i = 1; i <= n; ++i){
        cin >> v[i];
    }
    for(int i = 1; i <= n; ++i){
        for(int j = x+1; j <= x + t[i]; ++j){
            setmax[j] = v[i];
        }
        x += t[i];
    }
    // setmax[x] = 0;
    int lefts = 1;
    for(int i = 1; i <= x; ++i){
        if(setmax[i]){
            lefts = min(lefts, setmax[i]);
        }
        l[i] = lefts;
        lefts++;
    }
    int rights = 0;
    for(int i = x; i >= 0; --i){
        if(setmax[i+1]){
            rights = min(rights, setmax[i+1]);
        }
        r[i] = rights;
        rights++;
    }
    // int ans = 0;
    for(int i = 0; i <= x; ++i){
        // cout << l[i] << ' ' << r[i] << ' ' << i << endl;
        speed[i] = min(l[i], r[i]);
    }
    ldb ans = 0, pre;
    speed[x] = 0;
    for(int i = 1; i <= x; ++i){
        // cout << i << ' ' << speed[i] << '\n';
        pre = ans;
        if(speed[i] != speed[i-1]){
            ans += 0.5 + 1.0*min(speed[i], speed[i-1]);
        }
        else{
            if(speed[i] == setmax[i]){
                ans += speed[i];
            }
            else{
                ans += 0.5*(0.5) + 1.0*min(speed[i], speed[i-1]);
            }
        }
    }
    cout << setprecision(10) << fixed << ans << endl;
}


Measured memory_bytes: 1280
# include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10, INF = 1e9 + 100, P = 2019;
int dp[P], new_dp[P], ans;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	string s;
	cin >> s;
	for(int i = 0; i < s.size(); i++){
		new_dp[s[i] - '0'] = 1;
		for(int mod = 0; mod < P; mod++){
			int nxt = (mod * 10 + s[i] - '0') % P;
			new_dp[nxt] += dp[mod];
		}
		for(int mod = 0; mod < P; mod++){
			dp[mod] = new_dp[mod];
			new_dp[mod] = 0;
		}
		ans += dp[0];
	}
	cout << ans << '\n';
}


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

int main()
{
	long long n;
	cin >> n;
  	long long ans = n*(n-1)/2;
	cout << ans << endl;
	return 0;
}

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


int main(){
  int a, b;
  cin >> a >> b;
  int peace = a*3 +b;
  cout << peace / 2 << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1e9+7;

ll power(ll b, ll p, ll m) {
	if (p == 0)
		return 1;

	if (p == 1)
		return b;

	if (p % 2 == 0) {
		ll a = power(b, p/2, m);
		return (a * a) % m;
	}

	return (b * power(b, p-1, m)) % MOD;
}

ll mul(ll a, ll b) {
	return (a * b) % MOD;
}

ll factorial(ll n) {
	ll f = 1;

	for (int i = 1; i <= n; i++) {
		f = mul(f, i);
	}

	return f;
}

ll choose(ll n, ll r) {
	ll c = factorial(n);

	c = (c * power(factorial(r), MOD-2, MOD)) % MOD;
	c = (c * power(factorial(n-r), MOD-2, MOD)) % MOD;

	return c;
}

int main() {
	ll x, y;

	cin >> x >> y;

	if ((x+y) % 3) {
		cout << 0 << "\n";
		return 0;
	}

	ll n = (2*y - x) / 3;
	ll m = (2*x - y) / 3;

	if (n < 0 || m < 0) {
		cout << 0 << "\n";
		return 0;
	}

	cout << choose(n+m, m) << "\n";

	return 0;
}

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

int main() {
	ll n,m;
	cin>>n>>m;
	vector<ll> s(n);
	vector<ll> e(n);
	vector<vector<ll>> p(n,vector<ll>(0));
	rep(i,m){
		ll t,tt;
		cin>>t;
		s[t-1]++;
		cin>>tt;
		p[t-1].push_back(tt-1);
		e[tt-1]--;
	}
	ll ans=0;
	ll tmp=0;
	vector<ll> end(0);
	rep(i,n){
		if(e[i]<0){
			ans++;
			tmp=0;
			rep(j,end.size()){
				e[end[j]]++;
			}
			end.resize(0);
		}
		tmp+=s[i];
		if(s[i]>0){
			for(auto it:p[i]){
				end.push_back(it);
			}
		}
	}/*
	rep(i,n){
		cout<<s[i]<<" "<<e[i]<<endl;
	}
	rep(i,n){
		for(auto it:p[i]){
			cout<<it<<" ";
		}cout<<endl;
	}*/
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 7932
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();

		int temp = 0;

		if(a > b) {
			temp = a;
			a = b;
			b = temp;
		}

		if(a > c) {
			temp = a;
			a = c;
			c = temp;
		}

		if(b > c) {
			temp = c;
			c = b;
			b = temp;
		}

		System.out.println(a + " " + b + " " + c );
	}
}

Measured memory_bytes: 26204
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1e15;
const int inf=1e9;
const ll MOD=1000000007;

int main(){
    int N;cin>>N;
    int a[N];
    rep(i,N)cin>>a[i];
    sort(a,a+N);
    vector<pair<int,int>> info;
    int p=a[0],count=0;
    rep(i,N){
        if(a[i]==p)count++;
        else{
            info.push_back(make_pair(p,count));
            p=a[i];
            count=1;
        }
        if(i==N-1)info.push_back(make_pair(p,count));
    }
    int ans=0;
    rep(i,info.size()){
        if(info[i].first<=info[i].second)ans+=info[i].second-info[i].first;
        else ans+=info[i].second;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1784
#include "bits/stdc++.h"
using namespace std;
const int N = 2e5 + 5;
const int SN = 1 << 19;
int n;
int arr[N];
int ans[N];
int siz;
pair < int , int > segtree[SN][2];
void build(int l , int r , int node){
	if(l == r){
		if(l & 1){
			segtree[node][0] = make_pair(N , N);
			segtree[node][1] = make_pair(arr[l] , r);
		}
		else{
			segtree[node][0] = make_pair(arr[l] , r);
			segtree[node][1] = make_pair(N , N);
		}
	}
	else{
		int mid = l + r >> 1;
		build(l , mid , node + node);
		build(mid + 1 , r , node + node + 1);
		segtree[node][0] = min(segtree[node + node][0] , segtree[node + node + 1][0]);
		segtree[node][1] = min(segtree[node + node][1] , segtree[node + node + 1][1]);
	}
}
pair < pair < int , int > , pair < int , int > > query(int l , int r , int node , int ql , int qr){
	if(l > qr || r < ql || ql > qr){
		return make_pair(make_pair(N , N) , make_pair(N , N));
	}
	if(l >= ql && r <= qr){
		return make_pair(segtree[node][0] , segtree[node][1]);
	}
	int mid = l + r >> 1;
	auto lft = query(l , mid , node + node , ql , qr);
	auto rgt = query(mid + 1 , r , node + node + 1 , ql , qr);
	lft.first = min(lft.first , rgt.first);
	lft.second = min(lft.second , rgt.second);
	return lft;
}
pair < int , int > get(int l , int r){
	auto it = query(1 , n , 1 , l , r);
	if(l & 1){
		return make_pair(it.second.second , query(1 , n , 1 , it.second.second + 1 , r).first.second);
	}
	else{
		return make_pair(it.first.second , query(1 , n , 1 , it.first.second + 1 , r).second.second);
	}
}
priority_queue < pair < int , pair < int , int > > > pq;
void solve(){
	while(!pq.empty()){
		pq.pop();
	}
	pq.push({-arr[get(1 , n).first] , {1 , n}});
	while(!pq.empty()){
		auto lol = pq.top();
		pq.pop();
		int l = lol.second.first;
		int r = lol.second.second;
		auto it = get(l , r);
		ans[++siz] = arr[it.first];
		ans[++siz] = arr[it.second];
		int mid1 = it.first;
		int mid2 = it.second;
		if(l < mid1){
			pq.push({-arr[get(l , mid1 - 1).first] , {l , mid1 - 1}});
		}
		if(mid1 + 1 < mid2){
			pq.push({-arr[get(mid1 + 1 , mid2 - 1).first] , {mid1 + 1 , mid2 - 1}});
		}
		if(mid2 + 1 <= r){
			pq.push({-arr[get(mid2 + 1 , r).first] , {mid2 + 1 , r}});
		}
	}
}
int main(){
	scanf("%d" , &n);
	for(int i = 1 ; i <= n ; ++i){
		scanf("%d" , arr + i);
	}
	build(1 , n , 1);
	siz = 0;
	solve();
	for(int i = 1 ; i <= n ; ++i){
		printf("%d%c" , ans[i] , " \n"[i == n]);
	}
}


Measured memory_bytes: 11896
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define takearr(a,n) int a[n];for(int i=0;i<n;i++)cin>>a[i]
#define rep(i,n) for(int i=0;i<n;i++)
#define f(i,a,b) for(ll i=a;i<=b;i++)
#define mods (1000*1000*1000)+7

int main()
{

  int n,m;cin>>n>>m;
  vector<int>vec[n+1];int ind[n+1];memset(ind,0,sizeof(ind));
  rep(i,m)
    {
      int x,y;cin>>x>>y;
      vec[x].push_back(y);ind[y]++;
    }
  map<int,int>vis;map<int,int>dis;queue<int>q;
  f(i,1,n)if(ind[i]==0){q.push(i);vis[i]=1;}
  int ans=0;
  while(!q.empty())
    {

      int fro=q.front();
      q.pop();
      for(int i=0;i<vec[fro].size();i++)
        {
          dis[vec[fro][i]]=max(dis[fro]+1,dis[vec[fro][i]]);
          ans=max(ans,dis[vec[fro][i]]);
          ind[vec[fro][i]]--;
          if(ind[vec[fro][i]]==0){q.push(vec[fro][i]);vis[vec[fro][i]]=1;}
        }

    }
  cout<<ans<<endl;

}


Measured memory_bytes: 15488
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;

int a[1000], l;

int main() {
	int i, j;
	while( cin >> a[0] >> l ) {
		if (!l) break;
		for( i = 0; ; i++ ) {
			for( j = 0; j < i; j++ ) {
				if ( a[i] == a[j] ) {
					cout << j << " " << a[i] << " " << i - j << endl;
					break;
				}
			}
			if ( j < i )
				break;
				
			//Ai+1を作る。(変な計算せずに愚直にやるのが吉)
			int d[6], p = 1;
			for( j = 0; j < l; j++ ) {
				d[j] = (a[i]/p) % 10;
				p *= 10;
			}
			sort(d, d+l);
			
			int maxi = 0, mini = 0;
			p = 1;
			for( j = 0; j < l; j++ ) {
				//cout << d[j] << " ";
				maxi += d[j] * p;
				p *= 10;
			}
			//cout << endl;
			
			sort(d, d+l, greater<int>());
			p = 1;
			for( j = 0; j < l; j++ ) {
				//cout << d[j] << " ";
				mini += d[j] * p;
				p *= 10;
			}
			//cout << endl;
			//cout << endl;
			
			a[i+1] = maxi - mini;
		}
	}
	return 0;
}

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

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    vector<int> a(n);
    for (int &i : a) cin >> i;
    int ans = n + 1;
    int cur = 1;
    for (int x: a)
        if (x == cur){
            ans = cur;
            cur++;
        }
    cout << n - ans;    
    return 0;
}

Measured memory_bytes: 1024
//#define local
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define rep(i,n); for(long long i = 0;i < (n);i++)
using ll = long long;
using P = pair<long long,long long>;
template <class T> using vec = vector<T>;
#ifdef local
#include "debug.cpp"
#else
#define debug(...)
#endif

struct UnionFind {
    vector<ll> d;
    UnionFind(ll n=0): d(n,-1) {}
    ll root(ll x) {
        if (d[x] < 0) return x;
        return d[x] = root(d[x]);
    }
    bool unite(ll x, ll y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x,y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(ll x, ll y) { return root(x) == root(y);}
    ll size(ll x) { return -d[root(x)];}
};

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout << fixed << setprecision(10);
    ll n,m,k; cin >> n >> m >> k;
    vec<ll> f(n,0);
    UnionFind uf(n);
    rep(i,m){
        ll a,b; cin >> a >> b; --a; --b;
        uf.unite(a,b);
        f[a]++; f[b]++;
    }
    vec<vec<ll>> blo(n);
    rep(i,k){
        ll c,d; cin >> c >> d; --c; --d;
        blo[c].emplace_back(d);
        blo[d].emplace_back(c);
    }
    rep(i,n){
        ll b = 0;
        rep(j,blo[i].size()){
            if(uf.same(i,blo[i][j]))b++;
        }
        cout << uf.size(i) - f[i] - b - 1 << " ";
    }
    cout << endl;
}

Measured memory_bytes: 10504
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 2019
int main(){
  ll l,r;
  cin >> l >> r;
  ll ans = 2020;
  for(ll i=l; i<=r; i++){
    for(ll j=i+1; j<=r; j++){
      ans = min(ans,(i*j) % MOD);
      if(ans == 0) break;
    }
    if(ans == 0) break;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>

#include<climits>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cstring>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>
#include <cstdio>
using namespace std;

#define pb          push_back
#define mp          make_pair
#define ll          long long int
#define hmap        unordered_map
#define pii         pair<int,int>
#define pdd         pair<double, double>
#define M           1000000007
#define MOD         998244353
#define fast        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test        ll t; cin>>t; while(t--)
#define inp(a,n)    int a[n]; for(int i=0;i<n;i++)  cin>>a[i];
#define inpl(a,n)   ll a[n];  for(ll i=0;i<n;i++)   cin>>a[i];
#define out(a,n)    for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define outl(a,n)   for(ll i=0;i<n;i++)  cout<<a[i]<<" "; cout<<endl;
#define outv(v)     for(int i=0;i<v.size();i++) cout<<v[i]<<" ";  cout<<endl;
#define all(s)      (s).begin(),(s).end()

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define FOR(i,j,n) for(int i=j; i < n; i++)
#define souatari(i,j,n) rep1(i,n-1)rep(j,i)
#define souatari1(i,j,n) for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if
#define inpv(a,n)   vector<int>a(n);  for(ll i=0;i<n;i++)   cin>>a[i];



// ll  efficient_expo(ll a , ll  b , ll mod) {
// 	ll res = 1 ;
// 	// a = a % mod;
// 	// b = b % mod ;
// 	while (b > 0) {
// 		if (b & 1) res = (res * a) % mod ;
// 		a = (a * a) % mod ;
// 		b = b >> 1 ;
// 	}
// 	return res ;
// }

// int modd(int a, int b, int c)
// {
// 	if (b == 0) return 1;

// 	if (b % 2 == 0)
// 	{
// 		int x = modd(a, b / 2, c);
// 		return (x * x) % c;
// 	}
// 	else return (a % c * modd(a, b - 1, c)) % c;
// }

// ll recursive_mod(ll a , ll b , ll mod) {
// 	if (b == 0) return 1 ;
// 	if (b & 1) return (a % mod * recursive_mod(a, b - 1, mod)) % mod;
// 	ll x = (recursive_mod(a, b / 2, mod)) ;
// 	return ((x ) * (x )) % mod ;
// }

// ll leading_digit(ll a , ll b ,ll k) {
// 	long long double  pro = b*log10(a) ; 
// 	long long double deci = pro - floor(pro) ;
// 	int po = pow(10,k-1);
// 	return (ll)(((long long double)pow(10,deci))*po) ;
// }

// ll trailing_digits(ll a, ll b, ll k){
// 	ll res = 1 ;
// 	while()
// }

int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	fast ;
//     test{
        
//     }
    ll  a; long double b ;
    cin >> a >> b ;
    long double anss = a*b ;
    ll pp = anss ;
    //double aa = a*b; 
    cout << pp ;
    
    

}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
#define ipa pair<lld,lld>
#define lld long long int
#define x first
#define y second
#define ld long double
#define pb push_back
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI (atan(1)*4)
#define mp make_pair
#define mlog 21
#define mod 1000000000
using namespace std;
const int maxn=1e6+2;
main()
{
	fastread;
	lld i,j,n,m,arr[maxn];
	cin>>n;
	lld dp[n+2];
	dp[0]=0;
	for(i=0;i<n;++i)
	{
		cin>>arr[i];
	}
	dp[1]=fabs(arr[1]-arr[0]);
	for(i=2;i<n;++i)
		dp[i]=min(dp[i-1]+fabs(arr[i]-arr[i-1]),dp[i-2]+fabs(arr[i]-arr[i-2]));

	cout<<dp[n-1];
}

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

//ABC109C
int compare_int(const void *a, const void *b) { //sort
  return *(int*) a-*(int*) b;
}
int main(void) {
  int n, k, i, cou=0, tmp;
  scanf(" %d", &n);
  int x[ ++n];
  for(i=0; i<n; i++)
    scanf(" %d", &x[i]);


  qsort(x, n--, sizeof(int), compare_int); //sort

  for(i=0; i<n; i++)
    x[i]=x[i+1]-x[i];

 // printf("n=%d\n", n);
  for(i=0; i<n-1; i++){
    //printf("%d %d\n", x[i], x[i+1]);
    if(x[i]<x[i+1]) tmp=x[i], x[i]=x[i+1], x[i+1]=tmp; //ユークリッドの互除法//gcd(a,b)=>b
    while(x[i]%x[i+1]!=0){
      x[i]=x[i]%x[i+1];
      if(x[i]<x[i+1]) tmp=x[i], x[i]=x[i+1], x[i+1]=tmp; //swap
    }
    if(x[i+1]==1) break;
  }
  printf("%d", x[n-1]);
  return 0;
}


Measured memory_bytes: 892
n, m, l = list(map(int, input().split()))
a = [list(map(int, input().split())) for i in range(n)]
b = [list(map(int, input().split())) for i in range(m)]
for i in range(n):
	line = []
	for j in range(l):
		c = 0
		for k in range(m):
			c += a[i][k] * b[k][j]
		line.append(str(c))
	print(*line)
	


Measured memory_bytes: 6584
#include <bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define inf (int)(3e18)
#define mod (int)(1e9+7)
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int n,q;
string s;
char t[222222],d[222222];
signed main(){
	cin>>n>>q>>s;
	rep(i,q)cin>>t[i]>>d[i];
	int le=-1,ri=n;
	for(int i=q-1;i>=0;i--){
		if(s[le+1]==t[i]&&d[i]=='L')le++;
		if(s[ri-1]==t[i]&&d[i]=='R')ri--;
		if(le!=-1&&s[le]==t[i]&&d[i]=='R')le--;
		if(ri!=n&&s[ri]==t[i]&&d[i]=='L')ri++;
	}
	cout<<max(0ll,ri-le-1)<<endl;
}


Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int n,m;
vector<int> s,c;

bool ok(string str){
    if(str.size()!=n) return false;
    rep(i,m){
        if(str[s[i]]!=(char)(c[i]+'0')) return false;
    }
    return true;
}

int main(){
    
    cin>>n>>m;
    s.resize(m); c.resize(m);
    rep(i,m){
        cin>>s[i]>>c[i];
        s[i]--;
    }

    for(int i=0;i<=999;i++){
        string str=to_string(i);
        if(ok(str)){
            cout<<str<<endl;
            return 0;
        }
    }

    cout<<-1<<endl;
}



Measured memory_bytes: 256
//#include<cstdio>
//#include<cassert>
//#include<iostream>
//#include<cstring>
//#include<algorithm>
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define MAX ((int)1e9 + 5)
#define MAXL ((ll)3e18 + 7)
#define MAX_X ((ll)1e5 + 2)
#define pi (2.0*acos(0))
#define M ((int)1e6 + 7)
#define MOD ((int)1e9 + 7)
#define NN ((int)3e6 + 7)
#define N ((int)3e5 + 5)
#define eps (0)
#define fastio ios_base::sync_with_stdio(false),cin.tie(NULL)
#define logn 29
#define endl "\n"
#define mp make_pair
#define BUCK 105
#define RIG ((idx<<1)|1)
#define LEF (idx<<1)
//#define int ll


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;

/*fast io
ios_base::sync_with_stdio(false);
cin.tie(NULL);
*/




typedef tree < int,  null_type,  less < int >,  rb_tree_tag,  tree_order_statistics_node_update > o_set;
/// o_set s;
/// s.order_of_key(k) : Number of items strictly smaller than k .
/// *(s.find_by_order(k)) : K-th element in a set (counting from zero).

int arr[N];


int main()
{
    fastio;
    int n ;
    cin>>n;
    for(int i = 1 ; i<=n*3 ; i++){
        cin>>arr[i];
    }
    sort(arr+1,arr+3*n+1);
    ll ans = 0;
    for(int i = 3*n - 1 ; i>n ; i -= 2) ans += arr[i];
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int x, y;
    cin >> x >> y;
    --x;
    --y;
    auto get_dist = [&](int i, int j) {
        int a = abs(i - j);
        int b = abs(i - x) + abs(y - j) + 1;
        int c = abs(i - y) + abs(x - j) + 1;
        return min(a, min(b, c));
    };
    vector<int> dists(n, 0);
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            ++dists[get_dist(i, j)];
        }
    }
    for (int i = 1; i < n; ++i) {
        cout << dists[i] << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
void countingsort(int A[],int n,int maxs)//maxsize
{
	int *B=new int[n];
	int *C=new int[++maxs];
	int i;
	for(i=0;i<maxs;i++)C[i]=0;
	for(i=0;i<n;i++)
	{
		C[A[i]]++;
		B[i]=A[i];
	}
	for(i=1;i<maxs;i++)C[i]+=C[i-1];
	for(i=n;i--;)
	{
		C[B[i]]--;
		A[C[B[i]]]=B[i];
	}
	return;
}

int main() {
	const int maxs=10000;
	int n;cin>>n;
	int *A=new int[n];
	for(int i=0;i<n;i++)cin>>A[i];
	countingsort(A,n,maxs);
	for(int i=0;i<n;i++)
	{
		if(i)cout<<" ";
		cout<<A[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 18708
N, M = map(int, input().split())
s = [[] for i in range(N+1)]
e = [[] for i in range(N+1)]
for i in range(M):
    a, b = map(int, input().split())
    s[a].append(b)
    e[b].append(a)

for i in s[1]:
    if N in s[i]:
        print('POSSIBLE')
        exit()

print('IMPOSSIBLE')

Measured memory_bytes: 87244
import math
count = 0
def merge(a,left,mid,right):
    global count
    # n1 = mid-left
    # n2 = right - mid
    L = A[left:mid]+[1e9]#[0]*(n1+1)
    R = A[mid:right]+[1e9]#[0]*(n2+1)
    # for i in range(n1):
        # L[i] = A[left+i]
    # for i in range(n2):
        # R[i] = A[mid+i]
    # L[n1] = 1e9
    # R[n2] = 1e9
    i, j = [0,0]
    for k in range(left,right):
        if L[i] <= R[j]:
            A[k] = L[i]
            i+=1
        else:
            A[k] = R[j]
            j+=1
        count+=1
        
def mergesort(A,l,r):
    if (l+1) < r:
        mid = math.floor((l+r)/2)
        mergesort(A,l,mid)
        mergesort(A,mid,r)
        merge(A,l,mid,r)
N = int(input())
A = [int(x) for x in input().split(" ")]
A.append(1e9)
mergesort(A,0,N)
for i in range(len(A)):
    if i < len(A)-2:
        print(A[i],end=" ")
    else:
        print(A[i])
        break

print(count)


Measured memory_bytes: 65840
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		while(true){
			int num = in.nextInt();
			if(num == 0)break;
			int n = in.nextInt();
			int cnt = 0;
			for(int i = 0;i < n;i++){
				int s = in.nextInt();
				int e = in.nextInt();
				cnt = cnt + e - s;
			}
			if(cnt >= num){
				System.out.println("OK");
			}else{
				System.out.println((num - cnt));
			}
		}
	}
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()
#define ADD(a, b) a = (a + b) % MOD

int main()
{
  int H, W, K;
  cin >> H >> W >> K;
  K--;
  ll dp[101][8] = {};
  dp[0][0] = 1;
  REP(h, H)
  REP(w, W)
  {
    for (int b = 0; b < (1 << (W - 1)); ++b)
    {
      bool ok = true;
      REP(i, W - 2)
      {
        if ((b >> i) & 1 && (b >> (i + 1)) & 1)
          ok = false;
      }
      if (ok)
      {
        if (b & (1 << w))
          ADD(dp[h + 1][w + 1], dp[h][w]);
        else if (0 < w && b & (1 << (w - 1)))
          ADD(dp[h + 1][w - 1], dp[h][w]);
        else
          ADD(dp[h + 1][w], dp[h][w]);
      }
    }
  }
  cout << dp[H][K] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 998244353
#define int long long
#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, p;
int cnt[1000010];
int ans = 1;

signed main() {
	cin >> n >> p;
	int q = p;
	for (int i = 2; i <= sqrt(q); i++) {
		int k = 0;
		while (p%i == 0) {
			k++;
			p /= i;
		}
		cnt[i] = k;
	}
	if (1 < p&&n == 1)ans = p;
	for (int i = 2; i <= 1000000; i++)if (n <= cnt[i]) {
		ans *= pow(i, cnt[i] / n);
	}
	cout << ans << endl;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
signed main(){
  int a,b;
  cin>>a>>b;
  vector<string> c(a),d(b);
  rep(i,a)cin>>c.at(i);
  rep(i,b)cin>>d.at(i);
  rep(i,a-b+1)rep(j,a-b+1){
    bool e=true;
    rep(k,b)rep(l,b){
      if(d.at(k).at(l)!=c.at(k+i).at(l+j)){
        e=false;k=l=b;
        }
 }
    if(e){
      cout<<"Yes";
      return 0;
    }
    }
  cout<<"No";
}

Measured memory_bytes: 256
var s:string;

begin
  readln(s);
  if (s[1]=s[2])and(s[2]=s[3]) then
  begin
    writeln('Yes');
    exit;
  end;
  if (s[2]=s[3])and(s[3]=s[4]) then
  begin
    writeln('Yes');
    exit;
  end;
  writeln('No');
end.



Measured memory_bytes: 128
N = int(input())
H = list(map(int,input().split()))

cnt = 0
maxcnt = 0 


for i in range(N-1):
    
    if H[i] >= H[i+1]:
        cnt+=1
    else:
        maxcnt = max(maxcnt,cnt)
        cnt=0
    
        
result = max(maxcnt,cnt)
    

print(result)


Measured memory_bytes: 14252
#include<stdio.h>
int main()
{
	int a,b,c,d,flag=0;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	while(a>0)
	{c-=b;
	a-=d;
	if(c<=0){flag=1;break;}
	}
if(flag)printf("Yes\n");
else printf("No\n");
	return 0;
 } 

Measured memory_bytes: 1648
# https://atcoder.jp/contests/abc068/tasks/arc079_a



N, M = gets.split.map(&:to_i)

hash = Hash.new {|h, key| h[key] = []}
M.times do
  a, b = gets.split.map(&:to_i)
  hash[a] << b
  hash[b] << a
end

cond = false
hash[1].uniq.each do |via|
  cond = true if hash[via].include?(N)
end
puts cond ? 'POSSIBLE' : 'IMPOSSIBLE'


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;

const int inf = 2e9;


int n;
int ans[maxn];
vector<int> g[maxn];
int a[maxn];




int dp[maxn];
vector<int> v[maxn];

int ptr=0;


void dfs(int at, int p) {
    int idx = lower_bound(dp,dp+n+2,a[at]) - dp;
    dp[idx] = a[at];
    v[idx].push_back(a[at]);
    ptr=max(ptr,idx);
    ans[at]=ptr;
    
    for (int to: g[at]) {
	if (to == p) continue;
	dfs(to, at);
    }

    v[idx].pop_back();
    dp[idx] = v[idx].back();
    if (ptr==idx && dp[ptr]==inf) {
	--ptr;
    }
}


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


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

    for (int i=0; i<n-1; i++) {
	int u,v; cin>>u>>v;
	--u;
	--v;
	g[u].push_back(v);
	g[v].push_back(u);
    }


    dp[0] = -inf;
    v[0].push_back(-inf);
    for (int i=1; i<=n+10; i++) {
	dp[i] = inf;
	v[i].push_back(inf);
    }

    dfs(0, -1);


    for (int i=0; i<n; i++) {
	assert(ans[i]>0);
	cout<<ans[i]<<"\n";
    }
    
    return 0;
}


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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

using ll = long long;

int main() {
    string s, t = "ACGT";
    int cnt = 0, ans = 0;
    cin >> s;
    for (int i = 0; i < s.size(); ++i) {
        if (t.find(s[i]) != string::npos) {
            cnt++;
        }
        else {
            cnt = 0;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define PI atan(1)*4
typedef long long int ll;
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  const long long mod = 1e9 + 7;
  long long ans = 0;
  for(long long i = k; i <= n + 1; ++i){
    long long mn = ((i - 1) * i  / 2);
    long long mx = ((2 * n - i + 1) * i / 2);
    ans += (mx - mn + 1) % mod;
    ans %= mod;
  }
  cout << ans % mod;
}

Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
constexpr int MOD = 1'000'000'007;

long long power(long long x, long long n, long long mod = 1000000007) {
    if (n == 0) return 1;
    if (n % 2 == 0) return power(x * x % mod, n/2, mod);
    else return x * power(x, n-1, mod) % mod;
}

void solve() {
    int n;
    cin >> n;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    LL cnt[2][61] = {};
    REP(i,0,n) {
        REP(j,0,61) {
            if (a[i] & (1LL << j)) cnt[1][j]++;
            else cnt[0][j]++;
        }
    }
    LL ans = 0;
    REP(i,0,61) {
        //cerr << cnt[0][i] << ", " << cnt[1][i] << endl; 
        ans += ((cnt[0][i] * cnt[1][i]) % MOD) * power(2,i);
        ans %= MOD;
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 2560
//Utkarsh.25dec
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define vi vector <int>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
bool vis[N];
vector <int> adj[N];
string s;
ll check(int l,int r)
{
    for(int i=l;i<=r;i++)
    {
        if(s[i]!=s[r-(i-l)])
            return 0;
    }
    return 1;
}
void solve()
{
    cin>>s;
    ll n=s.length();
    // cout<<check(0,n-1)<<' '<<check((n+3)/2-1,n-1)<<'\n';
    ll flag=min3(check(0,n-1),check((n+3)/2-1,n-1),check(0,(n-1)/2-1));
    if(flag==1)
        cout<<"Yes";
    else
        cout<<"No";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int T=1;
    //cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 12032
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;
const int N = 1e5 + 2;
int a[N];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int ct = 0;
	int ans = 0;
	REP(i,n){
		int tmp;
		cin >> tmp;
		if(a[tmp] == 2){
			a[tmp]--;
			ct--;
		}else if(a[tmp] == 1){
			a[tmp]++;
			ct++;
		}else{
			a[tmp]++;
			ans++;
		}
	}
	cout << ans - ct%2 << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define int LL
#define upto(a, b, i) for(int i = (a), b_ = (b); i <= b_; ++i)
#define uptil(a, b, i) for(int i = (a), b_ = (b); i < b_; ++i)
#define downto(a, b, i) for(int i = (a), b_ = (b); i >= b_; --i)
#define downtil(a, b, i) for(int i = (a), b_ = (b); i > b_; --i)
#define times(n, i) uptil(0, n, i)
#define rtimes(n, i) downto((n)-1, 0, i)

#define sp <<" "
#define ln <<endl
#define size(x) ((int)x.size())

void solve() {
  int N,A,B; cin>>N>>A>>B;
  cout << min(N*A, B) ln;
}

signed main() {
  cout << fixed << setprecision(20);
  cerr << fixed << setprecision(6);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;
    cin>>n;
    ll A[n], B[n], C[n];
    ll dp[n+5][3];
    memset(dp, 0, sizeof(dp));
    for(ll i=0;i<n;i++){
        cin>>A[i]>>B[i]>>C[i];
    }
    for(ll i=0;i<n;i++){
        for(ll j=0;j<3;j++){
            if(i == 0){
                if(j == 0) dp[i][j] = A[i];
                else if(j == 1) dp[i][j] = B[i];
                else dp[i][j] = C[i];
            }
            else{
                for(ll k=0;k<3;k++){
                    if(j == k) continue;
                    if(j == 0) dp[i][j] = max(dp[i][j], dp[i-1][k]+A[i]);
                    else if(j == 1) dp[i][j] = max(dp[i][j], dp[i-1][k]+B[i]);
                    else dp[i][j] = max(dp[i][j], dp[i-1][k]+C[i]);
                }
            }
        }
    }
    ll ans = 0;
    ans = max(ans, max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2])));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4992
from heapq import *

n,m = map(int, input().split())
a = [int(x) for x in input().split()]

h = []
for aa in a:
    heappush(h, -aa)

for i in range(m):
    x = heappop(h)
    x = -x
    x = x //2
    heappush(h, -x)

s = 0
for hh in h:
    s += (-hh)
print(s)

Measured memory_bytes: 14180
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
using P = pair <int, int>;
 
ll MOD = 1000000007;
ll INF =1<<29;

int main() {
    int x;
    cin >> x;
    int M = 1;
    for(int i=2;i<=31;++i){
        int a = i;
        int cnt =0;
        while(a<=x){
        a*=i;
        cnt++;}
        if(cnt>=2){
        int ans =a/i;
        M = max(M,ans);} 
    }
    cout << M <<endl;
} 

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  vector<int> ans(n + 1, 0);

  REP(i, n - 1) {
    int a;
    cin >> a;
    a--;
    ans[a]++;
  }


  REP(i, n) cout << ans[i] << endl;
}


Measured memory_bytes: 3956