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

// 入力
int n, m;
int a0, b0, c0; // トレイA, B, C上のコップの個数
int A[15], B[15], C[15]; // トレイA, B, C上のコップ

int solve() {
    int ans = 100000000;
    for (int i = 0; i < 2; i++) {
        stack<int> a, b, c; // トレイA, B, C上のコップ
        for (int j = 0; j < a0; j++) a.push(A[j]);
        for (int j = 0; j < b0; j++) b.push(B[j]);
        for (int j = 0; j < c0; j++) c.push(C[j]);
        for (int j = 0; j <= m; j++) {
            if (a.size() == n || c.size() == n) {
                ans = min(ans, j);
                break;
            }
            if (j % 2 == i) {
                if (a.empty()) {
                    a.push(b.top());
                    b.pop();
                }
                else if (b.empty()) {
                    b.push(a.top());
                    a.pop();
                }
                else if (a.top() < b.top()) {
                    a.push(b.top());
                    b.pop();
                }
                else {
                    b.push(a.top());
                    a.pop();
                }
            }
            else {
                if (c.empty()) {
                    c.push(b.top());
                    b.pop();
                }
                else if (b.empty()) {
                    b.push(c.top());
                    c.pop();
                }
                else if (c.top() < b.top()) {
                    c.push(b.top());
                    b.pop();
                }
                else {
                    b.push(c.top());
                    c.pop();
                }
            }
        }
    }
    if (ans == 100000000) return -1;
    else return ans;
}

int main() {
    while (true){
        cin >> n >> m;
        if (n == 0) break;
        cin >> a0;
        for (int i = 0; i < a0; i++) cin >> A[i];
        cin >> b0;
        for (int i = 0; i < b0; i++) cin >> B[i];
        cin >> c0;
        for (int i = 0; i < c0; i++) cin >> C[i];
        cout << solve() << endl;
    }
    return 0;
}


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

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


int main()
{
	int x, y, z, k;
	cin >> x >> y >> z >> k;
	vector<ll> a(x), b(y), c(z);
	for(int i = 0; i < x; i++)cin >> a[i]; sort(a.begin(), a.end(), greater<ll>());
	for(int i = 0; i < y; i++)cin >> b[i]; sort(b.begin(), b.end(), greater<ll>());
	for(int i = 0; i < z; i++)cin >> c[i]; sort(c.begin(), c.end(), greater<ll>());
	using T = tuple<ll,int,int,int>;
	priority_queue<T> que;
	set<T> st;
	que.emplace(a.front() + b.front() + c.front(), 0, 0, 0);
	st.emplace(a.front() + b.front() + c.front(), 0, 0, 0);
	vector<ll> ans;


	for(int i = 0; i < k; i++) {
		auto cur = que.top();
		ans.push_back(get<0>(cur));
		que.pop();
//		cerr << get<0>(cur) << " :: " << get<1>(cur) << " :: " << get<2>(cur) << " :: " << get<3>(cur) << endl;
		T nx1, nx2, nx3;
		if(get<1>(cur) + 1 < x)
		nx1 = T(get<0>(cur) + a[get<1>(cur) + 1] - a[get<1>(cur)], get<1>(cur) + 1, get<2>(cur), get<3>(cur));

		if(get<2>(cur) + 1 < y)
		nx2 = T(get<0>(cur) + b[get<2>(cur) + 1] - b[get<2>(cur)], get<1>(cur), get<2>(cur) + 1, get<3>(cur));

		if(get<3>(cur) + 1 < z)
		nx3 = T(get<0>(cur) + c[get<3>(cur) + 1] - c[get<3>(cur)], get<1>(cur), get<2>(cur), get<3>(cur) + 1);

		if(!st.count(nx1)) {
			que.push(nx1);
			st.insert(nx1);
		}

		if(!st.count(nx2)) {
			que.push(nx2);
			st.insert(nx2);
		}

		if(!st.count(nx3)) {
			que.push(nx3);
			st.insert(nx3);
		}

	}

	for(auto i : ans) {
		cout << i << endl;
	}

}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
  int a, b, c, d;
  int res;
  cin >> a >> b >> c >> d;

  if (a * b > c * d) {
	res = a * b;
  }
  else {
	res = c * d;
  }

  cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
string s,t;
ll ans = 0;
int now = -2;
vector<vector<int> > v(26);
bool used[26]={};
signed main(){
    cin >> s >> t;
    int n=s.size(),m=t.size();
    for(int i=0;i<n;i++){
        used[s[i]-'a']=1;
        v[s[i]-'a'].push_back(i);
    }
    for(int i=0;i<m;i++){
        if(!used[t[i]-'a']){
            cout << -1 << endl;
            return 0;
        }
        int p = t[i] - 'a';
        auto itr = upper_bound(v[p].begin(),v[p].end(),now);
        if(itr == v[p].end()){
            now = v[p][0];
            ans ++;
        }
        else now = *itr;
    }
    ans *= n;
    ans += now + 1;
    cout << ans << endl;
    return 0;
}

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

  int main() {
  string s;
  cin >> s;
  int ans = 0;
  int a= s.size();
  for (int i = 0; i < a; i++) {
    ans += s[i] - '0';
  }
  if (ans % 9 == 0) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 3684
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
	string s;
	int q;
	
	cin >> s;
	cin >> q;
	
	for(int i=0; i<q; ++i){
		string od, p;
		int a, b;
		
		cin >> od >> a >> b;
		if(od=="replace"){
			cin >> p;
			s = s.replace(a, b-a+1, p);
		}
		else if(od=="print"){
			cout << s.substr(a, b-a+1) << endl;
		}
		else if(od=="reverse"){
			string tmp = s.substr(a, b-a+1);
			reverse(tmp.begin(), tmp.end());
			//cout <<"tmp=" << tmp <<endl;
			s = s.replace(a, b-a+1, tmp);	
		}
		
		//cout << s << endl;
		
	}
	return 0;
}



