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

int main() {

	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	int t, i;
	cin >> t;

	map<string, int> m;

	for (i = 0 ; i < t ; i++)
	{
		string s;
		cin >> s;

		m[s]++;
	}

	string a = "AC", b = "WA", c = "TLE", d = "RE";

	auto it = m.find(a);
	
	if(it!=m.end())
	cout << it->first << " x " << it->second << endl;
	else
	cout<<a<<" x 0\n";

	it = m.find(b);
	
	if(it!=m.end())
	cout << it->first << " x " << it->second << endl;
	else
	cout<<b<<" x 0\n";

	it = m.find(c);
	
	if(it!=m.end())
	cout << it->first << " x " << it->second << endl;
	else
	cout<<c<<" x 0\n";

	it = m.find(d);
	
	if(it!=m.end())
	cout << it->first << " x " << it->second << endl;
	else
	cout<<d<<" x 0\n";

	return 0;
}

Measured memory_bytes: 3660
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

bool truck(long int M,int n,int k,int bag[]);

int main(){
    int n,k,bag[100000+10];
    cin >> n >> k;
    for(int j=0;j<n;j++){
        cin >> bag[j];
    }
    long int l=0;
    long int h=pow(2,31);
    bool test;
    while(l+1<h){
        long int m=(l+h)/2;
        test=truck(m,n,k,bag);
        if(test) h=m;
        else l=m;
    }
//    cout << h << endl;
    printf("%ld\n",h);

}

bool truck(long int M,int n,int k,int bag[]){
    int wgt=0,num=1;
    for(int i=0;i<n;i++){
        if(wgt+bag[i]<=M) wgt+=bag[i];
        else{
            num++;
            if(bag[i]<=M) wgt=bag[i];
            else{
                num=100000+10;
                break;
            }
        }
    }
//    if(num<=k) cout << 1 << endl;
//    else cout << 0 << endl;
    return num<=k;
}

