akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


ll n, ans;
string s[100005];
map<string, ll> mp;

int main() {

	cin >> n;
	rep(i, n) {
		cin >> s[i];
		sort(s[i].begin(), s[i].end());
		mp[s[i]]++;
	}

	for (auto itr = mp.begin(); itr != mp.end(); itr++) {
		if (itr->se != 1) {
			ans += (itr->se * (itr->se - 1) / 2);
		}
	}

	cout << ans << endl;

	return 0;
}


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

int main(){
    string day;
    std::cin >> day;
    if (day == "SUN"){
        cout << 7 << endl;
    } else if (day == "MON"){
        cout << 6 << endl;
    } else if (day == "TUE"){
        cout << 5 << endl;
    } else if (day == "WED"){
        cout << 4 << endl;
    } else if (day == "THU"){
        cout << 3 << endl;
    } else if (day == "FRI"){
        cout << 2 << endl;
    } else {
        cout << 1 << endl;
    }
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x, n) bitset<n>(x)
#define PI 3.14159265358979323846

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

//-------------------------------------------------


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

	int a, b, c, d, p;
	cin >> a >> b >> c >> d >> p;
	cout << min(a * p, (p <= c ? b : b + (p - c) * d)) << endl;


    return 0;
}





Measured memory_bytes: 3164
import sys
from bisect import *
from collections import *
from copy import deepcopy
from datetime import *
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    a,b,x = map(int, input().split())
    if x <= a*a*b//2:
        # 断面の形は三角形
        c = x*2/(a*b)
        print(degrees(atan(b/c)))
    else:
        # 断面の形は台形
        # 上辺の長さをcとした時の体積は(c+b)*a//2*a
        # これがxと等しいのでcは以下の通り
        c = x*2/(a*a)-b
        print(degrees(atan((b-c)/a)))

if __name__ == '__main__':
    main()

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


int main(){
    int n;
    cin>>n;
    int c[n];
    for(int i =0; i < n; i++)
        cin>>c[i];
    int dp[n+1];
    dp[0] = 0;
    dp[1] = abs( c[1] - c[0] );

    for(int i= 2; i< n; i++)
        dp[i] = min(
                    dp[i-1] + abs( c[i] - c[i-1]),
                    dp[i-2] + abs( c[i] - c[i-2] )
                    );

    cout<<dp[n-1]<<endl;


    return 0;


}


Measured memory_bytes: 4340
fun main(args: Array<String>) {
  val a = readLine()!!.toInt()
  val b = readLine()!!.toInt()
  val c = readLine()!!.toInt()
  val x = readLine()!!.toInt()
  var ans = 0
  for (i in 0..a) {
    for (j in 0..b) {
      for (k in 0..c) {
        if (500 * i + 100 * j + 50 * k == x) ans++
      }
    }
  }
  println(ans)
}

Measured memory_bytes: 31696
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a),i##Len_=(b);i<i##Len_;i++)
#define ALL(x) (x).begin(),(x).end()
const char* LF = "\n";
template <class T> void chmin(T& a, const T& b) { if (b < a) a = b; }
namespace{struct _{_(){
    cin.tie(0);
    ios::sync_with_stdio(false);
}}a;}

// ----------------------------------------------------------------

auto nearest(vector<ll>& v, ll val) {
    auto lb = lower_bound(ALL(v), val);
    if (lb == v.end()) lb--;
    return lb;
}

vector<ll> S, T, X;

signed main() {
    ll A, B, Q;
    cin >> A >> B >>  Q;
    S.resize(A);
    T.resize(B);
    X.resize(Q);
    REP(i, A) { cin >> S[i]; }
    REP(i, B) { cin >> T[i]; }
    REP(i, Q) { cin >> X[i]; }

    for (ll x : X) {
        auto sb = nearest(S, x);
        auto sa = sb - ((sb != S.begin()) ? 1 : 0);
        auto tb = nearest(T, x);
        auto ta = tb - ((tb != T.begin()) ? 1 : 0);
        ll s[2] = {*sa, *sb};
        ll t[2] = {*ta, *tb};
        ll u[8][2];
        REP(i, 4) {
            u[i*2+0][0] = u[i*2+1][1] = s[i >> 1];
            u[i*2+0][1] = u[i*2+1][0] = t[i & 1];
        }

        ll ans = 1e16;
        REP(i, 8) {
            chmin(ans, abs(x - u[i][0]) + abs(u[i][0] - u[i][1]));
        }
        cout << ans << LF;
    }

    return 0;
}


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

/*
bool is_runrun(ll x){
    bool runrun = true;
    int keta = x%10;
    while(x!=0){
        int old_keta=keta;
        keta=x%10;
        if(old_keta-keta<= 1 && keta-old_keta<=1){
            x /= 10;
            continue;
        }
        else{
            runrun = false;
            break;
        }
    }
    return runrun;
}
*/