Measured memory_bytes: 3212
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#include <queue>
#define rep(i,n) for (int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

const ll mod = 1000000007;

int main() {
    int s;
    cin >> s;
    vector<int> dp(s+1);
    dp[0]=1;
    for(int i=1; i<=s; ++i) {
        for(int j=0; j<=i-3; ++j) {
            dp[i]+=dp[j];
            dp[i]%=mod;
        }
    }
    cout << dp[s] << endl;
    return 0;
}

Measured memory_bytes: 3596
#coding-utf:8

def main():
    n, q = map(int, input().split())
    s = input()
    t = [0] * (n+1)
    for i in range(n):
        if s[i : i+2] == 'AC':
            x = 1
        else:
            x = 0
        t[i+1] = t[i] + x
        x = 0

    for j in range(q):
        l, r = map(int, input().split())
        print(t[r-1] - t[l-1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 7748
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);++(i))
#define rREP(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	string s; cin >> s;
	unordered_map<char, int>mp;
	mp['a'] = 0; mp['b'] = 0; mp['c'] = 0;
	rep(i, 0, s.size())mp[s[i]]++;
	bool ans = true;
	char ch[] = { 'a','b','c' };
	rep(i, 0, 3) {
		rep(j, i + 1, 3) {
			if (abs(mp[ch[i]] - mp[ch[j]]) > 1)ans = false;
		}
	}
	
	cout << (ans ? "YES" : "NO") << "\n";

	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 10000000
const int maxn = 1e5 + 5;
const int mod=1e9+7;

int n,k;
int a[maxn];

int main()
{
   ios::sync_with_stdio(false),cin.tie(0);
   cin>>n>>k;
   int pos=0;
   for(int i=1;i<=n;i++)
    {
      cin>>a[i];
      if(a[i]==1)pos=i;
    }
   double left=max(0,pos-1);
   double right=max(0,n-pos-k+1);
   if(pos>=n-k)
    {
      left-=k-(n-pos+1);
      //cout<<left<<endl;
    }
   double si=k-1;
   int ans=INF;
   double L=0.0;
   double R=n-pos;
   if(k==n)
   {
    cout<<1;
    exit(0);
   }
   while(left>=L&&right<=R){
      //cout<<left<<" "<<right<<endl;
      int cnt1=ceil(right/si);
      int cnt2=ceil(left/si);
      ans=min(ans,cnt1+cnt2);
      left--;
      right++;
   } 
   ans++;
  cout<<ans;
}

Measured memory_bytes: 640
N=int(input())#3
lst=list(map(int,input().split()))#[8,12,40]
time=0
while True:
  for i in lst:#[8,12,40]
    if i%2!=0:
      break
  else:
    time+=1
    lst=[int(i/2) for i in lst]
    continue
  print(time)
  break

Measured memory_bytes: 2940
import java.util.Scanner;

/**
 * A - Registration
 * 高橋君はとあるWebサービスに会員登録しようとしています。
 * まずIDを S として登録しようとしました。しかし、このIDは既に他のユーザーによって使用されていました。
 * そこで、高橋君は S の末尾に 1 文字追加した文字列をIDとして登録することを考えました。
 * 高橋君は新しくIDを T として登録しようとしています。これが前述の条件を満たすか判定してください。
 * 羊が狼に襲われるなら unsafe、襲われないなら safe を出力してください。
 */
public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner( System.in );
        // 登録しようとしたID
        String s = sc.next();
        // 次に登録しようとしたID
        String t = sc.next();

        System.out.println( s.equals( t.substring( 0, s.length() ) ) ? "Yes" : "No" );

        sc.close();
    }
}


Measured memory_bytes: 35624
#include <bits/stdc++.h>
using namespace std;
#define  ll             long long
#define  fast         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define  pb           push_back
int main()
{
    fast;
    string str;
    cin >> str;
    if(str == "ARC")
        cout << "ABC" << endl;
    else cout << "ARC" << endl;
    return 0;
}


Measured memory_bytes: 3612
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include "bits/stdc++.h"

using namespace std;

#define int long long

const int N = 1e5 + 5;
int a[N];
vector<int> adj[N];
bool mark[N];
multiset<int> vertices;

