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

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

  bool ans = false;
  if (N.at(0)=='7') ans=true;
  if (N.at(1)=='7') ans=true;
  if (N.at(2)=='7') ans=true;
  
  if (ans) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
} 

Measured memory_bytes: 3624
#define _USE_MATH_DEFINES

#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>


using namespace std;

/* cout << fixed << setprecision(5); */

int main()
{	
	long a,n,Ma,Mi,s;
	n = 0;
	
	cin >> n;
	Ma = -1000001;
	Mi = 1000001;
	s= 0;

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

		if (Ma<a)
		{
			Ma = a;
		}

		if (Mi>a)
		{
			Mi = a;
		}
		
		s = s + a;
	}
	
	cout << Mi << " " <<Ma << " " <<s << endl;


	

	return 0;
}

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

bool pm (long x){
	
	for(long i = 2; i <= ceil( sqrt( x ) ) ; i++){
		if(x % i == 0) return 0;
	}
	return 1;
}

int main(){
	long x;
	
	cin>>x;
	
	for(long j = x; ; j++){
		
		if( (( j % 2 == 1)&&( pm( j ) == 1 ) )||( j == 2 ) ){
			cout<<j<<endl;
			break;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define mp make_pair
#define pb push_back
 
 
typedef long long ll;
typedef long double ld;
 
using namespace std;
const int MAXN = 220000;
 
int n, a, b;
ll x[MAXN];
ll y[MAXN];
set<tuple<ll, ll, int> >  ssx;
set<tuple<ll, ll, int> >  ssy;
vector<pair<ll, ll> > vvx;
vector<pair<ll, ll> > vvy;
int was[MAXN];
 
int main() {
	scanf("%d%d%d", &n, &a, &b);
	--a, --b;
	for (int i = 0; i < n; ++i)
		scanf("%lld%lld", x + i, y + i);
	for (int i = 0; i < n; ++i) {
		ll nx = x[i] - y[i];
		ll ny = x[i] + y[i];
		x[i] = nx;
		y[i] = ny;
	}
	ll d = max(abs(x[a] - x[b]), abs(y[a] - y[b]));
	was[a] = 1;
	was[b] = 1;
	queue<int> qu;
	qu.push(a);
	qu.push(b);
	for (int i = 0; i < n; ++i)
		if (!was[i]) {
			ssx.insert(make_tuple(x[i], y[i], i));
			ssy.insert(make_tuple(y[i], x[i], i));
		}
	while (!qu.empty()) {
		int a = qu.front();
		qu.pop();
		ll xl = x[a] - d;
		ll xr = x[a] + d;
		ll yl = y[a] - d;
		ll yr = y[a] + d;
		auto it = ssx.lower_bound(make_tuple(xl, yl, 0));
		while (it != ssx.end() && get<0>(*it) == xl && get<1>(*it) <= yr) {
			int b = get<2>(*it);
			ssy.erase(make_tuple(y[b], x[b], b));
			was[b] = 1;
			qu.push(b);
			ssx.erase(it++);
		}
		it = ssx.lower_bound(make_tuple(xr, yl, 0));
		while (it != ssx.end() && get<0>(*it) == xr && get<1>(*it) <= yr) {
			int b = get<2>(*it);
			ssy.erase(make_tuple(y[b], x[b], b));
			was[b] = 1;
			qu.push(b);
			ssx.erase(it++);
		}
		it = ssy.lower_bound(make_tuple(yl, xl, 0));
		while (it != ssy.end() && get<0>(*it) == yl && get<1>(*it) <= xr) {
			int b = get<2>(*it);
			ssx.erase(make_tuple(x[b], y[b], b));
			was[b] = 1;
			qu.push(b);
			ssy.erase(it++);
		}
		it = ssy.lower_bound(make_tuple(yr, xl, 0));
		while (it != ssy.end() && get<0>(*it) == yr && get<1>(*it) <= xr) {
			int b = get<2>(*it);
			ssx.erase(make_tuple(x[b], y[b], b));
			was[b] = 1;
			qu.push(b);
			ssy.erase(it++);
		}
	}
	for (int i = 0; i < n; ++i)
		vvx.push_back(make_pair(x[i], y[i]));
	for (int i = 0; i < n; ++i)
		vvy.push_back(make_pair(y[i], x[i]));
	sort(vvx.begin(), vvx.end());
	sort(vvy.begin(), vvy.end());
	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		if (!was[i])
			continue;
		ll xl = x[i] - d;
		ll xr = x[i] + d;
		ll yl = y[i] - d;
		ll yr = y[i] + d;
		ans += lower_bound(vvx.begin(), vvx.end(), make_pair(xl, yr)) - upper_bound(vvx.begin(), vvx.end(), make_pair(xl, yl));
		ans += lower_bound(vvx.begin(), vvx.end(), make_pair(xr, yr)) - upper_bound(vvx.begin(), vvx.end(), make_pair(xr, yl));
		ans += upper_bound(vvy.begin(), vvy.end(), make_pair(yl, xr)) - lower_bound(vvy.begin(), vvy.end(), make_pair(yl, xl));
		ans += upper_bound(vvy.begin(), vvy.end(), make_pair(yr, xr)) - lower_bound(vvy.begin(), vvy.end(), make_pair(yr, xl));
	}
	assert(ans % 2 == 0);
	cout << ans / 2 << "\n";
	return 0;
}

Measured memory_bytes: 20592
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>
 
#pragma GCC optimize("Ofast")
#pragma target("sse", "sse1")
 
#define mp make_pair
#define pb push_back
 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
 mt19937 gen(34);

string s, t;

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#else
//	freopen("memory.in", "r", stdin);
//	freopen("memory.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> s >> t;
	int ans = 0;
	for(int i = 0; i < 3; i++)
		ans += (s[i] == t[i]);
	cout << ans;

	return 0;
}

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

int main() {
  long n,a,b,c,d;
  string ans="NO";
  cin >> n >> a >> b >> c >> d;
  for(long i=0;i<n;i++) {
    if((b-a>=(i*c)-((n-i-1)*d))&&(b-a<=(i*d)-((n-i-1)*c))) ans="YES";
  }
  cout << ans << endl;
}

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

#define rep(i, N) for (int i = 0; i < N; i++)

using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int main()
{

    int N;
    cin >> N;
    vector<int> H(N);
    rep(i, N) cin >> H[i];

    int cnt = 0;
    int cnt_max = 0;
    rep(i, N - 1)
    {
        if (H[i] >= H[i + 1])
            cnt++;
        else
        {
            cnt_max = max(cnt_max, cnt);
            cnt = 0;
        }
    }
    cnt_max = max(cnt_max, cnt);
    cnt = 0;

    cout << cnt_max << endl;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"

using namespace std;
typedef long long ll;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
const ll mod = 1e9 + 7;
#define REP(i, o, n) for (ll i = o; i < n; i++)
#define rep(i, n) REP(i, 0, n)

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

void actual() {
  ll k, x;

  cin >> k >> x;
  ll s = x - k, e = x + k;

  REP(i, s+1, e) {
    if (k == 1) {
      cout << x << endl;
      return;
    }
    if (i == s) {
      printf("%d", i);
    } else {
      printf(" %d", i);
    }
  }
}

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


Measured memory_bytes: 256
/*Bismillahir Rahmanir Rahim
->>Code by Ashraful Islam Paran
->>CUET,CSE
*/
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef unsigned long long ull;
typedef vector<int> vi;
const int MX=2e5+5;
#define f(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define endl "\n"
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;

    return 0;
}



Measured memory_bytes: 3688
#include<iostream>
#include<cstdio>
const int N=105;
int n,a[N];
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",a+i);
    int ans=0,l=1;
    for(int i=2;i<=n+1;i++) {
        if(a[i]!=a[i-1]) {
            ans+=(i-l)/2;
            l=i;
        }
    }
    printf("%d\n",ans);
    return 0;
}


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

