akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define LL long long
#define MOD 1000000007
#define INF 2000000000
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
ll N, M, K,H,W, mi1,mi2,sum,B[102],C[102];
LL ans;
LL no;
bool b,bb[1000000000];
string s,t;

int main() {
	cin >> N;

	for (int i = 1; i <N; i++) {
		cin >> B[i];
	}
	B[0] = B[N] = INF;
	C[1] = B[1];
	ans = 0;
	for (int i = 2; i <= N; i++) {
		C[i] = min(B[i - 1], B[i]);
		ans += C[i];
	}
	cout << ans+C[1] << endl;



	return 0;
}



Measured memory_bytes: 256
package main

import "fmt"

func main() {

	var N int
	fmt.Scan(&N)
	var S string
	fmt.Scan(&S)

	var ans string
	for i :=0; i < N; {
		if i < N-1 && S[i] == S[i+1]{
			i++
		}else {
			ans = ans + string(S[i])
			i++
		}
	}
	fmt.Println(len(ans))

}


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

#define int ll
#define FOR(i,n,k) for(int i=n;i<k;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    int a[n],ans = INT_MAX;
    FOR(i,0,n) cin>>a[i];
    for(int i=-100;i<=100;i++)
    {
        int cur = 0;
        FOR(j,0,n) cur+= (a[j]-i) * (a[j]-i);
        ans = min(cur,ans);
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c,d,e,f,g,h;
	while(scanf("%d%d%d%d%d",&a,&b,&c,&d,&e),a){
		scanf("%d%d%d",&f,&g,&h);
		int ret=a*f+b*g+c*h;
		for(int i=1;i<=f+g+h;i++){
			int val=max(i,d)*e;
			if(i<h){
				val+=(h-i)*c+b*g+a*f;
			}else if(i<g+h){
				val+=(g+h-i)*b+a*f;
			}else{
				val+=(f+g+h-i)*a;
			}
			ret=min(ret,val);
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 1028
//
// C - Together
//

#include <iostream>

using namespace std;

int N;
int X_[100003] = {0};
int *X;

int main() {

    cin >> N;

    X = &X_[1];

    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        X[a - 1]++;
        X[a]++;
        X[a + 1]++;
    }

    int ans = 0;
    for (int i = -1; i <= 100001; i++) {
        ans = max(ans, X[i]);
    }

    cout << ans << endl;
}

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

int main(void) {
	long long H, W, N;
	std::cin >> H >> W >> N;
	//std::vector<std::vector<bool> > board(H, std::vector<bool>(W, false));
	std::set<std::pair<int, int> > board;
	std::vector<long long> result(10, 0);
	result[0] = (H - 2) * (W - 2);
	for(int i = 0; i < N; ++i) {
		int a, b;
		std::cin >> a >> b;
		--a;
		--b;
		for(int cy = std::max(a - 1, 1); cy <= std::min(a + 1, static_cast<int>(H - 2)); ++cy) {
			for(int cx = std::max(b - 1, 1); cx <= std::min(b + 1, static_cast<int>(W - 2)); ++cx) {
				int s = 0;
				for(int sy = cy - 1; sy <= cy + 1; ++sy) {
					for(int sx = cx - 1; sx <= cx + 1; ++sx) {
						//if(board[sy][sx]) ++s;
						if(board.find(std::make_pair(sy, sx)) != board.end()) ++s;
					}
				}
				--result[s];
				++result[s + 1];
			}
		}
		//board[a][b] = true;
		board.insert(std::make_pair(a, b));
	}
	for(int i = 0; i < 10; ++i) {
		std::cout << result[i] << '\n';
	}
	return 0;
}



Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    ll X, K, D;
    cin >> X >> K >> D;

    ll minK = abs(X) / D, ans;
    if (K > minK) {
        ans = abs(X) - minK * D;
        ll rest = K - minK;
        if (rest % 2 == 1) {
            ans = D - ans;
        }
    } else {
        ans = abs(X) - K * D;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
  int A,B,Q;
  cin>>A>>B>>Q;
  long long s,t;
  vector<long long> S,T;
  for(int i=0;i<A;++i){
    cin>>s;
    S.push_back(s);
  }
  for(int i=0;i<B;++i){
    cin>>t;
    T.push_back(t);
  }  
//ベクトルをソート 
  sort(S.begin(),S.end());
  sort(T.begin(),T.end());
  long long s_max,s_min,t_max,t_min;
  s_max=S[A-1];
  s_min=S[0];
  t_max=T[B-1];
  t_min=T[0];
  //upper_boundで次の地点を探す
  long long x,ans,ans1,ans2,ans3,ans4;
  vector<long long>::iterator its,itt;
  for(int i=0;i<Q;++i){
    ans=1000000000000;
    ans1=1000000000000;
    ans2=1000000000000;
    ans3=1000000000000;
    ans4=1000000000000;
    //ありうるパターンは[寺、神社]について[西、西]、[西、東]、[東、西]、[東、東]
    cin>>x;
    //寺が一択になる場合
    
    //神社が一択になる場合
    
    its=lower_bound(S.begin(),S.end(),x);
    itt=lower_bound(T.begin(),T.end(),x);
    //西、西
    ans1=max(*itt-x,*its-x);
    //東、東
    ans2=max(x-*(itt-1),x-*(its-1));
    //西、東
    ans3=(*itt-x)+(x-*(its-1))+min((*itt-x),(x-*(its-1)));
    //東、西
    ans4=(*its-x)+(x-*(itt-1))+min((*its-x),(x-*(itt-1)));
    //ダメなやつを判定
    if(x<s_min){
      ans2=1000000000000;
      ans3=1000000000000;
    }
    if(x<t_min){
      ans2=1000000000000;
      ans4=1000000000000;
    }
    if(x>s_max){
      ans1=1000000000000;
      ans4=1000000000000;
    }
    if(x>t_max){
      ans1=1000000000000;
      ans3=1000000000000;
    }
    
    ans=min(ans1,ans2);
    ans=min(ans,ans3);
    ans=min(ans,ans4);
    cout<<ans<<"\n";
  }
return 0;
}


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

int main() {
  	int price = 700;
  	string S;
  	cin >> S;
  	for(int i = 0; i < S.length(); i++){
    	if(S[i] == 'o'){
        	price += 100;
        }
    }
  	cout << price << endl;
  	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 100
#define INF 1<<25
int n,p[N+1],m[N+1][N+1];
int matrixchainmultiplication(){
  for(int i=1;i<=n;i++) m[i][i]=0;
  for(int l=2;l<=n;l++){
    for(int i=1;i<=n-l+1;i++){
      int j=i+l-1;
      m[i][j]=INF;
      for(int k=i;k<=j-1;k++){
	m[i][j]=min(m[i][j],m[i][k]+m[k+1][j]+p[i-1]*p[k]*p[j]);
      }
    }
  }
  return m[1][n];
}
int main(){
  cin>>n;
  for(int i=0;i<n;i++) cin>>p[i]>>p[i+1];
  cout<<matrixchainmultiplication()<<endl;
  return 0;
}

Measured memory_bytes: 3116
#include<iostream>
#include<string>
#include <cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define ll long long
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define all(c) (c).begin(), (c).end()
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  ll l[n+1];
  rep(i,n+1){
    l[i]=0;
  }
  l[0]=2;
  l[1]=1;
  for(int i = 2;i < n+1; i++){
    l[i] = l[i-1]+l[i-2];
  }
  cout << l[n] << endl;
}


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

int main()
{
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    if(a1 + a2 + a3 > 21)
    {
        cout << "bust" << endl;
    }
    else
    {
        cout << "win" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
a = [0]
for _ in range(N):
    a.append(int(input()))
memo = [-1] + [1] + [0] * (N-1)
next = 1
cnt = 0
while True:
    cnt += 1
    next = a[next]
    if next == 2:
        print(cnt)
        break
    if memo[next] == 1:
        print(-1)
        break
    memo[next] = 1

Measured memory_bytes: 82080
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;

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

	vector<vector<int32_t>> A;
	A.resize(2);
	for (int32_t row = 0; row < 2; row++) {
		A[row].resize(N);
		for (int32_t col = 0; col < N; col++) {
			cin >> A[row][col];
		}
	}

	int32_t max_sum = 0;
	for (int32_t corner = 0; corner < N; corner++) {
		int32_t sum = 0;
		for (int32_t col = 0; col <= corner; col++) {
			sum += A[0][col];
		}
		for (int32_t col = corner; col < N; col++) {
			sum += A[1][col];
		}
		max_sum = max(max_sum, sum);
	}

	cout << max_sum << endl;

	return 0;
}

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

using namespace std;

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

#define pb push_back
#define mp make_pair

string s, t;
int q;
int Sprefa[100010], Sprefb[100010];
int Tprefa[100010], Tprefb[100010];

int main()
{
    ios_base::sync_with_stdio(0);
    cin >> s >> t;
    for(int i = 0; i < s.length(); i++){
        if(i == 0){
            Sprefa[i] = (s[i] == 'A') ? 1 : 0;
            Sprefb[i] = (s[i] == 'B') ? 1 : 0;
        }
        else{
            Sprefa[i] = Sprefa[i - 1];
            Sprefb[i] = Sprefb[i - 1];
            Sprefa[i] += (s[i] == 'A') ? 1 : 0;
            Sprefb[i] += (s[i] == 'B') ? 1 : 0;
        }
    }
    for(int i = 0; i < t.length(); i++){
        if(i == 0){
            Tprefa[i] = (t[i] == 'A') ? 1 : 0;
            Tprefb[i] = (t[i] == 'B') ? 1 : 0;
        }
        else{
            Tprefa[i] = Tprefa[i - 1];
            Tprefb[i] = Tprefb[i - 1];
            Tprefa[i] += (t[i] == 'A') ? 1 : 0;
            Tprefb[i] += (t[i] == 'B') ? 1 : 0;
        }
    }
    cin >> q;
    for(int i = 0; i < q; i++){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        int sa = Sprefa[b - 1];
        if(a > 1) sa -= Sprefa[a - 2];
        int sb = Sprefb[b - 1];
        if(a > 1) sb -= Sprefb[a - 2];
        int ta = Tprefa[d - 1];
        if(c > 1) ta -= Tprefa[c - 2];
        int tb = Tprefb[d - 1];
        if(c > 1) tb -= Tprefb[c - 2];
        sb += sa * 2;
        tb += ta * 2;
        sb %= 3;
        tb %= 3;
        if(abs(tb) == abs(sb)) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 2512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
//#define at(x,i) get<i>(x);//
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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 main(){
    string s;cin >> s;
    ll sz=s.size();
    ll ans=0;
    rep(i,sz){
        char x=s[i];
        if(x=='g'){
            if(i%2==1)ans++;
        }
        if(x=='p'){
            if(i%2==0)ans--;
        }
    }
    cout <<ans <<endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define pb push_back
#define mod int(1e9+7)
#define N int(2e5+100)
#define ll long long int
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define si second
using namespace std;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
   ll n;
   cin>>n;
   ll a[n];
   for(ll i=0;i<n;i++)
      cin>>a[i];
   ll dp[n][2];
   dp[0][0]=0ll;
   dp[0][1]=a[0];
   dp[1][0]=dp[1][1]=max(a[0],a[1]);
   for(ll i=2;i<n;i++){
      if(i%2){
         dp[i][0]=dp[i][1]=max(dp[i-2][0]+a[i],dp[i-1][1]);
      }else{
         dp[i][1]=dp[i-2][1]+a[i];
         dp[i][0]=max(dp[i-1][0],dp[i-2][0]+a[i]);
      }
   }
   cout<<dp[n-1][0]<<'\n';
   return 0;
}

Measured memory_bytes: 8280
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/

#include <bits/stdc++.h>
using namespace std;


#define ll                          long long
#define ld                          long double

#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend();
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second

#define vpi                         <vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()

#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define MN                           INT_MIN
#define MX                           INT_MAX

bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}
int32_t main()
{
	int n,d,x;
	cin >> n >> d >> x;
	int a[n+1];
	for(int i = 1;i<=n;i++)
	{
		cin >> a[i];
	}
	for(int i = 1;i<=n;i++)
	{
		x+= d / a[i];
		if(d%a[i])x++;
	}
	cout << x << endl;
}
	

Measured memory_bytes: 3620
/*
"IOI 2018" Japan, Tokyo.
*/
#include <bits/stdc++.h>

#define fr first
#define sc second
#define mk make_pair
#define pb push_back
#define pp pop_back()
#define ll long long
#define ld long double
#define ok puts("OK");
#define sz(s) (int)s.size()
#define all(s) s.begin(), s.end()

using namespace std;

inline ll min(ll a, ll b) {
    return (a > b) ? b : a;
}

inline ll max(ll a, ll b) {
    return (a > b) ? a : b;
}

const int N = 1e5 + 7;
const int inf = 1e9 + 7;
const ll linf = 1e18 + 9;

int a[N], b[N], freq[N];

main() {
    int n; scanf ("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf ("%d", a + i);
        b[i] = i;
        freq[a[i]]++;
    }
    sort (b + 1, b + n + 1);
    int mx = 1;
    for (int i = 1; i <= n; i++) {
        int dif = b[i] - b[i - 1];
        int aa = 0, bb = 0;
        if (b[i] - dif >= 0) aa = freq[b[i] - dif];
        if (b[i] + dif < N) bb = freq[b[i] + dif];
        mx = max(mx, bb + freq[b[i]] + aa);
    }
    cout << mx;
}


Measured memory_bytes: 1408
hour_length, min_length, hour, min = gets.split.map(&:to_i)

hour_x = Math.cos((hour.to_f + min.to_f / 60.0) / 12.0 * 2.0 * Math::PI) * hour_length.to_f
hour_y = Math.sin((hour.to_f + min.to_f / 60.0) / 12.0 * 2.0 * Math::PI) * hour_length.to_f
min_x = Math.cos(min.to_f / 60.0 * 2.0 * Math::PI) * min_length.to_f
min_y = Math.sin(min.to_f / 60.0 * 2.0 * Math::PI) * min_length.to_f

puts Math.sqrt((hour_x - min_x) ** 2 + (hour_y - min_y) ** 2)


Measured memory_bytes: 14756
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
 
 
public class Main {
 
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        int N = 0, M = 0;
 
        String line;
        while ((line = br.readLine()) != null) {
            String[] n = line.split(",");
            int a = Integer.parseInt(n[0]);
            int b = Integer.parseInt(n[1]);
            int r = Integer.parseInt(n[2]);
 
            if (a == b) {
                if (r*r != a*a+b*b) M++;
            } else {
                if (r*r == a*a+b*b) N++;
            }
        }
        System.out.println(N);
        System.out.println(M);
 
    }
}

Measured memory_bytes: 16876
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
const int INF = 2e9;
const int MOD = 1e9 + 7;

int f(int x) {
   int res = 0;
   while (x) {
      res += x % 10;
      x /= 10;
   }
   return res;
}

int main() {
   int n;
   cin >> n;
   if (n % f(n) == 0) {
      cout << "Yes" << endl;
   } else {
      cout << "No" << endl;
   }

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};


struct UnionFind{
  vector<int> par;

  UnionFind(int N): par(N){
    for(int i=0;i<N;i++) par[i]=i;
  }

  int root(int x){
    if(par[x]==x) return x;
    else return par[x]=root(par[x]);
  }

  void unite(int x,int y){
    int rx=root(x);
    int ry=root(y);
    if(rx!=ry) par[rx]=ry;
  }

  bool sameroot(int x,int y){
    return root(x)==root(y);
  }

};

int N;
vector<pair<ll,int>> dists;
vector<pair<ll,int>> tonari[310];

int calc(int a,int b){
    vector<bool> det(N, false);
    vector<ll> dist(N,INF);
    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<>> pq;
    dist[a]=0;
    pq.push(make_pair(0,a));
    while(!pq.empty()){
        int d=pq.top().first,node=pq.top().second;
        pq.pop();
        if(det[node]) continue;
        det[node]= true;
        for(auto tsugi:tonari[node]){
            if(det[tsugi.second]) continue;
            if(chmin(dist[tsugi.second],dist[node]+tsugi.first)){
                pq.push(make_pair(dist[tsugi.second],tsugi.second));
            }
        }
        //if(det[b]) return dist[b];
    }
    return dist[b];
}

int main() {
    cin>>N;
    int inp;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            cin>>inp;
            if(i<j) dists.push_back(make_pair(inp,i*1000+j));
        }
    }
    sort(dists.begin(),dists.end());
    UnionFind uf(N);
    ll ans=0ll;
    for (auto itr:dists) {
        int d=itr.first, a=itr.second/1000, b=itr.second%1000;
        if(!uf.sameroot(a,b)){
            ans+=(ll)d;
            tonari[a].push_back(make_pair(d,b));
            tonari[b].push_back(make_pair(d,a));
            uf.unite(a,b);
        }else{
            int val=calc(a,b);
            //printf("%d,%d => %d %d \n",a,b,d,val);
            if(val>d){
                ans+=(ll)d;
                tonari[a].push_back(make_pair(d,b));
                tonari[b].push_back(make_pair(d,a));
            }else if(val<d){
                cout<<-1<<endl;
                return 0;
            }
        }
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string a;cin>>a;
    map<char,int> m;
    for(auto i:a)m[i]++;
    for(char i='a';i<='z';i++){if(m[i]%2){cout<<"No\n";return 0;}}
    cout<<"Yes\n";
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include<set>
#include <algorithm>
#define ll long long 
#include <string.h>
#define pb push_back
#define mp make_pair
# define pi 3.14159265358979323846
#define max 1e9;
using namespace std;

int main()
{
	ll int n;
	cin>>n;
	ll int a[n],i,p=1;
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	
		
	}
	sort(a,a+n);
	if (a[0]==0)
	cout<<0<<endl;
	else
	{
		for(i=0;i<n;i++)
		{
			if (a[i]<=1000000000000000000 /p)
			{
				p=p*a[i];
			}
			else
			{
				cout<<-1<<endl;
				return 0;
			}
		}
		
		cout<<p<<endl;
	}
	
	
	
	
	
}
    
	
		

	
			

		


 







Measured memory_bytes: 4372
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <map>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1LL << 60;


int main() {
  cin.tie(0); ios_base::sync_with_stdio(false);
  ll H, W, K; cin >> H >> W >> K;
  vector<string> S(H);
  vector<vector<ll>> ans(H, vector<ll>(W));
  for(int i = 0; i < H; ++i) cin >> S[i];
  // get all #
  ll cnt = 0;
  for(int i = 0; i < H; ++i)
    for(int j = 0; j < W; ++j) {
      if(S[i][j] == '#') {
        ++cnt;
        ans[i][j] = cnt;
      }
    }

  for(int i = 0; i < H; ++i) {
    for(int j = W-1; j > 0; --j) {
      int tmp = ans[i][j];
      while(j > 0 && ans[i][j-1] == 0) {
        ans[i][j-1] = tmp;
        --j;
      }
    }
    for(int j = 0; j < W-1; ++j) {
      int tmp = ans[i][j];
      while(j < W-1 && ans[i][j+1] == 0) {
        ans[i][j+1] = tmp;
        ++j;
      }
    }
  }

  for(int j = 0; j < W; ++j) {
    for(int i = H-1; i > 0; --i) {
      int tmp = ans[i][j];
      while(i > 0 && ans[i-1][j] == 0) {
        ans[i-1][j] = tmp;
        --i;
      }
    }
    for(int i = 0; i < H-1; ++i) {
      int tmp = ans[i][j];
      while(i < H-1 && ans[i+1][j] == 0) {
        ans[i+1][j] = tmp;
        ++i;
      }
    }
  }


  for(int i = 0; i < H; ++i) 
    for(int j = 0; j < W; ++j) cout << ans[i][j] << " \n"[j == W-1];

  return 0;
}


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

int main()
{
	long long a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;

	long long ret = 0;
	long long minxy = min(x, y);

	ret += min(minxy * 2 * c, minxy * a + minxy * b);
	if (x < y) {
		ret += min((y - x) * b, (y - x) * 2 * c);
	}
	else {
		ret += min((x - y) * a, (x - y) * 2 * c);
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();

		int kutikazu = 1;
		int tapNum = 0;


		for(int i=0;i<b;i++) {
			if(kutikazu>=b) {
				System.out.println(tapNum);
				break;
			}
			kutikazu = kutikazu - 1 + a;
			tapNum += 1;
		}
	}

}


Measured memory_bytes: 22612
N = int(input())
ab = []
for i in range(N):
  A, B = map(int, input().split())
  ab.append([A, B])

ab.sort(key=lambda x: x[1])

sums = 0
flag = True
for i in range(N):
   sums += ab[i][0]
   if sums > ab[i][1]:
      flag = False

if flag:
  print("Yes")
else:
  print("No")
    

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

enum Way{ LEFT, RIGHT };

string in;
string Left,Right;


void solve()
{
	int way = -1;
	int res = 0;

	for(int i = 0; i < Left.size(); i++)
		if(in[0] == Left[i])
			way = LEFT;
	if(way < 0)
		way = RIGHT;

	for(int i = 1; i < in.size(); i++){
		int j;
		if(way == LEFT){
			for(j = 0; j < Left.length(); j++){
				if(in[i] == Left[j])
					break;
			}
			if(j == Left.length()){
				way = RIGHT;
				res++;
			}
		}
		else{
			for(j = 0; j < Right.length(); j++){
				if(in[i] == Right[j])
					break;
			}
			if(j == Right.length()){
				way = LEFT;
				res++;
			}
		}
	}

	cout << res << endl;
}
						

	

int main(void)
{
	Left += "qwertasdfgzxcvb";
	Right+= "yuiophjklnm";

	while(cin >> in, in[0] != '#')
		solve();
	return 0;
}

Measured memory_bytes: 1188
// Problem : D - Handstand 2
// Contest : AtCoder Beginner Contest 152
// URL : https://atcoder.jp/contests/abc152/tasks/abc152_d
// Memory Limit : 1024.000000 MB 
// Time Limit : 2000.000000 milisec 
// Powered by CP Editor (https://github.com/coder3101/cp-editor)

#include<bits/stdc++.h>
#define pb push_back
#define int long long
#define vi vector<int>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcount(x)
#define f first
#define se second
using namespace std;
template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }
double pi=acos(-1.0);
int md=1000000007;
int abst(int a)
{return a<0?-a:a;}
struct HASH{
  size_t operator()(const pii &x)const{
    return (size_t) x.first * 37U + (size_t) x.second;}};

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int Pow(int n,int x){int ans=1;
 while(x>0)
 {if(x&1)ans=(ans*n)%md;n=(n*n)%md;x=x>>1;}
 return ans;}

int max(int a,int b){return a>b?a:b;}
int min(int a,int b){return a<b?a:b;}

void solve()
{
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int n;
cin>>n;
map<pii,int> mp;
for(int i=1;i<=n;i++)
{
	int x=i%10;
	int t=i;int y;
	while(t)
	{
		y=t%10;
		t/=10;
	}
	if(x!=0)
	mp[{y,x}]++;
}
int count=0;
for(int i=1;i<=n;i++)
{
	int x=i%10;
	int t=i;int y;
	while(t)
	{
		y=t%10;
		t/=10;
	}
 if(x!=0)
	count+=mp[{x,y}];
}
cout<<count;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t;
//cin>>t;
t=1;
while(t--)
{
    solve();
}
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# n,m = map(int,sys.stdin.readline().split())
# a = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
# a = tuple(sys.stdin.readline() for _ in range(n)) # multi line with single param
# a = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(N)) # multi line with multi param
# s = sys.stdin.readline().rstrip()
# n = int(sys.stdin.readline())
# INF = float("inf")
import sys,collections
N,Q = tuple(map(int,sys.stdin.readline().split())) # single line with multi param
S = sys.stdin.readline().rstrip()
se = tuple(tuple(map(int,sys.stdin.readline().rstrip().split())) for _ in range(Q)) # multi line with multi param

INF = float("inf")
com = [0]*(N+1)

for i in range(N):
    com[i+1] = com[i]
    if S[i] == "A" and S[min(i+1,N-1)] == "C":
        com[i+1] += 1

for s,e in se:
    print(com[e-1] - com[s-1])


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

using namespace std;

#define int long long
#define pii pair<int,int>
#define fi first
#define se second

const int N = 2e5 + 7, mod = 1e9 + 7, K = 3007;

int f[N], inv[N], d[K];
pii a[K];

int binpow(int a, int b){
	int res = 1;
	while(b){
		if(b & 1) (res *= a) %= mod, --b;
		else (a *= a) %= mod, b >>= 1;
	}
	return res;
}

int inverse(int x){
	return binpow(x, mod - 2);
}

void preset(){
	f[0] = 1, inv[0] = 1;
	for(int i = 1; i < N; ++i) f[i] = (f[i - 1] * i) % mod, inv[i] = inverse(f[i]);
}

int C(int k, int n){
	if(k > n) return 0;
	return ((f[n] * inv[k]) % mod) * inv[n - k] % mod;
}

signed main(){
	preset();
	int h, w, n;
	cin >> h >> w >> n;
	for(int i = 0; i < n; ++i){
		cin >> a[i].fi >> a[i].se;
	}
	a[n] = make_pair(h, w);
	
	sort(a, a + n);
	
	for(int i = 0; i <= n; ++i){
		d[i] = C(a[i].fi - 1, a[i].fi + a[i].se - 2);
		for(int j = i - 1; j >= 0; --j){
			int to = C(a[i].fi - a[j].fi, a[i].fi + a[i].se - a[j].fi - a[j].se);
			d[i] = (d[i] - d[j] * to) % mod;
			d[i] = (d[i] + mod) % mod;
		}
	}
	
	cout << d[n];
	
}

Measured memory_bytes: 6736
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int main() {
  long long N;
  long long ans = 10000000000;

  cin >> N;

  for (long long i = 1; i * i <= N; i++) {
    if (N % i == 0 ) {
      string str_a = to_string(i);
      string str_b = to_string(N / i);
      long long tmp = max(str_a.size(), str_b.size());
      ans = min(tmp, ans);
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt();
            var A = ReadIntArray();
            Console.WriteLine(string.Join(" ", A));
            insertionSort(A,N);
        }

        private static void insertionSort(int[] A,int N)
        {
            for (int i = 1; i < N; i++)
            {
                var v = A[i];
                var j = i - 1;
                while (j >= 0 && A[j] > v)
                {
                    A[j + 1] = A[j];
                    j--;
                }

                A[j + 1] = v;
                Console.WriteLine(string.Join(" ", A));
            }
        }

        private static readonly Func<string> Read = () => Console.ReadLine();
        private static readonly Func<string[]> ReadStringArray = () => Console.ReadLine().Split();
        private static readonly Func<int> ReadInt = () => int.Parse(Console.ReadLine());
        private static readonly Func<long> ReadLong = () => long.Parse(Console.ReadLine());
        private static readonly Func<int[]> ReadIntArray = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
        private static readonly Func<long[]> ReadLongArray = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
        private static readonly Action<string> Cw = str => Console.WriteLine(str);
    }
}


Measured memory_bytes: 16268
#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 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> A(Q);
  REP(i, Q) cin >> A[i];
  
  int a = K - Q;
  vector<int> B(N,a);
  REP(i,Q){
    B.at(A.at(i)-1)++;
  }

  REP(i,N){
    if(B.at(i)>0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 1408
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<utility>//swap(数値交換)
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define rt "\n"
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())

int main(){
	int a;
	string s;
	cin >> a >> s;
	int cnt=0;
	rep(i, s.size()) {
		if (s[i] == 'A') {
			if (s[i + 1] == 'B' && s[i + 2] == 'C') {
				cnt++;
			}
		}
	}
	cout << cnt << rt;
	return 0;
}

// abc : 141 , aoj : ITP1_6_D
//sort, abs, swap, reverse, max, min
//__gcd, substring, erase, push_back,stoll、stoi

Measured memory_bytes: 256
from collections import deque
u = int(input())
g = [[i for i in map(int, input().split())] for _ in range(u)]
graph = [[] for _ in range(u)]
ans = [-1] * u
for i in range(u):
    for j in range(g[i][1]):
        graph[i].append(g[i][2 + j] - 1)
que = deque()
que.append(0)
ans[0] = 0
while que:
    v = que.popleft()
    for nv in graph[v]:
        if ans[nv] != -1:
            continue
        ans[nv] = ans[v] + 1
        que.append(nv)

for i in range(u):
    print(i+1, ans[i])



Measured memory_bytes: 6048
#include<iostream>
using namespace std;
int main(){
  int bell,hess,aizu,riri=0;
  while(1){
    aizu=0;
    cin >> bell >> hess;
    if(bell==0 && hess==0){
      break;
    }
    if(riri!=0){
      cout << endl;
    }
    riri++;
    for(int i=bell;i<=hess;i++){
      if(i%4==0){
	if(i%100!=0){
	  cout << i << endl;
	  aizu++;
	}
	else if(i%400==0){
	  cout << i << endl;
	  aizu++;
	}
      }
    }
    if(aizu==0){
      cout << "NA" << endl;
    }
    aizu=0;
  }
}

Measured memory_bytes: 1160
#include <algorithm>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e8;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

string J(string m) {
  string ret = "";
  ret += m[m.size() - 1];
  ret += m.substr(0, m.size() - 1);
  return ret;
}
string C(string m) {
  string ret = "";
  ret += m.substr(1, m.size() - 1);
  ret += m[0];
  return ret;
}
string E(string m) {
  string ret = "";
  if (m.size() % 2 == 0) {
    ret += m.substr(m.size() / 2, m.size() / 2);
    ret += m.substr(0, m.size() / 2);
  } else {
    ret += m.substr(m.size() / 2 + 1, m.size() / 2);
    ret += m[m.size() / 2];
    ret += m.substr(0, m.size() / 2);
  }
  return ret;
}
string A(string m) {
  string ret = "";
  for (int i = m.size() - 1; i >= 0; i--) ret += m[i];
  return ret;
}
string P(string m) {
  string ret = "";
  rep(i, m.size()) {
    if (isdigit(m[i])) {
      if (m[i] == '0')
        ret += '9';
      else
        ret += m[i] - 1;
    } else {
      ret += m[i];
    }
  }
  return ret;
}
string M(string m) {
  string ret = "";
  rep(i, m.size()) {
    if (isdigit(m[i])) {
      if (m[i] == '9')
        ret += '0';
      else {
        ret += m[i] + 1;
      }
    } else {
      ret += m[i];
    }
  }
  return ret;
}

signed main() {
  int n;
  cin >> n;
  rep(i, n) {
    string order, message;
    cin >> order >> message;
    for (int i = order.size() - 1; i >= 0; i--) {
      if (order[i] == 'J')
        message = J(message);
      else if (order[i] == 'C')
        message = C(message);
      else if (order[i] == 'E')
        message = E(message);
      else if (order[i] == 'A')
        message = A(message);
      else if (order[i] == 'P')
        message = P(message);
      else
        message = M(message);
    }
    cout << message << endl;
  }
  return 0;
}



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

int main(){
  int a,b; cin>>a >>b;
  if(a >= 13){
    cout<<b<<endl;
  }else if(6 <= a && a <= 12){
    cout<<b/2<<endl;
  }else{
    cout<<0<<endl;
  }
}

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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/f.in", "r", stdin);
//  freopen("../IO/f.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}


void solve(std::istream &in, std::ostream &out) {
  int N, K;
  in >> N >> K;
  vector<pair<int, int>> v(N);
  for (pair<int, int> &p : v) in >> p.second >> p.first, --p.second;
  sort(v.rbegin(), v.rend());
  set<pair<int, int>> setik;
  vector<vector<int>> z(N);
  int64_t different = 0;
  int64_t sum = 0;
  for (int i = 0; i < K; ++i) {
    sum += v[i].first;
    different += z[v[i].second].empty();
    z[v[i].second].push_back(v[i].first);
  }
  int64_t ans = sum + different * different;
  for (int i = 0; i < N; ++i) {
    if ((int) z[i].size() > 1) {
      setik.emplace(z[i].back(), i);
    }
  }
  for (int i = K; i < N; ++i) {
    if (setik.empty()) break;
    int type = v[i].second, value = v[i].first;
    if (!z[type].empty()) continue;
    int type0 = setik.begin()->second, value0 = setik.begin()->first;
    sum -= value0;
    sum += value;
    different++;
    z[type].push_back(value);
    setik.erase(setik.begin());
    z[type0].pop_back();
    if ((int)z[type0].size() > 1) {
      setik.emplace(z[type0].back(), type0);
    }
    ans = max(ans, sum + different * different);
  }
  out << ans << '\n';
}

Measured memory_bytes: 9472
#include<bits/stdc++.h>
using namespace std;
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll              long long 

void solve(){
		ll n;
		ll d;
		cin >> n >> d;
		d *= d;
		int cnt=0;
		for(int i=0; i<n; ++i){
			ll x, y;
			cin >> x >> y;
			if(x*x + y*y <= d) cnt++;	
		}
		cout << cnt << endl;
}
int main(){
		FIO;
//		int t; cin >> t;
//		while(t--)
			solve();
		return 0; 
}
/*

*/

Measured memory_bytes: 3656
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
const int MOD = (1000000007);
//const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60)-1;
const double EPS = (1 >> 30);

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

using Graph = vector<vector<pair<int, int>>>;

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------
    
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    ll ans=1;
    vector<int> b(3,-1);
    rep(i,n){
        int count=0;
        rep(j,3){
            if(b[j]==a[i]-1){
                count++;
                if(count==1){
                    b[j]++;
                }
            }
            
        }
        //cout<<count<<endl;
        ans*=count;
        ans%=MOD;
    }
    cout<<ans<<endl;
    
}

Measured memory_bytes: 1152
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    string S;
    cin >> S;
    set<char> st(ALL(S));
    if (st.size() == 2 && count(ALL(S), *st.begin()) == 2) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
    return 0;
};


Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#define  For(a,b)    for(int a=0;a<b;a++)
#define  si(a)       scanf("%d",&a);
#define  sl(a)       scanf("%lld",&a);
#define  sii(a,b)    scanf("%d%d",&a,&b);
#define  sll(a,b)    scanf("%lld%lld",&a,&b);
#define  queues      priority_queue
#define mod 1000000007
#define mem(a)  memset(a,0,sizeof(a));
typedef long long ll;
const int INF=0x3f3f3f3f;
//queues<int,vector<int >,greater<int > >q;
using namespace std;

int main()
{ int s[100];mem(s)
  int n,m;
  cin>>n>>m;
  for(int i=1;i<=n;i++)
  {
      int t;
      cin>>t;
      while(t--)
      {
          int a;
          cin>>a;
          s[a]++;
      }
  }
  int sum=0;
  for(int i=1;i<=m;i++)
    if(s[i]==n)sum++;
  cout<<sum;
}

/******************************************
**        **             ********       **
**       ** **           **             **
**      **   **          **             **
**     **     **         **             **
**    ***********        **             **
**   **         **       ********       **
******************************************/


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

using namespace std;

using ll = long long;

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

    string s;
    cin >> s;

    int num_win = 0, num = 0;
    for (char c: s) {
        if (c == 'g') {
            if (0 < num) { --num; ++num_win; }
            else { ++num; }
        }
        else {
            if (0 < num) { --num; }
            else { ++num; --num_win; }
        }
    }

    cout << num_win << endl;

    return 0;
}


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

