akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll unsigned long long
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define ss(s) scanf("%s",s)
#define pi(x) printf("%d\n",x)
#define pl(x) printf("%lld\n",x)
#define ps(s) printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
int mpow(int base, int exp);
void ipgraph(int m);
//void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];
std::vector<int> adj[100000];
int cnt = 0;
void dfs(int src, vi &vis) {
  vis[src] = 1;
  cnt++;
  for (auto it : adj[src]) {
    if (!vis[it])dfs(it, vis);
  }
}
int main() {
  ios_base::sync_with_stdio(0);

#ifndef ONLINE_JUDGE
  freopen("input1.txt", "r", stdin);
  //freopen("error.txt", "w", stderr);
  freopen("output1.txt", "w", stdout);
#endif
  ll int t, i, j, k, p, q, r, x, y, u, v, n, m;
  t = 1;
  //cin >> t;
  while (t--) {
    cin >> n >> m;
    fo(i, m) {
      cin >> x >> y;
      x--; y--;
      adj[x].pb(y);
      adj[y].pb(x);

    }
    vi vis(n, 0);
    int ans = 1;
    fo(i, n) {
      if (!vis[i]) {
        cnt = 0;
        dfs(i, vis);
        ans = max(cnt, ans);

      }

    }

    cout << ans;
  }
  cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;

  return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(int n, int m) {
  int i, u, v;
  while (m--) {
    cin >> u >> v;
    g[u - 1].pb(v - 1);
    g[v - 1].pb(u - 1);
  }
}

void dfs(int u, int par) {
  for (int v : g[u]) {
    if (v == par) continue;
    dfs(v, u);
  }
}




Measured memory_bytes: 27016
#include <stdio.h>
#include <bits/stdc++.h>
     
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
     
using namespace std;

const int N = 100000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 31;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

bool iseven(string s)
{
	return s.substr(0, s.size()/2) == s.substr(s.size()/2);
}

int ss(string s)
{
	rep(i, 1, s.size())
		if (iseven(s.substr(0, s.size()-i)))
			return s.substr(0, s.size()-i).size();
	return 0;
}

int main()
{
	string s;
	cin >> s;
	cout << ss(s) << endl;
}


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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  int s;
  cin >> s;
  unordered_set<int> se;
  int old = s;
  int count = 1;
  while (se.find(old) == se.end()) {
    se.insert(old);
    old = old % 2 == 0 ? old / 2 : 3 * old + 1;
    count++;
  }
  cout << count << endl;
}

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

  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;i<n;i++)
#define ll long long
#define pii pair < ll , ll >
#define vi vector < int >
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define clr(x) memset(x, 0, sizeof(x))
#define init(x, a) memset(x, a, sizeof(x))
#define vll vector < long long int >
#define sll set < long long int >
#define fastIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
int main()
{
    fastIO;
    ll a,b,n,i,j,k;
    cin>>a>>b;
    i = min(a,b);
    a -= i;
    b -= i;
    k = 16-2*i;
    if(a>k/2 or b>k/2)
    {
        cout<<":("<<endl;
        return(0);
    }
    cout<<"Yay!"<<endl;
}

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

// https://youtu.be/tNyPYIhy9Ms

int g[15][15];