#define int long long
struct Fast {Fast() {cin.tie(0); ios::sync_with_stdio(false);}} fast;

signed main(void) {
  bool flag = true;
  int num; // num
  num = 0; // count, result
  // num = numeric_limits<int>::min(); // max
  // num = numeric_limits<int>::max(); // min
  int N;
  // int M;
  // array<int, 10000> A;
  // string yes = "Yes";
  // string no = "No";
  string S;
  // string T;

  S = "";
  
  cin >> N;

  while (N < 0 || 1 < N) {
    int Q, R;
    Q = N / -2;
    R = N - -2 * Q;

    if (R < 0) {
      Q += 1; R += 2;
    }

    if (R == 1) S = "1" + S;
    else S = "0" + S;

    // cout << N << " = " << -2 << " * " << Q << " + " << R << endl;
    N = Q;
    
  }

  if (N == 1) S = "1" + S;
  else S = "0" + S;

  cout << S << endl;
  
  
  // for (auto it = A.begin(); it < A.begin() + N; ++it)
  //   cin >> *it;

  // for (auto it = A.begin(); it < A.begin() + N; ++it)
  //   if (*it % 2 == 0) ++num;

  // cout << num << end;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
    
    int main(){
        int a , b;
        cin >> a >> b;
        if(a == b){
            cout << "Draw" << endl;
        }else if(a == 1){
            cout << "Alice" << endl;
        }else if(b == 1){
            cout << "Bob" << endl;
        }else if(a > b){
            cout << "Alice" << endl;
        }else{
            cout << "Bob" << endl;
        }
        return 0;
    }

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

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

    int n, m, a;
    while (cin >> n >> m >> a, n) {
        vector<vector<int>> v;
        rep(i, m) {
            int h, p, q;
            cin >> h >> p >> q;
            v.emplace_back(vector<int>{h, p, q});
        }
        sort(all(v));
        reverse(all(v));
        rep(i, m) {
            if (v[i][1] == a) {
                a = v[i][2];
            } else if (v[i][2] == a) {
                a = v[i][1];
            }
        }
        cout << a << endl;
    }

}