void dfs(int v, int p[]) {
	if (p[1] > a[v]) {
		p[2] = a[v];
		sort(p, p + 3);
	}
	mark[v] = true;
	vertices.insert(a[v]);
	for (int u: adj[v])
		if (!mark[u])
			dfs(u, p);
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	int ans = 0, alone = 0, comp = 0;
	const int INF = 1e10 + 9;
	int c[] = {0, 0, 0};
	for (int i = 0; i < n; ++i) {
		if (mark[i])
			continue;
		++comp;
		int p[] = {INF, INF, INF};
		dfs(i, p);
		ans += p[0];
		sort(c, c + 3, greater<int>());
		vertices.erase(vertices.find(p[0]));
	}
	if (comp == 1)
		return cout << 0 << endl, 0;
	int cnt = comp - 2;
	while (cnt) {
		if (vertices.size()) {
			ans += *vertices.begin();
			vertices.erase(vertices.begin());
			--cnt;
		} else {
			return cout << "Impossible" << endl, 0;
		}
	}
	cout << ans << endl;
	
}


Measured memory_bytes: 11776
import math


def resolve():
    import sys
    import string
    input = sys.stdin.readline
    # row = [int(x) for x in input().rstrip().split(" ")]
    # n = int(input().rstrip())
    n = int(input().rstrip())
    a_list = [int(input().rstrip()) * -1 for i in range(n)]

    import numpy
    indices = numpy.argsort(a_list)
    max_num = a_list[indices[0]] * -1
    second_max_num = a_list[indices[1]] * -1

    for i in range(len(a_list)):
        if i != indices[0]:
            print(max_num)
        else:
            print(second_max_num)


if __name__ == "__main__":
    resolve()


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

int main(void){
    int n, k; cin >> n >> k;
    vector<int> p(n); for(int i=0;i<n;i++){cin >> p[i];}
    sort(p.begin(), p.end());

    cout << accumulate(p.begin(), p.begin()+k, 0);

    return 0;
}

Measured memory_bytes: 3584
#include<iostream>
using namespace std;
int main(){
    int n, m, l;
    
    long long p;
    
    cin >> n >> m >> l;
    
    int dimA[n][m];
    int dimB[m][l];
    long long dimC[n][l];
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            dimC[i][j] = 0;
        }
    }
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> dimA[i][j];
        }
    }
    
    for(int i = 0; i < m; i++){
        for(int j = 0; j < l; j++){
            cin >> dimB[i][j];
        }
    }
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            for(int k = 0; k < l; k++){
                p = dimA[i][j] * dimB[j][k];
                dimC[i][k] += p;
                p = 0;
            }
        }
    }
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < l; j++){
            cout << dimC[i][j];
            
            if((j != (l - 1))){
                cout << " ";
            }
        }
        
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3240
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int d1[6] = { 1,0,-1,0,1,-1 };
	int d2[6] = { 0,1,0,-1,1,-1 };
	int t, n;
	while (cin >> t>>n, t) {
		int p[200][200] = {};
		int x, y, sta, las;
		for (int i = 0; i < n; i++) {
			cin >> x >> y;
			p[x + 100][y + 100] = 1;
		}
		cin >> sta >> las; sta += 100; las += 100;
		int used[200][200] = {};
		used[sta][las] = 1;
		vector<P> v;
		v.push_back({ sta,las });
		for (int i = 0; i < t; i++) {
			int len = v.size();
			for (int j = 0; j < len; j++) {
				int nx = v[0].first; int ny = v[0].second; v.erase(v.begin());
				for (int k = 0; k < 6; k++) {
					if (p[nx + d1[k]][ny + d2[k]] == 0 && used[nx + d1[k]][ny + d2[k]]==0) {
						used[nx + d1[k]][ny + d2[k]] = 1;
						v.push_back({ nx + d1[k],ny + d2[k] });
					}
				}
			}
		}
		v.clear();
		int cnt = 0;
		for (int i = 0; i < 200; i++) {
			for (int j = 0; j < 200; j++) {
				if (used[i][j] == 1)cnt++;
			}
		}
		cout << cnt << endl;
	}
	return 0;
}


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

/*----------------------------- DEFINES ------------------------------*/

#define eps 1e-9
#define mod 1000000007
#define ump unordered_map // operations take less time compared to map
#define pb push_back
#define pf push_front
#define pof pop_front()
#define pob pop_back()
#define mp make_pair
#define ps(x) push(x) // for stack and queue
#define T top() //  for stack
#define FR front()// for queue
#define BA back()// for queue
#define PP pop()// for queue and stack
#define B begin()
#define E end()
#define F first
#define S second
#define tostr(x) to_string(x)
#define SZ(x) ((int)x.size())
#define ins insert
#define MAE max_element
#define MIE min_element
#define cnt(x) count(x)
#define lb(x) lower_bound(x) // returns an it ptng to the element >=x if no such returns end
#define ub(x) upper_bound(x) // returns an it ptng to the element >x if no such returns end
#define rep(i,x,y) for(int i=x;i<y;i++)
#define per(i,x,y) for(int i=x;i>y;i--)
#define repi(i,x,y) for(int i=x;i<=y;i++)
#define peri(i,x,y) for(int i=x;i>=y;i--)
#define reps(i,x,y,k) for(int i=x;i<y;i+=k)
#define sper(i,x,y,k) for(int i=x;i>y;i-=k) 
#define all(x) ((x.B),(x.E))
#define inf (ll)LLONG_MAX
#define ds1(i,x) for(auto i=x.begin();i!=x.end();i++)
#define ds2(i,x) for(auto i:x) // easy method to iterate through a ds
#define sq(a) (a)*(a)
#define fib(n) ceil(pow((1+sqrt(5),n)-pow((1-sqrt(5),n)/(float)(pow(2,n)*sqrt(5)// compute fib(n) in O(1)
#define FIO {ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);}// fast i/o
#define dig(n) (int)(log10(n)+1) // num of digits
#define ss(x,k) substr(x,k)  // x is the start pos and k is the length of substr.
#define f(x) find(x)
#define set(x,k) memset(x,k,sizeof x)

