akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long MOD = 1e9+7;
#define int long long
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define REPR(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(int (i)=(a-1);(i)>=(b);(i)--)
#define ALL(x) (x).begin(), (x).end()
#define pb push_back
#define fst first
void print() {cout<<endl;}template <class Head,class... Tail>void print(Head&&head,Tail&&...tail){cout<<head;if(sizeof...(tail)!=0)cout<<" ";print(forward<Tail>(tail)...);}template <class T>void print(vector<T>&vec){for(auto&a:vec){cout<<a;if(&a!=&vec.back())cout<<" ";}cout<<endl;}template <class T>void print(vector<vector<T>>&df){for(auto&vec:df){print(vec);}}

signed main(){
    int n;
    cin >> n;
    vector<int> L;
    REP(i, n){
        int a;
        cin >> a;
        L.push_back(a);
    }
    sort(ALL(L));
    int ans = 0;
    REP(i, n-2){
        FOR(j, i+1, n-1){
            FOR(k, j+1, n){
                int a = L[i], b = L[j], c = L[k];
                if (a < b + c and b < a + c and c < a + b)
                    ans++;
            }
        }
    }
    print(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59


int main(){
  ll i,j;
  ll a,b,c;
  cin>>a>>b>>c;
  ll cnt=0;
  if(a%2==1) cnt++;
  if(b%2==1) cnt++;
  if(c%2==1) cnt++;
  if(cnt>=2) cout<<"Hom"<<endl;
  else cout<<"Tem"<<endl;
  
  return 0;
}


Measured memory_bytes: 3136
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
bon = []
for i in range(n):
  ri = n - i - 1
  if sum(b[ri::ri+1]) % 2 != a[ri]:
    b[ri] = 1
    bon.append(ri+1)
print(len(bon))
print(*bon)

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

int ans = 0;

void count(long long n, int d, int l, long long tmp, int flag) {
	if (d != 0 && d <= l) {
		if (n >= tmp && flag == 7) ans++;
	}
	if (d > l) return;
	count(n, d+1, l, tmp*10+3, flag | (1 << 0));
	count(n, d+1, l, tmp*10+5, flag | (1 << 1));
	count(n, d+1, l, tmp*10+7, flag | (1 << 2));
	return;
}

int main() {
	long long n; cin >> n;
	int l = 0; long long tmp = n;
	while (tmp > 0) {
		l++; tmp /= 10;
	}
	count(n, 0, l, 0, 0);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

namespace atcorderpractice
{
    class Mainclass
    {

        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = new int[n];
            string[] input = Console.ReadLine().Split(' ');

            for (int i = 0; i < n; i++)
            {
                a[i] = int.Parse(input[i]);
            }

            bool judge = true;

            for (int i = 0; i < n; i++)
            {
                if (a[i] % 2 == 0)
                {
                    if (judge == false)
                    {
                        break;
                    }
                    if (a[i] % 3 == 0 || a[i] % 5 == 0)
                    {
                        judge = true;

                    }
                    else
                    {
                        judge = false;
                        break;
                    }
                }
            }
            if (judge == true)
            {
                Console.WriteLine("APPROVED");
            }
            else
            {
                Console.WriteLine("DENIED");
            }
        }
    }
}

Measured memory_bytes: 11092
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();

        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }

        int[] ans = new int[N];
        int s = 0;
        int e = N - 1;
        int j = N - 1;

        while (j >= 1) {
            ans[s++] = a[j];
            ans[e--] = a[j - 1];
            j -= 2;
        }

        if (j == 0) {
            ans[e] = a[j];
        }

        for (int i = 0; i < N; i++) {
            out.print(ans[i]);
            if (i != N - 1) {
                out.print(" ");
            }
        }
        out.println();
    }
}

Measured memory_bytes: 93700
#include<iostream>
#include <stdio.h>
#include <string.h>

using namespace std;
int main()
{
	char s[4];
	int a, b, c, i, j, N;

	cin >> s;

	a = 0;
	b = 0;
	c = 0;

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

		if (s[i] == 'a') {
			a++;
		}
		else {
			if (s[i] == 'b') {
				b++;
			}
			else {
				if (s[i] == 'c') {
					c++;
				}
			}
		}
	}


		if (a == 1 && b == 1 && c == 1) {
			cout << "Yes";
		}

	else {
		cout << "No";
	}


	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define H 500000

void maxHeapify(int*,int,int);
void buildMaxHeap(int*,int);

int main(void){
  int n,Node[H];
  int i;

  scanf(" %d",&n);
  for(i = 1; i < n+1; i++){
    scanf(" %d",&Node[i]);
  }

  buildMaxHeap(Node,n);

  for(i = 1; i < n+1; i++){
    printf(" %d",Node[i]);
  }
  printf("\n");
  
  return 0;
}

