akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>

int read(){
    int x=0,f=1;char c=getchar();
    while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
    while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
    return x*f;
}

#define LL long long

#define MAXN 1000
int N;
LL T[MAXN+5],A[MAXN+5];

int main(){
    N=read();
    for(int i=1;i<=N;i++)
        T[i]=read(),A[i]=read();
    for(int i=2;i<=N;i++){
        LL tmp1=(T[i-1]+T[i]-1)/T[i];
        LL tmp2=T[i]*tmp1;
        LL tmp3=A[i]*tmp1;
        LL tmp4=(A[i-1]+A[i]-1)/A[i];
        LL tmp5=A[i]*tmp4;
        LL tmp6=T[i]*tmp4;
        if(tmp3-A[i-1]<0){
            LL tmp7=(A[i-1]-tmp3+A[i]-1)/A[i];
            tmp3+=tmp7*A[i];
            tmp2+=tmp7*T[i];
        }
        if(tmp6-T[i-1]<0){
            LL tmp8=(T[i-1]-tmp6+T[i]-1)/T[i];
            tmp6+=tmp8*T[i];
            tmp5+=tmp8*A[i];
        }
        LL d1=tmp3-A[i-1],d2=tmp6-T[i-1];
        if(d1<d2)
            T[i]=tmp2,A[i]=tmp3;
        else
            T[i]=tmp6,A[i]=tmp5;
    }
    printf("%lld",A[N]+T[N]);
}


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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

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

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

template <class T, class U> void chmax(T &a, U b) {
  if (a < b)
    a = b;
}

template <class T, class U> void chmin(T &a, U b) {
  if (b < a)
    a = b;
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

signed main() {
  string s = readString();
  int size = s.size();
  int odd = 0, even = 0;
  REP(i, size) {
    if (i & 1) {
      if (s[i] == 'L' || s[i] == 'U' || s[i] == 'D')
        even++;
    } else {
      if (s[i] == 'R' || s[i] == 'U' || s[i] == 'D')
        odd++;
    }
  }
  if (even == size / 2 && odd == size / 2 + (size & 1))
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;
}


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

using namespace std;

int main () {
	
	int n,w;
	cin>>n>>w;
	pair<int,int> cost[n+1];
	
	for (int i=1;i<=n;i++) {
		int x,y;
		cin>>x>>y;
		
		cost[i]={x,y};
	}
	
	long long dp[n+1][w+1];
	
	sort(cost+1,cost + n + 1);
	
	for (int i=0;i<=n;i++) {
		for (int j=0;j<=w;j++) {
			if (i==0) dp[i][j]=0;
			if (j==0) dp[i][j]=0;
			
			if (i) {
				
				if (j-cost[i].first <0) dp[i][j]= dp[i-1][j];
				else dp[i][j]= max(cost[i].second + dp[i-1][j-cost[i].first],dp[i-1][j]);
			}
		}
	}
	
	cout<<dp[n][w]<<endl;
} 


Measured memory_bytes: 82412
#include <iostream>
#include <stdio.h>

#define MAXN 100
#define INF 4000001

using namespace std;

int main()
{
  int A[MAXN];
  int n;
  long sum = INF;

  cin >> n;

  for ( int i = 0; i < n; ++i ) scanf("%d", &A[i]);

  for ( int i = -100; i <= 100; ++i ) {
    long tmp = 0;
    for ( int j = 0; j < n; ++j ) tmp += (A[j]-i)*(A[j]-i);

    if ( tmp < sum ) sum = tmp;
  }

  cout << sum << "\n";
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int WWW = 0;WWW < (n);WWW++)cerr << v[WWW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

struct UF
{
	vector<int> par; // 親のインデックスを記憶する配列
	vector<int> sz; // サイズを記憶する。
	vector<int> rank;
	// 初期化
	UF(int n):par(n),sz(n),rank(n){
		for(int i = 0; i < n; i++){
			par[i] = i;sz[i] = 1;rank[i] = 0;
		}
	}
	// 親を求める
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	// xとyの属する集合を併合
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y) return;
		if(rank[x] < rank[y]){
			par[x] = y;
			sz[y] += sz[x];
		}
		else{
			par[y] = x;
			sz[x] += sz[y];
			if(rank[x] == rank[y])rank[x]++;
		}
	}
	// xとyが同じ集合ならtrue
	bool same(int x, int y) { return find(x) == find(y); }
	// 素の集合のサイズを求める
	int size(int n){return sz[find(n)];}
};

ll n,m;
ll a[111111];
ll b[111111];
ll c[111111];
vector<pair<ll,pair<ll,ll>>> edge;
vector<vector<int>> v(111111);