/*------------------------------ TYPEDEFS-----------------------------*/

typedef long long ll;
typedef long l;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<pair<int,int> > vpii;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef ump<int,int> umpii;

/*-----------------------------START FROM HERE -----------------------*/

int main(){
	FIO
	
	int n;cin>>n;
	int s=0;
	int a[n];rep(i,0,n){cin>>a[i];s+=a[i];}
	int t;cin>>t;
	while(t--){
		int x,y;cin>>x>>y;
		cout<<s+y-a[x-1]<<"\n";
	}
	return 0;
}


Measured memory_bytes: 256
import sys
from functools import lru_cache
def input(): return sys.stdin.readline().rstrip()

@lru_cache(maxsize=None)
def gcd(m, n):
    if n == 0:
        return m
    else:
        return gcd(n, m % n)

def main():
    _ = int(input())
    A = tuple(map(int, input().split()))

    ans = A[0]
    for a in A[1:]:
        ans = gcd(ans, a)
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 54216
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;
 
void main() {
    int H, W; readf("%d %d\n", &H, &W);
    char[][] F;
    for (int i = 0; i < H; i++) {
        F ~= cast(char[])readln.chomp;
    }
    char[][] P;
    for (int i = 0; i < 2; i++) {
        P ~= cast(char[])readln.chomp;
    }
    string X = "JOI";
    int Ans = 0;

    bool M(int h, int w) {
        for (int y = 0; y < 2; y++) 
            for (int x = 0; x < 2; x++) {
                if (h + y < 0 || h + y >= H) return false;
                if (w + x < 0 || w + x >= W) return false;
                if (F[h + y][w + x] != P[y][x]) return false;
            }
        return true;
    }

    int C() {
        int Count = 0;
        for (int h = 0; h < H - 1; h++) {
            for (int w = 0; w < W - 1; w++) {
                if (M(h, w)) {
                    Count++;
                }
            }
        }
        return Count;
    }

    int Old = C();

    for (int h = 0; h < H; h++) {
        for (int w = 0; w < W; w++) {
            for (int i = 0; i < 3; i++) {
                static const  dy = [0, -1, -1, 0],
                              dx = [-1, 0, -1, 0]; 
                int Diff = 0;
                for (int j = 0; j < 4; j++) {
                    if (M(h + dy[j], w + dx[j])) Diff--;
                }
                char t = F[h][w];
                F[h][w] = X[i];
                for (int j = 0; j < 4; j++) {
                    if (M(h + dy[j], w + dx[j])) Diff++;
                }
                F[h][w] = t;
                Ans = max(Ans, Old + Diff);
            }
        }
    }
    printf("%d\n", Ans);
}

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  lint n,d; cin >> n >> d;
  vector<lint> x(n),y(n); for(lint i=0;i<n;i++) { cin >> x[i] >> y[i]; }

  lint ans=0;
  for(int i=0;i<n;i++) {
    if(x[i]*x[i]+y[i]*y[i] <= d*d) { ans++; }
  }

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


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
void debug(istringstream&){}
template <char sep=',', class Head, class... Tail>
void debug(istringstream& iss, Head&& head, Tail&&... tail)
{
  string name;
  getline(iss, name, ',');
  cout << sep << name << "=" << head;
  debug(iss, forward<Tail>(tail)...);
}
#define DEBUG(...) \
  do{ \
    istringstream ss(#__VA_ARGS__); \
    debug<' '>(ss, __VA_ARGS__); \
    cout<<endl; \
  }while(0)


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;


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

  string S;
  cin >> S;

  int ans = 0, len = 0;
  string acgt = "ACGT";
  for(char c: S){
    if(acgt.find(c) != string::npos){
      ++len;
      maxi(ans, len);
    }
    else len = 0;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int a, b, sum = 0;
	cin >> a >> b;
	loop(i, a, b+1){
		string s = to_string(i);
		string t = s;
		reverse(all(s));
		if(s == t) sum++;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
print(*a)
for i in range(1, len(a)):
  v = a[i]
  j = i - 1
  while 0 <= j and v < a[j]:
    a[j+1] = a[j]
    j -= 1
  a[j+1] = v
  print(*a)



Measured memory_bytes: 5976
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<long long> a(100005, 0);
  long long sum = 0;
  for (int i = 0; i < n; ++i) {
    int t;
    cin >> t;
    a[t]++;
    sum += t;
  }
  int q;
  cin >> q;
  while (q--) {
    int b, c;
    cin >> b >> c;
    a[c] += a[b];
    sum -= a[b] * b;
    sum += a[b] * c;
    a[b] = 0;
    cout << sum << '\n';
  }
}


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

int H, W;
vector<vector<char> > G;
vector<char> A, B;

vector<vector<int> > cc2;
int dp2(int a, int b) {
    int &ret = cc2[a][b];
    if(ret != -1) return ret;

    if(a == H || b == H) return ret = 0;
    return ret = (A[H - 1 - a] == B[H - 1 - b]) + dp2(a + 1, b + 1);
}

vector<vector<int> > cc1;
int dp1(int a, int b) {
    int &ret = cc1[a][b];
    if(ret != -1) return ret;

    if(a == H && b == H) return ret = 0;
    ret = 1e9;
    if(a < H) ret = min(ret, dp2(a, b) + dp1(a + 1, b));
    if(b < H) ret = min(ret, dp2(a, b) + dp1(a, b + 1));
    return ret;
}

int main() {
    scanf("%d %d", &H, &W);
    G = vector<vector<char> >(H, vector<char>(W));
    for(int i = 0; i < H; i++) {
        scanf("\n");
        for(int j = 0; j < W; j++) {
            scanf("%c", &G[i][j]);
        }
    }
    int cost = 0;
    for(int i = 0; i < W - 1; i++) {
        A.clear();
        B.clear();
        for(int j = 0; j < H; j++) A.push_back(G[j][i]);
        for(int j = 0; j < H; j++) B.push_back(G[j][i + 1]);

        cc1 = cc2 = vector<vector<int> >(H + 1, vector<int>(H + 1, -1));
        cost += dp1(0, 0);
    }
    printf("%d", cost);
}


Measured memory_bytes: 1600
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("[DEBUG] ");W(__VA_ARGS__);}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1<<20;
void solve() {
    int n;
    R(n);
    for(int i=360;;i+=360){
        if(i%n==0){
            W(i/n);
            return;
        }
    }
}
int main(){
#define MULTITEST 0
#if MULTITEST    
    CASET{
        solve();
    }
#else
    solve();
#endif
    return 0;
}


Measured memory_bytes: 3824
#include<stdio.h>
#define N 101
 
int v[N][N], d[N], k[N];
int n;
 
void Distance(int a, int b)
{
  int i;
  d[a] = b;
  for (i = 1; i <= k[a]; i++) {
    if (b + 1 < d[v[a][i]])
        Distance(v[a][i], b + 1);
  }
}
 
int main()
{
  int i, j, u;
 
  scanf("%d", &n);
  for (i = 1; i <= n; i++) {
    d[i] = 100000000;
    scanf("%d", &u);
    scanf("%d", &k[u]);
    for(j = 1; j <= k[u]; j++)
      scanf("%d", &v[u][j]);
  }
 
  Distance(1, 0);
 
  for (i = 1; i <= n; i++) {
     if (d[i] == 100000000)
         d[i] = -1;
  }
 
  for (i = 1; i <= n; i++)
     printf("%d %d\n", i, d[i]);
 
  return 0;
}

Measured memory_bytes: 636
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))
N, K = inpl()
H = sorted([int(input()) for _ in range(N)])