int main()
{
  int N;
  cin >> N;
  rep(i, N)
  {
    rep(j, N)
    {
      g[i][j] = -1;
    }
  }

  rep(i, N)
  {
    int A;
    cin >> A;
    rep(j, A)
    {
      int a, x;
      cin >> a >> x;
      a--;
      g[i][a] = x;
    }
  }

  int ans = 0;
  rep(i, 1 << N) /*2^N*/
  {
    vector<int> d(N);
    rep(j, N)
    {
      if (i >> j & 1)
      { // 誠実な人か不誠実の人かを入力 (ex) 001001
        d[j] = 1;
      }
    }
    bool ok = true;
    rep(j, N)
    {
      if (d[j])
      {
        rep(k, N)
        {
          if (g[j][k] == -1)
          {
            continue;
          }
          if (g[j][k] != d[k])
          {
            ok = false;
          }
        }
      }
    }
    if (ok)
    {
      ans = max(ans, __builtin_popcount(i)); // 1の個数
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#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 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 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(){
  ll n;cin >> n;
  vector<deque<ll>> g(n);
  rep(i,n)rep(j,n){
    char x;cin >> x;
    g[i].push_back(x-'a');
  }
  ll ans=0;
  rep(i,n){
    bool check=true;
    rep(j,n){
      rep(k,n){
        if(g[j][k]!=g[k][j])check=false;
      }
    }
    if(check)ans+=n;
    rep(j,n){
      ll a=g[j].front();
      g[j].pop_front();
      g[j].push_back(a);
    }
  }
  cout <<ans <<endl;
}

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

string s;

int main() {
	cin >> s;
	if (s.size() >= 4 && s[0] == 'Y' && s[1] == 'A' && s[2] == 'K' && s[3] == 'I') cout  << "Yes";
	else
	cout << "No";
	return 0;
}


Measured memory_bytes: 256
///*
#include<iostream>
using namespace std;

int main() {

	const int priceOfCake = 4, priceOfDonut = 7;
	int haveMoney, timesOfCake, timesOfDonut;
	bool isSame = false;
	cin >> haveMoney;
	
	timesOfCake = haveMoney / priceOfCake;
	timesOfDonut = haveMoney / priceOfDonut;

	//cout << timesOfCake << " " << timesOfDonut << endl;

	for (int countCake = 0; countCake <= timesOfCake; countCake++) {
		for (int countDonut = 0; countDonut <= timesOfDonut; countDonut++) {
			int sumPrice = priceOfCake * countCake + priceOfDonut * countDonut;
			
			//cout << "Cake : " << countCake << " Donut : " << countDonut << endl;
			//cout << "sumPrice :: " << sumPrice << endl;
			
			if (sumPrice <= haveMoney && haveMoney == sumPrice)isSame = true;
		}
	}

	isSame ? cout << "Yes" << endl : cout << "No" << endl;

	return 0;
}
//*/

Measured memory_bytes: 256
#include <iostream>
#define mod 1000000007

using namespace std;
long long n,len,i,lo,hi,now,ans;
long long dp[3005][3005];
long long sum[3005];
string s;
int main()
{
    cin>>n;
    cin>>s;
    dp[1][1]=1;
    for(len=2;len<=n;len++)
    {
        for(i=1;i<len;i++)
            sum[i] = (sum[i-1]+dp[len-1][i])%mod;
        for(now=1;now<=len;now++)
        {
            if(s[len-2]=='<')
            {
                lo=1;
                hi=now-1;
            }
            else
            {
                lo=now;
                hi=len-1;
            }
            if(lo>hi)
                continue;
            dp[len][now]+=sum[hi]-sum[lo-1];
            if(dp[len][now]<0)
                dp[len][now]+=mod;
            dp[len][now]%=mod;
            /*
            for(last=lo;last<=hi;last++)
            {
                dp[len][now]+=dp[len-1][last];
                dp[len][now]%=mod;
            }
            */

        }
    }
    for(i=1;i<=n;i++)
    {
        ans+=dp[n][i];
        ans%=mod;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 69120
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;
            string[] s = Console.ReadLine().Split(' ');

            int N = int.Parse(s[0]);
            int M = int.Parse(s[1]);

            ans = N * M / 2;

            Console.WriteLine(ans.ToString());
        }
    }
}


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

#define ln                 endl
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 1e2, inf = 0x3f3f3f3f;
bool g[nsz + 5][nsz + 5];
int n, m, dp[nsz + 5][nsz + 5];

void inline upd(int &a, int b) {
	a > b && (a = b);
}

int main() {
	ios::sync_with_stdio(0);
	cin >> n >> m;
	cont (i, n)  cont (j, m) {
		char c;
		cin >> c;
		g[i][j] = c == '#';
	}
	memset(dp, inf, sizeof(dp));
	dp[1][1] = g[1][1];
	cont (i, n)  cont (j, m) {
		if (dp[i][j] == inf)  continue;
		if (g[i + 1][j] == g[i][j])  upd(dp[i + 1][j], dp[i][j]);
		else  upd(dp[i + 1][j], dp[i][j] + g[i + 1][j]);
		if (g[i][j + 1] == g[i][j])  upd(dp[i][j + 1], dp[i][j]);
		else  upd(dp[i][j + 1], dp[i][j] + g[i][j + 1]);
	}
	cout << dp[n][m] << ln;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0

for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
        if (x/50)-(10*i+2*j+k)==0:
          ans += 1
          
print(ans)

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

ll Permutation(ll n,ll r,ll m){
	ll res = 1;
	for(ll i=0,v=n;i<r;i++){
		res *= v;
		res %= m;
		v--;
	}
	return res;
}

ll safemod(ll a,ll m){
	return (a%m+m)%m;
}

ll extend_gcd(ll a,ll b,ll &x,ll &y){
	if(b==0){
		x = 1;
		y = 0;
		return a;
	}
	ll d = extend_gcd(b,a%b,y,x);
	y -= a/b * x;
	return d;
}

ll modinv(ll a,ll m){
	ll x,y;
	extend_gcd(a,m,x,y);
	return safemod(x,m);
}

ll powermod(ll a,ll b,ll m){
	if(b==0){
		return 1LL;
	}
	if(b%2){
		return (a*powermod(a,b-1LL,m))%m;
	}
	return powermod((a*a)%m,b/2LL,m);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	int H=in(),A=in(),B=in();
	ll S=safemod(powermod(2,H,atcoder_mod)-1LL,atcoder_mod);
	S = safemod(S-Permutation(H,A,atcoder_mod)*modinv(Permutation(A,A,atcoder_mod),atcoder_mod),atcoder_mod);
	S = safemod(S-Permutation(H,B,atcoder_mod)*modinv(Permutation(B,B,atcoder_mod),atcoder_mod),atcoder_mod);
	out(S);
	return 0;
}


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

using namespace std;

#define REP(i,m,n) for(int i=m;i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define ALL(x) (x).begin(),(x).end()

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

const double eps = 1e-10;
const double pi = acos(-1.0);
const int di[][2] = {{1,0},{0,1},{-1,0},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}};

int main(){

	int a,b,t;
	cin >> a >> b >> t;
	int s = t / a;
	cout << s*b << endl;

	return 0;
}


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


int main(){
  ll N;
  cin >> N;
  
  vector <ll> h(N);
  vector <ll> coudp(N+1,INT_MAX);
  coudp.at(0)=0;
  
  rep(i,N)
    cin >> h.at(i);
  
  for(int i=1;i<N;i++){
    
    rep(j,2){
      if(i-j-1>=0){
        
        coudp.at(i)=min(coudp.at(i-j-1)+zettaichi(h.at(i),h.at(i-j-1)),coudp.at(i));
       // cout << i << coudp.at(i) << endl;
        
        
      }
    }
  
  }
  
  cout << coudp.at(N-1) << endl;
  
  }

  
  
  
  

int zettaichi(int h1,int h2){
  
  if(h1>h2)
    return h1-h2;
  else
    return h2-h1;
 
}






Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

#define memc(X) memset(X,0,sizeof(X))
#define ll long long
#define ic(i, a, b) for(int i=(a);i<(b);i++)
#define dc(i, a, b) for(int i=(a);i>(b);i--)

using namespace std;

int main() {
    char str[10];
    cin>>str;
    for(int i=0;str[i];i++){
        if(str[i]=='1'){
            str[i]='9';
        }
        else if(str[i]=='9'){
            str[i]='1';
        }
    }
    cout<<str<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

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

    int a = 0, b = 0, c = 0;

    for (auto& k : s)
    {
        if (k == 'a')
            a++;
        else if (k == 'b')
            b++;
        else
            c++;
    }

    if (max({ a,b,c }) - min({ a,b,c }) <= 1)
        printf("YES\n");
    else
        printf("NO\n");

    return 0;
}

Measured memory_bytes: 512
n = int(input())
ans_count = [0] * 4
ans = ['AC','WA','TLE','RE']

for s in range(n):
    tmp = input()
    for t in range(4):
        if tmp == ans[t]:
            ans_count[t] += 1

for s in range(4):
    print('%s x %d' % (ans[s],ans_count[s]))

Measured memory_bytes: 9136
def main() :

    s = input()
    t = input()

    if (t in s) :
        print(0)
        return
    
    difference = 99999999
    for offset in range(0,len(s) - len(t)+1):
        s2 = s[offset:offset+len(t)]
        diff = 0
        for i in range(len(t)) :
            if (s2[i] != t[i]) :
                diff += 1
        
        if (difference > diff) :
            difference = diff
    
    print(difference)

main()

Measured memory_bytes: 9068
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=int(a);i<=int(b);i++)
#define ROF(i,a,b) for(int i=int(b);i>=int(a);i--)
#define pb push_back
#define pq priority_queue
#define ps push
#define x first
#define y second
using namespace std;
int n;
double in[110],anw;
int main(){
    cin>>n;
    FOR(i,1,n){
        cin>>in[i];
        anw=anw+1/in[i];
    }
    printf("%f",1/anw);
}


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

