akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 2123
int a[N];
int b[N];
#define MOD 1'000'000'007LL

int main(){
	int n; ll k; scanf("%d%lld", &n, &k);
	REP(i, n){
		scanf("%d", a+i);
		b[a[i]]++;
	}
	ll ans = 0;
	REP(i, n){
		FOR(j, i+1, n){
			if(a[i] > a[j]) ans++;
		}
	}
	ans *= k;
	ans %= MOD;
	int x = 0;
	REP(i, N){
		ll tmp = k*(k-1)/2 % MOD;
		tmp = tmp * b[i] % MOD;
		tmp = tmp * x % MOD;
		ans = (ans + tmp) % MOD;
		x += b[i];
	}
	printf("%lld\n", ans);
}


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

int main() {
 int n,a,b;
 cin >> n >> a >> b;
 int ans = 0;
 for(int i =1 ; i <= n; i++){
 int sum = i%10;
   int t = i;
 while(t >= 10){
   t /= 10;
   sum += t%10;
 }
 if(sum >= a && sum <= b) ans+=i;
}
 cout << ans << endl;
 }


Measured memory_bytes: 3636
// https://atcoder.jp/contests/abc169/tasks/abc169_c

use proconio::input;

fn main() {
    input! {
      a: u64, b: String,
    }
    let b: Vec<&str> = b.split(".").collect();
    let b_100 = b[0].parse::<u64>().unwrap() * 100 + b[1].parse::<u64>().unwrap();
    println!("{}", a * b_100 / 100);
}


Measured memory_bytes: 2172
import bisect

n,m,k = map(int,input().split())
a = [0]+list(map(int,input().split()))
b = [0]+list(map(int,input().split()))

for i in range(1,n+1):
  a[i] = a[i]+a[i-1]
for j in range(1,m+1):
  b[j] = b[j]+b[j-1]

book_cnt=0
for a_cnt in range(n+1):
  if a[a_cnt]>k:
    continue
  rest=k-a[a_cnt]
  b_cnt=bisect.bisect(b,rest)-1
  book_cnt=max(book_cnt,a_cnt+b_cnt)

print(book_cnt)

Measured memory_bytes: 39916
n = int(input())

taro = 0
hanako = 0
for ni in range(n):
    t, h = input().split()

    if  t < h:
        hanako += 3
    elif t > h:
        taro += 3
    else:
        hanako += 1
        taro += 1
    
print(taro, hanako)

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

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> price;
  vector<vector<int>> A;
  for (int i = 0; i < N; i++) {
    int C;
    cin >> C;
    price.push_back(C);
    vector<int> a(M);
    for (int i = 0; i < M; i++) cin >> a.at(i);
    A.push_back(a);
  }
  int ans = 1e9;
  for (int bit = 0; bit < 1 << N; bit++) {
    vector<int> tmp(M);
    int P = 0;
    for (int i = 0; i < N; i++) {
      if (bit >> i & 1) {
        P += price.at(i);
        for (int j = 0; j < M; j++) {
          tmp.at(j) += A.at(i).at(j);
        }
      }
    }
    int mi = *min_element(tmp.begin(), tmp.end());
    if (mi >= X) ans = min(ans, P);
  }
  cout << ((ans == 1e9) ? -1 : ans) << "\n";
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;
struct Point{int x; int y;};

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    ll N; cin >> N;
    if(N % 2 == 0)
        cout << N;
    else
        cout << N * 2;
    
    
    return 0;
}


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

int main() {
    Int n, a, b; cin >> n >> a >> b;
    if (a > b) {
        cout << 0;
        return 0;
    }
    if (n == 1 && a != b) {
        cout << 0;
        return 0;
    }
    cout << (b-a) * (n - 2) + 1 << endl;
}

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

int N,W;

struct item{
    int v,w;
    item(int v=0,int w=0):v(v),w(w){}
};

vector<item> items(101);
vector<vector<int>> C(101,vector<int>(10001));
vector<vector<int>> G(101,vector<int>(10001));

void knapsack(){
    for(int w=0;w<W+1;w++){
        C[0][w]=0;
        G[0][w]=0;
    }
    for(int i=1;i<N+1;i++){
        C[i][0]=0;
    }

    for(int i=1;i<N+1;i++){
        for(int w=1;w<W+1;w++){
            C[i][w]=C[i-1][w];
            G[i][w]=0;
            if(items[i].w>w) continue;
            if(items[i].v+C[i-1][w-items[i].w]>C[i][w]){
                C[i][w]=items[i].v+C[i-1][w-items[i].w];
                G[i][w]=1;
            }
        }
    }
}

int main(){
    int a,b;
    cin>>N>>W;
    for(int i=1;i<N+1;i++){
        cin>>a>>b;
        items[i]=item(a,b);
    }

    knapsack();

    cout<<C[N][W]<<endl; 
}


Measured memory_bytes: 10636
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

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

using namespace std;

typedef long long int lli;