ll dfs(ll node){
	ll ret = LLINF;
	ll tmp_sum = b[node];
	vector<ll> seica(v[node].size());
	REP(i,v[node].size()){
		seica[i] = max(dfs(v[node][i]),c[node]);
		tmp_sum += b[v[node][i]];
	}
	REP(i,v[node].size()){
		ret = min(ret,seica[i]+tmp_sum-b[v[node][i]]);
	}
	
	ret = min(ret,c[node]+tmp_sum);
	
	b[node] = tmp_sum;
	return ret;
}

int main(){
		
	cin >> n >> m;
	ll ma = -1;
	ll node;
	REP(i,n){
		cin >> a[i] >> b[i];
		c[i] = max(0LL,a[i] - b[i]);
		if(ma < c[i]){ma = c[i],node = i;}
	}
	REP(i,m){
		int x,y;cin >> x >> y;
		x--;y--;
		edge.PB(MP(max(c[x],c[y]),MP(x,y)));
	}
	
	sort(ALL(edge));
	
	UF uf(n);
	
	REP(i,m){
		ll A = edge[i].SE.FI;
		ll B = edge[i].SE.SE;
		if(uf.same(A,B))continue;
		if(c[A] < c[B]){
			v[B].PB(uf.find(A));
			uf.par[uf.find(A)] = B;
		}
		else{
			v[A].PB(uf.find(B));
			uf.par[uf.find(B)] = A;
		}
		uf.unite(A,B);
	}
	
	cout << dfs(node) << endl;
		
	return 0;
}


Measured memory_bytes: 17136
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    if A > 12:
       sum = B
    elif A > 5:
        sum = B / 2
    else:
        sum = 0
    print(int(sum))


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e3+5;