Measured memory_bytes: 3168
const main = (input: string) => {
  const lines = input.split("\n");
  const RATE = 380000;
  let answer = 0;
  lines.slice(1).map(line => {
    if(line.slice(-3) === "JPY") {
      answer += Number(line.slice(0, -4));
    } else {
      answer += Number(line.slice(0, -4)) * RATE;
    }
  })
  console.log(answer);
}

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


Measured memory_bytes: 7372
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;

lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int main(void) {

  lli A,B,C;
  cin >> A >> B >> C;
  COUT(max(0LL,C - (A - B)));
  
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n, INF<int>), c(n);
    v[0] = 0;
    for (auto &&i : c) scanf("%d", &i);
    for (int i = 0; i < n-1; ++i) {
        for (int j = 1; j <= k; ++j) {
            if(i+j < n) v[i+j] = min(v[i+j],v[i]+abs(c[i+j]-c[i]));
        }
    }
    cout << v[n-1] << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
 
//const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main()
{
	int n;
	cin >> n;
	int h[n];
	bool ck = 1;
	int ans = 0;
	REP(i, n) cin >> h[i];
	REP(i, n){
		ck = 1;
		REP(j, i){
			if (h[j] > h[i]) ck = 0;
		}
		ans += ck;
	}

	cout << ans << endl;

}


Measured memory_bytes: 256
N = int(input())

score = []
for i in range(1, N+1):
    S, P = map(str, input().split())
    score.append((i, S, int(P)))

score_sorted = sorted(score, key=lambda x:(x[1], -x[2]), reverse=False)

for i in range(N):
    print(score_sorted[i][0])


Measured memory_bytes: 3060
n,m,l=map(int,input().split())
a=[list(map(int,input().split()))for _ in range(n)]
b=[list(map(int,input().split()))for _ in range(m)]
for x in[[sum([s*t for s,t in zip(c,l)])for l in zip(*b)]for c in a]:print(*x)


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

using namespace std;

int main()
{
  int x,n;
  cin>>x>>n;
  int A[n];

  if(n==0)
    cout<<x<<"\n";
  else
  {
    int p[101],pp[101];
    int min=0,max=101;
    int count = 0;

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

    for(int j=0;j<n;j++)
    {
      if(p[j]<=max)
        max = p[j];
      if(p[j]>=min)
        min = p[j];
    }

    for(int t=0;t<101;t++)
    {
      int c=0;
      for(int s=0;s<n;s++)
      {
        if(t==p[s])
          c=-1;
      }
       if(c == 0)
       {
            pp[count] = t;
             ++count;
       }
    }
    int resp = 101;

        for(int k = 0; k < count; ++k)
        {
             if(abs(pp[k] - x) <= abs(resp - x))
             {
                if(abs(pp[k] - x) == abs(resp - x))
                {
                    if(pp[k] < resp)
                        resp = pp[k];
                }
                else
                    resp = pp[k];
             }
        }
        cout<<resp;
  }

  return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n, m;
  cin >> n >> m;
  char a[n][n],b[m][m];

  for(int y=0; y<n; y++){
  	for(int x=0; x<n; x++) cin >> a[y][x];
  }
    for(int y=0; y<m; y++){
  	for(int x=0; x<m; x++) cin >> b[y][x];
  }

  bool exist = false;
  for(int ly=0; ly<n; ly++){
  	for(int lx=0; lx<n; lx++) {
    if(ly+m>n || lx+m>n) continue;
      
      bool match =true;
    for(int y=0; y<m; y++){
  		for(int x=0; x<m; x++) {
      		if(a[ly+y][lx+x] != b[y][x]) match =false;
      
    }
  }
  
      if(match) exist = true;
    }
  }
  
  if(exist) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}

Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws FileNotFoundException {

		//    	File file = new File("src/in.txt");
		//    	Scanner sc = new Scanner(file);

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		LinkedHashMap<String, Long> map = new LinkedHashMap<String, Long>();
		for (int i=0;i<N;i++) {
			String S = sort(sc.next());
		    if (map.containsKey(S)) {
		        map.put(S, map.get(S) + 1);
		    } else {
		        map.put(S, (long) 1);
		    }
		}
		long ans = 0;
		for(Long i : map.values()) {
			ans += i*(i-1)/2;
		}
		System.out.println(ans);

	}
	public static String sort(String S) {
		char[] C = S.toCharArray();
		Arrays.sort(C);
		S = new String(C);

		return S;

	}
}

Measured memory_bytes: 56296
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>

using namespace std;

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

#define rep(i, a, N) for(int i = a; i < N; i++)
#define rrep(i, a, N) for(int i = a; i >= N; i--)

const int INF = 1e9+7;

int main() {
    int N, K;
    scanf("%d %d", &N, &K);

    int cnt = 0;
    map<int, int> A;
    rep(i, 0, N) {
        int a;
        scanf("%d", &a);
        if (A.count(a)) A[a]++;
        else { 
            A[a] = 1;
            cnt++;
        }
    }

    vector<int> B;
    for (auto it = A.begin(); it != A.end(); it++) {
        B.push_back(it->second);
    }
    sort(B.begin(), B.end());

    int ans = 0;
    for (auto it = B.begin(); it != B.end(); it++) {
        if (cnt <= K) break;
        ans += *it;
        cnt--;
    }
    printf("%d\n", ans);
}

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