int main () {
    int N;
    cin >> N;
    vector<int> v(N);
    REP (i, 0, N) cin >> v[i];
    int m = 1 << 30;
    int M = 0;
    vector<int> cnt(N, 0);
    REP (i, 0, N) {
        m = min(m, v[i]);
        M = max(M, v[i]);
        cnt[v[i]]++;
    }
    if (M - m > 1) {
        cout << "No" << endl;
        return 0;
    }
    if (N < 2 * M) {
        if (2 * M - N == cnt[m] || (m == M && m + 1 == N)) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    } else {
        if (m == M) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pii acos(-1)
#define fo(i0n) for(i=0;i<n;i++)
#define fo(i1n) for(i=1;i<=n;i++)
#define fo(j0n) for(j=0;j<n;j++)
#define fo(j1n) for(j=1;j<=n;j++)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define pf push_front
#define pu push
#define bg begin
#define en end
using namespace std;

int main()
{
    fast();
    ll i,j,k,c,d,a,b,e,f,p,q,n,t,m,r,u,g,x,y,l;
    ld bb,cc,aa;
    string st,et,ft;
    priority_queue<ll,vector<ll>,greater<ll> > pq,aq,dq;
    map<ll,ll> ma,ta;
    map<ll,ll,greater<ll> >sa;
    set<ll> se,pe,me;
    vector<ll > vv,v,s,ss;


    cin>>x>>n;
    c = 0;
    d = 0;
    f = 0;
    for(i=0;i<n;i++){
       cin>>a;
       ma[a] = 1;
    }

    if(n==0)cout<<x<<endl;
    else{
         auto it = --ma.end();
    b = (*it).first;
    auto ki = ma.begin();
    d = (*ki).first;
    a = 99999999;
    m = 99999999;
      for(i=x;i<=b+1;i++){
        if(ma[i]==0){
            a = abs(x-i);
            c = i;
            break;
        }
    }
    for(i=x-1;i>=d-1;i--){
        if(ma[i]==0){
           // cout<<i<<endl;
            m = abs(x-i);
            e = i;
            break;
        }
    }
    if(a<m)cout<<c<<endl;
    else cout<<e<<endl;
    }

}


Measured memory_bytes: 3664
#include <stdio.h>
int main(void){
int n,i,j;
scanf("%d",&n);
int a[4][13]={};
for(i=0;i<n;i++){
    char x;
    int y;
    scanf(" %c%d",&x,&y);
    y--;
    if(x=='S')
    a[0][y]++;
    else if(x=='H')
    a[1][y]++;
    else if(x=='C')
    a[2][y]++;
    else
    a[3][y]++;
    
}
for(i=0;i<4;i++){
    char v;
    if(i==0)
    v='S';
    else if(i==1)
    v='H';
    else if(i==2)
    v='C';
    else
    v='D';
    for(j=0;j<13;j++){
        if(a[i][j]==0){
            printf("%c %d\n",v,j+1);
        }
    }
}

return 0;
}

Measured memory_bytes: 2668
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
#define sys system("PAUSE")
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt=1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
int prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
void prime_factor(int n){
	int cnt = 1;
	map<int, int>res;
	int m = n;
	for (int i = 2; i<= n; i++) {
		if(prime(i)){
			while (m%i == 0) {
				++res[i];
				m /= i;
			}
		}
	}
	cout << n <<":"<< endl;
	for (int i = 2; i<= n; i++) {
		if (res[i]) {
			cout << i << " " << res[i] << endl;
		}
	}
	cout << endl;
}
/*Library End!*/
int n, t;
pair<int, int>p[105];
signed main() {
	cin >> n >> t;
	for (int i = 0; i < n; i++) {
		cin >> p[i].first >> p[i].second;
	}
	sort(p, p + n);
	for (int i = 0; i < n; i++) {
		if (p[i].second <= t) {
			cout << p[i].first << endl;
			sys;
			return 0;
		}
	}
	cout << "TLE" << endl;
	sys;
	return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;

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

int n;
int w[301];
int dp[301][301];

int func(int l,int r){
	if(dp[l][r]!=-1)return dp[l][r];
	if(l+1>=r)return 0;
	if(l+2==r){
		if(abs(w[l]-w[l+1])<=1)return (dp[l][r]=2);
		else return (dp[l][r]=0);
	}
	int res=0;
	for(int i=l+1;i<r;i++){
		res=max(res,func(l,i)+func(i,r));
	}
	res=max(res,func(l+1,r));
	res=max(res,func(l+2,r)+((abs(w[l]-w[l+1])<=1)?2:0));
	res=max(res,func(l,r-1));
	res=max(res,func(l,r-2)+((abs(w[r-1]-w[r-2])<=1)?2:0));
	if(abs(w[l]-w[r-1])<=1){
		int v=func(l+1,r-1);
		if(v==((r-1)-(l+1))){
			res=r-l;
		}
	}
	return (dp[l][r]=res);
}

int main(void){
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		for(int i=0;i<n;i++){
			scanf("%d",&w[i]);
		}
		memset(dp,-1,sizeof(dp));
		printf("%d\n",func(0,n));
	}
	return 0;
}

Measured memory_bytes: 3500
#include<bits/stdc++.h>
using namespace std;
#define li long int
#define lli long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define endl "\n"
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
lli power(lli a,lli b)
{
    if(b==0)
        return 1;
    lli p=power(a,b/2);
    if(b%2==0)
        return p*p;
    else
        return a*p*p;
}
li gcd(li a,li b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
int main()
{
    fast;
    lli n,i,a;
    cin>>n;
    vector<lli> v;
    fr(i,n)
    {
    	cin>>a;
    	v.pb(a);
    }
    lli j;
    sort(v.begin(),v.end());
    lli ans=0,s,k;
    fr(i,n-2)
    {
    	for(j=i+1;j<n-1;j++)
    	{
    		s=v[i]+v[j];
    		k=lower_bound(v.begin(),v.end(),s)-v.begin();
    		ans+=k-j-1;
    	}
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[][] map = new String[8][8];
		for (int i = 0; i < 8; i++) {
			String line = br.readLine();
			for (int j = 0; j < 8; j++) {
				map[i][j] = line.substring(j, j + 1);
			}
		}

		String tomoe = "o";
		String charlotte = "x";

		String now = tomoe;
		boolean tomoeC = true;
		String wait = charlotte;
		boolean charlotteC = true;
		while (true) {
			int max = 0;
			int maxI = 0;
			int maxJ = 0;
			for (int i = 0; i < 8; i++) {
				for (int j = 0; j < 8; j++) {
					if (map[i][j].equals(".")) {
						int c = ch(i, j, now, wait, map);
						if (c == max && now.equals(tomoe)) {
							if (i < maxI || (i == maxI && j < maxJ)) {
								maxJ = j;
								maxI = i;
							}
						} else if (c == max && now.equals(charlotte)) {
							if (i > maxI || (i == maxI && j > maxJ)) {
								maxJ = j;
								maxI = i;
							}
						} else if (c > max) {
							max = c;
							maxI = i;
							maxJ = j;
						}
					}
				}
			}

			if (!tomoeC && !charlotteC)
				break;
			if (max == 0) {
				if (now.equals(tomoe))
					tomoeC = false;
				else
					charlotteC = false;
			} else {
				map[maxI][maxJ] = now;
				tu(maxI, maxJ, now, wait, map);
			}
			String t = now;
			now = wait;
			wait = t;
		}

		for (int i = 0; i < 8; i++) {
			for (int j = 0; j < 8; j++) {
				System.out.printf(map[i][j]);
			}
			System.out.println();
		}
	}

	public static int ch(int i, int j, String now, String wait, String[][] map) {
		int sum = 0;
		int[] x = { 0, 1, 1, 1, 0, -1, -1, -1 };
		int[] y = { -1, -1, 0, 1, 1, 1, 0, -1 };

		for (int k = 0; k < 8; k++) {
			int nx = i + x[k];
			int ny = j + y[k];
			int s = 0;
			while (nx < 8 && ny < 8 && nx >= 0 && ny >= 0) {
				if (map[nx][ny].equals(wait))
					s++;
				else if (map[nx][ny].equals(now))
					break;
				else {
					s = 0;
					break;
				}
				nx = nx + x[k];
				ny = ny + y[k];
				if (nx >= 8 || ny >= 8 || nx < 0 || ny < 0)
					s = 0;
			}
			sum += s;
		}
		return sum;
	}

	public static void tu(int i, int j, String now, String wait, String[][] map) {
		int[] x = { 0, 1, 1, 1, 0, -1, -1, -1 };
		int[] y = { -1, -1, 0, 1, 1, 1, 0, -1 };

		for (int k = 0; k < 8; k++) {
			int nx = i + x[k];
			int ny = j + y[k];
			int s = 0;
			while (nx < 8 && ny < 8 && nx >= 0 && ny >= 0) {
				if (map[nx][ny].equals(wait))
					s++;
				else if (map[nx][ny].equals(now))
					break;
				else {
					s = 0;
					break;
				}
				nx = nx + x[k];
				ny = ny + y[k];
				if (nx >= 8 || ny >= 8 || nx < 0 || ny < 0)
					s = 0;
			}
			if (s > 0) {
				nx = i + x[k];
				ny = j + y[k];
				for (int t = 0; t < s; t++) {
					map[nx][ny] = now;
					nx = nx + x[k];
					ny = ny + y[k];
				}
			}
		}
	}
}


Measured memory_bytes: 25364
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iomanip>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define INF 1e8
#define EPS 1e-9

#define rep2(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) rep2(i,0,n)

int n,k,a[100000];

int main(){
	while(cin>>n>>k&&n){
		rep(i,n)cin>>a[i];
		int s=0;
		rep(i,k)s+=a[i];
		int ans=s;
		rep(i,n-k){
			s+=a[k+i]-a[i];
			ans=max(ans,s);
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1240
import sys, math
from collections import defaultdict
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

N = ri()
A = rl()

B = [0] * N

R = [0] * N
for i in range(N-1, -1, -1):
	if R[i] % 2 == A[i]:
		B[i] = 0
	else:
		B[i] = 1
		n = i+1
		j = 1
		while j*j <= n:
			if n % j == 0:
				R[j-1] += 1
				m = n//j
				if m != j:
					R[m-1] += 1
			j += 1

ans = [i+1 for i, b in enumerate(B) if b == 1]
print(len(ans))
print(*ans)


Measured memory_bytes: 95044
#include <iostream>
using namespace std;
int main()
{
    int n;
    int x = 0;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }   
    for (int i = 0; i < n; i++) {
        while (a[i] % 2 == 0) {
            a[i] /= 2;
            x++;
        }
    }   
    cout << x;


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define det(A) (A.a*A.d-A.b*A.c)
#define fix(A) ((-0.0001<A && A<0)?0:A)

struct matrix{ double a, b, c, d; };
struct vector{ double a, b; };

struct vector multi(struct matrix x, struct vector y){
	struct vector res;
	res.a=x.a*y.a+x.b*y.b,
	res.b=x.c*y.a+x.d*y.b;
	return res;
}

struct matrix inv(struct matrix x){
	struct matrix res;
	res.a=x.d/det(x), res.b=-x.b/det(x),
	res.c=-x.c/det(x), res.d=x.a/det(x);
	return res;
}

int main(void){
	struct matrix m; struct vector v;
	while(scanf("%lf %lf %lf %lf %lf %lf",&m.a,&m.b,&v.a,&m.c,&m.d,&v.b)==6){
		printf("%.3lf %.3lf\n",fix(multi(inv(m),v).a),fix(multi(inv(m),v).b));
	}
	return 0;
}

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

main(void) {
  string n;cin>>n;
  int res=0;
  for (int i = 0; i < n.length(); i++) {
  	res += n[i] - '0';
  }
  if(res%9==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N>>K;
  vector<int64_t>A(N);
  for(int i=0;i<N;i++)
    cin>>A.at(i);
  int64_t ans=0;
  for(int i=0;i<=N;i++)
    for(int j=0;j<=N-i;j++){
    if(K<i+j)
      continue;
      else{
      set<int>S;
        int64_t a=0;
        for(int k=0;k<i;k++){S.insert(A.at(k)); a+=A.at(k);}
        for(int l=1;l<=j;l++){S.insert(A.at(N-l));a+=A.at(N-l);}
        int b=0;
        for(auto x:S){
        if(K-i-j-b<=0)break;
          else{if(x<=0)a-=x; b++;}
        }if(ans<=a)ans=a;
      
      }
    }cout<<ans<<endl;
  return 0;
}

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

using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < s.length(); i++)
    {
        if (s[i] != t[i])
        {
            cout << "No"
                 << "\n";
            return 0;
        }
    }
    cout << "Yes"
         << "\n";
}

Measured memory_bytes: 3612
#!/usr/bin/env python3
import sys
from itertools import permutations

def solve(N: int, M: int, R: int, r: "List[int]", A: "List[int]", B: "List[int]", C: "List[int]"):

    '''
    Warshall-Floyd
    input:  c[|V|][|V|]
            input example to from cost
            (c[i][i] == 0)
    Output: Minimun cost of all paths in the inputed graph 
    '''
    V = N
    INF = 1<<32
    d = [[INF] * (N+1) for i in range(N+1)]

    for i in range(M):
        d[A[i]][B[i]] = C[i]
        d[B[i]][A[i]] = C[i]

    for k in range(1,N+1):
        for i in range(1,N+1):
            for j in range(1,N+1):
                d[i][j] = min(d[i][j], d[i][k]+d[k][j])


    ans = INF
    
    for i in permutations(r):
        ta = 0
        for x in range(R-1):
            ta += d[i[x]][i[x+1]]
        
        if(ta < ans):
            ans = ta

    print(ans)

    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    R = int(next(tokens))  # type: int
    r = [int(next(tokens)) for _ in range(R)]  # type: "List[int]"
    A = [int()] * (M)  # type: "List[int]"
    B = [int()] * (M)  # type: "List[int]"
    C = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        A[i] = int(next(tokens))
        B[i] = int(next(tokens))
        C[i] = int(next(tokens))
    solve(N, M, R, r, A, B, C)

if __name__ == '__main__':
    main()


Measured memory_bytes: 45148
n,m=map(int,input().split())
edg1=[0]*(n+1)
edgn=[0]*(n+1)
for i in range(m):
    a,b=map(int,input().split())
    if a==1:
        edg1[b]=1
    if b==n:
        edgn[a]=1

f=1
for i in range(2,n+1):
    if edg1[i]==1 and edgn[i]==1:
        f=0
print("POSSIBLE" if f==0 else "IMPOSSIBLE")


Measured memory_bytes: 77696
import java.util.*;
public class Main{
  public static void main(String[]args){
      Scanner sc = new Scanner(System.in);

      String s = sc.next();
      char c;
      int count = 0;
      int ans = 0;

      for (int i = 0;i<s.length() ;i++ ) {
        c = s.charAt(i);
        if(c=='A'||c=='C'||c=='G'||c=='T'){
          count++;
          ans = Math.max(ans,count);
        }else{
          ans = Math.max(ans,count);
          count=0;
        }
      }

      System.out.println(ans);
      }
    }


Measured memory_bytes: 22608
#define _ 2<<17
A[_];long P[_],M=1e9+7,F[_],I[_]={1},X;i,j,k,t;c(a,b)int*a,*b;{t=*a-*b?:a[1]-b[1];}p(a,b){return b?p(a%M*a%M,b/2)*(b%2?a:1L)%M:1;}f(a,b){return F[a+b]*I[a]%M*I[b]%M;}main(s){for(;++X<_;)I[X]=p(s=F[X]=X*s%M,M-2);for(;~scanf("%d",A+i);)i++-1||gets(P);for(qsort(A,i/2,8,c);j<i;P[j]=X,j+=2)for(X=f(s=A[k=j]-=1,t=A[j+1]-=1);k;X=t<A[k+1]?X:(X-f(s-A[k],t-A[k+1])*P[k]%M+M)%M)k-=2;printf("%d",X);}

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
 
  if (N / 111 % 10 == 0 && N % 111 < 10) {
    cout << "Yes" << endl;
  }
  // 上三桁が同じ数字で、111で割った
  
  else if(N % 1000 % 111 == 0){
    cout << "Yes" << endl; 
  }
 
  else if(N % 1111 == 0){
    cout << "Yes" << endl; 
  }
  
  
   else {
    cout << "No" << endl;
  }
   
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1e9+7
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
    int ans=INF;
    for(int i=0;i*i*i<=n;i++){
      for(int j=0;j*j<=(n-i*i*i);j++){
	ans=min(ans,n+i+j-(i*i*i+j*j));
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}




Measured memory_bytes: 3096
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pi pair<int,int>
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define sz(x) ((int)x.size())
#define ln(x) ((int)x.length())
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define endl '\n'
#define dbg(x) cout<<#x<<": "<<x<<endl
#define clr(x,v) memset(x, v, sizeof(x))
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
const double eps = 1e-9;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const int MAXN = 1e6 + 5;

int lp[MAXN];
vector<int> prime;
bool present[MAXN];
void init()
{
    lp[1] = 1;
    for(int i = 2; i < MAXN; i++)
    {
        if(!lp[i])
            lp[i] = i, prime.pb(i);
        for(int j = 0; j < sz(prime) && i * 1LL * prime[j] < 1LL * MAXN; j++)
        {
            lp[i * prime[j]] = prime[j];
            if(i % prime[j] == 0)
                break;
        }
    }
}

void cp()
{
    int n;
    cin >> n;
    vector<int> arr(n);
    for(int &x : arr)
        cin >> x;
    int g = arr[0];
    for(int i = 1; i < n; i++)
        g = __gcd(g, arr[i]);
    bool is_pairwise = true;
    for(int i = n - 1; i >= 0 && is_pairwise; i--)
    {
        int temp = arr[i];
        while(temp > 1 && is_pairwise)
        {
            int pf = lp[temp];
            if(present[pf])
                is_pairwise = false;
            while(temp % pf == 0)
                temp /= pf;
            present[pf] = 1;
        }
    }
    if(is_pairwise)
        cout << "pairwise coprime";
    else if(g == 1)
        cout << "setwise coprime";
    else
        cout << "not coprime";
}

int main()
{
    FASTIO;
    int t;
    t = 1;
    // cin >> t;
    init();
    while(t--)
    {
        cp();
    }
    return 0;
}

Measured memory_bytes: 11564
N, u, v = map(int, input().split())
edge = [set() for i in range(N)]

u -= 1
v -= 1

for i in range(N-1):
  a, b = map(int, input().split())
  edge[a-1].add(b-1)
  edge[b-1].add(a-1)

def calcDepth(root):
  depth = [-1] * N
  stack = [(root, 0)]

  while stack:
    cur, curD = stack.pop()
    depth[cur] = curD
    for c in edge[cur]:
      if depth[c] != -1: continue
      stack.append((c, curD+1))
  
  return depth

Adepth = calcDepth(v)
Ddepth = calcDepth(u)

ans = 0
for i in range(N):
  if Adepth[i] >= Ddepth[i]:
    ans = max(ans, Adepth[i])
print(ans-1)

Measured memory_bytes: 40484
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int a,h,w,d,m,y[90001],x[90001],s[90001];
int main() {
	cin >> h >> w >> d;
	REP(i,h) REP(j,w) {
    cin >> a;
    y[a]=i,x[a]=j;
  }
	cin >> m;
  int l[m],r[m];
	REP(i,m) cin >> l[i] >> r[i];

	for (int i=d+1;i<=h*w;i++) {
		s[i] = s[i-d] + abs(x[i-d]-x[i]) + abs(y[i-d]-y[i]);
  }

  REP(i,m) {
		COUT(s[r[i]]-s[l[i]]);
	}

  return 0;
}

Measured memory_bytes: 5288
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
// Welcome to my source code!

int main() {
    int n, k;
    cin >> n >> k;
    int num = 1;
    for (int i = 0; i < n; i++) {
        if (num <= k) num *= 2;
        else num += k;
    }
    cout << num << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>
#include <queue>

using namespace std;

int N, L;
int ans[300][300];

void func(vector<vector<pair<int, int>>>& E, int start){
    vector<vector<int>> maxF(N, vector<int>(N, -1));
    vector<int> minCnt(N, -1);

    priority_queue<pair<pair<int, int>, int>> pq;
    maxF[start][0] = L;
    pq.push(make_pair(make_pair(0, L), start));

    while(!pq.empty()){
        auto temp = pq.top();
        pq.pop();

        int tempF = temp.first.second;
        int node = temp.second;
        int tempCnt = -temp.first.first;

        if(minCnt[node] != -1){
            continue;
        }
        minCnt[node] = tempCnt;

        if(tempCnt == N - 1){
            continue;
        }

        for(auto e: E[node]){
            int nextNode = e.first;
            int cost = e.second;
            if(cost > L){
                continue;
            }

            if(cost > tempF){
                if(minCnt[nextNode] == -1 && maxF[nextNode][tempCnt + 1] < L - cost){
                    maxF[nextNode][tempCnt + 1] = L - cost;
                    pq.push(make_pair(make_pair(-(tempCnt + 1), L - cost), nextNode));
                }
            }
            else{
                int nextF = tempF - cost;
                if(minCnt[nextNode] == -1 && maxF[nextNode][tempCnt] < nextF){
                    maxF[nextNode][tempCnt] = nextF;
                    pq.push(make_pair(make_pair(-tempCnt, nextF), nextNode));
                }
            }
        }
    }

    for(int i = 0; i < N; i++){
        ans[start][i] = minCnt[i];
    }
}

int main(){

    int M;
    cin >> N >> M >> L;

    vector<vector<pair<int, int>>> E(N);
    int a, b, c;
    for(int i = 0; i < M; i++){
        cin >> a >> b >> c;
        E[a - 1].emplace_back(make_pair(b - 1, c));
        E[b - 1].emplace_back(make_pair(a - 1, c));
    }

    for(int i = 0; i < N; i++){
        func(E, i);
    }

    int Q;
    cin >> Q;
    vector<pair<int, int>> st(Q);
    int s, t;
    for(int i = 0; i < Q; i++){
        cin >> s >> t;
        st[i] = make_pair(s, t);
    }

    for(int i = 0; i < Q; i++){
        auto temp = st[i];
        cout << ans[temp.first - 1][temp.second - 1] << endl;
    }

    return 0;
}

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

struct Card { char suit, value; };

void BubbleSort(struct Card A[], int N) {
	for (int i = 0; i <= N - 1; i++) {
		for (int j = N - 1; j >= i + 1; j--) {
			if (A[j].value < A[j - 1].value) swap(A[j], A[j - 1]);
		}
	}
}

void SelectionSort(struct Card A[], int N) {
	int minj;
	for (int i = 0; i <= N - 1; i++) {
		minj = i;
		for (int j = i; j <= N - 1; j++) {
			if (A[j].value < A[minj].value) minj = j;
		}
		swap(A[i], A[minj]);
	}
}

bool isStable(Card C1[], Card C2[], int N) {
	//C1???stable??????
	for (int i = 0; i <= N - 1; i++) {
		if (C1[i].suit != C2[i].suit) return false;
	}
	return true;
}

void print(Card C[], int N) {
	for (int i = 0; i <= N - 1; i++) {
		if (i > 0) cout << " ";
		cout << C[i].suit << C[i].value;
	}
	cout << endl;
}

int main(void) {
	int N;
	Card C1[36], C2[36];
	cin >> N;
	for (int i = 0; i <= N - 1; i++) {
		cin >> C1[i].suit >> C1[i].value;
	}
	for (int i = 0; i <= N - 1; i++) C2[i] = C1[i];
	BubbleSort(C1, N);
	SelectionSort(C2, N);

	print(C1, N);
	cout << "Stable" << endl;

	print(C2, N);
	if (isStable(C1, C2, N)) {
		cout << "Stable" << endl;
	} else {
		cout << "Not stable" << endl;
	}

	return 0;
}

Measured memory_bytes: 3096
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a==1) a+=13;
		if(b==1) b+=13;
		if(a==b) {
			System.out.println("Draw");
		}else if(a>b) {
			System.out.println("Alice");
		}else {
			System.out.println("Bob");
		}
	}
}


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

n, k, q = map(int, input().split())
memo = [0] * n
for i in range(q):
    a = int(input())
    memo[a - 1] += 1
for i in range(n):
    if k - (q - memo[i]) > 0:
        print('Yes')
    else:
        print('No')


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

int main(){
  long long int n,i,kotae=0;
  cin>>n;
  long long int a[3*n];
  for(i=0;i<3*n;i++){
    cin>>a[i];
  }
  sort(a,a+3*n);
  for(i=1;i<=n;i++){
    kotae+=a[3*n-2*i];
  }
  cout<<kotae;
}

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

ll digits(ll n)
{
    ll d = 0;
    if (n == 0)
        return 1;
    while (n > 0)
    {
        n /= 10;
        d++;
    }
    return d;
}

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

    vector<char> d[3];
    rep(i, m)
    {
        int s;
        char c;
        cin >> s >> c;
        s--;
        d[s].push_back(c);
    }
    rep(i, 3) sort(ALL(d[i]));
    rep(i, 3) d[i].erase(unique(d[i].begin(), d[i].end()), d[i].end());

    rep(i, 3)
    {
        if (d[i].size() >= 2)
        {

            OP(-1);
            return 0;
        }
    }

    int minv = 1000;

    rep(i, 1000)
    {
        if (digits(i) != n)
            continue;
        string t = to_string(i);

        bool flag = 1;

        rep(i, n)
        {
            if (d[i].size() == 0)
                continue;
            if (find(ALL(d[i]), t[i]) == d[i].end())
                flag = 0;
        }

        if (flag)
            minv = min(minv, stoi(t));
    }

    if (minv == 1000)
        OP(-1);
    else
        OP(minv);

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Math;

public class Main {

	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);

		String A = in.next();
		String B = in.next();
		
		in.close();
		
		double ans = (Double.parseDouble(B) - 1)/(Double.parseDouble(A) - 1);
		
		ans = Math.ceil(ans);
		
		int answer = (int)ans;
		
		System.out.println(answer);
	}
	
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
int k, n, a[200001], t1, t2, res=1e9;
int main()
{
    cin>>k>>n;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<n;i++)
    {
        t1=(a[i]+k-a[i+1]);
        res=min(res,t1);
    }
    t2=a[n]-a[1];
    res=min(res,t2);
    cout<<res;
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cstring>
#include <cstdio>
using namespace std;

const int mo = 1e9 + 7;
const int N = 4010;

int n, k, c[N][N]; 

int qpow(int a, int b) {
	int ans = 1;
	for(; b >= 1; b >>= 1, a = 1ll * a * a % mo)
		if(b & 1) ans = 1ll * ans * a % mo;
	return ans;
}

int C(int x, int y) {
	if(x < 0 || y < 0) return 0;
	return c[x][y];
}

int d(int x, int y) { //a[1] + .. + a[x] = y, a[i] >= 1
	return x == 0 && y == 0 ? 1 : C(y - 1, x - 1);
}

int main() {
	for(int i = 0; i < N; i ++) {
		c[i][0] = c[i][i] = 1;
		for(int j = 1; j < i; j ++) {
			c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mo;
		}
	}
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= k; i ++) {
		int ans = 0;
		for(int j = 0; j <= n - k; j ++) { //两边
			int now = (j + 1) * 1ll * C(k - 1, i - 1) % mo * d(i - 1, n - k - j) % mo;
			ans = (ans + now) % mo;
		}
		printf("%d\n", ans);
	}
	return 0;
}
//K blue球 N 个球, K球分布i个子段的排列数 
//dp[i][j][k] i balls, j blue, k duan
//dp[i][j][k][0] = dp[i - 1][j][k][0] + dp[i - 1][j][k][1]
//dp[i][j][k][1] = dp[i - 1][j - 1][k][1] + dp[i - 1][j - 1][k - 1][0]

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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

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

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

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

    vector<ll> A(N+1),B(N);
    rep(i,N+1) cin >> A[i];
    rep(i,N)cin>>B[i];
    //-----------------------------------
    ll ans=0,n=A[0],m;

    for(int i=0;i<N;i++){
        m=min(n,B[i]);
        ans+=m;
        n=B[i]-m;
        m=min(n,A[i+1]);
        ans+=m;
        n=A[i+1]-m;
    }

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

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

template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;

int main() {
	ll a, b, n;
	cin >> a >> b >> n;
	ll m;
	ll r;
	if (b > n) {
		m = n;
		r = a * m /b;
	}
	else {
		m = b - 1;
		if (m <= 0) m = 1;
		r = a * m / b;
		r -= a * (ll)(m / b);
	}
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
void solve(){
    ll n;
    cin>>n;
    ll a[n],b[n],c[n];
    for(ll i=0;i<n;i++) {cin>>a[i]>>b[i];}
    sort(a,a+n);
    sort(b,b+n);
    ll x,y;
    if(n%2){
        cout<<b[n/2]-a[n/2]+1;

    }
    else{
        cout<<(b[n/2]+b[n/2-1])-(a[n/2]+a[n/2-1])+1;
    }


    return;
}
int main(){
    IO
    //TEST
    solve();
    return(0);
}


Measured memory_bytes: 6784
#include <iostream>
#include <math.h>

#define N 10001

using namespace std;

int main(void){
	bool isprime[N];
	for(int i=0;i<N;i++) isprime[i]=true;
	int upto = (int)sqrt(N);
	for(int i=2;i<=upto;i++){
		if(isprime[i]){//消されてなければその倍数を消す
			for(int j=2;i*j<=N;j++) isprime[i*j] = false;
		}
	}
	int n;
	while(cin >> n){
		if(n==0)break;
		int p1,q1,w=3;
		for(int i=n;i>=3;--i){
			if(isprime[i]&&isprime[i-2]){
				q1=i;
				p1=i-2;
				break;
			}
		}
		cout<<p1<<" "<<q1<<"\n";
	}
	return 0;
}

Measured memory_bytes: 868
#include<stdio.h>

int main()
{
    int N;
    int i;
    char hoge[3];
    float fuga,ans=0;

    scanf("%d",&N);
    for(i=0;i <N;i++)
    {
        scanf("%f %s",&fuga,hoge);
        if(strcmp(hoge,"BTC")==0)ans += fuga*380000.0;
        else ans += fuga;
    }
    printf("%f",ans);
    return 0;
}


Measured memory_bytes: 128
N,M=map(int,input().split())
machi=[]
for i in range(N):
    machi.append(0)
for j in range(M):
    a,b=map(int,input().split())
    machi[a-1]+=1
    machi[b-1]+=1
for k in range(N):
    print(machi[k])

Measured memory_bytes: 3060
n = int(input())
A = [int(input()) for _ in range(n)]

prev_mod = 0
ans = 0
for a in A:
    if prev_mod == 1 and a > 0:
        a += 1
        prev_mod = 0
    ans += a // 2
    mod = a % 2
    if mod+prev_mod == 2:
        ans += 1
        mod = 0
    prev_mod = mod

print(ans)

Measured memory_bytes: 7072
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    string s;
    cin >> s;

    int c = 0;
    for (int i = 0; i < n; i++) {
        c += s[i] == 'R';
    }

    cout << (c > n - c ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
const int N = 10000;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int answer = 0;
	for (int i = 0; i < n - 2; ++i) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') {
			++answer;
		} 
	}
	cout << answer << '\n';
	return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split( ))
#c = [ [0] * w ]
#下の奴がまずい。各行が同一のアドレス指してる。上も一応変えておく。
#DP = [ [0] * w ] * ( h + 1 )
c=[[0 for _ in range(w)]]
DP = [[0 for _ in range(w)] for __ in range(h+1)]
for _ in range(h):
    c_tmp = list(map(int, input().split( )))
    c.append( c_tmp )


for i in range(w):
    for j in range(1,h+1):
        if c[j][i] == 1:
            DP[j][i] = 0
        else:
            DP[j][i] = min(DP[j-1][i],DP[j][i-1],DP[j-1][i-1])+1
 
mx =0

for i in range(h+1):
    mx =max(mx,max(DP[i]))
print(mx**2)




Measured memory_bytes: 55736
n = int(input())
a = list(map(int, input().split(' ')))

def swap(a, b):
    return b, a

ok = 0
f = 1
for i in range(n):
    if a[i] - 1 != i:
        f = 0
if f:
    ok = 1
for i in range(n):
    for j in range(i + 1, n):
        a[i], a[j] = swap(a[i], a[j])
        f = 1
        for k in range(n):
            if a[k] - 1 != k:
                f = 0
        if f:
            ok = 1
        a[i], a[j] = swap(a[i], a[j])
print('YES' if ok else 'NO')

Measured memory_bytes: 9168
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <utility>
#include <algorithm>
#include <vector>
#include <cmath>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
  int n;
  cin>>n;
  vi p(n);
  rep(i,n)cin>>p[i];
  sort(all(p));
  int s=0;
  rep(i,n-1)s+=p[i];
  cout<<s+p[n-1]/2<<endl;
}


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

