akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
static const int MAXSIZE = 200;

typedef struct {
	long long data[MAXSIZE];
	int top;
} Stack;

int pop(Stack * S)
{
	int ret_val = S->data[S->top]; 
	
	S->top--;
	
	return ret_val;
}

int push(Stack * S, long long x)
{
	S->top++;
	S->data[S->top] = x;
}

bool isEmpty(Stack * S)
{
	if (S->top == -1)
		return true;
	
	return false;
}

int main()
{
	Stack S;
	char str[MAXSIZE];
	long long n1, n2;	
	S.top = -1;
	
	//test-def
	//printf("%s", expression);
	//test-end
	
	while (scanf("%s", str) != EOF) {
		switch (str[0]) {
			case '+' :
				n1 = pop(&S);
				n2 = pop(&S);
				push(&S, n2+n1);
				break;
			case '-' :
				n1 = pop(&S);
				n2 = pop(&S);
				push(&S, n2-n1);
				break;
			case '*' :
				n1 = pop(&S);
				n2 = pop(&S);
				push(&S, n2*n1);
				break;
			default :
				push(&S, atoi(str));
				break;
		}
	}
	printf("%ld\n", pop(&S));
	
	return 0;
}


Measured memory_bytes: 2704
#include <iostream>
#include <sstream>  // istringstream
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;

int main()
{   
    int X, Y; 
    cin >> X >> Y;

    // Y は足の総数
    if (2 * X <= Y && Y <= 4 * X && Y % 2 == 0) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>
int main(void)
{
    int a=0;
    
    scanf("%d", &a);
    if(a%2==0){
    printf("%d",(a*a)/4);
    }
    if(a%2 == 1){
    printf("%d",((a*a)-1)/4);
    }
    return 0;
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            MainStream();
        }
        static void MainStream()
        {
            Scan sc = new Scan();
            write wr = new write();

            int n = sc.intarr[0];
            int[] array = sc.intarr;

            int count = 0;

            //偶数チェック機構
            while (true)
            {
                for (int i = 0; i < n; i++)
                {
                    if (array[i] % 2 != 0)
                    {
                        Console.WriteLine(count);
                        return;
                    }
                }

                for(int i=0; i<n; i++)
                {
                    array[i] = array[i] / 2;
                }
                count++;
            }
        }


    }

    class Scan
    {
        public string str => Console.ReadLine();

        public string[] strarr => str.Split(' ');

        public long[] longarr => strarr.Select(long.Parse).ToArray();
        public int[] intarr => strarr.Select(int.Parse).ToArray();
        public char[] chararr => str.ToArray();


    }



    class write
    {
        public void wri<Type>(Type x)
        {
            Console.WriteLine(x);
        }
    }

    class Method
    {
        static public int max(params int[] nums)
        {

            int maxx = nums[0];
            for (int i = 1; i < nums.Length; i++)
            {
                maxx = Math.Max(maxx, nums[i]);
            }
            return maxx;
        }
    }
}


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