int main(void) {
  string s;
  cin >> s;
  int ans = 700;
  if (s[0] == 'o') ans += 100;
  if (s[1] == 'o') ans += 100;
  if (s[2] == 'o') ans += 100;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(i = 0; i < n; i++)
//2D::rep(i,j)rep(j,j)cin>>bin[i][j];
//vector<int> a(n)
#define Graph vector<vector<int>>
#define A1 cout<<"No"<<endl
#define A2 cout<<"Yes"<<endl
#define A3 cout<<ans<<
#define AA(i) cout<<i<<endl;
const int U=2e5+5;
const ll MOD=1000000007;
const int INF = 1001001001;

int main(){
    int i,N; cin >> N;
    vector<ll> x(N);
    vector<ll> y(N);
    ll a,b;
    rep(i,N){
        cin>>a>>b;
        x[i]=a+b;
        y[i]=a-b;
    }
    sort(x.begin(), x.end());
    sort(y.begin(), y.end());
    AA(max(y[N-1]-y[0],x[N-1]-x[0]));
    return 0;
}

Measured memory_bytes: 6424
#include<iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    vector<vector<char>> vec(2,vector<char>(3));
    for(int i=0;i<2;i++){
        for(int j=0;j<3;j++){
        cin >> vec.at(i).at(j);
        }
    }
    
    if(vec.at(0).at(0)!=vec.at(1).at(2)){
        cout << "NO"<<endl;
        return 0;
    }
    else if(vec.at(0).at(1)!=vec.at(1).at(1)){
        cout << "NO"<<endl;
        return 0;
    }
    else if(vec.at(0).at(2)!=vec.at(1).at(0)){
        cout << "NO"<<endl;
        return 0;
    }
    
    cout << "YES"<<endl;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

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

  vector<ll> A(N);
  rep (i, N) cin >> A[i];

  vector<pair<ll, int>> CB;
  rep (i, M) {
    int b, c;
    cin >> b >> c;
    CB.eb(mp(c, b));
  }

  sort(all(A));
  sort(rall(CB));
  ll ans = 0;
  int idx = 0;

  rep (i, N) {
    ans += A[i];

    if (idx >= M) continue;

    if (A[i] < CB[idx].F) {
      CB[idx].S--;
      ans = ans - A[i] + CB[idx].F;

      if (CB[idx].S == 0) idx++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,n) for(ll i=0;i<(n);++i)
#define REPR(i,n) for(ll i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int l,r,d; cin>>l>>r>>d;
    int ans = 0;
    for (int i = l; i <= r; ++i) if (i%d==0) ans++;
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

double dist(double x1, double y1, double x2, double y2) {  // (x1, y1) と (x2, y2) のユークリッド距離
    return sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );
}
 
int main() {
    ll n;
    cin >> n;

    vector<double> x(n), y(n);
    rep(i, n) {
        cin >> x[i] >> y[i];
    }

    vl perm(n);
    rep(i, n) {
        perm[i] = i;
    }

    double ans = 0.0;
    do {
        rep(i, n-1) {
            ans += dist(x[perm[i]], y[perm[i]], x[perm[i+1]], y[perm[i+1]]);
        }
        // {0, 1, … , n-1} の全順列を昇順に出力
        /*rep(i, n) {
            cout << perm[i] << " ";
        }
        cout << "\n";*/
    } while(next_permutation(all(perm)));

    exrep(i, 1, n) {
        ans /= (double)i;
    }
    
    exout(ans);
    re0;
}

Measured memory_bytes: 256