Measured memory_bytes: 3592
#include<stdio.h>
int main()
{
	int a, b, c, x;
	while (~scanf("%d %d %d %d", &a, &b, &c, &x))
	{
		int num = 0,sum;
		for (int i = 0; i <= a; i++)
		{
			for (int j = 0; j <= b; j++)
			{
				for (int k = 0; k <= c; k++)
				{
					sum = i * 500 + j * 100 + k * 50;
					if (sum == x)
						num++;
					else if (sum > x)
						break;
				}
			}
		}
		printf("%d\n", num);
	}
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;


int32_t main(){
	int n ; cin >> n ;
	pair<int,int>arr[n];
	int x , y ;
	for(int i=0;i<n;i++){
		cin >> x >> y ; 
		arr[i] = {x+y,x-y};
	}
	sort(arr,arr+n);
	int cur = INT_MIN , ans =0 ;
	for(int i=0;i<n;i++){
		if(cur <= arr[i].y ){
			ans++;
			cur = arr[i].x;
		}
	}
	cout << ans << endl; 
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
    long n, d, x, y;
    long counter = 0;
    cin >> n >> d;
    for (long i = 0; i < n; i++)
    {
        cin >> x >> y;
        if (x * x + y * y <= d * d)
        {
            counter++;
        }
    }
    cout << counter << endl;
    return 0;
}


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

#define N 26

typedef struct{
  int left;
  int right;
}Node;

Node tree[N];
int n;
char root[N];

void visit_pre(int);
void visit_in(int);
void visit_post(int);

int main(){
  int i, r;
  
  scanf("%d", &n);
  memset(root, 1, n);

  for(i=0;i<n;i++)
  {
       tree[i].left = tree[i].right = -1;
  }

  for(i=0;i<n;i++){
      int idx, l, r;
    scanf("%d %d %d", &idx, &l, &r);
    tree[idx].left = l;
    tree[idx].right = r;
    root[l] = root[r] = 0;
  }

  for(i=0;i<n;i++) if(root[i]) r = i;

  printf("Preorder\n");
  visit_pre(r);
  printf("\n");
  printf("Inorder\n");
  visit_in(r);
  printf("\n");
  printf("Postorder\n");
  visit_post(r);
  printf("\n");
  return 0;
}

void visit_pre(int p)
{
  printf(" %d", p);
  if(tree[p].left != -1)
  {
       visit_pre(tree[p].left);
  }
  if(tree[p].right != -1)
  { 
      visit_pre(tree[p].right);
  }
}

void visit_in(int p)
{
  if(tree[p].left != -1) 
  {
      visit_in(tree[p].left);
  }
  printf(" %d", p);
  if(tree[p].right != -1) 
  {
      visit_in(tree[p].right);
  }
}

void visit_post(int p)
{
  if(tree[p].left != -1) 
  {
      visit_post(tree[p].left);
  }
  if(tree[p].right != -1) 
  {
      visit_post(tree[p].right);
  }
  printf(" %d", p);
}



Measured memory_bytes: 2052
import collections

h, w, n = map(int, input().split())
y, x = map(int, input().split())
s = input().rstrip()
t = input().rstrip()
counter = collections.Counter()
for c in s:
    counter[c] += 1


def check(counts, direction, opposite_direction, pos, target):
    for i in range(n):
        counts[direction] -= 1
        if s[i] == direction:
            pos += 1
        if pos == target:
            return False
        if t[i] == opposite_direction and pos > 1 and counts[
                opposite_direction] < pos:
            pos -= 1

    return True


for d, od, pos, target in [
    ('R', 'L', x, w + 1),
    ('L', 'R', w + 1 - x, w + 1),
    ('D', 'U', y, h + 1),
    ('U', 'D', h + 1 - y, h + 1),
]:
    ok = check(collections.Counter(counter.items()), d, od, pos, target)
    if not ok:
        print('NO')
        break
else:
    print('YES')

Measured memory_bytes: 4036
#include<bits/stdc++.h>
#define endl "\n"
#define pb push_back
#define ll long long
#define d1(x)  cerr << #x << "--> " << x << endl
#define d2(x,y)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<endl
#define d3(x,y,z)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z<< endl
#define d4(x,y,z,w)  cerr << #x << "--> " << x << " | " << #y << "--> " << y <<" | " << #z << "--> "<< z << " | "<< #w << "--> " << w <<endl
#define vpll vector<pair<ll,ll>>
#define F first
#define S second
#define T ll tt; cin>>tt; while(tt--)
using namespace std;
ll mode=1e9+7;
const long long maxn=2*1e5+10;
const long long inf=99999999999;
ll __lcm(ll a, ll b){ return (a*b)/__gcd(a,b); }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll getRand(ll l, ll r){ uniform_int_distribution<ll> uid(l, r); return uid(rng); }
 
ll power(ll x, ll y){  
	ll p=mode, res=1;
    x = x % p;
    while (y > 0) {  
        if (y & 1)  
            res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}  
bool ok;
ll n;
vector<char> ans;
vector<string> v;
void solve1(ll a, ll b, ll c, ll i){
	
	if (a<0 || b<0 || c<0){
		ok=false;
		return;
	}
	//d4(a,b,c,i);
	if (i==n){
	//	d3(a,b,c);
		if (a>=0 && b>=0 && c>=0) ok=true;
		else ok = false;
		
	}
	else{
		string s=v[i];
		if (s=="AB"){
			solve1(a-1, b+1, c, i+1);
			if (ok){
				ans.pb('B');
			}
			else{
				solve1(a+1, b-1, c, i+1);
				if (ok){
					ans.pb('A');
				}
				else{
					ok=false;
					return;
				}
			}
		}
		else if (s=="BC"){
			solve1(a, b+1, c-1, i+1);
			if (ok){
				ans.pb('B');
			}
			else{
				solve1(a, b-1, c+1, i+1);
				if (ok){
					ans.pb('C');
				}
				else{
					ok=false;
					return;
				}
			}
		}
		else{
			solve1(a+1, b, c-1, i+1);
			if (ok){
				ans.pb('A');
			}
			else{
				solve1(a-1, b, c+1, i+1);
				if (ok){
					ans.pb('C');
				}
				else{
					ok=false;
					return;
				}
			}
		}
	}
}

void solve(){
		
	ll a,b,c;
	cin>>n>>a>>b>>c;
	ok=true;
	
	for (int i=1;i<=n;i++){
		string s;
		cin>>s;
		v.pb(s);
	}
	
	solve1(a,b,c,0);
	if (ok){
		cout<<"Yes"<<endl;
		reverse(ans.begin(), ans.end());
		for (auto i:ans) cout<<i<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	
	
	return;
}
 
int main(){ 
    
    #ifndef ONLINE_JUDGE
		//freopen("input.txt", "r", stdin);
    #endif
    srand(time(0)); 
    
    ios::sync_with_stdio(0);
    cin.tie(0);
 	
	//T{ solve(); }
	solve();
	
	return 0;
}

Measured memory_bytes: 19072
# include <algorithm>
# include <iostream>
# include <iterator>
# include <vector>
# include <string>
# include <queue>
# include <stack>
# include <cmath>
# include <set>


using namespace std;


int main() {
    int n; cin >> n;
    vector<vector<int>> a(2);
    for(int i=0; i<2; ++i) {
        a[i].resize(n);
        for (int j=0; j<n; ++j) cin >> a[i][j];
    }

    a[1][0] += a[0][0];
    for (int i=1; i<n; ++i) a[0][i] += a[0][i-1];
    for (int i=1; i<n; ++i) a[1][i] += max(a[0][i], a[1][i-1]);

    cout << a[1][n-1] << endl;
    return 0;
}



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

int main() {
  int s;
  cin >> s;
  int COUNT = 3;
  
   while (true){
    COUNT++;
    if (s == 4 || s == 2 || s == 1){
      cout << COUNT << endl;
      break;
    }
    else if (s%2 == 0)
      s /= 2;
    else
      s = s*3+1;
  }      
}

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

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

  ll digit = 0;
  while (n > 0)
  {
    n /= k;
    digit++;
  }

  cout << digit << endl;

  return 0;
}


Measured memory_bytes: 256
// Problem : B - Distance 
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int t,d,count=0;
	cin>>t>>d;
	while(t--)
	{
		double x,y,dis;
		cin>>x>>y;
		dis=sqrt(x*x+y*y);
		if(dis<=d)
		count++;
	}
	cout<<count<<nl;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3864
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int         long long
#define mod         1000000007
#define FAST        ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n)      for(int i=0;i<n;i++)
#define fp(i,k,n)   for(int i=k;i<=n;i++)
#define fr(i,k,n)   for(int i=k;i>=n;i--)
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define dbg(x)      cout << (#x) << " is " << (x) << '\n' 
#define F           first
#define S           second
#define sz(x)       (int)(x).size()
#define lb          lower_bound
#define ub          upper_bound
#define mems(x)     memset(x,0,sizeof(x))
#define all(a)      a.begin(),a.end()
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
/*---------------------------------------------------------------------------------------------------*/

void solve()
{
  int n;
  cin >> n;
  int a[n];
  f(i,n)
    cin >> a[i];
  sort(a,a+n,greater<>());
  int tot=1,c=0;
  f(i,n)
  {
      if(tot==n)
         break;
      if(i==0)
        {
            tot+=1,c+=a[i];
        if(tot==n)
            break;
         continue;
        }
      tot+=1;
      c+=a[i];
      if(tot==n)
        break;
      tot+=1;
      c+=a[i];
      if(tot==n)
        break;
  }
  cout << c << '\n';
  return;
} 

signed main()
{
  FAST
  int T=1;
//   cin >> T;
  while(T--)
  {
    solve();
  }
  return 0;
}


Measured memory_bytes: 5228
#include <iostream>

using namespace std;

int main(int argc, const char *argv[])
{
    int N, L;
    cin >> N;
    int m = 0, s = 0;
    for (int i = 0; i < N; i++)
    {
        cin >> L;
        m = max(m, L);
        s += L;
    }
    if (m * 2 < s)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  char S[5];
  int i,k;
  int num = 0;
  scanf("%s",S);
  for(i=0;i<=3;i++){
    for(k=0;k<=3;k++){
      if(S[i] == S[k]){
        num = num+1;
      }
    }
  }
  if(num == 8)printf("Yes");
  else printf("No");
}

Measured memory_bytes: 128
import functools

import os
import sys

sys.setrecursionlimit(10000)
INF = float('inf')


def inp():
    return int(input())


def inpf():
    return float(input())


def inps():
    return input()


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


def inlf():
    return list(map(float, input().split()))


def inls():
    return input().split()


def inpm(line):
    return [inp() for _ in range(line)]


def inpfm(line):
    return [inpf() for _ in range(line)]


def inpsm(line):
    return [inps() for _ in range(line)]


def inlm(line):
    return [inl() for _ in range(line)]


def inlfm(line):
    return [inlf() for _ in range(line)]


def inlsm(line):
    return [inls() for _ in range(line)]


def Yesif(cond):
    print('Yes' if cond else 'No')


def YESIF(cond):
    print('YES' if cond else 'NO')


def yesif(cond):
    print('yes' if cond else 'no')


s = inls()
print(s[0][0].upper() + s[1][0].upper() + s[2][0].upper())


Measured memory_bytes: 3572
#include <cmath>  
#include <queue>  
#include <cstdio>  
#include <cstdlib>  
#include <cstring>  
#include <iostream>  
#include <algorithm>  
#include <map>  
#include <bits/stdc++.h>  
#define mp make_pair  
using namespace std;  
  
constexpr int maxn = 2000010;  
char s[maxn];  
  
set <int> S;  
int nextt[maxn][30];  
int now[30];  
int now_tot[maxn];  
  
void doit(){  
    scanf("%s",s);  
    int len=strlen(s);  
    int tot=0;  
    for (int i=len;i>=1;i--)  
    {  
        S.insert( s[i-1]-'a' );  
        now_tot[i]=tot;  
        if (S.size()==26)  
        {  
            tot++;  
            S.clear();  
        }  
    }  
    if (tot==0)  
        {  
        for (int i=0;i<26;i++)  
            if (S.count (i )==0)  
                {  
                    printf("%c",i+'a');  
                    return ;  
                }  
        }  
    memset(now,0,sizeof(now));  
    for (int i=len;i>=1;i--)  
    {  
        for (int j=0;j<26;j++)  
            nextt[i][j]=now[j];  
        now[ s[i-1]-'a' ]=i;  
    }  
    int tmp=0;  
    for (int i=0;i<26;i++)  
        if (S.count (i )==0)  
        {  
            tmp=now[i];  
            break;  
        }  
    printf("%c",s[tmp-1]);  
    for (int i=1;i<tot;i++)  
        {  
            for (int j=0;j<26;j++)  
                if (now_tot [ nextt[ tmp ][ j ] ]==now_tot [ tmp ] -1 )  
                    {  
                        tmp=nextt[ tmp ][ j ];  
                        printf("%c",s[tmp-1]);  
                        break;  
                    }  
        }  
    for (int i=0;i<26;i++)  
        if (nextt[ tmp ][ i ]==0)  
            {  
                printf("%c",i+'a');  
                break;  
            }  
}  
  
  
int main(){ 
	//freopen("i.txt","r",stdin); 
    doit();  
    return 0;  
}  

Measured memory_bytes: 29696
def main(n):
	a = list(map(int,input().split()))
	ans = 0
	flg = True
	while flg:
		flg = False
		for i in range(n-1, 0, -1):
			if a[i] < a[i-1]:
				a[i], a[i-1] = a[i-1], a[i]
				ans += 1
				flg = True
	print(" ".join(map(str, a)))
	print(ans)

main(int(input()))


Measured memory_bytes: 5596
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Max = 1e3 + 7;
int ls1[Max], ls2[Max];
int n;


int main()
{
	int n;
	cin >> n;
	map<int,int> ma;
	int sum = 0;
	for (int i = 1; i <= n; i++)
	{
		int t;
		cin >> t;
		if (ma[t]) continue;
		ma[t]++;
		sum++;
	}
	cout << sum;
}

Measured memory_bytes: 3164
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  for (int a = 1; a <= 9; ++a) {
    for (int b = 1; b <= 9; ++b) {
      if (a * b == n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int N;
	cin >> N;
	int arr[N];
	REP(i, 0, N) cin >> arr[i];
	int tmp = arr[N-1];
	string ans = "Yes";
	for(int i = N-2; i >= 0; i--){
		if(tmp >= arr[i]) tmp = arr[i];
		else if(tmp >= arr[i]-1) tmp = arr[i] - 1;
		else{
			ans = "No";
			break;
		}
	}
	cout << ans;

}


Measured memory_bytes: 640
#include <stdio.h>
int main(){
    int c,d,e,f;
    c = getchar();
    d = getchar();
    e = getchar();
    f = getchar();
    if((c==d)&&(d==e)&&(e==f)){
        printf("No\n");
    }
    else if((c==d)&&(e==f) ){
        printf("Yes\n");
    }
    else if((c==e)&&(d==f)){
        printf("Yes\n");
    }
    else if((c==f)&&(d==e)){
        printf("Yes\n");
    }
    
    else{
        printf("No\n");
    }
}

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

int main(int argc, char const *argv[])
{
	int n,q;
	cin>>n>>q;
	long long a[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
	}
	reverse(a,a+n);
	long long s[n+5]={},s2[n+5]={};
	for (int i = 0; i < n; ++i)
	{
		s[i+1]=s[i]+a[i];
		s2[i+1]=s2[i];
		if (i%2==0)
		{
			s2[i+1]+=a[i];
		}
	}
	vector<long long> memo,ans;
	for (int i = 0; i < (n+1)/2-1; ++i)
	{
		long long tmp=(a[i+1]+a[2*(i+1)])/2LL+1LL,nans=s[i+1]+s2[n]-s2[2*(i+1)];
		memo.push_back(tmp);
		ans.push_back(nans);
	}
	reverse(memo.begin(), memo.end());
	reverse(ans.begin(), ans.end());
	for (int i = 0; i < q; ++i)
	{
		long long x;
		cin>>x;
		int tmp=upper_bound(memo.begin(), memo.end(),x)-memo.begin();
		if (tmp==0)
		{
			cout<<s[(n+1)/2]<<endl;
		}
		else
		{
			cout<<ans[tmp-1]<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 5108
//Catchharsh
    #include<bits/stdc++.h>
    #define ll long long int 
    #define ld long double
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define F first
    #define S second
    #define pb push_back
    #define endl '\n'
    const ll MOD = 1e9+7;
    const ll INF = 1011111111;
    const ll LLINF = 1000111000111000111LL;
    const ld EPS = 1e-10;
    const ld PI = 3.14159265358979323;
    using namespace std;
    ll power (int x,int n)
    {
        if(n==0)
        return 1;
        else if(n%2==0)
        return power((x*x),n/2);
        else
        return x*power((x*x),(n-1)/2); 
    }
    vector<ll> seve;
    void  seveprime()
    {
      int prime[1000000]={0};
      for(int i=2;i*i<1000000;i++)
       {
        if(prime[i]==0)
         {
      	  for(int j=i*2;j<=1000000;j+=i)
           prime[j]=1;
         }
       }
       for(int i=2;i<=1000000;i++)
       {
       	if(prime[i]==0)
       		seve.pb(i);
       }
    }
    int main()
    {   
         IOS;
         int n;
         cin>>n;
         int i,j,k;
         vector<int> v(n);
         for(i=0;i<n;i++)
         	cin>>v[i];
         int dp[n];
         dp[0]=0;
         dp[1]=abs(v[1]-v[0]);
         for(i=2;i<n;i++)
         {
         	dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
         }
         // for(i=0;i<n;i++)
         // 	cout<<dp[i]<<" ";

        cout<<dp[n-1];
         
    }

Measured memory_bytes: 1024
k,n = map(int, input().split())			# "5 7" -> ["5", "7"] -> 5, 7 => N=5,K=7
A =        list( map(int, input().split()) )	# 1 2 3 4 5 ...

dMax=(k-A[-1]+A[0])

for i in range(n-1):
	dMax = max(dMax, A[i+1]-A[i])

ans = k - dMax
print(ans)


Measured memory_bytes: 26060
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main() {
  int N;
  cin>>N;
  int d[N];
  for(int i=0;i<N;i++) cin>>d[i];
  sort(d,d+N);
  //for(int i=0;i<N;i++)cout<<d[i]<<" ";
  cout<<d[N/2]-d[N/2-1]<<endl;
}	


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
#define MPlus(x,y) {x=(x+y)%M;}
#define MSub(x,y) {x=(x-y+M)%M;}
#define MMul(x,y) {x=(x*y)%M;}

int n,t;
int dp[6100];



signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  cin>>n>>t;
  vector<P> v(n);
  rep(i,n){
    cin>>v[i].F>>v[i].S;
  }
  sort(all(v));

  rep(i,n){
    rrep(j,t-1){
      dp[j+v[i].F]=max(dp[j+v[i].F],dp[j]+v[i].S);
    }
  }

  int ans=0;
  rep(i,6100){
    ans=max(ans,dp[i]);
  }

  cout<<ans<<endl;



}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()


ll modpow(ll a,ll n,ll mod){
  ll res=1;
  while(n){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a,ll mod){
  return modpow(a,mod-2,mod);
}

const int MAX=510000;
const int MOD=1000000007;
ll fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  rep(i,MAX){
    if(i>1){
      fac[i]=fac[i-1]*i%MOD;
      inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
      finv[i]=finv[i-1]*inv[i]%MOD;
    }
  }
}

ll COM(int n,int k){
  if(n<k) return 0;
  if(n<0||k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
 
int main(){
  int N,A,B;
  cin>>N>>A>>B;
  ll ans=modpow(2,N,MOD);
  ans--;
  COMinit();
  ll AA=1;
  rep(i,A) AA=AA*(N-i)%MOD;
  AA=AA*modinv(fac[A],MOD)%MOD;
  ll BB=1;
  rep(i,B) BB=BB*(N-i)%MOD;
  BB=BB*modinv(fac[B],MOD)%MOD;
  ans=ans+MOD-AA;
  ans%=MOD;
  ans=ans+MOD-BB;
  ans%=MOD;
  cout<<ans<<endl;
}

Measured memory_bytes: 12160
#include <stdio.h>
 
int main() {
	
	int H1, M1, H2, M2, K;

	int x, y;
	
	int z;
	
	if (scanf("%d %d %d %d %d", &H1, &M1, &H2, &M2, &K) != 5) {
		return 1;	
	}
	
	x = H1 * 60 + M1;
	
	y = H2 * 60 + M2;
 
	z = y - x - K;
	
	printf("%d\n", z >= 0 ? z : 0);
	
	return 0;
}

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

using namespace std;
typedef pair<double, string> P;

int main() {
  int n;
  while(cin >> n && n) {
    vector<P> vec(n);
    string l;
    int p, a, b, c, d, e, f, s, m;
    for(int i=0; i<n; i++) {
      cin >> l;
      cin >> p >> a >> b >> c >> d >> e >> f >> s >> m;
      vec[i] = make_pair(-(double)(f*s*m - p) / ((a+b+c+(d+e)*m)), l);
    }
    sort(vec.begin(), vec.end());
    for(int i=0; i<n; i++) {
      cout << vec[i].second << endl;
    }
    cout << "#\n";
  }
  
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  int ans = 700;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == 'o')ans += 100;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<unistd.h>
#include <array>
#include <map> 




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}

struct File {
    int aa;
    int bb;

    File(const int& aa, const int& bb)
        : aa(aa), bb(bb) {}
};

bool operator<(const File& a, const File& b)
{
    // ファイル種別、ファイル名の順番で優先順位を付けて比較
    return std::tie(a.aa, a.bb) < std::tie(b.aa, b.bb);
}




int main(){
  long long K,A,B;
  cin>>K>>A>>B;
  bool ok=false;
  if(B-A>2){
    ok=true;

  }
  long long sum=1;
  if(ok){
    while(K>0){
      if(K-2>=0&&sum>=A){
        sum+=B-A;
        K-=2;
      }else{
        sum++;
        K--;
      }

    }
  }else{
    sum+=K;
  }
  cout<<sum<<endl;


}


  

Measured memory_bytes: 256
#pragma warning(disable:4996)
#include <stdio.h>

int main(void) {
	int N = 0, X = 0;
	scanf("%d%d", &N, &X);

	int i;
	int D, L[100];
	int count = 0;
	L[0] = 0;
	for (i = 1; i <= N; i++) {
		scanf("%d", &L[i]);
	}
	for (i = 1; i <= N; i++) {
		D = D + L[i];
		if (D <= X) {
			++count;
		}
	}
	printf("%d", count + 1);

	return 0;
}


Measured memory_bytes: 128
A, B, ABhalf, X, Y = map(int, input().split())
ans_1 = max(X, Y) * 2 * ABhalf
ans_2 = 2 * Y * ABhalf + abs(X - Y) * A
ans_3 = 2*X*ABhalf+abs(X-Y)*B
ans_4 = X * A + Y * B
ans = min(ans_1, ans_2, ans_3, ans_4)
print(ans)


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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define rlo(i,n) for(int i=n-1;i>=0;i--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define pr(a) {for(auto x:a)cout<<x<<" ";cout<<nl;}

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu ()
{
    cerr << endl;
}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest)
{
    cerr << arg << ' ';
    faltu(rest...);
}

void f()
{
    int h,w;
    cin>>h>>w;
    string s[h];
    bool row[h+1]= {0},col[w+1]= {0};

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

    for(int i=0; i<h; i++)
    {
        for(int j=0; j<w; j++)
        {
            if(s[i][j]=='#')
            {
                row[i]=1;
                col[j]=1;
            }
        }
    }

    for(int i=0; i<h; i++)
    {
        if(row[i]==1)
        {
            for(int j=0; j<w; j++)
            {
                if(col[j]==1)
                {
                    cout<<s[i][j];
                }
            }
            cout<<nl;
        }
    }

}

int main()
{
    su;
    f();
    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
int main (void)
{
    int N=0,A=0;
    
    scanf("%d",&N);
    scanf("%d",&A);
    
    if(N%500<=A)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <time.h>
#define MAXT 10
#define MOD 1000000007
using namespace std;

int main()
{
	int n;
	cin >> n;
	bool flag = true;
	int max = 0;

	for (int i = 0; i < n; i++) {
		int tmp;
		cin >> tmp;
		if (max > tmp + 1) {
			flag = false;
			break;
		}
		if (max < tmp)max = tmp;
	}

	printf("%s", flag ? "Yes" : "No");
	

	return 0;
}


Measured memory_bytes: 256
A,B,C,X,Y=map(int,input().split())
if A+B<=2*C:
    print(A*X+B*Y)
elif X==Y or (X>Y and A>=2*C) or (X<Y and B>=2*C):
    print(2*max([X,Y])*C)
elif X>Y and A<2*C:
    print(2*Y*C+A*(X-Y))
elif X<Y and B<2*C:
    print(2*X*C+B*(Y-X))


Measured memory_bytes: 9164
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
ArrayDequeではpopとpushはStackと同じ操作になる
//import static java.lang.System.*; はしばらく使わなそう(使うとしてもexit(0)のためだけ)←return;でよさそう
最後にout.flush()またはout.close()をするのを忘れずに！
*/
//入力終了→Ctrl+D
import java.util.*;
import java.io.*;
import java.awt.*;
import java.awt.geom.Point2D;
//import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        int x=sc.nextInt();
        int y=sc.nextInt();
        int z=sc.nextInt();
        int k=sc.nextInt();
        long[] a=new long[x];
        long[] b=new long[y];
        long[] c=new long[z];
        for (int i = 0; i < x; i++) {
            a[i]=sc.nextLong();
        }
        for (int i = 0; i < x; i++) {
            b[i]=sc.nextLong();
        }
        for (int i = 0; i < x; i++) {
            c[i]=sc.nextLong();
        }
        PriorityQueue<Long> q=new PriorityQueue<>(Comparator.reverseOrder());
        PriorityQueue<Long> pq=new PriorityQueue<>(Comparator.reverseOrder());
        PriorityQueue<Long> ans=new PriorityQueue<>(Comparator.reverseOrder());
        for (int i = 0; i < x; i++) {
            for (int j = 0; j < y; j++) {
                q.add(a[i]+b[j]);
            }
        }
        if(k==x*y*z){
            for (Long l:q){
                for (int i = 0; i < z; i++) {
                    ans.add(c[i]+l);
                }
            }
        }else {
            Arrays.sort(c);
            while (pq.size()<k)pq.add(q.poll());
            for (Long l:pq){
                for (int i = 0; i < z; i++) {
                    ans.add(l+c[i]);
                }
            }
        }
        for (int i = 0; i <k; i++) {
            out.println(ans.poll());
        }
        out.close();
    }

    static PrintWriter out = new PrintWriter(System.out);

    static class sc {
        static Scanner s = new Scanner(System.in);

        static String next() {
            return s.next();
        }

        static int nextInt() {
            return Integer.parseInt(s.next());
        }

        static long nextLong() {
            return Long.parseLong(s.next());
        }

        static double nextDouble() {
            return Double.parseDouble(s.next());
        }
    }
}

Measured memory_bytes: 166620
# coding: utf-8
n = int(input())
data = list(map(int, input().split()))
x = list(range(1, n + 1))
cnt = 0
for i in range(n):
    if data[i] != x[i]:
        cnt += 1

if cnt <= 2:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 2940
/*
    Matrix Multiplication
    https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/7/ITP1_7_D
*/
#include <bits/stdc++.h>
using namespace std;
#define VVI vector<vector<int>>

void trace(VVI &vvi, int row, int col) {
    for (int i = 0; i < row; i++) {
        for (int j = 0; j < col; j++) {
            cout << vvi[i][j] << (j != col - 1 ? " " : "");
        }
        cout << endl;
    }
}

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

    int n, m, l;
    cin >> n >> m >> l;

    VVI Ai(100, vector<int>(100));
    VVI Bi(100, vector<int>(100));

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

    for (int i = 0; i < m; i++) {
        for (int j = 0; j < l; j++) {
            cin >> Bi[i][j];
        }
    }

    // trace(Ai, n, m);
    // trace(Bi, m, l);

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < l; j++) {
            long sum = 0;
            for (int k = 0; k < m; k++) {
                sum += (long)Ai.at(i).at(k) * Bi.at(k).at(j);
            }
            cout << sum;
            cout << ((j != l - 1) ? " " : "\n");
        }
    }
    return 0;
}


Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < (n); ++(i))
#define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i))
#define repeat_from_reverse(i,m,n) for (int i = (n)-1; (i) >= (m); --(i))
#define whole(f,x,...) ([&](decltype((x)) y) { return (f)(begin(y), end(y), ## __VA_ARGS__); })(x)
typedef long long ll;
using namespace std;
template <class T> void setmax(T & a, T const & b) { if (a < b) a = b; }
template <class T> void setmin(T & a, T const & b) { if (b < a) a = b; }
template <typename T, typename X> auto vectors(T a, X x) { return vector<T>(x, a); }
template <typename T, typename X, typename Y, typename... Zs> auto vectors(T a, X x, Y y, Zs... zs) { auto cont = vectors(a, y, zs...); return vector<decltype(cont)>(x, cont); }
template <typename T> T input(istream & in) { T a; in >> a; return a; }
const int dy[] = { -1, 1, 0, 0 };
const int dx[] = { 0, 0, 1, -1 };
bool is_on_field(int y, int x, int h, int w) { return 0 <= y and y < h and 0 <= x and x < w; }
typedef uint16_t color_t;
array<color_t,4> rotate(array<color_t,4> c, int r) {
    rotate(c.begin(), c.begin() + r, c.end());
    return c;
}
void normalize(array<color_t,4> & c) {
    array<color_t,4> d = c;
    repeat (r,4) setmin(c, rotate(d, r));
}
int multiplicity(array<color_t,4> const & c) {
    int n = 0;
    repeat (r,4) if (c == rotate(c, r)) n += 1;
    return n;
}
int main() {
    int n; cin >> n;
    vector<array<color_t,4> > c(n);
    repeat (i,n) repeat (j,4) cin >> c[i][j];
    repeat (i,n) normalize(c[i]);
    map<array<color_t,4>,int> cnt; repeat (i,n) cnt[c[i]] += 1;
    map<array<color_t,4>,int> mul; for (auto it : cnt) mul[it.first] = multiplicity(it.first);
    ll ans = 0;
    repeat (bi,n) repeat (ai,bi) { // div 2
        cnt[c[ai]] -= 1;
        cnt[c[bi]] -= 1;
        repeat (br,4) { // div 4
            //    b0 -- b3
            //   /     / |
            // a0 -- a1  |
            //  | _1  | b2
            //  |     | /
            // a3 -- a2
            array<color_t,4> const & a = c[ai];
            array<color_t,4> b = rotate(c[bi], br);
            array<array<color_t,4>,4> ds;
            ds[0] = { b[0], b[3], a[1], a[0] };
            ds[1] = { b[3], b[2], a[2], a[1] };
            ds[2] = { b[2], b[1], a[3], a[2] };
            ds[3] = { b[1], b[0], a[0], a[3] };
            ll acc = 1;
            map<array<color_t,4>,int> used;
            for (auto & d : ds) {
                normalize(d);
                if (not cnt.count(d)) { acc = 0; break; }
                used[d] += 1;
                acc *= mul[d] * (cnt[d] - used[d] + 1);
            }
            ans += acc;
        }
        cnt[c[ai]] += 1;
        cnt[c[bi]] += 1;
    }
    assert (ans % 3 == 0);
    ans /= 3;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/**
 *    author:  Taichicchi
 *    created: 19.09.2020 13:16:37
 **/

#include <bits/stdc++.h>

#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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

    cout << 1 - x << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main(void) {

	int n,i;
	int a[10000];
	int max = -1000000;
	int min = 1000000;
	long int sum = 0;

	scanf("%d", &n);

	for (i = 0; i < n; i++) {

		scanf("%d", &a[i]);

		sum += a[i];

		if (min > a[i]) {
			min = a[i];
		}

		if (max < a[i]) {
			max = a[i];
		}

	}

	printf("%d %d %ld\n", min, max, sum);

	return(0);

}


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

main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int x,a;
	cin>>x>>a;

	if(x<a)
		cout<<0;
	else
		cout<<10;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

constexpr double EPS = 1e-7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
#define PI (acos(-1))

constexpr int MOD = 1e9 + 7;

int main(int argc, char const *argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	int N;
	string S;
	cin >> N >> S;

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


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

using namespace std;

typedef pair<int, int> PII;

const int INF = 1e9;

struct State{
  int pos, cost, bit1, bit2;
  State(int p, int c, int b1, int b2):pos(p), cost(c), bit1(b1), bit2(b2){};
};

int d[1010][1010];
vector<PII> info;

void wf(int n){
  for(int i = 0 ; i < n ; i++) d[i][i] = 0;
  
  for(int k = 0 ; k < n ; k++)
    for(int i = 0 ; i < n ; i++)
      for(int j = 0 ; j < n ; j++) d[i][j] = min(d[i][j], d[i][k] + d[k][j]); 
}

int solve(int p){
  int m = info.size();
  
  queue<State> que;
  que.push(State(p, 0, 0, 0));
  
  int ret = INF;
  
  while(!que.empty()){
    State q = que.front(); que.pop();
    
    if(q.cost >= ret) continue;
    
    if(__builtin_popcount(q.bit2) == m){
      ret = min(ret, q.cost);
      continue;
    }

    // pick
    for(int i = 0 ; i < (int)info.size() ; i++){
      if( !((1<<i) & q.bit1)) que.push(State(info[i].first, q.cost + d[q.pos][info[i].first], q.bit1 | (1<<i), q.bit2));
    }
    
    // send
    for(int i = 0 ; i < (int)info.size() ; i++){
      if( (1<<i) & q.bit1 && !((1<<i) & q.bit2)){
	que.push(State(info[i].second, q.cost + d[q.pos][info[i].second], q.bit1, q.bit2 | (1<<i)));
      }
    }
    
  }
  return ret;
}

int main(){
  for(int i = 0 ; i < 1010 ; i++)
    for(int j = 0 ; j < 1010 ; j++) d[i][j] = INF;


  int n, m, k, p;
  cin >> n >> m >> k >> p;
  p--;
  
  int from, to, w;
  for(int i = 0 ; i < m ; i++){
    cin >> from >> to >> w;
    from--, to--;
    d[from][to] = d[to][from] = w;
  }
  
  wf(n);
  
  for(int i = 0 ; i < k ; i++){
    cin >> from >> to;
    from--, to--;
    info.push_back(PII(from, to));
  }
  
  int ans = solve(p);
  if(ans == INF) cout << "Cannot deliver" << endl;
  else cout << ans << endl;

}

Measured memory_bytes: 130612
'''C - Welcome to AtCoder
高橋君は AtCoder のコンテストに参加しています。

このコンテストでは、 N 問の問題が出題されます。
高橋君はコンテスト中に M回の提出を行いました。

i 回目の提出は pi番目の問題への提出であり、結果は Si (AC または WA) でした。
高橋君の正答数は、AC を 1回以上出した問題の数です。
高橋君のペナルティ数は、高橋君が AC を 1 回以上出した各問題において、初めて AC を出すまでに出した WA の数の総和です。
高橋君の正答数とペナルティ数を答えてください。

入力
入力は以下の形式で標準入力から与えられる。

N M
p1 S1
:
pM SM

2 5
1 WA
1 AC
2 WA
2 AC
2 WA
>
2 2

100000 3
7777 AC
7777 AC
7777 AC
>
1 0

6 0
>
0 0
'''
import numpy as np

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

AC = np.array([0]*N) # 正解を入れる箱
WA = np.array([0]*N) # 不正解を入れる箱

for _ in range(M):
    p, S = input().split()
    
    if AC[int(p)-1] ==0 and S == "WA": # まだ「正解が出てない & 不正解」
        WA[int(p)-1] += 1              # なら不正解の箱に＋１
    else:
        AC[int(p)-1] = 1               # それ以外は正解の箱に１
    
print(sum(AC), sum(WA*AC)) # ただし不正解の箱は最後まで正解が出なかった問題はペナルティ無しにする必要があるので、正解の箱の中身と掛け合わせて消しておく。



Measured memory_bytes: 16636
import numpy as np

N = int(input())
As = input().split()
As = [int(A) for A in As]


def gcd(a, b):
  while b > 0:
    a, b = b, a%b
  return a

min_HP = np.inf
a0 = As[0]
for a in As[1:]:
    b = gcd(a0,a)
    if b <= a0:
        a0 = b
print(a0)



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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int a, b, h, m;
  cin >> a >> b >> h >> m;

  double mang, hang, ang, ans;
  mang = m * 360.0 / 60.0;
  hang = h * 360.0 / 12.0;
  hang += m * 360.0 / 720.0;

  mang = mang;
  hang = hang;

  ang = max(mang, hang) - min(mang, hang);
  if (ang > 180) {
    ang = 360 - ang;
  }
  ang = deg_to_rad(ang);

  ans = sqrt((a * a) + (b * b) - (2 * a * b * cos(ang)));

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 4304
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;


int main(void) {
    int cnt = 0;
    int A, B;
    cin >> A >> B;
    int outlet = 1;
    for(; outlet<B; outlet+=A-1) {
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;

int main(){
	const int mod = 1e9+7;
	int n,k;
	cin >> n >> k;
	vector<int> a(n);
	vector<vector<int> > dp(n,vector<int>(k+2));
	for(int i = 0; i < n; i++) cin >> a[i];
	for(int i = 0; i <= a[0]; i++) dp[0][i]++;
	for(int i = 0; i < n-1; i++){
		for(int j = 0; j <= k; j++){
			int l = j;
			int r = min(a[i+1]+l+1,k+1);
			dp[i+1][l]+=dp[i][j];
			dp[i+1][r]-=dp[i][j];
			dp[i+1][l]%=mod;
			dp[i+1][r]%=mod;
			if(dp[i+1][r]<0) dp[i+1][r]+=mod;
		}
		for(int j = 1; j <= k; j++){
			dp[i+1][j]+=dp[i+1][j-1];
			dp[i+1][j]%=mod;
		}
	}
	cout << (dp[n-1][k] + mod)%mod << "\n";
	return 0;
}


Measured memory_bytes: 41084
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define ll long long

using namespace std;
double n;
int a[100005];
int main(){
   
    cin>>n;
    double pi=3.141592653589793238462643383279502884L;
    double res=2.0*pi*n;
    cout<<fixed<<setprecision(18)<<res;
}


Measured memory_bytes: 3780
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,i;
    string s;
  	cin>>n;
  	s=to_string(n);
  	for( i=0;i<s.length();i++){
    	if(s.at(i)!='7')continue;
      	else{
        cout<<"Yes"<<endl;
        break;}
    }if(i==s.length())cout<<"No"<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define pb push_back
#define vl vector
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,t;
    cin>>n;
    if(n>=400 && n<=599) cout<<"8";
    else if(n>=600 && n<=799) cout<<"7";
    else if(n>=800 && n<=999) cout<<"6";
    else if(n>=1000 && n<=1199) cout<<"5";
    else if(n>=1200 && n<=1399) cout<<"4";
    else if(n>=1400 && n<=1599) cout<<"3";
    else if(n>=1600 && n<=1799) cout<<"2";
    else cout<<"1";
    
}

Measured memory_bytes: 3608
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>

using namespace std;
#define ll long long
#define ld long double
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define P pair<int, int>
#define Q pair<int, pair<int, int>>
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define mkp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
const int Mod = 1e9 + 7;
const int mod = 998244353;
const ll Inf = 3 * 1e18;
const int inf = 15 * 1e8;
ll read() {
	ll u, k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j % i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}
ll bcount(ll x) {
	int sum = 0;
	for (int i = 0; i < 20; i++)
		if ((1ll << i) & x) sum++;
	return sum;
}
/*const int fn_ = 2000000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll mod = Mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % mod;
			comp_[i] = mod_pow(fact_[i], mod - 2, mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % mod * comp_[y] % mod;
}*/
//---------------------------------------------------
signed main() {
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	for (int i = 0; i < n;) {
		int j = i;
		while (j < n && s[i] == s[j]) j++;
		ans++;
		i = j;
	}
	cout << ans << endl;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int a, b;
    cin >> a >> b;
    if (a + b == 15) cout << "+" << endl;
    else if (a * b == 15) cout << "*" << endl;
    else cout << "x" << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n; cin>>n;
    vector<int> a(n);
    for (int &x: a) cin>>x;
    sort(a.begin(), a.end());

    long long res=0;
    for (int i=a.size()-1; i>=2; --i) {
        int l=0, r=i-1;
        while (l<r) {
            if (a[l]+a[r]>a[i]) {
                res+=(long long)(r-l);
                --r;
            } else {
                ++l;
            }
        }
    }
    cout<<res;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <tuple>

int main() {
  intmax_t x;
  scanf("%jd", &x);

  intmax_t res = 0;
  res += x / 500 * 1000;
  x %= 500;
  res += x / 5 * 5;
  printf("%jd\n", res);
}


Measured memory_bytes: 128
N, M = map(int, input().split())
l = 1
r = N
for m in range(M):
  m_l, m_r = map(int, input().split())
  l = max(l, m_l)
  r = min(r, m_r)
  if l>r:
    print(0)
    exit()
print(r+1-l)  
  

Measured memory_bytes: 3060