using namespace std;

#define REP(i, N) for (int i = 0; i < (int)N; i++)
#define RREP(i, N) for (int i =(int)N-1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define INF (1 << 30)
#define LLINF (1LL << 62)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
typedef pair<string,int>Psi;

int main(){
  int n,m;
  cin>>n>>m;
  int l,r;
  int max=INF;
  int min=-INF;
  REP(i,m){
    cin>>l>>r;
    if(r<max){
      max=r;
    }
    if(min<l){
      min=l;
    }
  }
  //cout<<min<< " "<<max<<endl;
  if(max<min){
    cout<<0<<endl;
  }else{
    cout<<max-min+1<<endl;
  }

}

Measured memory_bytes: 256
// Example program
#include <iostream>
#include <string>
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  if(a%2==1&&b%2==1){cout<<"Odd"<<endl;}
  if(a%2==0||b%2==0){cout<<"Even"<<endl;}
  return 0;
}


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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int n, a[maxn];

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

  cin>>n;
  for (int i=0; i<n; i++) {
    cin>>a[i];
  }
  int ans = 0;
  int dp = 0;
  for (int i=n-2; i>=0; i--) {
    if (a[i] >= a[i+1]) {
      dp++;
    } else {
      dp = 0;
    }
    ans = max(dp, ans);
  }

  cout<<ans<<endl;
  

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 2;

void solve() {
    ll k, n; cin >> k >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    // CW
    ll tmp = 0;
    for (int i = 0; i < n-1; ++i) {
        tmp = max(tmp, a[i+1] - a[i]);
    }
    tmp = max(tmp, (k-a[n-1]) + a[0]);
    ll ans = k - tmp;
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 1792
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=100050;
//ここまでテンプレ
int main(){
	int X,A,B;
	cin>>X>>A>>B;
	cout<<(X-A)%B<<endl;
	return 0;
}

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

int main(){
  int n,m;
  cin>>n>>m;
  valarray<int> b(0,m);
  vector<valarray<int> > A(n,b);
  REP(i,n) REP(j,m) cin>>A.at(i)[j];
  REP(i,m) cin>>b[i];
  REP(i,n){
    valarray<int> c(m);
    c = A.at(i)*b;
    cout<<c.sum()<<endl;}
  return 0;
}

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

typedef vector<int> VI;
const int N=450;
VI a[N];
typedef long long ll;
ll ans;
map<VI,int>mp;
#define nxt(x) x.push_back(x[0]),x.erase(x.begin())
void add(VI x,int y){for(int i=0;i<4;++i,nxt(x))mp[x]+=y;}
int n;
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(int i=0;i<n;++i){
		for(int j=0;j<4;++j){
			int x;cin>>x;
			a[i].push_back(x);
		}
		add(a[i],1);
	}
	for(int i=0;i<n;++i){
		add(a[i],-1);
		for(int j=i+1;j<n;++j){
			add(a[j],-1);
			for(int k=0;k<4;++k){
				VI x={a[i][3],a[j][2],a[j][1],a[i][0]},y={a[j][3],a[i][2],a[i][1],a[j][0]},
				   z={a[i][0],a[j][1],a[j][0],a[i][1]},w={a[j][2],a[i][3],a[i][2],a[j][3]};
				ll res=1;nxt(a[j]);
				if(!mp.count(x)||!mp.count(y)||!mp.count(z)||!mp.count(w))continue;
				res*=mp[x];add(x,-1);
				res*=mp[y];add(y,-1);
				res*=mp[z];add(z,-1);
				res*=mp[w];add(x,1);add(y,1);add(z,1);
				ans+=res;
			}
			add(a[j],1);
		}
	}
	cout<<ans<<'\n';
	return 0;
}


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