using namespace std;

#define ll long long
const int MOD = (int)1e9+7;

void solve() {
	int n, i;
	cin >> n;
	string s, s1;
	cin >> s >> s1;
	ll x;
	bool t = false;
	if (s[0] == s[1]) {
		x = 6;
		i = 2;
		t = true;
	} else {
		x = 3;
		i = 1;
		t = false;
	}
	for (; i < n; i++) {
		if (t) {
			if (s[i] == s[i+1]) {
				x = x * 3 % MOD;
				i++;
				t = true;
			} else {
				x = x % MOD;
				t = false;
			}
		} else {
			if (s[i] == s[i+1]) {
				i++;
				t = true;
			} else {
				t = false;
			}
			x = x * 2 % MOD;
		}
	}
	cout << x << "\n";
}

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

	int t = 1, i = 1;
	//cin >> t;
	while(t--) {
		//cout << "Case #" << i << ": ";
		solve();
		//i++;
	}
	return 0;
}



Measured memory_bytes: 3660
N=int(input())
AList = list(map(int, input().split()))
BList = list(map(int, input().split()))

Asum=sum(AList)

i=0
while i<N:
    Amari=max(0,BList[i]-AList[i])
    AList[i]=max(AList[i]-BList[i],0)
    AList[i+1]=max(AList[i+1]-Amari,0)
    
    
    i+=1

print(Asum-sum(AList))

Measured memory_bytes: 19156
#include <iostream>
#include <vector>

using namespace std;

int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    
    int prev = 0;
    unsigned long sum = 0;
    vector<int> A;
    A.push_back(0);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        sum += abs(prev-a);
        A.push_back(a);
        prev = a;
    }
    A.push_back(0);
    sum += abs(A[A.size()-2]);
    for (int i = 2; i < A.size(); i++) {
        int diff = 0;
        int a = A[i-2];
        int b = A[i-1];
        int c = A[i];
        if ((c<=a&&a<=b)||(b<=a&&a<=c)) {
            diff = -2*abs(b-a);
        }else if ((a<=c&&c<=b)||(b<=c&&c<=a)) {
            diff = -2*abs(c-b);
        }
        cout << sum+diff << endl;
    }
}


Measured memory_bytes: 1784
cmin = lambda a,b : a if a<b else b
cmax = lambda a,b : a if a>b else b
iin = lambda : int(input())
lin = lambda : list(map(int,input().split()))
rin = lambda n : [int(input()) for _ in range(n)]

s = input()