ans = 10**9
for i in range(K-1, N):
    ans = min(ans, H[i] - H[i-K+1])
print(ans)

Measured memory_bytes: 8256
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+1;
long long int tree[4*N]={0};
#define ff first
#define ss second
void update(long int node,long int l,long int r,long int ind,long long int val)
{
    if(l==r)
    {
        tree[node] = val;
    }
    else
    {
        long int mid = (l+r)/2;
        if(mid>=ind)
         update(2*node+1,l,mid,ind,val);
         else
         update(2*node+2,mid+1,r,ind,val);
         tree[node] = max(tree[2*node+1],tree[2*node+2]);
    }
}
long long int query(long int node,long int l,long int r,long int L,long int R)
{
    if(L>r || l>R)
    return 0;
    if(L<=l && R>=r)
    return tree[node];
    long int mid = (l+r)/2;
    return max(query(2*node+1,l,mid,L,R),query(2*node+2,mid+1,r,L,R));
}
long long int mod = 1e9+7;
bool compare(pair<long long int,long long int> a,pair<long long int,long long int> b)
{
    return a.ff>b.ff;
}

long long int power(long long int x,long long int y)
{
    long long int res=1;
    while(y>0)
    {
        if(y&1)res=(res*x)%mod;
        x=(x*x)%mod;
        y>>=1;
    }
    return res;
}
vector<long int> a[200001];bool vis[200001]={0};
long int kk=0;
void dfs(long int x)
{
    kk++;
    vis[x]=1;
    for(long int i=0;i<a[x].size();i++)
    {
        if(vis[a[x][i]]==0)
        {
            dfs(a[x][i]);
        }
    }
}
int main()
{
    long int t=1;
    // cin>>t;
    while(t--)
    {
        long int a[1000001]={0};
        for(long long int i=2;i<1000001;i++)
        {
            if(a[i]==0)
            {
                a[i]=i;
                for(long long int j=i*i;j<1000001;j+=i)
                a[j]=i;
            }
        }
        long int b[1000001]={0};
        long int n,aa;
        cin>>n;
        long int c[n];
        for(long int i=0;i<n;i++)
        {
            cin>>aa;
            c[i]=aa;
            while(aa!=1)
            {
                b[a[aa]]++;
                long int temp = aa;
                while(aa%a[temp]==0)
                {
                    aa/=a[temp];
                }
            }
        }
        long int bb=c[0];
        for(long int i=1;i<n;i++)
        {
           bb=__gcd(bb,c[i]);   
        }
        bool pp=0;
        for(long int i=0;i<1000001;i++)
        {
            if(b[i]>1)
            pp=1;
        }
        if(!pp)
        {
            cout<<"pairwise coprime";
            return 0;
        }
        if(bb==1)
        {
          cout<<"setwise coprime";
          return 0;
        }
        cout<<"not coprime";
    }
}

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