using namespace std;
#define INF (1<<28)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long
vector<int> dp[200000];

vector<pair<int,int>> v;

  string s;
  int n,q;

int rets(int nowd){
    int l=nowd;
    int stat=0;
    lp(i,q){
      if(v[i].first==s[l]-'A'){
        if(v[i].second==0) l++;
        else l--;
      }
      if(l>=n){
        return 1;
      }
      if(l<0){
        return 2;
      }
    }
    return 0;
}

signed main(){
  cin>>n>>q;  cin>>s;
  lp(i,q){
    char t,d;
    cin>>t>>d;
    int tt,dd;
    if(d=='R') dd=0;
    else dd=1;
    tt=t-'A';
    v.push_back({tt,dd});
  }
  int l=0,r=n-1,m;
  lp(i,30){
    m=0.5+(double)(r+l)/2;
    if(rets(m)==2) l=m;
    else r=m;
    //cout<<l<<" "<<r<<endl;
    /*int hoge;
    cin>>hoge;*/
  }
  /*lp(i,n){
    cout<<rets(i)<<endl;
  }*/
  int lmi=r;
  for(int i=lmi-2;;i++){
    if(i<0) continue;
    if(i>=n){
      cout<<0<<endl;
      return 0;
    }
    int hoge=rets(i);
    if(hoge==1){
      cout<<0<<endl;
      return 0;
    }
    if(hoge==0){
      lmi=i;
      break;
    }
  }
  l=0,r=n-1;
  lp(i,30){
    m=0.5+(double)(r+l)/2;
    if(rets(m)==1) r=m;
    else l=m;
    //cout<<l<<" "<<r<<endl;
  }
  int rmi=l;
  for(int i=rmi+2;;i--){
    if(i>=n) continue;
    if(i<0){
      cout<<0<<endl;
      return 0;
    }
    int hoge=rets(i);
    if(hoge==2){
      cout<<0<<endl;
      return 0;
    }
    if(hoge==0){
      rmi=i;
      break;
    }
  }

  /*
  if(rets(l)==0) rmi=r;
  else rmi=l;*/

  //cout<<rmi<<" "<<lmi<<endl;
  cout<<rmi-lmi+1<<endl;
  return 0;
}

Measured memory_bytes: 11252
#include<iostream>
#include<algorithm>

#define N 20001
#define M 17
#define V 256

using namespace std;

const int infty = 1<<29;

int correct(int i){
  return min( max( i, 0 ), V-1 );
}

int solve(int n, int m, int codebook[], int decode[]){
  int ret = infty;
  int **dp = new int*[N+1];
  for(int i = 0; i < N+1; ++i){
    dp[i] = new int[V];
  }
  
  for(int i = 0; i < N + 1; ++i){
    for(int j = 0; j < V; ++j){
      dp[i][j] = infty;
    }
  }
  
  dp[0][128] = 0;
  for(int i = 1; i <= n; ++i){
    for(int j = 0; j < V; ++j){
      if(dp[i-1][j]<infty){
	for(int k = 0; k < m; ++k){
	  int nextj = correct( j+codebook[k] );
	  //cout << " I : " << i << " NEXT J " << nextj << endl;
	  dp[i][nextj] = min( dp[i][nextj], dp[i-1][j] + ( decode[i-1] - nextj ) * ( decode[i-1] - nextj ) );
	  //cout << " DP : " << dp[i][nextj] << endl;
	}
      }
    }
  }
  for(int i = 0; i < V; ++i){
    ret = min( ret, dp[n][i] );
  }
  for(int i = 0; i < N+1; ++i){
    delete [] dp[i];
  }
  delete [] dp;
  return ret;
}

int main(){
  while(true){
    int n,m;
    int codebook[M];
    int decode[N];
    cin >> n >> m;
    if( n == 0 && m == 0 ) break;
    for(int i = 0; i < m; ++i){
      cin >> codebook[i];
    }
    for(int i = 0; i < n; ++i){
      cin >> decode[i];
    }
    cout << solve(n,m,codebook,decode) << endl;
  }
  return 0;
}

Measured memory_bytes: 20000
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define nummax 110000
using namespace std;
typedef long long ll;