count = 0
for i in range(len(s)//2):
    a = s[i]
    b = s[-i-1]
    if a!=b: count += 1

print(count)

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

using i64 = int64_t;

pair<int, int> func(int n){
    pair<int, int> res;
    res.second = n%10;
    int m = n;
    while(m > 0){
        res.first = m%10;
        m /= 10;
    }
    return res;
}

int main(){
    int n;
    cin >> n;
    map<pair<int, int>, int> mp;
    for(int i=1;i<=n;++i){
        auto p = func(i);
        mp[p]++;
    }
    i64 ans = 0;
    map<pair<int, int>, bool> used;
    for(auto e: mp){
        auto p = e.first;
        if(used[p])continue;
        cerr << p.first << " " << p.second << " " << e.second << endl;
        auto p2 = make_pair(p.second, p.first);
        if(p == p2){
            cerr << mp[p] * mp[p] << endl;
            ans += mp[p] * mp[p];
            used[p] = true;
        }else{
            cerr << mp[p] * mp[p2] * 2 << endl;
            ans += mp[p] * mp[p2] * 2;
            used[p] = true;
            used[p2] = true;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod  1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

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

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

bool comp(pair<ll, pair<ll, int> > a, pair<ll, pair<ll, int> > b){
  return (a.first + a.second.first < b.first + b.second.first);
}

int main(){
  int N;
  cin >> N;
  vector<pair<ll, int> > A(N), B(N);
  vector<pair<ll, pair<ll, int> > > data;
  pair<ll, pair<ll, int> > a;
  rep(i, N) {
    cin >> A[i].first >> B[i].first;
    A[i].second = B[i].second = i;
    a.first = A[i].first; a.second.first = B[i].first;
    a.second.second = i;
    data.pb(a);
  }

  sort(all(data), comp); reverse(all(data));

  vector<bool> used(N + 1);
  ll cnt = 0, sum_a = 0, sum_b = 0;
  for(int i = 0; i < N; i++){
    if(i % 2 == 0){
      sum_a += data[i].first;
    }else{
      sum_b += data[i].second.first;
    }
  }
  cout << sum_a - sum_b << endl;
  return 0;
}


Measured memory_bytes: 7924
from collections import Counter
N = int(input())
a = [int(a) for a in input().strip().split()]

def fac2(n):
    count = 0
    while n % 2 == 0:
        n = n / 2
        count += 1
    return count

ans = 0
for ai in a:
    ans += fac2(ai)

print(ans)


Measured memory_bytes: 4532
while True:
    N = int(input())
    if N == 0:
        break
    ans = 0
    for i in range(1, N + 1):
        for j in range(i + 1, N + 1):
            if (i + j) * (j - i + 1) / 2 == N + 0.0:
                ans += 1
    print(ans)



Measured memory_bytes: 5600
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))

vc = sorted([v[i] - c[i] for i in range(n)], reverse=True)

k = 0

for vc_i in vc:
    if vc_i > 0:
        k += vc_i

print(k)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s, n) for(int i = s; i < (int)(n); i++)
#define co(x) cout<<x<<endl
#define SQvec(i,j) vector<vector<int>> data(i, vector<int>(j))
#define mod 1000000000+7
typedef long long int lint;

int main (){
  int D,M;
  cin >> D >> M;
  if(M == 100){M++;}
  if(D == 0){co(M);}
  else if(D == 1){co(100*M);}
  else if(D == 2){co(10000*M);}
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
//#include<bits/stdc++.h>
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
//const int mod = 1e9 + 7;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b + c || b == a + c || c == a + b) { print("Yes"); }
	else {
		print("No")
	}
	return 0;

}

Measured memory_bytes: 256
n, k = [int(m) for m in input().split()]
mod = 10 ** 9 + 7

ans = 0
for i in range(k, n + 2):
    ans += (n * (n + 1) // 2 - (n - i) * (n - i + 1) // 2) - i * (i - 1) // 2 + 1
    ans %= mod

print(ans)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int a, b;
  cin >> a >> b;
  int ans = a + b;
  ans = max(ans, a - b);
  ans = max(ans, a * b);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3460
#include <bits/stdc++.h>
using namespace std;
#define PB push_back
#define ZERO (1e-10)
#define INF int(1e9+1)
#define CL(A,I) (memset(A,I,sizeof(A)))
#define DEB printf("DEB!\n");
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define EQ(A,B) (A+ZERO>B&&A-ZERO<B)
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define IN(n) int n;scanf("%d",&n);
#define FOR(i, m, n) for (int i(m); i < n; i++)
#define F(n) FOR(i,0,n)
#define FF(n) FOR(j,0,n)
#define FT(m, n) FOR(k, m, n)
#define aa first
#define bb second
void ga(int N,int *A){F(N)scanf("%d",A+i);}
ll A[5],N,W,a;
int main(void){
    scanf("%lld",&N);
    F(5)scanf("%lld",A+i);
    F(5){
        a=N/A[i]+!!(N%A[i])+4;
        W=max(W,a);
    }
    printf("%lld\n",W);
    return 0;
}


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


void solve(long long A, std::string op, long long B){
  if(op == "+") {
    cout << (A+B) << endl;
  }
  else {
    cout << (A-B) << endl;
  }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
  scanf("%lld",&A);
  std::string op;
  std::cin >> op;
  long long B;
  scanf("%lld",&B);
    solve(A, op, B);
    return 0;
}


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

const int MAX=3000000;
const int MOD=1000000007;

long long fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
  fac[0]=fac[1]=1;
  inv[1]=1;
  finv[0]=finv[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;
  }
}

long long choose(int x,int y){
  if(x<y) return 0;
  if(x<0||y<0) return 0;
  return fac[x]*(finv[y]*finv[x-y]%MOD)%MOD;
}

int main(){
  
  COMinit();
  
  long long r,c,R,C;
  cin >> r >> c >> R >> C;
  
  R++;
  C++;
  cout << (MOD+(choose(R+C,R)+choose(r+c,r)-choose(R+c,c)-choose(r+C,r)))%MOD << endl;
}


Measured memory_bytes: 70528
#pragma GCC optimize("O3")
#define first x
#define second y
#include <bits/stdc++.h>

using namespace std;

enum {MOD0 = 1000000000, MOD7 = 1000000007, MOD9 = 1000000009};
typedef unsigned short ushort;typedef unsigned int uint;typedef long long ll;typedef unsigned long long ull;
#ifndef CrafterKolyan
#define endl '\n'
#endif

void solve() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if (d < b || a < b) {
        cout << "No" << endl;
        return;
    }
    a %= b;
    d %= b;
    if (b <= c) {
        cout << "Yes" << endl;
        return;
    }
    if (d == 0) {
        if (a <= c) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
        return;
    }
    ll g = __gcd(d, b);
    a %= g;
    ll t = b - g + a;
    if (t > c) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}