int main(){
    int k;
    cin >> k;
    
    queue<ll> q;
    for(int i=1; i<=9; i++){
        q.push(i);
    }
    ll front;
    for(int i=0; i<k; i++){
        front = q.front();
        if(front%10 != 0){
            q.push(10*front+(front%10)-1);
        }
        q.push(10*front+(front%10));
        if(front%10 != 9){
            q.push(10*front+(front%10)+1);
        }
        q.pop();
    }
    cout << front << endl;
}


Measured memory_bytes: 5128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
const int MOD = 1000000007;
int main() {
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if (k<=a)
    {
        /* code */
        cout<<k<<endl;
    }
    else if (k<=a+b+c)
    {
        /* code */
        int m=max(0,(k-a-b));
        cout<<a-m<<endl;
    }
    
    
    
    
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  REP1(i, 9) REP1(j, 9) {
    if (i * j == n) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(' ').map(String::toInt)
    val allHn = n * (n - 1) / 2
    if (k > allHn - (n - 1)) {
        println(-1)
        return
    }
    val hn = allHn - k

    val allH = mutableListOf<MutableList<Int>>()
    (1..n).forEach { allH.add(mutableListOf()) }

    for (i in 1 until n) {
        for (j in i + 1..n) {
            allH[i].add(j)
        }
    }
    var deleteNum = 0
    for (i in 1 until (n - 1)) {
        if (deleteNum == k) break
        for (j in i + 1 until n) {
            allH[i].remove(j)
            deleteNum++
            if (deleteNum == k) break
        }
        if (deleteNum == k) break
    }

    println(hn)
    for(i in 1 until n){
        for(j in allH[i]){
            println("$i $j")
        }
    }
}


Measured memory_bytes: 40296
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#include <chrono> 
using namespace std::chrono;
using namespace std;
typedef long long ll;
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ordered_mset tree<pair<ll,ll>, null_type,less<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define fr(i,a,b) for (ll i=(a); i<(b);++i)
#define frr(i,a,b) for(ll i=(a-1);i>=(b);--i)
#define vi vector<ll>
#define vl vector<ll>
#define pb push_back
#define ppb pop_back()
#define pf push_front
#define ppf pop_front()
#define F first
#define S second
#define pii pair<ll,ll> 
#define rev(a) reverse(a.begin(),a.end())
#define srt(a,k) sort(a,a+k,greater<ll>())
#define rsrt(a) sort(a.begin(),a.end(),greater<ll>())
#define sz(a) (ll)a.size()
//#define endl "\n"
#define po(a,b) (ll)(pow(a,b)+0.5)
#define double long double
#define print(a) for(auto x:a)cout<<x<<" ";cout<<endl;
#define setbits(a) __builtin_popcount(a)
const ll M=1e9+7;
const ll mxx=3001;

ll grid[mxx][mxx];
ll dp[mxx][mxx][4];
ll r,c,k;
ll dfs(ll row,ll col, ll num)
{
    ll ans=0;
    if(row==r && col==c)
    {
       if(num==3)return 0;
       else return grid[row][col];
    }
    if(dp[row][col][num]!=-1)return dp[row][col][num];
      if(grid[row][col]==0)
      {
          if(row!=r)ans=dfs(row+1,col,0);
          if(col!=c)ans=max(ans,dfs(row,col+1,num));
      }
      else
      {
          if(num==3)
          {
          if(row!=r)ans=dfs(row+1,col,0);
          if(col!=c)ans=max(ans,dfs(row,col+1,num));
          }
          else
          {
          if(col!=c)ans=max(dfs(row,col+1,num),grid[row][col]+dfs(row,col+1,num+1));
          if(row!=r)ans=max(ans,grid[row][col]+dfs(row+1,col,0));
          }
      }
      return dp[row][col][num]=ans;
}
int main()
{  
    

 cin>>r>>c>>k;
 memset(grid,0,sizeof grid);
 memset(dp,-1,sizeof dp);
 fr(i,0,k)
 {
   ll x,y,z;
   cin>>x>>y>>z;
   grid[x][y]=z;
 }
 cout<<dfs(1,1,0);

  
}



Measured memory_bytes: 355828
#include<bits/stdc++.h>
using namespace std;
typedef long long           ll;
ll numLen(ll K) 
{ 
    if (K % 2 == 0 || K % 5 == 0) 
        return -1; 
  
    ll number = 0; 
  
    ll len = 1; 
  
    for (len = 1; len <= K; len++) { 
        number = (number * 10 + 7) % K; 
      if (number == 0) 
            return len; 
    } 
  
    return -1; 
} 
void test_case()
{
  ll x;
  cin>>x; 
  ll ans=numLen(x); 
  cout<<ans<<"\n";

}
int main()
{
  cin.sync_with_stdio(0);
  cin.tie(0);
  cin.exceptions(cin.failbit);
  ll t;
  t = 1;
  while (t--)
  {
    test_case();
  }


  return 0;
}


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

int main(){
  string s;
  cin >> s;
  int cur = 0, ans = 0;
  rep(i,3) {
    if(s[i] == 'R') {
      cur++;
      ans = max(ans,cur);
    } else cur = 0;
  } 
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3584
#include<iostream>

using namespace std;

int main() {
  int M;
  int D;
  cin >> M;
  cin >> D;
  int count = 0;
  int d1;
  int d10;
  
  for (int i=1; i<M+1; i++) {
    for (int j=1; j<D+1; j++) {
      d10 = j/10;
      d1  = j%10;
      if (d10*d1 == i && d10>1 && d1>1) count++;
    }
  }
  
  cout << count;
}

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

const ll nax = 1e18;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    sort(all(a));
    if(a[0] == 0){
        cout<<0<<endl;
        return 0;
    }
    ll ans = 1;
    rep(i,n){
        if(ans > nax/a[i]){
            cout<<-1<<endl;
            return 0;
        }else{
            ans *= a[i];
        }
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3928
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Hawawa
    {
        static void Main(string[] args)
        {
            Scanner scanner = new Scanner();
            int n = scanner.nextInt();
            int k = scanner.nextInt();
            if(k == 1)
            {
                Console.WriteLine(0);
            }
            else
            {
                Console.WriteLine(n - k);
            }
        }
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

}

class XRand
{
    uint x, y, z, w;
    public XRand()
    {
        x = 314159265; y = 358979323; z = 846264338; w = 327950288;
    }
    uint next()
    {
        uint t = x ^ x << 11; x = y; y = z; z = w; return w = w ^ w >> 19 ^ t ^ t >> 8;
    }
    public int nextInt(int m)
    {
        return (int)(next() % m);
    }
    int nextInt(int a, int b)
    {
        return a + nextInt(b - a + 1);
    }
}

Measured memory_bytes: 13140
mod=998244353
fact=[1]
for i in range(1,2*10**5+1):
  fact.append((fact[-1]*i)%mod)
revfact=[1]
for i in range(1,2*10**5+1):
  revfact.append(pow(fact[i],mod-2,mod))
n,m,k=map(int,input().split())
ans=0
for i in range(k,-1,-1):
  group=n-i
  tmp=fact[n-1]*revfact[group-1]*revfact[n-1-(group-1)]
  tmp%=mod
  tmp*=m
  tmp%=mod
  tmp*=pow(m-1,group-1,mod)
  ans+=tmp
  ans%=mod
print(ans)

Measured memory_bytes: 86368
n, m = map(int,raw_input().split())
 
A = [[0 for j in range(m)] for i in range(n)]
b = [0 for j in range(m)]
 
for i in range(n):
  A[i] = map(int, raw_input().split())
for j in range(m):
  b[j] = input()
  
for i in range(n):
    c = 0
    for j in range(m):
        c += A[i][j] * b[j]
    print c

Measured memory_bytes: 6536
#include <set>
#include <iostream>
#include <cstring>
#include <cstdio>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

#define MAX (100)

using namespace std;

int T;
int t[30];
int n;
int m[100];
int memo[100][30];

int solve(int dd, int tt){
  if(dd == 100) return 0;
  if(memo[dd][tt] != -1) return memo[dd][tt];

  int ret = 100;
  if(m[dd] >= t[tt]){
    ret = min(ret, solve(dd + 1, (tt + 1) % T));
  }
  ret = min(ret, 1 + solve(dd + 1, 1 % T));
  return memo[dd][tt] = ret;
}


int main(){
  while(T = getInt()){
    REP(i,100) m[i] = MAX;
    REP(i,T) t[i] = getInt();
    n = getInt();
    memset(memo, -1, sizeof(memo));
    REP(i,n){
      int D = getInt();
      int M = getInt();

      m[D - 1] = min(m[D - 1], M);
    }
    int ans = solve(0, 0);
    printf("%d\n", ans);
  }
}

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

using namespace std;

string s;

int main(void)
{
	cin >> s;
	
	int ans = s.size();
	for(int i = 0; i < s.size()-1; i++){
		if(s[i] == s[i+1]) continue;
		ans = min( ans, max(i+1, (int)s.size()-i-1) );
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <sstream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
constexpr int MOD = 1000000007;
constexpr int INF = 1e18;

using namespace std;


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

  vector<tuple<int, int, int>> P(M);
  int a, b;
  REP(i, M) {
    cin >> a >> b;
    P[i] = make_tuple(a, b, i);
  }

  sort(ALL(P));
  int cnt = 1;
  REP(i, M){
    if(get<0>(P[i]) == get<0>(P[i-1])){
      cnt++;
    }else cnt = 1;
    get<1>(P[i]) = cnt;
  }

  sort(ALL(P),
      [](tuple<int, int, int> const & l, tuple<int, int, int> const &  r){
      return get<2>(l) < get<2>(r);
      });

  REP(i, M){
    printf("%06lld%06lld\n", get<0>(P[i]), get<1>(P[i]));
  }

  return 0;
}

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

using namespace std;
//int moreGcd
int N = 0;
int K = 0;

int main(){
    
    cin >> N;

    vector<vector<int> > T;
    T = vector<vector<int> >(N + 1, vector<int>(3, 0));

    for(int i = 1; i <= N; i++){
        for(int j = 0;  j < 3; j++){
            cin >> T[i][j];
        }
    }

    int ans = 0;
    vector<vector<int> > dp;
    dp = vector<vector<int> >(N + 1, vector<int>(3, 0));

    for(int i = 1; i <= N; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(!(k == j)) dp[i][j] = max(dp[i][j], dp[i - 1][k] + T[i][j]);
            }
            if(ans < dp[i][j]){
                ans = dp[i][j];
            }
        }
    }

    /*
    for(int i = 0; i <= N; i++){
        for(int j = 0;  j < 3; j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    */
    
    cout << ans << endl;

}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
int n,l,a[100010];
int main()
{
	scanf("%d%d",&n,&l);
	for (int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	int mx=0;
	for (int i=1;i<n;i++)
	{
		mx=max(mx,a[i]+a[i+1]);
	}
	if (mx<l)
	{
		puts("Impossible");
		return 0;
	}
	puts("Possible");
	for (int i=1;i<n;i++)
	{
		if (a[i]+a[i+1]==mx)
		{
			for (int j=n-1;j>i;j--)
			{
				printf("%d\n",j);
			}
			printf("%d\n",i);
			return 0;
		}
		printf("%d\n",i);
	}
	return 0;
}
//还将旧时意，怜取眼前人。
//——元稹《崔莺莺》

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
using P = pair<int, int>;
const ll inf =1e9;

struct edge{
    int to;
    int cost;
};
using graph = vector<vector<edge>>;

int main(){
    int n, m; cin >> n >> m;
    priority_queue<ll> que;
    for(int i=0; i<n; i++){
        ll tmp; cin >> tmp; 
        que.push(tmp);
    }
    for(int i=0; i<m; i++){
        ll discounted = que.top();
        que.pop();
        que.push(discounted/2);
    }
    ll ans = 0;
    for(int i=0; i<n; i++){
        ans += que.top();
        que.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
int main() {
    string s, t;
    cin >> s >> t;
    vector<int> s_sum(100010), t_sum(100010);
    for(int i=0;i<s.size();i++) {
        int add;
        if(s[i] == 'A') add = 1;
        else add = 2;
        s_sum[i+1] = s_sum[i] + add;
    }
    for(int i=0;i<t.size();i++) {
        int add;
        if(t[i] == 'A') add = 1;
        else add = 2;
        t_sum[i+1] = t_sum[i] + add;
    }


    int q;
    cin >> q;
    vector<string> ans;
    for(int i=0;i<q;i++) {
        int a, b, c, d, num_s, num_t;
        cin >> a >> b >> c >> d;

        num_s = s_sum[b] - s_sum[a-1];
        num_t = t_sum[d] - t_sum[c-1];
        if(abs(num_s-num_t)%3 == 0)
            ans.push_back("YES");
            //cout << "YES" << endl;
        else
            ans.push_back("NO");
            //cout << "NO" << endl;
    }
    for(int i=0;i<q;i++) 
        cout << ans[i] << endl;
}


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

int main() {
  int a,b,d,r;
  double f;
  cin >> a >> b;
  d = a/b;
  r = a%b;
  f = (double)a/b;
  cout << fixed << setprecision(8) << d << " " << r << " " << f << endl;
  return 0;
}


Measured memory_bytes: 3288
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include<tuple>
#include<iomanip>
//AtCoderC++.cpp

using namespace std;

template<typename T> void Show(const vector<vector<T>>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].size(); j++) {
			cout << v[i][j];
			if (j != v[i].size() - 1) {
				cout << delimiter;
			} else {
				cout << endl;
			}
		}
	}
}
template<typename T> void Show(const vector<T>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		cout << v[i];
		if (i != v.size() - 1) {
			cout << delimiter;
		} else {
			cout << endl;
		}
	}
}
template<typename T> vector<T> getUniform(T value, int n) {
	vector<vector<T>> ts;
	ts.resize(n);
	for (int i = 0; i < n; i++) {
		ts[i] = value;
	}
	return ts;
}
template<typename T> vector<vector<T>> getUniform(T value, int row, int col) {
	vector<vector<T>> ts;
	ts.resize(row);
	for (int i = 0; i < row; i++) {
		ts[i].resize(col);
		for (int j = 0; j < col; j++) {
			ts[i][j] = value;
		}
	}
	return ts;
}
bool All(vector<vector<bool>> ts) {
	int h = ts.size();
	int w = ts[0].size();
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			if (!ts[i][j])return false;
	return true;
}

vector<string> split(string& content, char delim) {
	auto ss = vector<string>();
	string s = "";
	for (size_t i = 0; i < content.length(); i++) {
		if (content[i] == delim) {
			ss.push_back(s);
			s = "";
			continue;
		}
		s += content[i];
	}
	if (s != "")ss.push_back(s);
	return ss;
}

int main() {
	int n, x; cin >> n >> x;
	auto ls = vector<int>(n);
	for (size_t i = 0; i < n; i++) {
		cin >> ls[i];
	}
	auto ds = vector<int>(n + 1); ds[0] = 0;
	for (size_t i = 0; i < n; i++) {
		ds[i + 1] = ds[i] + ls[i];
	}
	int count = 0;
	for (auto d : ds)if (x >= d)count++;
	cout << count << endl;
}



Measured memory_bytes: 256
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

void main(){
    int h, w;
    readlnTo(h, w);
    string[] a;
    foreach(i; iota(h)) {
        a ~= readln().chomp();
    }
    int c;
    foreach(i; iota(h)) {
        foreach(j; iota(w)) {
            if(a[i][j] == '#') {
                ++c;
            }
        }
    }
    writeln(c == h+w-1 ? "Possible": "Impossible");
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#include <math.h>

int main() {

	string S,T;
	string ans;
	cin >> S >> T;

	T.pop_back();

	ans = "No";

	if (S == T) {
		ans = "Yes";
	}
	
	

	cout << ans << endl;

	cin >> S;

	return 0;


}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;
using std::swap;

int main() {
	long long int a,b,c,d,t;
	long long int L, R;
	cin >> L >> R;
	if (R - L >= 2018)cout << 0 << "\n";
	else {
		a = L / 2019;
		b = L % 2019;
		c = R / 2019;
		d = R % 2019;
		if (a != c)t = 0;
		else {
			t = 2019;
			for (int i = b; i < d; ++i) {
				for (int j = i + 1; j < d + 1; ++j) {
					if (i*j % 2019 < t)t = i * j % 2019;
				}
			}
		}
		cout << t << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>

int main() {
	std::string s; std::cin >> s;
	int count = 0; int count2 = 0;
	for (int i = 0; i < s.size(); ++i)
		if (s[i] - '0' == i % 2) ++count;
	for (int i = 0; i < s.size(); ++i)
		if (s[i] - '0' != i % 2) ++count2;
	std::cout << std::min(count, count2) << std::endl;

	return 0;
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
 ll N,B;
  cin>>N>>B;
  if(N>12) {
cout<<B<<endl;
  }
  else if(N>5) {
cout<<B/2<<endl;
  }
  else {
    cout<<0<<endl;
  }
}

Measured memory_bytes: 3624
using System;
using static System.Console;
using System.Linq;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] tmp = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int A = tmp[0];
            int B = tmp[1];
            WriteLine(A > 9 || B > 9 ? -1 : A * B);
        }
    }
}