using namespace std;

class DSU {
  private: vector<int> p, rank;
  public:
    DSU(int n) {
      p = vector<int>(n, -1);
      rank = vector<int>(n, 0);
    }
    int root(int x) {
      if (p[x] == -1) {
        return x;
      }
      return (p[x] = root(p[x]));
    }
    bool sameSet(int x, int y) {
      return root(x) == root(y);
    }
    void connect(int x, int y) {
      x = root(x);
      y = root(y);
      if (x != y) {
        if (rank[x] > rank[y]) {
          p[y] = x;
        } else {
          p[x] = y;
          rank[y] += (rank[x] == rank[y]);
        }
      }
    }
};

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<pair<int, pair<int, int>>> edges;
  for (int i = 0; i < m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    edges.push_back({w, {u, v}});
  }
  sort(edges.begin(), edges.end());
  DSU dsu(n);
  int ans = 0;
  for (auto& edge : edges) {
    int u = edge.second.first;
    int v = edge.second.second;
    int w = edge.first;
    if (!dsu.sameSet(u, v)) {
      dsu.connect(u, v);
      ans += w;
    }
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 4488
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
struct node{
    int pre, to;
}edge[10010];
int head[2010], tot;
int n, x, y;
int cnt[2010];
int dis[2010];
bool vis[2010];
priority_queue<pair<int, int> > q;
void dijkstra(int s) {
    memset(vis, 0, sizeof(vis));
    memset(dis, 0x3f, sizeof(dis));
    dis[s] = 0;
    q.push(make_pair(0, s));
    while (!q.empty()) {
        int u = q.top().second;
        q.pop();
        if (vis[u]) continue;
        vis[u] = 1;
        for (int i = head[u]; i; i = edge[i].pre) {
            int v = edge[i].to;
            if (dis[v] > dis[u] + 1) {
                dis[v] = dis[u] + 1;
                q.push(make_pair(-dis[v], v));
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        if (i != s && dis[i] < 0x3f3f3f3f) {
            cnt[dis[i]]++;
        }
    }
}
void add(int u, int v) {
    edge[++tot] = node{head[u], v};
    head[u] = tot;
}
int main() {
    cin >> n >> x >> y;
    for (int i = 1; i < n; i++) {
        add(i, i + 1);
        add(i + 1, i);
    }
    add(x, y);
    add(y, x);
    for (int i = 1; i <= n; i++) {
        dijkstra(i);
    }
    for (int i = 1; i < n; i++) {
        cout << cnt[i] / 2 << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
using namespace std;

int main(int argc, char const *argv[])
{
    string s;
    cin >> s;
    ll k;
    cin >> k;
    rep(i, s.size())
    {
        ll acost = 26 - s[i] + 'a';
        acost %= 26;
        cerr << acost << endl;
        if (acost <= k)
        {
            k -= acost;
            s[i] = 'a';
        }
    }
    s.back() = (s.back() - 'a' + (k % 26)) % 26 + 'a';
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 512
import java.math.BigDecimal;
import java.util.*;
import java.util.function.Consumer;
import java.util.stream.Collectors;

public class Main {
    private static final Scanner scanner = new Scanner(System.in);
    private static final Consumer<List<String>> consumer = solve();

    public static void main(String[] args) {
        consumer.accept(readInput());
    }

    private static List<String> readInput() {
        final List<String> lineList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            lineList.add(scanner.nextLine());
        }
        return lineList;
    }

    static Consumer<List<String>> solve() {
        return args -> {
            int N = Integer.parseInt(args.get(0).split(" ")[0]);
            long[] dist = new long[N];
            Arrays.fill(dist, Long.MAX_VALUE / 2);

            List<Edge> edges = new ArrayList<>();
            for (int i = 1; i < args.size(); i++) {
                int[] edge = Arrays.stream(args.get(i).split(" ")).mapToInt(Integer::parseInt).toArray();
                int from = edge[0] - 1, to = edge[1] - 1;
                long cost = -edge[2];
                edges.add(new Edge(from, to, cost));
            }

            dist[0] = 0;
            for (int i = 0; i < 2 * N; i++) {
                for (Edge e: edges) {
                    if (dist[e.to] > dist[e.from] + e.cost) {
                        dist[e.to] = dist[e.from] + e.cost;
                        if (i >= N) {
                            dist[e.to] = Long.MIN_VALUE / 2;
                        }
                    }
                }
            }

            System.out.println(dist[N - 1] == Long.MIN_VALUE / 2 ? "inf" : -dist[N - 1]);
        };
    }

    static class Edge {
        int from;
        int to;
        long cost;

        public Edge(int from, int to, long cost) {
            this.from = from;
            this.to = to;
            this.cost = cost;
        }
    }
}

Measured memory_bytes: 31440
#import numpy as np
import sys, math
from itertools import permutations, combinations
from collections import defaultdict, Counter, deque
from math import factorial#, gcd
from bisect import bisect_left #bisect_left(list, value)
sys.setrecursionlimit(10**7)
enu = enumerate
MOD = 10**9+7
def input(): return sys.stdin.readline()[:-1]
pl = lambda x: print(*x, sep='\n')

N, K = map(int, input().split())
p = list(map(int, input().split()))
p.sort()

print(sum(p[:K]))



Measured memory_bytes: 67248
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int d[202020];
int main()
{
	int num, len, query;
	scanf("%d%d%d", &num, &len, &query);
	for (int i = 0; i < num; i++)scanf("%d", &d[i]);
	int mini = 2020202020;
	d[num] = -2020202020;
	for (int i = 0; i < num; i++)
	{
		int pt = 0;
		vector<int>v;
		for (int j = 0; j <= num; j++)
		{
			if (d[i] > d[j])
			{
				if (j - pt >= len)
				{
					vector<int>t;
					for (int k = pt; k < j; k++)t.push_back(d[k]);
					sort(t.begin(), t.end());
					for (int k = 0; k < j - pt - len + 1; k++)v.push_back(t[k]);
				}
				pt = j + 1;
			}
		}
		sort(v.begin(), v.end());
		if (v.size() >= query)mini = min(mini, v[query - 1] - v[0]);
	}
	printf("%d\n", mini);
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define rep(i,a,b,k) for(register ll i=a;i<=b;i+=k)
#define drep(i,a,b,k) for(register ll i=a;i>=b;i-=k)
#define ll long long
#define mod 1000000007
using namespace std;
char a[100005];
int len;
bool flag=1;
int main()
{
	cin>>a;
	len=strlen(a)-1;
	if(!(len&1))
		puts("No"),exit(0);
	for(int i=0,j=len;i<j;i++,j--)
	{
		if((a[i]=='p'&&a[j]=='q')||(a[i]=='q'&&a[j]=='p')||(a[i]=='d'&&a[j]=='b')||(a[i]=='b'&&a[j]=='d'));
		else
		{
			flag=0;
			break;
		}
	}
	if(flag)
		puts("Yes"),exit(0);
	puts("No");
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

int main()
{
  ll n,k,h[200000],ans;
  cin >> n >> k;
  ans=INF;
  rep(i,n)cin >> h[i];
  sort(h,h+n);
  rep(i,n-k+1)ans=min(ans,abs(h[i]-h[i+k-1]));
  printf("%lld",ans);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
#define No cout<<"No"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    int n,m;
    cin>>n>>m;
    cout<<(n-1)*(m-1)<<endl;
    return 0;
}


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

int main() {
	static char s[4];

	scanf("%s", s);
	if (strcmp(s, "SUN") == 0)
		printf("7\n");
	else if (strcmp(s, "MON") == 0)
		printf("6\n");
	else if (strcmp(s, "TUE") == 0)
		printf("5\n");
	else if (strcmp(s, "WED") == 0)
		printf("4\n");
	else if (strcmp(s, "THU") == 0)
		printf("3\n");
	else if (strcmp(s, "FRI") == 0)
		printf("2\n");
	else
		printf("1\n");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
map<LL,LL>u;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    string a,b;
    cin>>n>>m;
    for(i=0;i<m;i++)
    {
        cin>>p>>q;
        u[p]++;
        u[q]++;
    }
    for(i=1;i<=n;i++)
    {
        cout<<u[i]<<endl;
    }
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 100000
using namespace std;
char str[MAXN+5];
int main()
{
	memset(str,0,sizeof(str));
	scanf("%s",str);
	int len=strlen(str);
	for(int i=0;i<len;i++)
	{
		if(str[i]==str[i+1])
		{
			printf("%d %d\n",i+1,i+2);
			return 0;
		}
		else if(str[i]==str[i+2])
		{
			printf("%d %d\n",i+1,i+3);
			return 0;
		}
	}
	printf("-1 -1\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
using namespace std;
int main() {
	int N; 
	cin >> N; 
	set<int> A; 
	for(int i = 0; i < N; i++){
		int a; 
		cin >> a; 
		A.insert(a); 
	}
	int L = A.size(); 
	if(L % 2 == 1){cout << L << endl;}
	else{cout << L - 1 << endl;}
}

Measured memory_bytes: 4992
N = int(input())


if N%10 == 2 or N%10 == 4 or N%10 == 5 or N%10 == 7 or N%10 == 9:
    print("hon")
elif N%10 == 0 or N%10 == 1 or N%10 == 6 or N%10 == 8:
    print("pon")
else:
    print("bon")



Measured memory_bytes: 8988
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<bitset>
#include<vector>
#include<queue>
#include<ext/pb_ds/priority_queue.hpp>
#include<set>
#include<map>
#include<math.h>
#include<set>
#define maxn 500005
#define lson (now<<1)
#define rson ((now<<1)|1)
typedef long long ll;
using namespace std;
using namespace __gnu_pbds; 
struct nod
{
	int nl,nr,id;
	nod(){}
}query[maxn];
bool operator<(nod a,nod b)
{
	return a.nr<b.nr;
}
int lowbit(int now)
{
	return (now&(-now));
}
int a[maxn],p[maxn];
int dat[maxn],n,q;
void add(int pos,int val)
{
	for(int i=pos;i<=n;i+=lowbit(i))
		dat[i]+=val;
}
int que(int pos)
{
	int ans=0;
	for(int i=pos;i;i-=lowbit(i))
		ans+=dat[i];
	return ans;
}
int ans[maxn];
int main()
{
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	for(int i=1;i<=q;i++)
	scanf("%d%d",&query[i].nl,&query[i].nr),query[i].id=i;
	sort(query+1,query+1+q);
	int pre=0;
	for(int i=1;i<=q;i++)
	{
		for(int j=pre+1;j<=query[i].nr;j++)
		{
			if(p[a[j]]!=0)
				add(p[a[j]],-1);
			add(j,1);
			p[a[j]]=j;
		}
		pre=query[i].nr;
		ans[query[i].id]=que(query[i].nr)-que(query[i].nl-1);
	}
	for(int i=1;i<=q;i++)
	printf("%d\n",ans[i]);
}

Measured memory_bytes: 17404
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = (int)(n); i >= 0; i--)
#define REP(i, m, n) for (int i = (int)(m); i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;

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

  while(1){
    c -= b;
    if(c <= 0){
      cout << "Yes" << endl;
      return 0;
    }
    a -= d;
    if(a <= 0){
      cout << "No" << endl;
      return 0;
    }
  }

}


Measured memory_bytes: 3636
import sys
s = sys.stdin.readline() 

l = [0,0,0]
for i in range(3):
    if s[i] == "o":
        l[i] = 100
    elif s[i] == "x":
        l[i] = 0
goukei = 700+l[0]+l[1]+l[2]
print(goukei)




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

struct AB
{
  int a;
  int b;
};

int main()
{
  typedef long long ll;
  ll N, K;
  cin >> N >> K;
  vector<AB> ab(N);
  for (auto & _ab : ab)
    cin >> _ab.a >> _ab.b;
  sort(ab.begin(), ab.end(), [](auto & l, auto & r){return l.a < r.a;});
  ll i = 0, cnt = 0;
  for (; i < N; ++i)
  {
    cnt += ab[i].b;
    if (K <= cnt)
      break;
  }
  cout << ab[i].a;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

int const dxL[] = {-1,0,1,0};
int const dxR[] = {1,0,-1,0};
int const dy[]  = {0,-1,0,1};
typedef pair<int, int> Pii;
#define X first
#define Y second
int const INF = 1<<28;
int W, H;
char grL[51][51], grR[51][51];
bool used[2500][2500];
inline bool isValid(int x, int y) {
  if(0<=x&&x<W && 0<=y&&y<H) return true;
  return false;
}

inline bool inF(int x, int y, int isL) {
  if(isL) return grL[y][x]!='#';
  return grR[y][x]!='#';
}
inline int toNode(int x, int y) {
  return y*W+x;
}
inline void toPos(int node, int &x, int &y) {
  x = node%W, y = node/W;
}
int main() {
  
  while(cin >> W >> H && (W|H)) {
    int sxL, syL, sxR, syR;
    int gxL, gyL, gxR, gyR;
    for(int i=0; i<H; i++) {
      for(int j=0; j<2*W; j++) {
        if(j<W) {
          cin >> grL[i][j];
          if(grL[i][j] == 'L') {
            sxL = j, syL = i;
          }
          if(grL[i][j] == '%') {
            gxL = j, gyL = i;
          }
        }
        else {
          cin >> grR[i][j-W];
          if(grR[i][j-W] == 'R') {
            sxR = j-W, syR = i;
          }
          if(grR[i][j-W] == '%') {
            gxR = j-W, gyR = i;
          }
        }
      }
    }
    
    queue<Pii> que;
    que.push(make_pair(toNode(sxL, syL), toNode(sxR, syR)));
    bool ok = false;
    memset(used, false, sizeof used);
    while(!que.empty()) {
      const int nowL = que.front().first;
      const int nowR = que.front().second; que.pop();
      int lx, ly; toPos(nowL, lx, ly);
      int rx, ry; toPos(nowR, rx, ry);

      if(lx == gxL && ly == gyL && rx == gxR && ry == gyR) {
        ok = true; break;
      }
      
      if(lx == gxL && ly == gyL) continue;
      if(rx == gxR && ry == gyR) continue;
      
      for(int i=0; i<4; i++) {
        int nxL = lx+dxL[i], nyL = ly+dy[i];
        int nxR = rx+dxR[i], nyR = ry+dy[i];

        if(!isValid(nxL, nyL) || !inF(nxL, nyL, 1)) { nxL = lx, nyL = ly; }
        if(!isValid(nxR, nyR) || !inF(nxR, nyR, 0)) { nxR = rx, nyR = ry; }
        if(used[toNode(nxL, nyL)][toNode(nxR, nyR)]) continue;
        que.push(make_pair(toNode(nxL, nyL), toNode(nxR, nyR)));
        used[toNode(nxL, nyL)][toNode(nxR, nyR)] = true;
      }
    }
    if(ok) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 7784
# -*- coding: utf-8 -*-
S = list(input())

S2 = []
S2.append(S[0])
for i in range(1,len(S)):
    if S[i-1] != S[i]:
        S2.append(S[i])
    else:
        pass

# print(S2)
print(len(S2)-1)

Measured memory_bytes: 4648
h,w = map(int, input().split())
row = [False]*h
line = [False]*w
a = []
for i in range(h):
    A = input()
    a.append(A)

for i in range(h):
    for j in range(w):
        if a[i][j] == "#":
            row[i] = True
            line[j] = True

for i in range(h):
    if row[i]:
        for j in range(w):
            if line[j]:
                print(a[i][j], end = "")
        print()


Measured memory_bytes: 4468