int main() {
#ifndef CrafterKolyan
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    //freopen("input.txt", "r", stdin);
    int T;
    cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
ll A[int(2e5+5)], B[int(2e5+5)];

int main(){
  cin >> N;
  for (int i = 0; i < N; i++){
    ll X, Y; cin >> X >> Y;
    A[i] = X - Y;
    B[i] = X + Y;
  }
  sort(A, A + N);
  sort(B, B + N);
  cout << max(A[N-1] - A[0], B[N-1] - B[0]) << endl;

  return 0;
}


Measured memory_bytes: 6716
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int n;
    cin >> n;
    int64 ans = 1;
    vector a(n,0LL);
    for (int i=0; i<n; i++) cin >> a[i];

    if (any_of(a.begin(), a.end(), [](const int64& x){return x == 0LL;})) {
        cout << 0 << endl;
        return 0;
    }

    for (int i=0; i<n; i++) {
        bool f = __builtin_mul_overflow(ans,a[i],&ans);
        if (f || ans > 1000000000000000000LL) {
            ans = -1;
            break;
        }
    }

    cout << ans << endl;
}

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

int main() {
    string S;
    cin >> S;
    int N = S.size() + 1;
    vector<ll> A(N, 0);
    rep(i, N - 1) if (S[i] == '<') A[i + 1] = A[i] + 1;
    rep(i, N - 1) if (S[N - 2 - i] == '>') A[N - 2 - i] =
        max(A[N - 2 - i], A[N - 1 - i] + 1);

    ll ans = 0;
    rep(i, N) ans += A[i];
    cout << ans << endl;
}


Measured memory_bytes: 7716
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

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

    if (2*n > m) {
        cout << m/2 << endl;
    } else {
        cout << n + (m - 2*n)/4 << endl;
    }

    return 0;
}

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

int main() {
 int s,ans;
 int cnt =0;
 vector<int> num(1000000);
  cin >> s;
  num[0] = s;
  if(s==2 || s==1 ){
  cout << 4 << endl;
  return 0;
  }

   else{  for(int i=0;i<1000000;i++){

     if(num[i]==4){
     cnt++;
     num[i+1] = num[i]/2;

     if(cnt ==2){
      ans = i+1;
      break;
      }
     }


    else if(num[i]%2==0 && num[i] !=4){
      num[i+1] = num[i]/2;
     }
    else {
     num[i+1] = num[i]*3+1;
     }


  }
}
 cout << ans << endl;
}

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

#define deb(x) cerr<<"["#x<<" : "<<x<<" ]\n";

int main()
{
	using ll = long long;
	ll n, y;
	cin >> n >> y;
	ll k = y - 1000*n;
	deb(k);
	int b = 0, a = 0;
	
	while(true) {
		if((k - (4000*b)) < 0) {
			puts("-1 -1 -1");
			return 0;
		}
		
		if((k - 4000*b) % 9000 == 0) {
			a = (k - 4000*b) / 9000;
			deb(a);
			deb(b);
			break;
		}
		b++;
	}
	
	if((n - a - b) < 0) puts("-1 -1 -1");
	else cout << a << ' ' << b << ' ' << n-a-b;
	
}


Measured memory_bytes: 3628
N = int(input())
A = list(map(int,input().split()))
import fractions
mod = 10**9+7
lcm = A[0]
for i in range(1,N):
    lcm = lcm*A[i]//fractions.gcd(lcm,A[i])
ans = 0
for i in range(N):
    ans += lcm*pow(A[i],mod-2,mod)
print(ans%mod)

Measured memory_bytes: 68056
#include <bits/stdc++.h>
#define ALL(a) (a).begin(),(a).end()
#define N_MAX 1000
#define ll long long int
using namespace std;

int main() {
	ll N; cin >> N;
	vector<ll> H(N);
	for (int i = 0; i < N; i++) cin >> H[i];

	vector<ll> C(N);

	for (int i = 1; i < N; i++) {
		if (H[i-1] >= H[i]) C[i] = C[i - 1] + 1;
		else C[i] = 0;
	}

	sort(C.begin(), C.end());
	cout << C[N - 1] << endl;
}


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int D, T, S; cin >> D >> T >> S;
    if(S*T >= D) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main() {
    int ti=clock();
   long long N;
   cin >> N;
   vector<long long> f(N);
   for (int i=0; i<N; i++) {
       f[i]=1;
   }
   for (long long i=2; i<=N; i++) {
       for (long long j=1; j<=N/i; j++) {
           f[i*j-1]++;
       }
   }
   long long total=0;
   for (long long i=0; i<N; i++) {
       long long a=(i+1)*f[i];
       total+=a;
   }
   cout << total << endl;
}