Measured memory_bytes: 13396
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;

struct edge{int to,cost;};

const int MOD=1e9+7;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);

	int n,m;
	cin >> n >> m;

	if(abs(n-m) >= 2) cout << "0\n";
	else{
		long long ans=1;
		
		for(int i=n;i>=2;i--){
			ans*=i;
			ans%=MOD;
		}
		for(int i=m;i>=2;i--){
			ans*=i;
			ans%=MOD;
		}
		if(n==m){
			ans *= 2;
			ans %= MOD;
		}
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct _I { _I() {cin.tie(0);ios::sync_with_stdio(false);}} __I;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> inline void sort_uniq(T& c) { sort(all(c)); c.erase(unique(all(c)), c.end()); }
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

int main()
{
    int N; cin >>N;
    vpii ab(N), cd(N);  
    rep(i, N) cin >> ab[i].first >> ab[i].second; // first:x, second:y
    rep(i, N) cin >> cd[i].first >> cd[i].second;

    // xが最大の赤を選ぶ
    // ペアになれる青の中で、yが最小のものをペアとする
    // O(N*N)

    sort(all(ab), greater<pii>());
    sort(all(cd));

    vector<bool> cd_used(N, false);

    int ans = 0;
    rep(i, N) {
        int blue_y = INT_MAX;
        int blue = -1;
        rep(j, N) {
            if (cd_used[j]) continue;
            if (ab[i].first < cd[j].first && ab[i].second < cd[j].second) {
                if (chmin(blue_y, cd[j].second)) {
                    blue = j;
                }
            }
        }
        if (blue != -1) {
            ans++;
            cd_used[blue] = true;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
N, Y = map(int, input().split())

for x in range(N + 1):
    for y in range(N - x + 1):
        z = N - x - y
        if 0 <= z <= 2000 and 10000 * x + 5000 * y  + 1000 * z == Y:
            print(x, y, z)
            exit()
print(-1, -1, -1)


Measured memory_bytes: 2940
def main():
    from itertools import accumulate
    n, c, *stc = map(int, open(0).read().split())
    table = [0] * (10 ** 5 + 2)
    m = sorted(list(zip(*[iter(stc)] * 3)), key=lambda a: (a[2], a[0], a[1]))

    ch_ = 0
    t_ = 0
    for s, t, ch in m:
        if ch != ch_:
            ch_ = ch
            t_ = 0
        if t_ == s:
            table[t_ + 1] += 1
        else:
            table[s] += 1

        table[t + 1] -= 1
        t_ = t

    *x, = accumulate(table)
    ans = max(x)

    print(ans)


if __name__ == '__main__':
    main()


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

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define rept(i,n) for(ll (i)=0;(i)<=(ll)(n);(i)++)
#define reps(i,s,n) for(ll (i)=(s);(i)<(ll)(n);(i)++)
#define repst(i,s,n) for(ll (i)=(s);(i)<=(ll)(n);(i)++)
#define repr(i,n) for(ll (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\???
// .???.:( ^??^)?????????.???.:( ^??^)?????????.???.:( ^??^)?????????.???.:( ^??^)?????????.???.:( ^??^)?????????
// ?????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\????????????????????\??????????????????

int h, w, c[1400][1400], dp[1400][1400], r;

int main() {
	cin >> h >> w;
	rep(i,h) rep(j,w) cin >> c[i][j];
	rep(i,h) if (!c[i][0]) dp[i][0] = 1, r = 1;
	rep(i,w) if (!c[0][i]) dp[0][i] = 1, r = 1;
	rep(i,h-1) {
		rep(j,w-1) {
			if (!c[i+1][j+1]) dp[i+1][j+1] = min(dp[i][j], min(dp[i][j+1], dp[i+1][j])) + 1;
			chmax(r, dp[i+1][j+1]);
		}
	}
	cout << r*r << ln;
}

Measured memory_bytes: 16260
s = input()
t = input()
ls = len( s)
lt = len( t)
CNT = [ [0]*(ls+1) for _ in range(lt+1)]
for i in range(1,lt+1):
    for j in range(1,ls+1):
        if s[j-1] == t[i-1]:
            CNT[i][j] = CNT[i-1][j-1]+1
        else:
            if CNT[i][j-1] >= CNT[i-1][j]:
                CNT[i][j] = CNT[i][j-1]
            else:
                CNT[i][j] = CNT[i-1][j]
i = lt
j = ls
ans = ""
while i > 0 and j > 0:
    if t[i-1] == s[j-1]:
        ans += t[i-1]
        i -= 1
        j -= 1
    else:
        if CNT[i-1][j] > CNT[i][j-1]:
            i -= 1
        else:
            j -= 1
print( ans[::-1])

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

using ll = long long;
#define f first
#define s second

#ifndef LOCAL
	#define cerr if(0) cerr
#endif

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(nullptr);
	
	int x;
	cin >> x;

	if (x >= 30)
		cout << "Yes\n";
	else
		cout << "No\n";
}


Measured memory_bytes: 3616
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main{
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        
        String line;

        while((line = br.readLine()) != null){
            String[] input = line.split(",");
            int[] cards = new int[5];

            // 特殊なstraight判定
            int[] special = {1,10,11,12,13};

            for(int i = 0; i < 5; i++){
                cards[i] = Integer.parseInt(input[i]);
            }

            Arrays.sort(cards);

            int tmp = 0;    // 比較対象の数字
            int same = 0;   // 前の数字と一致する回数
            boolean gtTwo = false; // 数字の一致する枚数が3枚以上かどうか
            boolean gtThree = false; // 数字の一致する枚数が4枚以上かどうか
            int count = 1;  // 今何枚連続で一致しているか

            for(int x : cards){
                if(tmp == x){
                    same++;
                    count++;
                    if(count > 2) gtTwo = true;
                    if(count > 3) gtThree = true;
                }else{
                    tmp = x;
                    count = 1;
                }
            }

            if(same == 3){
                if(gtThree){
                    System.out.println("four card");
                }else{
                    System.out.println("full house");
                }
            }else if(same == 2){
                if(gtTwo){
                    System.out.println("three card");
                }else{
                    System.out.println("two pair");
                }
            }else if(same == 1){
                System.out.println("one pair");
            }else if(same == 0){
                boolean isStraight = true;
                int run = cards[0];
                for(int i = 1; i < 5; i++){
                    if(cards[i] - run != 1){
                        isStraight = false;
                        break;
                    }
                    run = cards[i];
                }

                if(isStraight || Arrays.equals(cards, special)){
                    System.out.println("straight");
                }else{
                    System.out.println("null");
                }
            }

        } // end of while

    }
}


Measured memory_bytes: 24220
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 1000000000;
int main()
{
  ios::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
  ll n;
  cin>>n;
  n*=3;
  ll a[n];
  rep(i,n) cin >> a[i];
  sort(a,a+n);
  ll ans = 0;
  for(int i=n-2;i>n/3-1;i=i-2) {
      ans+= a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  if ((max(a,b) > c) && (c > min(a,b))) {
    printf("Yes");
  } else {
    printf("No");
  }
  printf("\n");
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solverS.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split(" ");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		int X = Integer.parseInt(strArr[0]);
		initPrimeNums(X);
		int ans = X;
		for (; ans > 1 && (!check(ans)); ans--) {
		}
		System.out.println(ans);
	}

	ArrayList<Integer> PrimeNums;

	private void initPrimeNums(int x) {
		int[] pnchk = new int[x + 1];
		PrimeNums = new ArrayList<Integer>();
		for (int i = 2; i < pnchk.length; i++) {
			if (pnchk[i] >= 0) {
				for (int j = i + i; j < pnchk.length; j += i)
					pnchk[j] = -1;
				PrimeNums.add(i);
			}
		}
		// for (int i : PrimeNums)
		// System.out.print(" " + i);
		// System.out.println();
	}

	private boolean check(int num) {
		HashMap<Integer, Integer> fact = factorization(num);
		int p = 0;
		for (int b : fact.keySet()) {
			// System.out.println(num + " " + b + " " + fact.get(b));
			if (fact.get(b) < 2)
				return false;
			if (p == 0)
				p = fact.get(b);
			if (p != fact.get(b))
				return false;
		}
		return true;
	}

	private HashMap<Integer, Integer> factorization(int num) {
		HashMap<Integer, Integer> ret = new HashMap<Integer, Integer>();
		for (int n = num; n > 1;) {
			for (int b : PrimeNums) {
				if (n % b == 0) {
					n /= b;
					if (ret.containsKey(b))
						ret.put(b, ret.get(b) + 1);
					else
						ret.put(b, 1);
				}
			}
		}
		return ret;
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


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

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

  string s;
  cin >> s;
  ll cnt = 0;
  for (auto&& i : s) {
    if (i == 'B') cnt++;
  }
  ll pos = s.length()-cnt;
  ll ans = 0;
  rep(i, s.length()) {
    if (s[i] == 'B') {
      ans += pos-i;
      pos++;
    }
  }
  cout << ans << endl;
}


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


using namespace std;

int main() {

	int N;
	string S;
	cin >> N;
	cin >> S;
	int count = 0;
	for (int i = 0; i < S.length(); i++) {

		if (S[i] == 'A') {
			if (S[i + 1] == 'B' && S[i + 2] == 'C') {
				count++;
			}
		}

	}



	cout << count;

	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define RNG(i,from,to) for(ll i=(from); i<(ll)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;

int main(int argc, char const *argv[])
{
  ll N, D, X, C; cin >> N >> D >> X;
  REP(i, N) {
    cin >> C;
    for (ll d = 1; d <= D; d += C) {
      X += 1;
    }
  }
  cout << X << endl;
  return 0;
}


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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF   = 1e9;
const ll  INFLL = 1e18;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int main()
{
    ios::sync_with_stdio(false);

    int N, M; cin >> N >> M;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    
    int ans = 0, idx = 0;
    while (true) {
        int mn = INF, mx = 0;

        rep(i, M) {
            mn = min(mn, A[idx]);
            mx = max(mx, A[idx]);
            idx = (idx + 1) % N;
        }

        ans += (mx - mn);
        if (idx == 0) break;
    }

    cout << ans << endl;
}

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

using namespace std;

int main(void) {
    int A, B, C, pA, pB, pC, ans = 0;
    cin >> A >> B >> C;
    pA = A; pB = B; pC = C;

    bool flag = true;
    while (flag) {
        if ((A % 2) || (B % 2) || (C % 2)) break;
        A = (pB + pC) / 2;
        B = (pC + pA) / 2;
        C = (pA + pB) / 2;
        if (A == pA && B == pB && C == pC) flag = false;
        pA = A; pB = B; pC = C;
        ans++;
    }

    if (flag) cout << ans << endl;
    else cout << "-1" << endl;

    return 0;
}

Measured memory_bytes: 256
fn main() {
    let std_in = std::io::stdin();
    let mut br = std::io::BufReader::new(std_in.lock());

    let tmp = rvn::<i32>(&mut br);
    let (N, K) = (tmp[0], tmp[1]);
    let mut sm = 0.0;
    for i in 1..N+1 {
        let mut bb = 1;
        while i * bb < K {
            bb *= 2;
        }
        sm += 1.0 / bb as f64;
    }
    println!("{}", sm / N as f64);
}


//////////////////////////////////////////////////////////////////////////////////
use std::io::{BufReader, BufRead, StdinLock};

#[allow(dead_code)]
fn rs(br: &mut BufReader<StdinLock>) -> Vec<char> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().chars().collect()
}

#[allow(dead_code)]
fn rn<T: std::str::FromStr>(br: &mut BufReader<StdinLock>) -> T {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

#[allow(dead_code)]
fn rvs(br: &mut BufReader<StdinLock>) -> Vec<Vec<char>> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|e| e.chars().collect()).collect()
}

#[allow(dead_code)]
fn rvn<T: std::str::FromStr>(br: &mut BufReader<StdinLock>) -> Vec<T> {
    let mut buf = String::new();
    br.read_line(&mut buf).ok();
    buf.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}



Measured memory_bytes: 4352
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		final int[] p = new int[n + 1];
		for (int i = 1; i <= n * (n - 1) / 2; i++) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int d = sc.nextInt();
			if (c > d)
				p[a] += 3;
			else if (c < d)
				p[b] += 3;
			else {
				p[a]++;
				p[b]++;
			}
		}
		int r[] = new int[n + 1];
		Integer[] num = new Integer[n];
		for (int i = 0; i < n; i++) {
			num[i] = i + 1;
		}
		Arrays.sort(num, new Comparator<Integer>() {
			public int compare(Integer a, Integer b) {
				return p[b] - p[a];
			}
		});
		// System.out.println(Arrays.toString(num));
		int rank = 0;
		int score = -1;
		for (int i = 0; i < n; i++) {
			if (score != p[num[i]]) {
				rank = i + 1;
				score = p[num[i]];
			}
			r[num[i]] = rank;
		}
		for (int i = 1; i <= n; i++) {
			System.out.println(r[i]);
		}
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

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

	int n;
	cin >> n;

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

	sort(a.begin(), a.end());
	if(n == 1){
		cout << 1 << endl;
		exit(0);
	}

	if(a[0] == 1){
		if(a[1] == 1){
			cout << 0 << endl;
		}else{
			cout << 1 << endl;
		}
		exit(0);
	}

	vector<bool> isok(1010101, true);
	int ans = 0;
	for(int i = 0; i < n; i++){
		int x = a[i];

		if(isok[x]){
			if(i+1 == n || a[i+1] != a[i]){
				ans++;
			}
			for(int j = x; j < 1010101; j += x) isok[j] = false;
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 4308
#include <iostream>
#include <cstdio>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>

using namespace std;

void solve()
{
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		if (i % 3 == 0)
		{
			cout << " " << i;
			continue;
		}
		int x = i;
		while (x)
		{
			if (x % 10 == 3)
			{
				cout << " " << i;
				break;
			}
			x /= 10;
		}
	}
	cout << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1164
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
//もう二度とつかわん//
//    ↓ ↓　↓　　 //
#define ll long long
//    ↑　↑　↑    //
//フェルマー方程式の恨み//
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar(); getchar();return 0;
using namespace std;
bool prime(ll n) {
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	if (n != 1)return true;
	return false;
}
signed main() {
	ll n;
	cin >> n;
	ll cnt = 0;
	for (int i = 2; i <= 55555; i++) {
		if (prime(i) && i % 5 == 1) {
			cout << i << " ";
			cnt++;
		}
		if (cnt == n)break;
	}
	ggr
}

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> c[3];
    rep(i, n)
    {
        if (s[i] == 'R')
            c[0].push_back(i);
        else if (s[i] == 'G')
            c[1].push_back(i);
        else
            c[2].push_back(i);
    }

    ll ans = 0;

    vector<int> p = {0, 1, 2};

    do
    {
        rep(i, c[p[0]].size())
        {
            rep(j, c[p[1]].size())
            {
                if (c[p[0]][i] >= c[p[1]][j])
                    continue;

                auto itr = upper_bound(ALL(c[p[2]]), c[p[1]][j]);

                int key = 2 * c[p[1]][j] - c[p[0]][i];

                if (binary_search(itr, c[p[2]].end(), key))
                    ans += c[p[2]].end() - itr - 1;
                else
                    ans += c[p[2]].end() - itr;
            }
        }
    } while (next_permutation(ALL(p)));

    OP(ans);

    return 0;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;


int main() {
    int n, m; cin >> n >> m;
    map<int, int> sum, red;

    for(int i = 1; i <= n; i++) sum[i]++;
    red[1]++;

    for(int i = 0; i < m; i++){
        int x, y; cin >> x >> y;
        if(red[x]){
            red[y]++;
            sum[y]++;
            sum[x]--;
            if(sum[x] == 0) red[x] = 0;
        }else{
            sum[x]--;
            sum[y]++;
        }
    }

    int ans = 0;
    for(auto p : red){
        if(p.second) ans++;
    }
    cout << ans << endl;

    return 0;
}


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

int64_t lucas(int64_t N, int64_t a, int64_t b) {
  if (N == 0) {
    return a;
  } else if (N == 1) {
    return b;
  }
  lucas(N - 1, b, a + b);
}

int non_tailrec_lucas(int N) {
  if (N == 0) {
    return 2;
  } else if (N == 1) {
    return 1;
  } else {
    return non_tailrec_lucas(N - 1) + non_tailrec_lucas(N - 2);
  }
}

int main() {
  int N;
  cin >> N;
  cout << lucas(N, 2, 1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;

int main(){
  string s;
  cin >> s;
  int mi = 1e9;
  for (int i = 0; i < s.size() - 2; i++) {
    int tmp = stoi(s.substr(i, 3));
    mi = min(mi, abs(tmp - 753));
  }
  cout << mi << endl;
  return 0;
}


Measured memory_bytes: 256