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

// = = = Mint = = =
template<int64_t MOD> struct Mint {
    int64_t v;
    Mint() { v = 0; }
    Mint(int64_t x) { v = x % MOD; if(v < 0)  v += MOD; }

    Mint operator-() { return Mint{-v}; };
    Mint operator+(Mint x) { return Mint(v + x.v); };
    Mint operator-(Mint x) { return Mint(v - x.v); };
    Mint operator*(Mint x) { return Mint(v * x.v); };
    Mint operator/(Mint x) { return Mint(v * pow(x.v, MOD-2).v); };

    Mint& operator+=(Mint x) { return *this = (*this + x); };
    Mint& operator-=(Mint x) { return *this = (*this - x); };
    Mint& operator*=(Mint x) { return *this = (*this * x); };
    Mint& operator/=(Mint x) { return *this = (*this / x); };

    static Mint pow(Mint base, int64_t exp) {
        if(exp == 0)  return Mint(1);
        return pow(base*base, exp/2) * (exp&1 ? base : Mint(1));
    }

    friend ostream& operator<<(ostream& os, Mint x) { return os << x.v; }
};
using mint = Mint<1000000007>;
// = = = = = = = = = =

// = = = Counting = = =
template<class T> struct Counting {
    Counting(int64_t n) {
        _fact.assign(n+1, 1);
        for(int64_t i = 1; i <= n; i++)  _fact[i] = T(i) * _fact[i-1];
    }

    T fact(int64_t n) {
        assert(0 <= n && n < (int)_fact.size());
        return _fact[n];
    }

    T perm(int64_t n, int64_t k) {
        if(n < k)  return 0;
        return fact(n) / fact(n-k);
    }

    T comb(int64_t n, int64_t k) {
        if(n < k)  return 0;
        return fact(n) / (fact(k) * fact(n-k));
    }

    private:
        vector<T> _fact;
};
// = = = = = = = = = =

lint n, k;
struct vertex { vector<lint> edge; };
vector<vertex> g;
Counting<mint> mc(100000);

mint dfs(lint node, lint from) {
    mint res = 1;

    if(from == -1)  res *= mc.perm(k-1, g[node].edge.size());
    else            res *= mc.perm(k-2, g[node].edge.size()-1);

    for(auto& next : g[node].edge) {
        if(next == from)  continue;
        res *= dfs(next, node);
    }
    return res;
}

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

    g.resize(n);
    for(lint i = 0; i < n-1; i++) {
        lint a, b;
        cin >> a >> b;
        a--;  b--;
        g[a].edge.push_back(b);
        g[b].edge.push_back(a);
    }
    cout << mint(k) * dfs(0, -1) << endl;
}

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

int main () {
  int n;
  std::cin >> n;
  std::vector<int> a;
  for (int i = 0; i < n; i++)
  {
    int b;
    std::cin >> b;
    a.push_back(b);
  }
  std::reverse(a.begin(), a.end());
  for (int i = 0; i < n; i++) {
    if (i == n - 1) {
      std::cout << a[i];
    }
    else
    {
      std::cout << a[i] << " ";
    }
  }
  std::cout << std::endl;
  return 0;
}


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

int main()
{
    int n,m,i,x,y;
    cin>>n>>m;
    set<pair<int,int> >se;
    set<int>s;
    set<int>::iterator it;
    set<pair<int ,int> >::iterator it1;

    for(i=0;i<m;i++)
    {
        cin>>x>>y;
        if(x==1)
        {
            s.insert(y);
        }
        se.insert(make_pair(x,y));

    }
    for(it=s.begin();it!=s.end();it++)
    {
        x=*it;
        it1=se.find(make_pair(x,n));
        if(it1!=se.end())
        {
            cout<<"POSSIBLE";
            return 0;
        }
    }
    cout<<"IMPOSSIBLE";
    return 0;
}


Measured memory_bytes: 14336
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

S= one_str()

flg1=False
flg2=False
flg3=False
N=len(S)

if S==S[::-1]:
    flg1=True
    