int main(){	
	int n,k,ans = 0;
	scanf("%d%d",&n,&k);
	while(n){
		n /= k;
		ans++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const long long MOD = 998244353;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
#define RSORT(v) std::sort(v.rbegin(), v.rend())
constexpr auto PI = 3.14159265358979323846264338327950L;

void dfs(int d, long long val,vector<long long> &all) {
    all.push_back(val);
    if(d==10) return;
    for(int j=-1;j<=1;++j){
        int add = (val%10) + j;
        if(add >=0 && add<=9)dfs(d+1,val*10+add,all);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int K;
    cin >> K;
    vector<long long> all;
    for(int i=1;i<10;++i){
        dfs(1,i,all);
    }
    SORT(all);
    cout << all[K-1] <<endl;
    return 0;
}


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

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

#define MOD 1000000007

int main(void) {
    vector<vector<ll>> C(3, vector<ll>(3));
    vector<ll> a(3), b(3);
    for(ll i = 0;i < 3;i++) {
        for(ll j = 0;j < 3;j++) {
            cin >> C[i][j];
        }
    }
    a[0] = C[0][0];
    a[1] = C[0][1];
    a[2] = C[0][2];
    b[0] = C[0][0] - a[0];
    b[1] = C[1][0] - a[0];
    b[2] = C[2][0] - a[0];
    if(a[1] + b[1] == C[1][1] && a[2] + b[1] == C[1][2] && a[1] + b[2] == C[2][1] && a[2] + b[2] == C[2][2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    freopen("debug.out","w",stderr);
    #endif
} 

// Code Here

int main()
{
    // Fast_IO();
    ll n; cin >> n;
    string ans = "";
    ll sum = 0;
    ll pow = 1;
    ll dig = 0;
    while(pow + sum <= n) {
    	sum += pow;
    	pow *= 26;
    	dig++;
    }
    n -= sum;
    rf(i,dig-1,0) {
    	ll lmao = 1;
    	f(j,1,i) lmao *= 26;
    	ll coeff = n / lmao;
    	n -= lmao * coeff;
    	cout << char(coeff + 'a');
    }
    return 0;
}

Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

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

		int H = Integer.parseInt(br.readLine());
		String[] data = br.readLine().split(" ");

		int[] A = new int[H+1];
		for (int i=0; i < H; i++) {
			A[i+1] = Integer.parseInt(data[i]);
		}

		StringBuilder sb = new StringBuilder();

		sb.append("node 1: key = " + A[1] + ", left key = "
				+ A[2] + ", right key = " +A[3] + ", \n");

		for (int id=2; id <= H; id++) {
			sb.append("node " + id +": key = " + A[id]);
			sb.append(", parent key = " + A[id/2]);
			if (id*2 <= H) sb.append(", left key = " + A[id*2]);
			if (id*2 +1 <= H) sb.append(", right key = " + A[id*2 + 1]);
			sb.append(", \n");
		}

		System.out.print(sb);
	}

}

Measured memory_bytes: 24308
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;

int main(){
    int a,b;
    cin>>a>>b;
    
    int c=a*3;
    int d=c+b;
    cout<<d/2;
}

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

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n,a,b,d;
    while(cin >> n >> a >> b)
    {
        d = abs(b-a) - 1;
        cout << (d % 2 == 0? "Borys" : "Alice") << '\n';
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<math.h>

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

using namespace std;

int main() {
	int N;
	cin >> N;
	int ans = 0;
	int count;
	rep(i, 1, N+1) {
		count = 0;
		if (i % 2 == 1){
			//cout << i << endl;
			rep(j, 1, i+1) {
				if (i%j == 0) {
					count++;
					//cout << j << " " <<count << endl;
				}
			}
			if (count == 8) {
				ans++;
			}
		}
	}

	cout << ans << endl;
	cin >> ans;

	return 0;
}



Measured memory_bytes: 256
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

class Factorial {
private:
	vector<lint> fac, inv, finv;

	void build(int N) {
		fac[0] = fac[1] = 1; inv[1] = 1; finv[0] = finv[1] = 1;

		for (int i = 2; i < N; 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;
		}
	}

public:
	Factorial(int N = 200) : fac(N + 1), inv(N + 1), finv(N + 1) { build(N + 1); }

	lint operator() (int n, int k) {
		if (n < k || k < 0) return 0LL;
		return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
	}

	lint Pmod(int n, int k) {
		if (n < k || k < 0) return 0LL;
		return fac[n] * finv[n - k] % MOD;
	}
};

template<class T>
vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }
template<class... Size>
auto make_vec(size_t s, Size... tail) {
	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string N;
	cin >> N;
	lint len = N.size();

	int K;
	cin >> K;

	auto dp = make_vec(len + 1, 4, 2, 0LL);
	dp[0][0][0] = 1;

	for (int i = 0; i < len; i++) {
		for (int j = 0; j <= 3; j++) {

			if(j != 3) dp[i + 1][j + 1][1] += dp[i][j][1] * 9;
			dp[i + 1][j][1] += dp[i][j][1];
			
			if (N[i] != '0') {
				if (j != 3) {
					dp[i + 1][j + 1][1] += dp[i][j][0] * (N[i] - '0' - 1);
					dp[i + 1][j + 1][0] += dp[i][j][0];
				}
				dp[i + 1][j][1] += dp[i][j][0];
			}
			else dp[i + 1][j][0] += dp[i][j][0];

		}
	}

	cout << (dp[len][K][0] + dp[len][K][1]) << "\n";

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=10000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	ll x,cost;
};
int main() {

	string s,t,u;
	int a,b;
	cin>>s;
	cin>>t;
	cin>>a>>b;
	cin>>u;
	if(t==u)cout<<a<<" "<<b-1<<endl;
	else if(s==u)cout<<a-1<<" "<<b<<endl;
	else cout<<a<<" "<<b<<endl;
	return 0;
}


Measured memory_bytes: 256
#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 GCD(int a,int b){return b?GCD(b,a%b):a;}
int LCM(int a,int b){return (a*b)/GCD(a,b);}
int abs(int x){return x>0?x:-x;}
 
//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 s;
	cin >> s;
	map<int, bool> mp;

	int i = 2;
	mp[s] = 1;

	while(1){
		if (s % 2 == 0){
			s /= 2;
			if (mp[s] != 0){
				cout << i << endl;
				return 0;
			}
			else mp[s] = 1;
		}
		else {
			s = 3 * s + 1;
			if (mp[s] != 0){
				cout << i << endl;
				return 0;
			}
			else mp[s] = 1;
		}
		i++;
	}
}


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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    ll ans = N * (N + 1) * (N + 1) / 2 - N * (N + 1) * (N * 2 + 1) / 6;
    for (ll i = 0; i < N - 1; i++) {
        ll u, v;
        cin >> u >> v;
        if (u > v) swap(u, v);
        ans -= u * (N - v + 1);
    }
    cout << ans << "\n";
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

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

const int INF = 1'000'000'000;

using Weight=int;
using P=pair<Weight, int>;
struct Edge { int to; Weight cost; };

void Dijkstra(const vector<vector<Edge>>& graph, vector<Weight>& dist, int s) {
	int V = graph.size();
	dist.assign(V, INF); dist[s] = 0;

	priority_queue<P, vector<P>, greater<P>> pq;
	pq.push({ 0,s });

	while (!pq.empty()) {
		P p = pq.top(); pq.pop(); int v = p.second;
		if (dist[v] < p.first)continue;
		for (auto e : graph[v]) {
			if (dist[e.to] > dist[v] + e.cost) {
				dist[e.to] = dist[v] + e.cost;
				pq.push({ dist[e.to],e.to });
			}
		}
	}
}

int main() {
	int V, E, r;
	cin >> V >> E >> r;
	vector<vector<Edge>> graph(V);
	vector<int> dist;

	for (int i = 0; i < E; i++) {
		int s, t, d;
		cin >> s >> t >> d;
		graph[s].push_back({ t,d });
	}

	Dijkstra(graph, dist, r);

	for (auto d : dist) {
		if (d == INF)puts("INF");
		else cout << d << endl;
	}
}


Measured memory_bytes: 13064
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
d = collections.defaultdict(int)
for e in s:
    d[e] += 1
items = d.items()
if len(d) == 2:
    print("Yes")
else:
    print("No")


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

int main(){
    int x1,y1,x2,y2;
    
    cin>>x1>>y1>>x2>>y2;
    
    cout<<x2-y2 +y1 <<'\t'<<y2+x2-x1<<'\t'<<x1-y2+y1<<'\t'<<y1+x2 -x1<<endl;

}

Measured memory_bytes: 256
from collections import defaultdict

h, w, n = map(int, input().split())
count = defaultdict(int)
# 3＊3の左上の位置でカウント
for i in range(n):
    a, b = map(int, input().split())
    for s in range(3):
        if a + s - 2 < 1 or a + s - 2 > h - 2:
            continue
        for t in range(3):
            if b - 2 + t < 1 or b - 2 + t > w - 2:
                continue
            count[(a - 2 + s, b - 2 + t)] += 1
ans = [0] * 10
for key, val in count.items():
    ans[val] += 1
ans[0] = (h - 2) * (w - 2) - sum(ans[1:])
print(*ans, sep="\n")


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

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

	string s;
	int k;
	cin >> k >> s;
	if (s.size() <= k)
		cout << s;
	else
	{
		for (int i = 0; i < k; i++)
			cout << s[i];
		cout << "...";
	}

    return 0;
}

Measured memory_bytes: 3648
N = int(input())
A = []
B = []

for i in range(N):
    a, b = list(map(int, input().split()))
    A.append(a)
    B.append(b)

A = sorted(A)
B = sorted(B)

if N % 2:
    ans = B[N//2] - A[N//2] + 1
else:
    l = A[N//2-1] + A[N//2]
    r = B[N//2-1] + B[N//2]
    ans = r-l+1
print(ans)

Measured memory_bytes: 27064
package main

import (
	"fmt"
)

// ここの解法（いもす法）を参考
// https://drken1215.hatenablog.com/entry/2019/06/11/103300#

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	G := make([]int, N+1)
	ans := 0
	for i := 0; i < M; i++ {
		// IndexとしてはL番目はG[L-1]になるのでマイナス1する
		// いもす法としてはR+1番目を見たいが、IndexとしてはRでよい
		var L, R int
		fmt.Scan(&L, &R)
		L--
		G[L]++
		G[R]--
	}

	for i := 0; i < N; i++ {
		G[i+1] += G[i]
	}

	for i := 0; i < N; i++ {
		if G[i] == M {
			ans++
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 5504
#include<iostream>
using namespace std;
int main(void){
    string a;   bool v[2]={0};
    cin>>a; 
    for(int i=0;i<a.length();i++)
    {
        if(a[i]=='C') v[0]=1;
        if(a[i]=='F'&&v[0])  v[1]=1;
    }
    if(v[1]) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
using System;

class MyClass
{
    public static void Main(string[] args)
    {
        while (true)
        {
            string[] input = Console.ReadLine().Split(' ');
            int n = int.Parse(input[0]);
            int x = int.Parse(input[1]);
            if (n == 0 && x == 0)
            {
                break;
            }
            int count = 0;
            for (int i = 1; i <= n; i++)
            {
                for (int j = i + 1; j <= n; j++)
                {
                    for (int k = j + 1; k <= n; k++)
                    {
                        if (i + j + k == x)
                        {
                            count++;
                        }
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 15884
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;

//二項係数
const int MAX = 2e5 + 7;
const int MOD = 1e9 + 7;
ll fac[MAX], finv[MAX], inv[MAX];

void combinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll comb(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}




int main(){
	combinit();

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

	ll sum=0;
	rep(i,0,h-a) {
		sum += (comb(b+i-1,b-1)*comb((h-1-i)+w-b-1,w-b-1)) % MOD;
	}

	cout << sum%MOD << endl;


	return 0;
}


Measured memory_bytes: 4992
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

#define EPS 1e-10
#define INF 1000000
#define mp make_pair
#define pb push_back

typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;
typedef long long ll;

int const N_MAX = 100000;

int main() {
	int m, n_min, n_max;
	while (1) {
		cin >> m >> n_min >> n_max;
		if (!m && !n_min && !n_max) {
			return 0;
		}
		vi points, people(N_MAX+1, 0);
		for (int i = 0; i < m; i++) {
			int p;
			cin >> p;
			points.pb(p);
			people[p]++;
		}
		sort(points.begin(), points.end(), greater<int>());
		for (int i = N_MAX; i > 0; i--) {
			people[i-1] += people[i];
		}

		pii ans = mp(0, 0);
		for (int i = 0; i < points.size(); i++) {
			int point = points[i],
					n = people[point];
			if (n < n_min) {
				continue;
			} else if (n > n_max) {
				break;
			}
			int diff = point - points[i+1];
			if (diff > ans.second || (diff == ans.second && n > ans.first)) {
				ans = mp(n, diff);
			}
		}

		cout << ans.first << endl;
	}
}

Measured memory_bytes: 1612
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
using vi=vector<int>;
int main() {
  int N,M,C;
  cin>>N>>M>>C;
  vi B=vi(M);
  FOR(i,0,M) cin>>B[i];
  int ans=0;
  FOR(k,0,N){
    int sum=C;
    FOR(i,0,M){
      int A_i;
      cin>>A_i;
      sum+=A_i*B[i];
    }
    if(sum>0)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
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;}
constexpr int INF=1000000000000000000;
constexpr int mod=998244353;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
vector<int>kaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    //if(!kaijo[0])init_fact(2000010);
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,k;
string s;
signed main(){
    cin>>n>>k>>s;
    chmin(k,20ll);
    while(k--){
        string ans=s;
        string t=s;
        reverse(all(t));
        s+=t;
        rep(i,n+1)chmin(ans,s.substr(i,n));
        reverse(all(ans));
        s=ans;
    }
    reverse(all(s));
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
// atcoder/abc086/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int a, b;
  while (cin >> a >> b) {
    cout << ((a * b) % 2 ? "Odd" : "Even") << endl;
  }

  return 0;
}


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

int main() {
    for(int i=0;i<3005;i++){
        int x,y;
        cin >> x >> y;
        if(x==0&&y==0) break;
        cout << min(x,y) << " " << max(x,y) << endl;
    }
}


Measured memory_bytes: 2968
from collections import Counter
N, X, Y = map(int, input().split())
ans = Counter()
for i in range(1, N):
    for j in range(i+1, N+1):
        cost = min([j-i, abs(X-i)+abs(Y-j)+1, abs(Y-i)+abs(X-j)+1])
        ans[cost] += 1
for k in range(1, N):
    # base = N - k
    print(ans[k])


Measured memory_bytes: 51548
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <list>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
#include <cstdlib>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

#define xx first
#define yy second
#define $1 first
#define $2 second

void solveCase() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	ll d, t, s;
	cin >> d >> t >> s;
	if (t*s >= d) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}


int main() {

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	solveCase();
}

Measured memory_bytes: 3616
/*
Author: CNYALI_LK
LANG: C++
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#define up(a,b,c) for (int a(b),end##a(c);a<=end##a;++a)
#define down(a,c,b) for (int a(b),end##a(c);a>=end##a;--a)
#define uup(a,c,b) for (int a(b),end##a(c);a<=end##a;++a)
#define udown(a,b,c) for (int a(b),end##a(c);a>=end##a;--a)
#define endl '\n'
using namespace std;
const double eps=1e-8;
const double PI=acos(-1.0);
long long gcd(long long a,long long b){
	return b?gcd(b,a%b):a;
}
int main(){
	int n;
	cin>>n;
	long long s=1,t;
	up(i,1,n){
		cin>>t;
		s=s/gcd(s,t)*t;
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<queue>
int a[7][7];
int b[7];
int F(int x)
{
	int f[7]={0},i,j,y;
	std::queue<int>q;
	q.push(x);
	while(!q.empty())
	{
		x=q.front();q.pop();
		if(f[x]++)continue;
		for(i=0;i<7;++i)if(a[i][x])q.push(i);
	}
	for(i=0;i<7;++i)if(b[i]&&!f[i])return 0;
	for(x=i=0;i<7;++i)
	{
		for(y=j=0;j<7;++j)y+=a[i][j];
		if(y&1)++x;
	}
	return x<3;
}
int main()
{
	int n,u,v;
	while(scanf("%d",&n)>0)
	{
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
		while(n--)
		{
			scanf("%d",&u);
			u-=(v=u/10)*10;
			++a[u][v],++a[v][u];
			b[u]=b[v]=1;
		}
		puts(F(u)?"Yes":"No");
	}
	return 0;
}

Measured memory_bytes: 0
package main

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

func min(x int, y int) int {
	if x > y {
		return y
  }
  return x
}

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	stdin.Scan()
	var line string
	line = stdin.Text()
	var numbers []int
	for _, s := range strings.Split(line, " ") {
		var i int
		var _ error
		i, _ = strconv.Atoi(s)
		numbers = append(numbers, i)
	}
	var n, a, b int
	n = numbers[0]
	a = numbers[1]
	b = numbers[2]
	var answer int
	var amari, shou int
	shou = n / (a + b)
	amari = n % (a + b)
	answer = (shou * a) + min(amari, a)
	fmt.Println(answer)
}


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

int main(){
    int n;
    vector <string> s;   
    long long ans = 0;
    cin >> n;
    for (int i = 0; i < n; i ++){
        string _s;
        cin >> _s;
        s.push_back(_s);
    }
    long long m, a, r, c, h;
    m = 0; a = 0; r = 0; c = 0; h = 0;
    for(auto cs: s){
        char _c = cs[0];
        if (_c == 'M') m++;
        if (_c == 'A') a++;
        if (_c == 'R') r++;
        if (_c == 'C') c++;
        if (_c == 'H') h++;
    }
    long long sum = m + a + r + c + h;
    //cout << sum << " " << r << " " << a << " " << c << " " << h << " " << endl;
    ans = sum * (sum - 1) * (sum - 2) / 6;

    ans -= m * (m - 1) * (m - 2) / 6;
    ans -= (m * (m - 1) / 2) * (sum - m);

    ans -= a * (a - 1) * (a - 2) / 6;
    ans -= (a * (a - 1) / 2) * (sum - a);

    ans -= r * (r - 1) * (r - 2) / 6;
    ans -= (r * (r - 1) / 2) * (sum - r);

    ans -= c * (c - 1) * (c - 2) / 6;
    ans -= (c * (c - 1) / 2) * (sum - c);

    ans -= h * (h - 1) * (h - 2) / 6;
    ans -= (h * (h - 1) / 2) * (sum - h);

    cout << ans << endl;
}

Measured memory_bytes: 7312
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(), v.end()

/* デカい配列はここで宣言 */

int main(int argc, char const *argv[])
{
    string s, t;
    cin >> s >> t;
    vector<string> q;

    if (s.size() < t.size())
    {
        cout << "UNRESTORABLE" << endl;
        exit(0);
    }

    for (ll i = 0; i < s.size() - t.size() + 1; i++)
    {
        string temp = s;
        for (ll k = 0; k < t.size(); k++)
        {
            if (s[i + k] == '?')
            {
                temp[i + k] = t[k];
            }
            else if (s[i + k] == t[k])
            {
            }
            else
            {
                // if (s[i] == '?')
                //     s[i] = 'a';
                break;
            }
            if (k == t.size() - 1)
            {
                for (ll m = 0; m < s.size(); m++)
                {
                    if (temp[m] == '?')
                    {
                        temp[m] = 'a';
                    }
                }
                q.push_back(temp);
            }
        }
    }
    
    if(q.empty())
    {
        cout << "UNRESTORABLE" << endl;
    }
    else
    {
        sort(ALL(q));
        cout << q.front() << endl;
    }
}

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


int dp__[100];

//最大公約数
ll gcd(ll x, ll y){
  if(x % y == 0) return y;
  return gcd(y, x % y);
}
//最小公倍数
ll lcm(ll x, ll y){
  return x * y / gcd(x, y);
}
//フィボナッチ数列
//配列dpを-1で初期化する
int fib(int n){
  if(n == 0 || n == 1) return dp__[n] = 1;
  if(dp__[n] != -1) return dp__[n];
  return dp__[n] = fib(n - 1) + fib(n - 2);
}
//階乗計算(factorial)
int fact(int n){
  if(n = 1) return 1;
  return n * fact(n - 1);
}
//累乗計算(Exponentiation)
//x**y
ll expo(int x, int y){
  ll ans = 1;
  rep(i, y){
    ans *= x;
  }
  return ans;
}
//桁数
int keta(ll x){
  if(x == 0) return 1;
  int res = 0;
  while(x){
    x /= 10;
    res++;
  }
  return res;
}


int main(){
  int n ;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  sort(a.begin(), a.end());
  REP(i,n) {
    if(a[i] == a[i-1]){
      cout<< "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}




Measured memory_bytes: 1024
#include<bits/stdc++.h>
const int mo=998244353;
inline int poww(int x,int y){
	int ans=1;
	for(;y;y>>=1,x=1ll*x*x%mo)if(y&1)ans=1ll*ans*x%mo;
	return ans;
}
int n,a[1<<18|5],i,s,b[1<<18|5];
inline void FWT(){
	for(int i=2,j,k,m,x,y;i<=1<<n;i<<=1)for(j=0,m=i>>1;j<1<<n;j+=i)
		for(k=0;k<m;++k)x=a[j+k],y=a[j+k+m],a[j+k]=(x+y)%mo,a[j+k+m]=(x+mo-y)%mo;
}
int main(){
	scanf("%d",&n);
	for(i=1;i<1<<n;++i)a[i]=1;FWT();memcpy(b,a,sizeof b);
	for(i=0;i<1<<n;++i)scanf("%d",a+i),s+=a[i];s=poww(s,mo-2);
	for(i=0;i<1<<n;++i)a[i]=1ll*a[i]*s%mo;
	FWT();for(s=0,i=1;i<1<<n;++i)a[i]=1ll*b[i]*poww(1+mo-a[i],mo-2)%mo,s=(s+a[i])%mo;a[0]=mo-s;
	FWT();s=poww(1<<n,mo-2);for(i=0;i<1<<n;++i)printf("%lld ",1ll*a[i]%mo);puts("");
	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;
typedef pair<Int,Int> P;

Int D;
vector<Int> C(26);
vector<vector<Int>> S(365, vector<Int>(26));


// 最終的な満足度を返す関数
Int score(vector<int> schedule){
    vector<int> last_day(26, 0); // 各コンテストを最後に行った日

    vector<Int> res(D, 0);

    rep(d,D){
        int type = schedule[d]-1; // その日に行われるコンテスト

        res[d] += S[d][type];
        rep(i,26){
            if(i == type) continue;
            res[d] -= C[i] * (d+1 - last_day[i]);
        }
        last_day[type] = d+1;

        if(d != D-1) res[d+1] += res[d];
    }

    return res[D-1];
}

int main(){
    clock_t start = clock();

    cin >> D;
    rep(i,26) cin >> C[i];
    rep(i,D) rep(j,26) cin >> S[i][j];

    vector<int> t_old(D);
    rep(i,D) t_old[i] = (i%26) + 1;
    
    int old_score = score(t_old);

    rep(k, 10000){
        vector<int> t_new = t_old;
        int d = rand() % D, q = rand() % 26 + 1;
        //cout << d << " " << q << endl;
        t_new[d] = q;

        if(score(t_new) > old_score) t_old = t_new;
    }

    rep(i,D) cout << t_old[i] << endl;
}

Measured memory_bytes: 3748
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include <iomanip>
#include<utility>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
#define S 21 
llfor;ll mod=1000000007;
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){ll ans=1,l=2;rep(i,0,min(n-r,r)){ans*=(n-i);while(ans%l==0&&l<=min(r,n-r)){ans/=l;l++;}}return ans;}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}//素数の時true
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
/*行列のコピー*/void matcpy(ll a[S][S],ll b[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)b[i][j]=a[i][j];/*(aをbに)*/i=t;}
/*行列のリセット*/void matrst(ll a[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)a[i][j]=0;i=t;}
/*行列の2乗*/void matpow(ll a[S][S]){ll ans[S][S];matrst(ans);ll t=i,k;rep(i,0,S)rep(j,0,S)rep(k,0,S)ans[i][j]+=a[i][k]*a[k][j];matcpy(ans,a);i=t;}
/*行列の乗算*/void matmul(ll a[S][S],ll b[S][S], ll as[S][S]){ll t=i,k;matrst(as);rep(i,0,S)rep(j,0,S)rep(k,0,S)as[i][j]+=a[i][k]*b[k][j];i=t;}
//ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 string s;
 cin>>s;
 ll n=s.length();
 ll b=0;
 ll ans=0;
  
 rrp(i,n,0){
  if(s[i]=='B'&&s[i+1]=='C'&&i<n-1)continue;
  if(i>0&&s[i]=='C'&&s[i-1]=='B')b++;  
  else if(s[i]=='A')ans+=b;
  else b=0;
 // cout<<i<<" ans: "<<ans<<" b: "<<b<<" "<<endl;
 }
 pr(ans);
return 0;}

Measured memory_bytes: 3728
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace __gnu_pbds; 
using namespace std;
using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007

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

ll mod_inverse(ll a) {
	return mod_pow(a , mod-2);
}

void solve() {
	
	int n , m, k;
	
	cin >> n >> m >> k;
	
	int a[n];
	int b[m];
	
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	
	for(int i = 0; i < m; ++i) {
		cin >> b[i];
		
		if(i != 0) {
			b[i] += b[i-1];
		}
	}
	
	int mx = 0;
	int sm = 0;
	
	for(int i = 0; i <= n; ++i) {
		
		if(i != 0)  {
			sm += a[i-1];
		}
		
		if(sm > k) {
			break;
		}
		
		auto u = upper_bound(b,b+m, k - sm) - b;
		
		mx = max(mx , i + u);
	}
	
	cout<< mx;
}

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

Measured memory_bytes: 6740
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define INF 1e18
#define max_n 1000000

using namespace std;

void solve()
{
	ll l, r, d;
	cin >> l >> r >> d;
	cout << (r / d - (l - 1) / d) << endl;
}

int32_t main()
{
	IOS
	ll T = 1;
	// cin>>T;
	for (ll i = 1; i <= T; ++i)
	{
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3652
function Main(input) {
  const inputs = input.split("\n");
  const num = parseInt(inputs[0], 10);
  var result = inputs[1];
  if (num < 3200) {
    result = 'red';
  }
  console.log(result);
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
P,Q,R=map(int,input().split())

min1=P
min2=Q

min1=101
min2=101





Z1=P+Q
Z2=Q+R
Z3=P+R
Z4=Q+R
Z5=R+P
Z6=Q+R

min1=Z1
if(min1>Z2):
    min1=Z2
if(min1>Z3):
    min1=Z3
print(min1)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;
constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,v.size())
#define all(v)(v).begin(),(v).end()
#define bit(n)(1ll<<(n))
#define uniq(v)sort(all(v));v.erase(unique(all(v)),v.end())
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
#ifndef LOCAL
struct osd{template<class T>osd&operator<(const T&t){return*this;}template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;template<class...T>void _print(osd&a,T&&...t){}
#define cerr cer_
#endif
template<class T>ostream&operator<(ostream&o,const T&t){return o<<t;}template<class T>istream&operator>(istream&i,T&t){return i>>t;}
void _print(ostream&s){}template<class T,class...U>void _print(ostream&s,T&&t,U&&...u){s<t<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(T&&...t){_print(cout,t...);}template<class...T>void dprint(T&&...t){_print(cerr,t...);}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<i<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<p.F<' '<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>p.F>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<i<' ';return o;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>queue<T>&operator<<(queue<T>&q,const T&t){q.push(t);return q;}template<class T>queue<T>&operator<<(T&t,queue<T>&q){t=q.front();q.pop();return q;}
template<class T>deque<T>&operator>>(const T&t,deque<T>&q){q.push_front(t);return q;}template<class T>deque<T>&operator<<(T&t,deque<T>&q){t=q.front();q.pop_front();return q;}
template<class T>deque<T>&operator<<(deque<T>&q,const T&t){q.push_back(t);return q;}template<class T>deque<T>&operator>>(deque<T>&q,T&t){t=q.back(t);q.pop_back();return q;}
template<class T>stack<T>&operator<<(stack<T>&s,const T&t){s.push(t);return s;}template<class T>stack<T>&operator>>(stack<T>&s,T&t){t=s.top();s.pop();return s;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int a,b;
    cin>a>b;
    if(abs(b-a)%2){
        print("IMPOSSIBLE");
    }else{
        cout<(b+a)/2<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define INF 0x3f3f3f3
#define LINF 0x3f3f3f3f3f3f3f
#define MAXN int(2*1e5)+5
#define fim '\n'
#define ll long long
#define f first
#define s second
#define FAST cin.tie(0), cout.tie(0), ios::sync_with_stdio(0)
#define debug(x) cout << "DEBUG " << x << fim
#define debug2(x, y) cout << "DEBUG " << x << " " << y << fim
#define debug3(x, y, z) cout << "DEBUG " << x << " " << y << " " << z<< fim
#define debug4(x, y, z, o) cout << "DEBUG " << x << " " << y << " " << z<< " " << o << fim
#define max3(x, y, z) max(x, max(y, z))
#define ull unsigned long long
using namespace std;
using namespace __gnu_pbds;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<unsigned ll, pair<int, int> > piii;
typedef pair<pair<int, int>, int> piii2;
typedef tree<int,null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> indexed_set;
const ll mod = 1e9+7;

ll cont[MAXN];

ll expo(ll a, ll b) {
	if(b == 0)
		return a;
	ll p = expo(a, b/2);
	return (b & 1 ? ((p*p%mod)*a)%mod : (p*p)%mod);
}

int main() {
	int a, b;
	cin >> a >> b;
	cout << (a >= 10 or b >= 10 ? -1 : a*b) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int s;
  vector<int> a(4);
  cin >> s;
  a.at(0) = s/1000;
  a.at(1) = s/100 - a.at(0)*10;
  a.at(2) = s/10 -a.at(0)*100 - a.at(1)*10;
  a.at(3) = s%10;
  int i,t;
  t=0;
  for(i=0;i<3;i++){
    if(a.at(i)==a.at(i+1)){
      t++;
    }
  }
  if(t==0){
    cout << "Good" << endl;
  }
  else{
    cout << "Bad" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[8] = {-1,0,1,0,-1,1,1,-1};
int dx[8] = {0,1,0,-1,1,1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 200100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,k;
    cin>>n>>k;
    vector<int> a(n+1);
    for(int i=1;i<=n;i++)cin>>a[i];
    int d[d5];
    fill(d,d+d5,-1);
    int now=1;
    int cnt=0;
    int loop=-1;
    while(true){
        if(d[now]==-1){
            d[now]=cnt;
            now=a[now];
            cnt++;
        }else{
            loop=cnt-d[now];
            break;
        }
    }
    /* for(int i=0;i<=n;i++)cout<<d[i]<<' ';
    cout<<endl; */
    if(k>d[now]){
        k-=d[now];
        k%=loop;
        k+=d[now];
    }
    for(int i=0;i<d5;i++){
        if(d[i]==k)cout<<i<<endl;
    }
}

Measured memory_bytes: 6372
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
vector<pair<int, int>> to[100010];
bool visited[100010];
ll dist[100010];

int main() {
    int n;
    cin >> n;
    int ans = -1;
    int index = 1;
    rep(i, 0, n){
        int num;
        cin >> num;
        if(num == index){
            ans++;
            index++;
        }
    }
    if(ans < 0)cout << ans << endl;
    else {
        n-=ans+1;
        cout << n << endl;
    }
    return 0;
}


Measured memory_bytes: 5924