struct Edge{
    int from,to;
    Weight weight;
};
using Edges=vector<Edge>;
using Graph=vector<Edges>;

const ll MOD=1e9+7;
pair<vector<Weight>,vector<ll>> dijkstra(Graph& g,int s){
    const Weight INF=1e15;
    vector<Weight> d(g.size(),INF);
    d[s]=0;
    vector<ll> pat(g.size(),0);
    pat[s]=1;
    priority_queue<pair<Weight,int>,vector<pair<Weight,int>>,greater<>> que;
    que.push(make_pair(Weight(0),s));
    while(!que.empty()){
        Weight w=que.top().first;
        int v=que.top().second;
        que.pop();
        if(d[v]<w) continue;
        for(int i=0;i<g[v].size();i++){
            int to=g[v][i].to;
            if(d[to]==d[v]+g[v][i].weight){
                pat[to]+=pat[v];
                pat[to]%=MOD;
                continue;
            }
            if(d[to]<d[v]+g[v][i].weight) continue;
            pat[to]=pat[v];
            d[to]=d[v]+g[v][i].weight;
            que.push(make_pair(d[to],to));
        }
    }
    return make_pair(d,pat);
}

int main(){
    int n,m;
    cin>>n>>m;
    int s,t;
    cin>>s>>t;
    s--,t--;
    Graph g(n);
    for(int i=0;i<m;i++){
        int u,v,d;
        cin>>u>>v>>d;
        u--,v--;
        g[u].push_back(Edge{u,v,d});
        g[v].push_back(Edge{v,u,d});
    }
    auto rets=dijkstra(g,s);
    auto rett=dijkstra(g,t);
    auto ds=rets.first;
    auto dt=rett.first;
    auto pats=rets.second;
    auto patt=rett.second;
    Weight dist=ds[t];
    vector<ll> online(n,0);
    for(int i=0;i<n;i++){
        online[i]=(ds[i]+dt[i]==dist);
    }
    vector<ll> clash;
    for(int i=0;i<n;i++){
        if(online[i] && dist==ds[i]*2) clash.push_back((pats[i]*patt[i])%MOD);
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<g[i].size();j++){
            int fr=g[i][j].from;
            int to=g[i][j].to;
            if(online[fr] && online[to] && ds[fr]+g[i][j].weight==ds[to]){
                if(ds[fr]*2<dist && dt[to]*2<dist){
                    clash.push_back((pats[fr]*patt[to])%MOD);
                }
            }
        }
    }
    ll sum=accumulate(clash.begin(),clash.end(),0LL)%MOD;
    ll sqsum=(accumulate(clash.begin(),clash.end(),0LL,[](ll a,ll b){return (a+(b*b)%MOD)%MOD;}));
    cout<<(sum*sum-sqsum+MOD)%MOD<<endl;
    return 0;
}