flg2_s = S[:(N-1)//2]
if flg2_s == flg2_s[::-1]:
    flg2=True

flg3_s = S[(N+3)//2 -1:]
if flg3_s == flg3_s[::-1]:
    flg3=True

if flg1 and flg2 and flg3:
    print("Yes")
else:
    print("No")

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

const int inf = 55555;

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

	int num = 0;
	for(int i=6;i<inf;i+=5){
		bool prime = true;
		for(int j=2;j<i;j++){
			if(i % j == 0){
				prime = false;
				break;
			}
		}
		if(prime){
			cout << i << " ";
			num++;
		}
		if(num == n)
			break;
	}
	cout << endl;
}

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

using namespace std;

typedef long long int ll;

int main()
{
  	ll n,m;
  	cin >> n >> m;
  
  	ll ans1 = (n*(n-1))/2 , ans2 = (m*(m-1))/2;
  
  	cout << ans1+ans2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
int main(){
    int n; sc(n);
    ll ans = 0;
    for (int i = 1; i <= n; i++){
        if (i % 3 == 0) continue;
        if (i % 5 == 0) continue;
        if (i % 15 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3768
#include <stdio.h>

int main(void)
{
    int a, b, c, x;
    
    scanf("%d %d %d", &a, &b, &c);
    
    if (a > b)
    {
        x = a;
        a = b;
        b = x;
    }
    if (b > c)
    {
        x = b;
        b = c;
        c = x;
    }
    if (a > b)
    {
        x = a;
        a = b;
        b = x;
    }
    
    printf("%d %d %d\n", a, b, c);
    
    return 0;
}

Measured memory_bytes: 596
from math import sin, cos, pi
A, B, H, M = map(int, input().split())

Ax, Ay = cos(M / 30 * pi) * A, sin(M / 30 * pi) * A
Bx, By = cos((M + H * 60) / 360 * pi) * B, sin((M + H * 60) / 360 * pi) * B

print(((Ax - Bx) ** 2 + (Ay - By) ** 2) ** 0.5)


Measured memory_bytes: 9568
import java.util.Scanner;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N =sc.nextInt();
		int K =sc.nextInt();
		int[] A =new int[N];
		int L =0;
		int M =0;
		
		for(int i=0;i<N;i++){
			A[i] =sc.nextInt();
		}
		
		Arrays.sort(A);
		
		L = N-K;
		for(int i=L; i<N; i++){
			M += A[i];
		}
			System.out.println(M);
	}
}

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

using namespace std;

typedef long long ll;
const ll mod = 1e9 + 7;
int main() {
    ll n, m;
    cin >> n >> m;
    if (n < m) {
        swap(n, m);
    }
    if(n > m + 1) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 1;

    for (ll i = 1; i <= n; i++) {
        ans = (ans * i) % mod;
    }
      for (ll i = 1; i <= m; i++) {
        ans = (ans * i) % mod;
    }

    if(n == m) {
        ans = (2 * ans) % mod;
    }

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


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>
#include <numeric>
using lint = long long;

int main()
{
    lint h, w, k;
    scanf("%lld", &h);
    scanf("%lld", &w);
    scanf("%lld", &k);

    std::vector<std::vector<lint>> cake(h, std::vector<lint>(w, 0));
    std::vector<std::vector<lint>> ans(h, std::vector<lint>(w, 0));

    std::vector<lint> emp_row;

    for (int i = 0; i < h; ++i)
    {
        std::string s;
        std::cin >> s;
        for (int j = 0; j < w; ++j)
        {
            if (s[j] == '#')
            {
                cake[i][j] = 1;
            }
        }
    }

    lint st_num = 1;

    std::vector<lint> last_row;

    for (int i = 0; i < h; ++i)
    {
        lint row_st_num = std::accumulate(cake[i].begin(), cake[i].end(), 0);
        if (row_st_num == 0)
        {
            emp_row.push_back(i);
            continue;
        }

        std::vector<lint> ans_row(w, 0);
        lint first_st = 1;

        for (int j = 0; j < w; ++j)
        {
            if (cake[i][j] == 1)
            {
                if (first_st)
                {
                    first_st = 0;
                }
                else
                {
                    st_num++;
                }
            }
            ans_row[j] = st_num;
        }

        ans[i] = ans_row;
        last_row = ans_row;

        for (auto emp_row_num : emp_row)
        {
            ans[emp_row_num] = last_row;
        }

        emp_row.clear();
        st_num++;
    }
    for (auto emp_row_num : emp_row)
    {
        ans[emp_row_num] = last_row;
    }

    for (int i = 0; i < h; ++i)
    {
        for (int j = 0; j < w; ++j)
        {
            printf("%lld ", ans[i][j]);
        }
        printf("\n");
    }

    return 0;
}


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

n,m,q=map(int,input().split())
T=[]
for i in range(m):
    l,r=map(int,input().split())
    T.append([l-1,r-1])

C=[[0]*n for i in range(n)] #C[始点][終点]=個数
for t in T:
    C[t[0]][t[1]]+=1

A=[[0]*n for i in range(n)] #A[始点][終点]=区間内の合計
for i in range(1,n+1): #iは区間の長さ
    for j in range(n-i+1): #jからj+i-1まで
        if i==1:
            A[j][j]=C[j][j]
        elif i==2:
            A[j][j+1]=A[j][j]+A[j+1][j+1]+C[j][j+1]
        else:
            A[j][j+i-1]=A[j][j+i-2]+A[j+1][j+i-1]-A[j+1][j+i-2]+C[j][j+i-1]

for i in range(q):
    a,b=map(int,input().split())
    print(A[a-1][b-1])


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

using namespace std;

int main()
{
    ios_base::sync_with_stdio( false ), cin.tie( nullptr ), cout.tie( nullptr );
    
    int N, count; cin >> N, count = N;

    const auto operations = [] ( int t, const int k )
    {
        int u = 0;
    
        while( t > 0 )
            u += t % k, t /= k;
        
        return u;
    };
    
    for( int u = 0, v = N; u <= N; u++, v-- )
        count = min( count, operations( u, 6 ) + operations( v, 9 ) );
        
    cout << count;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod = 1000000007;
const long long INF = 1LL << 55;
const double EPS = 1e-10;

ull func(ull a, ull b)
{
    ull tmp;
    ull x = a * b;

    if (a < b)
    {
        tmp = a;
        a = b;
        b = tmp;
    }

    ull r = a % b;
    while (r != 0)
    {
        a = b;
        b = r;
        r = a % b;
    }

    return x / b;
}

int main()
{
    ull A, B;
    cin >> A >> B;

    cout << func(A, B) << endl;
}

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

const ll MAXN = 200000;

ll N, ans=0, tmp=0;
vector<pair<ll,ll>> PV, PV2;
vector<ll> A, B;

signed main(){
    cin >> N;
    for(int i=0;i<N;i++) {
        ll a,b;
        cin >> a >> b;
        A.push_back(a);
        B.push_back(b);
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    if(N%2==1) {
        cout << B[(N-1)/2]-A[(N-1)/2]+1 << endl;
    }
    else {
        cout << B[(N-1)/2]+B[(N-1)/2+1]-A[(N-1)/2]-A[(N-1)/2+1]+1 << endl;
    }
    return 0;
}

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

using namespace std;

struct INIT{INIT(){ios::sync_with_stdio(false);cin.tie(0);}}init;

typedef long long LL;

#define rep(i,n) for(auto i=(n)*0;i<n;i++)
#define range(it,v) for(auto &it:v)

int main(){
    LL N,X;
    cin>>N>>X;
    LL res=N;
    LL R=N-X,C=X;
    while(true){
	if(R>C){
	    if(R%C==0){
		res+=(R/C)*C*2-C;
		break;
	    }
	    res+=(R/C)*C*2;
	    R%=C;
	}
	else{
	    if(C%R==0){
		res+=(C/R)*R*2-R;
		break;
	    }
	    res+=(C/R)*R*2;
	    C%=R;
	}
	//cout<<R<<" " <<C<<endl;cout<<res<<endl;
    }
    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 256
import sys
N, W = map(int, input().split())
X =[[0,0]] + [list(map(int, input().split())) for _ in range(N)]
# dp[i][j] i番目までの荷物を用いて、持ち帰る重さがj以下にするときの価値の総和の最大値
dp = [[0]*(W+1) for _ in range(N+1)] 
for i in range(1,N+1):
  for j in range(1,W+1):
    if j < X[i][0]:
      dp[i][j] = dp[i-1][j]
    else:  
      dp[i][j] = max(dp[i-1][j],dp[i-1][j-X[i][0]]+X[i][1])
print(dp[N][W])


Measured memory_bytes: 150168
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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; }
template<class T> inline bool int_ceil(T a, T b) { T res = a / b; if(a % b != 0) res++; return res; }
template<typename T>
using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define print(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define print(...)
#endif

int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	char a; cin >> a;
	if(!islower(a)){
		cout << 'A' << endl;
	}
	else{
		cout << 'a' << endl;
	}

	return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

const int inf = 1012345678;

int main() {
  vi X(5); rep(i,X.size()) cin >> X.at(i);
  vi P = {0,1,2,3,4};
  
  int final_answer = inf;
  do {
    int ans = 0;
    rep(i,5) {
      while (ans%10 != 0) ans++;
      ans += X.at(P.at(i));
    }
    
    final_answer = min(final_answer, ans);
  }while (next_permutation(all(P)));
  
  cout << final_answer << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
      string[] str=Console.ReadLine().Split(' ');
      int X=int.Parse(str[0]);
      int Y=int.Parse(str[1]);
      Console.WriteLine(X+(Y/2));
    }
    
  }

}


Measured memory_bytes: 27480
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){

    ll n,a,b;
    string s;
    ll yos = 0;
    ll kai=0;
    cin >> n >> a >> b >> s;
    for(int i=0;i<n;i++){
        if(s.at(i)=='b')kai++;
        if(s.at(i)=='a'&&yos<a+b){
            yos++;
            cout << "Yes" << endl;
        }
        else if(s.at(i)=='b'&&yos<a+b&&kai<=b){
            yos++;
            cout <<  "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#include <list> 
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
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;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b;
	cin >> a >> b;
	for (ll i = a;;i += a) {
		if(i%b == 0){
			return cout << i << endl,0;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main(void){
    int n,v[100000],k=0,c=0;
    string s;
    cin>>s;
    n=s.length();
    fill(v, v+n, -1);
    for(int i=0;i<n;i++){
        /*
        for(int j=0;j<n;j++){
            if(v[j]!=-1)cout<<v[j];
            else j=n;
        }
        cout<<endl;*/
        int m=s[i]-'0';
        if(k==0){
            v[k]=m;
            k++;
        }else{
            if(v[k-1]==1-m){
                v[k-1]=-1;
                k--;
                c+=2;
            }else{
                v[k]=m;
                k++;
            }
        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 896
n = int(input())
a = list(map(int, input().split()))
b = sorted(a)
c = []

if a != b:
    for i in range(1, n+1):
        if a[i-1] != i:
            c.append(i-1)

        if len(c) == 2:
            break

    if len(c) == 2:
        ch = a[c[0]]
        a[c[0]] = a[c[1]]
        a[c[1]] = ch

    if a == b:
        print('YES')
    else:
        print('NO')
else:
    print('YES')

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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int N;
	cin >> N;
	int a1 = 0;
	int a2 = 0;
	int a3 = 0;
	int a4 = 0;
	int a5 = 0;
	int a6 = 0;
	int a7 = 0;
	int a8 = 0;
	int a9 = 0;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		if (a <= 399) {
			a1 = 1;
		}
		else if (a <= 799) {
			a2 = 1;
		}
		else if (a <= 1199) {
			a3 = 1;
		}
		else if (a <= 1599) {
			a4 = 1;
		}
		else if (a <= 1999) {
			a5 = 1;
		}
		else if (a <= 2399) {
			a6 = 1;
		}
		else if (a <= 2799) {
			a7 = 1;
		}
		else if (a <= 3199) {
			a8 = 1;
		}
		else {
			a9++;
		}
	}
	int f = a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8;
	if (a9 > 0) {
		if (f > 0) {
			cout << f << " " << f + a9;
		}
		else {
			cout << 1 << " " << a9;
		}
	}
	else {
		cout << f << " " << f;
	}
}

Measured memory_bytes: 256
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int days[1000][11][21];

int main(){
	int n,y,m,d;
	int year=999,month=10,day=20,cnt=1;
	while(year>=1 && month>=1 && day>=1){
		days[year][month][day]=cnt;
		cnt++;
		day--;
		if(day<=0){
			if(month==1){
				year--;
				month=10;
				if(year%3==0)day=20;
				else day=19;
			}else{
				month--;
				if(year%3==0){
					day=20;
				}else{
					if(month%2==1){
						day=20;
					}else{
						day=19;
					}
				}
			}
		}
	}
	cin>>n;
	rep(k,n){
		cin>>y>>m>>d;
		cout<<days[y][m][d]<<endl;
	}
	return 0;
}

Measured memory_bytes: 2060
#include <iostream>

using namespace std;

int main()
{
	int x, a, b;
	cin >> x >> a >> b;

	if (a >= b) {
		cout << "delicious" << endl;
	}
	else if (b - a <= x) {
		cout << "safe" << endl;
	}
	else {
		cout << "dangerous" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
while true
  n = gets.to_i
  break if n == 0

  a, b = 0, 0
  n.times do
    a_, b_ = gets.split.map(&:to_i)
    sum = a_ + b_
    if a_ > b_
      a += sum
    elsif b_ > a_
      b += sum
    else
      a += a_
      b += b_
    end
  end

  puts "#{a} #{b}"
end

Measured memory_bytes: 6104
import collections
N, M = [int(_) for _ in input().split()]
H = [int(_) for _ in input().split()]
I = [i for v, i in sorted([(v, i) for i, v in enumerate(H)], reverse=True)]
G = collections.defaultdict(set)
for _ in range(M):
    a, b = [int(_) for _ in input().split()]
    a -= 1
    b -= 1
    G[a].add(b)
    G[b].add(a)
visited = set()
ans = 0
for i in I:
    visited.add(i)
    f = True
    for j in G[i]:
        visited.add(j)
        if H[j] >= H[i]:
            f = False
    if f:
        ans += 1
print(ans)


Measured memory_bytes: 60688
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let it = stdin.lock().bytes().map(|c| c.unwrap() as char);
    let (fs, ft) = (|c: &char| c.is_whitespace(), |c: &char| !c.is_whitespace());
    let token = it.skip_while(fs).take_while(ft).collect::<String>();
    token.parse().ok().unwrap()
}
#[allow(dead_code)]
fn with_stdout_lock<F: FnOnce(std::io::BufWriter<std::io::StdoutLock>)>(f: F) {
    let out = std::io::stdout();
    f(std::io::BufWriter::new(out.lock()));
}
#[allow(unused_macros)]
macro_rules! debug {
    ($($var:expr),*) => { #[cfg(debug_assertions)] {
        $({ match &$var { v => eprint!("{}={:?} ", stringify!($var), v) } })*
        eprintln!();
    }};
}

fn main() {
    let n: usize = input();
    let m: usize = input();
    let xyz: Vec<(i64, i64, i64)> = (0..n).map(|_| (input(), input(), input())).collect();

    let mut ans = i64::min_value();
    for &i in &[1, -1] {
        for &j in &[1, -1] {
            for &k in &[1, -1] {
                let mut v: Vec<i64> = xyz.iter().map(|&(x, y, z)| i * x + j * y + k * z).collect();
                v.sort_by_key(|&v| -v);
                ans = std::cmp::max(ans, v.iter().take(m).sum());
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void)
{
	int s;
	int a[1024];
	int i,f;
	
	scanf("%d",&s);
	a[0]=s;
	for(i=0;i<1024;i++){
	if(a[i]%2==1){
	a[i+1]=3*a[i]+1;
	}else{
	a[i+1]=a[i]/2;
	}
	//printf("%d\n",a[i+1]);
	
	for(f=0;f<i;f++){
	if(a[f]==a[i]){
	printf("%d",i+1);
	return 0;
	}
	}
	
	}
}

Measured memory_bytes: 128
arr = 10.times.map{ Array.new(10){0} }
while gets do
  x, y, size = $_.split(",").map(&:to_i)
  drops = [[0, 0], [0,1], [1,0], [0,-1], [-1,0]]
  drops += [[1, 1], [1, -1], [-1, 1], [-1, -1]] if size>=2
  drops += [[2, 0], [0, 2], [-2, 0], [0, -2]] if size>=3
  drops.each do |dx, dy|
    nx, ny = x+dx, y+dy
    arr[nx][ny] += 1 if (0..9).include?(nx) && (0..9).include?(ny)
  end
end
puts arr.map{|i| i.count{|v| v == 0} }.inject(:+)
puts arr.map{|i| i.max}.max

Measured memory_bytes: 6116
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define rg register
#define ll long long
#define db double
#define N 200005
#define M 1005
using namespace std;
int a;char c[M];
inline void read(int &x)
{
	x=0;int f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c<='9'&&c>='0'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}
	x*=f;
}
int main()
{
	gets(c+1);int l=strlen(c+1)+1;
	while(l--){
		if(c[l]=='F') a=1;
		if(a==1&&c[l]=='C'){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<map>
using namespace std;
typedef pair<int,int> p;
typedef pair<int,p> P;//time,which,weight
int main(){
	P t[300];
	int n,a,b,c;
	while(cin>>n,n){
		for(int i=0;i<n;i++){
			cin>>a>>b>>c;
			t[i].second.second=a;
			t[i].first=b;
			t[i].second.first=1;
			t[i+n].second.second=a;
			t[i+n].first=c;
			t[i+n].second.first=0;
		}
		int now=0;
		sort(t,t+2*n);
		for(int i=0;i<2*n;i++){
			
			if(t[i].second.first)now+=t[i].second.second;
			else now-=t[i].second.second;
			
			if(now>150){
				cout<<"NG"<<endl;
				goto end;
			}
		}
		
		cout<<"OK"<<endl;
		
		end:;
		
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
	ll n,breakk=0,index=1;
	cin>>n;
	assert(n>=1 && n<=200000);
	ll arr[n];
	for(ll i=0;i<n;i++){
		cin>>arr[i];
		if(arr[i]!=index){
			breakk++;
		}
		else
			index++;
	}
	if(breakk==n)
		breakk=-1;
	cout<<breakk<<endl;
	return 0;
}


Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSet;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String w = scanner.nextLine();
        ArrayList<String> t = new ArrayList<String>();

        while (true) {
            String word = scanner.next();
            if (word.equals("END_OF_TEXT")) {
                break;
            }
            t.add(word.toLowerCase());
        }

        int count = 0;
        for (int i = 0; i < t.size(); i++) {
            if (t.get(i).equals(w)) {
                count++;
            }
        }
        System.out.println(count);
        scanner.close();
    }
}



Measured memory_bytes: 26208
N = int(input())
p = list(map(int, input().split()))
result = 0

for i in range(N - 2):
  if((p[i] < p[i + 1] and p[i + 1] < p[i + 2]) or (p[i] > p[i + 1] and p[i + 1] > p[i + 2])):
    result += 1

print(result)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)



int N, C, K;
int T[101010];
//-----------------------------------------------------------------
int sol() {
	int ans = -1;
	int limit = -1, cnt = 0;
	rep(i, 0, N) {
		if (limit < T[i]) {
			ans++;
			limit = T[i] + K;
			cnt = 1;
		} else {
			cnt++;
			if (C < cnt) {
				ans++;
				limit = T[i] + K;
				cnt = 1;
			}
		}
	}
	if (0 < cnt) ans++;
	return ans;
}
//-----------------------------------------------------------------
int main() {
	cin >> N >> C >> K;
	rep(i, 0, N) scanf("%d", &T[i]);
	sort(T, T + N);
	
	cout << sol() << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
vector <int> wa;
int ans;
int l[200000];
signed main(){
  int n;
  cin >> n;
  REP(i,n){
    cin >> l[i];
  }
  REP(i,n){
    for(int j=i+1;j<n;j++){
      wa.pb(l[i]+l[j]);
    }
  }
  sort(wa.begin(),wa.end());
  REP(i,n){
    int t = lower_bound(wa.begin(),wa.end(),l[i]+0.1)-wa.begin();
    //dump(t);
    ans += t;
  }
  cout << n*(n-1)*(n-2)/6-ans << endl;
  return 0;
}


Measured memory_bytes: 18792
use std::io::Read;

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

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: isize = iterator.next().unwrap().parse().unwrap();
    let b: isize = iterator.next().unwrap().parse().unwrap();

    let d: isize = (a - b).abs();
    if d % 2 != 0 {
        return "IMPOSSIBLE".to_string();
    }

    let k: isize = if a < b {
        a + d / 2
    } else {
        b + d / 2
    };

    return k.to_string();
}


Measured memory_bytes: 2124
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	a--; b--;
	vector<vector<char>> grid(100, vector<char>(100, '.'));
	rep(i,50)rep(j,100) grid[i][j] = '#';
	rep(i,50){
		if(i%2 != 0) continue;
		rep(j,100){
			if(j%2 == 0 && a > 0){
				grid[i][j] = '.';
				a--;
			}
		}
	}
	for(int i = 51; i < 100; i++){
		if(i%2 == 0) continue;
		rep(j,100){
			if(j%2 == 0 && b > 0){
				grid[i][j] = '#';
				b--;
			}
		}
	}
	cout << 100 << " " << 100 << endl;
	rep(i,100){
		rep(j,100) cout << grid[i][j];
		cout << endl;
	}
	return 0;
}

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

int main() {
  int n;
  cin >> n;
  
  for (int i = 3; i < n + 1; i++) {
    if ((i / 1000) % 10 == 3){
      cout << ' '<< i;
    }
    else if ((i / 100) % 10 == 3){
      cout << ' '<< i;
    }
    else if ((i / 10) % 10 == 3){
       cout <<' '<< i; 
    }
    else if (i  % 10 == 3){
       cout << ' '<< i; 
    }
    else if (i % 3 == 0){
      cout << ' '<< i;
    }
  }
  cout << endl;
}
      
      


Measured memory_bytes: 3096
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
using ll = long long;
const int maxn = 104;
const int INF = 0x3f3f3f3f;
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};

int m, n; char s[maxn][maxn];

void dfs(int x, int y, char c) {
    if(x < 0 || y < 0 || x >= m || y >= n)
        return;
    if(s[x][y] != c)
        return;
    s[x][y] = '0';
    for(int i = 0; i < 4; ++i) {
        int nx = x + dx[i];
        int ny = y + dy[i];
        dfs(nx, ny, c);
    }
}

int main() {
    while(~scanf("%d%d", &m, &n) && (n || m)) {
        for(int i = 0; i < m; ++i) {
            getchar();
            for(int j = 0; j < n; ++j) {
                s[i][j] = getchar();
            }
        }
        int ans = 0;
        for(int i = 0; i < m; ++i) {
            for(int j = 0; j < n; ++j) {
                if(s[i][j] != '0') {
                    dfs(i, j, s[i][j]);
                    ++ans;
                }
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}



Measured memory_bytes: 3052
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <set>
#include <map>
#include <tuple>
#include <string>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
// constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

int main() {
  size_t n;
  scanf("%zu", &n);

  std::vector<int> v(n);
  for (auto& vi: v) scanf("%d", &vi);

  int res = 1;
  for (size_t i = 1; i < n; ++i)
    if (v[i-1] >= v[i]) ++res;

  printf("%d\n%zu\n", res, n);
}



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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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


int main(void){

	int N, M; cin >> N >> M;
	if(M >= N) cout << "Yes" << endl;
	else cout << "No" << endl;
	


	return 0;

}


Measured memory_bytes: 764
using System;
using System.Linq;

class ITP1
{
    static void Main()
    {
                int a = int.Parse(Console.ReadLine());
                string[] num = Console.ReadLine().Split(' ');
                for(int i=1;i<=a;i++){
                    if (i == a)
                    {
                        Console.Write("{0}\n", num[a - i]);
                    }
                    else
                    {
                        Console.Write("{0} ", num[a - i]);
                    }
                }
    }
}

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

using namespace std;

int N;
int a[100];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    sort(a, a + N, greater<int>());
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (i % 2) ans -= a[i];
        else ans += a[i];
    }
    cout << ans << endl;
}

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

main(){
  int x;
  while(1){
    int sum=0;
    if(scanf("%d", &x)==EOF) break;
    sum+=x;
    for(int i=0;i<3;i++){
      cin >> x;
      sum+=x;
    }

    int num=sum/60;
    int min=(sum-num*60);
    printf("%d\n%d\n", num, min);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
int main(){
    int n,x;
    int cnt =0;
    int sum =0;
    std::cin >> n >> x;
    std::vector <int> v(0);
    for(int i=0; i<n; ++i){
        int temp;
        std::cin >> temp;
        v.push_back(temp);
    }
    for(int i=0; i<n; i++){
        sum += v[i];
        //std::cout << sum << ", "<< std::endl;
        if(sum > x){
            break;
        }
        cnt++;
    }
    std::cout << cnt+1 << std::endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mk make_pair
#define vp vector<pair<ll,ll> >
#define se second
#define fi first
#define vi vector<ll>
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define fab(i,a,b) for(ll i=a;i<=b;i++)
#define inp(n,a) for(ll i=0;i<n;i++){cin>>a[i];}
#define FASTER std::ios::sync_with_stdio(false)
#define DEBUG(x) cout<<#x<<" = "<<x<<endl
#define strToInt(x,z) istringstream y(x);y>>z  //(string,lleger)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) a*b / __gcd(a,b);
#define mod 1000000007
#define pi 3.14159265
using namespace std;
const long long  MOD =1000000007;

int main()
{
	//FASTER;
	long long n , a[1000010], pre[1000010];
	cin >> n;
	fab(i,1,n)cin >> a[i];

	//pre[1] = a[1];

	//fab(i,2,n)pre[i] = pre[i-1] + a[i];
	ll ans1 = 0, ans = 0;
	ll sum = 0;
	ll flag = 0;

		fab(i,1,n)
		{
			sum += a[i];

			if(i%2)
			{
				if(sum >= 0)
				{
					ans += (sum +1);
					sum  = -1;
				}
			}else
			{
				if(sum <= 0)
				{
					ans += -1*sum + 1;
					sum = 1;
				}
			}
			
		}
		
		 sum = 0;

		fab(i,1,n)
		{
			sum += a[i];

			//cout << "sum before =" << sum << endl;
			if(i%2 == 0)
			{
				if(sum >= 0)
				{
					ans1 += (sum +1);
					sum  = -1;
				}
			}else
			{
				if(sum <= 0)
				{
					ans1 += -1*sum + 1;
					sum = 1;
				}
			}
			//DEBUG(sum);
			//DEBUG(ans1);
		}
	
		//DEBUG(ans);DEBUG(ans1);


	cout << min(ans,ans1) <<endl;	
}

Measured memory_bytes: 2944
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

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

tree=UnionFind(N+1)

for _ in range(M):
    x,y=list(map(int,input().split()))

    tree.union(p[x-1],p[y-1])
ans=0

for i in range(1,N+1):
    if tree.same(i,p[i-1]):
        ans+=1

print(ans)

Measured memory_bytes: 88812
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

using ll = long long;

int N, K, A[202020], B[202020];

int main() {
    cin >> N >> K;
    for (int j = 0; j < N; ++j) {
        cin >> A[j];
        ++B[A[j]];
    }

    vector<pair<int, int>> v;
    for (int j = 1; j <= N; ++j) {
        if (B[j] > 0) v.emplace_back(B[j], j);
    }

    sort(begin(v), end(v));

    int ans = 0;
    int M = v.size();
    for (int j = 0; j < v.size() && M > K; ++j) {
        ans += v[j].first;
        --M;
    }

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


Measured memory_bytes: 3956
class Node:
    def __init__(self):
        self.parent = -1


def dfs(v, d=0):
    G[v].depth = d
    for child in G[v].children:
        dfs(child, d+1)


N = int(input())
G = [Node() for _ in range(N)]
for _ in range(N):
    idx, k, *children = [int(x) for x in input().split()]
    G[idx].children = children
    if k:
        G[idx].type = 'internal node'
    else:
        G[idx].type = 'leaf'
    for child in children:
        G[child].parent = idx
root = [i for i, x in enumerate(G) if x.parent == -1][0]
G[root].type = 'root'
dfs(root)
for i, node in enumerate(G):
    print('node {}: parent = {}, depth = {}, {}, [{}]'.format(i, node.parent, node.depth, node.type, ', '.join(map(str, node.children))))

Measured memory_bytes: 79752
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) sort(a.begin(), a.end())
#define rsort(a) sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
typedef long long unsigned int ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

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

  int N;
  cin >> N;
  if (N == 1) {
    cout << "Hello World" << endl;
  } else {
    int A, B;
    cin >> A;
    cin >> B;
    cout << A + B << endl;
  }

  return 0;
}


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

int main(){
 string s;
  cin>>s;
  string t="";
  for(int i=0;i<10;i++)
  {
    t+="hi";
    if(s==t){
      cout<<"Yes";
      return 0;
  }
  }
  cout<<"No";
    return 0;
  
}

Measured memory_bytes: 256
#![allow(dead_code)]
use std::io;

fn main() {
    solve_c();
}

fn solve_d() {
    let mut x = String::new();

    io::stdin().read_line(&mut x).unwrap();

    let v: Vec<u32> = x.trim()
        .split(' ')
        .map(|s| s.parse::<u32>().unwrap())
        .collect();

    let a = v[0];
    let b = v[1];
    let c = v[2];
    let mut count = 0;
    for i in a..(b + 1) {
        if (c % i) == 0 {
            count += 1;
        }
    }
    println!("{}", count);
}

fn solve_c() {
    loop {
        let mut x = String::new();
        io::stdin().read_line(&mut x).unwrap();

        let v: Vec<&str> = x.trim().split(' ').collect();

        let a = v[0].parse::<i64>().unwrap();
        let op = v[1].to_string();
        let b = v[2].parse::<i64>().unwrap();
        if op == "+".to_string() {
            println!("{}", a + b);
        } else if op == "-".to_string() {
            println!("{}", a - b);
        } else if op == "*".to_string() {
            println!("{}", a * b);
        } else if op == "/".to_string() {
            println!("{}", a / b);
        } else {
            break;
        }
    }
}

fn solve_b() {
    let mut x = String::new();
    io::stdin().read_line(&mut x).unwrap();
    let r = x.trim().parse::<f64>().unwrap();

    println!(
        "{:.6} {:.6}",
        r * r * std::f64::consts::PI,
        2_f64 * r * std::f64::consts::PI
    );
}

fn solve_a() {
    let mut x = String::new();
    io::stdin().read_line(&mut x).unwrap();

    let v: Vec<u64> = x.trim()
        .split(' ')
        .map(|s| s.parse::<u64>().unwrap())
        .collect();

    let a = v[0];
    let b = v[1];

    println!("{} {} {:.5}", a / b, a % b, a as f64 / b as f64);
}



Measured memory_bytes: 5032
function main(input){
    //input = "YAKINIKU";
    input = input +'';
    //console.log(input);


    var str = /^YAKI/;
    if(str.test(input))
        console.log("Yes");
    else
        console.log("No");
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 16076
n = int(input())
w = [input() for i in range(n)]
ok = "Yes"
e = w[0][-1]
double = [w[0]]
for i in range(1, n):
    if double.count(w[i]) != 0:
        ok = "No"
        break
    double.append(w[i])
    s = w[i][0]
    if s != e:
        ok = "No"
        break
    e = w[i][-1]
print(ok)


Measured memory_bytes: 38256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	int x = 0, ans = 0;
	REP(i, N) {
		if (S[i] == 'I') {
			x++;
		}
		else if (S[i] == 'D') {
			x--;
		}
		ans = max(ans, x);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
s = list(input())

def even_str(s):
    if len(s)%2 != 0:
        return False
    elif s[:len(s)//2] == s[len(s)//2:]:
        return True
    else:
        return False
for i in range(2, len(s), 2):
    if even_str(s[:-i]):
        print(len(s)-i)
        break

Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define pi 3.14159
using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e5 + 7, M = 1e7, OO = 0x3f3f3f3f;
#define AC ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin.sync_with_stdio(0);
int main()
{
int n,i,counter=0;
string s1,s2;
cin>>s1;
cin>>s2;
n=s1.size();
for(i=0;i<n;++i){
    if(s1[i]!=s2[i]){
        counter++;
    }
}
printf("%d\n",counter);


    return 0;
}


Measured memory_bytes: 3860
//raja1999
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16)a; cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 <<endl;prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
int main(){
	std::ios::sync_with_stdio(false);
	int a,b,val;
	cin>>a>>b;
	val=b-a;
	val*=(val+1);
	val/=2;
	val-=b;
	cout<<val<<endl;
} 
	

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

long long  N, K;

/*2*(a+b+c)はKの倍数であるが、Kが奇数なら、a+b+cもまたKの倍数　かつa+b, b+c, c+aは
Kの倍数なので、Kが奇数⇔a,b,cすべてKの倍数が成立*/
/*Kが偶数であるとき(a+b+c)はK/2の倍数であることがわかる。かつa+b,b+c,c+aもまたKの倍数であることがわかっているので、a,b,cはすべてKの倍数またはK/2の倍数であればよい*/

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

  long n = N/K;
  if(K & 1)  cout << n * n * n << endl;     //Kの倍数の全組み合わせ(順序あり集合)
  else{
      long m = (N+K/2) / K;                               //Kで割ってK/2余る値の個数を取得
      cout << n * n * n + m * m * m << endl;    //全部Kの倍数か、K/2の倍数でかつKの倍数でない値
  }

  return 0;
}
 

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N) cin>>A[i];

  vector<int> P(N+1,0);
  for(int i=0;i<N;i++){
      P[A[i]]=i;
  }

  ll ans=0;
  set<int> se;
  se.insert(-1);
  se.insert(N);
  for(int i=1;i<=N;i++){
      ll now=P[i];
      auto itr=se.upper_bound(now);
      ll r=*itr;
      itr--;
      ll l=*itr;
      se.insert(now);

      l++;
      r--;
      ans+=(now-l+1)*(r-now+1)*i;
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define ll long long
string s,t;
int ans=1001,tmp;
int main(){
    cin>>s>>t;
    for(int i=0;i<=s.size()-t.size();i++)
    {   tmp=0;
    	for(int j=0;j<t.size();j++)
    	{
    		if(s[i+j]!=t[j]) tmp++;
    	}
    	ans=min(tmp,ans);
    }
   cout<<ans;

	return 0;
}


Measured memory_bytes: 3604
#include <stdio.h>

int main(void) {
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	if(a>=0&&c<=100){
		if(a<b&&b<c) printf("Yes\n");
		else printf("No\n");
	}
	else printf("No\n");

	return 0;
}


Measured memory_bytes: 2040
a=list(map(int,input().split(' ')))
if a[0] < a[1]:
    if a[1] > a[2]:
        if a[0] < a[2]:
            temp = a[1]
            a[1] = a[2]
            a[2] = temp
        else:
            temp = a[0]
            a[0] = a[2]
            a[2] = a[1]
            a[1] = temp
    
else:
    if a[1] < a[2]:
        if a[0] < a[2]:
            temp = a[0]
            a[0] = a[1]
            a[1] = temp
        else:
            temp = a[0]
            a[0] = a[1]
            a[1] = a[2]
            a[2] = temp
    else:
        temp = a[0]
        a[0] = a[2]
        a[2] = temp
print(a[2]-a[0])

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <map>
#include <string>
#include <stdio.h>
#include <math.h>

using namespace std;

#define min(a,b) ((a) < (b)?(a):(b))
#define max(a,b) ((a) > (b)?(a):(b))

map<char, int>mp;

int main()
{	
	int n,odd = 0;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	{	
		cin>>arr[i];
		if(arr[i] % 2)
			odd++;
	}
	if(odd % 2)
		cout<<"NO";
	else
		cout<<"YES";
	return 0;	
}	







Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
typedef long long ll;
typedef pair<ll, ll> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll mod = 1000000007;

void solve()
{
	int n; cin >> n;
	map<string, int> s;
	rep(i,n)
	{
		string tmp;
		cin>>tmp;
		s[tmp]++;
	}
	int ma=0;
	for(auto e:s)chmax(ma,e.second);
	vector<string> sv;
	for(auto e:s)if(e.second==ma)sv.push_back(e.first);
	sort(all(sv));
	rep(i,sz(sv))cout << sv[i] << endl;
	return;	
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 25584