int main(){
int n,flag=0;
cin>>n;
int ar[n];

for(int i=0;i<n;i++)
{
  cin>>ar[i];
    if (ar[i]%2==0) {
      if (ar[i]%3!=0 && ar[i]%5!=0) {
        flag=1;
      }
    }
}
if (flag==0) {
  cout << "APPROVED";
}
else
 cout << "DENIED";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>

using namespace std;

static const int N = 100;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
static const int INF = 1 << 30;

int n, M[N][N];
int color[N], d[N];


void dfs(int s){
    queue<int> q;
    q.push(s);
    for (int i = 0; i < n; ++i){
        d[i] = INF;
    }
    d[s] = 0;

    int u;
    while( !q.empty()){
        u = q.front();
        q.pop();
        for (int v = 0; v < n; ++v){
            if(M[u][v] ==0)
                continue;
            if( d[v] != INF)
                continue;
            d[v] = d[u] + 1;
            q.push(v);
        }
    }
    for (int i = 0; i < n; ++i){
        cout << i + 1 << " " << ((d[i] == INF) ? -1 : d[i] )<< endl;
    }
}

int main()
{
    int u, k, v;

    cin >> n;
    for (int i = 0; i < n; ++i){
        for (int j = 0; j < n; j++)
        {
            M[i][j] = 0;
        }
    }
    for (int i = 0; i < n; ++i){
        cin >> u >> k;
        for (int j = 0; j < k; ++j){
            cin >> v;
            M[u - 1][v - 1] = 1;
        }
    }

    dfs(0);

    return 0;
}


Measured memory_bytes: 3116
#include <stdio.h>

int main(void){
  int a,b,c,pool=0;
  
  scanf("%d %d %d",&a,&b,&c);
   
  if((a==b && b!=c)||(b==c && c!=a)||(c==a && a!=b)){
    pool = 1;
  }
 
    if(pool==1){
      printf("Yes\n");
    }
    else{
      printf("No\n");
    }
  return 0;
}

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

using namespace std;

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

    // aaはアンバランス
    for (int i = 0; i + 1 < s.size(); i++) {
        if (s[i] == s[i + 1]) {
            cout << i + 1 << " " << i + 2 << endl;
            return 0;
        }
    }

    // abaはアンランス。aaaもアンバランス
    for (int i = 0; i + 2 < s.size(); i++) {
        if (s[i] == s[i + 2]) {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }

    cout << -1 << " " << -1 << endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<stdlib.h>
using namespace std;
main(){
  int n,m;
  int kyori[100001]={0};
  int idou,now=1;
  long long int kiokufront[100001]={0};
  long long int kiokuback[100001]={0};
  long long int count=0;
  long long int zentai=0;
  cin>>n>>m;
  for(int i=2;i<=n;i++){
    cin>>kyori[i];
    kiokufront[i]=kiokufront[i-1]+kyori[i];
    zentai=zentai+kyori[i];
  }
  for(int i=n-1;i>=1;i--){
    kiokuback[i]=kiokuback[i+1]+kyori[i+1];
  }
  for(int i=0;i<m;i++){
    cin>>idou;
    count=count+labs(zentai-(kiokufront[now]+kiokuback[now+idou]));
    //cout<<count<<" "<<labs(zentai-(kiokufront[now]+kiokuback[now+idou]))<<endl;
    //cout<<kiokufront[now]<<" "<<kiokuback[now+idou]<<endl;
    //cout<<now<<" "<<now+idou<<endl;
    now=now+idou;
  }
  cout<<count%100000<<endl;
}

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

void solve() {
	double l;
	cin>>l;
	double ans = l/3;
	cout<<pow(ans, 3)<<"\n";
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    cout<<fixed;
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
string a[7]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main(void){
    string s;cin>>s;
    rep(i,7){
        if(a[i]==s){
            cout<<7-i<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
L, R = {}, {}
for n in range(N):
    L[n + A[n]] = L.get(n + A[n], 0) + 1
    R[n - A[n]] = R.get(n - A[n], 0) + 1
print(sum([R.get(k, 0) * v for k, v in L.items()]))


Measured memory_bytes: 56760
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n;
    int k;
    cin>>n>>k;
    int dp[100][3];
    for(int i=0;i<n;i++){
        for(int ii =0;ii<3;ii++){
            dp[i][ii] = 0;
        }
    }
    for(int i=0;i<k;i++){
        int a;
        int b;
        cin>>a>>b;
        dp[a-1][0] = -1;
        dp[a-1][1] = -1;
        dp[a-1][2] = -1;
        dp[a-1][b-1] = 0;
    }
    for(int i= 0; i<n;i++){
        for(int ii= 0;ii<3;ii++){
             
            if(dp[i][ii] == -1){
                dp[i][ii] = 0;
            }else{
                if(i==0)dp[i][ii]=1; 
                if(i!=0)dp[i][ii]=dp[i-1][0]+dp[i-1][1]+dp[i-1][2];
    if(i>=2){
        if(dp[i-1][ii]>0)
        dp[i][ii] = dp[i-2][0]+dp[i-2][1]+dp[i-2][2]-dp[i-2][ii]+dp[i-1][0]+dp[i-1][1]+dp[i-1][2]-dp[i-1][ii];
    }
            }
            dp[i][ii]= dp[i][ii]%10000;
        }
    }
    int res = dp[n-1][0]+dp[n-1][1]+dp[n-1][2];
    res = res%10000;
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 1164
import sys

n, k = (int(x) for x in sys.stdin.readline().split())
a_b_list = [[int(x) for x in sys.stdin.readline().split()] for y in range(n)]
a_b_list.sort(key=lambda x: x[0])
total_index = 0
for i in a_b_list:
    total_index += i[1]
for i in reversed(a_b_list):
    start = total_index
    end = total_index - i[1] + 1
    if start >= k >= end:
        print(i[0])
        sys.exit(0)
    total_index -= i[1]


Measured memory_bytes: 22912
H, W = map(int, input().split())
N, = map(int, input().split())
As = list(map(int, input().split()))
c = 1
r = [[0]*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        if i%2:
            r[i][j] = c
        else:
            r[i][W-j-1] = c
        As[c-1] -= 1
        if As[c-1] == 0:
            c += 1

for i in range(H):
    print(*r[i])


Measured memory_bytes: 42224
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#define go(i,a,b) for(int i=a;i<=b;i++)
#define og(i,a,b) for(int i=a;i>=b;i--)
#define mem(a,b) memset(a,b,sizeof(a))
#define Pi acos(-1)
#define eps 1e-8
using namespace std;
typedef long long int ll;
const int maxn=2*1e5+5;
const ll inf=0x3f3f3f3f;
const int mod=1e9+7;
multiset <int> s;
int main()
{
    int n; scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        int x; scanf("%d",&x);
        s.insert(x);
    }
    int ans=0;
    while(!s.empty())
    {
        multiset <int> ::iterator it=s.end();
        it--;
        int x=*it;
        s.erase(it);
        for(n=1;n<=x;n*=2);
        if(s.find(n-x)!=s.end())
            ans++,s.erase( s.find(n-x) );
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 9600
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

#define MAX 210

signed main() {
	//??????dp A<=??????<=B?????¨??? dp[i??\???][j????????????] ?????????
	int D, N; cin >> D >> N;
	int T[MAX] = {};
	rep(i, 0, D)cin >> T[i];
	int A[MAX], B[MAX], C[MAX];
	rep(j, 0, N)cin >> A[j] >> B[j] >> C[j];
	int dp[MAX][MAX] = {};
	fill(dp[0], dp[MAX], -1);
	rep(j, 0, N) {
		if (T[0] < A[j] || B[j] < T[0])continue;
		dp[1][j] = 0;
	}
	rep(i, 1, D) {
		rep(j, 0, N) {
			if (T[i] < A[j] || B[j] < T[i])continue;
			rep(k, 0, N) {
				if (dp[i][k] == -1)continue;
				dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + abs(C[j] - C[k]));
			}
		}
	}
	cout << *max_element(dp[D], dp[D] + MAX) << endl;;
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    int cnt_4 = 0, cnt_2 = 0;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        if (a % 4 == 0) cnt_4++;
        else if (a % 2 == 0) cnt_2++;
    }

    if (cnt_4 + (cnt_2 / 2) >= N / 2)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int,input().split())
arr = [0]*K
ans = 0
for i in range(1,N+1):
    arr[i%K] += 1
for a in range(K):
    b = (K-a) % K
    c = (K-a) % K
    if (b+c) % K == 0:
        ans += arr[a] * arr[b] * arr[c]
print(ans)

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

int main() {
      int a,b,c;
      cin>>a>>b>>c;
    if(a<=c&&c<=b){
      cout<<"Yes"<<endl;
}
    else if( b<=c&&c<=a){
 cout<<"Yes"<<endl;
}
else{  
cout<<"No"<<endl;
}

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <chrono>
#include <random>

using namespace std;

#define int long long
#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 32;
const int MOD = 998244353;

bool check(int n, int k) {
    while (n % k == 0) n /= k;
    n %= k;
    return n == 1;
}

void solve() {
    int n;
    cin >> n;
    if (n == 2) {
        cout << 1;
        return;
    }
    int x = n - 1;
    int ans = 1;
    for (int d = 2; d * d <= x; d++) {
        if (x % d == 0) ans++;
        if (x % d == 0 && d != x / d) ans++;
    }
    for (int d = 1; d * d <= n; d++) {
        if (n % d == 0) {
            if (d != 1 && check(n, d)) ans++;
            if (d != n / d && check(n, n / d)) ans++;
        }
    }
    cout << ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //int t;
    // cin >> t;
    int t = 1;
    while (t--) solve();
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline
sys.setrecursionlimit(10 ** 8)
from itertools import accumulate
from itertools import permutations
from itertools import combinations
from collections import defaultdict
from collections import Counter
import fractions
import math
from collections import deque
from bisect import bisect_left
from bisect import bisect_right
from bisect import insort_left
import itertools
from heapq import heapify
from heapq import heappop
from heapq import heappush
import heapq
from copy import deepcopy
from decimal import Decimal
alf = list("abcdefghijklmnopqrstuvwxyz")
ALF = list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
#import numpy as np
INF = float("inf")
#d = defaultdict(int)
#d = defaultdict(list)
N,M,C = map(int,input().split())
B = list(map(int,input().split()))
A = [list(map(int,input().split())) for _ in range(N)]
ans = 0 
for i in range(N):
    s = 0
    for j in range(M):
        s += A[i][j]*B[j]
    s += C
    if s > 0:
        ans += 1
print(ans)

Measured memory_bytes: 10584
#include<bits/stdc++.h>
using namespace std;
#define nn 65536*8
#define lln (16+3+1-1)
#define lf double 
#define ll long long
#define mod 924844033
#define g 5
ll qpow(ll x,ll y)
{
	if(y<0) y+=mod-1;
	ll res=1;
	while(y)
	{
		if(y&1) res=res*x%mod;
		x=x*x%mod;y=y/2;
	}
	return res;
}
ll pos[nn*2];
void ntt(ll a[],ll cid)
{
	for(ll i=0;i<nn*2;i++) if(pos[i]>i)swap(a[pos[i]],a[i]);
	for(ll p=1;p<nn*2;p<<=1)
	{
		ll m=p+p;
		ll w=qpow(g,(mod-1)/m*cid);
		for(ll i=0;i<nn*2;i+=m)
		{
			ll wx=1;
			for(ll j=0;j<p;j++,wx=wx*w%mod)
			{
				ll c1=a[i+j],c2=a[i+j+p]*wx%mod;
				a[i+j]=(c1+c2)%mod,a[i+j+p]=(c1-c2)%mod;
			}
		}
	}
}
ll n;
vector<ll> v[nn*2];ll siz[nn*2];ll a[nn*2];
void dfs(ll x,ll p)
{
	siz[x]=1;
	for(ll i=0;i<(ll)v[x].size();i++) if(v[x][i]!=p) dfs(v[x][i],x),siz[x]+=siz[v[x][i]],a[siz[v[x][i]]]++;
	a[n-siz[x]]++;
}
ll A[nn*3],B[nn*3],C[nn*3];
ll f[nn*2],rf[nn*2];
ll c(ll x,ll y)
{
	if(x>y) return 0;
	return f[y]*rf[x]%mod*rf[y-x]%mod;
}
int main()
{
	f[0]=1;for(ll i=1;i<nn;i++) f[i]=f[i-1]*i%mod;
	rf[nn-1]=qpow(f[nn-1],mod-2);for(ll i=nn-2;i>=0;i--) rf[i]=rf[i+1]*(i+1)%mod;
	scanf("%lld",&n);
	for(ll i=1;i<n;i++)
	{
		ll x,y;scanf("%lld%lld",&x,&y);
		v[x].push_back(y);v[y].push_back(x);
	}
	dfs(1,0);
	
	for(ll i=0;i<nn/2;i++) A[i+nn/2]=a[i]*f[i]%mod;
	for(ll i=0;i<nn/2;i++) B[nn/2-i]=rf[i];//cout<<B[0];
//	for(ll i=0;i<8;i++) cout<<A[i+nn/2+1]<<"*"<<B[nn/2-i]<<"\n";
	for(ll i=0;i<nn*2;i++)
		pos[i]=(((pos[i>>1])>>1)+(((i&1)<<lln)));
	ntt(A,1);ntt(B,1);
	for(ll i=0;i<nn*2;i++) C[i]=A[i]*B[i]%mod;
	ntt(C,-1);
	ll r=qpow(nn*2,mod-2);
	for(ll i=0;i<nn*2;i++) C[i]=C[i]*r%mod;
	//	cout<<C[nn/2*2]<<" ";


	for(ll i=1;i<=n;i++) printf("%lld\n",((n*c(i,n)%mod-C[nn/2*2+i]*rf[i]%mod)%mod+mod)%mod);
}

Measured memory_bytes: 99328
#include <iostream>

int main() {
    int A, B;
    std::cin >> A >> B;
    
    if (A == B) 
        std::cout << A*2 << std::endl;
    else if (A > B)
        std::cout << A*2-1 << std::endl;
    else
        std::cout << B*2-1 << std::endl;
}

Measured memory_bytes: 256
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/07/25.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

ll rec(string S, int len, int N);
int num(string S, int len);
int cnum(char c);

vector<ll> table;

int main()
{
    table.assign(4*4*4*400, -1);
    
    int N;
    cin >> N;
    
    cout << rec("", 0, N) % (ll)(pow(10,9) + 7) << endl;
    
    return 0;
}

ll rec(string S, int len, int N)
{
    if(len==N) return 1;
    
    int n = num(S, len);
    if(table[n] >= 0) return table[n];
    
    ll ans = 0;
    string sub2;
    // string sub2,sub3;
    if(len >= 3)
    {
        sub2 = S.substr(1,2);
        // sub2 = S.substr(len-2, 2);
        // sub3 = S.substr(len-3, 3);
        ans += rec(sub2 + 'A', len + 1, N);
        if(sub2 != "AG" && sub2 != "GA" && !(S[0] == 'A' && S[1] == 'G') && !(S[0] == 'A' && S[2] == 'G') )
            ans += rec(sub2 + 'C', len + 1, N);
        if(sub2 != "AC")
            ans += rec(sub2 + 'G', len + 1, N);
        ans += rec(sub2 + 'T', len + 1, N);
    }
    else if(len >= 2)
    {
        // sub2 = S.substr(len-2, 2);
        ans += rec(S + 'A', len + 1, N);
        if(S != "AG" && S != "GA")
            ans += rec(S + 'C', len + 1, N);
        if(S != "AC")
            ans += rec(S + 'G', len + 1, N);
        ans += rec(S + 'T', len + 1, N);
    }
    else
    {
        ans += rec(S + 'A', len + 1, N);
        ans += rec(S + 'C', len + 1, N);
        ans += rec(S + 'G', len + 1, N);
        ans += rec(S + 'T', len + 1, N);
    }
    
    return table[n] = ans % (ll)(pow(10,9) + 7);
}

// 3桁までの文字列 → 数字
int num(string S, int len)
{
    int size = (int)S.length();
    int ans = 0;
    for(int i= 0; i < size; i++)
    {
        ans += pow(4,size - i - 1) * cnum(S[i]);
    }
    ans += pow(4, 3) * len;
    return ans;
}

int cnum(char c)
{
    switch (c) {
        case 'A':
            return 0;
            break;
        case 'C':
            return 1;
            break;
        case 'G':
            return 2;
            break;
        case 'T':
            return 3;
            break;
            
        default:
            return -1;
            break;
    }
}


Measured memory_bytes: 512
def right(a,n):
    sw = [0]*(n+1)
    for x,y in enumerate(a):
        x_min = max(0,x-y)
        x_max = min(n,x+y+1)
        sw[x_min] += 1
        sw[x_max] -= 1
    s = 0
    for i in range(n):
        s += sw[i]
        a[i] = s
    return a

n,k = map(int,input().split())
a = list(map(int,input().split()))
for i in range(min(k,50)):
    a = right(a,n)
a = [str(n) for n in a]
print(" ".join(a))

Measured memory_bytes: 171996
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using static MyIO;


public class A
{
	public static void Main()
	{
		Console.WriteLine(Math.Max(GetInt() * GetInt(), GetInt() * GetInt()));
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}

Measured memory_bytes: 11092
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
using namespace std;

int main(){
	int N, max = 0;
	string S;
	cin >> N;
	S.reserve(N);

	cin >> S;	

	for (int i = 1; i < N; ++i){
		string tmp;
		string::iterator itr;
		int count = 0;
		for (int j = 0; j < i; ++j){
			itr = find(tmp.begin(), tmp.end(), S[j]);
			if (itr == tmp.end()){
				tmp.push_back(S[j]);
			}
		}
		for (int j = i; j < N; ++j){
			itr = find(tmp.begin(), tmp.end(), S[j]);
			if (itr != tmp.end()){
				++count;
				tmp.erase(itr);
			}
		}

		if (count > max)
			max = count;
	}

	cout << max << endl;
	return 0;
}

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

int h, w, a, b;

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

  cin >> h >> w >> a >> b;
  vector<vector<int>> board(h, vector<int>(w));

  vector<int> b0(w, 0), b1(w, 0);

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      board.at(i).at(j) = 0;
    }
  }

  for (int i = 0; i < h; i++) {
    int countA = 0;
    for (int j = 0; j < w; j++) {
      if (countA >= a) break;
      board.at(i).at(j) = 1;
      b1.at(j)++;
      countA++;
    }
  }

  for (int i = 0; i < b; i++) {
    for (int j = 0; j < w; j++) {
      board.at(i).at(j) = board.at(i).at(j) == 1 ? 0 : 1;
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cout << board.at(i).at(j);
    }
    cout << endl;
  }

  return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define lld long double
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

signed main(){

	string s;
	string t;

	cin>>s>>t;

	set<string> ans;

	REP(i,0,s.size()){
		bool ok = true;
		REP(j,0,t.size()){
			if(i+j>=s.size()){
				ok=false;
				break;
			}
			if(s.at(i+j)=='?')continue;
			if(s.at(i+j)!=t.at(j)){
				ok=false;
				break;
			}
		}
		if(ok){
			if(DEBUG)cout<<"i="<<i<<endl;
			string rtn="";
			REP(j,0,s.size()){
				//cout<<rtn<<endl;
				if(j<i|| (i+t.size())<=j){
					if(DEBUG)cout<<"a"<<endl;
					if(s.at(j)=='?')rtn.push_back('a');
					else rtn+=s.at(j);
				}
				else{
					if(DEBUG)cout<<"b"<<endl;
					rtn += t.at(j-i);
				}
			}
			//ans.insert(s.substr(0,i)+t+s.substr(i+t.size()));
			ans.insert(rtn);
		}
	}

	if(ans.size()){
		auto itr = ans.begin();
		cout<<(*itr)<<endl;
	}
	else{
		cout<<"UNRESTORABLE"<<endl;
	}

	return 0;
}

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

int S[400][400];
bool used[400][400];
struct place{ int y,x,c; };
int dx[4] = {0,1,0,-1},dy[4] = {1,0,-1,0};

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int H,W; cin >> H >> W;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      char c; cin >> c;
      if(c == '.') S[i][j] = -1; //白
      else S[i][j] = 1; //黒
    }
  }

  int ans = 0;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(S[i][j] == -1 || used[i][j]) continue;

      queue<place> q;
      q.push({i,j,1});
      int b = 0,w = 0;
      while(!q.empty()){
        place p = q.front();
        q.pop();
        if(used[p.y][p.x]) continue;
        used[p.y][p.x] = 1;
        if(S[p.y][p.x] == 1) b++;
        else w++;
        for(int k = 0; k < 4; k++){
          int ny = p.y+dy[k];
          int nx = p.x+dx[k];
          if(0 <= ny && ny < H && 0 <= nx && nx < W){
            if(S[ny][nx] == -p.c){
              q.push({ny,nx,-p.c});
            }
          }
        }
      }
      ans += b * w;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#define sqr(x) (x)*(x)
using namespace std;
int n,m,x,y,i,j,ans[300005],ss[300005];
bool check()
{
	vector<int> a,b;
	int i;
//	cerr<<endl;
	for (i=1;i<=n;i++)
	{
		if (a.empty()||a.back()<ans[i]) a.push_back(ans[i]); else *(upper_bound(a.begin(),a.end(),ans[i]))=ans[i];
		if (b.empty()||b.back()<-ans[i]) b.push_back(-ans[i]); else *(upper_bound(b.begin(),b.end(),-ans[i]))=-ans[i];
//		cerr<<a.size()<<' '<<b.size()<<endl;
//		cerr<<a.back()<<' '<<b.back()<<endl;
	}
	return a.size()==x&&b.size()==y;
}
void print()
{
	for (i=1;i<=n;i++) cout<<ans[i]<<' ';
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin>>n>>x>>y;
	if (x+y-1>n)
	{
		cout<<-1;
		return 0;
	}
	if (x+y-1==n)
	{
		for (i=1;i<x;i++) cout<<i<<' ';
		for (i=n;i>=x;i--) cout<<i<<' ';
		return 0;
	}
	if (x==1)
	{
		cout<<-1;
		return 0;
	}
	if (y==1)
	{
		cout<<-1;
		return 0;
	}
	int a,cnt,b,c,bck;
	a=n+1-x-y;b=y-1;c=x;cnt=0;
	for (i=a+b+1;i<=n;i++) ans[i]=++cnt;
	for (i=1;i<=a;i++) ans[i]=++cnt;
	for (i=a+b;i>a;i--) ans[i]=++cnt;
	if (check()){print();return 0;}
	a=n+1-x-y;b=x-1;c=y;cnt=0;
	for (i=a+1;i<=a+b;i++) ans[i]=++cnt;
	for (i=a;i;i--) ans[i]=++cnt;
	for (i=n;i>a+b;i--) ans[i]=++cnt;
	if (check()){print();return 0;}
	a=x-2;b=y;c=n+2-x-y;cnt=0;
	for (i=1;i<=a;i++) ans[i]=++cnt;
	for (i=a+b;i>a;i--) ans[i]=++cnt;
	for (i=n;i>a+b;i--) ans[i]=++cnt;
	a=x-2;b=y;c=n+2-x-y;cnt=0;
	for (i=1;i<=a;i++) ans[i]=++cnt;
	for (i=a+b;i>a;i--) ans[i]=++cnt;
	for (i=n;i>a+b;i--) ans[i]=++cnt;
	if (check()){print();return 0;}
	a=n+1-x-y;b=y;c=x-1;cnt=0;
	for (i=a+b+1;i<=n;i++) ans[i]=++cnt;
	for (i=1;i<=a;i++) ans[i]=++cnt;
	for (i=a+b;i>a;i--) ans[i]=++cnt;
	if (check()){print();return 0;}
	a=n+1-x-y;b=x;c=y-1;cnt=0;
	for (i=a+1;i<=a+b;i++) ans[i]=++cnt;
	for (i=a;i;i--) ans[i]=++cnt;
	for (i=n;i>a+b;i--) ans[i]=++cnt;
	if (check()){print();return 0;}
	cnt=0;bck=0;
	//for (j=min(n,i+y-1);j>=i;j--) ans[j]=++cnt;
	memset(ss,0,sizeof(ss));
	for (i=1;i<=n;i+=y)
	{
		bck++;
		for (j=min(n,i+y-1);j>=i;j--) ss[bck]++;
	}
	int i=1;
	while (bck<x)
	{
		if (i>bck) break;
		if (ss[i]>1)
		{
			ss[i]--;
			bck++;
			ss[bck]=1;
		}
		else i++;
	}
	for (i=1;i<=n;i+=ss[bck+1])
	{
		for (j=min(n,i+ss[bck]-1);j>=i;j--) ans[j]=++cnt;
		bck--;
	}
	if (check()){print();return 0;}
	/*cnt=0;
	for (i=n;i>=0;i-=x)
	{
		for (j=max(1,i-x+1);j<=i;j++) ans[j]=++cnt;
	}
	if (check()){print();return 0;}*/
	/*b=y-1;c=x;
	if (a+1<=x)
	{
		for (i=a+b+1;i<=n;i++) ans[i]=++cnt;
		for (i=1;i<=a;i++) ans[i]=++cnt;
		for (i=a+b;i>a;i--) ans[i]=++cnt;
		for (i=1;i<=n;i++) cout<<ans[i]<<' ';
		return 0;
	}
	b=x-1;c=y;
	if (a+1<=y)
	{
		for (i=a+1;i<=a+b;i++) ans[i]=++cnt;
		for (i=a;i;i--) ans[i]=++cnt;
		for (i=n;i>a+b;i--) ans[i]=++cnt;
		for (i=1;i<=n;i++) cout<<ans[i]<<' ';
		return 0;
	}*/
	cout<<-1;
	return 0;
}

Measured memory_bytes: 5316
from collections import deque

S = input()
Q = int(input())
right, left = deque(), deque()
right_inv, left_inv, S_inv = False, False, False

for q in range(Q):
  T = input().split(" ")
  if len(T) == 1:
    # reverse
    S_inv = not S_inv
    right_inv = not right_inv
    left_inv = not left_inv
  else:
    # append
    F, C = int(T[1]), T[2]
    if F == 1:
      if S_inv:
        # add right
        right.append(C)
      else:
        # add left
        left.appendleft(C)
    else:
      if S_inv:
        # add left
        left.appendleft(C)
      else:
        # add right
        right.append(C)

if S_inv:
  print(''.join(list(right)[::-1]), S[::-1], ''.join(list(left)[::-1]), sep='')
else:
  print(''.join(list(left)), S, ''.join(list(right)), sep='')

Measured memory_bytes: 6772
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int people[100010] = {0};

int main()
{
    int N, K;
    char c;
    cin >> N >> K;
    for (int i = 0; i < N; i++)
    {
        cin >> c;
        if (c == '0')
            people[i] = 0;
        else
            people[i] = 1;
    }

    int r_begin = 0, i = 0, r_end;
    vector <pair<int ,int> > record;
    while(i < N)
    {
        if (people[i] ==0)
        {
            while (i < N && people[i] == 0)
            {
                i++;
            }
            int next_begin = i;
            while (i < N && people[i] == 1)
            {
                i++;
            }
            i--;
            r_end = i;
            record.push_back(make_pair(r_begin, r_end));
            r_begin = next_begin;
        }
        i++;
    }
    //for (int i = 0 ; i < record.size(); i++)
    //    cout << record[i].first << " " << record[i].second <<endl;

    int ans = 0;
    if (K >=record.size())
    {
        cout << N << endl;
    }
    else
    {
        for (int i = 0; i + K -1 < record.size(); i++)
        {
            int l = record[i + K -1].second - record[i].first + 1;
            //cout << l << endl;
            if (l > ans)
                ans = l;
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 1276
def main():
    N = int(input())
    A = list(map(int, input().split()))
    Q = int(input())
    BC = [list(map(int, input().split())) for _ in range(Q)]
    
    S = sum(A)

    A_map = {}
    for a in A:
        if a in A_map:
            A_map[a] += 1
        else:
            A_map[a] = 1

    for b,c in BC:
        if b not in A_map:
            print(S)
            continue

        num = A_map.pop(b)
        if c in A_map:
            A_map[c] += num
        else:
            A_map[c] = num

        S -= b * num
        S += c * num
        print(S)
main()

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

#define ll long
#define ld double
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define setpr(pp) fixed<<setprecision(pp)
#define FOR(I,N) for(I=0;I<N;++I)
#define MS0(x) memset(x,0,sizeof(x))
#define MS1(x) memset(x,-1,sizeof(x))
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod	%1000000007
#define pi 3.141592653
#define NL -5000000

vector<ll> adj[100005];
bool vis[100005];
ll dpw[100005];
ll dpb[100005];

void DFS(ll x)
{
	vis[x]=1;
	ll i,n = adj[x].size();
	dpb[x] = dpw[x] = 1;
	FOR(i,n)
	{
		if(vis[adj[x][i]]==0)
		{
			DFS(adj[x][i]);
			dpb[x] = (dpb[x] * dpw[adj[x][i]] )mod;
			dpw[x] = ( dpw[x] * (dpw[adj[x][i]] + dpb[adj[x][i]])mod )mod;
		}
	}
}

int main()
{	IOS;
	ll n,i,j,x,y;
	cin>>n;
	FOR(i,n-1)
	{
		cin>>x>>y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	MS0(vis);
	DFS(1);
	cout<<(dpb[1]+dpw[1])mod;
}


Measured memory_bytes: 11520
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main() {
	
	int w,h,x,y,d,n;
	string c;
	
	while(1){
		cin>>w>>h;
		if(w==0&&h==0)return 0;
		x=1;
		y=1;
		d=0;
		while(1){
			cin>>c;
			if(c=="FORWARD"||c=="BACKWARD"){
				cin>>n;
				if(c=="BACKWARD")n=n*-1;
				if(d==0)y+=n;
				if(d==1)x-=n;
				if(d==2)y-=n;
				if(d==3)x+=n;
				if(x<1)x=1;
				if(x>w)x=w;
				if(y<1)y=1;
				if(y>h)y=h;
			}
			if(c=="RIGHT"){
				d--;
				if(d==-1)d=3;
			}
			if(c=="LEFT"){
				d++;
				if(d==4)d=0;
			}
			if(c=="STOP"){
				cout<<x<<" "<<y<<endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 0
#include <cstdint>
#include <iostream>

using namespace std;

int main() {
  int64_t a, b;
  cin >> a >> b;
  if ((a + b) % 2 == 0) {
    cout << (a + b) / 2 << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctype.h>
using namespace std;
#define dump(a) cout << (a) << '\n';
typedef long long Int;
Int mod = 1e9+7;
Int MOD = 998244353;

int main() {
    ios::sync_with_stdio(false);
    Int n, m, d;
    cin >> n >> m >> d;
    double res = 0.0;
    for (Int i = 0; i < m - 1; i++) {
        res += (double)(n - d) * 2.0 / (double)(n * n);
    }
    if (d == 0) res /= 2.0;
    printf("%.12lf\n", res);
    return 0;  
}    

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

using namespace std;

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = long long;
using P = std::tuple<int,int>;

const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};

int N, M;
std::vector<int> G[100100];
int dp[100100];

int rec(int v){
    if(dp[v] != -1){
        return dp[v];
    }

    dp[v] = 0;
    for(int w : G[v]){
        dp[v] = std::max(dp[v], rec(w) + 1);
    }

    return dp[v];
}

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

    std::cin >> N >> M;

    for(int i=0;i<M;++i){
        int x, y;
        std::cin >> x >> y;

        G[x].emplace_back(y);
    }

    memset(dp, -1, sizeof(dp));
    
    int res = 0;

    for(int i=1;i<=N;++i){
        res = std::max(res, rec(i));
    }

    std::cout << res << std::endl;
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    string s; cin >> s;
    ll n = s.size();
    REP(i, n/2){
        if (s[i] != s[n-i-1]){
            cout << "No" << endl;
            return 0;
        }
    }
    dump(0)
    ll end = (n-1)/2;
    REP(i, end/2){
        if (s[i] != s[end-i-1]){
            cout << "No" << endl;
            return 0;
        }
    }
    dump(1)
    REP(i, end/2){
        if (s[i + (n+3)/2 - 1] != s[end-i-1 + (n+3)/2 - 1]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
def count ( n , tpl ) :
	arr = [ x for x in range ( 1 , n+1 ) ] ;
	
	fact = [ 0 for  x in range( n +1 ) ] ; 
	fact[0] = 1 ; 
	for x in range ( 1 , n+1 ) :
		fact[x] = fact[x-1] * x ;
	c = 0 ;
	for idx, x in enumerate(tpl) :
		
		for r in range ( 1 , x ) :
			if r not in arr : continue ;
			c +=  fact[ len(tpl)-idx -1 ] ;
		arr.remove( x ) ;
	return c+ 1 ;

n = int( input().strip() ) ;
t1 = tuple( map ( int , input().strip().split(" ")) ) ;
t2 = tuple( map ( int , input().strip().split(" ")) ) ;
x1 =count( n , t1 ) ;
x2 = count( n , t2 ) ;
print ( abs ( x1 - x2 ) ) ;

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcdEx(ll a, ll b, ll *x, ll *y) {
    if (!a) {*x = 0; *y = 1; return b;}
    ll x1, y1, gcd = gcdEx(b % a, a, &x1, &y1); *x = y1 - (b / a) * x1; *y = x1; return gcd;
}
ll modI(ll b, ll m)      {ll x, y; gcdEx(b, m, &x, &y); return (x % m + m) % m;}
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define MOD                 1000000007
#define modA(a,b)           (((a%MOD)+(b%MOD))%MOD)
#define modS(a,b)           (((((a%MOD)-(b%MOD))%MOD)<0)?(ll)(MOD+((a%MOD)-(b%MOD))%MOD):(ll)(((a%MOD)-(b%MOD))%MOD))
#define modM(a,b)           (ll)((((ll)(a%MOD))*((ll)(b%MOD)))%MOD)
#define modD(a,b)           ((modI(b,MOD)*(a%MOD))%MOD)
ll modP(ll x, ll y)         {
    ll r = 1; x %= MOD; while (y > 0) {
        if (y & 1) {r = (r * x) % MOD;}
        y = y >> 1; x = (x * x) % MOD;
    } return r;
}
ll max(ll a, ll b) {return (a > b ? a : b);}
ll min(ll a, ll b) {return (a < b ? a : b);}
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " = " << arg1 << " | "; __f(comma + 1, args...);
}
ll gcd( ll a, ll b )
{
    if (b == 0)
    {
        return a;
    }
    else
    {
        return gcd( b, (a % b) );
    }
}
ll lcm (ll a, ll b)
{
    ll ans = (a  / gcd(a, b)) * b;
    return ans;
}
void solve()
{
    ll ans = 0;
    ll n;
    cin >> n;
    vector<ll> a(n);

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

    for (int i = 0; i < n; i += 2)
    {
        if (a[i] & 1) ans++;
    }
    cout << ans << "\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t ;
    t = 1;
    //  cin >> t;
    while (t--)
        solve();
    return 0;
}





Measured memory_bytes: 3588
#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, Q;
	cin >> N >> Q;
	string S;
	cin >> S;

	vi count(N, 0);
	FOR(i, 1, N-1) {
		count[i] = count[i - 1];
		if (S[i-1] == 'A' && S[i] == 'C') {
			count[i]++;
		}
	}

	int l, r;
	REP(i, Q) {
		cin >> l >> r;
		cout << (count[r - 1] - count[l - 1]) << endl;
	}

	return 0;
}

Measured memory_bytes: 1472
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

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

		int ans=0;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == 'C' && s[i-1] == 'B' && s[i-2] == 'A'){
				ans++;
			}
		}
		cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
//by rng_59
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <memory.h>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

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

const int MAXN = 100010;
long long a[MAXN],b[MAXN];

int main(void) {
	int N;
	long long ans = 0,poor = 0;
	cin >> N;
	REP(i,N) cin >> a[i];
	REP(i,N) cin >> b[i];
	priority_queue <int> q;
	REP(i,N)
		if(a[i] < b[i]) {
			poor += abs(a[i]-b[i]);
			ans++;
			
		}
		else q.push(abs(a[i]-b[i]));
	while(!q.empty() && poor > 0) {
		poor -= q.top();
		q.pop();
		ans++;
	}
	if(poor > 0) cout << -1 << endl;
	else cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2428
#include <cstdio>
int main(void){

	int a, b;

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

	if( (a*b) == 15 )		printf( "*" );
	else if((a+b) == 15)	printf( "+" );
	else				printf( "x" );
	return 0;
}

Measured memory_bytes: 128
from collections import *
p,i=print,input
q=lambda *a:(p('?',*a),i()=='Y')[1]
A,B=map(int,i().split())
r=range(A+B)
c=deque(r)
if A>B:
	while len(c)>2:c.extendleft(([],[c[-2]])[q(c.pop(),c.pop())])
	p('!',''.join(str(int(q(c[0],d))) for d in r))
else: p('Impossible')

Measured memory_bytes: 4156
import java.util.*;

import static java.lang.System.*;

class Main {
	public static Scanner sc = new Scanner(in);
	public static Random rand=new Random();

	public void run() {
		int money=sc.nextInt(),y=sc.nextInt();
		int n=sc.nextInt();

		int max=0;
		for(int c=0;c<n;c++){
			int m=money;
			int type=sc.nextInt();
			double par=sc.nextDouble();
			int dec=sc.nextInt();
			switch(type){
				case 1:
					for(int i=0;i<y;i++){
						m=m+(int)(m*par)-dec;
					}
					if(max<m)max=m;
					break;
				case 0:
					int risi=0;
					for(int i=0;i<y;i++){
						risi+=m*par;
						m-=dec;
					}
					m+=risi;
					if(max<m)max=m;
					break;
			}
		}
		ln(max);
	}
	public static void main(String[] args) {
		int t=sc.nextInt();
		while(t--!=0)
		new Main().run();
	}

	public int[] nextIntArray(int n){
		int[] res=new int[n];
		for(int i=0;i<n;i++){
			res[i]=sc.nextInt();
		}
		return res;
	}
	public static void pr(Object o) {
		out.print(o);
	}
	public static void ln(Object o) {
		out.println(o);
	}
	public static void ln() {
		out.println();
	}
}

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

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

const int MAXN = 2e5;
int n, ans;
multiset<int, greater<int> > S;

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

    scanf("%d", &n);
    for(i=0; i<n; i++) { int x; scanf("%d", &x); S.insert(x); }

    while(!S.empty())
    {
        int x=*S.begin();
        S.erase(S.begin());
        for(i=1; i<=x; i*=2);
        i-=x;
        if(S.find(i)!=S.end()) { S.erase(S.find(i)); ans++; }
    }

    printf("%d", ans);

    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
#include <cmath>
#define INF 1000000007
using namespace std;

int main() {
  int N, M;
  cin >> N;
  cin >> M;

  if (abs(N - M) > 1) {
    cout << 0 << endl;
  } else if (N == M) {
    long long int ans = 2L;
    for (int i=1;i<=N;i++) {
      ans *= i;
      ans %= INF;
      ans *= i;
      ans %= INF;
    }
    cout << ans << endl;
  } else {
    int max = N > M ? N : M;
    int min = N + M - max;
    long long int ans = 1L;

    for (int i=1;i<=N;i++) {
      ans *= i;
      ans %= INF;
    }

    for (int i=1;i<=M;i++) {
      ans *= i;
      ans %= INF;
    }

    cout << ans << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
 public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  int sx = sc.nextInt();
  int sy = sc.nextInt();
  int tx = sc.nextInt();
  int ty = sc.nextInt();
  String  result="";
for(int i=0;i<ty-sy;i++){
result=result+"U";
}
for(int i=0;i<tx-sx;i++){
result=result+"R";
}
for(int i=0;i<ty-sy;i++){
result=result+"D";
}
for(int i=0;i<tx-sx;i++){
result=result+"L";
}
result=result+"L";
for(int i=0;i<ty-sy;i++){
result=result+"U";
}
result=result+"U";
for(int i=0;i<tx-sx;i++){
result=result+"R";
}
result=result+"R";
result=result+"D";
result=result+"R";
for(int i=0;i<ty-sy;i++){
result=result+"D";
}
result=result+"D";
for(int i=0;i<tx-sx;i++){
result=result+"L";
}
result=result+"L";
result=result+"U";
System.out.println(result);
  }
}

Measured memory_bytes: 207036
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] original_enemy = Console.ReadLine().Split();
            int enemy = int.Parse(original_enemy[0]);
            int special_attack = int.Parse(original_enemy[1]);

            string[] original_hp = Console.ReadLine().Split();
            long[] hp = original_hp.Select(long.Parse).ToArray();
            Array.Sort(hp);
            Array.Reverse(hp);
            if (special_attack > hp.Length)
            {
                special_attack = hp.Length;
            }
            for (int i = 0; i < special_attack; i++)
            {
                hp[i] = 0;
            }
            Console.WriteLine(hp.Sum());
            Console.Read();
        }
    }
}

Measured memory_bytes: 35584
import heapq
import math
N = int(input())
a = list(map(int, input().split()))


hq = [-x for x in a]
heapq.heapify(hq)
ans = 0
while(hq[0] < 1-N):
    x = heapq.heappop(hq)
    x = -x
    k = x // N
    x %= N
    ans += k

    for i in range(N-1):
        hq[i] -= k
    heapq.heappush(hq, -x)

print(ans)


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

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

    if(n % 2 == 1){
        for(int i=0; i<m; i++){
            cout << i+1 << " " << n-i << endl;
        }
    }
    if(n % 2 == 0){
        for(int i=0; i<m; i++){
            if(i < n/4) cout << i+1 << " " << n-i << endl;
            else cout << i+2 << " " << n-i << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
using namespace std;
int A[200005];
vector<int> v;
int main()
{
	int m, n, a, b;
	cin >> n >> m;
	for (int i = 0; i < m; i++)
	{
		cin >> a >> b;
		if (a == 1) v.push_back(b);
		if (b == n) v.push_back(a);
	}
	for (int i = 0; i < v.size(); i++)
	{
		A[v[i]]++;
	}
	for (int i = 0; i < 200005;i++)
	{
		if (A[i] == 2)
		{
			cout << "POSSIBLE" << endl;
			return 0;
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}


Measured memory_bytes: 1908
from sys import stdin

s = stdin.readline().strip()

def is_acgt(ss):
  sset = set(ss)
  sset.discard('A')
  sset.discard('G')
  sset.discard('C')
  sset.discard('T')
  return len(sset) == 0

for i in range(1, len(s)+1)[::-1]:
  for j in range(len(s) - i + 1):
    ss = s[j:j+i]
    if is_acgt(ss):
      print(i)
      exit()
      
print(0)

Measured memory_bytes: 9116
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int m,n,s;
int main(){
	in(m);in(n);
    while(n--){
        int x;
        in(x);
        s+=x;
    }
    if(s>=m)puts("Yes");
    else puts("No");
	return 0;
}


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

int main() {
  int N, A, B, NA;
  cin >> N >> A >> B;
  
  NA = N * A;
    
  if(NA <= B){ 
    cout << NA << endl;
  }
  
  if(NA > B){
    cout << B << endl; 
  }
}

Measured memory_bytes: 256