int main() {
	ll i, j, N, M, A[nummax], B[nummax], C[nummax], BC[nummax], Bi, Ci, ans = 0, count;
	ll decmax = 2 * pow(10, 9);
	bool end = false;
	cin >> N >> M;
	for (i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	for (i = 0; i < M; i++)
	{
		cin >> B[i] >> C[i];
		BC[i] = B[i] + C[i] * decmax;
	}
	sort(A, A + N, less <ll>());
	sort(BC, BC + M, greater<ll>());
	for (i = 0; i < M; i++)
	{
		B[i] = BC[i] % decmax;
		C[i] = BC[i] / decmax;
	}
	i = 0;
	count = 0;
	while (!end)
	{
		Bi = B[i];
		Ci = C[i];
		if (i >= M)
			break;
		for (j = 1; j <= Bi; j++)
		{
			if (count >= N)
			{
				end = true;
				j = Bi + 1;
			}
			else if (A[count] < Ci)
			{
				A[count] = Ci;
				count++;
			}
			else
			{
				end = true;
				j = Bi + 1;
			}
			
		}
		i++;
	}
	for (i = 0; i < N; i++)
	{
		ans += A[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3584
#include <stdio.h>
#include <ctype.h>
#include <string.h>

void print_int(int n)
{
    printf("%d\n",n);
}

void swap(int * a, int * b)
{
    int t = *a;
    *a = *b;
    *b = t;
}

void sort(int a[], int n)
{
    for(int i = 1; i < n; i++)
    {
        int j = i-1;
        while(j >= 0 && a[j+1] > a[j])
        {
            swap(&a[j+1],&a[j]);
            j--;
        }
        
    }
    
}

char s[10000000];
int main(void)
{
    scanf("%s", s);
    int j = 0 ,k = 0;
    int count = strlen(s);
    

    for(int i = 0; i < count; i++)
    {
        if(s[i] != (i % 2 == 0 ? '1' : '0'))
        {
            j++;
        }
        else
        {
            k++;
        }
        
    }

    
    print_int(j > k ? k : j);
    return 0;
}



Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author izban
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

using namespace std;


using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double dbl;

#ifdef HOME
#define db(x) { cerr << #x << " = " << x << endl; }
#define db2(x, y) { cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl; }
#define db3(x, y, z) { cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")" << endl; }
#define dbv(a) { cerr << #a << " = "; for (auto xxx: a) cerr << xxx  << " "; cerr << endl; }
#else
#define db(x) ;
#define db3(x, y, z) ;
#define db2(x, y) ;
#define dbv(a) ;
#endif

#define sz(a)  (int)(a).size()
#define all(a) (a).begin(),a.end()
#define pw(x)  (1LL << (x))


class B {
public:
    void solve(std::istream &in, std::ostream &out) {
        ios_base::sync_with_stdio(0);
        in.tie(0);

        string s;
        in >> s;
        int n = s.length();

        ll ans = 0;
        int cur = 0;
        for (int i = n - 1; i >= 0; i--) {
            if (s[i] == 'A') {
                if (cur % 2 == 0) ans += cur / 2;
                else cur = 0;
            } else {
                if ((cur % 2 == 0 && s[i] == 'C') || (cur % 2 == 1 && s[i] == 'B')) cur++;
                else cur = s[i] == 'C';
            }
        }
        out << ans << endl;
    }
};


int main() {
    B solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 720
#include <stdio.h>

int main()
{
	int ikidomari[100];
	int out[100];
	int i=0,k=0;
	while(scanf("%d", &ikidomari[i])!=EOF){
		if(ikidomari[i]!=0){
			i++;
		}
		else{
			i--;
			out[k]=ikidomari[i];
			k++;
		}
	}
	for(i=0; i<k; i++){
		printf("%d\n", out[i]);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <array>
#include <cmath>

using namespace std;

using ll = long long int;

// GCDを計算します
template <typename NumType>
NumType calcGCD(NumType a, NumType b) {
    if (a < b) {
        NumType tmp = a;
        a = b;
        b = tmp; 
    }

    NumType r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }

    return b;
}

// 約数を数えます
template <typename NumType>
NumType cntDivisor(const NumType & num) {
    NumType cnt = 0;
    for(NumType i = 1; i * i <= num; ++i) {
        if(num % i == 0) {
            cnt++;
            if(i * i != num) cnt++;
        }
    }

    return cnt;
}

// [beg, end)の範囲を，添え字indexでループするfor文に置換します
#define FOR_RANGE(index, beg, end)     for (ll index = beg; index < N; ++index)

#define DEBUG(x)     std::cout << #x << " : " << x << "\n"

int main() {
    string S;

    cin >> S;

    vector<int> cnt;

    for (char ch = 'A'; ch <= 'Z'; ch++) {
        int c = 0;
        for (int i = 0; i < 4; i++) {
            if (S[i] == ch) c++;
        }

        if (c > 0) cnt.push_back(c);
    }

    if (cnt.size() == 2 && cnt.front() == cnt.back()) cout << "Yes";
    else cout << "No";


    return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define Abs(x)((x) < 0 ? (x) * -1 : (x))

#define rep(x, y) for ((x) = 0; (x) < (y); (x)++)
#define repin(x, y) for ((x) = 0; (x) <= (y); (x)++)
#define nep(x, y) for ((x) = (y) - 1; 0 <= (x); (x)--)
#define nepi(x, y, z) for ((x) = (y) - 1; (z) <= (x); (x)--)
#define repi(x, y, z) for ((x) = (z); (x) < (y); (x)++)
#define repiin(x, y, z) for ((x) = (z); (x) <= (y); (x)++)
#define reps(x, y, z) for ((x) = 0; (x) < (y); (x) += (z))
#define repis(x, y, z, s) for ((x) = (z); (x) < (y); (x) += (s))
#define repiins(x, y, z, s) for ((x) = (z); (x) <= (y); (x) += (s))
#define repit(x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define nepit(x) for (__typeof((x).rbegin()) it = (x).rbegin(); it != (x).rend(); it++)

#define All(x) (x).begin(),(x).end()

#define Mem0(x) memset(x, 0, sizeof(x))
#define Mem1(x) memset(x, -1, sizeof(x))

#define Unique(v) v.resize(unique(All(v)) - v.begin())

#define peq(p0, p1)(p0.first == p1.first && p0.second == p1.second)

#define End '\n'
#define Out(x) cout<<(x)<<End
#define OutP(p, sep, end) cout<<p.first<<sep<<p.second<<end

template<typename T> inline bool Max(T &x, const T &y) { return x < y ? x = y, 1 : 0; }
template<typename T> inline bool Min(T &x, const T &y) { return x > y ? x = y, 1 : 0; }
template<typename T> using V = vector<T>;
template<typename T> using VV = V<V<T> >;

#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define lb std::lower_bound
#define ub std::upper_bound

#define lbi(v, x) lb(All(v), (x))-v.begin()
#define ubi(v, x) ub(All(v), (x))-v.begin()

static const ll MOD = 1e9 + 7;
static const double PI = 3.141592653589793;

#define LOCAL 0

int main()
{
#if LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("debug.txt", "w", stderr);
#endif

    cin.tie(0);
    ios::sync_with_stdio(false);
	//std::cout.precision(18);

    int n;
	string s;

	cin >> n;
	cin >> s;

	int table[26];
	int ans = 0;
	int c;

	int i, j, len = s.size() - 1;

	repi(i, len, 1) {
		Mem0(table);
		c = 0;

		rep(j, i) table[s[j] - 'a'] = 1;
		repi(j, n, i) {
			if (table[s[j] - 'a'] == 1) {
				c++;
				table[s[j] - 'a']++;
			}
		}

	    Max(ans, c);
	}

	Out(ans);
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#define ll long long int
#define MOD 1000000007
using namespace std;

int main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(a>0&&c>0)
    {
        c-=b;
        if(c<=0)
        {
            cout << "Yes"<<endl;
            break;
        }
        a-=d;
        if(a<=0)
        {
            cout << "No"<<endl;
            break;
        }
    }
	return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAX 2000005
#define MOD 1000000007
#define MOD2 998244353
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define vi vector<ll>
#define vp vector<pii>
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
//using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>

ll mexp(ll a, ll b){
    ll ans=1;
    a%=MOD;
    while(b){
        if(b&1) ans=ans*a%MOD;
        b>>=1;
        a=a*a%MOD;
    }
    return ans;
}

int f[100005],g[100005];

int main(){

    int n;
    cin>>n;
    set<int>s,t;
    FOR(i,1,n+1){
        int x;
        cin>>x;
        if(i%2){
            f[x]++;
            s.insert(x);
        }
        else{
            g[x]++;
            t.insert(x);
        }
    }
    vector<pair<int,int> >v,w;
    for(int x:s){
        v.pb(mp(f[x],x));
    }
    for(int x:t){
        w.pb(mp(g[x],x));
    }
    sort(all(v));
    sort(all(w));
    if(sz(v)==1 && sz(w)==1){
        if(v[0].S==w[0].S){
            cout<<n/2;
            return 0;
        }
        else{
            cout<<0;
            return 0;
        }
    }
    else{
        if(sz(v)==1 && sz(w)>1){
            if(v[0].S==w[sz(w)-1].S){
                cout<<n/2-w[sz(w)-2].F;
            }
            else{
                cout<<n/2-w[sz(w)-1].F;
            }
        }
        else if(sz(v)>1 && sz(w)==1){
            if(w[0].S==v[sz(v)-1].S){
                cout<<n/2-v[sz(v)-2].F;
            }
            else{
                cout<<n/2-v[sz(v)-1].F;
            }
        }
        else{
            if(v[sz(v)-1].S==w[sz(w)-1].S){
                cout<<min(n-v[sz(v)-1].F-w[sz(w)-2].F,n-v[sz(v)-2].F-w[sz(w)-1].F);
            }
            else{
                cout<<n-v[sz(v)-1].F-w[sz(w)-1].F;
            }
        }
    }

    cerr<<"Time: "<<1.0/CLOCKS_PER_SEC<<" ms"<<endl;
    return 0;
}

Measured memory_bytes: 6904
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double pi = acos(-1);
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
	for (auto &e : t) fill_v(e, v);
}

//↑template↑



vector<pair<string, string>>p, ans;
int main() {
	int a, b;
	cin >> a >> b;

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

		for (int i = 0; i < n; ++i) {
			string h;
			cin >> h;
			v.push_back(h);
		}

		for (int i = 0; i < n; ++i) {
			for (int j = i + 1; j < n; ++j) {
				string aa = v[i], bb = v[j];
				if (aa > bb) { swap(aa, bb); }
				p.push_back(make_pair(aa, bb));
			}
		}
	}

	sort(all(p));
	int current = 1;
	auto mon = p[0];

	for (int i = 1; i < p.size(); ++i) {
		if (p[i] == mon) { ++current; }
		else {
			if (current >= b) {
				ans.push_back(make_pair(mon.first, mon.second));
			}
			current = 1;
			mon = p[i];
		}
	}

	if (current >= b) {
		ans.push_back(make_pair(mon.first, mon.second));
	}

	cout << ans.size() << endl;
	for (auto i : ans) {
		cout << i.first << " " << i.second << endl;
	}
}


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


int main(){
    string str;
    cin >> str;
    sort(str.begin(),str.end());
    if (str[0]==str[1] && str[1]!=str[2] && str[2]==str[3]){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}




Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
using namespace std;

int main() {
    int N, K, C;
    string S;
    cin>>N>>K>>C;
    cin>>S;
    vector<int> mae, ushiro;
    int num;
    bool ok = true;
    map<int, int> ansmap;
    for(int i=0;i<N;++i){
        if((S[i]=='o') & (ok)){
            if(C>0) ok = false;
            num = 0;
            mae.push_back(i+1);
        }
        else if(!ok){
            num++;
            if(num==C)ok = true;
        }
    }

    ok = true;

    for(int i=N-1;i>=0;--i){
        if((S[i]=='o') & (ok)){
            if(C>0) ok = false;
            num = 0;
            ushiro.push_back(i+1);
        }
        else if(!ok){
            num++;
            if(num==C)ok = true;
        }
    }
    for(int i=0;i<mae.size();++i){
        ansmap[ushiro[i]]++;
    }
    if(mae.size()<=K){
        for(int i=0;i<mae.size();++i){
            if(ansmap[mae[i]])cout<<mae[i]<<endl;
        }
    }
}


Measured memory_bytes: 12664
n, m = map(int, input().split())
Ab = []
for _ in range(m):
    ab = list(map(int, input().split()))
    Ab.append( [ab[0]-1, ab[1]-1] )

class UnionFind:
    def __init__(self, n):
        self.table = [-1]*n

    def _root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self._root(self.table[x])
            return self.table[x]

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            self.table[r1] += d2
        else:
            self.table[r1] = r2
            self.table[r2] += d1

ans = n*(n-1)//2
Ans = [ans]
uf = UnionFind(n)
for ab in Ab[-1:0:-1]:
    if not uf.find(ab[0], ab[1]):
        ans -= abs( uf.table[ uf._root(ab[0]) ]*uf.table[ uf._root(ab[1]) ])
        uf.union(ab[0], ab[1])
    Ans.append(ans)
for ans in Ans[-1::-1]:
    print(ans)

Measured memory_bytes: 111064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
using namespace std;
int n,l,r,mid,las,temp;
string s;
int main()
{
	cin >> n;
		printf("%d\n",0);
		cin >> s;
		if(s[0] =='V')
			return 0;
		else if(s[0] == 'M')
			las = 0;
		else
			las = 1;
		l = 1,r = n-1;
		while(l <= r)
		{
			mid = (l+r)>>1;
			printf("%d\n",mid);
			cin >> s;
			if(s[0] =='V')
				return 0;
			else if(s[0] == 'M')
				temp = 0;
			else
				temp = 1;
			if((mid-l)&1)
			{
				if(temp == las)
					l = mid+1;
				else
					r = mid-1;
			}
			else
			{
				if(temp == las)
					r = mid-1;
				else
				{
					l = mid+1;
					las = temp;
				}
			}
		}
	return 0;
}


Measured memory_bytes: 852
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define xx first
#define yy  second
#define MP make_pair
template <typename T> T gcd(T a, T b) {return !b ? a : gcd(b, a % b);}
template <typename T> T lcm(T a, T b) {return a * (b / gcd(a, b));}

const int N   = (int) 2e5 + 5;
using namespace std;
vector<int>prime;
bool pr[1000001];
void sieve(){
  for(int i =  2; i*i<=1000000; i++){

     if(pr[i]==0){
        for(int j = i*i; j<=1000000; j+=i)
             pr[j] = 1;
     }
  }

  for(int i  = 2; i<=1000000; i++){
    if(pr[i]==0){
        prime.pb(i);
    }
  }

  return ;

}

ll solve(int n){

  int last[20],first[20];
  memset(last,0,sizeof last);
  memset(first,0,sizeof first);
  int f;

  map< pair <int, int >,int >mp;
    for(int i = 1; i<=n; i++){
         int b = i;
          int l = b%10;
           if(l==0) continue;
         while(b>0){
            f = b%10;
            b/=10;
         }
         mp[{f,l}]++;
         //cout << i << " " << f << " " << l << endl;
    }

    int ans = 0;

    for(int i = 1; i<=n; i++){

           int b = i;
          int l = b%10;
           if(l==0) continue;
         while(b>0){
            f = b%10;
            b/=10;
         }
          ans +=mp[{l,f}];
    }

return ans;
}
int  main()
{
    //ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

     int t=1, n;
     //cin >> t;
     while(t--)
     {
         int n;
       cin >> n;
        cout<<solve(n)<<'\n';
     }



    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
    int n,d;
    long int p,q;
    int cnt=0;
    cin>>n>>d;
    for(int i=0;i<n;i++){
        cin>>p>>q;
        if(sqrt(p*p+q*q)<=d){
            cnt++;
        }
    }
    cout<<cnt;
}    
    

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

int main(){
    using namespace std;
    unsigned long N, M;
    cin >> N >> M;
    vector<unsigned long> D(N);
    for(auto& i : D)cin >> i;
    vector<unsigned long> edges(M);
    vector<vector<unsigned long>> edge(N);
    for(unsigned long i{0}, u, v; i < M; ++i){
        cin >> u >> v;
        edge[--u].push_back(i);
        edge[--v].push_back(i);
        edges[i] = u ^ v;
    }
    vector<unsigned long> ans(M, 1000000000);
    vector<unsigned long> uf(2 * N + 2), sz(2 * N + 2, 1);
    iota(uf.begin(), uf.end(), 0UL);
    const auto& find = [&uf](unsigned long i) -> unsigned long {
        while(i != uf[i])i = uf[i] = uf[uf[i]];
        return i;
    };
    const auto& unite = [&uf, &sz, &find](unsigned long i, unsigned long j) -> void {
        i = find(i);
        j = find(j);
        if(i == j)return;
        if(sz[i] < sz[j])swap(i, j);
        sz[i] += sz[j];
        uf[j] = i;
    };
    const auto& con = [&uf, &find](unsigned long i, unsigned long j) -> bool {
        return find(i) == find(j);
    };
    [&]{for(unsigned long i{0}; i < N; ++i)if([&]{
        for(auto j : edge[i])if(D[i] >= D[edges[j] ^ i]){
            ans[j] = D[i];
            unite(i, (edges[j] ^ i) + N);
            unite(i + N, (edges[j] ^ i));
            return false;
        }
        return true;
    }()){puts("-1");exit(0);}}();
    for(unsigned long i{0}; i < N; ++i)if(!con(i, 2 * N + 1)){
        unite(i, 2 * N);
        unite(i + N, 2 * N + 1);
    }
    for(unsigned long i{0}; i < N; ++i)putchar(66 + 21 * con(i, 2 * N));
    cout << endl;
    for(const auto& i : ans)cout << i << endl;
    return 0;
}

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

bool is_prime(long long N) {
  if (N == 1) return false;
  for (long long i = 2; i * i <= N; ++i) {
    if (N % i == 0) return false;
  }
  return true;
}

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

  int ans = 0;
  for (int i = 0; i < N; i++) {
    int A;
    cin >> A;
    if (is_prime(A)) ans++;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3080
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    int n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());

    ll dp[a[n-1]+1];
    memset(dp, 0, sizeof(dp));
    for (auto x : a) {
        for (int j = x; j <= a[n-1]; j += x) {
            dp[j]++;
        }
    }
    int ans = 0;
    rep(i,n) {
        if (dp[a[i]] == 1)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 12608
n = int(input())
A = list(map(int,input().split()))
b = []
if n%2==0:
    x = A[-1::-2]
    y = A[0::2]
    b.extend(x)
    b.extend(y)
else:
    x = A[-1::-2]
    y = A[1::2]
    b.extend(x)
    b.extend(y)
print(*b)

Measured memory_bytes: 26020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    ll X,Y,Z,K;
    cin >> X >> Y >> Z >> K;
    vector<ll> A(X);
    vector<ll> B(Y);
    vector<ll> C(Z);
    vector<ll> D;
  	rep(i,X)cin >> A[i];
  	rep(i,Y)cin >> B[i];
  	rep(i,Z)cin >> C[i];
    rep(i,X){
        rep(j,Y){
            D.push_back(A[i]+B[j]);
        }
    }
    sort(all(D));
    reverse(all(D));
    vector<ll> E;
    rep(i,min(K,(ll)D.size())){
        rep(j,Z){
            E.push_back(D[i]+C[j]);
        }
    }
    sort(all(E));
    reverse(all(E));
    rep(i,K){
        cout << E[i] << endl;
    }
}

/*



 */



Measured memory_bytes: 43240
import heapq

X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

Q = []
heapq.heappush(Q, (-(A[0]+B[0]+C[0]), 0, 0, 0))
registered = set()
registered.add((0, 0, 0))
for t in range(K):
    s, ai, bi, ci = heapq.heappop(Q)
    print(-s)

    if ai+1 < X and (ai+1, bi, ci) not in registered:
        heapq.heappush(Q, (-(A[ai+1]+B[bi]+C[ci]), ai+1, bi, ci))
        registered.add((ai+1, bi, ci))
    if bi+1 < Y and (ai, bi+1, ci) not in registered:
        heapq.heappush(Q, (-(A[ai]+B[bi+1]+C[ci]), ai, bi+1, ci))
        registered.add((ai, bi+1, ci))
    if ci+1 < Z and (ai, bi, ci+1) not in registered:
        heapq.heappush(Q, (-(A[ai]+B[bi]+C[ci+1]), ai, bi, ci+1))
        registered.add((ai, bi, ci+1))


Measured memory_bytes: 57564
a, b = map(int, input().split())
SUM = 0
if b < a:
    
    for i in range(a):
        SUM = SUM + (10**i) * b
    print(str(SUM))
elif a < b:
    for i in range(b):
        SUM = SUM + (10**i) * a
    print(str(SUM))
else:
    for i in range(a):
        SUM = SUM + (10**i) * a
    print(str(SUM))

Measured memory_bytes: 61104
#include <iostream>
#include <string>

int main(){
	std::string s;
	std::getline(std::cin, s);
	for(int i = 0; i < s.size()-4; ++i){
		if(s[i] != 'a' && s[i] != 'p')continue;
		else{
			if(s[i]=='a' && s[i+1]  == 'p' && s[i+2] == 'p' && s[i+3] == 'l' && s[i+4] == 'e'){
				s[i] = 'p';
				s[i+1] = 'e';
				s[i+2] = 'a';
				s[i+3] = 'c';
				s[i+4] = 'h';
				i+=4;
			}else if(s[i]=='p' && s[i+1]  == 'e' && s[i+2] == 'a' && s[i+3] == 'c' && s[i+4] == 'h'){
				s[i] = 'a';
				s[i+1] = 'p';
				s[i+2] = 'p';
				s[i+3] = 'l';
				s[i+4] = 'e';
				i+=4;
			}
			
		}
	}
	std::cout<<s<<std::endl;
}

Measured memory_bytes: 1172