void maxHeapify(int *A, int i, int n){
  int l,r,largest,tmp;
  l = 2*i;
  r = 2*i+1;
  
  if(l <= n && A[l] > A[i]) largest = l;
  else largest = i;
  if(r <= n && A[r] > A[largest]) largest = r;

  if(largest != i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(A,largest,n);
  }
}

void buildMaxHeap(int *A, int n){
  int i;

  for(i = n/2; i >= 1; i--){
    maxHeapify(A,i,n);
  }
}



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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
struct edge {int to; ll cost;};


int main()
{
  int n, m;
  cin >> n >> m;
  vector<vector<edge>> g(n+1);
  int init;
  rep(i, m) {
    int l, r, d;
    cin >> l >> r >> d;
    g[l].push_back(edge{r, d});
    g[r].push_back(edge{l, -d});
  }
  vector<ll> node(n+1, INF64);
  queue<int> q;

  for(int s = 1; s <= n; ++s) {
    if(node[s] != INF64) continue;

    node[s] = 0;
    q.push(s);

    while(!q.empty()) {
      int now = q.front(); q.pop();

      for(auto next : g[now]) {
        if(node[next.to] == INF64) {
          node[next.to] = node[now]+next.cost;
          q.push(next.to);
        }
        else if(node[next.to] != node[now]+next.cost) {
          cout << "No" << endl;
          return 0;
        }
      }

    }
  }

  cout << "Yes" << endl;
}