Measured memory_bytes: 81472
#include<stdio.h>
int main(void)
{
	float a;
	int s,d[13],f,g,h,i,j,z;
	while(1){
		scanf("%f",&a);
		h=0;
		z=a;
		if(z<0){
			break;
		}
		for(i=1;i<=12;i++){
			d[i]=0;
		}
		//printf("%f",a);
		f=a*16;
		i=4096;
		//printf("a == %f\n",a*16);
		s=f;
		j=1;
		while(i!=1){
			i=i/2;
			if(i<=f){
				d[j]=f/i;
				//printf("d[%d] = %d %d %d\n",j,d[j],i,f);
				f=f-i;
			}
			j++;
		}
		if(a>=4096){
			printf("NA\n");
			h=1;
			//printf("1111\n");
		}
		if(d[12]!=1&&d[12]!=0&&h==0){
			printf("NA\n");
			h=1;
		}
		if((a*16)-s>0&&h==0){
			//printf("2222 = %d\n",a*16-s);
			printf("NA\n");
			h=1;
		}
		/*for(i=0;i<12;i++){
			printf("%d\n",d[i]);
		}*/
		if(h==0){
			for(i=1;i<=12;i++){
				printf("%d",d[i]);
				if(i==8){
					printf(".");
				}
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1072
N, M = map(int, input().split())
from collections import defaultdict
edges = defaultdict(list)
for i in range(M):
    a,b = map(int, input().split())
    edges[a].append(b)
    edges[b].append(a)
# print(edges)
# print(1,edges[1])
first = edges[1]
# print("----")
for e in first:
    # print(e,edges[e]) 
    second = edges[e]
    if N in second:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>


int main(){
    int N; cin>>N;
    int num_f = 0;
    int num_t = 0;
    int num_r = 0;
    REP(i,N){
        ll a; cin >> a;
        if(a%4==0){ ++num_f; }
        else if(a%2==0){ ++num_t;}
        else{ ++num_r; }
    }
    bool ok;
    if(num_f>=num_r){ ok = true; }
    else{ 
      if(num_t==0 && num_f>=num_r-1){ ok = true;}
      else{ ok = false;}
    }
    cout << (ok?Liny:Linn);
}

Measured memory_bytes: 256
//binarySearch
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;

int A[1000000], n;

int main(void){
    cin >> n;
    for(int i = 0; i < n; i++){
        scanf("%d", &A[i]);
    }
    
    int q, k, sum = 0;
    cin >> q;
    for(int i = 0; i < q; i++){
        scanf("%d", &k);
        if(*lower_bound(A, A + n, k) == k)  sum++;
    }
    
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 1632
L = str(input())
mod = 10 ** 9 + 7

dp = [[0, 0] for _ in range(100002)]
dp[0][0] = 1
N = len(L)
for i in range(N):
    if L[i] == '0':  # dp[i][0]: i桁目で
        dp[i+1][0] = dp[i][0]
        dp[i+1][1] = dp[i][1]
    else:
        dp[i+1][1] = (dp[i][0] + dp[i][1]) % mod

    if L[i] == '0':
        dp[i+1][1] += dp[i][1] * 2 % mod
    else:
        dp[i+1][0] += dp[i][0] * 2 % mod
        dp[i+1][1] += dp[i][1] * 2 % mod

ans = (dp[N][0] + dp[N][1]) % mod
print(ans)

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

int main() {
  int N, K;
  cin >> N >> K;
  
  int sum = 0;
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    sum += min(2 * x, 2 * (K - x));
  }
  cout << sum << endl;
}


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

using namespace std;

template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}

class Solution {
public:
	void solve() {
		int h, w, k;
		cin >> h >> w >> k;
		vector<string> b(h);
		for(int i=0; i<h; i++)cin >> b[i];
		vector<vector<int>> ans(h, vector<int>(w, 0));
		int fy = -1;
		int id = 0;
		for(int i=0; i < h; i++){
			int fx = -1;
			for(int j=0; j < w; j++){
				if(b[i][j] =='#'){
					id++;
					if(fx == -1)for(int k = j; k >= 0; k--)ans[i][k] = id;
					else ans[i][j] = id;
					fx = j;
				}else{
					if(fx != -1)ans[i][j] = id;
				}
			}
		}
		for(int i=0; i < h; i++){
			for(int j=0; j < w; j++){
				if(ans[i][j] != 0){
					for(int k = i-1; k >= 0; k--){
						if(ans[k][j]!=0)break;
						ans[k][j] = ans[i][j];
					}
					for(int k = i+1; k < h; k++){
						if(ans[k][j]!=0)break;
						ans[k][j] = ans[i][j];
					}
				}
			}
		}
		for(int i=0; i < h; i++){
			for(int j=0; j<w; j++)cout << ans[i][j] << " ";
			cout << "\n";
		}		
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)
#define pi 3.141592653589793238462643

void solve(){
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll ans = 0;
    loop(i,0,n-2){
        string t(s, i, 3);
        if(t == "ABC"){
            ans++;
        }
    }
    print(ans);
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
     
}


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

#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
namespace adaptor = boost::adaptors;

// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */

using ll = long long;
using ull = unsigned long long;

void Main()
{
	ull A;
	cin >> A;

	string B;
	cin >> B;

	auto p = B.find(".");
	B = B.erase(p, 1);
	
	ull t = stoull(B);

	ull x = (A * t) / 100;
	cout << x;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

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

signed main() {
  int n;
  cin >> n;
  if(n%1000 == 0) cout << 0 << endl;
  else cout << 1000 - n % 1000 << endl;
}


Measured memory_bytes: 3620
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void debug(String str) {
        System.out.println(str);
    }

    public static void main(String[] args) {

        long N,K;
        long R,S,P;
        String T;
        try (Scanner sc = new Scanner(System.in)) {
            N = sc.nextLong();
            K = sc.nextLong();
            
            R = sc.nextLong();
            S = sc.nextLong();
            P = sc.nextLong();
            
            T = sc.next();   
        }
        
        char[] carray= T.toCharArray();
        long kouho =0;
        for (int i = 1; i <= K; i++) {
            //グループi carrys[K*j + (i-1)]
            int j = 0;
            
            List<Character> list= new LinkedList<>();
            while(K*j + (i-1) < N) {
                list.add(carray[(int)K*j + (i-1)]);
                j++;
            }
            kouho +=cal(list,R,S,P);
        }
        

        System.out.println(kouho);
    }
    
    private static long cal(List<Character> list,long R,long S,long P) {
        Character[] c = list.toArray(new Character[list.size()]);
        //勝てる相手の手
        int rCount = 0;
        int sCount = 0;
        int pCount = 0;
        
        int count = 1;
        Character pre= c[0];
        for (int i = 1; i < c.length; i++) {
            if(pre == c[i]) {
                count++;
            }else {
                //最大の勝てる手
                count++;
                if(pre == 'r') {
                    rCount += (count/2);
                }else if(pre == 's') {
                    sCount += (count/2);
                }else {
                    pCount += (count/2);
                }
                pre = c[i];
                count=1;
            }
        }
        //最大の勝てる手
        count++;
        if(pre == 'r') {
            rCount += (count/2);
        }else if(pre == 's') {
            sCount += (count/2);
        }else {
            pCount += (count/2);
        }
        long result = 0;
        result += rCount * P;
        result += sCount * R;
        result += pCount * S;
        return result;
    }
}


Measured memory_bytes: 31984
use std::collections::BTreeSet;
use std::cmp;

fn main(){
    let mut sc = Scanner::new();
    let n = sc.next();
    let x : i64 = sc.next();
    let mut a = vec![0i64; n];
    for e in a.iter_mut() { *e = sc.next(); }
    let mut ans = a.iter().fold(0, |x, y| x + y);
    a.resize(n*2, 0);
    for i in 0..n { a[i+n] = a[i]; }

    for mg in 1..n {
        let mut s:BTreeSet<(i64, usize)> = (n-mg..n).map(|i| (a[i], i)).collect();
        let mut cand = x*mg as i64;
        for j in n..n+n {
            let min = *s.iter().nth(0).unwrap();
            cand += cmp::min(min.0 as i64, a[j]);
            s.remove(&(a[j-mg], j-mg));
            s.insert((a[j], j));
        }
        ans = cmp::min(ans, cand);
    }
    println!("{}", ans);
}

// Scanner

#[allow(dead_code)]
struct Scanner {
    token_buffer : Vec<String>,
    index : usize,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner{
        Scanner { token_buffer: vec![], index: 0 }
    }

    fn wrapped<T>(& mut self) -> Result<T,&str> where T: std::str::FromStr {
        let s = try!(self.fetch_token());
        let t = try!(s.parse::<T>().map_err(|_| "Parse error"));
        Ok(t)
    }
    fn next<T>(& mut self) -> T where T: std::str::FromStr {
        self.wrapped::<T>().unwrap()
    }

    fn fetch_token(&mut self) -> Result<&String,&str> {
        while self.index >= self.token_buffer.len() {
            let mut st = String::new();
            while st.trim() == "" {
                match std::io::stdin().read_line(&mut st) {
                    Ok(l) if l > 0 => continue,
                    Ok(_)  => return Err("End of file"),
                    Err(_) => return Err("Failed to read line"),
                }
            }
            self.token_buffer = st.split_whitespace()
                .map(|x| x.to_string())
                .collect();
            self.index = 0;
        }

        self.index += 1;
        Ok(&self.token_buffer[self.index - 1])
    }
}


Measured memory_bytes: 764
///-BISMILLAHIR RAHMANIR RAHIM-///
#include <bits/stdc++.h>
#include<vector>
#include<string>
using namespace std;
#define pb push_back
#define scn(n) scanf("%lld",&n)
#define pi acos(-1)
#define ll long long
#define llu unsigned long long
#define mod 1000000007
int main()
{
    double x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;
    printf("%.8lf\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
    return 0;
}



Measured memory_bytes: 3284
/*
 * main.c
 *
 *  Created on: 2020/02/22
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}


int main()
{
	ll a = 0, b = 0, c = 0;
	int ans = 0;
	scanf("%lld %lld %lld", &a, &b, &c);
	if ((c - a - b) < 0) {
		ans = 1;
	} else {
		if ((4*a*b) < ((c-a-b) * (c-a-b))) {
		} else {
			ans = 1;
		}
	}
	if (ans == 0) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
    return 0;
}


Measured memory_bytes: 128
fun main(args: Array<String>) {
  val (a,b) = readLine()!!.split(" ").map(String::toInt)
  if (a > b) {
    pri(b,a)
  } else {
    pri(a,b)
  }
}
  
fun pri(a: Int, n: Int) {
  for (i in 1..n) {
      print(a) 
    }
    println()
}

Measured memory_bytes: 37860