Measured memory_bytes: 20940
#include <stdio.h>

int main() {
  while(1) {
    int a, b;
    char op;
    scanf("%d %c %d", &a, &op, &b);
    if (op == '?') {
      break;
    } else if (op == '+') {
      printf("%d\n", a + b);
    } else if (op == '-') {
      printf("%d\n", a - b);
    } else if (op == '*') {
      printf("%d\n", a * b);
    } else {
      printf("%d\n", a / b);
    }
  }
  return 0;
}



Measured memory_bytes: 2048
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<functional>
using namespace std;
long long n, a, b, c, d; bool OK = false;
int main() {
	cin >> n >> a >> b >> c >> d;
	for (long long i = 0; i <= n - 1; i++) {
		long long L = -1LL * d*i + 1LL * c*(n - 1 - i);
		long long R = -1LL * c*i + 1LL * d*(n - 1 - i);
		if (L <= b - a && b - a <= R) { cout << "YES" << endl; OK = true; break; }
	}
	if (OK == false)cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long LL;
LL a,b;
int main(){
  cin>>a>>b;
  LL x,y;
  x=a-(a%4);
  y=b-(b%4);
  LL c=0,d=0;
  for(LL i=x;i<a;i++){
    c=c^i;
  }
  for(LL i=y;i<=b;i++){
    d=d^i;
  }
  cout<<(d^c)<<endl;
  return 0;
}

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

int main() {
 int n;
 cin>>n;
 string s;
 map <string,int> mp;
 while(n--)
 {
     cin>>s;
     mp[s]++;
 }
 cout<<"AC x "<<mp["AC"]<<endl;
 cout<<"WA x "<<mp["WA"]<<endl;
 cout<<"TLE x "<<mp["TLE"]<<endl;
 cout<<"RE x "<<mp["RE"]<<endl;
 return 0;
}


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

struct Tree {
  int key;
  Tree *left, *right, *parent;
};

bool find(Tree* trees, int key) {
  if (trees == nullptr) return false;
  if (trees->key == key) return true;
  else if (key < trees->key) return find(trees->left, key);
  else return find(trees->right, key);
}

void insert(Tree* trees, Tree* new_tree) {
  Tree *cur_tree = trees;
  Tree *pre_tree;
  bool is_left_selected;
  while (cur_tree != nullptr) {
    pre_tree = cur_tree;
      if (new_tree->key < cur_tree->key) {
        cur_tree = pre_tree->left;
        is_left_selected = true;
      } else {
        cur_tree = pre_tree->right;
        is_left_selected = false;
      }
  }
  new_tree->parent = pre_tree;
  if (is_left_selected) {
    pre_tree->left = new_tree;
  } else {
    pre_tree->right = new_tree;
  }
}

void inorder(Tree *tree) {
  if (tree->left != nullptr) {
    inorder(tree->left);
  }
  cout << " " << tree->key;
  if (tree->right != nullptr) {
    inorder(tree->right);
  }
}

void preorder(Tree *tree) {
  cout << " " << tree->key;
  if (tree->left != nullptr) {
    preorder(tree->left);
  }
  if (tree->right != nullptr) {
    preorder(tree->right);
  }
}

void print(Tree* trees) {
  inorder(trees);
  cout << endl;
  preorder(trees);
  cout << endl;
}

int main() {
  int n;
  cin >> n;
  Tree* trees = nullptr;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    if (s.find("insert") != string::npos) {
      Tree* new_tree = new Tree;
      cin >> new_tree->key;
      new_tree->parent = nullptr;
      new_tree->left = nullptr;
      new_tree->right = nullptr;
      if (trees == nullptr) {
        trees = new_tree;
      } else {
        insert(trees, new_tree);
      }
    } else if (s.find("find") != string::npos) {
      int key;
      cin >> key;
      if (find(trees, key)) {
        cout << "yes" << endl;
      } else {
        cout << "no" << endl;
      }
    } else {
      print(trees);
    }
  }
  return 0;
}



Measured memory_bytes: 21756
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if( a + b > c + d){
    cout << "Left" << endl;
  }else if( a + b == c + d ){
    cout << "Balanced" << endl;
  }else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256