Measured memory_bytes: 16848
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
#include <sstream>
#include <queue>
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<ll> l(n);

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

  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < i; j++) {
      for (int k = 0; k < j; k++) {
        if (l[k] != l[j] && l[i] != l[j] && l[k] != l[i]) {
          if (l[k] + l[j] > l[i] && l[k] + l[i] > l[j] && l[i] + l[j] > l[k]) {
            ans++;
          }
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
int gcd(unsigned long long x,unsigned long long y){
	if(y==0) return x;
	else return gcd(y,x%y);
}
int main(){
	unsigned long long a,b;
	cin>>a>>b;
	if(a>=b) cout<<a*b/gcd(a,b);
	if(a<b) cout<<a*b/gcd(b,a);
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
S = []
tmp = -1
for _ in range(m):
  a = int(input())
  S.append(a-tmp-2)
  tmp = a
S.append(n-tmp-1)

fib = [1 for _ in range(n+1)]
for i in range(n-1):
  fib[i+2] = fib[i] + fib[i+1]

total = 1
for x in S:
  if x == -1:
    print(0)
    exit()
  total *= fib[x]

#print(S)
print(total%1000000007)

Measured memory_bytes: 460848
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

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

const int INF = 100000000;
const double EPS = 1e-10;

int d[100001];
int dsum[100001];

int main(){
	string s;
	while(getline(cin, s), s != "END OF INPUT"){
		int cnt = 0;
		rep(i, s.size()+1){
			if(i == s.size()){
				cout << cnt;
				break;
			}
			if(s[i] == ' '){
				cout << cnt;
				cnt = 0;
			}else{
				cnt++;
			}
		}
		cout << endl;
	}


	return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <string>
#include <cstring>

using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    
    string abc;
    
    cin >> abc;
    int check[3];
    for(int i = 0; i < 3; i++){
        check[i] = 0;
    }
    
    for(unsigned int i = 0; i < abc.size(); i++){
        check[abc[i] - 'a']++;
    }
    for(int i = 0; i < 3; i++){
        if (check[i] != 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
//    cout << result << endl;
    
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
arr = list(map(int, input().split()))

l = 0
r = max(arr)

while l + 1 < r:
    m = (l + r) // 2

    cut = 0
    for x in arr:
        cut += (x - 1) // m

    if cut > k:
        l = m
    else:
        r = m

print(r)

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


int main(){
    int a, b, c, cnt;
    cin >> a >> b >> c;
    cnt = 0;
    for(int i = a; i <= b; i++){
        if(c % i == 0){
            cnt++;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
#define int long long
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

const ll MOD = 1e9+7;
const int MAX = 1001001;
ll fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        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;
}
ll powmod(ll x, ll n){
    ll ret=1;
    while(n>0){
        if(n&1){
            ret*=x;
            ret%=MOD;
            n-=1;
        }
        else{
            x*=x;
            x%=MOD;
            n>>=1;
        }
    }
    return ret;
}

signed main(){
    COMinit();
    int n; cin >> n;
    ll a[n];
    map<ll,int> mp;
    rep(i,n){
        cin >> a[i];
        ll t=a[i];
        for(ll j=2;j*j<=a[i];j++){
            ll res=0;
            while(t%j==0){
                res++;
                t/=j;
            }
            chmax(mp[j],res);
        }
        if(t!=1) chmax(mp[t],1LL);
    }
    ll ans=0;
    rep(i,n){
        ans+=inv[a[i]];
        ans%=MOD;
    }
    for(auto itr=mp.begin();itr!=mp.end();itr++){
        ll res=powmod(itr->fi,itr->se);
        ans*=res; ans%=MOD;
    }
    cout << ans << endl;
}


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

int main(){
    string s;
    cin >> s;
    long long n = s.size();
    long long sum = 0;
    for(long long i = 0; i < n; i++){
        sum += s[i] - 48;
    }
    if(sum % 9 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



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

using namespace std;
int main(void){
    int w,h,n,x,y,a;
    int array[4];

    cin >> w >> h >> n;
    array[0]=0;
    array[1]=w;
    array[2]=0;
    array[3]=h;

    for(int i=0; i<n; i++){
        cin >> x >> y >> a;
        switch(a){
            case 1:
                if(array[0]<x)array[0]=x;
                break;

            case 2:
                if(array[1]>x)array[1]=x;
                break;

            case 3:
                if(array[2]<y)array[2]=y;
                break;

            case 4:
                if(array[3]>y)array[3]=y;
                break;
        }
    }
    if((array[1]-array[0])<0 || (array[3]-array[2])<0) cout << 0 << endl;
    else cout << (array[1]-array[0])*(array[3]-array[2]) << endl;
    return 0;
}

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

int n;
double p[3005],dp[3005][3005];

int main() {
	scanf("%d",&n);
	for (int i=1; i<=n; i++) {
		scanf("%lf",&p[i]);
	}
	dp[0][0] = 1;
	for (int i=1; i<=n; i++) {
		for (int j=0; j<=i; j++) {
			dp[i][j] = 0;
			dp[i][j] += dp[i-1][j]*(1-p[i]);
			if (j > 0) dp[i][j] += dp[i-1][j-1]*p[i];
		}
	}
	double ret = 0;
	for (int i=n/2+1; i<=n; i++) {
		ret += dp[n][i];
	}
	printf("%.11f\n",ret);
	return 0;
}


Measured memory_bytes: 68992
#include <bits/stdc++.h>
#define va first
#define vb second
#define lb lower_bound
#define pb push_back
#define all(v) v.begin(),v.end()
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
using ll = long long;
using lf = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
const ll mod = 1e9 + 7;

string S;
int n;
ll p[3005][3005];

int main(){
    fio;
    cin >> n >> S;
    p[0][1] = 1;
    for(int i = 1; i < n; i++){
        for(int j = 1; j <= i+1; j++){
            if(S[i-1] == '<'){
                p[i][j] = p[i-1][j-1];
            }else{
                p[i][j] = (p[i-1][i] + mod - p[i-1][j-1]) % mod;
            }
        }
        for(int j = 1; j <= i+1; j++) p[i][j] = (p[i][j] + p[i][j-1]) % mod;
    }
    cout << p[n-1][n] << '\n';
}

Measured memory_bytes: 68992
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
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 kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
//BIT(蟻本）
struct edge { int to, cost; };
int n, k;
int a[114514];
int memo[114514];
int bit[114514];
P p[114514];
//BIT(蟻本）
int sum(int i) {
	int s = 0;
	while (i) {
		s += bit[i];
		i -= i & -i;
	}
	return s;
}
void add(int i, int x) {
	while (i <= n) {
		bit[i] += x;
		i += i & -i;
	}
}
signed main() {
	cin >> n >> k;
	rep(i, n)cin >> a[i];
	rep(i, n)a[i] = a[i] - k;
	memo[0] = 0;
	for (int i = 1; i <= n; i++)memo[i] = memo[i - 1] + a[i - 1];
	rep(i, n + 1)p[i].first = memo[i], p[i].second = i;
	sort(p, p + n + 1);
	int q = 0;
	rep(i, n + 1) {
		if (p[i].first == p[i + 1].first && i < n) {
			memo[p[i].second] = q + 1;
		}
		else {
			memo[p[i].second] = q + 1;
			q++;
		}
	}
	int ans = 0;
	rep(i, n + 1) {
		ans += sum(memo[i]);
		add(memo[i], (int)1);
	}
	cout << ans << endl;
	ggr
}




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

int n;

int main()
{
    cin >> n;
    if (n % 2 == 1)
    {
        n--;
        int num = n / 2 * (n - 2) + n;
        cout << num << endl;
        for (int i = 1; i <= n; i++)
        {
            cout << i << " " << n + 1 << endl;
        }
    }
    else
    {
        int num = n / 2 * (n - 2);
        cout << num << endl;
    }
    for (int i = 1; i <= n; i++)
    {
        for (int j = i; j <= n; j++)
        {
            if (j == i || j + i == n + 1)
            {
                continue;
            }
            cout << i << " " << j << endl;
        }
    }
    return 0;
}

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

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

        int N = sc.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < a.length; ++i) {
            a[i] = sc.nextInt();
        }

        System.out.println(solve(a));

        sc.close();
    }

    static int solve(int[] a) {
        return Arrays.stream(a).map(Integer::numberOfTrailingZeros).sum();
    }
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

// UnionFindを示す構造体
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

int main() {
  int N, M, K; cin >> N >> M >> K;
  vector<int> ans(N + 1, 0);

  vector<int> A(M), B(M);
  REP(i, M) {
    cin >> A[i] >> B[i];
    ans[A[i]]++; ans[B[i]]++;
  }

  UnionFind uf(N + 1);
  REP(i, M) uf.merge(A[i], B[i]);

  vector<int> C(K), D(K);
  REP(i, K) {
    cin >> C[i] >> D[i];
    // もしブロック関係が同じグループ下に存在しなければ、「友達候補」の候補に入らない
    if(!uf.issame(C[i], D[i])) continue;
    ans[C[i]]++; ans[D[i]]++;
  }

  for(int i = 1; i <= N; ++i) {
    cout << uf.size(i) - ans[i] - 1 << " ";
  }
  cout << endl;
}

Measured memory_bytes: 5568
#include <stdio.h>

int main(void){
   
    int n,m,i,j;
    int a[60]={0};
    int b[60]={0};
    int c[60]={0};
    
    scanf( "%d %d",&n,&m );
    
    for( i = 0; i < m; i++ ){
        scanf( "%d %d",&a[i],&b[i] );
    }
    
    for( i = 1; i <= n; i++ ){
        for( j = 0; j < m; j++){
            if( i == a[j] || i == b[j] ){
                c[i]++;
            }
        }
        printf( "%d\n",c[i] );
    }
    return 0;
}

Measured memory_bytes: 128
cups = {"A": 1, "B": 0, "C": 0}
while True:
    try:
        c1, c2 = raw_input().split(',')
        cups[c1], cups[c2] = cups[c2], cups[c1]
    except EOFError:
        break
    
for k, v in cups.items():
    if v:
        print k

Measured memory_bytes: 6404
#include <iostream>
#include <cmath>
#include <vector>

using namespace std;

int main(){
    int a,b;
    string S;
    cin >> a >>b;
    cin >> S;
    for(int i=0;i<a+b+1;i++){
        if (i==a){
            if (S[i] != '-'){
                cout << "No" << endl;
                return 0;
            }
        }
        else{
            if (std::isdigit(S[i])==0){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
  
}

Measured memory_bytes: 256
import java.io.*
import java.util.*
import java.lang.*
import java.lang.Math.*


fun solve() {
    val (N, D) = rd.readIntArray()
    val X = LongArray(N); val Y = LongArray(N)
    for (i in 0 until N) {
        val (x, y) = rd.readLongArray()
        X[i] = x; Y[i] = y
    }

    var ans = 0
    for (i in 0 until N) {
        if ((X[i]*X[i] + Y[i]*Y[i]) <= (D.toLong() * D.toLong())) {
            ans++
        }
    }

    println(ans)
}


//val rd = debug.Reader("abc", "174", "b", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!!
    } catch (e: Exception) { throw e }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int); data class LongPair(val first: Long, val second: Long)
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}


Measured memory_bytes: 62460
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////

int main() {

	ll n, m;
	cin >> n>> m;

	cout << (n - 1)*(m - 1);

	
	system("PAUSE");
}


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

class Cmondai
{
    static void Main()
    {
        var N = Int32.Parse(Console.ReadLine());
        var A=Console.ReadLine().Split(' ').Select(num => Int32.Parse(num)).ToArray();
        var zenbu = 0L;
        for (int i=0;i<N-1;++i)
        {
            zenbu += Math.Abs(A[i + 1] - A[i]);
        }
        zenbu += Math.Abs(A[0]);
        zenbu += Math.Abs(A[N-1]);
        for (int i = 0; i < N ; ++i)
        {
            var sa = 0;
            if (i == 0)
            {
                sa = (Math.Abs(A[0]) + Math.Abs(A[1] - A[0]))-Math.Abs(A[1]);
            }
            else if(i==N-1)
            {
                sa = (Math.Abs(A[i] - A[i - 1]) + Math.Abs(A[i])) - Math.Abs(A[i - 1]);
            }
            else
            {
                sa = (Math.Abs(A[i] - A[i - 1]) + Math.Abs(A[i + 1] - A[i])) - Math.Abs(A[i + 1] - A[i - 1]);
            }
            var ans = zenbu - sa;
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 26076
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
#include <numeric>
using namespace std;

#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))
#define LLONG_MAX numeric_limits<long long>::max()
#define INT_MAX numeric_limits<int>::max()

typedef long long       ll;
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<vi>		vvi;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " " << p.second << "}";
	return os;
}

template <typename T>
void say(vector<T>& vec, string pad = " ") {
	for (const T& elem : vec)
		cout << elem << pad;
}


/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	int N;
	cin >> N;
	cout << N * (1 + N) / 2 << endl;

	return 0;
}

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

int a, b, c, d;
int main() {
	scanf("%d%d%d%d", &a, &b, &c, &d);
	int left = a + b;
	int right = c + d;

	if (left > right) {
		printf("Left");
	}
	else if (left == right){
		printf("Balanced");
	}
	else {
		printf("Right");
	}
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#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 sl(n) scanf("%lld", &n);
#define si(n) scanf("%d", &n);
#define RepAll(a) for(auto x: a)
#define cout(ans) cout << ans << endl;
typedef long long ll;

using namespace std;
int main()
{
    int n, y;
    scanf("%d %d", &n, &y);
    y /= 1000;
    if( n * 10 < y || n > y)
    {
        return printf("-1 -1 -1\n") * 0;
    }
    bool flag = false;
    for(int i = n; i >= 0; i--)
    {
        for(int j = n - i; j >= 0; j--)
        {
            for(int l = n - i - j; l>=0; l--)
            {
                if((i+j+l==n) && (i*10+j*5+l==y))
                {
                    cout<<i<<" "<<j<<" "<<l<<endl;
                    flag = true;;
                    break;
                }
            }
            if(flag)
                break;
        }
        if(flag)
            break;
    }
    if(!flag)
        return printf("-1 -1 -1\n") * 0;

return 0;
}


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

int n,t,ans;
int a[N];
int mn[N],mx;

int main()
{
	
	cin>>n>>t;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
	{
		if(i) mn[i]=min(a[i],mn[i-1]);
		else mn[i]=a[i];
		mx=max(mx,a[i]-mn[i]);
	}
	for(int i=0;i<n;i++)
		if(a[i]-mn[i]==mx) ans++;
	cout<<ans<<'\n';
	
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<map>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<bitset>
#include<iomanip>
#define BUG puts("no bug")
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define ll long long
#define ull unsigned long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define PER(a,b,c) for(int a=b;a>=c;a--)
#define lb(a) (a&(-a))
#define pp (p<<1)
#define ppp (p<<1|1)
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
using namespace std;
const int MAXN=1e6+5;
int n,m,t;
int v[MAXN];
char s[MAXN];
int main(){
    cin>>n;
    REP(i,1,n){
        cin>>v[i];
    }
    int ans=1e9;
    REP(i,1,100){
        int tmpans=0;
        REP(j,1,n){
            tmpans+=(i-v[j])*(i-v[j]);
        }
        ans=min(ans,tmpans);
    }
    cout<<ans;
}

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

using namespace std;
inline int read()
{
	int ck=0;
	char fu=1;
	char c;
	for(;!isdigit(c);c=getchar())
		if(c=='-')
			fu=-1;
	for(;isdigit(c);c=getchar())
		ck=ck*10+c-'0';
	return fu*ck;
}
const int N=1e5+5;
int a[N],b[N];
int x,y;
int ppt(int a){
	if(a>=0) return a;
	else return -a;
}
int t;
int main()
{	
	int n=read();
	for(int i=1;i<=n;i++){
		cin>>t>>a[i]>>b[i];
		if(ppt(a[i]-x)+ppt(b[i]-y)>t){
			cout<<"No"<<endl;
			return 0;
		}
		if((a[i]+b[i])%2==1&&t%2==0){
			cout<<"No"<<endl;
			return 0;
		}
		if((a[i]+b[i])%2==0&&t%2==1){
			cout<<"No"<<endl;
			return 0;
		}
	} 
	cout<<"Yes"<<endl;
	return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>

int main() {
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if(x - r >= 0) {
        if(y - r >= 0) {
            if(x + r <= W) {
                if(y + r <= H) {
                    printf("Yes\n");
                } else {
                    printf("No\n");
                }
            } else {
                printf("No\n");
            }
        } else {
            printf("No\n");
        }
    } else {
        printf("No\n");
    }
}


Measured memory_bytes: 2108
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readFloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)
	r := readInt()

	ans := 2.0 * float64(r) * math.Pi
	fmt.Println(ans)
}


Measured memory_bytes: 1756
#import math

while True:
    n = int(input())
    if n == 0: break
    t = []
    for i in range(n):
        t.append(int(input()))
    t.sort()
    time = 0
    sum = 0
    for i in range(len(t)):
        time += t[i]
        sum += time
    print(sum-time)


Measured memory_bytes: 5724
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<functional>
#include<string.h>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<list>
#include<queue>
#include<deque>
#include<string>
#include<stack>
#define int long long
using namespace std;

vector<int>V[100000];
int d[100000];
void DFS(int x,int y) {
	for (int i : V[x]) {
		if (y != i&&d[i] == -1) {
			d[i] = d[x] + 1;
			DFS(i, x);
		}
	}
}
signed main() {
	bool OK = false;
	memset(d, -1, sizeof(d));
	d[0] = 0;
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int x, y; cin >> x >> y;
		x--; y--;
		V[x].push_back(y);
		V[y].push_back(x);
	}
	DFS(0, 0);
	for (int i = 0; i < n; i++) {
		for (int j : V[i]) {
			if (abs(d[i] - d[j]) % 2 ==0) {
				OK = true;
			}
		}
	}
	if (OK)cout << n*(n - 1) / 2 - m << endl;
	else {
		int x = 0, y = 0;
		for (int i = 0; i < n; i++) {
			if (d[i] & 1)x++;
			else y++;
		}
		cout << x*y - m << endl;
	}
}

Measured memory_bytes: 8064
#include <stdio.h>

int main(void){
    int N;
    scanf("%d", &N);
    if(N == 1)printf("%s\n", "Hello World");
    if(N == 2){
        int A, B;
        scanf("%d\n%d", &A, &B);
        printf("%d\n", A+B);
    }
    return 0; 
}

Measured memory_bytes: 128
import java.io.*;
import java.util.*;

@SuppressWarnings("unchecked")
public class Main {
    private static final long MOD = (int)1e9 + 7;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];

        for (int i = 0; i < n; ++i) {
            a[i] = in.nextInt();
        }
        for (int i = 0; i < n; ++i) {
            b[n - i - 1] = in.nextInt();
        }

        int x = -1;
        int maxI = Integer.MIN_VALUE;
        int minI = Integer.MAX_VALUE;
        for (int i = 0; i < n; ++i) {
            if (a[i] == b[i]) {
                minI = Math.min(minI, i);
                maxI = Math.max(maxI, i);
                x = a[i];
            }
        }

        int i = 0;
        int idx = minI;
        if (idx != Integer.MAX_VALUE) {
           while (i < n) {
            if (idx >= minI && idx <= maxI && a[i] != x && b[i] != x) {
                int temp = b[i];
                b[i] = x;
                b[idx++] = temp;
            } 
            ++i;
        } 
        }
        

        for (i = 0; i < n; ++i) {
            if (a[i] == b[i]) {
                System.out.println("No");
                return;
            }
        }
        System.out.println("Yes");
        for (i = 0; i < n; ++i) {
            System.out.print(b[i] + " ");
        }
    }
}

Measured memory_bytes: 53744
import sys
from collections import defaultdict
def input(): return sys.stdin.readline().strip()


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))

    B = [0] * (N + 1)
    for i in range(1, N + 1):
        B[i] = B[i - 1] + A[i - 1]
        B[i] %= M
    #print(B)
    
    d = defaultdict(int)
    for b in B: d[b] += 1
    #print(d)
    ans = 0
    for m in d: ans += d[m] * (d[m] - 1) // 2
    print(ans)
    

if __name__ == "__main__":
    main()


Measured memory_bytes: 62576
n=int(input())
w=[]
for i in range(n):
    w.append(str(input()))
a=True
for i in range(n):
    if i ==0:
        a = a
    else:
        a = a and w[i][0]==w[i-1][-1] and w[i] not in w[:i]
if a:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
struct hopcroft{
	vector<int> dist, pair_l, pair_r;
	vector<bool> seen;
	vector<vector<int>> to;
	int n1, n2;
	hopcroft(int n1, int n2) : n1(n1), n2(n2){
		to.resize(n1);
		pair_l.assign(n1, -1);
		pair_r.assign(n2, -1);
		dist.resize(n1);
		seen.resize(n1);
	}
	void add_edge(int u, int v){
		to[u].push_back(v);
	}
	bool bfs(){
		fill(dist.begin(), dist.end(), -1);
		queue<int> q;
		for (int i = 0; i < n1; i++){
			if (pair_l[i] == -1){
				dist[i] = 0;
				q.push(i);
			}
		}
		bool reach_minus = false;
		while (!q.empty()){
			int u = q.front();
			q.pop();
			for (int adj : to[u]){
				int radj = pair_r[adj];
				if (radj == -1){
					reach_minus = true;
				} else if (dist[radj] == -1){
					dist[radj] = dist[u] + 1;
					q.push(radj);
				}
			}
		}
		return reach_minus;
	}
	bool dfs(int u){
		seen[u] = true;
		for (int adj : to[u]){
			int radj = pair_r[adj];
			if (radj == -1 || (!seen[radj] && dist[radj] == dist[u] + 1 && dfs(radj))){
				pair_l[u] = adj;
				pair_r[adj] = u;
				return true;
			}
		}
		return false;
	}
	int max_matching(){
		int res = 0;
		while (bfs()){
			fill(seen.begin(), seen.end(), false);
			for (int i = 0; i < n1; i++)
				if (pair_l[i] == -1 && dfs(i))
					res++;
		}
		return res;
	}
};
const int lim = 10000002;
namespace sieve {
        vector<bool> is_prime;
        void sieve(int n){
                if(is_prime.size() >= n + 1) 
                        return;
                is_prime.assign(n + 1, true);
                is_prime[0] = false;
                is_prime[1] = false;
                int sqrtn = sqrt(n) + 1;
                for(int i = 2; i <= sqrtn; i++) if(is_prime[i]){
                        for(int j = i * i; j <= n; j += i){
                                is_prime[j] = false;
                        }
                }
        }
};
int main(){
	sieve::sieve(lim);
	int n; cin >> n;
	bitset<lim> b;
	for(int i = 0; i < n; i++){
		int x; cin >> x;
		b[x] = 1;
	}
	vector<int> p[2];
	for(int i = 1; i < lim; i++){
		if(b[i] != b[i - 1]){
			p[i%2].push_back(i);
		}
	}
	int l0 = p[0].size(), l1 = p[1].size();
	hopcroft ho(l0, l1);
	assert((l0 + l1) % 2 == 0);
	for(int i = 0; i < l0; i++){
		for(int j = 0; j < l1; j++){
			if(sieve::is_prime[abs(p[0][i] - p[1][j])]){
				ho.add_edge(i, j);
			}
		}
	}
	int fl = ho.max_matching();
	int ans = fl + ((l0 - fl) / 2) * 2 + ((l1 - fl)/2) * 2 + ((((l0 - fl) % 2) + ((l1 - fl) % 2))/2) * 3;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2688
#!venv/bin/python
 
import math
import numpy as np
import random
import copy
import statistics 
import bisect
import heapq
from collections import defaultdict 
 
arg = [int(input()) for i in range(5)]

last_i = 0
min = 100;
for i in range(5):
    if arg[i] % 10 == 0:
        continue
    if arg[i] % 10 < min:
        last_i = i
        min = arg[i] % 10

ans = 0
for i in range(5):
    if last_i == i:
        ans += arg[i]
    else:
        ans += math.ceil(arg[i] / 10) * 10

print(ans)



Measured memory_bytes: 14584
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll ;
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
 const ll inf=1e9+7;
const ll MAX=1e5+5;

ll lcm(ll x,ll y)
{
	return ((x*y)/ __gcd(x,y));
}
void test_cases()
{
ll r,d,x;
cin>>r>>d>>x;

for(ll i=1;i<=10;i++)
{
	x=r*x-d;
	cout<<x<<"\n";
}

}

int main()
{
    fast;
	
	ll t;
//	cin>>t;
	t=1;
	while(t--)
	test_cases();





    
}

		
	
	
	
	


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

#define REP(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define PI 3.141592653589

using namespace std;

void InpAr(int *array, int n){
    REP(i,n) cin >> array[i];
}

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

    string s;
    cin >> s;

    int ctr = 0;

    REP(i,n-2){
        if(s[i] == 'A'){
            if(s[i+1] == 'B'){
                if(s[i+2] == 'C'){
                    ctr ++;
                }
            }
        }
    }
    

    cout << ctr;
    return 0;
}

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


int main(void){
   
   int N;
   double X[200];
   char U[200][30];
   
   scanf("%d",&N);
   
   int i;
   
   for(i = 0;i < N;i++){
      scanf("%lf %s",&X[i],U[i]);
   }
   
   double Y = 0;
   
   for(i = 0;i < N;i++){
      if(strcmp(U[i],"JPY") == 0){
         Y = Y + X[i];
      }
      else {
         Y = Y + X[i]*380000;
      }
   }
   
   printf("%lf\n",Y);
   
   
   return 0;
   
}



Measured memory_bytes: 128
n = int(input())
L = [0]
R = [0]

for i in range(n):
	l, r = map(int, input().split())
	L.append(l)
	R.append(r)

L.sort(reverse = True)
R.sort()

ans = 0
tmp = 0

for i in range(n):
	if L[i] - R[i] > 0:
		ans += 2 * (L[i] - R[i])
	else:
		print(ans)
		break

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

int sumDigit(int n){
  int sum = 0;
  while(n > 0){
    sum += n%10;
    n /= 10;
  }
  return sum;
}

int main(void){
  int n, a, b, i, sum = 0, sumdigit;
  cin >> n >> a >> b;
  for(i = 1; i <= n; i++){
    sumdigit = sumDigit(i);
    if(a <= sumdigit && sumdigit <= b) sum += i;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int x; SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long x; SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
////////////////////////////////////////////////////////////////////
struct edge {
	int to,cap,rev; // rev 逆向きに貼る辺(cap=0で初期化)
};
const int V_MAX = 102;
int V,E;

vector<vector<edge>> G(V_MAX);
vector<int>itr, level;

void bfs(int s){
	level.assign(V,-1); //-1 reset
	queue<int> Q;
	level[s] = 0;
	Q.push(s);
	while(!Q.empty()){
		int v = Q.front(); Q.pop();
		REP(i,G[v].size()){
			edge e = G[v][i];
			if ((e.cap > 0) and (level[e.to] < 0)){// cap > 0 && not visited
				level[e.to] = level[v] + 1;
				Q.push(e.to);
			}
		}
	}
}

int dfs(int v,int t,int flow){
	if (v == t) return flow;
	for(int &i = itr[v]; i < (int)G[v].size(); ++i){
		edge& e = G[v][i];
		if ((e.cap > 0) and (level[v] < level[e.to])){
			int d = dfs(e.to,t,min(flow,e.cap));
			if (d>0){
				e.cap -= d;
				G[e.to][e.rev].cap += d; //逆向きに流せる量を増やす
				return d;
			}
			
		}
	}
	return 0;
}

int main(){
	SCD2(V,E);
	REP(i,E){ //add edge
		int u,v,c; SCD3(u,v,c);
		edge e;
		e.to = v; e.cap = c; e.rev = (int)G[v].size();
		G[u].PB(e);
		e.to = u; e.cap = 0; e.rev = G[u].size()-1;
		G[v].PB(e);
	}

	int flow = 0;
	int f = 0;

	int s = 0;
	int t = V-1;

	while(bfs(s),level[t] >= 0){
		itr.assign(V,0);
		while((f = dfs(s,t,1000000000)) > 0) flow += f;
	}
	
	PRINTD(flow);
	return 0;
}


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,n,i,a,mx,mn;
    set<int>s;
    cin>>x>>n;
    for(i=0; i<n; i++)
    {
        cin>>a;
        s.insert(a);
    }
    for(i=x; ; i--)
    {
        if(s.count(i)==0)
        {
            mn=i;
            break;
        }
    }
    for(i=x; ; i++)
    {
        if(s.count(i)==0)
        {
            mx=i;
            break;
        }
    }
    cout<<((abs(x-mn)<=abs(x-mx))?mn:mx)<<endl;
}


Measured memory_bytes: 3636
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

s,t = list(input().split())
print(t+s)

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

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

int bubblesort(int A[], int n) {

    int cnt = 0;

    for (int i = 1; i < n; i++) {
        int v;
        int j = i-1;
        bool can = true;

        while (can && j >= 0) {
            
            if (A[j] > A[j+1]) {
                v = A[j];
                A[j] = A[j+1];
                A[j+1] = v;
                j--;
                cnt++;
            }

            else 
                can = false;
        }
    }

    return cnt;
}

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

    int A[105];
    REP(i, n)   cin >> A[i];

    int cnt = bubblesort(A, n);

    REP(i, n-1)   cout << A[i] << " ";
                  cout << A[n-1] << endl;
                  
    cout << cnt << endl;
}


Measured memory_bytes: 3120
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
//const ll MOD = 998244353
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (s == "SUN") cout << 7 << endl;
    if (s == "MON") cout << 6 << endl;
    if (s == "TUE") cout << 5 << endl;
    if (s == "WED") cout << 4 << endl;
    if (s == "THU") cout << 3 << endl;
    if (s == "FRI") cout << 2 << endl;
    if (s == "SAT") cout << 1 << endl;
}

Measured memory_bytes: 256